Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/ValidationsFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@ class PageNavigateValidations extends Validations {
}
}

/**
* No-op validations (e.g. FormRecordList — modal fields validate separately)
*/
class NoOpValidations extends Validations {
async addValidations() {
// intentionally empty
}
}

/**
* Add validations for a form element
*/
Expand Down Expand Up @@ -400,8 +409,9 @@ function ValidationsFactory(element, options) {
return new FormLoopValidations(element, options);
}
if (element.component === 'FormRecordList') {
//not required
//return new FormRecordListValidations(element, screen);
// Record list modal fields are validated only when submitting the modal,
// not as part of the parent screen's validation rules.
return new NoOpValidations(element, options);
}
if (element.component === 'FormButton' && element.config.event === 'pageNavigate') {
return new PageNavigateValidations(element, options);
Expand Down
29 changes: 26 additions & 3 deletions src/components/renderer/form-record-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
:current-page="form"
:computed="formComputed"
:watchers="formWatchers"
:isolated="true"
debug-context="Record List Add"
:_parent="validationData"
@update="updateRowDataNamePrefix"
Expand All @@ -198,7 +199,7 @@
header-close-content="×"
data-cy="modal-edit"
@ok="edit"
@hidden="$refs.addRenderer.hasSubmitted(false)"
@hidden="handleHideEditModal"
@shown="emitShownEvent"
>
<vue-form-renderer
Expand All @@ -210,6 +211,7 @@
:current-page="form"
:computed="formComputed"
:watchers="formWatchers"
:isolated="true"
debug-context="Record List Edit"
:_parent="validationData"
@update="updateRowDataNamePrefix"
Expand Down Expand Up @@ -254,11 +256,13 @@

<script>
import _ from "lodash";
import { mapActions } from "vuex";
import { dateUtils } from "@processmaker/vue-form-elements";
import VueFormRenderer from "@/components/vue-form-renderer.vue";
import mustacheEvaluation from "../../mixins/mustacheEvaluation";
import MustacheHelper from "../inspector/mustache-helper.vue";
import Mustache from "mustache";
import { findRootScreen } from "@/mixins/DataReference";

const jsonOptionsActionsColumn = {
key: "__actions",
Expand Down Expand Up @@ -507,6 +511,7 @@ export default {
this.$root.$emit("record-list-option", this.source?.sourceOptions);
},
methods: {
...mapActions("globalErrorsModule", ["validateNow", "close"]),
togglePopover(index, event, rowId) {
this.deleteIndex = _.find(this.tableData.data, { row_id: rowId });
this.isPopoverVisible = this.isPopoverVisible === index ? null : index;
Expand Down Expand Up @@ -991,7 +996,7 @@ export default {
});
},
edit(event) {
this.$refs.addRenderer.hasSubmitted(true);
this.$refs.editRenderer.hasSubmitted(true);
if (
this.$refs.editRenderer.$refs.renderer.$refs.component.$v.vdata.$invalid
) {
Expand Down Expand Up @@ -1030,7 +1035,25 @@ export default {
},
handleHideAddModal() {
this.addItem = this.initFormValues;
this.$refs.addRenderer.hasSubmitted(false);
if (this.$refs.addRenderer) {
this.$refs.addRenderer.hasSubmitted(false);
}
this.restoreParentValidationState();
},
handleHideEditModal() {
if (this.$refs.editRenderer) {
this.$refs.editRenderer.hasSubmitted(false);
}
this.restoreParentValidationState();
},
restoreParentValidationState() {
// Clear modal-driven global submit flags and refresh parent validity
// so required modal fields (e.g. FormCheckbox) never block parent submit.
this.close();
const rootScreen = findRootScreen(this);
if (rootScreen && typeof rootScreen.loadValidationRules === "function") {
this.validateNow(rootScreen);
}
},
async handleOk(bvModalEvt) {
this.$refs.addRenderer.hasSubmitted(true);
Expand Down
8 changes: 7 additions & 1 deletion src/components/vue-form-renderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export default {
"showErrors",
"testScreenDefinition",
"deviceScreen",
"taskdraft"
"taskdraft",
// When true, local $v is still used (e.g. record list modals) but data
// changes do not update the parent form's global valid/submit state.
"isolated"
],
data() {
return {
Expand Down Expand Up @@ -152,6 +155,9 @@ export default {
deep: true,
handler() {
this.$emit("update", this.data);
if (this.isolated) {
return;
}
const mainScreen = this.getMainScreen();
if (mainScreen) {
this.validate(mainScreen);
Expand Down
Loading