@everymatrix/casino-filter-page 0.0.94 → 0.0.98

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": "@everymatrix/casino-filter-page",
3
- "version": "0.0.94",
3
+ "version": "0.0.98",
4
4
  "main": "dist/casino-filter-page.js",
5
5
  "svelte": "src/index.ts",
6
6
  "scripts": {
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "22c01bfe195ffacb2177610d0728c9f876e3a057"
39
+ "gitHead": "3ecd09ff4964585af90dab401fed6fc7e49e596e"
40
40
  }
@@ -55,6 +55,7 @@
55
55
 
56
56
  if (!provisionalVendorArray) {
57
57
  let filters = sessionStorage.getItem("vendorFiltersByCategory");
58
+
58
59
  if (filters == null) {
59
60
  sessionStorage.setItem("vendorFiltersByCategory", JSON.stringify(provisionalVendorObject = {
60
61
  [currentCategoryId]: provisionalVendorArray
@@ -73,8 +74,8 @@
73
74
 
74
75
  if (selectedVendorsArray) {
75
76
  if (selectedVendorsArray.length) {
76
- vendorsArray.forEach((vendor) => {
77
- selectedVendorsArray.forEach((selected) => {
77
+ vendorsArray.forEach((vendor:any) => {
78
+ selectedVendorsArray.forEach((selected:any) => {
78
79
  if (vendor.id === selected) {
79
80
  vendor.isFilterSelected = true;
80
81
  }
@@ -84,7 +85,7 @@
84
85
  }
85
86
 
86
87
  // populate values for vendor filter selection control
87
- previousFilterSelection = vendorsArray.reduce((arr, obj) => (obj.isFilterSelected && arr.push(obj.id), arr), []);
88
+ previousFilterSelection = vendorsArray.reduce((arr:Array<any>, obj:any) => (obj.isFilterSelected && arr.push(obj.id), arr), []);
88
89
  provisionalVendorArray = previousFilterSelection;
89
90
  // initially, since there is no change in the vendor filter selection, the apply button is disabled
90
91
  applyFilters = false;
@@ -92,27 +93,27 @@
92
93
 
93
94
  case 'AvailableVendors':
94
95
  vendorsArray = e.data.venArray;
95
- provisionalVendorArray = vendorsArray.reduce((a, o) => (o.isFilterSelected && a.push(o.id), a), []);
96
+ provisionalVendorArray = vendorsArray.reduce((arr:Array<any>, obj:any) => (obj.isFilterSelected && arr.push(obj.id), arr), []);
96
97
  break;
97
98
 
98
99
  case 'UpdateSelectedVendorFilters':
99
100
  vendorsArray = e.data.venArray;
100
- if(vendorsArray) {
101
- provisionalVendorArray = vendorsArray.reduce((a, o) => (o.isFilterSelected && a.push(o.id), a), []);
101
+ if (vendorsArray) {
102
+ provisionalVendorArray = vendorsArray.reduce((arr:Array<any>, obj:any) => (obj.isFilterSelected && arr.push(obj.id), arr), []);
102
103
  }
103
104
  break;
104
105
 
105
106
  case 'ClearVendorFilters':
106
107
  clearVendorFilter();
107
- window.postMessage({ type: "ApplyFilters"}, window.location.href);
108
+ window.postMessage({ type: "ApplyFilters" }, window.location.href);
108
109
  applyFilters = false;
109
110
  break;
110
111
 
111
112
  case 'ModalClosed':
112
- vendorsArray.forEach((ven) => {
113
- ven.isFilterSelected = false;
113
+ vendorsArray.forEach((vendor:any) => {
114
+ vendor.isFilterSelected = false;
114
115
  });
115
- window.postMessage({ type: "UpdateFilters", vendorsArray}, window.location.href);
116
+ window.postMessage({ type: "UpdateFilters", vendorsArray }, window.location.href);
116
117
  break;
117
118
 
118
119
  case 'CategoryVendors':
@@ -123,6 +124,7 @@
123
124
  provisionalVendorArray = categoryVendorFiltersCollection[currentCategoryId];
124
125
  }
125
126
  }
127
+
126
128
  break;
127
129
 
128
130
  case 'ModalLoader':
@@ -139,35 +141,35 @@
139
141
  const getVendors = (url:any) => {
140
142
  return new Promise((resolve, reject) => {
141
143
  fetch(url)
142
- .then((res:any) => res.json())
143
- .then((response:any) => {
144
- response = response.items;
144
+ .then((res:any) => res.json())
145
+ .then((response:any) => {
146
+ response = response.items;
145
147
 
146
- resolve(response.items);
148
+ resolve(response.items);
147
149
 
148
- response.forEach((ven:any) => {
149
- let vendors = JSON.parse(sessionStorage.getItem('vendorFiltersByCategory'));
150
+ response.forEach((ven:any) => {
151
+ let vendors = JSON.parse(sessionStorage.getItem('vendorFiltersByCategory'));
150
152
 
151
- if (!vendors) {
152
- vendors = {
153
- currentCategoryId: []
153
+ if (!vendors) {
154
+ vendors = {
155
+ currentCategoryId: []
156
+ }
154
157
  }
155
- }
156
158
 
157
- if (currentCategoryId) {
158
- if (vendors[currentCategoryId]) {
159
- ven.isFilterSelected = (vendors[currentCategoryId].indexOf(ven.id) >= 0) ? true : false;
159
+ if (currentCategoryId) {
160
+ if (vendors[currentCategoryId]) {
161
+ ven.isFilterSelected = (vendors[currentCategoryId].indexOf(ven.id) >= 0) ? true : false;
162
+ }
160
163
  }
161
- }
162
- });
164
+ });
163
165
 
164
- vendorsArray = response;
166
+ vendorsArray = response;
165
167
 
166
- window.postMessage({ type: "UpdateFilters", vendorsArray}, window.location.href);
167
- }).catch((err:any) => {
168
- console.error(err);
169
- reject(err);
170
- });
168
+ window.postMessage({ type: "UpdateFilters", vendorsArray}, window.location.href);
169
+ }).catch((err:any) => {
170
+ console.error(err);
171
+ reject(err);
172
+ });
171
173
  });
172
174
  }
173
175
 
@@ -192,12 +194,16 @@
192
194
  // simple check for array euqlity, indifferent to array's elements order
193
195
  const checkArrayEquality = (arr1:Array<string>, arr2:Array<string>) => {
194
196
  if (arr1.length !== arr2.length) return false;
197
+
195
198
  const uniqueValues = new Set([...arr1, ...arr2]);
199
+
196
200
  for (const v of uniqueValues) {
197
201
  const arr1Count = arr1.filter(e => e === v).length;
198
202
  const arr2Count = arr2.filter(e => e === v).length;
203
+
199
204
  if (arr1Count !== arr2Count) return false;
200
205
  }
206
+
201
207
  return true;
202
208
  }
203
209
 
@@ -205,16 +211,21 @@
205
211
  vendorsArray.forEach((ven) => {
206
212
  ven.isFilterSelected = false;
207
213
  });
208
-
209
214
  let filters = sessionStorage.getItem("vendorFiltersByCategory");
210
215
 
211
216
  window.postMessage({ type: "ClearFilters", vendorsArray}, window.location.href);
217
+
212
218
  filtersMarkedForClearance = true;
213
- applyFilters = (!provisionalVendorArray.length && checkArrayEquality(provisionalVendorArray, previousFilterSelection)) ? false : true;
219
+
220
+ // check if there are any differences between current and previous selections
221
+ applyFilters = checkArrayEquality(provisionalVendorArray, previousFilterSelection);
222
+ // clear current array
223
+ provisionalVendorArray = [];
214
224
 
215
225
  if (filters !== null) {
216
226
  filters = JSON.parse(filters);
217
227
  filters[currentCategoryId] = provisionalVendorArray;
228
+
218
229
  sessionStorage.setItem("vendorFiltersByCategory", JSON.stringify(filters))
219
230
  }
220
231
  }
@@ -231,32 +242,32 @@
231
242
  } else {
232
243
  filters = JSON.parse(filters);
233
244
  filters[currentCategoryId] = provisionalVendorArray;
245
+
234
246
  sessionStorage.setItem("vendorFiltersByCategory", JSON.stringify(filters))
235
247
  }
248
+
236
249
  window.postMessage({ type: "ApplyFilters"}, window.location.href);
237
250
  }
238
251
 
239
252
  const setClientStyling = () => {
240
253
  let sheet = document.createElement('style');
254
+
241
255
  sheet.innerHTML = clientstyling;
242
256
  customStylingContainer.appendChild(sheet);
243
257
  }
244
258
 
245
259
  const setClientStylingURL = () => {
246
260
  let cssFile = document.createElement('style');
247
- cssFile.innerHTML = `@import ${clientstylingurl}`;
248
261
 
249
- if (clientstylingurl) {
250
- fetch(new URL(clientstylingurl))
251
- .then((res) => res.text())
252
- .then((data) => {
253
- cssFile.innerHTML = data
262
+ fetch(new URL(clientstylingurl))
263
+ .then((res) => res.text())
264
+ .then((data) => {
265
+ cssFile.innerHTML = data
254
266
 
255
- if (customStylingContainer) {
256
- setTimeout(() => { customStylingContainer.appendChild(cssFile); });
257
- }
258
- });
259
- }
267
+ if (customStylingContainer) {
268
+ setTimeout(() => { customStylingContainer.appendChild(cssFile); });
269
+ }
270
+ });
260
271
  }
261
272
 
262
273
  onMount(() => {
@@ -275,41 +286,42 @@
275
286
  $: clientstylingurl && setClientStylingURL();
276
287
  </script>
277
288
 
278
- {#if isLoading}
279
- <!-- <p class="FilterLoading">{$_('filters.loading')}</p> -->
280
- <div class="lds-dual-ring"></div>
281
- {:else}
282
- <div class="FilterModalContent {mobileView ? 'FilterModalMobileContent' : ''}" bind:this={customStylingContainer}>
283
- <section class="FilterHeaderSection">
284
- <div class="FilterHeaderDetails">
285
- <h4 class="FilterHeaderTitle">{$_('filters.filterModalTitle')}</h4>
286
- <h5 class="FilterHeaderSubtitle">{$_('filters.filterModalSubtitle')}</h5>
287
- </div>
288
- </section>
289
- <section class="FilterContentSection">
290
- {#if vendorsArray}
291
- {#each vendorsArray as vendor}
292
- <div class="VendorBox {vendor.isFilterSelected ? 'VendorBoxSelected' : ''}" on:click="{() => toggleVendorFilter(vendor)}">
293
- <img class="VendorImage" src="{vendor.image}" alt="{vendor.name}" />
294
- {#if vendor.isFilterSelected}
295
- <div class="FilterIconContainer">
296
- <div class="CheckMark"></div>
297
- </div>
298
- {/if}
299
- </div>
300
- {/each}
301
- {/if}
302
- </section>
303
- <section class="FilterFooterSection">
304
- {#if provisionalVendorArray}
305
- {#if provisionalVendorArray.length}
306
- <div class="ClearFiltersButton" on:click="{() => clearVendorFilter()}">{$_('filters.filterClear')}</div>
289
+ <div bind:this={customStylingContainer}>
290
+ {#if isLoading}
291
+ <div class="lds-dual-ring"></div>
292
+ {:else}
293
+ <div class="FilterModalContent {mobileView ? 'FilterModalMobileContent' : ''}" >
294
+ <section class="FilterHeaderSection">
295
+ <div class="FilterHeaderDetails">
296
+ <h4 class="FilterHeaderTitle">{$_('filters.filterModalTitle')}</h4>
297
+ <h5 class="FilterHeaderSubtitle">{$_('filters.filterModalSubtitle')}</h5>
298
+ </div>
299
+ </section>
300
+ <section class="FilterContentSection">
301
+ {#if vendorsArray}
302
+ {#each vendorsArray as vendor}
303
+ <div class="VendorBox {vendor.isFilterSelected ? 'VendorBoxSelected' : ''}" on:click="{() => toggleVendorFilter(vendor)}">
304
+ <img class="VendorImage" src="{vendor.image}" alt="{vendor.name}" />
305
+ {#if vendor.isFilterSelected}
306
+ <div class="FilterIconContainer">
307
+ <div class="CheckMark"></div>
308
+ </div>
309
+ {/if}
310
+ </div>
311
+ {/each}
312
+ {/if}
313
+ </section>
314
+ <section class="FilterFooterSection">
315
+ {#if provisionalVendorArray}
316
+ {#if provisionalVendorArray.length}
317
+ <div class="ClearFiltersButton" on:click="{() => clearVendorFilter()}">{$_('filters.filterClear')}</div>
318
+ {/if}
307
319
  {/if}
308
- {/if}
309
- <div class="ApplyFiltersButton {!applyFilters ? "ApplyFilterButtonDisabled" : ''}" on:click="{() => applyVendorFilter()}">{$_('filters.filterApply')}</div>
310
- </section>
311
- </div>
312
- {/if}
320
+ <div class="ApplyFiltersButton {!applyFilters ? "ApplyFilterButtonDisabled" : ''}" on:click="{() => applyVendorFilter()}">{$_('filters.filterApply')}</div>
321
+ </section>
322
+ </div>
323
+ {/if}
324
+ </div>
313
325
 
314
326
  <style lang="scss">
315
327
  .FilterModalContent {
@@ -3,7 +3,7 @@ export const VendorFilterPageTranslations = {
3
3
  filters: {
4
4
  loading: 'Loading',
5
5
  filterModalTitle: 'Filter',
6
- filterModalSubtitle: 'You can select multiple vendors',
6
+ filterModalSubtitle: 'You can select multiple options',
7
7
  filterClear: 'Reset filter',
8
8
  filterApply: 'Done'
9
9
  }
@@ -12,7 +12,7 @@ export const VendorFilterPageTranslations = {
12
12
  filters: {
13
13
  loading: 'Loading',
14
14
  filterModalTitle: 'Filter',
15
- filterModalSubtitle: 'You can select multiple vendors',
15
+ filterModalSubtitle: 'Mehrfachauswahl möglich',
16
16
  filterClear: 'Filter zurücksetzen',
17
17
  filterApply: 'Fertig'
18
18
  }
@@ -21,7 +21,7 @@ export const VendorFilterPageTranslations = {
21
21
  filters: {
22
22
  loading: 'Loading',
23
23
  filterModalTitle: 'Filtro',
24
- filterModalSubtitle: 'You can select multiple vendors',
24
+ filterModalSubtitle: 'È possibile la selezione multipla',
25
25
  filterClear: 'Resetta il filtro',
26
26
  filterApply: 'Fatto'
27
27
  }
@@ -75,7 +75,7 @@ export const VendorFilterPageTranslations = {
75
75
  filters: {
76
76
  loading: 'Učitavanje',
77
77
  filterModalTitle: 'Filter',
78
- filterModalSubtitle: 'You can select multiple vendors',
78
+ filterModalSubtitle: 'Možete odabrati više opcija',
79
79
  filterClear: 'Ponovno postavi filter',
80
80
  filterApply: 'Gotovo'
81
81
  }
@@ -84,7 +84,7 @@ export const VendorFilterPageTranslations = {
84
84
  filters: {
85
85
  loading: 'betöltés',
86
86
  filterModalTitle: 'Szűrő',
87
- filterModalSubtitle: 'You can select multiple vendors',
87
+ filterModalSubtitle: 'Több lehetőséget is kiválaszthat',
88
88
  filterClear: 'Szűrő visszaállítása',
89
89
  filterApply: 'Kész'
90
90
  }
@@ -93,7 +93,7 @@ export const VendorFilterPageTranslations = {
93
93
  filters: {
94
94
  loading: 'Ładowanie',
95
95
  filterModalTitle: 'Wyszukaj',
96
- filterModalSubtitle: 'You can select multiple vendors',
96
+ filterModalSubtitle: 'Możliwy wybór wielokrotny',
97
97
  filterClear: 'Wyłącz filtr',
98
98
  filterApply: 'Gotowe'
99
99
  }
@@ -102,7 +102,7 @@ export const VendorFilterPageTranslations = {
102
102
  filters: {
103
103
  loading: 'A carregar',
104
104
  filterModalTitle: 'Filtrar',
105
- filterModalSubtitle: 'You can select multiple vendors',
105
+ filterModalSubtitle: 'Escolha múltipla possível',
106
106
  filterClear: 'Limpar filtro',
107
107
  filterApply: 'Feito'
108
108
  }
@@ -111,7 +111,7 @@ export const VendorFilterPageTranslations = {
111
111
  filters: {
112
112
  loading: 'Loading',
113
113
  filterModalTitle: 'Filter',
114
- filterModalSubtitle: 'You can select multiple vendors',
114
+ filterModalSubtitle: 'Izberete lahko več možnosti',
115
115
  filterClear: 'Ponastavi filter',
116
116
  filterApply: 'Končano'
117
117
  }
@@ -120,7 +120,7 @@ export const VendorFilterPageTranslations = {
120
120
  filters: {
121
121
  loading: 'Loading',
122
122
  filterModalTitle: 'Filter',
123
- filterModalSubtitle: 'You can select multiple vendors',
123
+ filterModalSubtitle: 'Moguć je višestruki izbor',
124
124
  filterClear: 'Resetujte filter',
125
125
  filterApply: 'Gotovo'
126
126
  }