From 94788e0e7cbffd2bfdfb69acb40ef587fc662a47 Mon Sep 17 00:00:00 2001 From: elsiosanchez <45974454+elsiosanchez@users.noreply.github.com> Date: Tue, 4 Feb 2020 10:38:58 -0400 Subject: [PATCH] changing chat structure and asynchronous methods (#298) * changing chat structure and asynchronous methods * changing descending order * reverse changes * change constante * clear notes when new record * clear notes when new record * rename change history to activities --- src/api/ADempiere/data.js | 2 + src/lang/ADempiere/en.js | 4 +- src/lang/ADempiere/es.js | 4 +- src/store/modules/ADempiere/containerInfo.js | 27 +++- src/views/ADempiere/Window/index.vue | 152 ++++++++++--------- 5 files changed, 107 insertions(+), 82 deletions(-) diff --git a/src/api/ADempiere/data.js b/src/api/ADempiere/data.js index c91565ce..8e93d5ff 100644 --- a/src/api/ADempiere/data.js +++ b/src/api/ADempiere/data.js @@ -464,6 +464,7 @@ export function requestListWorkflows({ * @param {string} pageSize */ export function requestListRecordChats({ tableName, recordId, pageToken, pageSize }) { + console.log(tableName, recordId, Instance.call(this).requestListRecordChats({ tableName, recordId, pageToken, pageSize })) return Instance.call(this).requestListRecordChats({ tableName, recordId, @@ -478,6 +479,7 @@ export function requestListRecordChats({ tableName, recordId, pageToken, pageSiz * @param {string} pageSize */ export function requestListChatEntries({ uuid, pageToken, pageSize }) { + console.log(uuid, Instance.call(this).requestListChatEntries({ uuid, pageToken, pageSize })) return Instance.call(this).requestListChatEntries({ uuid, pageToken, diff --git a/src/lang/ADempiere/en.js b/src/lang/ADempiere/en.js index b47de3d8..17668ff2 100644 --- a/src/lang/ADempiere/en.js +++ b/src/lang/ADempiere/en.js @@ -271,7 +271,7 @@ export default { undoNew: 'Undo New Record', containerInfo: { notes: 'Notes', - changeLog: 'Change Log', + changeLog: 'ACtivity', workflowLog: 'Workflow Log', changeDetail: 'Change detail', logWorkflow: { @@ -279,7 +279,7 @@ export default { responsible: 'Responsible', workflowName: 'Name of Workflow Status', timeElapsed: 'Time Elapsed', - addNote: 'Notas' + addNote: 'Add Note' } } }, diff --git a/src/lang/ADempiere/es.js b/src/lang/ADempiere/es.js index 25d94a60..ec259afe 100644 --- a/src/lang/ADempiere/es.js +++ b/src/lang/ADempiere/es.js @@ -246,7 +246,7 @@ export default { undoNew: 'Descartar Nuevo Registro', containerInfo: { notes: 'Notas', - changeLog: 'Histórico de Cambios', + changeLog: 'Actividad', workflowLog: 'Histórico de Flujo de Trabajo', changeDetail: 'Detalle del cambio', logWorkflow: { @@ -254,7 +254,7 @@ export default { responsible: 'Responsable', workflowName: 'Nombre de estado del flujo de trabajo', timeElapsed: 'Tiempo transcurrido', - addNote: 'Notas' + addNote: 'Agregar Nota' } } }, diff --git a/src/store/modules/ADempiere/containerInfo.js b/src/store/modules/ADempiere/containerInfo.js index 7e11be20..528b3191 100644 --- a/src/store/modules/ADempiere/containerInfo.js +++ b/src/store/modules/ADempiere/containerInfo.js @@ -8,7 +8,8 @@ const containerInfo = { listRecordChats: [], listChatEntries: [], listWorkflows: [], - note: [] + note: [], + isNote: false }, mutations: { addListWorkflow(state, payload) { @@ -28,6 +29,9 @@ const containerInfo = { }, addNote(state, payload) { state.note = payload + }, + isNote(state, payload) { + state.isNote = payload } }, actions: { @@ -37,12 +41,16 @@ const containerInfo = { const comment = params.comment return requestCreateChatEntry({ tableName, recordId, comment }) .then(response => { + commit('isNote', true) dispatch('listChatEntries', { - tableName: params.tableName, - recordId: params.recordId + tableName: tableName, + recordId: recordId }) commit('addNote', response) }) + .catch(error => { + console.warn(`Error getting epale error en guardar: ${error.message}. Code: ${error.code}.`) + }) }, listWorkflowLogs({ commit, state, dispatch }, params) { const tableName = params.tableName @@ -65,6 +73,9 @@ const containerInfo = { console.warn(`Error getting List workflow: ${error.message}. Code: ${error.code}.`) }) }, + isNote({ commit }, params) { + commit('isNote', params) + }, listWorkflows({ commit, state }, params) { const tableName = params.tableName const pageSize = 0 @@ -105,9 +116,9 @@ const containerInfo = { var listRecord = { recordChatsList: response.recordChatsList, recordCount: response.recordCount, - epale: isEmptyValue(response.recordChatsList), nextPageToken: response.nextPageToken } + commit('isNote', !isEmptyValue(response.recordChatsList)) dispatch('listRecordChat', { chatUuid: response.recordChatsList[0].chatUuid }) @@ -143,10 +154,16 @@ const containerInfo = { return state.listRecordLogs }, getListRecordChats: (state) => { - return state.listRecordChats + return state.listRecordChats.recordChatsList }, getChatEntries: (state) => { return state.listChatEntries + }, + getAddNote: (state) => { + return state.note + }, + getIsNote: (state) => { + return state.isNote } } } diff --git a/src/views/ADempiere/Window/index.vue b/src/views/ADempiere/Window/index.vue index 1ccc69fa..591f56b6 100644 --- a/src/views/ADempiere/Window/index.vue +++ b/src/views/ADempiere/Window/index.vue @@ -158,6 +158,51 @@

+ + {{ $t('window.containerInfo.notes') }} +

+ +
+ {{ $t('window.containerInfo.notes') }} +
+ + + + +
+ {{ chats.userName }} + {{ chats.characterData }} +
+
+
+
+
+
+
+
+ +
+ {{ $t('window.containerInfo.logWorkflow.addNote') }} +
+ + +
+
+ @@ -202,6 +247,7 @@ /> {{ $t('window.containerInfo.workflowLog') }} @@ -265,51 +311,6 @@ class="loading-window" /> - - {{ $t('window.containerInfo.notes') }} -
- -
- {{ $t('window.containerInfo.notes') }} -
- - - - -
- {{ chats.userName }} - {{ chats.characterData }} -
-
-
-
-
-
-
-
- -
- {{ $t('window.containerInfo.logWorkflow.addNote') }} -
- -
-
-

@@ -358,7 +359,7 @@ export default { panelType: 'window', isLoaded: false, isPanel: false, - activeInfo: 'listRecordLogs', + activeInfo: 'listChatEntries', show: false, chatNote: '', typeAction: 0, @@ -470,7 +471,16 @@ export default { return false }, gettersListRecordLogs() { - return this.$store.getters.getRecordLogs.recorLogs + const changeLog = this.$store.getters.getRecordLogs.recorLogs + if (this.isEmptyValue(changeLog)) { + return changeLog + } + changeLog.sort((a, b) => { + var c = new Date(a.logDate) + var d = new Date(b.logDate) + return d - c + }) + return changeLog }, getIsChangeLog() { if (this.isEmptyValue(this.gettersListRecordLogs)) { @@ -485,10 +495,7 @@ export default { return true }, getIsChat() { - if (this.isEmptyValue(this.gettersLisRecordChats)) { - return false - } - return true + return this.$store.getters.getIsNote }, getTypeLogs() { const groupLog = this.gettersListRecordLogs.reduce((groupLog, item) => { @@ -509,8 +516,11 @@ export default { gettersLischat() { return this.$store.getters.getChatEntries.chatEntriesList }, - gettersLisRecordChats() { - return this.$store.getters.getListRecordChats + // gettersLisRecordChats() { + // return this.$store.getters.getListRecordChats[0].description + // }, + isNote() { + return this.$store.getters.getIsNote }, gettersListWorkflow() { return this.$store.getters.getWorkflow @@ -527,10 +537,12 @@ export default { }, watch: { $route(value) { - this.$store.dispatch('listChatEntries', { - tableName: value.params.tableName, - recordId: value.params.recordId - }) + if (this.show) { + if (value.query.action === 'create-new') { + this.$store.dispatch('isNote', false) + } + this.refres(this.activeInfo) + } }, 'this.$route.params'(newValue, oldValue) { if (!this.isEmptyValue(newValue)) { @@ -549,6 +561,10 @@ export default { comment: comment }) this.chatNote = '' + // this.$store.dispatch('listChatEntries', { + // tableName: this.$route.params.tableName, + // recordId: this.$route.params.recordId + // }) }, showkey(key, index) { if (key === this.currentKey && index === this.typeAction) { @@ -571,17 +587,15 @@ export default { }, conteInfo() { this.show = !this.show + this.$store.dispatch('listWorkflowLogs', { + tableName: this.$route.params.tableName, + recordId: this.$route.params.recordId + }) this.$store.dispatch('listChatEntries', { tableName: this.$route.params.tableName, recordId: this.$route.params.recordId }) this.$store.dispatch('showContainerInfo', !this.getterShowContainerInfo) - if (this.show) { - this.$store.dispatch('listRecordLogs', { - tableName: this.$route.params.tableName, - recordId: this.$route.params.recordId - }) - } }, handleClick(tab, event) { this.$store.dispatch(tab.name, { @@ -589,16 +603,8 @@ export default { recordId: this.$route.params.recordId }) }, - refres() { - this.$store.dispatch('listWorkflowLogs', { - tableName: this.$route.params.tableName, - recordId: this.$route.params.recordId - }) - this.$store.dispatch('listRecordLogs', { - tableName: this.$route.params.tableName, - recordId: this.$route.params.recordId - }) - this.$store.dispatch('listChatEntries', { + refres(tabInfo) { + this.$store.dispatch(tabInfo, { tableName: this.$route.params.tableName, recordId: this.$route.params.recordId })