@webitel/ui-datalist 1.1.55 → 1.1.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-datalist",
3
- "version": "1.1.55",
3
+ "version": "1.1.56",
4
4
  "description": "Toolkit for building data lists in webitel ui system",
5
5
  "scripts": {
6
6
  "build:types": "vue-tsc -b tsconfig.build.json",
@@ -2,25 +2,54 @@
2
2
  <wt-multi-select
3
3
  :label="t('webitelUI.filters.filterValue')"
4
4
  :options="AmdResultOptions"
5
- v-model:model-value="model"
5
+ v-model:model-value="selectValue"
6
6
  :v="v$.model"
7
7
  data-key="value"
8
8
  option-value="value"
9
9
  />
10
+ <wt-checkbox
11
+ :label="t('webitelUI.filters.showEmptyAmdResult')"
12
+ :value="AMD_RESULT_EMPTY_VALUE"
13
+ v-model:selected="isEmptySelected"
14
+ />
10
15
  </template>
11
16
 
12
17
  <script lang="ts" setup>
13
18
  import { useVuelidate } from '@vuelidate/core';
14
19
  import { required } from '@vuelidate/validators';
15
- import { WtMultiSelect } from '@webitel/ui-sdk/components';
16
- import { computed, watch } from 'vue';
20
+ import { WtCheckbox, WtMultiSelect } from '@webitel/ui-sdk/components';
21
+ import { computed, ref, watch } from 'vue';
17
22
  import { useI18n } from 'vue-i18n';
18
23
 
19
24
  import { AmdResultOptions } from '../../enums/options/AMDResultOptions';
20
25
 
21
- const model = defineModel<string>();
26
+ const AMD_RESULT_EMPTY_VALUE = 'EMPTY';
27
+
28
+ const model = defineModel<string[]>();
22
29
  const { t } = useI18n();
23
30
 
31
+ // keeps the select's own model limited to real AmdResultOptions values,
32
+ // so it never treats EMPTY as a missing/custom option to reconcile
33
+ const selectValue = ref(
34
+ (model.value || []).filter((value) => value !== AMD_RESULT_EMPTY_VALUE),
35
+ );
36
+ const isEmptySelected = ref(!!model.value?.includes(AMD_RESULT_EMPTY_VALUE));
37
+
38
+ watch(
39
+ [
40
+ selectValue,
41
+ isEmptySelected,
42
+ ],
43
+ ([select, isEmpty]) => {
44
+ model.value = isEmpty
45
+ ? [
46
+ ...select,
47
+ AMD_RESULT_EMPTY_VALUE,
48
+ ]
49
+ : select;
50
+ },
51
+ );
52
+
24
53
  const v$ = useVuelidate(
25
54
  computed(() => ({
26
55
  model: {
@@ -39,4 +39,12 @@ export const AmdResultOptions: Array<FilterInitParams> = [
39
39
  name: 'TIMEOUT',
40
40
  value: 'TIMEOUT',
41
41
  },
42
+ {
43
+ name: 'UNDEFINED',
44
+ value: 'UNDEFINED',
45
+ },
46
+ {
47
+ name: 'NO ANSWER',
48
+ value: 'NO ANSWER',
49
+ },
42
50
  ] as const;