File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ const props = defineProps<{
3333 title? : string ;
3434 /** Fixes the height of the modal to a pre-set height based on `size` */
3535 fixedHeight? : boolean ;
36+ /** Disables the Ok button */
37+ okDisabled? : boolean ;
38+ /** Title to show when the Ok button is disabled */
39+ okDisabledTitle? : string ;
3640}>();
3741
3842const emit = defineEmits <{
@@ -170,7 +174,13 @@ defineExpose({ showModal, hideModal });
170174
171175 <div v-if =" props.confirm" class =" g-modal-confirm-buttons" >
172176 <GButton @click =" hideModal(false)" > {{ props.cancelText ?? "Cancel" }} </GButton >
173- <GButton color =" blue" @click =" hideModal(true)" > {{ props.okText ?? "Ok" }} </GButton >
177+ <GButton
178+ :disabled =" okDisabled"
179+ :disabled-title =" okDisabledTitle"
180+ color =" blue"
181+ @click =" hideModal(true)" >
182+ {{ props.okText ?? "Ok" }}
183+ </GButton >
174184 </div >
175185 </footer >
176186 </section >
Original file line number Diff line number Diff line change 11<script setup lang="ts">
2- import { ref } from " vue" ;
2+ import { computed , ref } from " vue" ;
33
44import GModal from " @/components/BaseComponents/GModal.vue" ;
55import StatelessTags from " @/components/TagsMultiselect/StatelessTags.vue" ;
@@ -17,6 +17,10 @@ const props = withDefaults(defineProps<Props>(), {
1717
1818const tags = ref (props .initialTags );
1919
20+ const emptyTagList = computed (() => {
21+ return tags .value .length === 0 ;
22+ });
23+
2024const emit = defineEmits <{
2125 (e : " cancel" ): void ;
2226 (e : " ok" , tags : string []): void ;
@@ -42,7 +46,16 @@ function resetTags() {
4246 </script >
4347
4448<template >
45- <GModal :show =" show" ok-text =" Add" :confirm =" true" size =" small" :title =" title" @ok =" onOk" @cancel =" onCancel" >
49+ <GModal
50+ :show =" show"
51+ ok-text =" Add"
52+ :confirm =" true"
53+ size =" small"
54+ :title =" title"
55+ :ok-disabled =" emptyTagList"
56+ ok-disabled-title =" Please select at least one tag"
57+ @ok =" onOk"
58+ @cancel =" onCancel" >
4659 <StatelessTags :value =" tags" @input =" onTagsChange($event)" />
4760 </GModal >
4861</template >
You can’t perform that action at this time.
0 commit comments