Skip to content

Commit 74fc944

Browse files
authored
Merge pull request #1052 from nscuro/backport-pr-1039
Backport: Fix: "Add Version" Create Button Should Be Inactive Until Version Provided
2 parents cc5ca36 + ddc9fe8 commit 74fc944

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/views/portfolio/projects/ProjectAddVersionModal.vue

+28-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515
label-for="input-1"
1616
label-class="required"
1717
>
18-
<b-form-input id="input-1" v-model="version" class="required" trim />
18+
<b-form-input
19+
id="input-1"
20+
v-model="version"
21+
class="required"
22+
trim
23+
required
24+
/>
1925
</b-form-group>
2026
</b-col>
2127
<b-col cols="auto">
@@ -108,9 +114,13 @@
108114
<b-button size="md" variant="secondary" @click="cancel()">{{
109115
$t('message.cancel')
110116
}}</b-button>
111-
<b-button size="md" variant="primary" @click="createVersion()">{{
112-
$t('message.create')
113-
}}</b-button>
117+
<b-button
118+
size="md"
119+
variant="primary"
120+
:disabled="isSubmitButtonDisabled"
121+
@click="createVersion()"
122+
>{{ $t('message.create') }}</b-button
123+
>
114124
</template>
115125
</b-modal>
116126
</template>
@@ -137,6 +147,20 @@ export default {
137147
makeCloneLatest: false,
138148
};
139149
},
150+
computed: {
151+
isSubmitButtonDisabled() {
152+
const versionInputValue = this.version;
153+
if (versionInputValue) {
154+
/**
155+
* * ideally we would apply the check with the input value trimmed, however, since we are already using 'trim' prop on the input value.
156+
* * trimming the value here is not required.
157+
*/
158+
return versionInputValue.length === 0;
159+
}
160+
161+
return true;
162+
},
163+
},
140164
methods: {
141165
createVersion: function () {
142166
let url = `${this.$api.BASE_URL}/${this.$api.URL_PROJECT}/clone`;

0 commit comments

Comments
 (0)