Skip to content

Commit

Permalink
fix: disable create button until version is provided
Browse files Browse the repository at this point in the history
added a fix to keep the create button inactive until any value is provided in the version input
this is to improve the UX of the form and prevent invalid submission

Signed-off-by: idrisGit <[email protected]>
  • Loading branch information
IdrisGit committed Oct 8, 2024
1 parent 15d377c commit 7135bf8
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions src/views/portfolio/projects/ProjectAddVersionModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
label-for="input-1"
label-class="required"
>
<b-form-input id="input-1" v-model="version" class="required" trim />
<b-form-input
id="input-1"
v-model="version"
class="required"
trim
required
/>
</b-form-group>
</b-col>
<b-col cols="auto">
Expand Down Expand Up @@ -108,9 +114,13 @@
<b-button size="md" variant="secondary" @click="cancel()">{{
$t('message.cancel')
}}</b-button>
<b-button size="md" variant="primary" @click="createVersion()">{{
$t('message.create')
}}</b-button>
<b-button
size="md"
variant="primary"
:disabled="isSubmitButtonDisabled"
@click="createVersion()"
>{{ $t('message.create') }}</b-button
>
</template>
</b-modal>
</template>
Expand All @@ -137,6 +147,20 @@ export default {
makeCloneLatest: false,
};
},
computed: {
isSubmitButtonDisabled() {
const versionInputValue = this.version;
if (versionInputValue) {
/**
* * ideally we would apply the check with the input value trimmed, however, since we are already using 'trim' prop on the input value.
* * trimming the value here is not required.
*/
return versionInputValue.length === 0;
}
return true;
},
},
methods: {
createVersion: function () {
let url = `${this.$api.BASE_URL}/${this.$api.URL_PROJECT}/clone`;
Expand Down

0 comments on commit 7135bf8

Please sign in to comment.