Skip to content

Commit

Permalink
Add disable button submit
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoAntonioNina committed Nov 15, 2023
1 parent 78297da commit c1e5925
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions src/components/task.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default {
value: { type: Object, default: () => {} },
beforeLoadTask: { type: Function, default: defaultBeforeLoadTask },
initialLoopContext: { type: String, default: "" },
avoidClose: { type: Boolean, default: false },
taskPreview: { type: Boolean, default: false },
loading: { type: Number, default: null }
},
data() {
Expand Down Expand Up @@ -186,9 +186,16 @@ export default {
this.nodeId = this.task.element_id;
this.listenForParentChanges();
if (this.task.process_request.status === 'COMPLETED') {
this.$emit('completed', this.task.process_request.id);
if (!this.taskPreview) {
this.$emit('completed', this.task.process_request.id);
}
}
},
if (this.taskPreview && this.task.status === "CLOSED") {
this.task.interstitial_screen['_interstitial'] = false;
this.task.screen.config = this.disableForm(this.task.screen.config);
this.screen = this.task.screen;
}
}
},
value: {
Expand Down Expand Up @@ -241,6 +248,24 @@ export default {
},
},
methods: {
disableForm(json) {
if (json instanceof Array) {
for (let item of json) {
if (item.component==='FormButton' && item.config.event==='submit') {
json.splice(json.indexOf(item), 1);
} else {
this.disableForm(item);
}
}
}
if (json.config !== undefined) {
json.config.disabled = true;
}
if (json.items !== undefined) {
this.disableForm(json.items);
}
return json;
},
showSimpleErrorMessage() {
this.renderComponent = 'simpleErrorMessage';
},
Expand Down Expand Up @@ -342,16 +367,13 @@ export default {
if (this.task.process_request.status === 'COMPLETED') {
this.loadNextAssignedTask(parentRequestId);
} else if (this.loadingButton) {
this.loadNextAssignedTask(parentRequestId);
} else if (this.task.allow_interstitial) {
this.task.interstitial_screen['_interstitial'] = true;
this.screen = this.task.interstitial_screen;
this.loadNextAssignedTask(parentRequestId);
} else if (!this.avoidClose) {
} else if (!this.taskPreview) {
this.$emit('closed', this.task.id);
}
},
Expand Down

0 comments on commit c1e5925

Please sign in to comment.