Skip to content

Commit

Permalink
add validation rules to check if the project name ends with white space
Browse files Browse the repository at this point in the history
  • Loading branch information
khansadaoudi committed Aug 23, 2024
1 parent 18bbae0 commit 46a288d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/components/project/CreaProjectCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
v-model="project.projectName"
:label="$t('createProjectCard.projectName') + ' *'"
lazy-rules
:rules="[(val) => (val && val.length > 0) || $t('createProjectCard.inputWarning')]"
:rules="[
(val) => (val && val.length > 0) || $t('createProjectCard.inputWarning[0]'),
(val) => (val && !val.endsWith(' ')) || $t('createProjectCard.inputWarning[1]'),
]"
/>
<q-input outlined dense v-model="project.description" label="Description" />
<q-separator />
Expand Down Expand Up @@ -223,7 +226,7 @@ export default defineComponent({
return this.loggedWithGithub && this.isShowSyncBtn && !this.isShowGithubSyncPanel;
},
disableSubmitBtn() {
return this.project.projectName === '' || this.project.language === '' || this.project.config === '';
return this.project.projectName === '' || this.project.language === '' || this.project.config === '' || this.project.projectName.endsWith(' ');
},
},
methods: {
Expand Down
13 changes: 11 additions & 2 deletions src/components/project/RenameProjectDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@
v-model="newProjectName"
:label="$t('renameProject.inputLabel')"
lazy-rules
:rules="[(val) => (val && val.length > 0) || $t('renameProject.inputError')]"
:rules="[
(val) => (val && val.length > 0) || $t('renameProject.inputError'),
(val) => (val && !val.endsWith(' ')) || $t('createProjectCard.inputWarning[1]'),
]"
/>
<div class="flex flex-center">
<q-btn v-close-popup :disable="newProjectName === ''" color="primary" :label="$t('renameProject.renameBtn')" @click="renameProject()" />
<q-btn v-close-popup :disable="disableBtn" color="primary" :label="$t('renameProject.renameBtn')" @click="renameProject()" />
</div>
</q-card-section>
</q-card>
</template>
<script lang="ts">
import { mapActions } from 'pinia';
import { cpuUsage } from 'process';
import { useProjectStore } from 'src/pinia/modules/project';
import { PropType, defineComponent } from 'vue';
Expand All @@ -40,6 +44,11 @@ export default defineComponent({
newProjectName: this.projectName,
};
},
computed: {
disableBtn() {
return this.newProjectName === '' || this.newProjectName.endsWith(' ');
}
},
methods: {
...mapActions(useProjectStore, ['updateProjectSettings']),
renameProject() {
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/en-us/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default {
blindAnnotationMode: 'blind annotation mode',
create: 'Create',
createMessage: 'is created',
inputWarning: 'Please type something',
inputWarning: ['Please type something', "Project name shouldn't ends with white space" ],
selectWarning: 'Please select something',
corpusConfig: 'Corpus configuration',
enterLanguage: 'Enter language',
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/fr-fra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default {
blindAnnotationMode: 'Mode annotation aveugle',
create: 'Créer',
createMessage: 'est créé',
inputWarning: 'Veuillez taper quelque chose',
inputWarning: ['Veuillez taper quelque chose', 'Le nom du project ne deverait pas se terminer par un espace'],
selectWarning: 'Veuillez choisir quelque chose',
corpusConfig: 'La configuration du corpus',
enterLanguage: 'Saisir la langue du projet',
Expand Down

0 comments on commit 46a288d

Please sign in to comment.