fix: Corrects update records, no value was sent. (#188)
parent
0b95a6e10d
commit
f82d0a49b3
|
@ -38,8 +38,8 @@ const panel = {
|
||||||
payload.fieldList = payload.newFieldList
|
payload.fieldList = payload.newFieldList
|
||||||
},
|
},
|
||||||
changeFieldValue(state, payload) {
|
changeFieldValue(state, payload) {
|
||||||
payload.field.value = payload.newValue
|
|
||||||
payload.field.oldValue = payload.field.value
|
payload.field.oldValue = payload.field.value
|
||||||
|
payload.field.value = payload.newValue
|
||||||
if (payload.isChangedOldValue) {
|
if (payload.isChangedOldValue) {
|
||||||
payload.field.oldValue = payload.newValue
|
payload.field.oldValue = payload.newValue
|
||||||
}
|
}
|
||||||
|
@ -398,37 +398,42 @@ const panel = {
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* TODO: Add fieldAttributes
|
* TODO: Add fieldAttributes
|
||||||
* @param {string} params.parentUuid
|
* @param {string} parentUuid
|
||||||
* @param {string} params.containerUuid
|
* @param {string} containerUuid
|
||||||
* @param {string} params.columnName
|
* @param {string} panelType
|
||||||
* @param {string} params.newValue
|
* @param {boolean} isAdvancedQuery
|
||||||
|
* @param {string} columnName
|
||||||
|
* @param {mixin} newValue
|
||||||
|
* @param {mixin} valueTo
|
||||||
* @param {string} displayColumn, only used for lookup
|
* @param {string} displayColumn, only used for lookup
|
||||||
* @param {string} params.panelType
|
* @param {boolean} isSendToServer
|
||||||
* @param {string} params.isSendToServer
|
* @param {boolean} isSendCallout
|
||||||
* @param {string} params.isAdvancedQuery
|
* @param {boolean} isSendToQuery
|
||||||
|
* @param {boolean} isChangedOldValue
|
||||||
|
* @param {array} withOutColumnNames
|
||||||
*/
|
*/
|
||||||
notifyFieldChange({ commit, dispatch, getters }, params) {
|
notifyFieldChange({ commit, dispatch, getters }, {
|
||||||
const {
|
parentUuid, containerUuid, panelType = 'window', isAdvancedQuery = false, columnName,
|
||||||
parentUuid, containerUuid, columnName, displayColumn, isSendToServer = true,
|
newValue, valueTo, displayColumn,
|
||||||
isAdvancedQuery = false, panelType = 'window', withOutColumnNames = [],
|
isSendToServer = true, isSendCallout = true, isSendToQuery = true,
|
||||||
isSendCallout = true
|
isChangedOldValue = false, withOutColumnNames = []
|
||||||
} = params
|
}) {
|
||||||
const panel = getters.getPanel(containerUuid, isAdvancedQuery)
|
const panel = getters.getPanel(containerUuid, isAdvancedQuery)
|
||||||
var fieldList = panel.fieldList
|
var fieldList = panel.fieldList
|
||||||
// get field
|
// get field
|
||||||
var field = fieldList.find(fieldItem => fieldItem.columnName === columnName)
|
var field = fieldList.find(fieldItem => fieldItem.columnName === columnName)
|
||||||
|
|
||||||
params.newValue = parsedValueComponent({
|
newValue = parsedValueComponent({
|
||||||
fieldType: field.componentPath,
|
fieldType: field.componentPath,
|
||||||
referenceType: field.referenceType,
|
referenceType: field.referenceType,
|
||||||
value: params.newValue
|
value: newValue
|
||||||
})
|
})
|
||||||
|
|
||||||
if (field.isRange) {
|
if (field.isRange) {
|
||||||
params.valueTo = parsedValueComponent({
|
valueTo = parsedValueComponent({
|
||||||
fieldType: field.componentPath,
|
fieldType: field.componentPath,
|
||||||
referenceType: field.referenceType,
|
referenceType: field.referenceType,
|
||||||
value: params.valueTo
|
value: valueTo
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,7 +443,7 @@ const panel = {
|
||||||
parentUuid: parentUuid,
|
parentUuid: parentUuid,
|
||||||
containerUuid: containerUuid,
|
containerUuid: containerUuid,
|
||||||
columnName: columnName,
|
columnName: columnName,
|
||||||
value: params.newValue
|
value: newValue
|
||||||
})
|
})
|
||||||
|
|
||||||
// request context info field
|
// request context info field
|
||||||
|
@ -478,60 +483,52 @@ const panel = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// the field has not changed, then the action is broken
|
// the field has not changed, then the action is broken
|
||||||
if (params.newValue === field.value && isEmptyValue(displayColumn)) {
|
if (newValue === field.value && isEmptyValue(displayColumn)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
commit('changeFieldValue', {
|
commit('changeFieldValue', {
|
||||||
field: field,
|
field: field,
|
||||||
newValue: params.newValue,
|
newValue: newValue,
|
||||||
valueTo: params.valueTo,
|
valueTo: valueTo,
|
||||||
displayColumn: displayColumn,
|
displayColumn: displayColumn,
|
||||||
isChangedOldValue: params.isChangedOldValue
|
isChangedOldValue: isChangedOldValue
|
||||||
})
|
})
|
||||||
|
|
||||||
// Change Dependents
|
// Change Dependents
|
||||||
var dependents = fieldList.filter(fieldItem => {
|
const dependents = 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 => {
|
dependents.forEach(dependent => {
|
||||||
// isDisplayed Logic
|
// isDisplayed Logic
|
||||||
var isDisplayedFromLogic = false
|
let isDisplayedFromLogic, isMandatoryFromLogic, isReadOnlyFromLogic
|
||||||
var isMandatoryFromLogic = false
|
|
||||||
var isReadOnlyFromLogic = false
|
|
||||||
if (dependent.displayLogic.trim() !== '') {
|
if (dependent.displayLogic.trim() !== '') {
|
||||||
isDisplayedFromLogic = evaluator.evaluateLogic({
|
isDisplayedFromLogic = evaluator.evaluateLogic({
|
||||||
context: getters,
|
context: getters,
|
||||||
parentUuid: params.parentUuid,
|
parentUuid: parentUuid,
|
||||||
containerUuid: params.containerUuid,
|
containerUuid: containerUuid,
|
||||||
logic: dependent.displayLogic,
|
logic: dependent.displayLogic,
|
||||||
type: 'displayed'
|
type: 'displayed'
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
isDisplayedFromLogic = undefined
|
|
||||||
}
|
}
|
||||||
// Mandatory Logic
|
// Mandatory Logic
|
||||||
if (dependent.mandatoryLogic.trim() !== '') {
|
if (dependent.mandatoryLogic.trim() !== '') {
|
||||||
isMandatoryFromLogic = evaluator.evaluateLogic({
|
isMandatoryFromLogic = evaluator.evaluateLogic({
|
||||||
context: getters,
|
context: getters,
|
||||||
parentUuid: params.parentUuid,
|
parentUuid: parentUuid,
|
||||||
containerUuid: params.containerUuid,
|
containerUuid: containerUuid,
|
||||||
logic: dependent.mandatoryLogic
|
logic: dependent.mandatoryLogic
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
isReadOnlyFromLogic = undefined
|
|
||||||
}
|
}
|
||||||
// Read Only Logic
|
// Read Only Logic
|
||||||
if (dependent.readOnlyLogic.trim() !== '') {
|
if (dependent.readOnlyLogic.trim() !== '') {
|
||||||
isReadOnlyFromLogic = evaluator.evaluateLogic({
|
isReadOnlyFromLogic = evaluator.evaluateLogic({
|
||||||
context: getters,
|
context: getters,
|
||||||
parentUuid: params.parentUuid,
|
parentUuid: parentUuid,
|
||||||
containerUuid: params.containerUuid,
|
containerUuid: containerUuid,
|
||||||
logic: dependent.readOnlyLogic
|
logic: dependent.readOnlyLogic
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
isReadOnlyFromLogic = undefined
|
|
||||||
}
|
}
|
||||||
commit('changeFieldLogic', {
|
commit('changeFieldLogic', {
|
||||||
field: dependent,
|
field: dependent,
|
||||||
|
@ -543,7 +540,7 @@ const panel = {
|
||||||
|
|
||||||
// request callouts
|
// request callouts
|
||||||
if (field.panelType === 'window' && isSendCallout) {
|
if (field.panelType === 'window' && isSendCallout) {
|
||||||
if (!withOutColumnNames.includes(field.columnName) && !isEmptyValue(params.newValue) && !isEmptyValue(field.callout)) {
|
if (!withOutColumnNames.includes(field.columnName) && !isEmptyValue(newValue) && !isEmptyValue(field.callout)) {
|
||||||
withOutColumnNames.push(field.columnName)
|
withOutColumnNames.push(field.columnName)
|
||||||
dispatch('getCallout', {
|
dispatch('getCallout', {
|
||||||
parentUuid: parentUuid,
|
parentUuid: parentUuid,
|
||||||
|
@ -551,7 +548,7 @@ const panel = {
|
||||||
tableName: panel.tableName,
|
tableName: panel.tableName,
|
||||||
columnName: field.columnName,
|
columnName: field.columnName,
|
||||||
callout: field.callout,
|
callout: field.callout,
|
||||||
value: params.newValue,
|
value: newValue,
|
||||||
oldValue: field.oldValue,
|
oldValue: field.oldValue,
|
||||||
withOutColumnNames: withOutColumnNames
|
withOutColumnNames: withOutColumnNames
|
||||||
})
|
})
|
||||||
|
@ -574,25 +571,15 @@ const panel = {
|
||||||
parentUuid: parentUuid,
|
parentUuid: parentUuid,
|
||||||
containerUuid: containerUuid
|
containerUuid: containerUuid
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(() => {
|
||||||
// change old value so that it is not send in the next update
|
// change old value so that it is not send in the next update
|
||||||
commit('changeFieldValue', {
|
commit('changeFieldValue', {
|
||||||
field: field,
|
field: field,
|
||||||
newValue: params.newValue,
|
newValue: newValue,
|
||||||
valueTo: params.valueTo,
|
valueTo: valueTo,
|
||||||
displayColumn: params.displayColumn,
|
displayColumn: displayColumn,
|
||||||
isChangedOldValue: true
|
isChangedOldValue: true
|
||||||
})
|
})
|
||||||
|
|
||||||
var oldRoute = router.app._route
|
|
||||||
router.push({
|
|
||||||
name: oldRoute.name,
|
|
||||||
query: {
|
|
||||||
...oldRoute.query,
|
|
||||||
action: response.recordUuid
|
|
||||||
}
|
|
||||||
})
|
|
||||||
dispatch('tagsView/delView', oldRoute, true)
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
showMessage({
|
showMessage({
|
||||||
|
@ -614,9 +601,9 @@ const panel = {
|
||||||
})
|
})
|
||||||
commit('changeFieldValue', {
|
commit('changeFieldValue', {
|
||||||
field: field,
|
field: field,
|
||||||
newValue: params.newValue,
|
newValue: newValue,
|
||||||
valueTo: params.valueTo,
|
valueTo: valueTo,
|
||||||
displayColumn: params.displayColumn,
|
displayColumn: displayColumn,
|
||||||
isChangedOldValue: true
|
isChangedOldValue: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -639,7 +626,7 @@ const panel = {
|
||||||
type: 'info'
|
type: 'info'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if (!params.isDontSendToQuery) {
|
} else if (isSendToQuery) {
|
||||||
if (panelType === 'table' || isAdvancedQuery) {
|
if (panelType === 'table' || isAdvancedQuery) {
|
||||||
if (fieldIsDisplayed(field) && field.isShowedFromUser) {
|
if (fieldIsDisplayed(field) && field.isShowedFromUser) {
|
||||||
// change action to advanced query on field value is changed in this panel
|
// change action to advanced query on field value is changed in this panel
|
||||||
|
@ -864,33 +851,28 @@ const panel = {
|
||||||
fieldList = getters.getFieldsListFromPanel(containerUuid)
|
fieldList = getters.getFieldsListFromPanel(containerUuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
var attributesList = fieldList
|
let attributesList = fieldList
|
||||||
var attributesObject = {}
|
const attributesObject = {}
|
||||||
var displayColumnsList = []
|
const displayColumnsList = []
|
||||||
var rangeColumnsList = []
|
const rangeColumnsList = []
|
||||||
if (withOut.length || isEvaluatedChangedValue) {
|
if (withOut.length || isEvaluatedChangedValue || isEvaluateValues) {
|
||||||
attributesList = attributesList.filter(fieldItem => {
|
attributesList = attributesList.filter(fieldItem => {
|
||||||
// columns to exclude
|
// columns to exclude
|
||||||
if (withOut.includes(fieldItem.columnName)) {
|
if (withOut.includes(fieldItem.columnName)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
// if value is changed
|
||||||
if (isEvaluatedChangedValue && fieldItem.value === fieldItem.oldValue) {
|
if (isEvaluatedChangedValue && fieldItem.value === fieldItem.oldValue) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
// TODO: Evaluate valueTo for range
|
||||||
|
if (isEvaluateValues && isEmptyValue(fieldItem.value)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Evaluate valueTo
|
|
||||||
if (isEvaluateValues) {
|
|
||||||
attributesList = attributesList
|
|
||||||
.filter(fieldItem => {
|
|
||||||
if (!isEmptyValue(fieldItem.value)) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
attributesList = attributesList
|
attributesList = attributesList
|
||||||
.map(fieldItem => {
|
.map(fieldItem => {
|
||||||
const valueToReturn = fieldItem[propertyName]
|
const valueToReturn = fieldItem[propertyName]
|
||||||
|
@ -898,18 +880,18 @@ const panel = {
|
||||||
|
|
||||||
// Add display columns if field has value
|
// Add display columns if field has value
|
||||||
if (fieldItem[propertyName] && fieldItem.displayColumn) {
|
if (fieldItem[propertyName] && fieldItem.displayColumn) {
|
||||||
attributesObject['DisplayColumn_' + fieldItem.columnName] = fieldItem.displayColumn
|
attributesObject[`DisplayColumn_${fieldItem.columnName}`] = fieldItem.displayColumn
|
||||||
displayColumnsList.push({
|
displayColumnsList.push({
|
||||||
columnName: 'DisplayColumn_' + fieldItem.columnName,
|
columnName: `DisplayColumn_${fieldItem.columnName}`,
|
||||||
value: fieldItem.displayColumn
|
value: fieldItem.displayColumn
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// add range columns
|
// add range columns
|
||||||
if (isAddRangeColumn && fieldItem.isRange) {
|
if (isAddRangeColumn && fieldItem.isRange) {
|
||||||
attributesObject[fieldItem.columnName + '_To'] = fieldItem.valueTo
|
attributesObject[`${fieldItem.columnName}_To`] = fieldItem.valueTo
|
||||||
rangeColumnsList.push({
|
rangeColumnsList.push({
|
||||||
columnName: fieldItem.columnName + '_To',
|
columnName: `${fieldItem.columnName}_To`,
|
||||||
value: fieldItem.valueTo
|
value: fieldItem.valueTo
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,16 @@ const windowControl = {
|
||||||
eventType: 'INSERT'
|
eventType: 'INSERT'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const oldRoute = router.app._route
|
||||||
|
router.push({
|
||||||
|
name: oldRoute.name,
|
||||||
|
query: {
|
||||||
|
...oldRoute.query,
|
||||||
|
action: response.getUuid()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
dispatch('tagsView/delView', oldRoute, true)
|
||||||
|
|
||||||
resolve({
|
resolve({
|
||||||
data: newValues,
|
data: newValues,
|
||||||
recordUuid: response.getUuid(),
|
recordUuid: response.getUuid(),
|
||||||
|
|
Loading…
Reference in New Issue