|
3 | 3 | <ContentDropDownPicker v-bind="formFieldProps" |
4 | 4 | :modelValue="pickerValue" |
5 | 5 | iconCssClass="ti ti-map-pin" |
6 | | - :showClear="!!pickerValue" |
| 6 | + :showClear="!isPickerEmpty" |
7 | 7 | @primaryButtonClicked="select" |
8 | 8 | @secondaryButtonClicked="cancel" |
9 | 9 | @clearButtonClicked="clear" |
|
77 | 77 | const controlValue = ref({}); |
78 | 78 |
|
79 | 79 | // This Picker |
80 | | - const pickerValue = ref({}); |
| 80 | + const pickerValue = ref<AddressControlBag>(getEmptyAddressControlBag()); |
81 | 81 | const pickerLabel = ref(""); |
| 82 | + |
82 | 83 | const errors = ref<FormError[]>([]); |
| 84 | + |
83 | 85 | const isLoading = ref(false); |
84 | 86 | const internalShowPopup = useVModelPassthrough(props, "showPopup", emit); |
85 | 87 |
|
|
89 | 91 |
|
90 | 92 | // #region Computed Values |
91 | 93 |
|
| 94 | + const isPickerEmpty = computed(() => { |
| 95 | + return !pickerValue.value.street1 |
| 96 | + && !pickerValue.value.city |
| 97 | + && !pickerValue.value.state |
| 98 | + && !pickerValue.value.postalCode |
| 99 | + && !pickerValue.value.country; |
| 100 | + }); |
| 101 | + |
92 | 102 | const isRequired = computed(() => { |
93 | 103 | return containsRequiredRule(props.rules); |
94 | 104 | }); |
95 | 105 |
|
96 | 106 | // #endregion |
97 | 107 |
|
| 108 | + // #region Functions |
| 109 | + |
| 110 | + function getEmptyAddressControlBag(): AddressControlBag { |
| 111 | + return { |
| 112 | + street1: "", |
| 113 | + street2: "", |
| 114 | + city: "", |
| 115 | + state: "", |
| 116 | + postalCode: "", |
| 117 | + country: "" |
| 118 | + }; |
| 119 | + } |
| 120 | + |
| 121 | + // #endregion Functions |
| 122 | + |
98 | 123 | // #region Event Handlers |
99 | 124 |
|
100 | 125 | async function select(): Promise<void> { |
|
126 | 151 | } |
127 | 152 |
|
128 | 153 | function clear(): void { |
129 | | - pickerValue.value = {}; |
| 154 | + pickerValue.value = getEmptyAddressControlBag(); |
130 | 155 | pickerLabel.value = ""; |
131 | 156 | } |
132 | 157 |
|
|
0 commit comments