|
123 | 123 | var changeTimer; |
124 | 124 | var lastImage=null; |
125 | 125 | var touchmoved; |
| 126 | + var notificationBadges = []; |
| 127 | + var currentInstanceId = buildfire.getContext().instanceId; |
126 | 128 |
|
127 | 129 |
|
128 | 130 | var lazyLoad = { |
|
407 | 409 | var display=(obj.data.content&&obj.data.content.display)?obj.data.content.display:0; |
408 | 410 | renderCarousel(obj.data.content.carouselImages, layout,speed,order,display); |
409 | 411 | } |
| 412 | + |
| 413 | + if (obj.data.design.showNotificationBadges && plugins && plugins.length) { |
| 414 | + getBadges(plugins.map(function (plugin) { return plugin.instanceId }), function (badgesData) { |
| 415 | + if (!badgesData || !badgesData.length) return; |
| 416 | + if (layout == 1) { |
| 417 | + var sections = document.getElementsByClassName('pluginItem'); |
| 418 | + for (var i = 0; i < sections.length; i++) { |
| 419 | + var pluginIndex = sections[i].children[0].children[1].getAttribute('index'); |
| 420 | + var instanceId = plugins[parseInt(pluginIndex)] ? plugins[parseInt(pluginIndex)].instanceId : null; |
| 421 | + if (!instanceId) continue; |
| 422 | + var currentBadgeData = badgesData.find(function(item) { return item.uniqueId === instanceId }); |
| 423 | + var countValue = currentBadgeData && currentBadgeData.count ? currentBadgeData.count : 0; |
| 424 | + if (!countValue) continue; |
| 425 | + var notificationBadgeBoxElem = document.createElement('div') |
| 426 | + notificationBadgeBoxElem.setAttribute('class', 'notificationBadgeBox btn-info'); |
| 427 | + notificationBadgeBoxElem.innerHTML = '<span style="color: #fff">' + countValue + '</span>'; |
| 428 | + sections[i].appendChild(notificationBadgeBoxElem); |
| 429 | + } |
| 430 | + } |
| 431 | + }); |
| 432 | + } |
| 433 | + |
| 434 | + } |
| 435 | + |
| 436 | + function getBadges(uniqueIds = [], callback) { |
| 437 | + if (!uniqueIds.length) return callback([]); |
| 438 | + buildfire.appData.search( |
| 439 | + { filter: { '_buildfire.index.string1': { $in: [...uniqueIds, currentInstanceId] } } }, |
| 440 | + '$$notificationBadges', |
| 441 | + function (err, result) { |
| 442 | + if (err || !result || !result.length) return callback([]); |
| 443 | + var mappedData = result.map(function (data) { return data.data }); |
| 444 | + notificationBadges = notificationBadges.concat(mappedData); |
| 445 | + callback(mappedData); |
| 446 | + } |
| 447 | + ); |
| 448 | + }; |
| 449 | + |
| 450 | + function setBadgesCount(uniqueId, count = 0) { |
| 451 | + buildfire.appData.searchAndUpdate( |
| 452 | + { '_buildfire.index.string1': uniqueId }, |
| 453 | + { count }, |
| 454 | + '$$notificationBadges', |
| 455 | + function () {} |
| 456 | + ); |
410 | 457 | } |
411 | 458 |
|
412 | 459 | function getPlugins(obj, callback) { |
|
685 | 732 | if(touchmoved != true){ |
686 | 733 | var i = parseInt(this.getAttribute('index')); |
687 | 734 | var p = plugins[i]; |
| 735 | + var queryString = new URLSearchParams(); |
| 736 | + queryString.append('parentUniqueId', currentInstanceId); |
688 | 737 |
|
689 | 738 | buildfire.navigation.navigateTo({ |
690 | 739 | pluginId: p.pluginTypeId |
691 | 740 | , folderName: p.folderName |
692 | 741 | , instanceId: p.instanceId |
693 | 742 | , title: p.title |
| 743 | + , queryString: queryString.toString() |
694 | 744 | }); |
695 | 745 | } |
696 | 746 | } |
|
981 | 1031 | line-height: 20vw !important; |
982 | 1032 | } |
983 | 1033 |
|
| 1034 | + .layout1 .pluginItem { |
| 1035 | + position: relative; |
| 1036 | + } |
| 1037 | + |
| 1038 | + .layout1 .pluginItem .notificationBadgeBox { |
| 1039 | + position: absolute; |
| 1040 | + top: 50%; |
| 1041 | + right: 4vw; |
| 1042 | + transform: translateY(-50%); |
| 1043 | + width: 25px; |
| 1044 | + height: 25px; |
| 1045 | + display: flex; |
| 1046 | + justify-content: center; |
| 1047 | + align-items: center; |
| 1048 | + border-radius: 50%; |
| 1049 | + } |
| 1050 | + |
| 1051 | + .layout1 .pluginItem .notificationBadgeBox span { |
| 1052 | + position: relative; |
| 1053 | + right: 1px; |
| 1054 | + } |
| 1055 | + |
984 | 1056 | /* |
985 | 1057 | Layout-2 |
986 | 1058 | */ |
|
0 commit comments