Skip to content

Commit

Permalink
Added option to selection buttons for progress bar. Added CSV export …
Browse files Browse the repository at this point in the history
…header.
  • Loading branch information
mgroeneweg committed Oct 27, 2017
1 parent a95948f commit d588b6c
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ Make sure that the default button is always allowed.
- _Class_ - Optional. Specify class(es) to be put on the button
- _Glyphicon classes_ - Optional. Glyphicon classes, like __glyphicon glyphicon-edit__
- _Button microflow_ - The name of the microflow (Module.Microflow) that is called when the button is clicked
- _Show progress_ - Show progress bar

#### Confirmation

Expand Down
5 changes: 5 additions & 0 deletions src/DataTables/DataTables.xml
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,11 @@
<description>The microflow that is called when the button is clicked</description>
<returnType type="Void"></returnType>
</property-->
<property key="showProgress" type="boolean" defaultValue="false">
<caption>Show progress</caption>
<category>Button</category>
<description>Show progress bar</description>
</property>
<property key="askConfirmation" type="boolean" defaultValue="false">
<caption>Ask confirmation</caption>
<category>Confirmation</category>
Expand Down
49 changes: 36 additions & 13 deletions src/DataTables/widget/DataTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ define([
}
dojoOn(button, "click", function () {
var guids = thisObj._getSelectedRows();
thisObj._callButtonMicroflow(buttonDefinition, guids);
thisObj._handleButtonClick(buttonDefinition, guids);
});
thisObj._buttonList.push(button);
}, thisObj);
Expand All @@ -548,7 +548,7 @@ define([
// Add click handler for default button
if (thisObj._defaultButtonDefinition) {
$(tableNodeList).on("dblclick", "tr", function () {
thisObj._callButtonMicroflow(thisObj._defaultButtonDefinition, [this.getAttribute("data-guid")]);
thisObj._handleButtonClick(thisObj._defaultButtonDefinition, [this.getAttribute("data-guid")]);
});
}

Expand Down Expand Up @@ -634,8 +634,9 @@ define([
logger.debug("Export MF callback");
thisObj._hideProgress();
},
error: function () {
error: function (error) {
logger.error("Call to " + thisObj.exportMicroflow + " ended in error");
console.dir(error);
thisObj._hideProgress();
}
});
Expand Down Expand Up @@ -722,26 +723,48 @@ define([
},

// call button microflow
_callButtonMicroflow: function (buttonDefinition, guids) {
_handleButtonClick: function (buttonDefinition, guids) {
var thisObj = this;
if (buttonDefinition.askConfirmation) {
mx.ui.confirmation({
content: buttonDefinition.confirmationQuestion,
proceed: buttonDefinition.proceedCaption,
cancel: buttonDefinition.cancelCaption,
handler: function () {
thisObj._clearSelection();
mx.data.action({
params : {
applyto : "selection",
actionname : buttonDefinition.buttonMicroflowName,
guids : guids
}
});
thisObj._callButtonMicroflow(buttonDefinition, guids);
}
});
} else {
this._callButtonMicroflow(buttonDefinition, guids);
}
},

// call button microflow
_callButtonMicroflow: function (buttonDefinition, guids) {
var thisObj = this;

this._clearSelection();
if (buttonDefinition.showProgress) {
this._showProgress();
mx.data.action({
params : {
applyto : "selection",
actionname : buttonDefinition.buttonMicroflowName,
guids : guids
},
callback: function () {
thisObj._hideProgress();
},
error: function (error) {
logger.error("Call to " + buttonDefinition.buttonMicroflowName + " ended in error");
console.dir(error);
thisObj._hideProgress();
},
onValidation: function () {
thisObj._hideProgress();
}
});
} else {
this._clearSelection();
mx.data.action({
params : {
applyto : "selection",
Expand Down
Binary file modified test/DataTablesTest.mpr
Binary file not shown.
5 changes: 5 additions & 0 deletions test/javasource/datatablesexportdata/ExportDataImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ private void writeHeaderToCsv() throws IOException {
if (logger.isTraceEnabled()) {
logger.trace(logPrefix + "start");
}

String customHeader = Constants.getCSV_EXPORT_HEADER();
if (customHeader != null && !customHeader.trim().isEmpty()) {
tempFileWriter.write(customHeader + "\r\n");
}

boolean firstColumnHeader = true;
for (ExportDataColumn exportDataColumn : columnList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ public class Constants
{
// These are the constants for the DataTablesExportData module

/**
* Custom header to include in exported CSV data. Do not include a newline character.
*/
public static java.lang.String getCSV_EXPORT_HEADER()
{
return (java.lang.String)Core.getConfiguration().getConstantValue("DataTablesExportData.CSV_EXPORT_HEADER");
}

public static java.lang.String getLOGNODE_DATATABLES_EXPORT()
{
return (java.lang.String)Core.getConfiguration().getConstantValue("DataTablesExportData.LOGNODE_DATATABLES_EXPORT");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,19 @@ public static void aCT_TestDataTypes_Edit_Popup(IContext context, datatablestest
throw new MendixRuntimeException(e);
}
}
public static void aCT_TestDataTypes_Edit_Popup_LongRunning(IContext context, datatablestestmodule.proxies.TestDataTypes _testDataTypes)
{
try
{
Map<java.lang.String, Object> params = new HashMap<java.lang.String, Object>();
params.put("TestDataTypes", _testDataTypes == null ? null : _testDataTypes.getMendixObject());
Core.execute(context, "DataTablesTestModule.ACT_TestDataTypes_Edit_Popup_LongRunning", params);
}
catch (CoreException e)
{
throw new MendixRuntimeException(e);
}
}
public static void aCT_TestDataTypes_Save(IContext context, datatablestestmodule.proxies.TestDataTypes _testDataTypes)
{
try
Expand Down
Binary file modified test/widgets/DataTables.mpk
Binary file not shown.

0 comments on commit d588b6c

Please sign in to comment.