|
32 | 32 |
|
33 | 33 | <button
|
34 | 34 | v-show="isValidCurrentValue"
|
35 |
| - class="reset-button btn btn-sm fa fa-times" |
| 35 | + class="reset-button btn btn-sm focus:outline-none flex justify-center items-center" |
36 | 36 | @click="resetFilter"
|
37 |
| - ></button> |
| 37 | + > |
| 38 | + <XIcon class="reset-icon"/> |
| 39 | + </button> |
38 | 40 | </div>
|
39 | 41 | </div>
|
40 | 42 | </div>
|
|
66 | 68 | };
|
67 | 69 | },
|
68 | 70 |
|
| 71 | + created () { |
| 72 | + /* |
| 73 | + * Clear the displayed value when clicking 'Reset Filters' |
| 74 | + * to reset all applied filters. Without this, the filter is |
| 75 | + * removed, but the input value remains, which is confusing. |
| 76 | + */ |
| 77 | + this.$store.subscribeAction((action, state) => { |
| 78 | + if (action.type === `${this.resourceName}/resetFilterState`) { |
| 79 | + this.resetFilter(); |
| 80 | + } |
| 81 | + }); |
| 82 | + }, |
| 83 | +
|
69 | 84 | methods: {
|
70 | 85 | handleChange: function (value) {
|
71 |
| - if (Array.isArray(value) && value.length === 2) { |
72 |
| - value = value.map((value) => moment(value).format('YYYY-MM-DD')); |
73 |
| - } |
| 86 | + /* |
| 87 | + * Remove repetition and provide empty value when clear button is pressed. |
| 88 | + * This tells Nova that the filter is no longer enabled, changing the filter |
| 89 | + * icon colour from blue to regular colour. Without this fix, you can press |
| 90 | + * the clear button, but the filter icon still looks as if a filter is applied. |
| 91 | + */ |
| 92 | + value = Array.isArray(value) && value.length === 2 |
| 93 | + ? value.map((value) => moment(value).format('YYYY-MM-DD')) |
| 94 | + : []; |
74 | 95 |
|
75 | 96 | this.$store.commit(`${this.resourceName}/updateFilterState`, {
|
76 | 97 | filterClass: this.filterKey,
|
77 |
| - value: Array.isArray(value) && value.length === 2 ? value : [], |
| 98 | + value: value, |
78 | 99 | });
|
79 | 100 |
|
80 | 101 | this.$emit('change');
|
|
94 | 115 | },
|
95 | 116 |
|
96 | 117 | isValidCurrentValue: function () {
|
97 |
| - return Array.isArray(this.filter.currentValue) && this.filter.currentValue.length === 2 |
| 118 | + return Array.isArray(this.filter.currentValue) && this.filter.currentValue.length === 2; |
98 | 119 | },
|
99 | 120 |
|
100 | 121 | resetFilter: function () {
|
|
0 commit comments