From 1c133bc87cc4e059a934facab80d5946d3d67985 Mon Sep 17 00:00:00 2001 From: Yamel Senih Date: Tue, 28 Apr 2020 01:39:27 -0400 Subject: [PATCH] Feature/#source code improve reorder implementation (#466) * Improve source code and define structure for api Note that currently does not exist a way for spared api and search from backend or push, this pull request want reorder use of api by functionality or tool: - All inside ADempiere folder is dedicated for adempiere functionality - ADempiere/dashboard: use this path for add your api resource for all related with dashboard, note that already exist a file named dashboard.js with standard dashboard for ADempiere, if you want to add a new dashboard just create a new file .js for gest info from backend - ADempiere/form: used for all form, for now exist the first implementation named price-checking.js that matched with components/ADempiere/form/PriceChecking, if you want to add a new form just add a new file here - ADempiere/browser.js: browser is a native functionality for Smart Browser tool, just add here all functions related for browser - ADempiere/private-access.js: just handle private access, will be used for add role table access and record access (nice to have) - ADempiere/process.js: related with all action for process and get information from server like getProcessLog and others - ADempiere/report.js: get info like getReportOutput from parameters used for window report and change print formats - ADempiere/rule.js: for now is used for dispatch callouts from server but will be implemented for run rules directly for client on languages like javascript, kotlin and groovy - ADempiere/system-core.js: just get generic functions like getWarehouseList and organization, also can be used for get langages and other infor from server - ADempiere/values.js: get info like lookup list, default values and other values like systen configurator - ADempiere/window.js: all functions related to window like record log, workflow log and other infor that can be used for container - ADempiere/persistence.js: handle standard CRUD for all entities and implement functions like getTranslation from entity * Improve source code and define structure for api Note that currently does not exist a way for spared api and search from backend or push, this pull request want reorder use of api by functionality or tool: - All inside ADempiere folder is dedicated for adempiere functionality - ADempiere/dashboard: use this path for add your api resource for all related with dashboard, note that already exist a file named dashboard.js with standard dashboard for ADempiere, if you want to add a new dashboard just create a new file .js for gest info from backend - ADempiere/form: used for all form, for now exist the first implementation named price-checking.js that matched with components/ADempiere/form/PriceChecking, if you want to add a new form just add a new file here - ADempiere/browser.js: browser is a native functionality for Smart Browser tool, just add here all functions related for browser - ADempiere/private-access.js: just handle private access, will be used for add role table access and record access (nice to have) - ADempiere/process.js: related with all action for process and get information from server like getProcessLog and others - ADempiere/report.js: get info like getReportOutput from parameters used for window report and change print formats - ADempiere/rule.js: for now is used for dispatch callouts from server but will be implemented for run rules directly for client on languages like javascript, kotlin and groovy - ADempiere/system-core.js: just get generic functions like getWarehouseList and organization, also can be used for get langages and other infor from server - ADempiere/values.js: get info like lookup list, default values and other values like systen configurator - ADempiere/window.js: all functions related to window like record log, workflow log and other infor that can be used for container - ADempiere/persistence.js: handle standard CRUD for all entities and implement functions like getTranslation from entity --- src/api/ADempiere/browser.js | 41 ++ src/api/ADempiere/dashboard/dashboard.js | 77 +++ src/api/ADempiere/data.js | 567 ------------------ .../{pos.js => form/price-checking.js} | 2 +- src/api/ADempiere/index.js | 3 - src/api/ADempiere/persistence.js | 131 ++++ src/api/ADempiere/private-access.js | 42 ++ src/api/ADempiere/process.js | 49 ++ src/api/ADempiere/report.js | 70 +++ src/api/ADempiere/rule.js | 43 ++ src/api/ADempiere/system-core.js | 50 ++ src/api/ADempiere/values.js | 82 +++ src/api/ADempiere/window.js | 99 +++ .../ADempiere/Dashboard/docstatus/index.vue | 2 +- src/components/ADempiere/Dashboard/index.vue | 6 +- .../ADempiere/Dashboard/recentItems/index.vue | 2 +- .../{favourites => userfavorites}/index.vue | 2 +- src/components/ADempiere/Field/index.vue | 4 + .../ADempiere/Form/PriceChecking/index.vue | 2 +- src/store/modules/ADempiere/browserControl.js | 2 +- src/store/modules/ADempiere/calloutControl.js | 2 +- src/store/modules/ADempiere/containerInfo.js | 2 +- src/store/modules/ADempiere/contextMenu.js | 2 +- src/store/modules/ADempiere/dashboard.js | 2 +- src/store/modules/ADempiere/data.js | 12 +- .../modules/ADempiere/languageControl.js | 7 +- src/store/modules/ADempiere/lookup.js | 2 +- src/store/modules/ADempiere/processControl.js | 2 +- src/store/modules/ADempiere/reportControl.js | 2 +- src/store/modules/ADempiere/windowControl.js | 3 +- src/store/modules/user.js | 2 +- 31 files changed, 712 insertions(+), 602 deletions(-) create mode 100644 src/api/ADempiere/browser.js create mode 100644 src/api/ADempiere/dashboard/dashboard.js delete mode 100644 src/api/ADempiere/data.js rename src/api/ADempiere/{pos.js => form/price-checking.js} (100%) create mode 100644 src/api/ADempiere/persistence.js create mode 100644 src/api/ADempiere/private-access.js create mode 100644 src/api/ADempiere/process.js create mode 100644 src/api/ADempiere/report.js create mode 100644 src/api/ADempiere/rule.js create mode 100644 src/api/ADempiere/system-core.js create mode 100644 src/api/ADempiere/values.js create mode 100644 src/api/ADempiere/window.js rename src/components/ADempiere/Dashboard/{favourites => userfavorites}/index.vue (98%) diff --git a/src/api/ADempiere/browser.js b/src/api/ADempiere/browser.js new file mode 100644 index 00000000..b036af28 --- /dev/null +++ b/src/api/ADempiere/browser.js @@ -0,0 +1,41 @@ +import { getLanguage } from '@/lang/index' +import BusinessData from '@adempiere/grpc-data-client' +import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' +import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' + +// Get Instance for connection +function Instance() { + return new BusinessData({ + host: BUSINESS_DATA_ADDRESS, + sessionUuid: getToken(), + organizationUuid: getCurrentOrganization(), + warehouseUuid: getCurrentWarehouse(), + language: getLanguage() || 'en_US' + }) +} + +/** + * Request a browser search + * @param {string} uuid + * @param {string} query + * @param {string} whereClause + * @param {string} orderByClause + * @param {string} nextPageToken + * @param {array} parametersList, This allows follow structure: + * [{ + * columnName, + * value + * }] + */ +export function getBrowserSearch({ uuid, parametersList = [], query, whereClause, orderByClause, nextPageToken: pageToken, pageSize }) { + // Run browser + return Instance.call(this).requestListBrowserSearch({ + uuid, + parametersList, + query, + whereClause, + orderByClause, + pageToken, + pageSize + }) +} diff --git a/src/api/ADempiere/dashboard/dashboard.js b/src/api/ADempiere/dashboard/dashboard.js new file mode 100644 index 00000000..a83aa054 --- /dev/null +++ b/src/api/ADempiere/dashboard/dashboard.js @@ -0,0 +1,77 @@ +// This file is for get all information for dashboard of ADempiere client, +// please if you want to implement a custom dashboard create a new fielwith api definition +import { getLanguage } from '@/lang/index' +import BusinessData from '@adempiere/grpc-data-client' +import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' +import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' + +// Get Instance for connection +function Instance() { + return new BusinessData({ + host: BUSINESS_DATA_ADDRESS, + sessionUuid: getToken(), + organizationUuid: getCurrentOrganization(), + warehouseUuid: getCurrentWarehouse(), + language: getLanguage() || 'en_US' + }) +} + +// Request a Process Activity list +export function requestListProcessesLogs({ pageToken, pageSize }) { + // Get Process Activity + return Instance.call(this).requestListProcessesLogs({ pageToken, pageSize }) +} + +// Get Recent Items based on selection option +export function getRecentItems({ pageToken, pageSize }) { + return Instance.call(this).requestListRecentItems({ pageToken, pageSize }) +} + +/** + * Request Favorites List + * @param {string} userUuid + */ +export function getFavoritesFromServer({ userUuid, pageToken, pageSize }) { + return Instance.call(this).requestListFavorites({ userUuid, pageToken, pageSize }) +} + +// Get pending documents +export function getPendingDocumentsFromServer({ userUuid, roleUuid, pageToken, pageSize }) { + return Instance.call(this).requestListPendingDocuments({ + userUuid, + roleUuid, + pageToken, + pageSize + }) +} + +// List all dashboard for role +export function requestLisDashboards({ roleUuid, pageToken, pageSize }) { + return Instance.call(this).requestListDashboards({ + roleUuid, + pageToken, + pageSize + }) +} + +/** + * Request Document Status List + * @param {string} tableName + * @param {number} recordId + * @param {string} recordUuid + * @param {string} documentStatus + * @param {string} documentAction + * @param {number} pageSize + * @param {string} pageToken + */ +export function requestListDocumentStatuses({ tableName, recordId, recordUuid, documentStatus, documentAction, pageSize, pageToken }) { + return Instance.call(this).requestListDocumentStatuses({ + tableName, + recordId, + recordUuid, + documentStatus, + documentAction, + pageSize, + pageToken + }) +} diff --git a/src/api/ADempiere/data.js b/src/api/ADempiere/data.js deleted file mode 100644 index e9c51174..00000000 --- a/src/api/ADempiere/data.js +++ /dev/null @@ -1,567 +0,0 @@ -import { getLanguage } from '@/lang/index' -import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' -import BusinessData from '@adempiere/grpc-data-client' -import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' - -// Get Instance for connection -function Instance() { - return new BusinessData({ - host: BUSINESS_DATA_ADDRESS, - sessionUuid: getToken(), - organizationUuid: getCurrentOrganization(), - warehouseUuid: getCurrentWarehouse(), - language: getLanguage() || 'en_US' - }) -} - -/** - * Create entity - * @param {string} parameters.tableName - * @param {array} parameters.attributesList - */ -export function createEntity({ tableName, attributesList }) { - return Instance.call(this).requestCreateEntity({ - tableName, - attributesList - }) -} - -/** - * Update entity - * @param {string} tableName - * @param {number} recordId - * @param {string} recordUuid - * @param {array} attributesList - */ -export function updateEntity({ tableName, recordId, recordUuid, attributesList }) { - return Instance.call(this).requestUpdateEntity({ - tableName, - recordId, - recordUuid, - attributesList - }) -} - -/** - * Delete entity - * @param {string} tableName - * @param {number} recordId - * @param {string} recordUuid - */ -export function deleteEntity({ tableName, recordId, recordUuid }) { - return Instance.call(this).requestDeleteEntity({ - tableName, - recordId, - recordUuid - }) -} - -export function getEntity({ tableName, recordId, recordUuid }) { - return Instance.call(this).requestGetEntity({ - tableName, - recordId, - recordUuid - }) -} - -/** - * Object List from window - * @param {string} tableName - * @param {string} query - * @param {string} whereClause - * @param {array} conditionsList - * @param {string} orderByClause - * @param {string} pageToken - */ -export function getEntitiesList({ - tableName, - query, - whereClause, - conditionsList = [], - orderByClause, - pageToken, - pageSize -}) { - return Instance.call(this).requestListEntities({ - tableName, - query, - whereClause, - conditionsList, - orderByClause, - pageToken, - pageSize - }) -} - -// Get Organization list from role -export function getOrganizationsList({ - roleUuid, - roleId, - pageToken, - pageSize -}) { - return Instance.call(this).requestListOrganizations({ - roleUuid, - roleId, - pageToken, - pageSize - }) -} - -// Get Warehouses of Organization -export function getWarehousesList({ - organizationUuid, - organizationId, - pageToken, - pageSize -}) { - return Instance.call(this).requestListWarehouses({ - organizationUuid, - organizationId, - pageToken, - pageSize - }) -} - -/** - * Get all operator or get key value type from value - * @param {number} keyToFind - EQUAL = 0; - NOT_EQUAL = 1; - LIKE = 2; - NOT_LIKE = 3; - GREATER = 4; - GREATER_EQUAL = 5; - LESS = 6; - LESS_EQUAL = 7; - BETWEEN = 8; - NOT_NULL = 9; - NULL = 10; - IN = 11; - NOT_IN = 12; - */ -export function getConditionOperators(keyToFind) { - return Instance.call(this).getConditionOperators(keyToFind) -} - -/** - * Rollback entity (Create, Update, Delete) - * @param {string} tableName - * @param {number} recordId - * @param {string} eventType - */ -export function rollbackEntity({ - tableName, - recordId, - eventType -}) { - return Instance.call(this).requestRollbackEntity({ - tableName, - recordId, - eventTypeExecuted: eventType - }) -} - -/** - * Request a Lookup data from Reference - * The main attributes that function hope are: - * @param {string} tableName - * @param {string} directQuery - * @param {string|number} value - */ -export function getLookup({ - tableName, - directQuery, - value -}) { - return Instance.call(this).requestLookupFromReference({ - tableName, - directQuery, - value - }) -} - -/** - * Request a Lookup list data from Reference - * The main attributes that function hope are: - * @param {string} tableName - * @param {string} query - */ -export function getLookupList({ - tableName, - query, - pageToken, - pageSize -}) { - return Instance.call(this).requestListLookupFromReference({ - tableName, - query, - pageToken, - pageSize - }) -} - -/** - * Request a process - * This function allows follow structure: - * @param {string} uuid, uuid from process to run - * @param {number} reportType - * @param {number} tableName, table name of tab, used only window - * @param {number} recordId, record identifier, used only window - * @param {array} parametersList, parameters from process [{ columnName, value }] - * @param {array} selectionsList, selection records, used only browser - [{ - selectionId, - selectionValues: [{ columnName, value }] - }] - * @param {string} printFormatUuid - */ -export function runProcess({ uuid, reportType, tableName, recordId, parametersList = [], selectionsList = [], printFormatUuid }) { - // Run Process - return Instance.call(this).requestRunProcess({ - uuid, - reportType, - tableName, - recordId, - parametersList, - selectionsList, - printFormatUuid - }) -} - -/** - * Request a browser search - * @param {string} uuid - * @param {string} query - * @param {string} whereClause - * @param {string} orderByClause - * @param {string} nextPageToken - * @param {array} parametersList, This allows follow structure: - * [{ - * columnName, - * value - * }] - */ -export function getBrowserSearch({ uuid, parametersList = [], query, whereClause, orderByClause, nextPageToken: pageToken, pageSize }) { - // Run browser - return Instance.call(this).requestListBrowserSearch({ - uuid, - parametersList, - query, - whereClause, - orderByClause, - pageToken, - pageSize - }) -} - -// Request a Process Activity list -export function requestListProcessesLogs({ pageToken, pageSize }) { - // Get Process Activity - return Instance.call(this).requestListProcessesLogs({ pageToken, pageSize }) -} - -export function getRecentItems({ pageToken, pageSize }) { - return Instance.call(this).requestListRecentItems({ pageToken, pageSize }) -} - -/** - * Reference List from Window - * @param {string} tableName - * @param {string} windowUuid - * @param {string} recordUuid - * @param {number} recordId - */ -export function getReferencesList({ windowUuid, tableName, recordId, recordUuid, pageToken, pageSize }) { - return Instance.call(this).requestListReferences({ - windowUuid, - tableName, - recordId, - recordUuid, - pageToken, - pageSize - }) -} - -/** - * Run callout request - * @param {string} windowUuid - * @param {number} windowNo - * @param {string} tabUuid - * @param {string} tableName - * @param {string} columnName - * @param {mixed} value - * @param {mixed} oldValue - * @param {string} callout - * @param {array} attributesList - * @returns {Map} Entity - */ -export function runCallOutRequest({ windowUuid, windowNo, tabUuid, tableName, columnName, value, oldValue, valueType, callout, attributesList = [] }) { - return Instance.call(this).requestRunCallout({ - windowUuid, - windowNo, - tabUuid, - tableName, - columnName, - value, - oldValue, - valueType, - callout, - attributesList - }) -} - -export function getDefaultValueFromServer(query) { - return Instance.call(this).requestGetDefaultValue(query) -} - -export function getContextInfoValueFromServer({ uuid, query }) { - return Instance.call(this).requestGetContextInfoValue({ uuid, query }) -} - -export function getPrivateAccessFromServer({ tableName, recordId, userUuid }) { - return Instance.call(this).requestGetPrivateAccess({ - tableName, - recordId, - userUuid - }) -} - -export function lockPrivateAccessFromServer({ tableName, recordId, userUuid }) { - return Instance.call(this).requestLockPrivateAccess({ - tableName, - recordId, - userUuid - }) -} - -export function unlockPrivateAccessFromServer({ tableName, recordId, userUuid }) { - return Instance.call(this).requestUnlockPrivateAccess({ - tableName, - recordId, - userUuid - }) -} - -/** - * Request Favorites List - * @param {string} userUuid - */ -export function getFavoritesFromServer({ userUuid, pageToken, pageSize }) { - return Instance.call(this).requestListFavorites({ userUuid, pageToken, pageSize }) -} - -export function getPendingDocumentsFromServer({ userUuid, roleUuid, pageToken, pageSize }) { - return Instance.call(this).requestListPendingDocuments({ - userUuid, - roleUuid, - pageToken, - pageSize - }) -} - -/** - * Request Pending Documents List - * @param {string} tableName - * @param {string} processUuid - */ -export function requestReportViews({ tableName, processUuid, pageToken, pageSize }) { - return Instance.call(this).requestListReportViews({ - tableName, - processUuid, - pageToken, - pageSize - }) -} - -export function requestPrintFormats({ tableName, reportViewUuid, processUuid, pageToken, pageSize }) { - return Instance.call(this).requestListPrintFormats({ - tableName, - reportViewUuid, - processUuid, - pageToken, - pageSize - }) -} - -export function requestLisDashboards({ roleUuid, pageToken, pageSize }) { - return Instance.call(this).requestListDashboards({ - roleUuid, - pageToken, - pageSize - }) -} - -export function requestLanguages({ pageToken, pageSize }) { - return Instance.call(this).requestListLanguages({ pageToken, pageSize }) -} - -/** - * Request translations - * @param {string} tableName - * @param {string} language - * @param {string} recordUuid - * @param {integer} recordId - */ -export function requestTranslations({ tableName, language, recordUuid, recordId, pageToken, pageSize }) { - return Instance.call(this).requestListTranslations({ - tableName, - recordUuid, - recordId, - language, - pageToken, - pageSize - }) -} - -export function requestDrillTables({ tableName, pageToken, pageSize }) { - return Instance.call(this).requestListDrillTables({ - tableName, - pageToken, - pageSize - }) -} - -export function getReportOutput({ - parametersList, - tableName, - printFormatUuid, - reportViewUuid, - isSummary, - reportName, - reportType -}) { - return Instance.call(this).requestGetReportOutput({ - parametersList, - tableName, - printFormatUuid, - reportViewUuid, - isSummary, - reportName, - reportType - }) -} - -export function requestListRecordsLogs({ - tableName, - recordId, - pageToken, - pageSize -}) { - return Instance.call(this).requestListRecordsLogs({ - tableName, - recordId, - pageToken, - pageSize - }) -} - -export function requestListWorkflowsLogs({ - tableName, - recordId, - pageToken, - pageSize -}) { - return Instance.call(this).requestListWorkflowsLogs({ - tableName, - recordId, - pageToken, - pageSize - }) -} - -export function requestListWorkflows({ - tableName, - pageToken, - pageSize -}) { - return Instance.call(this).requestListWorkflows({ - tableName, - pageToken, - pageSize - }) -} - -/** - * @param {string} tableName - * @param {integer} recordId - * @param {string} pageToken - * @param {string} pageSize - */ -export function requestListRecordChats({ tableName, recordId, pageToken, pageSize }) { - return Instance.call(this).requestListRecordChats({ - tableName, - recordId, - pageToken, - pageSize - }) -} - -/** - * @param {string} uuid - * @param {string} pageToken - * @param {string} pageSize - */ -export function requestListChatEntries({ uuid, pageToken, pageSize }) { - return Instance.call(this).requestListChatEntries({ - uuid, - pageToken, - pageSize - }) -} - -/** - * @param {string} tableName - * @param {string} recordId - * @param {string} comment - */ -export function requestCreateChatEntry({ tableName, recordId, comment }) { - return Instance.call(this).requestCreateChatEntry({ - tableName, - recordId, - comment - }) -} - -/** - * Request Document Actions List - * @param {string} tableName - * @param {number} recordId - * @param {string} recordUuid - * @param {string} documentStatus - * @param {string} documentAction - * @param {number} pageSize - * @param {string} pageToken - */ -export function requestListDocumentActions({ tableName, recordId, recordUuid, documentStatus, documentAction, pageSize, pageToken }) { - return Instance.call(this).requestListDocumentActions({ - tableName, - recordId, - recordUuid, - documentStatus, - documentAction, - pageSize, - pageToken - }) -} -/** - * Request Document Status List - * @param {string} tableName - * @param {number} recordId - * @param {string} recordUuid - * @param {string} documentStatus - * @param {string} documentAction - * @param {number} pageSize - * @param {string} pageToken - */ -export function requestListDocumentStatuses({ tableName, recordId, recordUuid, documentStatus, documentAction, pageSize, pageToken }) { - return Instance.call(this).requestListDocumentStatuses({ - tableName, - recordId, - recordUuid, - documentStatus, - documentAction, - pageSize, - pageToken - }) -} diff --git a/src/api/ADempiere/pos.js b/src/api/ADempiere/form/price-checking.js similarity index 100% rename from src/api/ADempiere/pos.js rename to src/api/ADempiere/form/price-checking.js index e08627f5..c594f43f 100644 --- a/src/api/ADempiere/pos.js +++ b/src/api/ADempiere/form/price-checking.js @@ -1,7 +1,7 @@ import { getLanguage } from '@/lang/index' -import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' import POS from '@adempiere/grpc-pos-client' import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' +import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' // Get Instance for connection function Instance() { diff --git a/src/api/ADempiere/index.js b/src/api/ADempiere/index.js index 9f4a9c5c..59f693cd 100644 --- a/src/api/ADempiere/index.js +++ b/src/api/ADempiere/index.js @@ -1,8 +1,5 @@ // Export dictionary connection export * from './dictionary' -// Export data connection -export * from './data' - // Export enrollment user connection export * from './enrollment' diff --git a/src/api/ADempiere/persistence.js b/src/api/ADempiere/persistence.js new file mode 100644 index 00000000..c997dc0f --- /dev/null +++ b/src/api/ADempiere/persistence.js @@ -0,0 +1,131 @@ +import { getLanguage } from '@/lang/index' +import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' +import BusinessData from '@adempiere/grpc-data-client' +import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' + +// Get Instance for connection +function Instance() { + return new BusinessData({ + host: BUSINESS_DATA_ADDRESS, + sessionUuid: getToken(), + organizationUuid: getCurrentOrganization(), + warehouseUuid: getCurrentWarehouse(), + language: getLanguage() || 'en_US' + }) +} + +/** + * Create entity + * @param {string} parameters.tableName + * @param {array} parameters.attributesList + */ +export function createEntity({ tableName, attributesList }) { + return Instance.call(this).requestCreateEntity({ + tableName, + attributesList + }) +} + +/** + * Update entity + * @param {string} tableName + * @param {number} recordId + * @param {string} recordUuid + * @param {array} attributesList + */ +export function updateEntity({ tableName, recordId, recordUuid, attributesList }) { + return Instance.call(this).requestUpdateEntity({ + tableName, + recordId, + recordUuid, + attributesList + }) +} + +/** + * Delete entity + * @param {string} tableName + * @param {number} recordId + * @param {string} recordUuid + */ +export function deleteEntity({ tableName, recordId, recordUuid }) { + return Instance.call(this).requestDeleteEntity({ + tableName, + recordId, + recordUuid + }) +} + +/** + * Rollback entity (Create, Update, Delete) + * @param {string} tableName + * @param {number} recordId + * @param {string} eventType + */ +export function rollbackEntity({ + tableName, + recordId, + eventType +}) { + return Instance.call(this).requestRollbackEntity({ + tableName, + recordId, + eventTypeExecuted: eventType + }) +} + +// Get entity from table name and record id or record uuid +export function getEntity({ tableName, recordId, recordUuid }) { + return Instance.call(this).requestGetEntity({ + tableName, + recordId, + recordUuid + }) +} + +/** + * Object List from window + * @param {string} tableName + * @param {string} query + * @param {string} whereClause + * @param {array} conditionsList + * @param {string} orderByClause + * @param {string} pageToken + */ +export function getEntitiesList({ + tableName, + query, + whereClause, + conditionsList = [], + orderByClause, + pageToken, + pageSize +}) { + return Instance.call(this).requestListEntities({ + tableName, + query, + whereClause, + conditionsList, + orderByClause, + pageToken, + pageSize + }) +} + +/** + * Request translations + * @param {string} tableName + * @param {string} language + * @param {string} recordUuid + * @param {integer} recordId + */ +export function requestTranslations({ tableName, language, recordUuid, recordId, pageToken, pageSize }) { + return Instance.call(this).requestListTranslations({ + tableName, + recordUuid, + recordId, + language, + pageToken, + pageSize + }) +} diff --git a/src/api/ADempiere/private-access.js b/src/api/ADempiere/private-access.js new file mode 100644 index 00000000..b7228c93 --- /dev/null +++ b/src/api/ADempiere/private-access.js @@ -0,0 +1,42 @@ +import { getLanguage } from '@/lang/index' +import BusinessData from '@adempiere/grpc-data-client' +import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' +import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' + +// Get Instance for connection +function Instance() { + return new BusinessData({ + host: BUSINESS_DATA_ADDRESS, + sessionUuid: getToken(), + organizationUuid: getCurrentOrganization(), + warehouseUuid: getCurrentWarehouse(), + language: getLanguage() || 'en_US' + }) +} + +// Get private access for a record +export function getPrivateAccessFromServer({ tableName, recordId, userUuid }) { + return Instance.call(this).requestGetPrivateAccess({ + tableName, + recordId, + userUuid + }) +} + +// Lock a record for a user +export function lockPrivateAccessFromServer({ tableName, recordId, userUuid }) { + return Instance.call(this).requestLockPrivateAccess({ + tableName, + recordId, + userUuid + }) +} + +// Unlock a record from a user +export function unlockPrivateAccessFromServer({ tableName, recordId, userUuid }) { + return Instance.call(this).requestUnlockPrivateAccess({ + tableName, + recordId, + userUuid + }) +} diff --git a/src/api/ADempiere/process.js b/src/api/ADempiere/process.js new file mode 100644 index 00000000..e4157b83 --- /dev/null +++ b/src/api/ADempiere/process.js @@ -0,0 +1,49 @@ +import { getLanguage } from '@/lang/index' +import BusinessData from '@adempiere/grpc-data-client' +import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' +import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' + +// Get Instance for connection +function Instance() { + return new BusinessData({ + host: BUSINESS_DATA_ADDRESS, + sessionUuid: getToken(), + organizationUuid: getCurrentOrganization(), + warehouseUuid: getCurrentWarehouse(), + language: getLanguage() || 'en_US' + }) +} + +/** + * Request a process + * This function allows follow structure: + * @param {string} uuid, uuid from process to run + * @param {number} reportType + * @param {number} tableName, table name of tab, used only window + * @param {number} recordId, record identifier, used only window + * @param {array} parametersList, parameters from process [{ columnName, value }] + * @param {array} selectionsList, selection records, used only browser + [{ + selectionId, + selectionValues: [{ columnName, value }] + }] + * @param {string} printFormatUuid + */ +export function runProcess({ uuid, reportType, tableName, recordId, parametersList = [], selectionsList = [], printFormatUuid }) { + // Run Process + return Instance.call(this).requestRunProcess({ + uuid, + reportType, + tableName, + recordId, + parametersList, + selectionsList, + printFormatUuid + }) +} + +// Request a Process Activity list +export function requestListProcessesLogs({ pageToken, pageSize }) { + // Get Process Activity + return Instance.call(this).requestListProcessesLogs({ pageToken, pageSize }) +} diff --git a/src/api/ADempiere/report.js b/src/api/ADempiere/report.js new file mode 100644 index 00000000..17c05de2 --- /dev/null +++ b/src/api/ADempiere/report.js @@ -0,0 +1,70 @@ +import { getLanguage } from '@/lang/index' +import BusinessData from '@adempiere/grpc-data-client' +import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' +import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' + +// Get Instance for connection +function Instance() { + return new BusinessData({ + host: BUSINESS_DATA_ADDRESS, + sessionUuid: getToken(), + organizationUuid: getCurrentOrganization(), + warehouseUuid: getCurrentWarehouse(), + language: getLanguage() || 'en_US' + }) +} + +/** + * Request Pending Documents List + * @param {string} tableName + * @param {string} processUuid + */ +export function requestReportViews({ tableName, processUuid, pageToken, pageSize }) { + return Instance.call(this).requestListReportViews({ + tableName, + processUuid, + pageToken, + pageSize + }) +} + +// Get print formats from table name, report view uuid or process uuid +export function requestPrintFormats({ tableName, reportViewUuid, processUuid, pageToken, pageSize }) { + return Instance.call(this).requestListPrintFormats({ + tableName, + reportViewUuid, + processUuid, + pageToken, + pageSize + }) +} + +// Get drill tables for a report +export function requestDrillTables({ tableName, pageToken, pageSize }) { + return Instance.call(this).requestListDrillTables({ + tableName, + pageToken, + pageSize + }) +} + +// Get report output from parameters +export function getReportOutput({ + parametersList, + tableName, + printFormatUuid, + reportViewUuid, + isSummary, + reportName, + reportType +}) { + return Instance.call(this).requestGetReportOutput({ + parametersList, + tableName, + printFormatUuid, + reportViewUuid, + isSummary, + reportName, + reportType + }) +} diff --git a/src/api/ADempiere/rule.js b/src/api/ADempiere/rule.js new file mode 100644 index 00000000..5bb45d2f --- /dev/null +++ b/src/api/ADempiere/rule.js @@ -0,0 +1,43 @@ +import { getLanguage } from '@/lang/index' +import BusinessData from '@adempiere/grpc-data-client' +import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' +import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' + +// Get Instance for connection +function Instance() { + return new BusinessData({ + host: BUSINESS_DATA_ADDRESS, + sessionUuid: getToken(), + organizationUuid: getCurrentOrganization(), + warehouseUuid: getCurrentWarehouse(), + language: getLanguage() || 'en_US' + }) +} + +/** + * Run callout request + * @param {string} windowUuid + * @param {number} windowNo + * @param {string} tabUuid + * @param {string} tableName + * @param {string} columnName + * @param {mixed} value + * @param {mixed} oldValue + * @param {string} callout + * @param {array} attributesList + * @returns {Map} Entity + */ +export function runCallOutRequest({ windowUuid, windowNo, tabUuid, tableName, columnName, value, oldValue, valueType, callout, attributesList = [] }) { + return Instance.call(this).requestRunCallout({ + windowUuid, + windowNo, + tabUuid, + tableName, + columnName, + value, + oldValue, + valueType, + callout, + attributesList + }) +} diff --git a/src/api/ADempiere/system-core.js b/src/api/ADempiere/system-core.js new file mode 100644 index 00000000..5a7e0725 --- /dev/null +++ b/src/api/ADempiere/system-core.js @@ -0,0 +1,50 @@ +import { getLanguage } from '@/lang/index' +import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' +import BusinessData from '@adempiere/grpc-data-client' +import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' + +// Get Instance for connection +function Instance() { + return new BusinessData({ + host: BUSINESS_DATA_ADDRESS, + sessionUuid: getToken(), + organizationUuid: getCurrentOrganization(), + warehouseUuid: getCurrentWarehouse(), + language: getLanguage() || 'en_US' + }) +} + +// Get Organization list from role +export function getOrganizationsList({ + roleUuid, + roleId, + pageToken, + pageSize +}) { + return Instance.call(this).requestListOrganizations({ + roleUuid, + roleId, + pageToken, + pageSize + }) +} + +// Get Warehouses of Organization +export function getWarehousesList({ + organizationUuid, + organizationId, + pageToken, + pageSize +}) { + return Instance.call(this).requestListWarehouses({ + organizationUuid, + organizationId, + pageToken, + pageSize + }) +} + +// Get languages from api +export function requestLanguages({ pageToken, pageSize }) { + return Instance.call(this).requestListLanguages({ pageToken, pageSize }) +} diff --git a/src/api/ADempiere/values.js b/src/api/ADempiere/values.js new file mode 100644 index 00000000..d4f69dba --- /dev/null +++ b/src/api/ADempiere/values.js @@ -0,0 +1,82 @@ +import { getLanguage } from '@/lang/index' +import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' +import BusinessData from '@adempiere/grpc-data-client' +import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' + +// Get Instance for connection +function Instance() { + return new BusinessData({ + host: BUSINESS_DATA_ADDRESS, + sessionUuid: getToken(), + organizationUuid: getCurrentOrganization(), + warehouseUuid: getCurrentWarehouse(), + language: getLanguage() || 'en_US' + }) +} + +/** + * Request a Lookup data from Reference + * The main attributes that function hope are: + * @param {string} tableName + * @param {string} directQuery + * @param {string|number} value + */ +export function getLookup({ + tableName, + directQuery, + value +}) { + return Instance.call(this).requestLookupFromReference({ + tableName, + directQuery, + value + }) +} + +/** + * Request a Lookup list data from Reference + * The main attributes that function hope are: + * @param {string} tableName + * @param {string} query + */ +export function getLookupList({ + tableName, + query, + pageToken, + pageSize +}) { + return Instance.call(this).requestListLookupFromReference({ + tableName, + query, + pageToken, + pageSize + }) +} + +/** + * Reference List from Window + * @param {string} tableName + * @param {string} windowUuid + * @param {string} recordUuid + * @param {number} recordId + */ +export function getReferencesList({ windowUuid, tableName, recordId, recordUuid, pageToken, pageSize }) { + return Instance.call(this).requestListReferences({ + windowUuid, + tableName, + recordId, + recordUuid, + pageToken, + pageSize + }) +} + +// Get default value for a field +export function getDefaultValueFromServer(query) { + return Instance.call(this).requestGetDefaultValue(query) +} + +// Get context information for a window, tab or field +export function getContextInfoValueFromServer({ uuid, query }) { + return Instance.call(this).requestGetContextInfoValue({ uuid, query }) +} diff --git a/src/api/ADempiere/window.js b/src/api/ADempiere/window.js new file mode 100644 index 00000000..0a3fa378 --- /dev/null +++ b/src/api/ADempiere/window.js @@ -0,0 +1,99 @@ +import { getLanguage } from '@/lang/index' +import BusinessData from '@adempiere/grpc-data-client' +import { BUSINESS_DATA_ADDRESS } from '@/api/ADempiere/constants' +import { getToken, getCurrentOrganization, getCurrentWarehouse } from '@/utils/auth' + +// Get Instance for connection +function Instance() { + return new BusinessData({ + host: BUSINESS_DATA_ADDRESS, + sessionUuid: getToken(), + organizationUuid: getCurrentOrganization(), + warehouseUuid: getCurrentWarehouse(), + language: getLanguage() || 'en_US' + }) +} + +// Get list of log for a records +export function requestListRecordsLogs({ + tableName, + recordId, + pageToken, + pageSize +}) { + return Instance.call(this).requestListRecordsLogs({ + tableName, + recordId, + pageToken, + pageSize + }) +} + +// Get workflow log for a record +export function requestListWorkflowsLogs({ + tableName, + recordId, + pageToken, + pageSize +}) { + return Instance.call(this).requestListWorkflowsLogs({ + tableName, + recordId, + pageToken, + pageSize + }) +} + +// Get workflow list for a document +export function requestListWorkflows({ + tableName, + pageToken, + pageSize +}) { + return Instance.call(this).requestListWorkflows({ + tableName, + pageToken, + pageSize + }) +} + +/** + * @param {string} tableName + * @param {integer} recordId + * @param {string} pageToken + * @param {string} pageSize + */ +export function requestListRecordChats({ tableName, recordId, pageToken, pageSize }) { + return Instance.call(this).requestListRecordChats({ + tableName, + recordId, + pageToken, + pageSize + }) +} + +/** + * @param {string} uuid + * @param {string} pageToken + * @param {string} pageSize + */ +export function requestListChatEntries({ uuid, pageToken, pageSize }) { + return Instance.call(this).requestListChatEntries({ + uuid, + pageToken, + pageSize + }) +} + +/** + * @param {string} tableName + * @param {string} recordId + * @param {string} comment + */ +export function requestCreateChatEntry({ tableName, recordId, comment }) { + return Instance.call(this).requestCreateChatEntry({ + tableName, + recordId, + comment + }) +} diff --git a/src/components/ADempiere/Dashboard/docstatus/index.vue b/src/components/ADempiere/Dashboard/docstatus/index.vue index e7797bd8..ac16c3f0 100644 --- a/src/components/ADempiere/Dashboard/docstatus/index.vue +++ b/src/components/ADempiere/Dashboard/docstatus/index.vue @@ -25,7 +25,7 @@