From 1a2b777ca3672c984a626a8bc65b63aad53d1775 Mon Sep 17 00:00:00 2001 From: Roly Gutierrez Date: Thu, 9 Sep 2021 17:00:01 -0400 Subject: [PATCH 1/2] PMCORE-3301 Custom cases list: Can not import a JSON related to the custom Caselist --- .../admin/settings/customCaseList/Tables.vue | 6 +++--- .../translations/english/processmaker.en.po | 18 ++++++++++++++++++ workflow/engine/data/mysql/insert.sql | 3 +++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/resources/assets/js/admin/settings/customCaseList/Tables.vue b/resources/assets/js/admin/settings/customCaseList/Tables.vue index 2fa03fb0c..8c6a92531 100644 --- a/resources/assets/js/admin/settings/customCaseList/Tables.vue +++ b/resources/assets/js/admin/settings/customCaseList/Tables.vue @@ -249,8 +249,8 @@ export default { * @param {Array} data */ filterDataToExport(data) { - var dataExport = []; - dataExport.push({ + var dataExport; + dataExport = { type: data['type'], name: data['name'], description: data['description'], @@ -263,7 +263,7 @@ export default { iconColorScreen: data['iconColorScreen'], createDate: data['createDate'], updateDate: data['updateDate'] - }); + }; return dataExport; }, /** diff --git a/workflow/engine/content/translations/english/processmaker.en.po b/workflow/engine/content/translations/english/processmaker.en.po index 980870add..b2e960e67 100755 --- a/workflow/engine/content/translations/english/processmaker.en.po +++ b/workflow/engine/content/translations/english/processmaker.en.po @@ -10145,6 +10145,12 @@ msgstr "Import connection" msgid "CSV Import" msgstr "CSV Import" +# TRANSLATION +# LABEL/ID_IMPORT_CUSTOM_CASE_LIST +#: LABEL/ID_IMPORT_CUSTOM_CASE_LIST +msgid "Import Custom Case List" +msgstr "Import Custom Case List" + # TRANSLATION # LABEL/ID_IMPORT_DATA_CSV #: LABEL/ID_IMPORT_DATA_CSV @@ -20153,6 +20159,12 @@ msgstr "New case" msgid "% New Cases" msgstr "% New Cases" +# TRANSLATION +# LABEL/ID_NEW_CASES_LISTS +#: LABEL/ID_NEW_CASES_LISTS +msgid "New Case List" +msgstr "New Case List" + # TRANSLATION # LABEL/ID_NEW_CASE_PANEL #: LABEL/ID_NEW_CASE_PANEL @@ -21587,6 +21599,12 @@ msgstr "The PIN is invalid" msgid "please" msgstr "please" +# TRANSLATION +# LABEL/ID_PLEASE_ADD_THE_CUSTOM_LIST_FILE_TO_BE_UPLOADED +#: LABEL/ID_PLEASE_ADD_THE_CUSTOM_LIST_FILE_TO_BE_UPLOADED +msgid "Please add the Custom List File to be uploaded" +msgstr "Please add the Custom List File to be uploaded" + # TRANSLATION # LABEL/ID_PLEASE_ADD_THE_FILE_SETTINGS_TO_BE_UPLOADED #: LABEL/ID_PLEASE_ADD_THE_FILE_SETTINGS_TO_BE_UPLOADED diff --git a/workflow/engine/data/mysql/insert.sql b/workflow/engine/data/mysql/insert.sql index 5fbf9db3f..cc93a4965 100755 --- a/workflow/engine/data/mysql/insert.sql +++ b/workflow/engine/data/mysql/insert.sql @@ -58548,6 +58548,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_IMPORT_BPMN','en','Import BPMN','2015-02-20') , ( 'LABEL','ID_IMPORT_CONNECTION','en','Import connection','2020-12-10') , ( 'LABEL','ID_IMPORT_CSV','en','CSV Import','2014-01-15') , +( 'LABEL','ID_IMPORT_CUSTOM_CASE_LIST','en','Import Custom Case List','2021-09-09') , ( 'LABEL','ID_IMPORT_DATA_CSV','en','Import Data from CSV file','2014-01-15') , ( 'LABEL','ID_IMPORT_LICENSE','en','Import license','2014-09-18') , ( 'LABEL','ID_IMPORT_PMT','en','Import PM Table','2014-01-15') , @@ -60258,6 +60259,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_NEW_BPMN_PROJECT','en','New BPMN Project','2015-08-18') , ( 'LABEL','ID_NEW_CASE','en','New case','2014-01-15') , ( 'LABEL','ID_NEW_CASES','en','% New Cases','2015-04-06') , +( 'LABEL','ID_NEW_CASES_LISTS','en','New Case List','2021-09-09') , ( 'LABEL','ID_NEW_CASE_PANEL','en','New Case Panel','2014-01-15') , ( 'LABEL','ID_NEW_CASE_SCHEDULER','en','New Case Scheduler','2014-01-15') , ( 'LABEL','ID_NEW_CATEGORY','en','Create New Category','2014-01-15') , @@ -60506,6 +60508,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_PIN','en','Pin','2015-05-08') , ( 'LABEL','ID_PIN_INVALID','en','The PIN is invalid','2014-01-15') , ( 'LABEL','ID_PLEASE','en','please','2014-01-15') , +( 'LABEL','ID_PLEASE_ADD_THE_CUSTOM_LIST_FILE_TO_BE_UPLOADED','en','Please add the Custom List File to be uploaded','2021-09-09') , ( 'LABEL','ID_PLEASE_ADD_THE_FILE_SETTINGS_TO_BE_UPLOADED','en','Please add the file settings to be uploaded','2020-12-10') , ( 'LABEL','ID_PLEASE_CHANGE_PASSWORD_POLICY','en','Please change your password to one that complies with these policies.','2014-01-15') , ( 'LABEL','ID_PLEASE_CONFIGURE_ESTIMATED_DURATION_TASK','en','Please, configure the estimated duration of the task.','2014-10-23') , From 3bd4180e2d93b510ac63197954504248f0093654 Mon Sep 17 00:00:00 2001 From: Roly Gutierrez Date: Mon, 13 Sep 2021 16:49:54 -0400 Subject: [PATCH 2/2] PMCORE-3308 The 'Custom Cases List' filters must act on the search results. --- .../ProcessMaker/BusinessModel/Cases/Home.php | 135 ++++++++++++++--- .../src/ProcessMaker/Services/Api/Home.php | 140 +++++++++++++++--- 2 files changed, 240 insertions(+), 35 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Home.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Home.php index 3b9ee52c2..e9ea2cfd7 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Home.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Home.php @@ -267,8 +267,9 @@ class Home * @param int $id * @param array $arguments * @param array $defaultColumns + * @param array $customFilters */ - public function buildCustomCaseList(string $type, int $id, array &$arguments, array &$defaultColumns) + public function buildCustomCaseList(string $type, int $id, array &$arguments, array &$defaultColumns, array $customFilters = []) { $caseList = CaseList::where('CAL_TYPE', '=', $type) ->where('CAL_ID', '=', $id) @@ -287,22 +288,47 @@ class Home $defaultColumns = []; } $fields = []; + $types = []; foreach ($columns as $value) { if ($value['set'] === true) { $defaultColumns[] = $value; if ($value['source'] === $tableName) { $fields[] = $value['field']; + $types[$value['field']] = $value['type']; } } } //this modifies the query if (!empty($tableName) && !empty($fields)) { - $arguments[] = function ($query) use ($tableName, $fields) { + $arguments[] = function ($query) use ($tableName, $fields, $customFilters, $types) { $query->leftJoin($tableName, "{$tableName}.APP_UID", "=", "APP_DELEGATION.APP_UID"); foreach ($fields as $value) { $query->addSelect($value); } + //filters for custom case list + foreach ($customFilters as $key => $filter) { + if (in_array($key, $fields)) { + //special case for date range + if (isset($types[$key]) && ($types[$key] === "DATETIME" || $types[$key] === "DATE")) { + if (strpos($customFilters[$key], ",") !== false) { + $explode = explode(",", $customFilters[$key]); + $dateFrom = $explode[0]; + $dateTo = $explode[1]; + $query->whereBetween($key, [$dateFrom, $dateTo]); + if (is_null($filter) || $filter === "") { + $subquery->orWhereNull($key); + } + continue; + } + } + //normal filter + $subquery = $query->where($key, 'like', "%{$filter}%"); + if (is_null($filter) || $filter === "") { + $subquery->orWhereNull($key); + } + } + } }; } } @@ -319,6 +345,7 @@ class Home * @param string $caseTitle * @param string $filterCases * @param string $sort + * @param array $customFilters * @return array */ public function getCustomDraft( @@ -330,15 +357,30 @@ class Home int $offset = 0, string $caseTitle = '', string $filterCases = '', - string $sort = 'APP_NUMBER,DESC' + string $sort = 'APP_NUMBER,DESC', + array $customFilters = [] ) { - $arguments = func_get_args(); - array_shift($arguments); + $arguments = [ + $caseNumber, + $process, + $task, + $limit, + $offset, + $caseTitle, + $filterCases, + $sort + ]; + + //clear duplicate indexes + $keys = ['caseNumber', 'process', 'task', 'limit', 'offset', 'caseTitle', 'filterCases', 'sort']; + foreach ($keys as $value) { + unset($customFilters[$value]); + } $type = 'draft'; $defaultColumns = CaseList::formattingColumns($type, '', []); - $this->buildCustomCaseList($type, $id, $arguments, $defaultColumns); + $this->buildCustomCaseList($type, $id, $arguments, $defaultColumns, $customFilters); $result = $this->getDraft(...$arguments); $result['columns'] = $defaultColumns; @@ -359,6 +401,7 @@ class Home * @param string $filterCases * @param string $sort * @param string $sendBy + * @param array $customFilters * @return array */ public function getCustomInbox( @@ -373,15 +416,33 @@ class Home string $delegateTo = '', string $filterCases = '', string $sort = 'APP_NUMBER,DESC', - string $sendBy = '' + string $sendBy = '', + array $customFilters = [] ) { - $arguments = func_get_args(); - array_shift($arguments); + $arguments = [ + $caseNumber, + $process, + $task, + $limit, + $offset, + $caseTitle, + $delegateFrom, + $delegateTo, + $filterCases, + $sort, + $sendBy + ]; + + //clear duplicate indexes + $keys = ['caseNumber', 'process', 'task', 'limit', 'offset', 'caseTitle', 'delegateFrom', 'delegateTo', 'filterCases', 'sort', 'sendBy']; + foreach ($keys as $value) { + unset($customFilters[$value]); + } $type = 'inbox'; $defaultColumns = CaseList::formattingColumns($type, '', []); - $this->buildCustomCaseList($type, $id, $arguments, $defaultColumns); + $this->buildCustomCaseList($type, $id, $arguments, $defaultColumns, $customFilters); $result = $this->getInbox(...$arguments); $result['columns'] = $defaultColumns; @@ -402,6 +463,7 @@ class Home * @param string $filterCases * @param string $sort * @param string $sendBy + * @param array $customFilters * @return array */ public function getCustomUnassigned( @@ -416,15 +478,33 @@ class Home string $delegateTo = '', string $filterCases = '', string $sort = 'APP_NUMBER,DESC', - string $sendBy = '' + string $sendBy = '', + array $customFilters = [] ) { - $arguments = func_get_args(); - array_shift($arguments); + $arguments = [ + $caseNumber, + $process, + $task, + $limit, + $offset, + $caseTitle, + $delegateFrom, + $delegateTo, + $filterCases, + $sort, + $sendBy + ]; + + //clear duplicate indexes + $keys = ['caseNumber', 'process', 'task', 'limit', 'offset', 'caseTitle', 'delegateFrom', 'delegateTo', 'filterCases', 'sort', 'sendBy']; + foreach ($keys as $value) { + unset($customFilters[$value]); + } $type = 'unassigned'; $defaultColumns = CaseList::formattingColumns($type, '', []); - $this->buildCustomCaseList($type, $id, $arguments, $defaultColumns); + $this->buildCustomCaseList($type, $id, $arguments, $defaultColumns, $customFilters); $result = $this->getUnassigned(...$arguments); $result['columns'] = $defaultColumns; @@ -445,6 +525,7 @@ class Home * @param string $filterCases * @param string $sort * @param string $sendBy + * @param array $customFilters * @return array */ public function getCustomPaused( @@ -459,15 +540,33 @@ class Home string $delegateTo = '', string $filterCases = '', string $sort = 'APP_NUMBER,DESC', - string $sendBy = '' + string $sendBy = '', + array $customFilters = [] ) { - $arguments = func_get_args(); - array_shift($arguments); + $arguments = [ + $caseNumber, + $process, + $task, + $limit, + $offset, + $caseTitle, + $delegateFrom, + $delegateTo, + $filterCases, + $sort, + $sendBy + ]; + + //clear duplicate indexes + $keys = ['caseNumber', 'process', 'task', 'limit', 'offset', 'caseTitle', 'delegateFrom', 'delegateTo', 'filterCases', 'sort', 'sendBy']; + foreach ($keys as $value) { + unset($customFilters[$value]); + } $type = 'paused'; $defaultColumns = CaseList::formattingColumns($type, '', []); - $this->buildCustomCaseList($type, $id, $arguments, $defaultColumns); + $this->buildCustomCaseList($type, $id, $arguments, $defaultColumns, $customFilters); $result = $this->getPaused(...$arguments); $result['columns'] = $defaultColumns; diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Home.php b/workflow/engine/src/ProcessMaker/Services/Api/Home.php index 5286cbbfb..774cf8427 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Home.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Home.php @@ -79,7 +79,16 @@ class Home extends Api { try { $bmHome = new BMHome($this->getUserId()); - return $bmHome->getDraft(...func_get_args()); + return $bmHome->getDraft( + $caseNumber, + $process, + $task, + $limit, + $offset, + $caseTitle, + $filterCases, + $sort + ); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -126,7 +135,19 @@ class Home extends Api { try { $bmHome = new BMHome($this->getUserId()); - return $bmHome->getInbox(...func_get_args()); + return $bmHome->getInbox( + $caseNumber, + $process, + $task, + $limit, + $offset, + $caseTitle, + $delegateFrom, + $delegateTo, + $filterCases, + $sort, + $sendBy + ); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -172,7 +193,19 @@ class Home extends Api { try { $bmHome = new BMHome($this->getUserId()); - return $bmHome->getUnassigned(...func_get_args()); + return $bmHome->getUnassigned( + $caseNumber, + $process, + $task, + $limit, + $offset, + $caseTitle, + $delegateFrom, + $delegateTo, + $filterCases, + $sort, + $sendBy + ); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -218,7 +251,19 @@ class Home extends Api { try { $bmHome = new BMHome($this->getUserId()); - return $bmHome->getPaused(...func_get_args()); + return $bmHome->getPaused( + $caseNumber, + $process, + $task, + $limit, + $offset, + $caseTitle, + $delegateFrom, + $delegateTo, + $filterCases, + $sort, + $sendBy + ); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -226,7 +271,7 @@ class Home extends Api /** * Get the custom draft cases. - * @url GET /draft/:id + * @url POST /draft/:id * @param int $id * @param int $caseNumber * @param int $process @@ -236,6 +281,7 @@ class Home extends Api * @param string $caseTitle * @param string $filterCases * @param string $sort + * @param array $request_data * @return array * @throws RestException * @access protected @@ -250,12 +296,24 @@ class Home extends Api int $offset = 0, string $caseTitle = '', string $filterCases = '', - string $sort = 'APP_NUMBER,DESC' + string $sort = 'APP_NUMBER,DESC', + array $request_data = [] ) { try { $bmHome = new BMHome($this->getUserId()); - return $bmHome->getCustomDraft(...func_get_args()); + return $bmHome->getCustomDraft( + $id, + $caseNumber, + $process, + $task, + $limit, + $offset, + $caseTitle, + $filterCases, + $sort, + $request_data + ); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -263,7 +321,7 @@ class Home extends Api /** * Get the custom inbox cases. - * @url GET /inbox/:id + * @url POST /inbox/:id * @param int $id * @param int $caseNumber * @param int $process @@ -276,12 +334,13 @@ class Home extends Api * @param string $filterCases * @param string $sort * @param string $sendBy + * @param array $request_data * @return array * @throws RestException * @access protected * @class AccessControl {@permission PM_CASES} */ - public function doGetCustomTodoCases( + public function doGetCustomInboxCases( int $id, int $caseNumber = 0, int $process = 0, @@ -293,12 +352,27 @@ class Home extends Api string $delegateTo = '', string $filterCases = '', string $sort = 'APP_NUMBER,DESC', - string $sendBy = '' + string $sendBy = '', + array $request_data = [] ) { try { $bmHome = new BMHome($this->getUserId()); - return $bmHome->getCustomInbox(...func_get_args()); + return $bmHome->getCustomInbox( + $id, + $caseNumber, + $process, + $task, + $limit, + $offset, + $caseTitle, + $delegateFrom, + $delegateTo, + $filterCases, + $sort, + $sendBy, + $request_data + ); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -306,7 +380,7 @@ class Home extends Api /** * Get the custom unassigned cases. - * @url GET /unassigned/:id + * @url POST /unassigned/:id * @param int $id * @param int $caseNumber * @param int $process @@ -319,6 +393,7 @@ class Home extends Api * @param string $filterCases * @param string $sort * @param string $sendBy + * @param array $request_data * @return array * @throws RestException * @access protected @@ -336,12 +411,27 @@ class Home extends Api string $delegateTo = '', string $filterCases = '', string $sort = 'APP_NUMBER,DESC', - string $sendBy = '' + string $sendBy = '', + array $request_data = [] ) { try { $bmHome = new BMHome($this->getUserId()); - return $bmHome->getCustomUnassigned(...func_get_args()); + return $bmHome->getCustomUnassigned( + $id, + $caseNumber, + $process, + $task, + $limit, + $offset, + $caseTitle, + $delegateFrom, + $delegateTo, + $filterCases, + $sort, + $sendBy, + $request_data + ); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -349,7 +439,7 @@ class Home extends Api /** * Get the custom paused cases. - * @url GET /paused/:id + * @url POST /paused/:id * @param int $id * @param int $caseNumber * @param int $process @@ -362,6 +452,7 @@ class Home extends Api * @param string $filterCases * @param string $sort * @param string $sendBy + * @param array $request_data * @return array * @throws RestException * @access protected @@ -379,12 +470,27 @@ class Home extends Api string $delegateTo = '', string $filterCases = '', string $sort = 'APP_NUMBER,DESC', - string $sendBy = '' + string $sendBy = '', + array $request_data = [] ) { try { $bmHome = new BMHome($this->getUserId()); - return $bmHome->getCustomPaused(...func_get_args()); + return $bmHome->getCustomPaused( + $id, + $caseNumber, + $process, + $task, + $limit, + $offset, + $caseTitle, + $delegateFrom, + $delegateTo, + $filterCases, + $sort, + $sendBy, + $request_data + ); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); }