@designcrowd/library.brand-page 5.11.1 → 5.11.2

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.
@@ -61,8 +61,13 @@ declare const _default: import("vue").DefineComponent<{}, {
61
61
  tabs: any[];
62
62
  shapeLibrary: ShapeSearchResponseModel;
63
63
  debounceOnSearch: DebounceHandle | undefined;
64
+ tabsWithTranslations: {
65
+ key: string;
66
+ displayName: any;
67
+ }[];
64
68
  }, {
65
69
  tabMenuClasses(): string;
70
+ selectedTabDisplayName(): string;
66
71
  }, {
67
72
  getShapesCategories(): Promise<void>;
68
73
  getShapes(): Promise<void>;
@@ -4,7 +4,7 @@ import debounce from 'lodash.debounce';
4
4
  import { preloadImage } from '../../brand-page/utils';
5
5
  import { useBrandPageContainerStore, useUiStore, } from '../../brand-page-maker/stores';
6
6
  import {} from '../../models/shapeModels';
7
- import { commonTr } from '../../composables/useTranslate';
7
+ import { commonTr, currentLocale } from '../../composables/useTranslate';
8
8
  export default defineComponent({
9
9
  emits: ['on-select-image'],
10
10
  setup() {
@@ -41,12 +41,16 @@ export default defineComponent({
41
41
  tabs: tabsWithTranslations.map((tab) => tab.displayName),
42
42
  shapeLibrary: {},
43
43
  debounceOnSearch: undefined,
44
+ tabsWithTranslations,
44
45
  };
45
46
  },
46
47
  computed: {
47
48
  tabMenuClasses() {
48
49
  return this.isDesignCom ? 'tw-capitalize tw-pb-4 !tw-font-medium' : '';
49
50
  },
51
+ selectedTabDisplayName() {
52
+ return (this.tabsWithTranslations.find((tab) => tab.key === this.selectedTabName)?.displayName || this.tabsWithTranslations[0].displayName);
53
+ },
50
54
  },
51
55
  created() {
52
56
  this.debounceOnSearch = debounce(this.onSearchShapesText, 1500);
@@ -62,10 +66,14 @@ export default defineComponent({
62
66
  if (!this.shapeLibraryApi) {
63
67
  return;
64
68
  }
69
+ if (this.shapeLibraryCategories.length > 0) {
70
+ return;
71
+ }
65
72
  try {
66
73
  this.isLoading = true;
74
+ const locale = currentLocale();
67
75
  this.shapeLibraryCategories =
68
- (await this.shapeLibraryApi.getShapeCategoriesAsync());
76
+ (await this.shapeLibraryApi.getShapeCategoriesAsync(locale));
69
77
  this.shapeLibraryCategories = this.shapeLibraryCategories.filter((shape) => shape.isEnabled);
70
78
  }
71
79
  catch (e) {
@@ -83,7 +91,8 @@ export default defineComponent({
83
91
  }
84
92
  try {
85
93
  this.isLoading = true;
86
- const newShapes = (await this.shapeLibraryApi.getShapesBySearchTermOrCategoryAsync(this.category ? '' : this.searchText, this.category, this.currentShapeLibraryPage, this.currentPageSize, 'BrandSite', false));
94
+ const locale = currentLocale();
95
+ const newShapes = (await this.shapeLibraryApi.getShapesBySearchTermOrCategoryAsync(this.category ? '' : this.searchText, this.category, this.currentShapeLibraryPage, this.currentPageSize, locale, 'BrandSite', false));
87
96
  this.totalPageSize += newShapes.items.length;
88
97
  if (!this.shapeLibrary || !this.shapeLibrary.items) {
89
98
  this.shapeLibrary = { ...newShapes }; // Initialize if `items` is missing
@@ -131,10 +140,11 @@ export default defineComponent({
131
140
  try {
132
141
  this.isLoading = true;
133
142
  this.currentShapeLibraryPage = 1;
134
- this.searchText = category;
135
- this.category = category;
143
+ this.searchText = category.displayName;
144
+ this.category = category.displayName;
136
145
  this.shapeLibrary = {};
137
- const res = (await this.shapeLibraryApi.getShapesBySearchTermOrCategoryAsync('', this.category, this.currentShapeLibraryPage, this.currentPageSize, 'BrandSite', false));
146
+ const locale = currentLocale();
147
+ const res = (await this.shapeLibraryApi.getShapesBySearchTermOrCategoryAsync('', category.name, this.currentShapeLibraryPage, this.currentPageSize, locale, 'BrandSite', false));
138
148
  this.totalPageSize += res.items.length;
139
149
  if (!this.shapeLibrary || !this.shapeLibrary.items) {
140
150
  this.shapeLibrary = { ...res };
@@ -156,8 +166,10 @@ export default defineComponent({
156
166
  }
157
167
  },
158
168
  async selectTab(tabName) {
159
- this.selectedTabName = tabName;
160
- if (tabName === 'Categories') {
169
+ const tabKey = this.tabsWithTranslations.find((tab) => tab.displayName === tabName)
170
+ ?.key || this.tabsWithTranslations[0].key;
171
+ this.selectedTabName = tabKey;
172
+ if (tabKey === 'Categories') {
161
173
  await this.getShapesCategories();
162
174
  }
163
175
  },
@@ -176,8 +188,9 @@ export default defineComponent({
176
188
  }
177
189
  try {
178
190
  this.isLoading = true;
191
+ const locale = currentLocale();
179
192
  if (this.searchText) {
180
- const res = (await this.shapeLibraryApi.getShapesBySearchTermOrCategoryAsync(this.searchText, '', this.currentShapeLibraryPage, this.currentPageSize, 'BrandSite', false));
193
+ const res = (await this.shapeLibraryApi.getShapesBySearchTermOrCategoryAsync(this.searchText, '', this.currentShapeLibraryPage, this.currentPageSize, locale, 'BrandSite', false));
181
194
  this.totalPageSize += res.items.length;
182
195
  if (!this.shapeLibrary || !this.shapeLibrary.items) {
183
196
  this.shapeLibrary = { ...res };
@@ -87,7 +87,10 @@ export default defineComponent({
87
87
  return !this.searchText;
88
88
  },
89
89
  searchText() {
90
- return this.searchTerm || this.selectedCategory;
90
+ const selectedCategoryObj = this.templateCategories.find((category) => category.name === this.selectedCategory);
91
+ return (this.searchTerm ||
92
+ selectedCategoryObj?.displayName ||
93
+ this.selectedCategory);
91
94
  },
92
95
  templateGridClasses() {
93
96
  return `tw-grid-cols-${this.numColumns}`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@designcrowd/library.brand-page",
3
3
  "description": "A collection of Maker/Designer applications",
4
- "version": "5.11.1",
4
+ "version": "5.11.2",
5
5
  "author": "Design.com Eng",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",
@@ -1,4 +1,5 @@
1
1
  import axios from 'axios';
2
+ import type { LocaleTypes } from '../composables/useTranslate';
2
3
  import type {
3
4
  ShapeCategoryModel,
4
5
  ShapeSearchResponseModel,
@@ -17,8 +18,8 @@ export default class AssetLibraryClient {
17
18
  return `${this.baseUrl}/maker/api/font/${version}`;
18
19
  }
19
20
 
20
- private getShapeCategoriesEndpoint(): string {
21
- return `${this.baseUrl}/api/shape/getcategories`;
21
+ private getShapeCategoriesEndpoint(locale: LocaleTypes): string {
22
+ return `${this.baseUrl}/api/shape/getcategories?locale=${locale}`;
22
23
  }
23
24
 
24
25
  private getShapesByIdsEndpoint = (shapeIds: number[]): string =>
@@ -38,12 +39,13 @@ export default class AssetLibraryClient {
38
39
  pageSize: number,
39
40
  makerMode: string,
40
41
  includeDisabled: boolean,
42
+ locale: LocaleTypes,
41
43
  pageName?: string,
42
44
  pageSection?: string,
43
45
  templateType?: string,
44
46
  searchId?: string,
45
47
  ) => {
46
- let endpoint = `${this.baseUrl}/api/shape/search?searchterm=${searchTerm}&category=${category}&page=${page}&pageSize=${pageSize}&makerMode=${makerMode}&includeDisabled=${includeDisabled}`;
48
+ let endpoint = `${this.baseUrl}/api/shape/search?searchterm=${searchTerm}&category=${category}&page=${page}&pageSize=${pageSize}&makerMode=${makerMode}&includeDisabled=${includeDisabled}&locale=${locale}`;
47
49
 
48
50
  if (pageName) {
49
51
  endpoint += `&pageName=${pageName}`;
@@ -74,9 +76,11 @@ export default class AssetLibraryClient {
74
76
  }
75
77
  }
76
78
 
77
- async getShapeCategoriesAsync(): Promise<ShapeCategoryModel[]> {
79
+ async getShapeCategoriesAsync(
80
+ locale: LocaleTypes,
81
+ ): Promise<ShapeCategoryModel[]> {
78
82
  try {
79
- const resp = await axios.get(this.getShapeCategoriesEndpoint());
83
+ const resp = await axios.get(this.getShapeCategoriesEndpoint(locale));
80
84
 
81
85
  return resp.data;
82
86
  } catch (error) {
@@ -91,6 +95,7 @@ export default class AssetLibraryClient {
91
95
  category: string | null,
92
96
  page: number,
93
97
  pageSize: number,
98
+ locale: LocaleTypes,
94
99
  makerMode?: string,
95
100
  includeDisabled = false,
96
101
  pageName?: string,
@@ -105,6 +110,7 @@ export default class AssetLibraryClient {
105
110
  pageSize,
106
111
  makerMode ?? '',
107
112
  includeDisabled,
113
+ locale,
108
114
  pageName,
109
115
  pageSection,
110
116
  templateType,
@@ -162,6 +162,7 @@ const existingDomainModalTr = (key) => tr(`existingDomainModal.${key}`);
162
162
  const sensitiveContentModalTr = (key, valuesToInterpolate = {}) =>
163
163
  tr(`sensitiveContentModal.${key}`, valuesToInterpolate, true);
164
164
  const quickLinkBarTr = (key) => tr(`quickLinkBar.${key}`);
165
+ const unsplashImageCategoriesTr = (key) => tr(`unsplashImageCategories.${key}`);
165
166
  const brandPageFooterTr = (key, valuesToInterpolate = {}) =>
166
167
  tr(`brandPageFooter.${key}`, valuesToInterpolate);
167
168
  const productTr = (key) => tr(`product.${key}`);
@@ -185,10 +186,22 @@ const productDetailModalTr = (key, valuesToInterpolate = {}) =>
185
186
  const videoTr = (key, valuesToInterpolate = {}) =>
186
187
  tr(`video.${key}`, valuesToInterpolate);
187
188
 
189
+ const currentLocale = (): LocaleTypes => {
190
+ const i18 = getI18NextInstance();
191
+ const locale = i18.language as LocaleTypes;
192
+
193
+ if (supportedLocales.includes(locale)) {
194
+ return locale;
195
+ }
196
+
197
+ return fallbackLocale;
198
+ };
199
+
188
200
  export {
189
201
  setLocaleAsync,
190
202
  getCurrentLocale,
191
203
  tr,
204
+ currentLocale,
192
205
  modelsTr,
193
206
  commonTr,
194
207
  actionBarTr,
@@ -248,6 +261,7 @@ export {
248
261
  existingDomainModalTr,
249
262
  sensitiveContentModalTr,
250
263
  quickLinkBarTr,
264
+ unsplashImageCategoriesTr,
251
265
  brandPageFooterTr,
252
266
  productTr,
253
267
  imageTr,
@@ -44,7 +44,8 @@
44
44
 
45
45
  <div
46
46
  v-if="
47
- data.activeTab === 'shapes' && data.selectedShapeTab === 'Background'
47
+ data.activeTab === 'shapes' &&
48
+ data.selectedShapeTab === backgroundSettingsTr(`other`)
48
49
  "
49
50
  >
50
51
  <slot
@@ -66,7 +67,10 @@
66
67
  />
67
68
  </div>
68
69
  <div
69
- v-if="data.activeTab === 'shapes' && data.selectedShapeTab === 'Other'"
70
+ v-if="
71
+ data.activeTab === 'shapes' &&
72
+ data.selectedShapeTab === backgroundSettingsTr(`background`)
73
+ "
70
74
  >
71
75
  <slot v-if="isAdmin" name="pre-shape" config-option="shape" />
72
76
 
@@ -11,7 +11,7 @@ import {
11
11
  type ShapeCategoryModel,
12
12
  type ShapeSearchResponseModel,
13
13
  } from '../../models/shapeModels';
14
- import { commonTr } from '../../composables/useTranslate';
14
+ import { commonTr, currentLocale } from '../../composables/useTranslate';
15
15
 
16
16
  export default defineComponent({
17
17
  emits: ['on-select-image'],
@@ -51,12 +51,20 @@ export default defineComponent({
51
51
  tabs: tabsWithTranslations.map((tab) => tab.displayName),
52
52
  shapeLibrary: {} as ShapeSearchResponseModel,
53
53
  debounceOnSearch: undefined as DebounceHandle | undefined,
54
+ tabsWithTranslations,
54
55
  };
55
56
  },
56
57
  computed: {
57
58
  tabMenuClasses(): string {
58
59
  return this.isDesignCom ? 'tw-capitalize tw-pb-4 !tw-font-medium' : '';
59
60
  },
61
+ selectedTabDisplayName(): string {
62
+ return (
63
+ this.tabsWithTranslations.find(
64
+ (tab) => tab.key === this.selectedTabName,
65
+ )?.displayName || this.tabsWithTranslations[0].displayName
66
+ );
67
+ },
60
68
  },
61
69
  created() {
62
70
  this.debounceOnSearch = debounce(this.onSearchShapesText, 1500);
@@ -74,10 +82,18 @@ export default defineComponent({
74
82
  return;
75
83
  }
76
84
 
85
+ if (this.shapeLibraryCategories.length > 0) {
86
+ return;
87
+ }
88
+
77
89
  try {
78
90
  this.isLoading = true;
91
+ const locale = currentLocale();
92
+
79
93
  this.shapeLibraryCategories =
80
- (await this.shapeLibraryApi.getShapeCategoriesAsync()) as ShapeCategoryModel[];
94
+ (await this.shapeLibraryApi.getShapeCategoriesAsync(
95
+ locale,
96
+ )) as ShapeCategoryModel[];
81
97
  this.shapeLibraryCategories = this.shapeLibraryCategories.filter(
82
98
  (shape) => shape.isEnabled,
83
99
  );
@@ -97,6 +113,7 @@ export default defineComponent({
97
113
 
98
114
  try {
99
115
  this.isLoading = true;
116
+ const locale = currentLocale();
100
117
 
101
118
  const newShapes =
102
119
  (await this.shapeLibraryApi.getShapesBySearchTermOrCategoryAsync(
@@ -104,6 +121,7 @@ export default defineComponent({
104
121
  this.category,
105
122
  this.currentShapeLibraryPage,
106
123
  this.currentPageSize,
124
+ locale,
107
125
  'BrandSite',
108
126
  false,
109
127
  )) as ShapeSearchResponseModel;
@@ -159,16 +177,18 @@ export default defineComponent({
159
177
  try {
160
178
  this.isLoading = true;
161
179
  this.currentShapeLibraryPage = 1;
162
- this.searchText = category;
163
- this.category = category;
180
+ this.searchText = category.displayName;
181
+ this.category = category.displayName;
164
182
  this.shapeLibrary = {} as ShapeSearchResponseModel;
183
+ const locale = currentLocale();
165
184
 
166
185
  const res =
167
186
  (await this.shapeLibraryApi.getShapesBySearchTermOrCategoryAsync(
168
187
  '',
169
- this.category,
188
+ category.name,
170
189
  this.currentShapeLibraryPage,
171
190
  this.currentPageSize,
191
+ locale,
172
192
  'BrandSite',
173
193
  false,
174
194
  )) as ShapeSearchResponseModel;
@@ -193,9 +213,13 @@ export default defineComponent({
193
213
  },
194
214
 
195
215
  async selectTab(tabName) {
196
- this.selectedTabName = tabName;
216
+ const tabKey =
217
+ this.tabsWithTranslations.find((tab) => tab.displayName === tabName)
218
+ ?.key || this.tabsWithTranslations[0].key;
219
+
220
+ this.selectedTabName = tabKey;
197
221
 
198
- if (tabName === 'Categories') {
222
+ if (tabKey === 'Categories') {
199
223
  await this.getShapesCategories();
200
224
  }
201
225
  },
@@ -221,6 +245,7 @@ export default defineComponent({
221
245
 
222
246
  try {
223
247
  this.isLoading = true;
248
+ const locale = currentLocale();
224
249
 
225
250
  if (this.searchText) {
226
251
  const res =
@@ -229,6 +254,7 @@ export default defineComponent({
229
254
  '',
230
255
  this.currentShapeLibraryPage,
231
256
  this.currentPageSize,
257
+ locale,
232
258
  'BrandSite',
233
259
  false,
234
260
  )) as ShapeSearchResponseModel;
@@ -15,7 +15,7 @@
15
15
  class="tw-w-full tw-mb-6"
16
16
  :classes="tabMenuClasses"
17
17
  :tab-names="tabs"
18
- :selected-tab-name="selectedTabName"
18
+ :selected-tab-name="selectedTabDisplayName"
19
19
  @on-tab-selected="selectTab"
20
20
  />
21
21
  <div
@@ -35,7 +35,7 @@
35
35
  <button
36
36
  class="tw-p-4 tw-w-full tw-text-white tw-bg-opacity-75 tw-bg-black tw-cursor-pointer"
37
37
  :data-test-shape-library-category="shapeCategory.displayName"
38
- @click="onCategoryClicked(shapeCategory.displayName)"
38
+ @click="onCategoryClicked(shapeCategory)"
39
39
  >
40
40
  {{ shapeCategory.displayName }}
41
41
  </button>
@@ -125,7 +125,15 @@ export default defineComponent({
125
125
  },
126
126
 
127
127
  searchText(): string | undefined {
128
- return this.searchTerm || this.selectedCategory;
128
+ const selectedCategoryObj = this.templateCategories.find(
129
+ (category) => category.name === this.selectedCategory,
130
+ );
131
+
132
+ return (
133
+ this.searchTerm ||
134
+ selectedCategoryObj?.displayName ||
135
+ this.selectedCategory
136
+ );
129
137
  },
130
138
 
131
139
  templateGridClasses(): string {
@@ -87,7 +87,7 @@
87
87
  style="height: auto"
88
88
  @click="onCategorySelect(templateCategory)"
89
89
  >
90
- {{ templateCategory.name }}
90
+ {{ templateCategory?.displayName ?? templateCategory.name }}
91
91
  </div>
92
92
  </li>
93
93
  </ul>