Skip to content

Commit

Permalink
feat: Add load report/process panel. (#1292)
Browse files Browse the repository at this point in the history
* feat: Add load report/process panel.

* fix set default values.

* fix readonly and mandatory.

* fix mandatory column.
  • Loading branch information
EdwinBetanc0urt authored Oct 23, 2021
1 parent f9e03e8 commit b32d7ff
Show file tree
Hide file tree
Showing 15 changed files with 459 additions and 442 deletions.
5 changes: 2 additions & 3 deletions src/components/ADempiere/Field/FieldYesNo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
<el-switch
:ref="metadata.columnName"
v-model="value"
:active-text="value ? $t('components.switchActiveText') : $t('components.switchInactiveText')"
:active-text="$t('components.switchActiveText')"
:inactive-text="$t('components.switchInactiveText')"
:class="cssClassStyle"
:true-value="true"
:false-value="false"
:disabled="isDisabled"
@change="preHandleChange"
@blur="focusLost"
Expand Down
120 changes: 28 additions & 92 deletions src/components/ADempiere/Field/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<script>
import FieldOptions from '@/components/ADempiere/Field/FieldOptions/index.vue'
import { evalutateTypeField, fieldIsDisplayed } from '@/utils/ADempiere/dictionaryUtils'
import { evalutateTypeField } from '@/utils/ADempiere/dictionaryUtils'
import { TEXT } from '@/utils/ADempiere/references'
import {
ACTIVE, CLIENT, PROCESSING, PROCESSED
Expand Down Expand Up @@ -223,8 +223,8 @@ export default {
isPanelWindow: this.isPanelWindow,
isAdvancedQuery: this.isAdvancedQuery,
// DOM properties
required: this.isMandatory,
readonly: this.isReadOnly,
required: this.isMandatoryField,
readonly: this.isReadOnlyField,
displayed: this.isDisplayedField,
disabled: !this.field.isActive,
isSelectCreated: this.isSelectCreated,
Expand All @@ -234,32 +234,35 @@ export default {
isDisplayedField() {
// validate with container manager
if (!this.isEmptyValue(this.containerManager) &&
this.containerManager.isDisplayedField) {
return this.containerManager.isDisplayedField(this.field) &&
(this.isMandatory || this.field.isShowedFromUser)
}
if (this.isAdvancedQuery) {
return this.field.isShowedFromUser
}
return fieldIsDisplayed(this.field) &&
(this.isMandatory || this.field.isShowedFromUser || this.inTable)
return this.containerManager.isDisplayedField(this.field) &&
(this.isMandatoryField || this.field.isShowedFromUser || this.inTable)
},
/**
* Idicate if field is read only
*/
isReadOnlyField() {
// TODO: Add validate method to record uuid uuid without route.action
// edit mode is diferent to create new
const isWithRecord = this.recordUuid !== 'create-new' &&
!this.isEmptyValue(this.recordUuid)
isMandatory() {
// validate with container manager
if (!this.isEmptyValue(this.containerManager) &&
this.containerManager.validateMandatory) {
return this.containerManager.isMandatoryField(this.field)
}
if (this.isAdvancedQuery) {
return false
}
return this.field.isMandatory || this.field.isMandatoryFromLogic
return this.containerManager.isReadOnlyField({
field: this.field,
preferenceClientId: this.preferenceClientId,
// record values
clientId: this.containerClientId,
isActive: this.containerIsActive,
isProcessing: this.containerIsProcessing,
isProcessed: this.containerIsProcessed,
isWithRecord
})
},
isMandatoryField() {
// validate with container manager
return this.containerManager.isMandatoryField(this.field)
},
isPanelWindow() {
return this.field.panelType === 'window'
},
Expand Down Expand Up @@ -308,73 +311,6 @@ export default {
return this.$store.getters.getPreferenceClientId
},
/**
* Idicate if field is read only
* TODO: Create common method to evaluate isReadOnly
*/
isReadOnly() {
if (this.isAdvancedQuery) {
if (['NULL', 'NOT_NULL'].includes(this.field.operator)) {
return true
}
return false
}
// validate with container manager
if (!this.isEmptyValue(this.containerManager) &&
this.containerManager.validateReadOnly) {
// TODO: Add validate method to record uuid uuid without route.action
// edit mode is diferent to create new
const isWithRecord = this.recordUuid !== 'create-new' &&
!this.isEmptyValue(this.recordUuid)
return this.containerManager.validateReadOnly({
field: this.field,
preferenceClientId: this.preferenceClientId,
// record values
clientId: this.containerClientId,
isActive: this.containerIsActive,
isProcessing: this.containerIsProcessing,
isProcessed: this.containerIsProcessed,
isWithRecord
})
}
const isUpdateableAllFields = this.field.isReadOnly || this.field.isReadOnlyFromLogic
if (this.isPanelWindow) {
// TODO: Evaluate record uuid without route.action
// edit mode is diferent to create new
let isWithRecord = this.field.recordUuid !== 'create-new'
// evaluate context
if ((this.preferenceClientId !== this.metadataField.clientId) && isWithRecord) {
return true
}
if (this.field.isAlwaysUpdateable) {
return false
}
if (this.field.isProcessingContext || this.field.isProcessedContext) {
return true
}
if (this.inTable) {
isWithRecord = !this.isEmptyValue(this.field.recordUuid)
}
return (!this.field.isUpdateable && isWithRecord) ||
(isUpdateableAllFields || this.field.isReadOnlyFromForm)
} else if (this.field.panelType === 'browser') {
if (this.inTable) {
// browser result
return this.field.isReadOnly
}
// query criteria
return this.field.isReadOnlyFromLogic
}
// other type of panels (process/report)
return Boolean(isUpdateableAllFields)
},
isFieldOnly() {
if (this.inTable || this.field.isFieldOnly) {
return undefined
Expand Down
95 changes: 89 additions & 6 deletions src/store/modules/ADempiere/dictionary/process/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,104 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

import router from '@/router'

import { requestProcessMetadata } from '@/api/ADempiere/dictionary/process.js'
import { generateProcess } from '@/utils/ADempiere/dictionary/process.js'
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'

export default {
getProcessDefinitionFromServer({ commit }, uuid) {
addProcessToList({ commit }, processResponse) {
return new Promise(resolve => {
commit('addProcessToList', processResponse)

resolve(processResponse)
})
},

getProcessDefinitionFromServer({ dispatch }, {
uuid
}) {
return new Promise((resolve, reject) => {
requestProcessMetadata({
uuid
})
.then(process => {
// parameters as fields in panel
process.fields = process.parameters
.then(processResponse => {
const { processDefinition } = generateProcess({
processToGenerate: processResponse
})

dispatch('setProcessDefaultValues', {
containerUuid: processDefinition.uuid,
fieldsList: processDefinition.fieldsList
})

commit('addProcessToList', process)
resolve(process)
dispatch('addProcessToList', processDefinition)
resolve(processDefinition)
})
.catch(error => {
reject(error)
})
})
},

/**
* Used by components/fields/filterFields
*/
changeProcessFieldShowedFromUser({ commit, getters }, {
containerUuid,
groupField,
fieldsShowed,
fieldsList = []
}) {
if (isEmptyValue(fieldsList)) {
fieldsList = getters.getStoredFieldsFromProcess(containerUuid)
}

fieldsList.forEach(itemField => {
if (groupField === itemField.groupAssigned) {
let isShowedFromUser = false
if (fieldsShowed.includes(itemField.columnName)) {
isShowedFromUser = true
}

commit('changeProcessFieldAttribute', {
field: itemField,
attributeName: 'isShowedFromUser',
attributeValue: isShowedFromUser
})
}
})
},

/**
* Set default values to panel
* @param {string} parentUuid
* @param {string} containerUuid
*/
setProcessDefaultValues({ dispatch, getters }, {
containerUuid,
fieldsList = []
}) {
return new Promise(resolve => {
if (isEmptyValue(fieldsList)) {
fieldsList = getters.getStoredFieldsFromProcess(containerUuid)
}

const currentRoute = router.app._route
const defaultAttributes = getters.getParsedDefaultValues({
containerUuid,
isSOTrxMenu: currentRoute.meta.isSalesTransaction,
fieldsList
})

dispatch('updateValuesOfContainer', {
containerUuid,
isOverWriteParent: true,
attributes: defaultAttributes
})

resolve(defaultAttributes)
})
}
}
14 changes: 12 additions & 2 deletions src/store/modules/ADempiere/dictionary/process/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,25 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

import { isEmptyValue } from '@/utils/ADempiere/valueUtils'

/**
* Dictionary Process Getters
*/

export default {
getStoredProcesses: (state) => {
return state.storedProcesses
},

getStoredProcess: (state) => (processUuid) => {
return state.storedProcesses.find(process => process.uuid === processUuid)
return state.storedProcesses[processUuid]
},

getStoredFieldsFromProcess: (state, getters) => (processUuid) => {
const process = getters.getStoredProcess(processUuid)
if (!isEmptyValue(process)) {
return process.fieldsList
}
return undefined
}
}
20 changes: 14 additions & 6 deletions src/store/modules/ADempiere/dictionary/process/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,26 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
import Vue from 'vue'

/**
* Process Mutations
* All related to global store of Dictionary Window
*/
export default {
addProcessToList(state, process) {
if (!isEmptyValue(process)) {
if (!state.storedProcesses.find(processToFind => processToFind.uuid === process.uuid)) {
state.storedProcesses.push(process)
}
}
Vue.set(state.storedProcesses, process.uuid, process)
},

/**
* Change field process attribute
* @param {object} field
* @param {string} attributeName
* @param {mixed} attributeValue
*/
changeProcessFieldAttribute(state, payload) {
const { attributeName, attributeValue } = payload

payload.field[attributeName] = attributeValue
}
}
2 changes: 1 addition & 1 deletion src/store/modules/ADempiere/dictionary/process/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

export default {
storedProcesses: []
storedProcesses: {}
}
1 change: 0 additions & 1 deletion src/store/modules/ADempiere/dictionary/window/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export default {
fieldsList = []
}) {
if (isEmptyValue(fieldsList)) {
console.log(parentUuid, 1, containerUuid)
fieldsList = getters.getStoredFieldsFromTab(parentUuid, containerUuid)
}

Expand Down
Loading

0 comments on commit b32d7ff

Please sign in to comment.