diff --git a/workflow/engine/content/translations/english/processmaker.en.po b/workflow/engine/content/translations/english/processmaker.en.po index e13aec174..3bacc36a7 100644 --- a/workflow/engine/content/translations/english/processmaker.en.po +++ b/workflow/engine/content/translations/english/processmaker.en.po @@ -20087,6 +20087,24 @@ msgstr "User has been updated successfully" msgid "Off" msgstr "Off" +# TRANSLATION +# LABEL/ID_OFFLINE_TABLES +#: LABEL/ID_OFFLINE_TABLES +msgid "Offline Tables" +msgstr "Offline Tables" + +# TRANSLATION +# LABEL/ID_OFFLINE_TABLES_ENABLE +#: LABEL/ID_OFFLINE_TABLES_ENABLE +msgid "Set Offline" +msgstr "Set Offline" + +# TRANSLATION +# LABEL/ID_OFFLINE_TABLES_DISABLE +#: LABEL/ID_OFFLINE_TABLES_DISABLE +msgid "Set Online" +msgstr "Set Online" + # TRANSLATION # LABEL/ID_OF_THE_MONTH #: LABEL/ID_OF_THE_MONTH diff --git a/workflow/engine/controllers/pmTablesProxy.php b/workflow/engine/controllers/pmTablesProxy.php index 3d59b1cc3..d9d3e660d 100644 --- a/workflow/engine/controllers/pmTablesProxy.php +++ b/workflow/engine/controllers/pmTablesProxy.php @@ -1,6 +1,7 @@ rows)); + $data = []; + $enable = false; + foreach ($array as $value) { + if ($value->type !== "NORMAL") { + $data[] = $value->id; + $enable = $value->offline ? 1 : 0; + } + } + AdditionalTablesModel::updatePropertyOffline($data, $enable); + $result->success = true; + $result->message = $enable ? G::LoadTranslation("ID_ENABLE") : G::LoadTranslation("ID_DISABLE"); + } catch (Exception $e) { + $result->success = false; + $result->message = $e->getMessage(); + } + return $result; + } + /** * delete pm table * diff --git a/workflow/engine/data/mysql/insert.sql b/workflow/engine/data/mysql/insert.sql index 8404ddb27..f35f5bc2a 100644 --- a/workflow/engine/data/mysql/insert.sql +++ b/workflow/engine/data/mysql/insert.sql @@ -60216,6 +60216,9 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_OBJECT_REMOVE','en','Object has been removed successfully','2014-01-15') , ( 'LABEL','ID_OBJECT_UPDATE','en','User has been updated successfully','2014-01-15') , ( 'LABEL','ID_OFF','en','Off','2014-01-15') , +( 'LABEL','ID_OFFLINE_TABLES','en','Offline Tables','2019-12-19') , +( 'LABEL','ID_OFFLINE_TABLES_ENABLE','en','Set Offline Tables','2019-12-19') , +( 'LABEL','ID_OFFLINE_TABLES_DISABLE','en','Set Online Tables','2019-12-19') , ( 'LABEL','ID_OF_THE_MONTH','en','of the month(s)','2014-01-15') , ( 'LABEL','ID_OK','en','Ok','2015-09-17') , ( 'LABEL','ID_OLD_VERSION','en','old version','2014-01-15') , diff --git a/workflow/engine/src/ProcessMaker/Model/AdditionalTables.php b/workflow/engine/src/ProcessMaker/Model/AdditionalTables.php index 535387053..c25583b75 100644 --- a/workflow/engine/src/ProcessMaker/Model/AdditionalTables.php +++ b/workflow/engine/src/ProcessMaker/Model/AdditionalTables.php @@ -90,4 +90,16 @@ class AdditionalTables extends Model return $data; } + + /** + * Update the offline property. + * @param array $tablesUid + * @param int $value + * @return void + */ + public static function updatePropertyOffline(array $tablesUid, $value): void + { + $query = AdditionalTables::whereIn('ADD_TAB_UID', $tablesUid) + ->update(['ADD_TAB_OFFLINE' => $value]); + } } diff --git a/workflow/engine/templates/pmTables/edit.js b/workflow/engine/templates/pmTables/edit.js index 23f6b7165..843d1abe6 100644 --- a/workflow/engine/templates/pmTables/edit.js +++ b/workflow/engine/templates/pmTables/edit.js @@ -741,20 +741,6 @@ Ext.onReady(function () { } ] }); - items.push({ - layout: "column", - style: "margin-left: 255px;", - hidden: false, - items: [ - { - xtype: "checkbox", - id: "checkboxAvailableOffline", - name: "checkboxAvailableOffline", - checked: false, - boxLabel: _("ID_AVAILABLE_OFFLINE_THE_MOBILE_APPLICATIONS") - } - ] - }); var frmDetails = new Ext.FormPanel({ id: 'frmDetails', @@ -811,7 +797,6 @@ Ext.onReady(function () { Ext.getCmp('REP_TAB_NAME').setValue(TABLE.ADD_TAB_NAME); Ext.getCmp('REP_TAB_NAME').setDisabled(false); Ext.getCmp('REP_TAB_DSC').setValue(TABLE.ADD_TAB_DESCRIPTION); - Ext.getCmp('checkboxAvailableOffline').setValue(TABLE.ADD_TAB_OFFLINE === 1); loadTableRowsFromArray(TABLE.FIELDS); } @@ -941,7 +926,6 @@ function createReportTable() REP_TAB_CONNECTION: "workflow", REP_TAB_TYPE: "", REP_TAB_GRID: "", - REP_TAB_OFFLINE: Ext.getCmp("checkboxAvailableOffline").checked === true ? "1" : "0", columns: Ext.util.JSON.encode(columns) }; diff --git a/workflow/engine/templates/pmTables/list.js b/workflow/engine/templates/pmTables/list.js index 5cee228e2..ac1d77d6e 100644 --- a/workflow/engine/templates/pmTables/list.js +++ b/workflow/engine/templates/pmTables/list.js @@ -7,6 +7,7 @@ var editButton; var deleteButton; var importButton; var exportButton; +var offlineEnableDisable; var dataButton; var store; @@ -108,6 +109,26 @@ Ext.onReady(function () { disabled: true }); + offlineEnableDisable = new Ext.Action({ + id: 'offlineEnableDisable', + text: _('ID_OFFLINE_TABLES'), + iconCls: 'silk-add', + icon: '/images/offline-pin.png', + menu: [{ + text: _('ID_OFFLINE_TABLES_ENABLE'), + handler: function () { + OfflineEnableDisablePMTable(true); + } + }, { + text: _('ID_OFFLINE_TABLES_DISABLE'), + handler: function () { + OfflineEnableDisablePMTable(false); + } + } + ], + disabled: true + }); + dataButton = new Ext.Action({ id: 'dataButton', text: ' ' + _('ID_DATA'), @@ -252,18 +273,21 @@ Ext.onReady(function () { editButton.disable(); deleteButton.disable(); exportButton.disable(); + offlineEnableDisable.disable(); dataButton.disable(); break; case 1: editButton.enable(); deleteButton.enable(); exportButton.enable(); + offlineEnableDisable.enable(); dataButton.enable(); break; default: editButton.disable(); deleteButton.enable(); exportButton.enable(); + offlineEnableDisable.enable(); dataButton.disable(); break; } @@ -365,6 +389,7 @@ Ext.onReady(function () { dataButton, '-', importButton, exportButton, + offlineEnableDisable, '->', searchText, clearTextButton, @@ -515,6 +540,7 @@ DeletePMTable = function () { editButton.disable(); deleteButton.disable(); exportButton.disable(); + offlineEnableDisable.disable(); dataButton.disable(); } } @@ -777,7 +803,6 @@ function updateTagPermissions() { location.href = 'pmReports/reportsAjax?action=permissionList&ADD_TAB_NAME=' + rowsSelected[0].get('ADD_TAB_NAME') + '&ADD_TAB_UID=' + rowsSelected[0].get('ADD_TAB_UID') + '&pro_uid=' + PRO_UID + '&flagProcessmap=' + flagProcessmap; } } -; function PopupCenter(pageURL, title, w, h) { var left = (Ext.getBody().getViewSize().width / 3); @@ -947,4 +972,40 @@ function pmtablesErrors(aOverwrite, aRelated, aMessage) { for (i = 0; i < aOverwrite.length; i++) { Ext.get(aOverwrite[i]['NAME_TABLE']).setStyle({border: '0', marginTop: '0'}); } -} \ No newline at end of file +} + +function OfflineEnableDisablePMTable(enableDisable) { + var rows = Ext.getCmp('infoGrid').getSelectionModel().getSelections(); + if (rows.length <= 0) { + return; + } + var selections = []; + for (var i = 0; i < rows.length; i++) { + selections[i] = { + id: rows[i].get('ADD_TAB_UID'), + type: rows[i].get('ADD_TAB_TYPE'), + offline: enableDisable + }; + } + Ext.Ajax.request({ + url: 'pmTablesProxy/updateOffline', + params: { + rows: Ext.util.JSON.encode(selections) + }, + success: function (response) { + Ext.MessageBox.hide(); + var result = Ext.util.JSON.decode(response.responseText); + if (result.success) { + PMExt.notify(_("ID_OFFLINE_TABLES"), result.message.nl2br()); + } else { + PMExt.error(_("ID_ERROR"), result.message.nl2br()); + } + Ext.getCmp('infoGrid').getStore().reload(); + }, + failure: function (target, response) { + Ext.MessageBox.hide(); + Ext.getCmp('infoGrid').getStore().reload(); + Ext.Msg.alert(_('ID_ERROR'), response.result.message); + } + }); +} diff --git a/workflow/public_html/images/offline-pin.png b/workflow/public_html/images/offline-pin.png new file mode 100644 index 000000000..7adf7e2af Binary files /dev/null and b/workflow/public_html/images/offline-pin.png differ