Skip to content

Commit

Permalink
feat: Add update record. (#989)
Browse files Browse the repository at this point in the history
* feat: Add update record.

* delete duplicated call action performed.
  • Loading branch information
EdwinBetanc0urt authored Jul 15, 2021
1 parent 65588c3 commit 529b265
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 11 deletions.
51 changes: 46 additions & 5 deletions src/store/modules/ADempiere/persistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const persistence = {
state: {
persistence: {}
},

mutations: {
resetStatepersistence(state) {
state = {
Expand All @@ -34,7 +35,50 @@ const persistence = {
})
}
},

actions: {
actionPerformed({ commit, getters, dispatch }, {
field,
value
}) {
return new Promise((resolve, reject) => {
commit('addChangeToPersistenceQueue', {
containerUuid: field.containerUuid,
columnName: field.columnName,
value
})

// TODO: Add dictonary getter
const emptyFields = getters.getFieldsListEmptyMandatory({
containerUuid: field.containerUuid,
formatReturn: false
}).filter(itemField => {
return !LOG_COLUMNS_NAME_LIST.includes(itemField.columnName)
}).map(itemField => {
return itemField.name
})

if (!isEmptyValue(emptyFields)) {
showMessage({
message: language.t('notifications.mandatoryFieldMissing') + emptyFields,
type: 'info'
})
return
}

const recordUuid = getters.getUuidOfContainer(field.containerUuid)
dispatch('flushPersistenceQueue', {
containerUuid: field.containerUuid,
tableName: field.tabTableName,
recordUuid
})
.then(response => {
resolve(response)
})
.catch(error => reject(error))
})
},

flushPersistenceQueue({ getters, dispatch }, {
containerUuid,
tableName,
Expand All @@ -56,11 +100,7 @@ const persistence = {
attributesList
})
.then(response => {
dispatch('listRecordLogs', {
tableName: response.tableName,
recordId: response.id,
recordUuid: response.uuid
})
// TODO: Get list record log
resolve(response)
})
.catch(error => reject(error))
Expand All @@ -86,6 +126,7 @@ const persistence = {
})
}
},

getters: {
getPersistenceMap: (state) => (tableName) => {
return state.persistence[tableName]
Expand Down
8 changes: 5 additions & 3 deletions src/views/ADempiere/Test/MultiTabWindow/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ export default defineComponent({
const metadata = multiTabMetadata.result

const containerManager = {
actionPerformed: function(eventInfo) {
console.log('actionPerformed: ', eventInfo)
return new Promise()
actionPerformed: ({ field, value }) => {
root.$store.dispatch('actionPerformed', {
field,
value
})
},

seekRecord: ({ row, tableName, parentUuid, containerUuid }) => {
Expand Down
8 changes: 5 additions & 3 deletions src/views/ADempiere/Test/Window/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ export default defineComponent({
const metadata = standardMetadata.result

const containerManager = {
actionPerformed: function(eventInfo) {
console.log('actionPerformed: ', eventInfo)
return new Promise()
actionPerformed: ({ field, value }) => {
root.$store.dispatch('actionPerformed', {
field,
value
})
},

seekRecord: ({ row, tableName, parentUuid, containerUuid }) => {
Expand Down

0 comments on commit 529b265

Please sign in to comment.