Skip to content

Commit

Permalink
fix(ui): remove empty arrays overriding default values upon task vali…
Browse files Browse the repository at this point in the history
…dation in low code

closes #4758
  • Loading branch information
brian-mulier-p committed Aug 29, 2024
1 parent 0d4e8f2 commit 3c35c8a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
4 changes: 2 additions & 2 deletions ui/src/components/flows/tasks/TaskArray.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
mixins: [Task],
emits: ["update:modelValue"],
created() {
if (!Array.isArray(this.modelValue)) {
if (!Array.isArray(this.modelValue) && this.modelValue !== undefined) {
this.$emit("update:modelValue", []);
}
},
computed: {
values() {
if (this.modelValue === undefined || (Array.isArray(this.modelValue) && this.modelValue.length === 0)) {
if (this.modelValue === undefined) {
return this.schema.default || [undefined];
}
Expand Down
30 changes: 12 additions & 18 deletions ui/src/components/inputs/EditorView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@
const isCurrentTabFlow = computed(() => currentTab?.value?.extension === undefined)
const flowErrors = computed(() => {
const isFlow = currentTab?.value?.flow;
const isFlow = () => currentTab?.value?.flow || props.isCreating;
if (isFlow) {
const flowErrors = computed(() => {
if (isFlow()) {
const flowExistsError =
props.flowValidation?.outdated && props.isCreating
? [outdatedMessage.value]
Expand Down Expand Up @@ -152,9 +152,7 @@
});
const flowWarnings = computed(() => {
const isFlow = currentTab?.value?.flow;
if (isFlow) {
if (isFlow()) {
const outdatedWarning =
props.flowValidation?.outdated && !props.isCreating
? [outdatedMessage.value]
Expand Down Expand Up @@ -283,9 +281,7 @@
);
const flowHaveTasks = (source) => {
const isFlow = currentTab?.value?.flow || props.isCreating;
if (isFlow) {
if (isFlow()) {
const flow = props.isCreating ? props.flow.source : (source ? source : flowYaml.value);
return flow ? YamlUtils.flowHaveTasks(flow) : false;
} else return false;
Expand Down Expand Up @@ -441,10 +437,10 @@
});
};
const onEdit = (event, isFlow = false) => {
const onEdit = (event, currentIsFlow = false) => {
flowYaml.value = event;
if (isFlow) {
if (currentIsFlow) {
if (
flowParsed.value &&
!props.isCreating &&
Expand All @@ -467,7 +463,7 @@
haveChange.value = true;
store.dispatch("core/isUnsaved", true);
if(!props.isCreating){
store.commit("editor/changeOpenedTabs", {
action: "dirty",
Expand All @@ -480,7 +476,7 @@
clearTimeout(timer.value);
if(!isFlow) return;
if(!currentIsFlow) return;
return store
.dispatch("flow/validateFlow", {flow: yamlWithNextRevision.value})
Expand Down Expand Up @@ -602,13 +598,13 @@
};
const editorUpdate = (event) => {
const isFlow = currentTab?.value?.flow;
const currentIsFlow = isFlow();
updatedFromEditor.value = true;
flowYaml.value = event;
clearTimeout(timer.value);
timer.value = setTimeout(() => onEdit(event, isFlow), 500);
timer.value = setTimeout(() => onEdit(event, currentIsFlow), 500);
};
const switchViewType = (event, shouldPersist = true) => {
Expand Down Expand Up @@ -722,9 +718,7 @@
}
}
const isFlow = currentTab?.value?.flow || props.isCreating;
if (isFlow) {
if (isFlow()) {
onEdit(flowYaml.value, true).then((validation) => {
if (validation.outdated && !props.isCreating) {
confirmOutdatedSaveDialog.value = true;
Expand Down

0 comments on commit 3c35c8a

Please sign in to comment.