Fix for missing Phases
This commit is contained in:
@@ -240,9 +240,42 @@ const loadOptions = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
loadOptions()
|
||||
normalizeLoadedSelectValues()
|
||||
|
||||
const initialProjecttype = props.type === "projects" ? item.value.projecttype : null
|
||||
const lastAppliedProjecttype = ref(null)
|
||||
|
||||
const syncProjectPhasesForProjecttype = () => {
|
||||
if (props.type !== "projects") return
|
||||
if (!item.value?.projecttype) return
|
||||
if (!Array.isArray(loadedOptions.value.projecttypes) || !loadedOptions.value.projecttypes.length) return
|
||||
|
||||
const projecttypeColumn = dataType.templateColumns.find((column) => column.key === "projecttype")
|
||||
if (!projecttypeColumn?.inputChangeFunction) return
|
||||
|
||||
const shouldSyncOnCreate = props.mode === "create" && lastAppliedProjecttype.value !== item.value.projecttype
|
||||
const shouldSyncOnEdit = props.mode === "edit"
|
||||
&& item.value.projecttype !== initialProjecttype
|
||||
&& lastAppliedProjecttype.value !== item.value.projecttype
|
||||
|
||||
if (!shouldSyncOnCreate && !shouldSyncOnEdit) return
|
||||
|
||||
projecttypeColumn.inputChangeFunction(item.value, loadedOptions.value)
|
||||
lastAppliedProjecttype.value = item.value.projecttype
|
||||
}
|
||||
|
||||
loadOptions().then(() => {
|
||||
syncProjectPhasesForProjecttype()
|
||||
})
|
||||
|
||||
watch(
|
||||
() => [item.value?.projecttype, loadedOptions.value.projecttypes?.length || 0],
|
||||
() => {
|
||||
syncProjectPhasesForProjecttype()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const contentChanged = (content, datapoint) => {
|
||||
if (datapoint.key.includes(".")) {
|
||||
item.value[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]].html = content.html
|
||||
@@ -274,6 +307,9 @@ const getSelectSearchInput = (datapoint) => {
|
||||
const triggerInputChange = (datapoint) => {
|
||||
if (datapoint.inputChangeFunction) {
|
||||
datapoint.inputChangeFunction(item.value, loadedOptions.value)
|
||||
if (datapoint.key === "projecttype") {
|
||||
lastAppliedProjecttype.value = item.value.projecttype
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user