@webitel/ui-datalist 1.1.55 → 1.1.57

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.
Files changed (61) hide show
  1. package/package.json +1 -1
  2. package/src/modules/_shared/createDatalistStore.ts +1 -1
  3. package/src/modules/card/stores/createCardStore.ts +7 -2
  4. package/src/modules/filter-presets/api/PresetQuery.ts +12 -2
  5. package/src/modules/filter-presets/stores/createFilterPresetsStore.ts +1 -1
  6. package/src/modules/filters/classes/Filter.ts +1 -1
  7. package/src/modules/filters/classes/FiltersManager.ts +29 -18
  8. package/src/modules/filters/classes/__tests__/FiltersManager.spec.ts +1 -1
  9. package/src/modules/filters/modules/filterConfig/classes/FilterConfig.ts +6 -4
  10. package/src/modules/filters/modules/filterConfig/components/_shared/date-time-filter/date-time-filter-value-field.vue +7 -13
  11. package/src/modules/filters/modules/filterConfig/components/_shared/durations/duration-filter-value-field.vue +6 -8
  12. package/src/modules/filters/modules/filterConfig/components/amd-result/amd-result-filter-value-field.vue +33 -4
  13. package/src/modules/filters/modules/filterConfig/components/amd-result/amd-result-filter-value-preview.vue +15 -2
  14. package/src/modules/filters/modules/filterConfig/components/case-assignee/case-assignee-filter-value-field.vue +7 -12
  15. package/src/modules/filters/modules/filterConfig/components/case-close-reason-groups/case-close-reason-groups-filter-value-field.vue +7 -12
  16. package/src/modules/filters/modules/filterConfig/components/case-sla-condition/case-sla-condition-filter-value-field.vue +7 -11
  17. package/src/modules/filters/modules/filterConfig/components/case-status/case-status-filter-value-field.vue +7 -12
  18. package/src/modules/filters/modules/filterConfig/components/contact-group/contact-group-filter-value-field.vue +6 -12
  19. package/src/modules/filters/modules/filterConfig/components/has-file/has-file-filter-value-field.vue +1 -1
  20. package/src/modules/filters/modules/filterConfig/components/has-rating/has-rating-filter-value-field.vue +1 -1
  21. package/src/modules/filters/modules/filterConfig/components/has-transcription/has-transcription-filter-value-field.vue +1 -1
  22. package/src/modules/filters/modules/filterConfig/components/has-user/has-user-filter-value-field.vue +1 -1
  23. package/src/modules/filters/modules/filterConfig/components/rating/rating-from-to-filter-value-field.vue +9 -8
  24. package/src/modules/filters/modules/filterConfig/components/score/score-from-to-filter-value-field.vue +6 -7
  25. package/src/modules/filters/modules/filterConfig/composables/booleanFilterToolkit.ts +2 -2
  26. package/src/modules/filters/modules/filterConfig/composables/useQueueTypeOptions.ts +2 -1
  27. package/src/modules/filters/modules/filterConfig/enums/options/AMDResultOptions.ts +8 -0
  28. package/src/modules/filters/scripts/utils.ts +6 -2
  29. package/src/modules/headers/createTableHeadersStore.ts +6 -4
  30. package/src/modules/pagination/createTablePaginationStore.ts +2 -2
  31. package/src/modules/permissions-page/scripts/PermissionsApiModule.ts +3 -4
  32. package/src/modules/permissions-page/stores/createPermissionsStore.ts +3 -3
  33. package/src/modules/persist/PersistedStorage.types.ts +5 -2
  34. package/src/modules/persist/useLocalStoragePersistedStorage.ts +3 -6
  35. package/src/modules/persist/usePersistedStorage.ts +18 -12
  36. package/src/modules/table/createTableStore.store.ts +6 -6
  37. package/src/modules/types/tableStore.types.ts +9 -1
  38. package/types/.tsbuildinfo +1 -1
  39. package/types/modules/_shared/createDatalistStore.d.ts +1 -1
  40. package/types/modules/card/stores/createCardStore.d.ts +14 -10
  41. package/types/modules/filter-presets/stores/createFilterPresetsStore.d.ts +8 -8
  42. package/types/modules/filters/classes/Filter.d.ts +2 -2
  43. package/types/modules/filters/classes/FiltersManager.d.ts +3 -2
  44. package/types/modules/filters/createTableFiltersStore.d.ts +4 -4
  45. package/types/modules/filters/modules/filterConfig/components/amd-result/amd-result-filter-value-field.vue.d.ts +3 -3
  46. package/types/modules/filters/modules/filterConfig/components/amd-result/amd-result-filter-value-preview.vue.d.ts +1 -1
  47. package/types/modules/filters/modules/filterConfig/components/has-file/has-file-filter-value-field.vue.d.ts +1 -1
  48. package/types/modules/filters/modules/filterConfig/components/has-rating/has-rating-filter-value-field.vue.d.ts +1 -1
  49. package/types/modules/filters/modules/filterConfig/components/has-transcription/has-transcription-filter-value-field.vue.d.ts +1 -1
  50. package/types/modules/filters/modules/filterConfig/components/has-user/has-user-filter-value-field.vue.d.ts +1 -1
  51. package/types/modules/filters/modules/filterConfig/components/rating/rating-from-to-filter-value-field.vue.d.ts +2 -2
  52. package/types/modules/filters/modules/filterConfig/components/score/score-from-to-filter-value-field.vue.d.ts +2 -2
  53. package/types/modules/filters/modules/filterConfig/composables/booleanFilterToolkit.d.ts +3 -3
  54. package/types/modules/filters/scripts/utils.d.ts +2 -2
  55. package/types/modules/headers/createTableHeadersStore.d.ts +6 -4
  56. package/types/modules/permissions-page/scripts/PermissionsApiModule.d.ts +2 -2
  57. package/types/modules/permissions-page/stores/createPermissionsStore.d.ts +14 -14
  58. package/types/modules/persist/PersistedStorage.types.d.ts +2 -2
  59. package/types/modules/persist/useLocalStoragePersistedStorage.d.ts +1 -1
  60. package/types/modules/table/createTableStore.store.d.ts +14 -14
  61. package/types/modules/types/tableStore.types.d.ts +7 -1
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.57",
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",
@@ -27,7 +27,7 @@ const defaultStoreType = DatalistStoreProvider.Pinia;
27
27
  * */
28
28
  export const makeThisToRefs = <StoreBody extends object>(
29
29
  store: StoreBody,
30
- storeType: DatalistStoreProviderType,
30
+ storeType?: DatalistStoreProviderType,
31
31
  ): ToRefs<StoreBody> => {
32
32
  const thisStoreType = storeType || defaultStoreType;
33
33
 
@@ -33,7 +33,12 @@ export const createCardStore = <
33
33
  }: {
34
34
  namespace: string;
35
35
  standardValidationSchema: z.ZodType;
36
- apiModule: ApiModule<Entity>;
36
+ /**
37
+ * Every method on {@link ApiModule} is optional, but a card store reads and
38
+ * writes one item, so these three are required here.
39
+ */
40
+ apiModule: ApiModule<Entity> &
41
+ Required<Pick<ApiModule<Entity>, 'get' | 'add' | 'update'>>;
37
42
  validationSchemaOptions?: RegleSchemaBehaviourOptions;
38
43
  }) => {
39
44
  return defineStore(namespace, () => {
@@ -61,7 +66,7 @@ export const createCardStore = <
61
66
  // processing progress vars
62
67
  const isLoading = ref(false);
63
68
  const isSaving = ref(false);
64
- const error = ref(null); // if needed
69
+ const error = ref<unknown>(null); // if needed
65
70
 
66
71
  validationSchema.value = useRegleSchema(
67
72
  draftItemInstance,
@@ -23,6 +23,16 @@ const configuration = getDefaultOpenAPIConfig();
23
23
 
24
24
  const service = PresetQueryServiceApiFactory(configuration, '', instance);
25
25
 
26
+ const isConflictError = (err: unknown): boolean =>
27
+ typeof err === 'object' &&
28
+ err !== null &&
29
+ 'status' in err &&
30
+ (
31
+ err as {
32
+ status: unknown;
33
+ }
34
+ ).status === 409;
35
+
26
36
  type GetPresetListRequestConfig = {
27
37
  transformers: {
28
38
  useStarToSearch?: boolean;
@@ -104,7 +114,7 @@ const addPreset = async ({
104
114
  ]);
105
115
  } catch (err) {
106
116
  throw applyTransform(err, [
107
- skipIf(notify, (err) => err.status === 409),
117
+ skipIf(notify, isConflictError),
108
118
  ]);
109
119
  }
110
120
  };
@@ -125,7 +135,7 @@ const updatePreset = async ({ item: itemInstance, id, namespace }) => {
125
135
  ]);
126
136
  } catch (err) {
127
137
  throw applyTransform(err, [
128
- skipIf(notify, (err) => err.status === 409),
138
+ skipIf(notify, isConflictError),
129
139
  ]);
130
140
  }
131
141
  };
@@ -26,7 +26,7 @@ export const filterPresetsStoreBody = (namespace = 'presets') => {
26
26
  ? namespace
27
27
  : `${namespace}/presets`;
28
28
 
29
- const presetId = ref(null);
29
+ const presetId = ref<number | null>(null);
30
30
 
31
31
  const setupPresetPersistence = async () => {
32
32
  const { restore: restorePreset, reset } = usePersistedStorage({
@@ -53,7 +53,7 @@ export class Filter implements IFilter {
53
53
  constructor(
54
54
  { name, value, label }: FilterInitParams,
55
55
  public payload: object | undefined,
56
- public config: FilterInstanceConfig,
56
+ public config: FilterInstanceConfig | undefined,
57
57
  ) {
58
58
  this.name = name;
59
59
  this.value = value;
@@ -21,7 +21,8 @@ export interface IFiltersManager {
21
21
  filters: Map<FilterName, IFilter>;
22
22
 
23
23
  hasFilter: (name: FilterName) => boolean;
24
- getFilter: (name: FilterName) => IFilter;
24
+ /** `undefined` when no filter is registered under `name` */
25
+ getFilter: (name: FilterName) => IFilter | undefined;
25
26
  addFilter: (
26
27
  params: FilterInitParams,
27
28
  payload?: object,
@@ -34,7 +35,7 @@ export interface IFiltersManager {
34
35
  value?: FilterValue;
35
36
  label?: FilterLabel;
36
37
  }) => IFilter;
37
- deleteFilter: ({ name }: { name: FilterName }) => IFilter;
38
+ deleteFilter: ({ name }: { name: FilterName }) => IFilter | undefined;
38
39
 
39
40
  /**
40
41
  * Converts filters data to String, that can be stored
@@ -105,7 +106,7 @@ class FiltersManager implements IFiltersManager {
105
106
  return this.filters.has(name);
106
107
  }
107
108
 
108
- getFilter(name: FilterName): IFilter {
109
+ getFilter(name: FilterName): IFilter | undefined {
109
110
  return this.filters.get(name);
110
111
  }
111
112
 
@@ -129,6 +130,9 @@ class FiltersManager implements IFiltersManager {
129
130
  label?: FilterLabel;
130
131
  }): IFilter {
131
132
  const filter = this.filters.get(name);
133
+ if (!filter) {
134
+ throw new Error(`FiltersManager: cannot update unknown filter "${name}"`);
135
+ }
132
136
  filter.set({
133
137
  value,
134
138
  label,
@@ -136,7 +140,7 @@ class FiltersManager implements IFiltersManager {
136
140
  return filter;
137
141
  }
138
142
 
139
- deleteFilter({ name }: { name: FilterName }): IFilter {
143
+ deleteFilter({ name }: { name: FilterName }): IFilter | undefined {
140
144
  const filter = this.filters.get(name);
141
145
  this.filters.delete(name);
142
146
  return filter;
@@ -206,6 +210,11 @@ class FiltersManager implements IFiltersManager {
206
210
  const name = filterNameFromSnapshotKey(snapshotKey);
207
211
  const valueProp = filterValuePropFromSnapshotKey(snapshotKey);
208
212
 
213
+ // keys that are neither `_lbl` nor `_val`
214
+ if (name === undefined || valueProp === undefined) {
215
+ return filtersAcc;
216
+ }
217
+
209
218
  if (filtersAcc[name]) {
210
219
  filtersAcc[name][valueProp] = snapshotValue;
211
220
  } else {
@@ -249,10 +258,11 @@ class FiltersManager implements IFiltersManager {
249
258
  include?: FilterName[];
250
259
  exclude?: FilterName[];
251
260
  } = {}): IFilter[] {
252
- const useInclude = !isEmpty(include);
253
- const useExclude = !isEmpty(exclude) && !useInclude;
261
+ // bound to consts so the narrowing survives into the filter callback
262
+ const includeList = isEmpty(include) ? undefined : include;
263
+ const excludeList = isEmpty(exclude) ? undefined : exclude;
254
264
 
255
- if (!useInclude && !useExclude) {
265
+ if (!includeList && !excludeList) {
256
266
  return [
257
267
  ...this.filters.values(),
258
268
  ];
@@ -261,10 +271,10 @@ class FiltersManager implements IFiltersManager {
261
271
  return [
262
272
  ...this.filters.values(),
263
273
  ].filter(({ name }) => {
264
- if (useInclude) {
265
- return include.includes(name);
266
- } else if (useExclude) {
267
- return !exclude.includes(name);
274
+ if (includeList) {
275
+ return includeList.includes(name);
276
+ } else if (excludeList) {
277
+ return !excludeList.includes(name);
268
278
  }
269
279
 
270
280
  return true;
@@ -278,24 +288,25 @@ class FiltersManager implements IFiltersManager {
278
288
  include?: FilterName[];
279
289
  exclude?: FilterName[];
280
290
  } = {}): void {
281
- const useInclude = !isEmpty(include);
282
- const useExclude = !isEmpty(exclude) && !useInclude;
291
+ // bound to consts so the narrowing survives into the forEach callbacks
292
+ const includeList = isEmpty(include) ? undefined : include;
293
+ const excludeList = isEmpty(exclude) ? undefined : exclude;
283
294
 
284
- if (!useInclude && !useExclude) {
295
+ if (!includeList && !excludeList) {
285
296
  this.filters.clear();
286
297
  return;
287
298
  }
288
299
 
289
- if (useInclude) {
290
- include.forEach((name) => {
300
+ if (includeList) {
301
+ includeList.forEach((name) => {
291
302
  this.filters.delete(name);
292
303
  });
293
304
  return;
294
305
  }
295
306
 
296
- if (useExclude) {
307
+ if (excludeList) {
297
308
  this.filters.forEach((_, filterName) => {
298
- if (!exclude.includes(filterName)) {
309
+ if (!excludeList.includes(filterName)) {
299
310
  this.filters.delete(filterName);
300
311
  }
301
312
  });
@@ -29,7 +29,7 @@ describe('FiltersManager', () => {
29
29
  name: 'test',
30
30
  value: 'test2',
31
31
  });
32
- expect(filtersManager.getFilter('test').value).toBe('test2');
32
+ expect(filtersManager.getFilter('test')?.value).toBe('test2');
33
33
  });
34
34
 
35
35
  it('should be able to getAllValues', () => {
@@ -74,9 +74,11 @@ export type FilterConfigSearchFilterContext = {
74
74
  };
75
75
 
76
76
  export class FilterConfig implements BaseFilterConfig {
77
- name: FilterName;
78
- valueInputComponent: Component;
79
- valuePreviewComponent: Component;
77
+ // assigned by concrete configs as field initializers, e.g.
78
+ // `readonly name = FilterOption.Skill`, not necessarily by this constructor
79
+ name!: FilterName;
80
+ valueInputComponent!: Component;
81
+ valuePreviewComponent!: Component;
80
82
  label?: ReturnType<MessageResolver> | string;
81
83
  staticView?: boolean;
82
84
  notDeletable: boolean;
@@ -96,7 +98,7 @@ export class FilterConfig implements BaseFilterConfig {
96
98
  this.valuePreviewComponent = valuePreviewComponent;
97
99
  this.notDeletable = !!notDeletable;
98
100
  if (staticView) this.staticView = staticView;
99
- if (showFilterName) this.showFilterName = showFilterName;
101
+ this.showFilterName = !!showFilterName;
100
102
  }
101
103
  }
102
104
 
@@ -26,7 +26,7 @@
26
26
  import { useVuelidate } from '@vuelidate/core';
27
27
  import { required } from '@vuelidate/validators';
28
28
  import { endOfToday, startOfToday } from 'date-fns';
29
- import { computed, onMounted, watch } from 'vue';
29
+ import { computed, watch } from 'vue';
30
30
  import { useI18n } from 'vue-i18n';
31
31
 
32
32
  type ModelValue = {
@@ -40,7 +40,12 @@ const emit = defineEmits<{
40
40
  ];
41
41
  }>();
42
42
 
43
- const model = defineModel<ModelValue>();
43
+ const model = defineModel<ModelValue>({
44
+ default: (): ModelValue => ({
45
+ from: startOfToday().getTime(),
46
+ to: endOfToday().getTime(),
47
+ }),
48
+ });
44
49
  const { t } = useI18n();
45
50
 
46
51
  const from = computed(() => model.value?.from);
@@ -82,17 +87,6 @@ const handleInput = (key: keyof ModelValue, value: number) => {
82
87
  [key]: value,
83
88
  };
84
89
  };
85
-
86
- const initModel = () => {
87
- if (!model.value) {
88
- model.value = {
89
- from: startOfToday().getTime(),
90
- to: endOfToday().getTime(),
91
- };
92
- }
93
- };
94
-
95
- onMounted(() => initModel());
96
90
  </script>
97
91
 
98
92
  <style lang="scss" scoped>
@@ -31,7 +31,12 @@ type ModelValue = {
31
31
  to: number;
32
32
  };
33
33
 
34
- const model = defineModel<ModelValue>();
34
+ const model = defineModel<ModelValue>({
35
+ default: (): ModelValue => ({
36
+ from: 0,
37
+ to: 0,
38
+ }),
39
+ });
35
40
 
36
41
  const emit = defineEmits<{
37
42
  'update:invalid': [
@@ -39,13 +44,6 @@ const emit = defineEmits<{
39
44
  ];
40
45
  }>();
41
46
 
42
- if (!model.value) {
43
- model.value = {
44
- from: 0,
45
- to: 0,
46
- };
47
- }
48
-
49
47
  const isValueEmpty = () => {
50
48
  return !!model?.value?.to || !!model?.value?.from;
51
49
  };
@@ -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: {
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <ul>
3
3
  <li
4
- v-for="(result, index) of props.value"
4
+ v-for="(result, index) of shownValues"
5
5
  :key="index"
6
6
  >
7
7
  {{ result }}
@@ -10,9 +10,22 @@
10
10
  </template>
11
11
 
12
12
  <script lang="ts" setup>
13
+ import { computed } from 'vue';
14
+ import { useI18n } from 'vue-i18n';
15
+
16
+ const AMD_RESULT_EMPTY_VALUE = 'EMPTY';
17
+
13
18
  const props = defineProps<{
14
- value: number[];
19
+ value: string[];
15
20
  }>();
21
+
22
+ const { t } = useI18n();
23
+
24
+ const shownValues = computed(() =>
25
+ props.value.map((result) =>
26
+ result === AMD_RESULT_EMPTY_VALUE ? t('reusable.empty') : result,
27
+ ),
28
+ );
16
29
  </script>
17
30
 
18
31
  <style scoped></style>
@@ -19,7 +19,7 @@
19
19
  import { useVuelidate } from '@vuelidate/core';
20
20
  import { requiredIf } from '@vuelidate/validators';
21
21
  import { WtCheckbox, WtMultiSelect } from '@webitel/ui-sdk/components';
22
- import { computed, onMounted, watch } from 'vue';
22
+ import { computed, watch } from 'vue';
23
23
  import { useI18n } from 'vue-i18n';
24
24
 
25
25
  import { CaseAssigneeFilterConfig } from './index';
@@ -29,7 +29,12 @@ type ModelValue = {
29
29
  unassigned: boolean;
30
30
  };
31
31
 
32
- const model = defineModel<ModelValue>();
32
+ const model = defineModel<ModelValue>({
33
+ default: (): ModelValue => ({
34
+ list: [],
35
+ unassigned: false,
36
+ }),
37
+ });
33
38
 
34
39
  const props = defineProps<{
35
40
  filterConfig: CaseAssigneeFilterConfig;
@@ -43,16 +48,6 @@ const emit = defineEmits<{
43
48
 
44
49
  const { t } = useI18n();
45
50
 
46
- const initModel = () => {
47
- if (!model.value) {
48
- model.value = {
49
- list: [],
50
- unassigned: false,
51
- };
52
- }
53
- };
54
- onMounted(() => initModel());
55
-
56
51
  const v$ = useVuelidate<{
57
52
  model: ModelValue;
58
53
  }>(
@@ -30,7 +30,7 @@
30
30
  import { useVuelidate } from '@vuelidate/core';
31
31
  import { required } from '@vuelidate/validators';
32
32
  import { WtMultiSelect, WtSingleSelect } from '@webitel/ui-sdk/components';
33
- import { computed, onMounted, watch } from 'vue';
33
+ import { computed, watch } from 'vue';
34
34
  import { useI18n } from 'vue-i18n';
35
35
 
36
36
  import {
@@ -42,7 +42,12 @@ type ModelValue = {
42
42
  selection: string;
43
43
  conditions: string;
44
44
  };
45
- const model = defineModel<ModelValue>();
45
+ const model = defineModel<ModelValue>({
46
+ default: (): ModelValue => ({
47
+ selection: '',
48
+ conditions: '',
49
+ }),
50
+ });
46
51
  const { t } = useI18n();
47
52
 
48
53
  const updateSelected = (value) => {
@@ -57,16 +62,6 @@ const getConditionList = (params) => {
57
62
  });
58
63
  };
59
64
 
60
- const initModel = () => {
61
- if (!model.value) {
62
- model.value = {
63
- selection: '',
64
- conditions: '',
65
- };
66
- }
67
- };
68
- onMounted(() => initModel());
69
-
70
65
  const v$ = useVuelidate<{
71
66
  model: ModelValue;
72
67
  }>(
@@ -30,7 +30,7 @@
30
30
  import { useVuelidate } from '@vuelidate/core';
31
31
  import { required } from '@vuelidate/validators';
32
32
  import { WtMultiSelect, WtSingleSelect } from '@webitel/ui-sdk/components';
33
- import { computed, onMounted, watch } from 'vue';
33
+ import { computed, watch } from 'vue';
34
34
  import { useI18n } from 'vue-i18n';
35
35
 
36
36
  import { slasConditionsSearchMethod, slasSearchMethod } from './config.js';
@@ -39,7 +39,12 @@ type ModelValue = {
39
39
  selection: string;
40
40
  conditions: string;
41
41
  };
42
- const model = defineModel<ModelValue>();
42
+ const model = defineModel<ModelValue>({
43
+ default: (): ModelValue => ({
44
+ selection: '',
45
+ conditions: '',
46
+ }),
47
+ });
43
48
  const { t } = useI18n();
44
49
 
45
50
  const updateSelected = (value) => {
@@ -54,15 +59,6 @@ const getConditionList = async (params) => {
54
59
  });
55
60
  };
56
61
 
57
- const initModel = () => {
58
- if (!model.value) {
59
- model.value = {
60
- selection: '',
61
- conditions: '',
62
- };
63
- }
64
- };
65
- onMounted(() => initModel());
66
62
  const v$ = useVuelidate<{
67
63
  model: ModelValue;
68
64
  }>(
@@ -29,7 +29,7 @@
29
29
  import { useVuelidate } from '@vuelidate/core';
30
30
  import { required } from '@vuelidate/validators';
31
31
  import { WtMultiSelect, WtSingleSelect } from '@webitel/ui-sdk/components';
32
- import { computed, onMounted, watch } from 'vue';
32
+ import { computed, watch } from 'vue';
33
33
  import { useI18n } from 'vue-i18n';
34
34
 
35
35
  import {
@@ -41,7 +41,12 @@ type ModelValue = {
41
41
  selection: string;
42
42
  conditions: string;
43
43
  };
44
- const model = defineModel<ModelValue>();
44
+ const model = defineModel<ModelValue>({
45
+ default: (): ModelValue => ({
46
+ selection: '',
47
+ conditions: '',
48
+ }),
49
+ });
45
50
  const { t } = useI18n();
46
51
 
47
52
  const updateSelected = (value) => {
@@ -56,16 +61,6 @@ const getConditionList = (params) => {
56
61
  });
57
62
  };
58
63
 
59
- const initModel = () => {
60
- if (!model.value) {
61
- model.value = {
62
- selection: '',
63
- conditions: '',
64
- };
65
- }
66
- };
67
- onMounted(() => initModel());
68
-
69
64
  const v$ = useVuelidate<{
70
65
  model: ModelValue;
71
66
  }>(
@@ -38,7 +38,12 @@ type ModelValue = {
38
38
  unassigned?: boolean | null;
39
39
  };
40
40
 
41
- const model = defineModel<ModelValue>();
41
+ const model = defineModel<ModelValue>({
42
+ default: (): ModelValue => ({
43
+ list: [],
44
+ unassigned: null,
45
+ }),
46
+ });
42
47
 
43
48
  const emit = defineEmits<{
44
49
  'update:invalid': [
@@ -95,19 +100,8 @@ const vUnassigned = computed(() => {
95
100
  return modelValidation.unassigned;
96
101
  });
97
102
 
98
- const initModel = () => {
99
- if (!model.value) {
100
- model.value = {
101
- list: [],
102
- unassigned: null,
103
- };
104
- }
105
- };
106
-
107
103
  onMounted(() => {
108
104
  if (!props?.disableValidation) v$.value.$touch();
109
-
110
- initModel();
111
105
  });
112
106
 
113
107
  watch(
@@ -13,7 +13,7 @@ import { useBooleanFilterValueValidation } from '../../composables/booleanFilter
13
13
  import { BooleanFilterModelValue } from '../../enums/options/BooleanFilterOptions';
14
14
  import HasOptionFilterValueField from '../_shared/has-options/has-option-filter-value-field.vue';
15
15
 
16
- const model = defineModel<BooleanFilterModelValue>();
16
+ const model = defineModel<BooleanFilterModelValue | null>();
17
17
 
18
18
  const { v$ } = useBooleanFilterValueValidation<BooleanFilterModelValue>(model);
19
19
 
@@ -13,7 +13,7 @@ import { useBooleanFilterValueValidation } from '../../composables/booleanFilter
13
13
  import { BooleanFilterModelValue } from '../../enums/options/BooleanFilterOptions';
14
14
  import HasOptionFilterValueField from '../_shared/has-options/has-option-filter-value-field.vue';
15
15
 
16
- const model = defineModel<BooleanFilterModelValue>();
16
+ const model = defineModel<BooleanFilterModelValue | null>();
17
17
 
18
18
  const { v$ } = useBooleanFilterValueValidation<BooleanFilterModelValue>(model);
19
19
 
@@ -13,7 +13,7 @@ import { useBooleanFilterValueValidation } from '../../composables/booleanFilter
13
13
  import { BooleanFilterModelValue } from '../../enums/options/BooleanFilterOptions';
14
14
  import HasOptionFilterValueField from '../_shared/has-options/has-option-filter-value-field.vue';
15
15
 
16
- const model = defineModel<BooleanFilterModelValue>();
16
+ const model = defineModel<BooleanFilterModelValue | null>();
17
17
 
18
18
  const { v$ } = useBooleanFilterValueValidation<BooleanFilterModelValue>(model);
19
19
 
@@ -21,7 +21,7 @@ const props = defineProps<{
21
21
  hideLabel?: boolean;
22
22
  }>();
23
23
 
24
- const model = defineModel<BooleanFilterModelValue>();
24
+ const model = defineModel<BooleanFilterModelValue | null>();
25
25
 
26
26
  let v$: ReturnType<typeof useBooleanFilterValueValidation>['v$'] | null = null;
27
27
  if (!props.disableValidation) {