fix: Mandatory logic on first field load. (#223)

pull/3759/head
EdwinBetanc0urt 2020-01-14 17:45:25 -04:00 committed by Yamel Senih
parent 04b7c1bb6d
commit f728e4eb43
3 changed files with 32 additions and 27 deletions

View File

@ -9,7 +9,7 @@
:readonly="Boolean(metadata.readonly)" :readonly="Boolean(metadata.readonly)"
:disabled="isDisabled" :disabled="isDisabled"
:maxlength="maxLength" :maxlength="maxLength"
:show-password="metadata.isEncrypted ? true : false" :show-password="Boolean(metadata.isEncrypted)"
@change="preHandleChange" @change="preHandleChange"
/> />
</template> </template>

View File

@ -57,13 +57,13 @@ export default {
}) })
} else if (this.panelType === 'window') { } else if (this.panelType === 'window') {
// compare group fields to window // compare group fields to window
return this.$store.getters.getFieldsListNotMandatory(this.containerUuid) return this.$store.getters.getFieldsListNotMandatory({ containerUuid: this.containerUuid })
.filter(fieldItem => { .filter(fieldItem => {
return fieldItem.groupAssigned === this.groupField return fieldItem.groupAssigned === this.groupField
}) })
} }
// get fields not mandatory // get fields not mandatory
return this.$store.getters.getFieldsListNotMandatory(this.containerUuid) return this.$store.getters.getFieldsListNotMandatory({ containerUuid: this.containerUuid })
}, },
getFieldSelected() { getFieldSelected() {
return this.getterFieldListOptional return this.getterFieldListOptional

View File

@ -529,25 +529,15 @@ const panel = {
} }
} }
// the field has not changed, then the action is broken
if (newValue === field.value && isEmptyValue(displayColumn)) {
return
}
commit('changeFieldValue', {
field,
newValue,
valueTo,
displayColumn,
isChangedOldValue
})
// Change Dependents // Change Dependents
const dependents = fieldList.filter(fieldItem => { let dependentsList = []
if (field.dependentFieldsList.length) {
dependentsList = fieldList.filter(fieldItem => {
return field.dependentFieldsList.includes(fieldItem.columnName) return field.dependentFieldsList.includes(fieldItem.columnName)
}) })
}
// Iterate for change logic // Iterate for change logic
dependents.forEach(dependent => { dependentsList.forEach(dependent => {
// isDisplayed Logic // isDisplayed Logic
let isDisplayedFromLogic, isMandatoryFromLogic, isReadOnlyFromLogic let isDisplayedFromLogic, isMandatoryFromLogic, isReadOnlyFromLogic
if (dependent.displayLogic.trim() !== '') { if (dependent.displayLogic.trim() !== '') {
@ -585,6 +575,19 @@ const panel = {
}) })
}) })
// the field has not changed, then the action is broken
if (newValue === field.value && isEmptyValue(displayColumn)) {
return
}
commit('changeFieldValue', {
field,
newValue,
valueTo,
displayColumn,
isChangedOldValue
})
// request callouts // request callouts
if (field.panelType === 'window' && isSendCallout) { if (field.panelType === 'window' && isSendCallout) {
if (!withOutColumnNames.includes(field.columnName) && !isEmptyValue(newValue) && !isEmptyValue(field.callout)) { if (!withOutColumnNames.includes(field.columnName) && !isEmptyValue(newValue) && !isEmptyValue(field.callout)) {
@ -838,9 +841,8 @@ const panel = {
var fieldList = getters.getFieldsListFromPanel(containerUuid).filter(fieldItem => { var fieldList = getters.getFieldsListFromPanel(containerUuid).filter(fieldItem => {
const isMandatory = fieldItem.isMandatory || fieldItem.isMandatoryFromLogic const isMandatory = fieldItem.isMandatory || fieldItem.isMandatoryFromLogic
if (isMandatory) { if (isMandatory) {
const isDisplayed = fieldIsDisplayed(fieldItem)
if (evaluateShowed) { if (evaluateShowed) {
return isDisplayed return fieldIsDisplayed(fieldItem)
} }
return isMandatory return isMandatory
} }
@ -859,15 +861,18 @@ const panel = {
return fieldItem.name return fieldItem.name
}) })
}, },
// all available fields not mandatory to show, used in components panel/filterFields.vue /**
getFieldsListNotMandatory: (state, getters) => (containerUuid, evaluateShowed = true) => { * Show all available fields not mandatory to show, used in components panel/filterFields.vue
* @param {string} containerUuid
* @param {boolean} isEvaluateShowed
*/
getFieldsListNotMandatory: (state, getters) => ({ containerUuid, isEvaluateShowed = true }) => {
// all optionals (not mandatory) fields // all optionals (not mandatory) fields
return getters.getFieldsListFromPanel(containerUuid).filter(fieldItem => { return getters.getFieldsListFromPanel(containerUuid).filter(fieldItem => {
const isMandatory = fieldItem.isMandatory || fieldItem.isMandatoryFromLogic const isMandatory = fieldItem.isMandatory || fieldItem.isMandatoryFromLogic
if (!isMandatory) { if (!isMandatory) {
const isDisplayed = fieldIsDisplayed(fieldItem) if (isEvaluateShowed) {
if (evaluateShowed) { return fieldIsDisplayed(fieldItem)
return isDisplayed
} }
return !isMandatory return !isMandatory
} }