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)"
:disabled="isDisabled"
:maxlength="maxLength"
:show-password="metadata.isEncrypted ? true : false"
:show-password="Boolean(metadata.isEncrypted)"
@change="preHandleChange"
/>
</template>

View File

@ -57,13 +57,13 @@ export default {
})
} else if (this.panelType === 'window') {
// compare group fields to window
return this.$store.getters.getFieldsListNotMandatory(this.containerUuid)
return this.$store.getters.getFieldsListNotMandatory({ containerUuid: this.containerUuid })
.filter(fieldItem => {
return fieldItem.groupAssigned === this.groupField
})
}
// get fields not mandatory
return this.$store.getters.getFieldsListNotMandatory(this.containerUuid)
return this.$store.getters.getFieldsListNotMandatory({ containerUuid: this.containerUuid })
},
getFieldSelected() {
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
const dependents = fieldList.filter(fieldItem => {
return field.dependentFieldsList.includes(fieldItem.columnName)
})
let dependentsList = []
if (field.dependentFieldsList.length) {
dependentsList = fieldList.filter(fieldItem => {
return field.dependentFieldsList.includes(fieldItem.columnName)
})
}
// Iterate for change logic
dependents.forEach(dependent => {
dependentsList.forEach(dependent => {
// isDisplayed Logic
let isDisplayedFromLogic, isMandatoryFromLogic, isReadOnlyFromLogic
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
if (field.panelType === 'window' && isSendCallout) {
if (!withOutColumnNames.includes(field.columnName) && !isEmptyValue(newValue) && !isEmptyValue(field.callout)) {
@ -838,9 +841,8 @@ const panel = {
var fieldList = getters.getFieldsListFromPanel(containerUuid).filter(fieldItem => {
const isMandatory = fieldItem.isMandatory || fieldItem.isMandatoryFromLogic
if (isMandatory) {
const isDisplayed = fieldIsDisplayed(fieldItem)
if (evaluateShowed) {
return isDisplayed
return fieldIsDisplayed(fieldItem)
}
return isMandatory
}
@ -859,15 +861,18 @@ const panel = {
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
return getters.getFieldsListFromPanel(containerUuid).filter(fieldItem => {
const isMandatory = fieldItem.isMandatory || fieldItem.isMandatoryFromLogic
if (!isMandatory) {
const isDisplayed = fieldIsDisplayed(fieldItem)
if (evaluateShowed) {
return isDisplayed
if (isEvaluateShowed) {
return fieldIsDisplayed(fieldItem)
}
return !isMandatory
}