@webitel/ui-sdk 0.9.34 → 0.9.35

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-sdk",
3
- "version": "0.9.34",
3
+ "version": "0.9.35",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <wt-select
3
3
  :value="filterSchema.value"
4
- :options="filterSchema.options"
4
+ :options="localizedOptions"
5
5
  :label="$t(filterSchema.locale.label)"
6
6
  :track-by="filterSchema.storedProp"
7
7
  :multiple="filterSchema.multiple"
@@ -45,10 +45,26 @@ describe('Enum filter mixin', () => {
45
45
  });
46
46
 
47
47
  it('Sets empty array value if $route query is empty', async () => {
48
- const wrapper = shallowMount(Component, {
48
+ shallowMount(Component, {
49
49
  localVue,
50
50
  router,
51
51
  });
52
52
  expect(setValue).not.toHaveBeenCalled();
53
53
  });
54
+
55
+ it('Attaches locales to options, if they have "locale" key', async () => {
56
+ const options = [{
57
+ locale: 'jest.locale',
58
+ }];
59
+ const expectedOptions = [{
60
+ locale: options[0].locale,
61
+ name: options[0].locale,
62
+ }];
63
+ const wrapper = shallowMount(Component, {
64
+ localVue,
65
+ router,
66
+ data: () => ({ options }),
67
+ });
68
+ expect(wrapper.vm.localizedOptions).toEqual(expectedOptions);
69
+ });
54
70
  });
@@ -4,7 +4,7 @@ export default {
4
4
  mixins: [baseFilterMixin],
5
5
  computed: {
6
6
  options() {
7
- return this.filterSchema.options;
7
+ return this.filterSchema?.options;
8
8
  },
9
9
  locale() {
10
10
  return this.filterSchema?.locale;
@@ -18,6 +18,13 @@ export default {
18
18
  closeOnSelect() {
19
19
  return this.filterSchema?.storedProp;
20
20
  },
21
+ localizedOptions() {
22
+ const optsHaveLocale = this.options.length && this.options[0].locale; // just check 1st el
23
+ if (optsHaveLocale) {
24
+ return this.options.map((opt) => ({ ...opt, name: this.$t(opt.locale) }));
25
+ }
26
+ return this.options;
27
+ },
21
28
  },
22
29
  methods: {
23
30
  restoreValue(value) {