diff --git a/package.json b/package.json index badf8368..043f42f3 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "path-to-regexp": "2.4.0", "screenfull": "4.2.0", "showdown": "1.9.0", - "sortablejs": "1.8.4", + "sortablejs": "1.10.1", "tui-editor": "1.3.3", "vue": "2.6.10", "vue-count-to": "1.0.13", @@ -77,7 +77,7 @@ "vue-router": "3.0.4", "vue-split-panel": "^1.0.4", "vue-splitpane": "1.0.4", - "vuedraggable": "^2.20.0", + "vuedraggable": "^2.23.2", "vuex": "3.1.0", "xlsx": "0.14.1" }, diff --git a/src/components/ADempiere/ContextMenu/contextMenuMixin.js b/src/components/ADempiere/ContextMenu/contextMenuMixin.js index c2c5859e..1f787dbf 100644 --- a/src/components/ADempiere/ContextMenu/contextMenuMixin.js +++ b/src/components/ADempiere/ContextMenu/contextMenuMixin.js @@ -39,10 +39,6 @@ export const contextMixin = { type: String, default: undefined }, - modalMetadata: { - type: Object, - default: () => {} - }, // used only window isInsertRecord: { type: Boolean, @@ -322,25 +318,10 @@ export const contextMixin = { showModal(action) { // TODO: Refactor and remove redundant dispatchs if (action.type === 'process') { - var processData = this.$store.getters.getProcess(action.uuid) - if (processData === undefined) { - this.$store.dispatch('getProcessFromServer', { - containerUuid: action.uuid, - routeToDelete: this.$route - }) - .then(response => { - this.$store.dispatch('setShowDialog', { - type: action.type, - action: response - }) - }).catch(error => { - console.warn('ContextMenu: Dictionary Process (State) - Error ' + error.code + ': ' + error.message) - }) - } else { - this.$store.dispatch('setShowDialog', { type: action.type, action: processData }) - } - } else { - this.$store.dispatch('setShowDialog', { type: action.type, action: this.modalMetadata }) + this.$store.dispatch('setShowDialog', { + type: action.type, + action: action + }) } }, runAction(action) { @@ -360,7 +341,10 @@ export const contextMixin = { } } if (this.panelType === 'process') { - this.$store.dispatch('setTempShareLink', { processId: this.$route.params.processId, href: window.location.href }) + this.$store.dispatch('setTempShareLink', { + processId: this.$route.params.processId, + href: window.location.href + }) } this.$store.dispatch(action.action, { action: action, diff --git a/src/components/ADempiere/ContextMenu/index.vue b/src/components/ADempiere/ContextMenu/index.vue index 7e8bce09..d762b3b5 100644 --- a/src/components/ADempiere/ContextMenu/index.vue +++ b/src/components/ADempiere/ContextMenu/index.vue @@ -8,7 +8,6 @@ :is-report="isReport" :last-parameter="lastParameter" :report-format="reportFormat" - :modal-metadata="modalMetadata" :is-insert-record="isInsertRecord" /> @@ -47,10 +46,6 @@ export default { type: String, default: undefined }, - modalMetadata: { - type: Object, - default: () => {} - }, // used only window isInsertRecord: { type: Boolean, diff --git a/src/components/ADempiere/DataTable/index.vue b/src/components/ADempiere/DataTable/index.vue index 0204c9f0..71561e1d 100644 --- a/src/components/ADempiere/DataTable/index.vue +++ b/src/components/ADempiere/DataTable/index.vue @@ -35,6 +35,17 @@ > {{ $t('window.newRecord') }} + + + {{ actionSequence.name }} + + { this.isLoadPanelFromServer = true }).catch(error => { diff --git a/src/components/ADempiere/Dialog/index.vue b/src/components/ADempiere/Dialog/index.vue index 476d93a8..342c2562 100644 --- a/src/components/ADempiere/Dialog/index.vue +++ b/src/components/ADempiere/Dialog/index.vue @@ -2,26 +2,44 @@ - {{ modalMetadata.description }} - + + + + - + {{ $t('components.dialogCancelButton') }} - + {{ $t('components.dialogConfirmButton') }} @@ -30,12 +48,14 @@ + + diff --git a/src/components/ADempiere/Panel/index.vue b/src/components/ADempiere/Panel/index.vue index 9540380b..5f8e29ae 100644 --- a/src/components/ADempiere/Panel/index.vue +++ b/src/components/ADempiere/Panel/index.vue @@ -333,7 +333,7 @@ export default { this.$store.dispatch('getPanelAndFields', { parentUuid: this.parentUuid, containerUuid: this.containerUuid, - type: this.panelType, + panelType: this.panelType, isAdvancedQuery: this.isAdvancedQuery }).then(() => { this.generatePanel(this.getterFieldList) diff --git a/src/components/ADempiere/SequenceOrder/index.vue b/src/components/ADempiere/SequenceOrder/index.vue new file mode 100644 index 00000000..97bca44c --- /dev/null +++ b/src/components/ADempiere/SequenceOrder/index.vue @@ -0,0 +1,299 @@ + + + + + + {{ this.$t('sequence.available') }} ({{ getterListAvaliable.length }}) + + + + {{ displayedName(element) }} + + + + + + + + {{ this.$t('sequence.sequence') }} ({{ getterListSequence.length }}) + + + + {{ displayedName(element) }} + + + + + + + + + + + diff --git a/src/components/ADempiere/Tab/index.vue b/src/components/ADempiere/Tab/index.vue index 1ec1e7fa..cf91b91a 100644 --- a/src/components/ADempiere/Tab/index.vue +++ b/src/components/ADempiere/Tab/index.vue @@ -1,24 +1,23 @@ - + diff --git a/src/components/ADempiere/Tab/tabChildren.vue b/src/components/ADempiere/Tab/tabChildren.vue index af673c79..eca5ecb9 100644 --- a/src/components/ADempiere/Tab/tabChildren.vue +++ b/src/components/ADempiere/Tab/tabChildren.vue @@ -1,21 +1,20 @@ - + @@ -38,10 +37,6 @@ export default { firstTabUuid: { type: String, default: undefined - }, - firstIndex: { - type: String, - default: undefined } }, data() { @@ -65,8 +60,33 @@ export default { return this.getterDataParentTab.isLoadedContext } }, + watch: { + // Current TabChildren + currentTabChild(newValue, oldValue) { + if (newValue !== oldValue) { + this.$router.push({ + query: { + ...this.$route.query, + tabChild: String(newValue) + }, + params: { + ...this.$route.params + } + }) + } + } + }, mounted() { this.setCurrentTabChild() + }, + methods: { + setCurrentTabChild() { + let activeTab = this.$route.query.tabChild + if (activeTab === undefined) { + activeTab = String(0) + } + this.currentTabChild = activeTab + } } } diff --git a/src/components/ADempiere/Tab/tabMixin.js b/src/components/ADempiere/Tab/tabMixin.js index 9dae6750..415707be 100644 --- a/src/components/ADempiere/Tab/tabMixin.js +++ b/src/components/ADempiere/Tab/tabMixin.js @@ -7,7 +7,7 @@ export const tabMixin = { default: '' }, tabsList: { - type: [Array, Object], + type: Array, default: () => [] } }, @@ -25,6 +25,9 @@ export const tabMixin = { }, getterDataRecords() { return this.$store.getters.getDataRecordsList(this.tabUuid) + }, + getTabsList() { + return this.tabsList.filter(tab => !tab.isSortTab) } }, watch: { @@ -34,12 +37,6 @@ export const tabMixin = { this.getDataTable() } }, - // Current TabChildren - currentTabChild(newValue, oldValue) { - if (newValue !== oldValue) { - this.$router.push({ query: { ...this.$route.query, tabChild: String(newValue) }, params: { ...this.$route.params }}) - } - }, // Load parent tab context getterIsLoadContextParent(value) { if (value && !this.getDataSelection.isLoaded && this.getterIsLoadRecordParent) { @@ -48,7 +45,8 @@ export const tabMixin = { } }, created() { - this.tabUuid = this.tabsList[0].uuid + const tabs = this.tabsList.filter(item => !item.isSortTab) + this.tabUuid = tabs[0].uuid }, methods: { parseContext, @@ -66,11 +64,6 @@ export const tabMixin = { }) this.$route.meta.tabUuid = this.tabUuid }, - setCurrentTabChild() { - if (this.$route.query.tabChild === undefined && this.firstIndex) { - this.currentTabChild = this.firstIndex - } - }, /** * @param {object} tabHTML DOM HTML the tab clicked */ @@ -81,7 +74,9 @@ export const tabMixin = { } }, handleBeforeLeave(activeName) { - var metadataTab = this.tabsList.find(tab => tab.index === parseInt(activeName)) + const metadataTab = this.tabsList + .filter(tab => !tab.isSortTab) + .find(tab => tab.index === parseInt(activeName)) if (!this.isEmptyValue(metadataTab.whereClause) && metadataTab.whereClause.includes('@')) { metadataTab.whereClause = parseContext({ parentUuid: metadataTab.parentUuid, diff --git a/src/lang/ADempiere/en.js b/src/lang/ADempiere/en.js index 1b90767b..baf0259b 100644 --- a/src/lang/ADempiere/en.js +++ b/src/lang/ADempiere/en.js @@ -38,6 +38,7 @@ export default { copyUnsuccessful: 'Error, unable to copy', mandatoryFieldMissing: 'Missing fill in the fields ', updateFields: 'The record is updated with the field ', + updateSuccessfully: 'Successfully made changes', invalidEmailFormat: 'Invalid email format', recordLocked: 'This record has been locked', recordUnlocked: 'This record has been unlocked' @@ -274,5 +275,9 @@ export default { undo: 'Undo', lockRecord: 'Lock Record', unlockRecord: 'Unlock Record' + }, + sequence: { + available: 'Available', + sequence: 'Sequence' } } diff --git a/src/lang/ADempiere/es.js b/src/lang/ADempiere/es.js index 40169fac..90f26943 100644 --- a/src/lang/ADempiere/es.js +++ b/src/lang/ADempiere/es.js @@ -38,6 +38,7 @@ export default { copyUnsuccessful: 'Error, no se puede copiar', mandatoryFieldMissing: 'Falta completar los campos ', updateFields: 'Se actualiza el registro con el campo ', + updateSuccessfully: 'Cambios realizados exitosamente', invalidEmailFormat: 'Formato de correo electronico invalido', recordLocked: 'Este registro ha sido bloqueado', recordUnlocked: 'Este registro ha sido desbloqueado' @@ -249,5 +250,9 @@ export default { undo: 'Deshacer', lockRecord: 'Bloquear Registro', unlockRecord: 'Desbloquear Registro' + }, + sequence: { + available: 'Disponibles', + sequence: 'Secuencia' } } diff --git a/src/store/modules/ADempiere/data.js b/src/store/modules/ADempiere/data.js index 60fdebd0..af4ac2c4 100644 --- a/src/store/modules/ADempiere/data.js +++ b/src/store/modules/ADempiere/data.js @@ -37,12 +37,17 @@ const data = { deleteInGetting(state, payload) { state.inGetting = state.inGetting.filter(item => item.containerUuid !== payload.containerUuid) }, + addRecordSelection(state, payload) { + state.recordSelection.push(payload) + }, setRecordSelection(state, payload) { - if (payload.index > -1 && payload.index !== undefined) { - state.recordSelection.splice(payload.index, 1, payload) - } else { - state.recordSelection.push(payload) - } + payload.dataStore.record = payload.newDataStore.record + payload.dataStore.selection = payload.newDataStore.selection + payload.dataStore.pageNumber = payload.newDataStore.pageNumber + payload.dataStore.recordCount = payload.newDataStore.recordCount + payload.dataStore.nextPageToken = payload.newDataStore.nextPageToken + payload.dataStore.isLoadedContext = payload.newDataStore.isLoadedContext + payload.dataStore.isLoaded = payload.newDataStore.isLoaded }, setSelection(state, payload) { payload.data.selection = payload.newSelection @@ -124,24 +129,30 @@ const data = { * @param {string} parameters.pageNumber */ setPageNumber({ commit, state, dispatch, rootGetters }, parameters) { + const { + parentUuid, containerUuid, panelType = 'window', pageNumber, + isAddRecord = false, isShowNotification = true + } = parameters const data = state.recordSelection.find(recordItem => { - return recordItem.containerUuid === parameters.containerUuid + return recordItem.containerUuid === containerUuid }) commit('setPageNumber', { data: data, - pageNumber: parameters.pageNumber + pageNumber: pageNumber }) // refresh list table with data from server - if (parameters.panelType === 'window') { + if (panelType === 'window') { dispatch('getDataListTab', { - parentUuid: parameters.parentUuid, - containerUuid: parameters.containerUuid + parentUuid: parentUuid, + containerUuid: containerUuid, + isAddRecord: isAddRecord, + isShowNotification: isShowNotification }) - } else if (parameters.panelType === 'browser') { - if (!rootGetters.isNotReadyForSubmit(parameters.containerUuid)) { + } else if (panelType === 'browser') { + if (!rootGetters.isNotReadyForSubmit(containerUuid)) { dispatch('getBrowserSearch', { - containerUuid: parameters.containerUuid, + containerUuid: containerUuid, isClearSelection: true }) } @@ -330,19 +341,18 @@ const data = { */ setIsloadContext({ commit, state }, parameters) { const { containerUuid } = parameters - const data = state.recordSelection.find(recordItem => { + const dataStore = state.recordSelection.find(recordItem => { return recordItem.containerUuid === containerUuid }) - if (data) { + if (dataStore) { commit('setIsloadContext', { - data: data, + data: dataStore, isLoadedContext: true }) } }, /** * Set record, selection, page number, token, and record count, with container uuid - * TODO: Refactor and optimize the mutation of state * @param {string} parameters.containerUuid * @param {array} parameters.record * @param {array} parameters.selection @@ -351,12 +361,19 @@ const data = { * @param {string} parameters.nextPageToken * @param {string} parameters.panelType */ - setRecordSelection({ commit, state }, parameters) { - const { parentUuid, containerUuid, record = [], selection = [], pageNumber = 1, recordCount = 0, nextPageToken, panelType = 'window' } = parameters - var index = state.recordSelection.findIndex(recordItem => { + setRecordSelection({ state, commit, rootGetters, dispatch }, parameters) { + const { + parentUuid, containerUuid, panelType = 'window', record = [], + query, whereClause, orderByClause, + selection = [], pageNumber = 1, recordCount = 0, nextPageToken, + originalNextPageToken, isAddRecord = false, isLoaded = true + } = parameters + + const dataStore = state.recordSelection.find(recordItem => { return recordItem.containerUuid === containerUuid }) - commit('setRecordSelection', { + + const newDataStore = { parentUuid: parentUuid, containerUuid: containerUuid, record: record, @@ -364,11 +381,26 @@ const data = { pageNumber: pageNumber, recordCount: recordCount, nextPageToken: nextPageToken, + originalNextPageToken: originalNextPageToken, panelType: panelType, - isLoaded: true, + isLoaded: isLoaded, isLoadedContext: false, - index: index - }) + query: query, + whereClause: whereClause, + orderByClause: orderByClause + } + + if (dataStore) { + if (isAddRecord) { + newDataStore.record = dataStore.record.concat(newDataStore.record) + } + commit('setRecordSelection', { + dataStore: dataStore, + newDataStore: newDataStore + }) + } else { + commit('addRecordSelection', newDataStore) + } }, /** * Set selection in data list associated in container @@ -406,6 +438,7 @@ const data = { return itemRecord.containerUuid !== viewUuid }) commit('deleteRecordContainer', record) + dispatch('setTabSequenceRecord', []) if (setNews.length) { setNews.forEach(uuid => { @@ -453,7 +486,11 @@ const data = { * @param {array} conditions, conditions to criteria */ getObjectListFromCriteria({ commit, dispatch, getters, rootGetters }, parameters) { - const { parentUuid, containerUuid, tableName, query, whereClause, orderByClause, conditions = [], isShowNotification = true, isParentTab = true } = parameters + const { + parentUuid, containerUuid, + tableName, query, whereClause, orderByClause, conditions = [], + isShowNotification = true, isParentTab = true, isAddRecord = false + } = parameters if (isShowNotification) { showMessage({ title: language.t('notifications.loading'), @@ -463,12 +500,12 @@ const data = { } const dataStore = getters.getDataRecordAndSelection(containerUuid) - var nextPageToken + let nextPageToken if (!isEmptyValue(dataStore.nextPageToken)) { nextPageToken = dataStore.nextPageToken + '-' + dataStore.pageNumber } - var inEdited = [] + let inEdited = [] if (!isParentTab) { // TODO: Evaluate peformance to evaluate records to edit inEdited = dataStore.record.filter(itemRecord => { @@ -499,11 +536,11 @@ const data = { .then(response => { const recordList = response.getRecordsList() const record = recordList.map(itemRecord => { - var values = convertValuesMapToObject( + const values = convertValuesMapToObject( itemRecord.getValuesMap() ) - // datatables attribute + // datatables attributes values.isNew = false values.isEdit = false values.isSelected = false @@ -521,14 +558,15 @@ const data = { } }) - var token = response.getNextPageToken() - if (!isEmptyValue(token)) { + const originalNextPageToken = response.getNextPageToken() + let token = originalNextPageToken + if (isEmptyValue(token)) { + token = dataStore.nextPageToken + } else { token = token.slice(0, -2) if (token.substr(-1, 1) === '-') { token = token.slice(0, -1) } - } else { - token = dataStore.nextPageToken } if (isShowNotification) { let searchMessage = 'searchWithOutRecords' @@ -548,7 +586,12 @@ const data = { selection: dataStore.selection, recordCount: response.getRecordcount(), nextPageToken: token, - pageNumber: dataStore.pageNumber + originalNextPageToken: originalNextPageToken, + isAddRecord: isAddRecord, + pageNumber: dataStore.pageNumber, + tableName: tableName, + query: query, + whereClause: whereClause }) return record }) @@ -567,7 +610,7 @@ const data = { type: 'error' }) } - console.warn('Error Get Object List ' + error.message + '. Code: ' + error.code) + console.warn(`Error Get Object List ${error.message}. Code: ${error.code}`) }) .finally(() => { commit('deleteInGetting', { @@ -850,7 +893,11 @@ const data = { getPrivateAccessFromServer({ commit, rootGetters }, parameters) { const { tableName, recordId } = parameters const userUuid = rootGetters['user/getUserUuid'] - return getPrivateAccessFromServer({ tableName: tableName, recordId: recordId, userUuid: userUuid }) + return getPrivateAccessFromServer({ + tableName: tableName, + recordId: recordId, + userUuid: userUuid + }) .then(privateAccess => { if (privateAccess.getRecordid()) { var recordPrivateAccess = { @@ -876,7 +923,11 @@ const data = { lockRecord({ commit, rootGetters }, parameters) { const { tableName, recordId } = parameters const userUuid = rootGetters['user/getUserUuid'] - return lockPrivateAccessFromServer({ tableName: tableName, recordId: recordId, userUuid: userUuid }) + return lockPrivateAccessFromServer({ + tableName: tableName, + recordId: recordId, + userUuid: userUuid + }) .then(response => { if (response.getRecordid()) { const recordLocked = { @@ -906,7 +957,11 @@ const data = { unlockRecord({ commit, rootGetters, state }, parameters) { const { tableName, recordId } = parameters const userUuid = rootGetters['user/getUserUuid'] - return unlockPrivateAccessFromServer({ tableName: tableName, recordId: recordId, userUuid: userUuid }) + return unlockPrivateAccessFromServer({ + tableName: tableName, + recordId: recordId, + userUuid: userUuid + }) .then(response => { if (response.getRecordid()) { const recordUnlocked = { @@ -934,7 +989,9 @@ const data = { }) }, requestPrintFormats({ commit }, parameters) { - return requestPrintFormats({ processUuid: parameters.processUuid }) + return requestPrintFormats({ + processUuid: parameters.processUuid + }) .then(response => { const printFormatList = response.getPrintformatsList().map(printFormat => { return { @@ -973,6 +1030,7 @@ const data = { selection: [], pageNumber: 1, nextPageToken: undefined, + originalNextPageToken: undefined, isLoadedContext: false, isLoaded: false // Boolean(false || getters.getInGetting(containerUuid)) } @@ -983,9 +1041,12 @@ const data = { getDataRecordCount: (state, getters) => (containerUuid) => { return getters.getDataRecordAndSelection(containerUuid).recordCount }, - getPageNextToken: (state, getters) => (containerUuid) => { + getNextPageToken: (state, getters) => (containerUuid) => { return getters.getDataRecordAndSelection(containerUuid).nextPageToken }, + getOriginalNextPageToken: (state, getters) => (containerUuid) => { + return getters.getDataRecordAndSelection(containerUuid).originalNextPageToken + }, getDataRecordSelection: (state, getters) => (containerUuid) => { return getters.getDataRecordAndSelection(containerUuid).selection }, diff --git a/src/store/modules/ADempiere/panel.js b/src/store/modules/ADempiere/panel.js index c00cf683..37e8b081 100644 --- a/src/store/modules/ADempiere/panel.js +++ b/src/store/modules/ADempiere/panel.js @@ -58,10 +58,11 @@ const panel = { } }, actions: { - addPanel({ commit, dispatch }, params) { - var keyColumn = '' - var selectionColumn = [] - var count = 0 + addPanel({ commit, dispatch, getters }, params) { + let keyColumn = '' + let selectionColumn = [] + let identifierColumns = [] + let count = 0 params.fieldList.forEach(itemField => { if (itemField.isKey) { keyColumn = itemField.columnName @@ -69,6 +70,13 @@ const panel = { if (itemField.isSelectionColumn) { selectionColumn.push(itemField.columnName) } + if (itemField.isIdentifier) { + identifierColumns.push({ + columnName: itemField.columnName, + identifierSequence: itemField.identifierSequence, + componentPath: itemField.componentPath + }) + } if (params.panelType === 'table' || params.isAdvancedQuery) { itemField.isShowedFromUser = false @@ -89,7 +97,19 @@ const panel = { }) params.keyColumn = keyColumn + if (params.isSortTab) { + const panelParent = getters.getPanel(params.tabAssociatedUuid) + selectionColumn = selectionColumn.concat(panelParent.selectionColumn) + identifierColumns = identifierColumns.concat(panelParent.identifierColumns) + params.fieldLinkColumnName = panelParent.fieldLinkColumnName + params.keyColumn = panelParent.keyColumn + } params.selectionColumn = selectionColumn + params.identifierColumns = identifierColumns + .sort((itemA, itemB) => { + return itemA.identifierSequence - itemB.identifierSequence + }) + params.recordUuid = null params.fieldList = assignedGroup(params.fieldList) @@ -683,7 +703,7 @@ const panel = { commit('changeFieldValue', newField) }, getPanelAndFields({ dispatch }, parameters) { - if (parameters.type === 'process' || parameters.type === 'report') { + if (parameters.panelType === 'process' || parameters.panelType === 'report') { return dispatch('getProcessFromServer', parameters) .then(response => { return response @@ -691,11 +711,11 @@ const panel = { .catch(error => { return { ...error, - moreInfo: `Dictionary getPanelAndFields ${parameters.type} (State Panel)`, + moreInfo: `Dictionary getPanelAndFields ${parameters.panelType} (State Panel)`, parameters: parameters } }) - } else if (parameters.type === 'browser') { + } else if (parameters.panelType === 'browser') { return dispatch('getBrowserFromServer', parameters) .then(response => { return response @@ -707,12 +727,12 @@ const panel = { parameters: parameters } }) - } else if (parameters.type === 'window' || parameters.type === 'table') { + } else if (parameters.panelType === 'window' || parameters.panelType === 'table') { return dispatch('getTabAndFieldFromServer', { parentUuid: parameters.parentUuid, containerUuid: parameters.containerUuid, isAdvancedQuery: parameters.isAdvancedQuery, - panelType: parameters.type + panelType: parameters.panelType }).then(response => { return response }).catch(error => { diff --git a/src/store/modules/ADempiere/processControl.js b/src/store/modules/ADempiere/processControl.js index bb054bf7..ff3b0303 100644 --- a/src/store/modules/ADempiere/processControl.js +++ b/src/store/modules/ADempiere/processControl.js @@ -418,15 +418,31 @@ const processControl = { * * @param {object} params */ - setShowDialog({ commit }, params) { - if (params.type === 'process' || params.type === 'report' || params.type === 'window') { - if (params.action) { - commit('setMetadata', params.action) + setShowDialog({ state, commit, dispatch, rootGetters }, params) { + const panels = ['process', 'report', 'window'] + if (params.action && (panels.includes(params.type) || panels.includes(params.action.panelType))) { + if (params.action.containerUuid === state.metadata.containerUuid) { commit('setShowDialog', true) - } else { - commit('setShowDialog', false) + return } + const panel = rootGetters.getPanel(params.action.containerUuid) + if (!panel) { + dispatch('getPanelAndFields', { + parentUuid: params.action.parentUuid, + containerUuid: params.action.containerUuid, + panelType: params.action.panelType + }) + .then(response => { + commit('setMetadata', response) + commit('setShowDialog', true) + }) + } else { + commit('setMetadata', panel) + commit('setShowDialog', true) + } + return } + commit('setShowDialog', false) }, finishProcess({ commit }, parameters) { var processMessage = { diff --git a/src/store/modules/ADempiere/window.js b/src/store/modules/ADempiere/window.js index 2949234c..5559ff90 100644 --- a/src/store/modules/ADempiere/window.js +++ b/src/store/modules/ADempiere/window.js @@ -46,7 +46,30 @@ const window = { const childrenTabs = [] const parentTabs = [] - const tabs = responseWindow.tabsList.map((tabItem, index) => { + const tabsSequence = [] + // TODO Add source tab on the server for tabs Translation and Sort + const tabs = responseWindow.tabsList.filter(itemTab => { + if (itemTab.isSortTab) { + // TODO: Add convert tab as process function + tabsSequence.push({ + uuid: itemTab.uuid, + id: itemTab.id, + parentUuid: windowUuid, + containerUuid: itemTab.uuid, + parentTabUuid: itemTab.parentTabUuid, + panelType: 'window', + type: 'sequence', + isSortTab: itemTab.isSortTab, + name: itemTab.name, + description: itemTab.description, + tableName: itemTab.tableName, + sortOrderColumnName: itemTab.sortOrderColumnName, // order column + sortYesNoColumnName: itemTab.sortYesNoColumnName // included column + }) + } + // TODO: Add support to isAdvancedTab, isTranslationTab and isHasTree + return !itemTab.isTranslationTab + }).map((tabItem, index, list) => { // let tab = tabItem const tab = { ...tabItem, @@ -58,6 +81,7 @@ const window = { // relations isParentTab: Boolean(firstTab === tabItem.tableName), // app properties + isAssociatedTabSequence: false, // show modal with order tab isShowedRecordNavigation: !(tabItem.isSingleRow), isLoadFieldList: false, index: index @@ -110,6 +134,32 @@ const window = { recordId: null }) + if (tab.isSortTab) { + const tabParent = list.find(itemTab => itemTab.tableName === tab.tableName && !itemTab.isSortTab) + if (tabParent) { + tab.tabAssociatedUuid = tabParent.uuid // tab source uuid + tab.tabAssociatedName = tabParent.name // tab source name + } + } else { + // add tabs sequence associated as process in tab source + let orderTabs = tabsSequence.filter(itemTab => itemTab.tableName === tab.tableName) + if (orderTabs.length) { + orderTabs = orderTabs.map(itemTab => { + return { + ...itemTab, + // appication attributes + tabAssociatedUuid: tab.uuid, // tab source + tabAssociatedName: tab.name, // tab source + action: 'orderSequence', + type: 'application' + } + }) + actions = actions.concat(orderTabs) + tab.isAssociatedTabSequence = true + tab.tabsOrder = orderTabs + } + } + // get processess associated in tab if (tabItem.processesList && tabItem.processesList.length) { const processList = tabItem.processesList.map(processItem => { @@ -138,17 +188,12 @@ const window = { references: [] }) - // TODO: Add support to isSortTab and isTranslationTab - if (!(tab.isSortTab || tab.isTranslationTab)) { - if (tab.isParentTab) { - parentTabs.push(tab) - } else { - childrenTabs.push(tab) - } + if (tab.isParentTab) { + parentTabs.push(tab) + } else { + childrenTabs.push(tab) } return tab - }).filter(itemTab => { - return !(itemTab.isSortTab || itemTab.isTranslationTab) }) const tabProperties = { @@ -272,35 +317,51 @@ const window = { console.warn(`Dictionary Tab (State Window) - Error ${error.code}: ${error.message}`) }) }, - changeShowedDetailWindow: ({ commit, state }, params) => { + changeShowedDetailWindow({ commit, state }, { + containerUuid, + isShowedDetail = true + }) { const window = state.window.find(itemWindow => { - return itemWindow.uuid === params.containerUuid + return itemWindow.uuid === containerUuid }) commit('changeShowedDetailWindow', { window: window, - changeShowedDetail: params.isShowedDetail + changeShowedDetail: isShowedDetail }) }, - changeShowedRecordWindow: ({ commit, state }, params) => { + changeShowedRecordWindow({ commit, state }, { + parentUuid, + isShowedRecordNavigation = true + }) { const window = state.window.find(itemWindow => { - return itemWindow.uuid === params.parentUuid + return itemWindow.uuid === parentUuid }) commit('changeShowedRecordWindow', { window: window, - isShowedRecordNavigation: params.isShowedRecordNavigation + isShowedRecordNavigation: isShowedRecordNavigation }) }, /** - * @param {string} parameters.parentUuid - * @param {string} parameters.containerUuid + * @param {string} parentUuid + * @param {string} containerUuid */ - setCurrentTab: ({ commit, getters }, parameters) => { + setCurrentTab({ commit, getters }, { + parentUuid, + containerUuid + }) { commit('setCurrentTab', { - window: getters.getWindow(parameters.parentUuid), - tabUuid: parameters.containerUuid + window: getters.getWindow(parentUuid), + tabUuid: containerUuid }) }, - setTabIsLoadField: ({ commit, getters }, { parentUuid, containerUuid }) => { + /** + * Indicate if fields is load in tab (containerUuid) + * @param {string} parentUuid + * @param {string} containerUuid + */ + setTabIsLoadField({ commit, getters }, { + parentUuid, containerUuid + }) { const tab = getters.getTab(parentUuid, containerUuid) commit('setTabIsLoadField', { tab: tab, @@ -314,9 +375,6 @@ const window = { item => item.uuid === windowUuid ) }, - getIndexWindow: (state) => { - return state.windowIndex - }, getIsShowedRecordNavigation: (state, getters) => (windowUuid) => { const window = getters.getWindow(windowUuid) if (window) { diff --git a/src/store/modules/ADempiere/windowControl.js b/src/store/modules/ADempiere/windowControl.js index 5359413f..8381320a 100644 --- a/src/store/modules/ADempiere/windowControl.js +++ b/src/store/modules/ADempiere/windowControl.js @@ -13,7 +13,10 @@ const windowControl = { fullPath: '', query: {} }, - dataLog: {} // { containerUuid, recordId, tableName, eventType } + dataLog: {}, // { containerUuid, recordId, tableName, eventType } + tabSequenceRecord: [], + totalResponse: 0, + totalRequest: 0 }, mutations: { addInCreate(state, payload) { @@ -42,6 +45,15 @@ const windowControl = { }, setWindowOldRoute(state, payload) { state.windowOldRoute = payload + }, + setTabSequenceRecord(state, payload) { + state.tabSequenceRecord = payload + }, + setTotalResponse(state, payload) { + state.totalResponse = payload + }, + setTotalRequest(state, payload) { + state.totalRequest = payload } }, actions: { @@ -526,20 +538,15 @@ const windowControl = { */ getDataListTab({ dispatch, rootGetters }, parameters) { const { - parentUuid, - containerUuid, - recordUuid, - isRefreshPanel = false, - isLoadAllRecords = false, - isReference = false, - referenceWhereClause = '', - columnName, - value, - criteria + parentUuid, containerUuid, recordUuid, + referenceWhereClause = '', columnName, value, criteria, + isRefreshPanel = false, isLoadAllRecords = false, isReference = false, + isShowNotification = true } = parameters + let { isAddRecord = false } = parameters const tab = rootGetters.getTab(parentUuid, containerUuid) - var parsedQuery = tab.query + let parsedQuery = tab.query if (!isEmptyValue(parsedQuery) && parsedQuery.includes('@')) { parsedQuery = parseContext({ parentUuid: parentUuid, @@ -548,7 +555,7 @@ const windowControl = { }, true) } - var parsedWhereClause = tab.whereClause + let parsedWhereClause = tab.whereClause if (!isEmptyValue(parsedWhereClause) && parsedWhereClause.includes('@')) { parsedWhereClause = parseContext({ parentUuid: parentUuid, @@ -573,7 +580,7 @@ const windowControl = { } } - var conditions = [] + const conditions = [] if (tab.isParentTab && !isEmptyValue(tab.tableName) && !isEmptyValue(value)) { conditions.push({ columnName: columnName, @@ -589,7 +596,9 @@ const windowControl = { orderByClause: tab.orderByClause, // TODO: evaluate if overwrite values to conditions conditions: isLoadAllRecords ? [] : conditions, - isParentTab: tab.isParentTab + isParentTab: tab.isParentTab, + isAddRecord: isAddRecord, + isShowNotification: isShowNotification }) .then(response => { if (isRefreshPanel && !isEmptyValue(recordUuid) && recordUuid !== 'create-new') { @@ -615,6 +624,53 @@ const windowControl = { .catch(error => { return error }) + .finally(() => { + const currentData = rootGetters.getDataRecordAndSelection(containerUuid) + const { originalNextPageToken, pageNumber, recordCount } = currentData + let nextPage = pageNumber + const isAdd = isAddRecord + if (originalNextPageToken && isAddRecord) { + const pageInToken = originalNextPageToken.substring(originalNextPageToken.length - 2) + if (pageInToken === '-1') { + isAddRecord = false + } + if (pageNumber === 1 && recordCount > 50) { + nextPage = nextPage + 1 + isAddRecord = true + } + } else { + isAddRecord = false + } + if (recordCount <= 50) { + isAddRecord = false + } + + if (isAddRecord) { + dispatch('setPageNumber', { + parentUuid: parentUuid, + containerUuid: containerUuid, + pageNumber: nextPage, + panelType: 'window', + isAddRecord: isAddRecord, + isShowNotification: false + }) + } + if (isAdd && isAdd !== isAddRecord) { + if (tab.isSortTab) { + const record = rootGetters.getDataRecordsList(containerUuid) + const recordToTab = record + .map(itemRecord => { + return { + ...itemRecord + } + }) + .sort((itemA, itemB) => { + return itemA[tab.sortOrderColumnName] - itemB[tab.sortOrderColumnName] + }) + dispatch('setTabSequenceRecord', recordToTab) + } + } + }) }, /** * Get references asociate to record @@ -670,6 +726,86 @@ const windowControl = { }, setWindowOldRoute({ commit }, oldPath = { path: '', fullPath: '', query: {}}) { commit('setWindowOldRoute', oldPath) + }, + setTabSequenceRecord({ commit }, record) { + commit('setTabSequenceRecord', record) + }, + /** + * Update records in tab sort + * @param {string} containerUuid + * @param {string} parentUuid + */ + updateSequence({ state, commit, dispatch, getters, rootGetters }, { + parentUuid, + containerUuid + }) { + const { tableName, sortOrderColumnName, sortYesNoColumnName, tabAssociatedUuid } = rootGetters.getTab(parentUuid, containerUuid) + const listSequenceToSet = getters.getTabSequenceRecord + const recordData = rootGetters.getDataRecordsList(containerUuid) + + // scrolls through the logs and checks if there is a change to be sent to server + recordData.forEach(itemData => { + const dataSequence = listSequenceToSet.find(item => item.UUID === itemData.UUID) + if (itemData[sortOrderColumnName] === dataSequence[sortOrderColumnName]) { + return + } + const valuesToSend = [{ + columnName: sortOrderColumnName, + value: dataSequence[sortOrderColumnName] + }] + + if (itemData[sortYesNoColumnName] !== dataSequence[sortYesNoColumnName]) { + valuesToSend.push({ + columnName: sortYesNoColumnName, + value: dataSequence[sortYesNoColumnName] + }) + } + + const countRequest = state.totalRequest + 1 + commit('setTotalRequest', countRequest) + + updateEntity({ + tableName: tableName, + recordUuid: itemData.UUID, + attributesList: valuesToSend + }) + .catch(error => { + showMessage({ + message: error.message, + type: 'error' + }) + console.warn(`Update Entity Table Error ${error.code}: ${error.message}`) + }) + .finally(() => { + const countResponse = state.totalResponse + 1 + commit('setTotalResponse', countResponse) + if (state.totalResponse === state.totalRequest) { + showMessage({ + message: language.t('notifications.updateSuccessfully'), + type: 'success' + }) + dispatch('setShowDialog', { + type: 'window', + action: undefined + }) + commit('setTotalRequest', 0) + commit('setTotalResponse', 0) + + dispatch('setRecordSelection', { + parentUuid: parentUuid, + containerUuid: containerUuid, + isLoaded: false + }) + dispatch('setTabSequenceRecord', []) + + // refresh record list in table source + dispatch('getDataListTab', { + parentUuid: parentUuid, + containerUuid: tabAssociatedUuid + }) + } + }) + }) } }, getters: { @@ -688,6 +824,9 @@ const windowControl = { return state.windowRoute } }, + getTabSequenceRecord: (state) => { + return state.tabSequenceRecord + }, getDataLog: (state) => (containerUuid, recordUuid) => { const current = state.dataLog if (current.containerUuid === containerUuid && diff --git a/src/utils/ADempiere/dictionaryUtils.js b/src/utils/ADempiere/dictionaryUtils.js index 6d897d36..aee01ce2 100644 --- a/src/utils/ADempiere/dictionaryUtils.js +++ b/src/utils/ADempiere/dictionaryUtils.js @@ -455,39 +455,39 @@ export function convertAction(action) { switch (action) { case 'B': - actionAttributes.name = 'workbech' + actionAttributes.name = 'Workbech' actionAttributes.icon = 'peoples' break case 'F': - actionAttributes.name = 'workflow' + actionAttributes.name = 'Workflow' actionAttributes.icon = 'example' break case 'P': - actionAttributes.name = 'process' + actionAttributes.name = 'Process' actionAttributes.icon = 'component' actionAttributes.component = () => import('@/views/ADempiere/Process') break case 'R': - actionAttributes.name = 'report' + actionAttributes.name = 'Report' actionAttributes.icon = 'skill' actionAttributes.component = () => import('@/views/ADempiere/Process') break case 'S': - actionAttributes.name = 'browser' + actionAttributes.name = 'Browser' actionAttributes.icon = 'search' actionAttributes.component = () => import('@/views/ADempiere/Browser') break case 'T': - actionAttributes.name = 'task' + actionAttributes.name = 'Task' actionAttributes.icon = 'size' break case 'W': - actionAttributes.name = 'window' + actionAttributes.name = 'Window' actionAttributes.icon = 'tab' actionAttributes.component = () => import('@/views/ADempiere/Window') break case 'X': - actionAttributes.name = 'form' + actionAttributes.name = 'Form' actionAttributes.icon = 'form' break default: diff --git a/src/views/ADempiere/Browser/index.vue b/src/views/ADempiere/Browser/index.vue index d9d135a3..ab52e157 100644 --- a/src/views/ADempiere/Browser/index.vue +++ b/src/views/ADempiere/Browser/index.vue @@ -153,7 +153,7 @@ export default { } else { this.$store.dispatch('getPanelAndFields', { containerUuid: this.browserUuid, - type: this.panelType, + panelType: this.panelType, routeToDelete: this.$route }) .then(() => { diff --git a/src/views/ADempiere/Process/index.vue b/src/views/ADempiere/Process/index.vue index 17331d3d..a8f7271d 100644 --- a/src/views/ADempiere/Process/index.vue +++ b/src/views/ADempiere/Process/index.vue @@ -94,7 +94,7 @@ export default { } else { this.$store.dispatch('getPanelAndFields', { containerUuid: this.processUuid, - type: this.panelType, + panelType: this.panelType, routeToDelete: this.$route }).then(() => { this.processMetadata = this.getterProcess diff --git a/src/views/ADempiere/Window/index.vue b/src/views/ADempiere/Window/index.vue index 73025333..8c3d914f 100644 --- a/src/views/ADempiere/Window/index.vue +++ b/src/views/ADempiere/Window/index.vue @@ -66,7 +66,6 @@ :container-uuid="windowMetadata.currentTabUuid" :panel-type="panelType" :is-insert-record="getterIsInsertRecord" - :modal-metadata="windowMetadata" /> @@ -87,7 +86,7 @@ (isMobile && !isShowedRecordNavigation || !isMobile)" v-show="!isShowedTabChildren" icon="el-icon-caret-top" - :class="classIsMObile" + :class="classIsMobile" circle @click="handleChangeShowedTabChildren()" /> @@ -129,7 +128,6 @@ :window-uuid="windowUuid" :tabs-list="windowMetadata.tabsListChildren" :first-tab-uuid="windowMetadata.firstTabUuid" - :first-index="String(windowMetadata.tabsListChildren[0].index)" :style="{ 'height': getHeightPanelBottom + 'vh' }" /> @@ -214,7 +212,7 @@ export default { return this.$store.state.app.device === 'mobile' }, // convert ternary operator into computed property - classIsMObile() { + classIsMobile() { if (this.isMobile) { return 'open-table-detail-mobile' } else {