@everymatrix/casino-games-category-section 1.5.6 → 1.7.0

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-games-category-section",
3
- "version": "1.5.6",
3
+ "version": "1.7.0",
4
4
  "main": "dist/casino-games-category-section.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": "18b817f66a008871bf85a5a004a749dca5111add"
39
+ "gitHead": "b405cf7bcce97b06567550e59f40f2d310be97af"
40
40
  }
@@ -9,6 +9,8 @@
9
9
  import moment from 'moment';
10
10
 
11
11
  import '@everymatrix/casino-game-thumbnail';
12
+ import '@everymatrix/casino-filter';
13
+
12
14
 
13
15
  const MASONRY_CLASS_PREFIX = 'game-tile-';
14
16
 
@@ -32,6 +34,9 @@
32
34
  export let integratedgameframedesktop:string = 'false';
33
35
  export let integratedgameframemobile:string = 'false';
34
36
  export let casinomygames:string = 'false';
37
+ export let addfilterselector:string = 'false';
38
+ export let addsortingselector:string = 'false';
39
+ export let filterbylogo:string = '';
35
40
 
36
41
  export let once = true;
37
42
  export let top = 0;
@@ -177,19 +182,20 @@
177
182
 
178
183
  // @TODO categoryId type
179
184
  const getData = (categoryId:any, offset:number, limit:number, filterArray:Array<Object> = []) => {
185
+ isLoading = true;
186
+
180
187
  let categoryidparsed = '';
181
188
  let url:any = '';
182
- isLoading = true;
189
+ let vendorFilters = JSON.parse(localStorage.getItem('vendorFiltersByCategory'));
190
+
191
+ let tempEndpoint:string = endpoint.replace(/.$/, "2"); // @TODO remove after we migrate with all endpoints to v2 - hack for the endpoint since the filtering of categories functionality was developed only for the v2 api
183
192
  if((categoryid.match(/\$/g) || []).length > 1) {
184
193
  categoryidparsed = categoryid.split('$').slice(0, 2).join('$');
185
- url = new URL(`${endpoint}/casino/groups/${datasource}/${categoryidparsed}/subGroups`);
186
-
194
+ url = new URL(`${tempEndpoint}/casino/groups/${datasource}/${categoryidparsed}/subGroups`);
187
195
  } else {
188
- url = new URL(`${endpoint}/casino/groups/${datasource}/${categoryid}`);
196
+ url = new URL(`${tempEndpoint}/casino/groups/${datasource}/${categoryid}`);
189
197
  }
190
198
 
191
- let vendorFilters = JSON.parse(sessionStorage.getItem('vendorFiltersByCategory'));
192
-
193
199
  return new Promise((resolve, reject) => {
194
200
  url.searchParams.delete("pagination");
195
201
  url.searchParams.append("expand", "games(vendor)");
@@ -208,10 +214,10 @@
208
214
 
209
215
  filteresPresent = true;
210
216
  vendorFilters[categoryid].forEach(vendorId => {
211
- queryParamVendorId = queryParamVendorId + (queryParamVendorId ? `, id=${vendorId}` : `id=${vendorId}`);
217
+ queryParamVendorId = queryParamVendorId + (queryParamVendorId ? `,games(vendor(id=${vendorId}))` : `games(vendor(id=${vendorId}))`);
212
218
  });
213
219
 
214
- url.searchParams.append('filter', `games(vendor(${queryParamVendorId}))`);
220
+ url.searchParams.append('filter', ((vendorFilters && vendorFilters[categoryid].length < 2) ? `$and` : `$or`) + `(${queryParamVendorId})`);
215
221
  } else {
216
222
  filteresPresent = false;
217
223
  }
@@ -232,7 +238,7 @@
232
238
  dataloaded = true;
233
239
  hasErrors = false;
234
240
  maxTotal = categoryData.games.total;
235
-
241
+
236
242
  resolve(categoryData);
237
243
  }, (err:any) => {
238
244
  hasErrors = true;
@@ -369,7 +375,7 @@
369
375
  shownCategoryData = categoryData.games.items;
370
376
  showLoadCategory = false;
371
377
  // @TODO: replace this quick fix - when there are only a few category games, the view scrolls to the footer
372
- if(shownCategoryData.length < 10) {
378
+ if(shownCategoryData.length < 10 && e.data.origin ==! 'filters') {
373
379
  scrollTop = true;
374
380
  setTimeout(() => {
375
381
  window.postMessage({ type: 'WidgetTopReference', scrollTop }, window.location.href);
@@ -381,16 +387,17 @@
381
387
 
382
388
  case 'FavoriteUpdate':
383
389
  lobbyView = true;
384
- shownCategoryData = categoryData.games.items;
385
- shownCategoryData.forEach((item:any) => {
386
- item.isFavorite = checkFavorite(item.id);
387
- });
390
+ if(categoryData) {
391
+ shownCategoryData = categoryData.games.items;
392
+ shownCategoryData.forEach((item:any) => {
393
+ item.isFavorite = checkFavorite(item.id);
394
+ });
395
+ }
388
396
 
389
397
  break;
390
398
 
391
399
  // Start favorite category section
392
400
  case 'UpdateCategoryFavoriteGames':
393
-
394
401
  if (e.data.receivedFavoriteResults) {
395
402
  favoriteGames = e.data.receivedFavoriteResults.items;
396
403
  if(e.data.favStadalone) return;
@@ -477,10 +484,10 @@
477
484
  }
478
485
 
479
486
  const addGameTag = (tags:any[]):string => {
480
- if(tags?.length === 0) return '';
487
+ if (tags?.length === 0) return '';
481
488
 
482
- let tagName:string;
483
- let differenceOfTime = 99999999999;
489
+ let tagName:string = '';
490
+ let differenceOfTime = 999999999999;
484
491
  let firstToExpire:number;
485
492
 
486
493
  const currentDate = new Date(Date.now());
@@ -493,7 +500,7 @@
493
500
  differenceOfTime = moment(endDateOfTag).diff(currentDate)
494
501
  firstToExpire = index;
495
502
  }
496
-
503
+
497
504
  if (moment(currentDate).isAfter(startDateOfTag) && moment(currentDate).isBefore(endDateOfTag)) {
498
505
  tagName = tags[firstToExpire].name;
499
506
  }
@@ -548,7 +555,7 @@
548
555
  });
549
556
  }
550
557
  }
551
-
558
+
552
559
  const setClientStyling = ():void => {
553
560
  let sheet = document.createElement('style');
554
561
  sheet.innerHTML = clientstyling;
@@ -661,18 +668,34 @@
661
668
  <div class="CasinoGamesContainer" part="CasinoGamesContainer">
662
669
  {#if casinomygames !== 'true'}
663
670
  <div class="CasinoGamesHeader" part="CasinoGamesHeader">
664
- <h3 class="CategoryName" part="CategoryName" bind:this={categoryName}>
665
- {categoryData.name}
666
- </h3>
667
- {#if showLoadCategory}
668
- <!-- svelte-ignore a11y-missing-attribute -->
669
- <a class="CategoryNameLink" part="CategoryNameLink" on:click="{e => showCategory(categoryData.id, categoryData)}">
670
- <span class="CategoryLoadMore" part="CategoryLoadMore">
671
- {$_('gamesCategorySection.viewAll')} ({categoryData.games.total})
672
- </span>
673
- </a>
674
- {/if}
675
- </div>
671
+ <h3 class="CategoryName" part="CategoryName" bind:this={categoryName}>
672
+ {categoryData.name}
673
+ </h3>
674
+ {#if showLoadCategory}
675
+ <!-- svelte-ignore a11y-missing-attribute -->
676
+ <a class="CategoryNameLink" part="CategoryNameLink" on:click="{e => showCategory(categoryData.id, categoryData)}">
677
+ <span class="CategoryLoadMore" part="CategoryLoadMore">
678
+ {$_('gamesCategorySection.viewAll')} ({categoryData.games.total})
679
+ </span>
680
+ </a>
681
+ {:else}
682
+ <div class=" {(addfilterselector == 'true' && addsortingselector == 'true') ? 'CategoryFilterContainer' : ''}">
683
+ {#if addfilterselector == "true"}
684
+ <casino-filter
685
+ {clientstylingurl}
686
+ {clientstyling}
687
+ {endpoint}
688
+ {datasource}
689
+ {lang}
690
+ {categoryid}
691
+ {addfilterselector}
692
+ {addsortingselector}
693
+ {filterbylogo}>
694
+ </casino-filter>
695
+ {/if}
696
+ </div>
697
+ {/if}
698
+ </div>
676
699
  {/if}
677
700
  {#if isLoading}
678
701
  <div class="lds-dual-ring" part="lds-dual-ring"></div>
@@ -680,7 +703,7 @@
680
703
  {#if shownCategoryData.length !== 0}
681
704
  <ul class="{(favoriteGamesData.items.length === 0 && showFavGamesCategory) ? '' : 'CasinoGamesGrid'} GamesListIncreasedGap" part="{(favoriteGamesData.items.length === 0 && showFavGamesCategory) ? '' : 'CasinoGamesGrid'} GamesListIncreasedGap" bind:this={container}>
682
705
  {#each shownCategoryData as gameprops, index}
683
- {#if intersecting || nativeLoading}
706
+ {#if intersecting || nativeLoading}
684
707
  <casino-game-thumbnail
685
708
  session={session}
686
709
  userid={userid}
@@ -722,10 +745,10 @@
722
745
  <div class="CasinoGamesContainer" part="CasinoGamesContainer">
723
746
  {#if casinomygames !== 'true'}
724
747
  <div class="CasinoGamesHeader" part="CasinoGamesHeader">
725
- <h3 class="CategoryName" part="CategoryName" bind:this={categoryName}>
726
- {$_('gamesCategorySection.favorites')}
727
- <span class="CategoryFavName">({favoriteGamesData.items.length})</span>
728
- </h3>
748
+ <h3 class="CategoryName" part="CategoryName" bind:this={categoryName}>
749
+ {$_('gamesCategorySection.favorites')}
750
+ <span class="CategoryFavName">({favoriteGamesData.items.length})</span>
751
+ </h3>
729
752
  </div>
730
753
  {/if}
731
754
 
@@ -740,7 +763,7 @@
740
763
  {#if intersecting || nativeLoading}
741
764
  {#if isMobile(userAgent)}
742
765
  {#if (gameprops.gameModel.platform.includes("iPad") || gameprops.gameModel.platform.includes("iPhone") || gameprops.gameModel.platform.includes("Android"))}
743
- <casino-game-thumbnail
766
+ <casino-game-thumbnail
744
767
  class="{MASONRY_CLASS_PREFIX}{gameprops.cellSize ? gameprops.cellSize : '1x1'}"
745
768
  part="{MASONRY_CLASS_PREFIX}{gameprops.cellSize ? gameprops.cellSize : '1x1'}"
746
769
  session={session}
@@ -751,7 +774,7 @@
751
774
  gamename={gameprops.gameModel.name}
752
775
  gamevendor={gameprops.gameModel.vendor.name}
753
776
  gameisnew={gameprops.gameModel.isNew}
754
- gametag={gameprops.gameModel.advancedTags?.length > 0 && addGameTag(gameprops.advancedTags)}
777
+ gametag={gameprops.gameModel.advancedTags?.length > 0 && addGameTag(gameprops.gameModel.advancedTags)}
755
778
  gamecellsize={gameprops.cellSize}
756
779
  gameid={gameprops.gameModel.id}
757
780
  gamefunmode={gameprops.gameModel.hasFunMode}
@@ -782,7 +805,7 @@
782
805
  gamename={gameprops.gameModel.name}
783
806
  gamevendor={gameprops.gameModel.vendor.name}
784
807
  gameisnew={gameprops.gameModel.isNew}
785
- gametag={gameprops.gameModel.advancedTags?.length > 0 && addGameTag(gameprops.advancedTags)}
808
+ gametag={gameprops.gameModel.advancedTags?.length > 0 && addGameTag(gameprops.gameModel.advancedTags)}
786
809
  gamecellsize={gameprops.cellSize}
787
810
  gameid={gameprops.gameModel.id}
788
811
  gamefunmode={gameprops.gameModel.hasFunMode}
@@ -983,6 +1006,12 @@
983
1006
  }
984
1007
  }
985
1008
 
1009
+ .CategoryFilterContainer {
1010
+ display: grid;
1011
+ grid-template-columns: 1fr 1fr;
1012
+ gap: 20px;
1013
+ }
1014
+
986
1015
  @media screen and (max-width: 385px) {
987
1016
  .CasinoGamesGrid {
988
1017
  display: grid;
@@ -1013,6 +1042,17 @@
1013
1042
  }
1014
1043
  }
1015
1044
 
1045
+ @media only screen and (max-width: 768px) {
1046
+ .CasinoGamesHeader {
1047
+ align-items: unset;
1048
+ flex-direction: column;
1049
+ }
1050
+
1051
+ .CategoryName {
1052
+ margin-bottom: 20px;
1053
+ }
1054
+ }
1055
+
1016
1056
  @media screen and (min-width: 1100px) {
1017
1057
  .CasinoGamesGrid {
1018
1058
  grid-template-rows: repeat(auto-fill, 142px);
@@ -14,7 +14,7 @@ export const GamesCategorySectionTranslations = {
14
14
  waiting: 'Waiting',
15
15
  }
16
16
  },
17
- zh: {
17
+ 'zh-hk': {
18
18
  gamesCategorySection: {
19
19
  showMore: '更多的',
20
20
  viewAll: '顯示所有',