Skip to content

Commit

Permalink
Fix design of page creation
Browse files Browse the repository at this point in the history
  • Loading branch information
caleeli committed Feb 27, 2024
1 parent 9bde89c commit 401daa4
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/components/vue-form-builder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -383,28 +383,30 @@
<b-modal
id="addPageModal"
ref="addPageModal"
:ok-title="$t('Save')"
:cancel-title="$t('Cancel')"
header-class="pb-2"
size="lg"
:ok-title="$t('SAVE')"
:cancel-title="$t('CANCEL')"
cancel-variant="btn btn-outline-secondary"
ok-variant="btn btn-secondary ml-2"
:title="$t('Add New Page')"
header-close-content="&times;"
data-cy="add-page-modal"
:ok-disabled="!addPageName || !!checkPageName(addPageName)"
@ok="addPage"
@hide="addPageName = ''"
@show="addPageName = ''; showAddPageValidations=false;"
>
<required />
<template #modal-title>
<h5 class="modal-title">{{ $t('Create New Page') }}</h5>
<small class="modal-subtitle mb-n2">{{ $t('Create a new page in your screen') }}</small>
</template>
<form-input
ref="addPageInput"
v-model="addPageName"
:name="$t('Page Name')"
:label="$t('Page Name') + ' *'"
:helper="$t('The name of the new page to add')"
validation="required"
:error="checkPageName(addPageName)"
data-cy="add-page-name"
required
aria-required="true"
/>
</b-modal>
Expand Down Expand Up @@ -583,6 +585,7 @@ export default {
}

return {
showAddPageValidations: false,
openedPages: [0],
currentPage: 0,
selected: null,
Expand Down Expand Up @@ -758,7 +761,13 @@ export default {
onClick(page) {
this.$refs.tabsBar.openPageByIndex(page);
},
checkPageName(value) {
checkPageName(value, force = false) {
if (!force && !this.showAddPageValidations) {
return null;
}
if (!value.trim()) {
return this.$t("The Page Name field is required.");
}
const pageNames = this.config
.map((config) => config.name)
.filter((name) => name !== this.originalPageName);
Expand Down Expand Up @@ -1133,7 +1142,9 @@ export default {
this.updateState();
},
addPage(e) {
if (this.$refs.addPageInput.validator.errorCount) {
this.showAddPageValidations = true;
const error = this.checkPageName(this.addPageName, true);
if (error) {
e.preventDefault();
return;
}
Expand Down

0 comments on commit 401daa4

Please sign in to comment.