From 52d80d5fb681f0807228d30fc70768c5bf3cd6a7 Mon Sep 17 00:00:00 2001 From: halwan-bot Date: Tue, 27 Jul 2021 06:05:45 +0300 Subject: [PATCH 1/8] Implemented Seminar Delay --- .../controllers/content.home.controller.js | 8 +- .../controllers/content.item.controller.js | 10 + control/settings/app.js | 2 +- .../controllers/settings.home.controller.js | 71 +++++- control/settings/templates/home.html | 68 ++++-- widget/assets/css/style.css | 7 + widget/assets/js/shared/stringsConfig.js | 12 + .../controllers/widget.bookmark.controller.js | 80 ++++++- widget/controllers/widget.home.controller.js | 209 ++++++++++++++++-- widget/controllers/widget.notes.controller.js | 1 + .../controllers/widget.search.controller.js | 93 +++++++- widget/index.html | 2 +- widget/templates/Bookmarks.html | 2 +- widget/templates/Item_List_1.html | 4 +- widget/templates/Item_List_2.html | 4 +- widget/templates/Item_List_3.html | 4 +- widget/templates/Item_List_4.html | 6 +- widget/templates/Item_List_5.html | 4 +- widget/templates/Search.html | 4 +- 19 files changed, 517 insertions(+), 74 deletions(-) diff --git a/control/content/controllers/content.home.controller.js b/control/content/controllers/content.home.controller.js index 66600e1..c550072 100644 --- a/control/content/controllers/content.home.controller.js +++ b/control/content/controllers/content.home.controller.js @@ -81,6 +81,7 @@ if(data) { var item = ContentHome.items[_index]; Deeplink.deleteById(item.id); + buildfire.analytics.unregisterEvent(item.id); DataStore.deleteById(item.id, TAG_NAMES.SEMINAR_ITEMS).then(function (result) { ContentHome.items.splice(_index, 1); searchOptionUserData.filter ={"$or": [{"$json.itemID": {"$eq": item.id}}]}; @@ -191,8 +192,10 @@ else editor.loadItems(ContentHome.data.content.carouselImages); } - if(typeof ContentHome.data.content.sortBy == "undefined") - ContentHome.data.content.sortBy=SORT.MANUALLY; + if(typeof ContentHome.data.content.sortBy == "undefined"){ + // ContentHome.data.content.sortBy=SORT.MANUALLY; + ContentHome.sortItemBy(SORT.OLDEST_FIRST) + } ContentHome.itemSortableOptions.disabled = !(ContentHome.data.content.sortBy === SORT.MANUALLY); RankOfLastItem.setRank(ContentHome.data.content.rankOfLastItem || 0); updateMasterItem(ContentHome.data); @@ -358,7 +361,6 @@ } }; - /* * Call the datastore to save the data object */ diff --git a/control/content/controllers/content.item.controller.js b/control/content/controllers/content.item.controller.js index 14a9a23..6924a73 100644 --- a/control/content/controllers/content.item.controller.js +++ b/control/content/controllers/content.item.controller.js @@ -173,6 +173,16 @@ _data.rank = ContentItem.item.data.rank; RankOfLastItem.setRank(_rankOfLastItem); updateMasterItem(ContentItem.item); + + buildfire.analytics.registerEvent( + { + title: ContentItem.item.data.title, + key: result.id, + description: "Number of times this item has been opened", + }, + { silentNotification: true } + ); + ContentItem.item.data.deepLinkUrl = Buildfire.deeplink.createLink({ id: result.id }); if (ContentItem.item.id) { buildfire.messaging.sendMessageToWidget({ diff --git a/control/settings/app.js b/control/settings/app.js index 38dee5f..b3aecd4 100644 --- a/control/settings/app.js +++ b/control/settings/app.js @@ -1,7 +1,7 @@ 'use strict'; (function (angular) { angular - .module('seminarSettings', ['ngRoute']) + .module('seminarSettings', ['ngRoute', 'ui.bootstrap']) .config(['$routeProvider', function ($routeProvider) { $routeProvider .when('/', { diff --git a/control/settings/controllers/settings.home.controller.js b/control/settings/controllers/settings.home.controller.js index 688981e..d4322ad 100644 --- a/control/settings/controllers/settings.home.controller.js +++ b/control/settings/controllers/settings.home.controller.js @@ -6,16 +6,30 @@ function ($scope, Buildfire, LAYOUTS, DataStore, TAG_NAMES) { var Settings = this; Settings.data = {}; + + Settings.seminarDelayOptions = [ + { label: "Off", value: 0 }, + { label: "Half hour", value: 30 }, + { label: "One hour", value: 60 }, + { label: "One Day", value: 1440 }, + { label: "One Week", value: 10080 }, + ]; + + Settings.seminarLockedClassOptions = ["hidden", "locked"]; + var _data = { "content": { "carouselImages": [], - "description": "" + "description": "", + seminarDelay: Settings.seminarDelayOptions[0], + lockedClass: Settings.seminarLockedClassOptions[0] }, "design": { "itemListLayout": LAYOUTS.itemListLayout[0].name, "itemListBgImage": "" } }; + Settings.init = function () { var success = function (result) { console.info('Init success result:', result); @@ -23,14 +37,19 @@ if (!Settings.data) { Settings.data = angular.copy(_data); } else { - if (!Settings.data.content) - Settings.data.content = {}; + if (!Settings.data.content) { + Settings.data.content = {}; + } + + if (!Settings.data.content.seminarDelay) Settings.data.content.seminarDelay = Settings.seminarDelayOptions[0]; + if (!Settings.data.content.lockedClass) Settings.data.content.lockedClass = Settings.seminarLockedClassOptions[0]; } }, error = function (err) { console.error('Error while getting data', err); }; - DataStore.get(TAG_NAMES.SEMINAR_INFO).then(success, error); + + DataStore.get(TAG_NAMES.SEMINAR_INFO).then(success, error); }; Settings.setAllowShare = function(check){ @@ -46,6 +65,50 @@ } } + Settings.setSeminarSettings = (type, value) => { + if (type === 'seminarDelay') { + Settings.data.content.seminarDelay = value; + } else { + Settings.data.content.lockedClass = value; + } + + let success = (result) => { + console.info('Data saved:', result); + }, + error = (err) => { + console.error('Error while saving data', err); + }; + + DataStore.save(Settings.data, TAG_NAMES.SEMINAR_INFO).then(success, error); + } + + // Settings.getDelaySettings = (callback) => { + // buildfire.appData.get("seminarDelay", (err, result) => { + // if (err) return console.error('Error while getting delay settings', err); + // if (result && result.data && result.data.seminarSettings) { + // console.error("Result", result.data) + // Settings.data.design.seminarDelay = result.data.seminarDelay; + // } + // callback(); + // }); + // } + + // Settings.setDelaySettings = (type, value) => { + // if (type === 'seminarDelay') { + // Settings.data.design.seminarDelay = seminarDelay; + // } else { + + // } + // buildfire.appData.save( + // { seminarDelay }, + // "seminarDelay", + // (err, result) => { + // if (err) return console.error("Error while saving delay settings", err); + // console.log("Delay settings successfully", result); + // } + // ); + // } + Settings.init(); } ]) diff --git a/control/settings/templates/home.html b/control/settings/templates/home.html index f20e803..299fddd 100644 --- a/control/settings/templates/home.html +++ b/control/settings/templates/home.html @@ -1,20 +1,54 @@ - - - -
-
-

- Allow Content Sharing -

-
- - -
+
+
+

+ Allow Content Sharing +

+
+ + +
+
+
+
+
+
+

+ Next Seminar Delay + + + Turning this feature on will require the users to be logged in. + + +

+
+ -
+
+
+
+

+ Locked Seminars Style +

+
+
- \ No newline at end of file +
diff --git a/widget/assets/css/style.css b/widget/assets/css/style.css index 63c56f5..cac469c 100644 --- a/widget/assets/css/style.css +++ b/widget/assets/css/style.css @@ -1036,4 +1036,11 @@ html[buildfire='widget'] .modal { .plugin-slide, .plugin-slide img{ width:100% !important; +} + +.hidden .bookmark-holder, +.hidden .bookmark-icon, +.locked .bookmark-holder, +.locked .bookmark-icon { + display: none !important; } \ No newline at end of file diff --git a/widget/assets/js/shared/stringsConfig.js b/widget/assets/js/shared/stringsConfig.js index 7310c87..549c8f8 100644 --- a/widget/assets/js/shared/stringsConfig.js +++ b/widget/assets/js/shared/stringsConfig.js @@ -189,6 +189,18 @@ const stringsConfig = { maxLength: 50, defaultValue: "Item does not exist!", }, + nextSeminarOpen: { + title: "Next seminar is open", + placeholder: "The next seminar is now open", + maxLength: 160, + defaultValue: "The next seminar is now open", + }, + seminarNotAvailable: { + title: "Seminar not available", + placeholder: "This seminar is not available at this time", + maxLength: 60, + defaultValue: "This seminar is not available at this time", + }, } } }; diff --git a/widget/controllers/widget.bookmark.controller.js b/widget/controllers/widget.bookmark.controller.js index 5719441..e4529da 100644 --- a/widget/controllers/widget.bookmark.controller.js +++ b/widget/controllers/widget.bookmark.controller.js @@ -124,15 +124,81 @@ }; WidgetBookmark.init(); - WidgetBookmark.openDetails = function (itemId) { - ViewStack.push({ - template: 'Item', - params: { - controller: "WidgetItemCtrl as WidgetItem", - itemId: itemId + $scope.shouldLockItem = (rank) => { + if ($rootScope.data && $rootScope.data.content && $rootScope.data.content.seminarDelay && $rootScope.data.content.seminarDelay.value) { + if (rank <= $rootScope.seminarOptions.rank) { + return '' + } else if ((rank === ($rootScope.seminarOptions.rank + 1)) && $rootScope.seminarOptions.nextOpenIn && $rootScope.seminarOptions.nextOpenIn <= Date.now()) { + return '' } - }); + return $rootScope.data.content.lockedClass; + } else return ''; + } + + const seminarDelayHandler = (itemRank, callback) => { + if ( + // If item rank is bigger the current rank and nextOpenIn has not been set, exit + (itemRank > $rootScope.seminarOptions.rank && + !$rootScope.seminarOptions.nextOpenIn) || + // If If item rank is bigger the current rank and the item open time has not been reached, exit + (itemRank > $rootScope.seminarOptions.rank && + Date.now() < $rootScope.seminarOptions.nextOpenIn) + ) { + // set navigate to false to not allow to navigate to the item + return callback(false); + } + + // If the item is the same rank as the current rank + if ($rootScope.seminarOptions.rank === itemRank) { + // if the next item open time have not been initialized, initialize it. + if (!$rootScope.seminarOptions.nextOpenIn) { + $rootScope.seminarOptions.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + } + } + // If item rank is bigger than the current rank by one and it reached it's open time + else if (($rootScope.seminarOptions.rank + 1) === itemRank && Date.now() >= $rootScope.seminarOptions.nextOpenIn) { + // Change the current rank to the item rank + $rootScope.seminarOptions.rank = itemRank; + // Set the time for when the next item will open + $rootScope.seminarOptions.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + } + // Set navigate to true, to allow the user to navigate to the item + callback(true); + } + + WidgetBookmark.openDetails = function (itemId) { + if ($rootScope.data && $rootScope.data.content && $rootScope.data.content.seminarDelay && $rootScope.data.content.seminarDelay.value) { + seminarDelayHandler(itemRank, navigate => { + if (navigate) { + buildfire.analytics.trackAction(itemId); + ViewStack.push({ + template: 'Item', + params: { + controller: "WidgetItemCtrl as WidgetItem", + itemId: itemId + } + }); + } else { + buildfire.dialog.toast({ + message: $rootScope.languages.seminarNotAvailable ? $rootScope.languages.seminarNotAvailable : "This seminar is not available at this time", + type: "danger", + }); + } + }); + } else { + buildfire.analytics.trackAction(itemId); + ViewStack.push({ + template: 'Item', + params: { + controller: "WidgetItemCtrl as WidgetItem", + itemId: itemId + } + }); + } }; + WidgetBookmark.showItemNotes = function () { ViewStack.push({ template: 'Notes', diff --git a/widget/controllers/widget.home.controller.js b/widget/controllers/widget.home.controller.js index cf9dc07..af5cb6b 100644 --- a/widget/controllers/widget.home.controller.js +++ b/widget/controllers/widget.home.controller.js @@ -23,7 +23,8 @@ $rootScope.deeplinkingDone = false;//it makes bug if its not rootscope with cp var searchOptions = { skip: 0, - limit: PAGINATION.itemCount + limit: PAGINATION.itemCount, + recordCount: true }; //Refresh list of items on pulling the tile bar @@ -49,14 +50,101 @@ }); }); - WidgetHome.openDetails = function (itemId) { - ViewStack.push({ - template: 'Item', - params: { - controller: "WidgetItemCtrl as WidgetItem", - itemId: itemId + const seminarDelayHandler = (itemRank, itemIndex, callback) => { + if ( + // If item rank is bigger the current rank and nextOpenIn has not been set, exit + (itemRank > $rootScope.seminarOptions.rank && + !$rootScope.seminarOptions.nextOpenIn) || + // If If item rank is bigger the current rank and the item open time has not been reached, exit + (itemRank > $rootScope.seminarOptions.rank && + Date.now() < $rootScope.seminarOptions.nextOpenIn) + ) { + // set navigate to false to not allow to navigate to the item + return callback(false); } - }); + + // If the item is the same rank as the current rank + if ($rootScope.seminarOptions.rank === itemRank) { + // if the next item open time have not been initialized, initialize it. + if (!$rootScope.seminarOptions.nextOpenIn) { + $rootScope.seminarOptions.nextOpenIn = Date.now() + (WidgetHome.data.content.seminarDelay.value * 60 * 1000); + buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + } + // create a timeout function to unlock the next item if it's time reached. + let openAfter = (Date.now() + ((WidgetHome.data.content.seminarDelay.value) * 60 * 1000)) - Date.now(); + setTimeout(() => { + // Remove next item locked status after the time is reached + let nextItem = document.getElementById(`seminarItem${$rootScope.seminarOptions.rank + 1}`); + if (nextItem) { + nextItem.classList.remove(WidgetHome.data.content.lockedClass); + } + }, openAfter); + + } + // If item rank is bigger than the current rank by one and it reached it's open time + else if (($rootScope.seminarOptions.rank + 1) === itemRank && Date.now() >= $rootScope.seminarOptions.nextOpenIn) { + // Change the current rank to the item rank + $rootScope.seminarOptions.rank = itemRank; + // Set the time for when the next item will open + $rootScope.seminarOptions.nextOpenIn = Date.now() + (WidgetHome.data.content.seminarDelay.value * 60 * 1000); + + // If not last item + if (itemIndex !== ($rootScope.totalItemsCount - 1)) { + // Schedule a notification for the next Item + buildfire.notifications.pushNotification.schedule({ + at: $rootScope.seminarOptions.nextOpenIn, + title: "Push notification", + text: WidgetHome.languages.nextSeminarOpen ? WidgetHome.languages.nextSeminarOpen : 'The next seminar is now open!' + }) + + let openAfter = $rootScope.seminarOptions.nextOpenIn - Date.now(); + buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => { + // Remove next item locked status after the time is reached + setTimeout(() => { + // Remove item locked status after the time is reached + let nextItem = document.getElementById(`seminarItem${$rootScope.seminarOptions.rank + 1}`); + if (nextItem) { + nextItem.classList.remove(WidgetHome.data.content.lockedClass); + $rootScope.seminarOptions.rank++; + buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + } + }, openAfter); + }); + } + } + // Set navigate to true, to allow the user to navigate to the item + callback(true); + } + + WidgetHome.openDetails = function (itemId, itemRank, index) { + if (WidgetHome.data && WidgetHome.data.content && WidgetHome.data.content.seminarDelay && WidgetHome.data.content.seminarDelay.value) { + seminarDelayHandler(itemRank, index, navigate => { + if (navigate) { + buildfire.analytics.trackAction(itemId); + ViewStack.push({ + template: 'Item', + params: { + controller: "WidgetItemCtrl as WidgetItem", + itemId: itemId + } + }); + } else { + buildfire.dialog.toast({ + message: WidgetHome.languages.seminarNotAvailable ? WidgetHome.languages.seminarNotAvailable : "This seminar is not available at this time", + type: "danger", + }); + } + }); + } else { + buildfire.analytics.trackAction(itemId); + ViewStack.push({ + template: 'Item', + params: { + controller: "WidgetItemCtrl as WidgetItem", + itemId: itemId + } + }); + } //buildfire.messaging.sendMessageToControl({ // type: 'OpenItem', @@ -212,11 +300,13 @@ $rootScope.itemListbackgroundImage = WidgetHome.data.design.itemListBgImage; } console.log("==============", WidgetHome.data.design); + $rootScope.data = WidgetHome.data; cb(); } , error = function (err) { Buildfire.spinner.hide(); WidgetHome.data = { design: { itemListLayout: LAYOUTS.itemListLayout[0].name } }; + $rootScope.data = WidgetHome.data console.error('Error while getting data', err); cb(err); }; @@ -327,6 +417,7 @@ WidgetHome.openLogin(); } }; + var onUpdateCallback = function (event) { console.log(event); setTimeout(function () { @@ -338,7 +429,16 @@ WidgetHome.data.design = {}; if (!WidgetHome.data.content) WidgetHome.data.content = {}; - if (event.data.content.sortBy && currentSortOrder != event.data.content.sortBy) { + + if (WidgetHome.data && WidgetHome.data.content && WidgetHome.data.content.seminarDelay && WidgetHome.data.content.seminarDelay.value) { + WidgetHome.init(() => { + searchOptions.skip = 0; + WidgetHome.busy = false; + WidgetHome.items = []; + WidgetHome.seminarItemsInitialFetch=false; + WidgetHome.loadMore(); + }); + } else if (event.data.content.sortBy && currentSortOrder != event.data.content.sortBy) { WidgetHome.data.content.sortBy = event.data.content.sortBy; searchOptions.skip = 0; WidgetHome.busy = false; @@ -351,6 +451,7 @@ } else { $rootScope.itemListbackgroundImage = WidgetHome.data.design.itemListBgImage; } + $rootScope.data = WidgetHome.data; } else if (event && event.tag === TAG_NAMES.SEMINAR_ITEMS) { searchOptions.skip = 0; @@ -395,10 +496,10 @@ if (itemsCount > 0 && itemsCount < PAGINATION.itemCount) { return; } + //If there are 0 items loaded and initial fetch was done, don't try to load again. if (itemsCount === 0 && WidgetHome.seminarItemsInitialFetch) return; - if (WidgetHome.readyToLoadItems) - WidgetHome.getItems(); + if (WidgetHome.readyToLoadItems) WidgetHome.getItems(); }; WidgetHome.getItems = function () { @@ -406,17 +507,19 @@ WidgetHome.readyToLoadItems = false; Buildfire.spinner.show(); var successAll = function (resultAll) { - Buildfire.spinner.hide(); WidgetHome.busy = false; WidgetHome.seminarItemsInitialFetch = true; - WidgetHome.items = WidgetHome.items.length != 0 ? WidgetHome.items.concat(resultAll) : resultAll; + WidgetHome.items = WidgetHome.items.length != 0 ? WidgetHome.items.concat(resultAll.result) : resultAll.result; var released = WidgetHome.items.filter(result => { return !result.data.releaseDate || result.data.releaseDate < Date.now(); }); WidgetHome.released = released; searchOptions.skip = searchOptions.skip + PAGINATION.itemCount; + // Set the total items count globally + $rootScope.totalItemsCount = resultAll.totalRecord; + console.log("----------------------", WidgetHome.items); WidgetHome.setBookmarks(); WidgetHome.readyToLoadItems = true; @@ -435,18 +538,87 @@ if (WidgetHome.data && WidgetHome.data.content && WidgetHome.data.content.sortBy) { searchOptions = WidgetHome.getSearchOptions(WidgetHome.data.content.sortBy); } - DataStore.search(searchOptions, TAG_NAMES.SEMINAR_ITEMS).then(successAll, errorAll); + + if (WidgetHome.data && WidgetHome.data.content && WidgetHome.data.content.seminarDelay && WidgetHome.data.content.seminarDelay.value) { + if (!WidgetHome.currentLoggedInUser) { + WidgetHome.openLogin(() => { + seminarDelayInit(() => { + DataStore.search(searchOptions, TAG_NAMES.SEMINAR_ITEMS).then(successAll, errorAll); + }); + }); + } else { + seminarDelayInit(() => { + DataStore.search(searchOptions, TAG_NAMES.SEMINAR_ITEMS).then(successAll, errorAll); + }); + } + } else { + // Removed saved data if there delay option is turned off + buildfire.userData.save({}, "seminarOptions", false, () => {}); + DataStore.search(searchOptions, TAG_NAMES.SEMINAR_ITEMS).then(successAll, errorAll); + } }; + const seminarDelayInit = (callback) => { + buildfire.userData.get("seminarOptions", (err, result) => { + if (err) { + console.error("Error while retrieving your data", err) + return callback(); + }; + + $rootScope.seminarOptions = result.data; + + if (typeof $rootScope.seminarOptions.rank === 'undefined') { + $rootScope.seminarOptions.rank = 0; + buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + } + + if ($rootScope.seminarOptions.nextOpenIn) { + if ($rootScope.seminarOptions.nextOpenIn <= Date.now()) { + $rootScope.seminarOptions.rank++; + $rootScope.seminarOptions.nextOpenIn = null; + buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + } else { + setTimeout(() => { + // Remove item locked status after the time is reached + let nextItem = document.getElementById(`seminarItem${$rootScope.seminarOptions.rank + 1}`); + if (nextItem) { + nextItem.classList.remove(WidgetHome.data.content.lockedClass); + $rootScope.seminarOptions.rank++; + buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + } + }, $rootScope.seminarOptions.nextOpenIn - Date.now()); + } + } + + callback(); + }); + } + + $scope.shouldLockItem = (rank) => { + if (WidgetHome.data && WidgetHome.data.content && WidgetHome.data.content.seminarDelay && WidgetHome.data.content.seminarDelay.value) { + if (rank <= $rootScope.seminarOptions.rank) { + return '' + } else if ((rank === ($rootScope.seminarOptions.rank + 1)) && $rootScope.seminarOptions.nextOpenIn && $rootScope.seminarOptions.nextOpenIn <= Date.now()) { + return '' + } + return WidgetHome.data.content.lockedClass; + } else return ''; + } WidgetHome.currentLoggedInUser = null; /** * Method to open buildfire auth login pop up and allow user to login using credentials. */ - WidgetHome.openLogin = function () { - buildfire.auth.login({}, function () { - }); + WidgetHome.openLogin = function (callback) { + if (WidgetHome.data && WidgetHome.data.content && WidgetHome.data.content.seminarDelay && WidgetHome.data.content.seminarDelay.value) { + buildfire.auth.login({ allowCancel: false }, () => { + if (callback) callback(); + }); + } else { + buildfire.auth.login({}, function () { + }); + } }; var loginCallback = function () { @@ -465,6 +637,9 @@ var logoutCallback = function () { WidgetHome.currentLoggedInUser = null; + if (WidgetHome.data && WidgetHome.data.content && WidgetHome.data.content.seminarDelay && WidgetHome.data.content.seminarDelay.value) { + WidgetHome.openLogin(() => {}); + } $scope.$apply(); }; diff --git a/widget/controllers/widget.notes.controller.js b/widget/controllers/widget.notes.controller.js index 5f97a8e..d3cc5d8 100644 --- a/widget/controllers/widget.notes.controller.js +++ b/widget/controllers/widget.notes.controller.js @@ -106,6 +106,7 @@ }; WidgetNotes.openDetails = function (itemId, noteId) { + buildfire.analytics.trackAction(itemId); ViewStack.push({ template: 'Item', params: { diff --git a/widget/controllers/widget.search.controller.js b/widget/controllers/widget.search.controller.js index 69eba01..e7ec369 100644 --- a/widget/controllers/widget.search.controller.js +++ b/widget/controllers/widget.search.controller.js @@ -24,9 +24,14 @@ * Method to open buildfire auth login pop up and allow user to login using credentials. */ WidgetSearch.openLogin = function () { - buildfire.auth.login({}, function () { - - }); + if ($rootScope.data && $rootScope.data.content && $rootScope.data.content.seminarDelay && $rootScope.data.content.seminarDelay.value) { + buildfire.auth.login({ allowCancel: false }, () => { + if (callback) callback(); + }); + } else { + buildfire.auth.login({}, function () { + }); + } }; Buildfire.datastore.get("languages", (err, result) => { @@ -59,6 +64,9 @@ buildfire.auth.onLogin(loginCallback); var logoutCallback = function () { + if ($rootScope.data && $rootScope.data.content && $rootScope.data.content.seminarDelay && $rootScope.data.content.seminarDelay.value) { + WidgetSearch.openLogin(() => {}); + } WidgetSearch.currentLoggedInUser = null; $scope.$apply(); }; @@ -215,16 +223,81 @@ }); }; - WidgetSearch.openDetails = function (itemId) { - ViewStack.push({ - template: 'Item', - params: { - controller: "WidgetItemCtrl as WidgetItem", - itemId: itemId + const seminarDelayHandler = (itemRank, callback) => { + if ( + // If item rank is bigger the current rank and nextOpenIn has not been set, exit + (itemRank > $rootScope.seminarOptions.rank && + !$rootScope.seminarOptions.nextOpenIn) || + // If If item rank is bigger the current rank and the item open time has not been reached, exit + (itemRank > $rootScope.seminarOptions.rank && + Date.now() < $rootScope.seminarOptions.nextOpenIn) + ) { + // set navigate to false to not allow to navigate to the item + return callback(false); + } + + // If the item is the same rank as the current rank + if ($rootScope.seminarOptions.rank === itemRank) { + // if the next item open time have not been initialized, initialize it. + if (!$rootScope.seminarOptions.nextOpenIn) { + $rootScope.seminarOptions.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); } - }); + } + // If item rank is bigger than the current rank by one and it reached it's open time + else if (($rootScope.seminarOptions.rank + 1) === itemRank && Date.now() >= $rootScope.seminarOptions.nextOpenIn) { + // Change the current rank to the item rank + $rootScope.seminarOptions.rank = itemRank; + // Set the time for when the next item will open + $rootScope.seminarOptions.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + } + // Set navigate to true, to allow the user to navigate to the item + callback(true); + } + + WidgetSearch.openDetails = function (itemId, itemRank) { + if ($rootScope.data && $rootScope.data.content && $rootScope.data.content.seminarDelay && $rootScope.data.content.seminarDelay.value) { + seminarDelayHandler(itemRank, navigate => { + if (navigate) { + buildfire.analytics.trackAction(itemId); + ViewStack.push({ + template: 'Item', + params: { + controller: "WidgetItemCtrl as WidgetItem", + itemId: itemId + } + }); + } else { + buildfire.dialog.toast({ + message: $rootScope.languages.seminarNotAvailable ? $rootScope.languages.seminarNotAvailable : "This seminar is not available at this time", + type: "danger", + }); + } + }); + } else { + buildfire.analytics.trackAction(itemId); + ViewStack.push({ + template: 'Item', + params: { + controller: "WidgetItemCtrl as WidgetItem", + itemId: itemId + } + }); + } }; + $scope.shouldLockItem = (rank) => { + if ($rootScope.data && $rootScope.data.content && $rootScope.data.content.seminarDelay && $rootScope.data.content.seminarDelay.value) { + if (rank <= $rootScope.seminarOptions.rank) { + return '' + } else if ((rank === ($rootScope.seminarOptions.rank + 1)) && $rootScope.seminarOptions.nextOpenIn && $rootScope.seminarOptions.nextOpenIn <= Date.now()) { + return '' + } + return $rootScope.data.content.lockedClass; + } else return ''; + } + WidgetSearch.addToBookmark = function (itemId, isBookmarked, index, item) { console.log("$$$$$$$$$$$$$$$$$111", item.isBookmarked); Buildfire.spinner.show(); diff --git a/widget/index.html b/widget/index.html index 7ebae77..7ed925d 100755 --- a/widget/index.html +++ b/widget/index.html @@ -13,7 +13,7 @@ - + diff --git a/widget/templates/Bookmarks.html b/widget/templates/Bookmarks.html index 30d37a8..8af5367 100644 --- a/widget/templates/Bookmarks.html +++ b/widget/templates/Bookmarks.html @@ -14,7 +14,7 @@

-
+

-
-
+
+
diff --git a/widget/templates/Item_List_2.html b/widget/templates/Item_List_2.html index c1fd025..3d60654 100644 --- a/widget/templates/Item_List_2.html +++ b/widget/templates/Item_List_2.html @@ -19,8 +19,8 @@ {{WidgetHome.languages.noItems}}

-
-
+
+
diff --git a/widget/templates/Item_List_3.html b/widget/templates/Item_List_3.html index 02be14f..b165b32 100644 --- a/widget/templates/Item_List_3.html +++ b/widget/templates/Item_List_3.html @@ -20,8 +20,8 @@ {{WidgetHome.languages.noItems}}

-
-
+
+
-
+
-
+
{{item.data.title}}

{{item.data.summary}}

{{item.data.publishDate | date}} @@ -46,7 +46,7 @@

{{item.data.title}}
ng-click="WidgetHome.addToBookmark(item,item.isBookmarked, $index)">
-
+
diff --git a/widget/templates/Item_List_5.html b/widget/templates/Item_List_5.html index 02cf584..f706f88 100644 --- a/widget/templates/Item_List_5.html +++ b/widget/templates/Item_List_5.html @@ -20,7 +20,7 @@

+ ng-if="isFetchedAllData" ng-class="shouldLockItem(item.data.rank)" id="{{ 'seminarItem' + item.data.rank }}">
{{item.data.title}}

{{item.data.summary}}

-
+
diff --git a/widget/templates/Search.html b/widget/templates/Search.html index e6410f7..8b709e4 100644 --- a/widget/templates/Search.html +++ b/widget/templates/Search.html @@ -17,8 +17,8 @@

-
-
+
+
From d32cf2a70690d3087b302acdc579f61173c108d1 Mon Sep 17 00:00:00 2001 From: halwan-bot Date: Wed, 28 Jul 2021 04:34:10 +0300 Subject: [PATCH 2/8] Updated events and add validation on item page --- .../controllers/content.home.controller.js | 2 +- .../controllers/content.item.controller.js | 2 +- .../controllers/widget.bookmark.controller.js | 32 ++++---- widget/controllers/widget.home.controller.js | 74 +++++++++---------- widget/controllers/widget.item.controller.js | 74 +++++++++++++++---- widget/controllers/widget.notes.controller.js | 2 +- .../controllers/widget.search.controller.js | 32 ++++---- 7 files changed, 130 insertions(+), 88 deletions(-) diff --git a/control/content/controllers/content.home.controller.js b/control/content/controllers/content.home.controller.js index c550072..a3799bc 100644 --- a/control/content/controllers/content.home.controller.js +++ b/control/content/controllers/content.home.controller.js @@ -81,7 +81,7 @@ if(data) { var item = ContentHome.items[_index]; Deeplink.deleteById(item.id); - buildfire.analytics.unregisterEvent(item.id); + buildfire.analytics.unregisterEvent(`DOCUMENT_${item.id}_OPENED`); DataStore.deleteById(item.id, TAG_NAMES.SEMINAR_ITEMS).then(function (result) { ContentHome.items.splice(_index, 1); searchOptionUserData.filter ={"$or": [{"$json.itemID": {"$eq": item.id}}]}; diff --git a/control/content/controllers/content.item.controller.js b/control/content/controllers/content.item.controller.js index 6924a73..2fe9f95 100644 --- a/control/content/controllers/content.item.controller.js +++ b/control/content/controllers/content.item.controller.js @@ -177,7 +177,7 @@ buildfire.analytics.registerEvent( { title: ContentItem.item.data.title, - key: result.id, + key: `DOCUMENT_${result.id}_OPENED`, description: "Number of times this item has been opened", }, { silentNotification: true } diff --git a/widget/controllers/widget.bookmark.controller.js b/widget/controllers/widget.bookmark.controller.js index e4529da..50e15bc 100644 --- a/widget/controllers/widget.bookmark.controller.js +++ b/widget/controllers/widget.bookmark.controller.js @@ -126,9 +126,9 @@ $scope.shouldLockItem = (rank) => { if ($rootScope.data && $rootScope.data.content && $rootScope.data.content.seminarDelay && $rootScope.data.content.seminarDelay.value) { - if (rank <= $rootScope.seminarOptions.rank) { + if (rank <= $rootScope.seminarLastDocument.rank) { return '' - } else if ((rank === ($rootScope.seminarOptions.rank + 1)) && $rootScope.seminarOptions.nextOpenIn && $rootScope.seminarOptions.nextOpenIn <= Date.now()) { + } else if ((rank === ($rootScope.seminarLastDocument.rank + 1)) && $rootScope.seminarLastDocument.nextOpenIn && $rootScope.seminarLastDocument.nextOpenIn <= Date.now()) { return '' } return $rootScope.data.content.lockedClass; @@ -138,31 +138,31 @@ const seminarDelayHandler = (itemRank, callback) => { if ( // If item rank is bigger the current rank and nextOpenIn has not been set, exit - (itemRank > $rootScope.seminarOptions.rank && - !$rootScope.seminarOptions.nextOpenIn) || + (itemRank > $rootScope.seminarLastDocument.rank && + !$rootScope.seminarLastDocument.nextOpenIn) || // If If item rank is bigger the current rank and the item open time has not been reached, exit - (itemRank > $rootScope.seminarOptions.rank && - Date.now() < $rootScope.seminarOptions.nextOpenIn) + (itemRank > $rootScope.seminarLastDocument.rank && + Date.now() < $rootScope.seminarLastDocument.nextOpenIn) ) { // set navigate to false to not allow to navigate to the item return callback(false); } // If the item is the same rank as the current rank - if ($rootScope.seminarOptions.rank === itemRank) { + if ($rootScope.seminarLastDocument.rank === itemRank) { // if the next item open time have not been initialized, initialize it. - if (!$rootScope.seminarOptions.nextOpenIn) { - $rootScope.seminarOptions.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); - buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + if (!$rootScope.seminarLastDocument.nextOpenIn) { + $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } } // If item rank is bigger than the current rank by one and it reached it's open time - else if (($rootScope.seminarOptions.rank + 1) === itemRank && Date.now() >= $rootScope.seminarOptions.nextOpenIn) { + else if (($rootScope.seminarLastDocument.rank + 1) === itemRank && Date.now() >= $rootScope.seminarLastDocument.nextOpenIn) { // Change the current rank to the item rank - $rootScope.seminarOptions.rank = itemRank; + $rootScope.seminarLastDocument.rank = itemRank; // Set the time for when the next item will open - $rootScope.seminarOptions.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); - buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } // Set navigate to true, to allow the user to navigate to the item callback(true); @@ -172,7 +172,7 @@ if ($rootScope.data && $rootScope.data.content && $rootScope.data.content.seminarDelay && $rootScope.data.content.seminarDelay.value) { seminarDelayHandler(itemRank, navigate => { if (navigate) { - buildfire.analytics.trackAction(itemId); + buildfire.analytics.trackAction(`DOCUMENT_${itemId}_OPENED`); ViewStack.push({ template: 'Item', params: { @@ -188,7 +188,7 @@ } }); } else { - buildfire.analytics.trackAction(itemId); + buildfire.analytics.trackAction(`DOCUMENT_${itemId}_OPENED`); ViewStack.push({ template: 'Item', params: { diff --git a/widget/controllers/widget.home.controller.js b/widget/controllers/widget.home.controller.js index af5cb6b..830e4af 100644 --- a/widget/controllers/widget.home.controller.js +++ b/widget/controllers/widget.home.controller.js @@ -53,28 +53,28 @@ const seminarDelayHandler = (itemRank, itemIndex, callback) => { if ( // If item rank is bigger the current rank and nextOpenIn has not been set, exit - (itemRank > $rootScope.seminarOptions.rank && - !$rootScope.seminarOptions.nextOpenIn) || + (itemRank > $rootScope.seminarLastDocument.rank && + !$rootScope.seminarLastDocument.nextOpenIn) || // If If item rank is bigger the current rank and the item open time has not been reached, exit - (itemRank > $rootScope.seminarOptions.rank && - Date.now() < $rootScope.seminarOptions.nextOpenIn) + (itemRank > $rootScope.seminarLastDocument.rank && + Date.now() < $rootScope.seminarLastDocument.nextOpenIn) ) { // set navigate to false to not allow to navigate to the item return callback(false); } // If the item is the same rank as the current rank - if ($rootScope.seminarOptions.rank === itemRank) { + if ($rootScope.seminarLastDocument.rank === itemRank) { // if the next item open time have not been initialized, initialize it. - if (!$rootScope.seminarOptions.nextOpenIn) { - $rootScope.seminarOptions.nextOpenIn = Date.now() + (WidgetHome.data.content.seminarDelay.value * 60 * 1000); - buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + if (!$rootScope.seminarLastDocument.nextOpenIn) { + $rootScope.seminarLastDocument.nextOpenIn = Date.now() + (WidgetHome.data.content.seminarDelay.value * 60 * 1000); + buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } // create a timeout function to unlock the next item if it's time reached. let openAfter = (Date.now() + ((WidgetHome.data.content.seminarDelay.value) * 60 * 1000)) - Date.now(); setTimeout(() => { // Remove next item locked status after the time is reached - let nextItem = document.getElementById(`seminarItem${$rootScope.seminarOptions.rank + 1}`); + let nextItem = document.getElementById(`seminarItem${$rootScope.seminarLastDocument.rank + 1}`); if (nextItem) { nextItem.classList.remove(WidgetHome.data.content.lockedClass); } @@ -82,31 +82,31 @@ } // If item rank is bigger than the current rank by one and it reached it's open time - else if (($rootScope.seminarOptions.rank + 1) === itemRank && Date.now() >= $rootScope.seminarOptions.nextOpenIn) { + else if (($rootScope.seminarLastDocument.rank + 1) === itemRank && Date.now() >= $rootScope.seminarLastDocument.nextOpenIn) { // Change the current rank to the item rank - $rootScope.seminarOptions.rank = itemRank; + $rootScope.seminarLastDocument.rank = itemRank; // Set the time for when the next item will open - $rootScope.seminarOptions.nextOpenIn = Date.now() + (WidgetHome.data.content.seminarDelay.value * 60 * 1000); + $rootScope.seminarLastDocument.nextOpenIn = Date.now() + (WidgetHome.data.content.seminarDelay.value * 60 * 1000); // If not last item if (itemIndex !== ($rootScope.totalItemsCount - 1)) { // Schedule a notification for the next Item buildfire.notifications.pushNotification.schedule({ - at: $rootScope.seminarOptions.nextOpenIn, + at: $rootScope.seminarLastDocument.nextOpenIn, title: "Push notification", text: WidgetHome.languages.nextSeminarOpen ? WidgetHome.languages.nextSeminarOpen : 'The next seminar is now open!' }) - let openAfter = $rootScope.seminarOptions.nextOpenIn - Date.now(); - buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => { + let openAfter = $rootScope.seminarLastDocument.nextOpenIn - Date.now(); + buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => { // Remove next item locked status after the time is reached setTimeout(() => { // Remove item locked status after the time is reached - let nextItem = document.getElementById(`seminarItem${$rootScope.seminarOptions.rank + 1}`); + let nextItem = document.getElementById(`seminarItem${$rootScope.seminarLastDocument.rank + 1}`); if (nextItem) { nextItem.classList.remove(WidgetHome.data.content.lockedClass); - $rootScope.seminarOptions.rank++; - buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + $rootScope.seminarLastDocument.rank++; + buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } }, openAfter); }); @@ -120,7 +120,7 @@ if (WidgetHome.data && WidgetHome.data.content && WidgetHome.data.content.seminarDelay && WidgetHome.data.content.seminarDelay.value) { seminarDelayHandler(itemRank, index, navigate => { if (navigate) { - buildfire.analytics.trackAction(itemId); + buildfire.analytics.trackAction(`DOCUMENT_${itemId}_OPENED`); ViewStack.push({ template: 'Item', params: { @@ -136,7 +136,7 @@ } }); } else { - buildfire.analytics.trackAction(itemId); + buildfire.analytics.trackAction(`DOCUMENT_${itemId}_OPENED`); ViewStack.push({ template: 'Item', params: { @@ -552,41 +552,39 @@ }); } } else { - // Removed saved data if there delay option is turned off - buildfire.userData.save({}, "seminarOptions", false, () => {}); DataStore.search(searchOptions, TAG_NAMES.SEMINAR_ITEMS).then(successAll, errorAll); } }; const seminarDelayInit = (callback) => { - buildfire.userData.get("seminarOptions", (err, result) => { + buildfire.userData.get("seminarLastDocument", (err, result) => { if (err) { console.error("Error while retrieving your data", err) return callback(); }; - $rootScope.seminarOptions = result.data; + $rootScope.seminarLastDocument = result.data; - if (typeof $rootScope.seminarOptions.rank === 'undefined') { - $rootScope.seminarOptions.rank = 0; - buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + if (typeof $rootScope.seminarLastDocument.rank === 'undefined') { + $rootScope.seminarLastDocument.rank = 0; + buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } - if ($rootScope.seminarOptions.nextOpenIn) { - if ($rootScope.seminarOptions.nextOpenIn <= Date.now()) { - $rootScope.seminarOptions.rank++; - $rootScope.seminarOptions.nextOpenIn = null; - buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + if ($rootScope.seminarLastDocument.nextOpenIn) { + if ($rootScope.seminarLastDocument.nextOpenIn <= Date.now()) { + $rootScope.seminarLastDocument.rank++; + $rootScope.seminarLastDocument.nextOpenIn = null; + buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } else { setTimeout(() => { // Remove item locked status after the time is reached - let nextItem = document.getElementById(`seminarItem${$rootScope.seminarOptions.rank + 1}`); + let nextItem = document.getElementById(`seminarItem${$rootScope.seminarLastDocument.rank + 1}`); if (nextItem) { nextItem.classList.remove(WidgetHome.data.content.lockedClass); - $rootScope.seminarOptions.rank++; - buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + $rootScope.seminarLastDocument.rank++; + buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } - }, $rootScope.seminarOptions.nextOpenIn - Date.now()); + }, $rootScope.seminarLastDocument.nextOpenIn - Date.now()); } } @@ -596,9 +594,9 @@ $scope.shouldLockItem = (rank) => { if (WidgetHome.data && WidgetHome.data.content && WidgetHome.data.content.seminarDelay && WidgetHome.data.content.seminarDelay.value) { - if (rank <= $rootScope.seminarOptions.rank) { + if (rank <= $rootScope.seminarLastDocument.rank) { return '' - } else if ((rank === ($rootScope.seminarOptions.rank + 1)) && $rootScope.seminarOptions.nextOpenIn && $rootScope.seminarOptions.nextOpenIn <= Date.now()) { + } else if ((rank === ($rootScope.seminarLastDocument.rank + 1)) && $rootScope.seminarLastDocument.nextOpenIn && $rootScope.seminarLastDocument.nextOpenIn <= Date.now()) { return '' } return WidgetHome.data.content.lockedClass; diff --git a/widget/controllers/widget.item.controller.js b/widget/controllers/widget.item.controller.js index 194d493..467c4ba 100644 --- a/widget/controllers/widget.item.controller.js +++ b/widget/controllers/widget.item.controller.js @@ -54,6 +54,38 @@ }); } + const seminarDelayHandler = (itemRank, callback) => { + if ( + // If item rank is bigger the current rank and nextOpenIn has not been set, exit + (itemRank > $rootScope.seminarLastDocument.rank && + !$rootScope.seminarLastDocument.nextOpenIn) || + // If If item rank is bigger the current rank and the item open time has not been reached, exit + (itemRank > $rootScope.seminarLastDocument.rank && + Date.now() < $rootScope.seminarLastDocument.nextOpenIn) + ) { + // set navigate to false to not allow to navigate to the item + return callback(false); + } + + // If the item is the same rank as the current rank + if ($rootScope.seminarLastDocument.rank === itemRank) { + // if the next item open time have not been initialized, initialize it. + if (!$rootScope.seminarLastDocument.nextOpenIn) { + $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); + } + } + // If item rank is bigger than the current rank by one and it reached it's open time + else if (($rootScope.seminarLastDocument.rank + 1) === itemRank && Date.now() >= $rootScope.seminarLastDocument.nextOpenIn) { + // Change the current rank to the item rank + $rootScope.seminarLastDocument.rank = itemRank; + // Set the time for when the next item will open + $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); + } + // Set navigate to true, to allow the user to navigate to the item + callback(true); + } //Refresh item details on pulling the tile bar @@ -77,21 +109,33 @@ var getEventDetails = function () { Buildfire.spinner.show(); var success = function (result) { - - Buildfire.spinner.hide(); - WidgetItem.item = result; - //$rootScope.$broadcast("NEW_ITEM_ADDED_UPDATED"); - console.log("========ingeteventdetails", result); - - if (!WidgetItem.item.data.itemListBgImage) { - $rootScope.itemDetailbackgroundImage = ""; - } else { - $rootScope.itemDetailbackgroundImage = WidgetItem.item.data.itemListBgImage; - } - - $timeout(function () { - WidgetItem.forceScroll = true; - }, 0); + seminarDelayHandler(result.data.rank, allow => { + if (!allow) { + buildfire.dialog.toast({ + message: WidgetItem.languages.seminarNotAvailable ? WidgetItem.languages.seminarNotAvailable : "This seminar is not available at this time", + type: "danger", + }); + setTimeout(() => { + window.location.reload(); + }, 2000); + } else { + Buildfire.spinner.hide(); + WidgetItem.item = result; + + //$rootScope.$broadcast("NEW_ITEM_ADDED_UPDATED"); + console.log("========ingeteventdetails", result); + + if (!WidgetItem.item.data.itemListBgImage) { + $rootScope.itemDetailbackgroundImage = ""; + } else { + $rootScope.itemDetailbackgroundImage = WidgetItem.item.data.itemListBgImage; + } + + $timeout(function () { + WidgetItem.forceScroll = true; + }, 0); + } + }); } , error = function (err) { Buildfire.spinner.hide(); diff --git a/widget/controllers/widget.notes.controller.js b/widget/controllers/widget.notes.controller.js index d3cc5d8..8791c03 100644 --- a/widget/controllers/widget.notes.controller.js +++ b/widget/controllers/widget.notes.controller.js @@ -106,7 +106,7 @@ }; WidgetNotes.openDetails = function (itemId, noteId) { - buildfire.analytics.trackAction(itemId); + buildfire.analytics.trackAction(`DOCUMENT_${itemId}_OPENED`); ViewStack.push({ template: 'Item', params: { diff --git a/widget/controllers/widget.search.controller.js b/widget/controllers/widget.search.controller.js index e7ec369..b908efb 100644 --- a/widget/controllers/widget.search.controller.js +++ b/widget/controllers/widget.search.controller.js @@ -226,31 +226,31 @@ const seminarDelayHandler = (itemRank, callback) => { if ( // If item rank is bigger the current rank and nextOpenIn has not been set, exit - (itemRank > $rootScope.seminarOptions.rank && - !$rootScope.seminarOptions.nextOpenIn) || + (itemRank > $rootScope.seminarLastDocument.rank && + !$rootScope.seminarLastDocument.nextOpenIn) || // If If item rank is bigger the current rank and the item open time has not been reached, exit - (itemRank > $rootScope.seminarOptions.rank && - Date.now() < $rootScope.seminarOptions.nextOpenIn) + (itemRank > $rootScope.seminarLastDocument.rank && + Date.now() < $rootScope.seminarLastDocument.nextOpenIn) ) { // set navigate to false to not allow to navigate to the item return callback(false); } // If the item is the same rank as the current rank - if ($rootScope.seminarOptions.rank === itemRank) { + if ($rootScope.seminarLastDocument.rank === itemRank) { // if the next item open time have not been initialized, initialize it. - if (!$rootScope.seminarOptions.nextOpenIn) { - $rootScope.seminarOptions.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); - buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + if (!$rootScope.seminarLastDocument.nextOpenIn) { + $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } } // If item rank is bigger than the current rank by one and it reached it's open time - else if (($rootScope.seminarOptions.rank + 1) === itemRank && Date.now() >= $rootScope.seminarOptions.nextOpenIn) { + else if (($rootScope.seminarLastDocument.rank + 1) === itemRank && Date.now() >= $rootScope.seminarLastDocument.nextOpenIn) { // Change the current rank to the item rank - $rootScope.seminarOptions.rank = itemRank; + $rootScope.seminarLastDocument.rank = itemRank; // Set the time for when the next item will open - $rootScope.seminarOptions.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); - buildfire.userData.save($rootScope.seminarOptions, "seminarOptions", false, () => {}); + $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } // Set navigate to true, to allow the user to navigate to the item callback(true); @@ -260,7 +260,7 @@ if ($rootScope.data && $rootScope.data.content && $rootScope.data.content.seminarDelay && $rootScope.data.content.seminarDelay.value) { seminarDelayHandler(itemRank, navigate => { if (navigate) { - buildfire.analytics.trackAction(itemId); + buildfire.analytics.trackAction(`DOCUMENT_${itemId}_OPENED`); ViewStack.push({ template: 'Item', params: { @@ -276,7 +276,7 @@ } }); } else { - buildfire.analytics.trackAction(itemId); + buildfire.analytics.trackAction(`DOCUMENT_${itemId}_OPENED`); ViewStack.push({ template: 'Item', params: { @@ -289,9 +289,9 @@ $scope.shouldLockItem = (rank) => { if ($rootScope.data && $rootScope.data.content && $rootScope.data.content.seminarDelay && $rootScope.data.content.seminarDelay.value) { - if (rank <= $rootScope.seminarOptions.rank) { + if (rank <= $rootScope.seminarLastDocument.rank) { return '' - } else if ((rank === ($rootScope.seminarOptions.rank + 1)) && $rootScope.seminarOptions.nextOpenIn && $rootScope.seminarOptions.nextOpenIn <= Date.now()) { + } else if ((rank === ($rootScope.seminarLastDocument.rank + 1)) && $rootScope.seminarLastDocument.nextOpenIn && $rootScope.seminarLastDocument.nextOpenIn <= Date.now()) { return '' } return $rootScope.data.content.lockedClass; From 187184044cc40eafde50ad519513f6549b00a9bb Mon Sep 17 00:00:00 2001 From: halwan-bot Date: Fri, 30 Jul 2021 01:16:50 +0300 Subject: [PATCH 3/8] Fixes and enhancements --- .../controllers/content.home.controller.js | 23 ++++-- widget/assets/css/style.css | 5 ++ .../controllers/widget.bookmark.controller.js | 4 +- widget/controllers/widget.home.controller.js | 10 +++ widget/controllers/widget.item.controller.js | 80 +++++-------------- widget/controllers/widget.notes.controller.js | 71 +++++++++++++--- .../controllers/widget.search.controller.js | 2 +- widget/templates/Bookmarks.html | 2 +- widget/templates/Notes.html | 2 +- 9 files changed, 119 insertions(+), 80 deletions(-) diff --git a/control/content/controllers/content.home.controller.js b/control/content/controllers/content.home.controller.js index a3799bc..7f19592 100644 --- a/control/content/controllers/content.home.controller.js +++ b/control/content/controllers/content.home.controller.js @@ -192,10 +192,6 @@ else editor.loadItems(ContentHome.data.content.carouselImages); } - if(typeof ContentHome.data.content.sortBy == "undefined"){ - // ContentHome.data.content.sortBy=SORT.MANUALLY; - ContentHome.sortItemBy(SORT.OLDEST_FIRST) - } ContentHome.itemSortableOptions.disabled = !(ContentHome.data.content.sortBy === SORT.MANUALLY); RankOfLastItem.setRank(ContentHome.data.content.rankOfLastItem || 0); updateMasterItem(ContentHome.data); @@ -224,10 +220,13 @@ return; } + ContentHome.searchOptions.limit = 99999; + ContentHome.busy = true; if (ContentHome.data && ContentHome.data.content.sortBy && !search) { ContentHome.searchOptions = getSearchOptions(ContentHome.data.content.sortBy); } + DataStore.search(ContentHome.searchOptions, TAG_NAMES.SEMINAR_ITEMS).then(function (result) { if (result.length <= SORT._limit) {// to indicate there are more ContentHome.noMore = true; @@ -237,8 +236,22 @@ ContentHome.searchOptions.skip = ContentHome.searchOptions.skip + SORT._limit; ContentHome.noMore = false; } + + ContentHome.items = ContentHome.items ? ContentHome.items.concat(result) : result; - ContentHome.busy = false; + // Make sure Items are sorted + if(typeof ContentHome.data.content.sortBy == "undefined"){ + ContentHome.busy = false; + return ContentHome.sortItemBy(SORT.OLDEST_FIRST) + } else { + // Make sure Items are ranked correctly; + for(let i = 0; i < ContentHome.items.length; i++) { + if (ContentHome.items[i].data.rank !== i) { + ContentHome.items[i].data.rank = i; + DataStore.update(ContentHome.items[i].id, ContentHome.items[i].data, TAG_NAMES.SEMINAR_ITEMS, () => {}); + } + } + } Buildfire.spinner.hide(); }, function (error) { Buildfire.spinner.hide(); diff --git a/widget/assets/css/style.css b/widget/assets/css/style.css index cac469c..cf20d6c 100644 --- a/widget/assets/css/style.css +++ b/widget/assets/css/style.css @@ -1038,6 +1038,11 @@ html[buildfire='widget'] .modal { width:100% !important; } +.hidden, +.locked { + pointer-events: none !important; +} + .hidden .bookmark-holder, .hidden .bookmark-icon, .locked .bookmark-holder, diff --git a/widget/controllers/widget.bookmark.controller.js b/widget/controllers/widget.bookmark.controller.js index 50e15bc..481499c 100644 --- a/widget/controllers/widget.bookmark.controller.js +++ b/widget/controllers/widget.bookmark.controller.js @@ -168,7 +168,7 @@ callback(true); } - WidgetBookmark.openDetails = function (itemId) { + WidgetBookmark.openDetails = function (itemId, itemRank) { if ($rootScope.data && $rootScope.data.content && $rootScope.data.content.seminarDelay && $rootScope.data.content.seminarDelay.value) { seminarDelayHandler(itemRank, navigate => { if (navigate) { @@ -182,7 +182,7 @@ }); } else { buildfire.dialog.toast({ - message: $rootScope.languages.seminarNotAvailable ? $rootScope.languages.seminarNotAvailable : "This seminar is not available at this time", + message: WidgetBookmark.languages.seminarNotAvailable ? WidgetBookmark.languages.seminarNotAvailable : "This seminar is not available at this time", type: "danger", }); } diff --git a/widget/controllers/widget.home.controller.js b/widget/controllers/widget.home.controller.js index 830e4af..6c74d00 100644 --- a/widget/controllers/widget.home.controller.js +++ b/widget/controllers/widget.home.controller.js @@ -27,6 +27,16 @@ recordCount: true }; + // Subscribe to notifications on the device + buildfire.notifications.pushNotification.subscribe( + {}, + (err, subscribed) => { + if (err) return console.error(err); + + console.log("User subscribed to group", subscribed); + } + ); + //Refresh list of items on pulling the tile bar buildfire.datastore.onRefresh(function () { diff --git a/widget/controllers/widget.item.controller.js b/widget/controllers/widget.item.controller.js index 467c4ba..db2aec4 100644 --- a/widget/controllers/widget.item.controller.js +++ b/widget/controllers/widget.item.controller.js @@ -54,39 +54,6 @@ }); } - const seminarDelayHandler = (itemRank, callback) => { - if ( - // If item rank is bigger the current rank and nextOpenIn has not been set, exit - (itemRank > $rootScope.seminarLastDocument.rank && - !$rootScope.seminarLastDocument.nextOpenIn) || - // If If item rank is bigger the current rank and the item open time has not been reached, exit - (itemRank > $rootScope.seminarLastDocument.rank && - Date.now() < $rootScope.seminarLastDocument.nextOpenIn) - ) { - // set navigate to false to not allow to navigate to the item - return callback(false); - } - - // If the item is the same rank as the current rank - if ($rootScope.seminarLastDocument.rank === itemRank) { - // if the next item open time have not been initialized, initialize it. - if (!$rootScope.seminarLastDocument.nextOpenIn) { - $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); - buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); - } - } - // If item rank is bigger than the current rank by one and it reached it's open time - else if (($rootScope.seminarLastDocument.rank + 1) === itemRank && Date.now() >= $rootScope.seminarLastDocument.nextOpenIn) { - // Change the current rank to the item rank - $rootScope.seminarLastDocument.rank = itemRank; - // Set the time for when the next item will open - $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); - buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); - } - // Set navigate to true, to allow the user to navigate to the item - callback(true); - } - //Refresh item details on pulling the tile bar buildfire.datastore.onRefresh(function () { @@ -109,33 +76,21 @@ var getEventDetails = function () { Buildfire.spinner.show(); var success = function (result) { - seminarDelayHandler(result.data.rank, allow => { - if (!allow) { - buildfire.dialog.toast({ - message: WidgetItem.languages.seminarNotAvailable ? WidgetItem.languages.seminarNotAvailable : "This seminar is not available at this time", - type: "danger", - }); - setTimeout(() => { - window.location.reload(); - }, 2000); - } else { - Buildfire.spinner.hide(); - WidgetItem.item = result; - - //$rootScope.$broadcast("NEW_ITEM_ADDED_UPDATED"); - console.log("========ingeteventdetails", result); - - if (!WidgetItem.item.data.itemListBgImage) { - $rootScope.itemDetailbackgroundImage = ""; - } else { - $rootScope.itemDetailbackgroundImage = WidgetItem.item.data.itemListBgImage; - } - - $timeout(function () { - WidgetItem.forceScroll = true; - }, 0); - } - }); + Buildfire.spinner.hide(); + WidgetItem.item = result; + + //$rootScope.$broadcast("NEW_ITEM_ADDED_UPDATED"); + console.log("========ingeteventdetails", result); + + if (!WidgetItem.item.data.itemListBgImage) { + $rootScope.itemDetailbackgroundImage = ""; + } else { + $rootScope.itemDetailbackgroundImage = WidgetItem.item.data.itemListBgImage; + } + + $timeout(function () { + WidgetItem.forceScroll = true; + }, 0); } , error = function (err) { Buildfire.spinner.hide(); @@ -296,13 +251,16 @@ WidgetItem.addNoteToItem = function () { WidgetItem.inInsertNote = true; Buildfire.spinner.show(); + WidgetItem.itemNote = { noteTitle: WidgetItem.Note.noteTitle, noteDescription: WidgetItem.Note.noteDescription, itemID: WidgetItem.item.id, itemTitle: WidgetItem.item.data.title, - dateAdded: new Date() + dateAdded: new Date(), + itemRank: WidgetItem.item.data.rank }; + var successItem = function (result) { Buildfire.spinner.hide(); console.log("Inserted Item Note", result); diff --git a/widget/controllers/widget.notes.controller.js b/widget/controllers/widget.notes.controller.js index 8791c03..fbf8c48 100644 --- a/widget/controllers/widget.notes.controller.js +++ b/widget/controllers/widget.notes.controller.js @@ -105,16 +105,69 @@ }); }; - WidgetNotes.openDetails = function (itemId, noteId) { - buildfire.analytics.trackAction(`DOCUMENT_${itemId}_OPENED`); - ViewStack.push({ - template: 'Item', - params: { - controller: "WidgetItemCtrl as WidgetItem", - itemId: itemId, - noteId: noteId + const seminarDelayHandler = (itemRank, callback) => { + if ( + // If item rank is bigger the current rank and nextOpenIn has not been set, exit + (itemRank > $rootScope.seminarLastDocument.rank && + !$rootScope.seminarLastDocument.nextOpenIn) || + // If If item rank is bigger the current rank and the item open time has not been reached, exit + (itemRank > $rootScope.seminarLastDocument.rank && + Date.now() < $rootScope.seminarLastDocument.nextOpenIn) + ) { + // set navigate to false to not allow to navigate to the item + return callback(false); + } + + // If the item is the same rank as the current rank + if ($rootScope.seminarLastDocument.rank === itemRank) { + // if the next item open time have not been initialized, initialize it. + if (!$rootScope.seminarLastDocument.nextOpenIn) { + $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } - }); + } + // If item rank is bigger than the current rank by one and it reached it's open time + else if (($rootScope.seminarLastDocument.rank + 1) === itemRank && Date.now() >= $rootScope.seminarLastDocument.nextOpenIn) { + // Change the current rank to the item rank + $rootScope.seminarLastDocument.rank = itemRank; + // Set the time for when the next item will open + $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); + } + // Set navigate to true, to allow the user to navigate to the item + callback(true); + } + + WidgetNotes.openDetails = function (itemId, noteId, itemRank) { + if ($rootScope.data && $rootScope.data.content && $rootScope.data.content.seminarDelay && $rootScope.data.content.seminarDelay.value) { + seminarDelayHandler(itemRank, navigate => { + if (navigate) { + buildfire.analytics.trackAction(`DOCUMENT_${itemId}_OPENED`); + ViewStack.push({ + template: 'Item', + params: { + controller: "WidgetItemCtrl as WidgetItem", + itemId: itemId + } + }); + } else { + buildfire.dialog.toast({ + message: WidgetNotes.languages.seminarNotAvailable ? WidgetNotes.languages.seminarNotAvailable : "This seminar is not available at this time", + type: "danger", + }); + } + }); + } else { + buildfire.analytics.trackAction(`DOCUMENT_${itemId}_OPENED`); + ViewStack.push({ + template: 'Item', + params: { + controller: "WidgetItemCtrl as WidgetItem", + itemId: itemId, + noteId: noteId + } + }); + } }; WidgetNotes.deleteNote = function (noteId, index) { diff --git a/widget/controllers/widget.search.controller.js b/widget/controllers/widget.search.controller.js index b908efb..cce29f4 100644 --- a/widget/controllers/widget.search.controller.js +++ b/widget/controllers/widget.search.controller.js @@ -270,7 +270,7 @@ }); } else { buildfire.dialog.toast({ - message: $rootScope.languages.seminarNotAvailable ? $rootScope.languages.seminarNotAvailable : "This seminar is not available at this time", + message: WidgetSearch.languages.seminarNotAvailable ? WidgetSearch.languages.seminarNotAvailable : "This seminar is not available at this time", type: "danger", }); } diff --git a/widget/templates/Bookmarks.html b/widget/templates/Bookmarks.html index 8af5367..255b397 100644 --- a/widget/templates/Bookmarks.html +++ b/widget/templates/Bookmarks.html @@ -14,7 +14,7 @@

-
+
+ ng-click="WidgetNotes.openDetails(note.data.itemID, note.id, note.data.itemRank)">

{{note.data.itemTitle}}

From 20d7e56261962f4b79113df888ac37c3f33accb8 Mon Sep 17 00:00:00 2001 From: halwan-bot Date: Mon, 16 Aug 2021 03:15:47 +0300 Subject: [PATCH 4/8] Add locked design and counter --- .../controllers/content.home.controller.js | 7 +- plugin.json | 2 +- widget/assets/css/style.css | 77 ++++++++++- .../controllers/widget.bookmark.controller.js | 16 +-- widget/controllers/widget.home.controller.js | 123 +++++++++++++----- widget/controllers/widget.item.controller.js | 4 - widget/controllers/widget.notes.controller.js | 14 +- .../controllers/widget.search.controller.js | 16 +-- widget/templates/Item_List_1.html | 26 +++- widget/templates/Item_List_2.html | 26 +++- widget/templates/Item_List_3.html | 27 +++- widget/templates/Item_List_4.html | 22 +++- widget/templates/Item_List_5.html | 27 ++-- 13 files changed, 296 insertions(+), 91 deletions(-) diff --git a/control/content/controllers/content.home.controller.js b/control/content/controllers/content.home.controller.js index 7f19592..346bdc6 100644 --- a/control/content/controllers/content.home.controller.js +++ b/control/content/controllers/content.home.controller.js @@ -220,13 +220,14 @@ return; } - ContentHome.searchOptions.limit = 99999; + // Make sure to get all the items to be able to rank them + ContentHome.searchOptions.limit = 999999; ContentHome.busy = true; if (ContentHome.data && ContentHome.data.content.sortBy && !search) { ContentHome.searchOptions = getSearchOptions(ContentHome.data.content.sortBy); } - + DataStore.search(ContentHome.searchOptions, TAG_NAMES.SEMINAR_ITEMS).then(function (result) { if (result.length <= SORT._limit) {// to indicate there are more ContentHome.noMore = true; @@ -244,7 +245,7 @@ ContentHome.busy = false; return ContentHome.sortItemBy(SORT.OLDEST_FIRST) } else { - // Make sure Items are ranked correctly; + // Make sure Items are sorted (ranked) correctly, since the items are ranked only on manual for(let i = 0; i < ContentHome.items.length; i++) { if (ContentHome.items[i].data.rank !== i) { ContentHome.items[i].data.rank = i; diff --git a/plugin.json b/plugin.json index 9467149..1e1a7fd 100755 --- a/plugin.json +++ b/plugin.json @@ -1,6 +1,6 @@ { "author":"BuildFire" -,"pluginName":"Seminar and Lecture Notes" +,"pluginName":"Seminar and Lecture Notes [dev Hamza]" ,"pluginDescription":"This feature allows your students to create, save, and share notes on your class, seminar, lecture, or sermon. You can even embed images and videos and include links to PDFs, webpages, and other resources. Settings can allow content to be time released by date. Related Topics: Seminar Notes, Bible, Blog." ,"supportEmail":"support@buildfire.com" , "supportSite":"http://learn.appdocumentation.com/plugin-tutorials/seminar-and-lecture-notes-plugin-tutorial" diff --git a/widget/assets/css/style.css b/widget/assets/css/style.css index cf20d6c..99adc4f 100644 --- a/widget/assets/css/style.css +++ b/widget/assets/css/style.css @@ -282,7 +282,7 @@ h5 { left: 0; padding: .5rem; display: flex; - align-items: center; + align-items: flex-start; width: 100%; z-index: 3; pointer-events: none; @@ -1035,7 +1035,11 @@ html[buildfire='widget'] .modal { } .plugin-slide, .plugin-slide img{ - width:100% !important; + width: 100% !important; +} + +.image-overlay { + display: none; } .hidden, @@ -1048,4 +1052,73 @@ html[buildfire='widget'] .modal { .locked .bookmark-holder, .locked .bookmark-icon { display: none !important; +} + +.list-media-holder img { + object-fit: cover; + width: 100%; + height: 100%; +} + +.locked .list-media-holder { + position: relative; + z-index: 10; +} + +.locked .list-media-holder .image-overlay, +.locked .blackLayer .image-overlay { + display: block !important; + height: 100%; + position: absolute; + text-align: center; + top: 0; + left: 0; + background-color: rgba(0, 0, 0, .5); + width: 100%; +} + +.locked .list-media-holder .image-overlay > div, +.locked .blackLayer .image-overlay > div { + height: 100%; + display: flex; + justify-content: center; + align-items: center; +} + +.locked .list-media-holder .image-overlay > div > i { + color: white !important; + font-size: 18px !important; +} + +.locked .blackLayer .image-overlay > div > i { + color: white !important; + font-size: 24px !important; +} + +.published-at { + display: block; +} + +.available-in { + display: none; +} + +.locked .published-at { + display: none !important; +} + +.locked .available-in { + display: block !important; +} + +.layout4 .locked .available-in { + position: absolute; + top: 0; + left: 0; + width: 100%; + color: #fff; + z-index: 7; + padding: .75rem; + text-align: left; + font-size: 15px; } \ No newline at end of file diff --git a/widget/controllers/widget.bookmark.controller.js b/widget/controllers/widget.bookmark.controller.js index 481499c..6f40779 100644 --- a/widget/controllers/widget.bookmark.controller.js +++ b/widget/controllers/widget.bookmark.controller.js @@ -128,7 +128,7 @@ if ($rootScope.data && $rootScope.data.content && $rootScope.data.content.seminarDelay && $rootScope.data.content.seminarDelay.value) { if (rank <= $rootScope.seminarLastDocument.rank) { return '' - } else if ((rank === ($rootScope.seminarLastDocument.rank + 1)) && $rootScope.seminarLastDocument.nextOpenIn && $rootScope.seminarLastDocument.nextOpenIn <= Date.now()) { + } else if ((rank === ($rootScope.seminarLastDocument.rank + 1)) && $rootScope.seminarLastDocument.nextAvailableIn && $rootScope.seminarLastDocument.nextAvailableIn <= Date.now()) { return '' } return $rootScope.data.content.lockedClass; @@ -137,12 +137,12 @@ const seminarDelayHandler = (itemRank, callback) => { if ( - // If item rank is bigger the current rank and nextOpenIn has not been set, exit + // If item rank is bigger the current rank and nextAvailableIn has not been set, exit (itemRank > $rootScope.seminarLastDocument.rank && - !$rootScope.seminarLastDocument.nextOpenIn) || + !$rootScope.seminarLastDocument.nextAvailableIn) || // If If item rank is bigger the current rank and the item open time has not been reached, exit (itemRank > $rootScope.seminarLastDocument.rank && - Date.now() < $rootScope.seminarLastDocument.nextOpenIn) + Date.now() < $rootScope.seminarLastDocument.nextAvailableIn) ) { // set navigate to false to not allow to navigate to the item return callback(false); @@ -151,17 +151,17 @@ // If the item is the same rank as the current rank if ($rootScope.seminarLastDocument.rank === itemRank) { // if the next item open time have not been initialized, initialize it. - if (!$rootScope.seminarLastDocument.nextOpenIn) { - $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + if (!$rootScope.seminarLastDocument.nextAvailableIn) { + $rootScope.seminarLastDocument.nextAvailableIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } } // If item rank is bigger than the current rank by one and it reached it's open time - else if (($rootScope.seminarLastDocument.rank + 1) === itemRank && Date.now() >= $rootScope.seminarLastDocument.nextOpenIn) { + else if (($rootScope.seminarLastDocument.rank + 1) === itemRank && Date.now() >= $rootScope.seminarLastDocument.nextAvailableIn) { // Change the current rank to the item rank $rootScope.seminarLastDocument.rank = itemRank; // Set the time for when the next item will open - $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + $rootScope.seminarLastDocument.nextAvailableIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } // Set navigate to true, to allow the user to navigate to the item diff --git a/widget/controllers/widget.home.controller.js b/widget/controllers/widget.home.controller.js index 6c74d00..eae0800 100644 --- a/widget/controllers/widget.home.controller.js +++ b/widget/controllers/widget.home.controller.js @@ -6,6 +6,7 @@ function ($scope, TAG_NAMES, LAYOUTS, DataStore, PAGINATION, Buildfire, Location, $rootScope, ViewStack, $sce, UserData, TempPublicDataCopy, SORT, $modal, $timeout) { var WidgetHome = this; var currentListLayout, currentSortOrder = null; + let nextSeminarTimout; $rootScope.deviceHeight = window.innerHeight; $rootScope.deviceWidth = window.innerWidth || 320; @@ -62,12 +63,12 @@ const seminarDelayHandler = (itemRank, itemIndex, callback) => { if ( - // If item rank is bigger the current rank and nextOpenIn has not been set, exit + // If item rank is bigger the current rank and nextAvailableIn has not been set, exit (itemRank > $rootScope.seminarLastDocument.rank && - !$rootScope.seminarLastDocument.nextOpenIn) || + !$rootScope.seminarLastDocument.nextAvailableIn) || // If If item rank is bigger the current rank and the item open time has not been reached, exit (itemRank > $rootScope.seminarLastDocument.rank && - Date.now() < $rootScope.seminarLastDocument.nextOpenIn) + Date.now() < $rootScope.seminarLastDocument.nextAvailableIn) ) { // set navigate to false to not allow to navigate to the item return callback(false); @@ -76,13 +77,16 @@ // If the item is the same rank as the current rank if ($rootScope.seminarLastDocument.rank === itemRank) { // if the next item open time have not been initialized, initialize it. - if (!$rootScope.seminarLastDocument.nextOpenIn) { - $rootScope.seminarLastDocument.nextOpenIn = Date.now() + (WidgetHome.data.content.seminarDelay.value * 60 * 1000); + if (!$rootScope.seminarLastDocument.nextAvailableIn) { + $rootScope.seminarLastDocument.nextAvailableIn = Date.now() + (WidgetHome.data.content.seminarDelay.value * 60 * 1000); buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } // create a timeout function to unlock the next item if it's time reached. let openAfter = (Date.now() + ((WidgetHome.data.content.seminarDelay.value) * 60 * 1000)) - Date.now(); - setTimeout(() => { + // Show countdown timer + countdown(); + clearTimeout(nextSeminarTimout); + nextSeminarTimout = setTimeout(() => { // Remove next item locked status after the time is reached let nextItem = document.getElementById(`seminarItem${$rootScope.seminarLastDocument.rank + 1}`); if (nextItem) { @@ -92,30 +96,34 @@ } // If item rank is bigger than the current rank by one and it reached it's open time - else if (($rootScope.seminarLastDocument.rank + 1) === itemRank && Date.now() >= $rootScope.seminarLastDocument.nextOpenIn) { + else if (($rootScope.seminarLastDocument.rank + 1) === itemRank && Date.now() >= $rootScope.seminarLastDocument.nextAvailableIn) { // Change the current rank to the item rank $rootScope.seminarLastDocument.rank = itemRank; // Set the time for when the next item will open - $rootScope.seminarLastDocument.nextOpenIn = Date.now() + (WidgetHome.data.content.seminarDelay.value * 60 * 1000); + $rootScope.seminarLastDocument.nextAvailableIn = Date.now() + (WidgetHome.data.content.seminarDelay.value * 60 * 1000); // If not last item if (itemIndex !== ($rootScope.totalItemsCount - 1)) { // Schedule a notification for the next Item buildfire.notifications.pushNotification.schedule({ - at: $rootScope.seminarLastDocument.nextOpenIn, + at: $rootScope.seminarLastDocument.nextAvailableIn, title: "Push notification", text: WidgetHome.languages.nextSeminarOpen ? WidgetHome.languages.nextSeminarOpen : 'The next seminar is now open!' }) - let openAfter = $rootScope.seminarLastDocument.nextOpenIn - Date.now(); + let openAfter = $rootScope.seminarLastDocument.nextAvailableIn - Date.now(); buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => { + // Show countdown timer + countdown(); // Remove next item locked status after the time is reached - setTimeout(() => { + clearTimeout(nextSeminarTimout) + nextSeminarTimout = setTimeout(() => { // Remove item locked status after the time is reached let nextItem = document.getElementById(`seminarItem${$rootScope.seminarLastDocument.rank + 1}`); if (nextItem) { nextItem.classList.remove(WidgetHome.data.content.lockedClass); $rootScope.seminarLastDocument.rank++; + $rootScope.seminarLastDocument.nextAvailableIn = null; buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } }, openAfter); @@ -428,11 +436,12 @@ } }; + var updateTimeout; var onUpdateCallback = function (event) { - console.log(event); + if (updateTimeout) clearTimeout(updateTimeout); + setTimeout(function () { - if (!$scope.$$phase) - $scope.$digest(); + if (!$scope.$$phase) $scope.$digest(); if (event && event.tag === TAG_NAMES.SEMINAR_INFO) { WidgetHome.data = event.data; if (!WidgetHome.data.design) @@ -441,20 +450,16 @@ WidgetHome.data.content = {}; if (WidgetHome.data && WidgetHome.data.content && WidgetHome.data.content.seminarDelay && WidgetHome.data.content.seminarDelay.value) { - WidgetHome.init(() => { - searchOptions.skip = 0; - WidgetHome.busy = false; - WidgetHome.items = []; - WidgetHome.seminarItemsInitialFetch=false; - WidgetHome.loadMore(); - }); + searchOptions.skip = 0; + WidgetHome.busy = false; + WidgetHome.items = []; + WidgetHome.seminarItemsInitialFetch=false; } else if (event.data.content.sortBy && currentSortOrder != event.data.content.sortBy) { WidgetHome.data.content.sortBy = event.data.content.sortBy; searchOptions.skip = 0; WidgetHome.busy = false; WidgetHome.items = []; WidgetHome.seminarItemsInitialFetch=false; - WidgetHome.loadMore(); } if (!WidgetHome.data.design.itemListBgImage) { $rootScope.itemListbackgroundImage = ""; @@ -468,7 +473,6 @@ WidgetHome.busy = false; WidgetHome.items = []; WidgetHome.seminarItemsInitialFetch=false; - WidgetHome.loadMore(); } if (!WidgetHome.data.design.itemListLayout) { @@ -485,11 +489,19 @@ console.log("==========2") } } + currentListLayout = WidgetHome.data.design.itemListLayout; - if (!$scope.$$phase) - $scope.$digest(); - if (!$rootScope.$$phase) - $rootScope.$digest(); + + updateTimeout = setTimeout(() => { + if (WidgetHome.data && WidgetHome.data.content && WidgetHome.data.content.seminarDelay && WidgetHome.data.content.seminarDelay.value) { + WidgetHome.init(() => { WidgetHome.loadMore() }); + } else { + WidgetHome.loadMore(); + } + }, 500); + + if (!$scope.$$phase) $scope.$digest(); + if (!$rootScope.$$phase) $rootScope.$digest(); }, 0); }; DataStore.onUpdate().then(null, null, onUpdateCallback); @@ -539,6 +551,8 @@ } else { WidgetHome.openLogin(); } + if (!$scope.$$phase) $scope.$digest(); + if (!$rootScope.$$phase) $rootScope.$digest(); }, errorAll = function (error) { Buildfire.spinner.hide(); @@ -579,22 +593,27 @@ $rootScope.seminarLastDocument.rank = 0; buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } - - if ($rootScope.seminarLastDocument.nextOpenIn) { - if ($rootScope.seminarLastDocument.nextOpenIn <= Date.now()) { + + if ($rootScope.seminarLastDocument.nextAvailableIn) { + if ($rootScope.seminarLastDocument.nextAvailableIn <= Date.now()) { $rootScope.seminarLastDocument.rank++; - $rootScope.seminarLastDocument.nextOpenIn = null; + $rootScope.seminarLastDocument.nextAvailableIn = null; buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } else { - setTimeout(() => { + let openAfter = $rootScope.seminarLastDocument.nextAvailableIn - Date.now(); + // Show countdown timer + countdown(); + clearTimeout(nextSeminarTimout); + nextSeminarTimout = setTimeout(() => { // Remove item locked status after the time is reached let nextItem = document.getElementById(`seminarItem${$rootScope.seminarLastDocument.rank + 1}`); if (nextItem) { nextItem.classList.remove(WidgetHome.data.content.lockedClass); $rootScope.seminarLastDocument.rank++; + $rootScope.seminarLastDocument.nextAvailableIn = null; buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } - }, $rootScope.seminarLastDocument.nextOpenIn - Date.now()); + }, openAfter); } } @@ -606,7 +625,7 @@ if (WidgetHome.data && WidgetHome.data.content && WidgetHome.data.content.seminarDelay && WidgetHome.data.content.seminarDelay.value) { if (rank <= $rootScope.seminarLastDocument.rank) { return '' - } else if ((rank === ($rootScope.seminarLastDocument.rank + 1)) && $rootScope.seminarLastDocument.nextOpenIn && $rootScope.seminarLastDocument.nextOpenIn <= Date.now()) { + } else if ((rank === ($rootScope.seminarLastDocument.rank + 1)) && $rootScope.seminarLastDocument.nextAvailableIn && $rootScope.seminarLastDocument.nextAvailableIn <= Date.now()) { return '' } return WidgetHome.data.content.lockedClass; @@ -791,10 +810,42 @@ searchOptions.skip = 0; WidgetHome.busy = false; WidgetHome.loadMore(); - if (!$scope.$$phase) - $scope.$digest(); + if (!$scope.$$phase) $scope.$digest(); }); } }); + + let countdownInterval; + const countdown = () => { + clearInterval(countdownInterval); + countdownInterval = setInterval(() => { + let endDate = $rootScope.seminarLastDocument.nextAvailableIn - Date.now(); + + if (endDate >= 0) { + let days = Math.floor(endDate / (1000 * 60 * 60 * 24)); + let hours = Math.floor( + (endDate % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60) + ); + let mins = Math.floor( + (endDate % (1000 * 60 * 60)) / (1000 * 60) + ); + let secs = Math.floor((endDate % (1000 * 60)) / 1000); + + $scope.days = days; + $scope.hours = ("0" + hours).slice(-2); + $scope.minutes = ("0" + mins).slice(-2); + $scope.seconds = ("0" + secs).slice(-2); + $scope.hideCountdown = false; + if (!$scope.$$phase) $scope.$digest(); + } else { + $scope.hours = ""; + $scope.minutes = ""; + $scope.seconds = ""; + clearInterval(countdownInterval); + $scope.hideCountdown = true; + if (!$scope.$$phase) $scope.$digest(); + } + }, 1000); + }; }]) })(window.angular, window.buildfire); diff --git a/widget/controllers/widget.item.controller.js b/widget/controllers/widget.item.controller.js index db2aec4..8dfbd79 100644 --- a/widget/controllers/widget.item.controller.js +++ b/widget/controllers/widget.item.controller.js @@ -323,10 +323,6 @@ } }; - - - - WidgetItem.getNoteList = function () { Buildfire.spinner.show(); searchOptions.filter = { "$or": [{ "$json.itemID": { "$eq": WidgetItem.item.id } }] }; diff --git a/widget/controllers/widget.notes.controller.js b/widget/controllers/widget.notes.controller.js index fbf8c48..9b34208 100644 --- a/widget/controllers/widget.notes.controller.js +++ b/widget/controllers/widget.notes.controller.js @@ -107,12 +107,12 @@ const seminarDelayHandler = (itemRank, callback) => { if ( - // If item rank is bigger the current rank and nextOpenIn has not been set, exit + // If item rank is bigger the current rank and nextAvailableIn has not been set, exit (itemRank > $rootScope.seminarLastDocument.rank && - !$rootScope.seminarLastDocument.nextOpenIn) || + !$rootScope.seminarLastDocument.nextAvailableIn) || // If If item rank is bigger the current rank and the item open time has not been reached, exit (itemRank > $rootScope.seminarLastDocument.rank && - Date.now() < $rootScope.seminarLastDocument.nextOpenIn) + Date.now() < $rootScope.seminarLastDocument.nextAvailableIn) ) { // set navigate to false to not allow to navigate to the item return callback(false); @@ -121,17 +121,17 @@ // If the item is the same rank as the current rank if ($rootScope.seminarLastDocument.rank === itemRank) { // if the next item open time have not been initialized, initialize it. - if (!$rootScope.seminarLastDocument.nextOpenIn) { - $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + if (!$rootScope.seminarLastDocument.nextAvailableIn) { + $rootScope.seminarLastDocument.nextAvailableIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } } // If item rank is bigger than the current rank by one and it reached it's open time - else if (($rootScope.seminarLastDocument.rank + 1) === itemRank && Date.now() >= $rootScope.seminarLastDocument.nextOpenIn) { + else if (($rootScope.seminarLastDocument.rank + 1) === itemRank && Date.now() >= $rootScope.seminarLastDocument.nextAvailableIn) { // Change the current rank to the item rank $rootScope.seminarLastDocument.rank = itemRank; // Set the time for when the next item will open - $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + $rootScope.seminarLastDocument.nextAvailableIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } // Set navigate to true, to allow the user to navigate to the item diff --git a/widget/controllers/widget.search.controller.js b/widget/controllers/widget.search.controller.js index cce29f4..23787d9 100644 --- a/widget/controllers/widget.search.controller.js +++ b/widget/controllers/widget.search.controller.js @@ -225,12 +225,12 @@ const seminarDelayHandler = (itemRank, callback) => { if ( - // If item rank is bigger the current rank and nextOpenIn has not been set, exit + // If item rank is bigger the current rank and nextAvailableIn has not been set, exit (itemRank > $rootScope.seminarLastDocument.rank && - !$rootScope.seminarLastDocument.nextOpenIn) || + !$rootScope.seminarLastDocument.nextAvailableIn) || // If If item rank is bigger the current rank and the item open time has not been reached, exit (itemRank > $rootScope.seminarLastDocument.rank && - Date.now() < $rootScope.seminarLastDocument.nextOpenIn) + Date.now() < $rootScope.seminarLastDocument.nextAvailableIn) ) { // set navigate to false to not allow to navigate to the item return callback(false); @@ -239,17 +239,17 @@ // If the item is the same rank as the current rank if ($rootScope.seminarLastDocument.rank === itemRank) { // if the next item open time have not been initialized, initialize it. - if (!$rootScope.seminarLastDocument.nextOpenIn) { - $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + if (!$rootScope.seminarLastDocument.nextAvailableIn) { + $rootScope.seminarLastDocument.nextAvailableIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } } // If item rank is bigger than the current rank by one and it reached it's open time - else if (($rootScope.seminarLastDocument.rank + 1) === itemRank && Date.now() >= $rootScope.seminarLastDocument.nextOpenIn) { + else if (($rootScope.seminarLastDocument.rank + 1) === itemRank && Date.now() >= $rootScope.seminarLastDocument.nextAvailableIn) { // Change the current rank to the item rank $rootScope.seminarLastDocument.rank = itemRank; // Set the time for when the next item will open - $rootScope.seminarLastDocument.nextOpenIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); + $rootScope.seminarLastDocument.nextAvailableIn = Date.now() + ($rootScope.data.content.seminarDelay.value * 60 * 1000); buildfire.userData.save($rootScope.seminarLastDocument, "seminarLastDocument", false, () => {}); } // Set navigate to true, to allow the user to navigate to the item @@ -291,7 +291,7 @@ if ($rootScope.data && $rootScope.data.content && $rootScope.data.content.seminarDelay && $rootScope.data.content.seminarDelay.value) { if (rank <= $rootScope.seminarLastDocument.rank) { return '' - } else if ((rank === ($rootScope.seminarLastDocument.rank + 1)) && $rootScope.seminarLastDocument.nextOpenIn && $rootScope.seminarLastDocument.nextOpenIn <= Date.now()) { + } else if ((rank === ($rootScope.seminarLastDocument.rank + 1)) && $rootScope.seminarLastDocument.nextAvailableIn && $rootScope.seminarLastDocument.nextAvailableIn <= Date.now()) { return '' } return $rootScope.data.content.lockedClass; diff --git a/widget/templates/Item_List_1.html b/widget/templates/Item_List_1.html index ffe0330..a9e7c36 100644 --- a/widget/templates/Item_List_1.html +++ b/widget/templates/Item_List_1.html @@ -18,15 +18,33 @@

-
- + + +
+
+ +
+
{{item.data.title}}

{{item.data.summary}}

-

- {{item.data.publishDate | date}}

+

+ {{item.data.publishDate | date}} +

+
+
+ Available In:  + + {{days || '00'}}d + {{hours || '00'}}h + {{minutes || '00'}}m + {{seconds || '00'}}s + +
+
- +
+
+ Available In:
+ + {{days || '00'}}d + {{hours || '00'}}h + {{minutes || '00'}}m + {{seconds || '00'}}s + +
+
From 6dbf55841e8576111a57c253e63ab384759a1d75 Mon Sep 17 00:00:00 2001 From: halwan-bot Date: Thu, 19 Aug 2021 19:02:16 +0300 Subject: [PATCH 5/8] locked design enhancements --- plugin.json | 2 +- widget/assets/css/style.css | 40 ++++++++++++++++++++++++++----- widget/images/lock-icon.svg | 1 + widget/templates/Item_List_1.html | 2 +- widget/templates/Item_List_2.html | 2 +- widget/templates/Item_List_3.html | 2 +- widget/templates/Item_List_4.html | 4 ++-- widget/templates/Item_List_5.html | 4 ++-- 8 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 widget/images/lock-icon.svg diff --git a/plugin.json b/plugin.json index 1e1a7fd..9467149 100755 --- a/plugin.json +++ b/plugin.json @@ -1,6 +1,6 @@ { "author":"BuildFire" -,"pluginName":"Seminar and Lecture Notes [dev Hamza]" +,"pluginName":"Seminar and Lecture Notes" ,"pluginDescription":"This feature allows your students to create, save, and share notes on your class, seminar, lecture, or sermon. You can even embed images and videos and include links to PDFs, webpages, and other resources. Settings can allow content to be time released by date. Related Topics: Seminar Notes, Bible, Blog." ,"supportEmail":"support@buildfire.com" , "supportSite":"http://learn.appdocumentation.com/plugin-tutorials/seminar-and-lecture-notes-plugin-tutorial" diff --git a/widget/assets/css/style.css b/widget/assets/css/style.css index 99adc4f..c4b373f 100644 --- a/widget/assets/css/style.css +++ b/widget/assets/css/style.css @@ -1085,14 +1085,42 @@ html[buildfire='widget'] .modal { align-items: center; } -.locked .list-media-holder .image-overlay > div > i { - color: white !important; - font-size: 18px !important; +.locked .list-media-holder .image-overlay > div > img { + filter: invert(0.9); + width: 25px !important; + height: auto; +} + +.locked .blackLayer .image-overlay > div > img { + filter: invert(0.9); + width: 42px !important; + height: auto; +} +.locked div.copy-holder.ellipsis > h5, +.locked div.list-item-copy.ellipsis > div > h5, +.locked p.ellipsis.margin-zero.bodyTextTheme { + color: #ACACAC !important; +} +/* #seminarItem1 > */ +.layout4 .locked div.countdown.available-in > div.timer span, +.layout4 .locked div.countdown.available-in > div > b span, +.layout5 .locked div.countdown.available-in > div.timer span, +.layout5 .locked div.countdown.available-in > div > b span { + color: #ffffff !important; } -.locked .blackLayer .image-overlay > div > i { - color: white !important; - font-size: 24px !important; +.layout4 .locked div.countdown.available-in > div.timer, +.layout5 .locked div.countdown.available-in > div.timer { + text-align: left !important; +} + +.layout4 .locked div.item-text > *, +.layout5 .locked div.item-text > * { + color: #ACACAC !important; +} + +.locked div.copy-holder.ellipsis > div.countdown.available-in { + color: inherit; } .published-at { diff --git a/widget/images/lock-icon.svg b/widget/images/lock-icon.svg new file mode 100644 index 0000000..1a38f2f --- /dev/null +++ b/widget/images/lock-icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/widget/templates/Item_List_1.html b/widget/templates/Item_List_1.html index a9e7c36..ddca483 100644 --- a/widget/templates/Item_List_1.html +++ b/widget/templates/Item_List_1.html @@ -24,7 +24,7 @@
- +
diff --git a/widget/templates/Item_List_2.html b/widget/templates/Item_List_2.html index 110a6b8..ab8a498 100644 --- a/widget/templates/Item_List_2.html +++ b/widget/templates/Item_List_2.html @@ -27,7 +27,7 @@
- +
diff --git a/widget/templates/Item_List_3.html b/widget/templates/Item_List_3.html index 33454c9..429f624 100644 --- a/widget/templates/Item_List_3.html +++ b/widget/templates/Item_List_3.html @@ -28,7 +28,7 @@
- +
diff --git a/widget/templates/Item_List_4.html b/widget/templates/Item_List_4.html index 716bee2..dd176b4 100644 --- a/widget/templates/Item_List_4.html +++ b/widget/templates/Item_List_4.html @@ -26,7 +26,7 @@
- +
@@ -37,7 +37,7 @@
- Available In:
+ Available In: {{days || '00'}}d {{hours || '00'}}h diff --git a/widget/templates/Item_List_5.html b/widget/templates/Item_List_5.html index 074cd31..a4ee168 100644 --- a/widget/templates/Item_List_5.html +++ b/widget/templates/Item_List_5.html @@ -28,7 +28,7 @@
- +
@@ -37,7 +37,7 @@ {{item.data.publishDate | date}} 

- Available In:
+ Available In: {{days || '00'}}d {{hours || '00'}}h From 953f4d0e51392705a690bf4ce2689cc8f4f05099 Mon Sep 17 00:00:00 2001 From: halwan-bot Date: Sat, 21 Aug 2021 02:21:39 +0300 Subject: [PATCH 6/8] Resolved Problems --- .../controllers/content.home.controller.js | 22 +++++++++---------- control/content/enums.js | 4 ++-- widget/controllers/widget.home.controller.js | 8 ++++--- widget/enums.js | 2 +- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/control/content/controllers/content.home.controller.js b/control/content/controllers/content.home.controller.js index 346bdc6..f9f875f 100644 --- a/control/content/controllers/content.home.controller.js +++ b/control/content/controllers/content.home.controller.js @@ -22,7 +22,7 @@ ContentHome.searchOptions = { filter: {"$json.title": {"$regex": '/*'}}, skip: SORT._skip, - limit: SORT._limit + 1 // the plus one is to check if there are any more + limit: SORT._limit // the plus one is to check if there are any more }; /** @@ -220,32 +220,30 @@ return; } - // Make sure to get all the items to be able to rank them - ContentHome.searchOptions.limit = 999999; - ContentHome.busy = true; if (ContentHome.data && ContentHome.data.content.sortBy && !search) { ContentHome.searchOptions = getSearchOptions(ContentHome.data.content.sortBy); } + + DataStore.search(ContentHome.searchOptions, TAG_NAMES.SEMINAR_ITEMS).then((result) => { + + ContentHome.items = ContentHome.items ? ContentHome.items.concat(result) : result; + ContentHome.busy = false; - DataStore.search(ContentHome.searchOptions, TAG_NAMES.SEMINAR_ITEMS).then(function (result) { - if (result.length <= SORT._limit) {// to indicate there are more + if (result.length < SORT._limit) {// to indicate there are more ContentHome.noMore = true; Buildfire.spinner.hide(); } else { - result.pop(); ContentHome.searchOptions.skip = ContentHome.searchOptions.skip + SORT._limit; ContentHome.noMore = false; + return ContentHome.loadMore(search); } - - ContentHome.items = ContentHome.items ? ContentHome.items.concat(result) : result; // Make sure Items are sorted if(typeof ContentHome.data.content.sortBy == "undefined"){ - ContentHome.busy = false; return ContentHome.sortItemBy(SORT.OLDEST_FIRST) } else { - // Make sure Items are sorted (ranked) correctly, since the items are ranked only on manual + // Make sure Items are ranked correctly; for(let i = 0; i < ContentHome.items.length; i++) { if (ContentHome.items[i].data.rank !== i) { ContentHome.items[i].data.rank = i; @@ -253,6 +251,8 @@ } } } + + if (!$scope.$$phase && !$scope.$root.$$phase) $scope.$apply(); Buildfire.spinner.hide(); }, function (error) { Buildfire.spinner.hide(); diff --git a/control/content/enums.js b/control/content/enums.js index e7b5c75..56cb6b9 100644 --- a/control/content/enums.js +++ b/control/content/enums.js @@ -46,8 +46,8 @@ OLDEST_PUBLICATION_DATE: 'Oldest pub. date first', NEWEST_FIRST: 'Newest entry first', OLDEST_FIRST: 'Oldest entry first', - _limit: 10, - _maxLimit: 19, + _limit: 50, + _maxLimit: 50, _skip: 0 }); })(window.angular); \ No newline at end of file diff --git a/widget/controllers/widget.home.controller.js b/widget/controllers/widget.home.controller.js index eae0800..03a871a 100644 --- a/widget/controllers/widget.home.controller.js +++ b/widget/controllers/widget.home.controller.js @@ -498,7 +498,7 @@ } else { WidgetHome.loadMore(); } - }, 500); + }, 700); if (!$scope.$$phase) $scope.$digest(); if (!$rootScope.$$phase) $rootScope.$digest(); @@ -507,7 +507,6 @@ DataStore.onUpdate().then(null, null, onUpdateCallback); WidgetHome.loadMore = function () { - console.log("------------------------In loadmore"); if (WidgetHome.busy) { return; } @@ -515,7 +514,9 @@ var itemsCount = (WidgetHome.items && WidgetHome.items.length) ? WidgetHome.items.length : 0; //If the items have loaded, and they are less than a page, don't try to load again - if (itemsCount > 0 && itemsCount < PAGINATION.itemCount) { + if (itemsCount > 0 && (typeof $rootScope.totalItemsCount !== undefined && itemsCount === $rootScope.totalItemsCount)) { + WidgetHome.busy = false; + Buildfire.spinner.hide(); return; } @@ -551,6 +552,7 @@ } else { WidgetHome.openLogin(); } + WidgetHome.loadMore(); if (!$scope.$$phase) $scope.$digest(); if (!$rootScope.$$phase) $rootScope.$digest(); }, diff --git a/widget/enums.js b/widget/enums.js index e1b9264..fbbc334 100644 --- a/widget/enums.js +++ b/widget/enums.js @@ -36,7 +36,7 @@ ] }) .constant('PAGINATION', { - itemCount: 30, + itemCount: 50, noteCount: 30 }) .constant('SORT', { From 945fbf9c14762f231a5a93cce39580c51e76dcec Mon Sep 17 00:00:00 2001 From: NenoR96 Date: Wed, 29 Sep 2021 16:04:00 +0200 Subject: [PATCH 7/8] CP: use standard toggle switches --- .../settings/assets/css/control.settings.css | 60 +++++++++++++++++++ .../controllers/settings.home.controller.js | 19 ++++-- control/settings/templates/home.html | 47 ++++++++++----- 3 files changed, 106 insertions(+), 20 deletions(-) diff --git a/control/settings/assets/css/control.settings.css b/control/settings/assets/css/control.settings.css index 3e63cdd..3689964 100644 --- a/control/settings/assets/css/control.settings.css +++ b/control/settings/assets/css/control.settings.css @@ -1,3 +1,63 @@ + +.button-switch{ + display: flex; + align-items: center; + height: 1.5rem; +} +.button-switch > label { + cursor: pointer; + height: 0; + position: relative; + width: 40px; + text-align: left; +} + +.button-switch > label::before { + background: #909090; + border-radius: 18px; + content: ""; + height: 27px; + margin-top: -13.5px; + position: absolute; + opacity: 0.3; + transition: all 0.4s ease-in-out; + width: 46px; +} + +.button-switch > label::after { + background: #fff; + border-radius: 16px; + box-shadow: 0 0 5px rgb(0 0 0 / 30%); + content: ""; + height: 24px; + left: 0; + margin-top: -9px; + position: absolute; + top: -3px; + transition: all 0.3s ease-in-out; + width: 24px; +} + +.button-switch > input[type="checkbox"]:checked + label::before { + background: inherit; + opacity: 0.5; +} + +.button-switch > input[type="checkbox"] { + display: none; + margin: 4px 0 0; +} + +.button-switch > input[type="checkbox"]:checked + label::after { + background: inherit; + left: 23px; +} + +.button-switch.switch-sm > input[type="checkbox"]:checked + label::after { + left: 17px; +} + + .toolbar { display: flex; justify-content: space-between; diff --git a/control/settings/controllers/settings.home.controller.js b/control/settings/controllers/settings.home.controller.js index d4322ad..a56a823 100644 --- a/control/settings/controllers/settings.home.controller.js +++ b/control/settings/controllers/settings.home.controller.js @@ -15,6 +15,8 @@ { label: "One Week", value: 10080 }, ]; + $scope.nextSeminarDelay = false; + Settings.seminarLockedClassOptions = ["hidden", "locked"]; var _data = { @@ -41,7 +43,10 @@ Settings.data.content = {}; } - if (!Settings.data.content.seminarDelay) Settings.data.content.seminarDelay = Settings.seminarDelayOptions[0]; + if (!Settings.data.content.seminarDelay) { + Settings.data.content.seminarDelay = Settings.seminarDelayOptions[0]; + $scope.nextSeminarDelay = false; + } else $scope.nextSeminarDelay = true; if (!Settings.data.content.lockedClass) Settings.data.content.lockedClass = Settings.seminarLockedClassOptions[0]; } }, @@ -52,17 +57,19 @@ DataStore.get(TAG_NAMES.SEMINAR_INFO).then(success, error); }; - Settings.setAllowShare = function(check){ - if(Settings.data.allowSharing!=check){ - Settings.data.allowSharing=check; + $scope.setAllowShare = function(){ var success = function (result) { console.info('Data saved:', result); }, error = function (err) { console.error('Error while saving data', err); }; - DataStore.save(Settings.data,TAG_NAMES.SEMINAR_INFO).then(success, error); - } + DataStore.save(Settings.data,TAG_NAMES.SEMINAR_INFO).then(success, error); + } + + $scope.setSeminarSettings = () => { + if($scope.nextSeminarDelay) + Settings.setSeminarSettings('seminarDelay', Settings.seminarDelayOptions[1]); } Settings.setSeminarSettings = (type, value) => { diff --git a/control/settings/templates/home.html b/control/settings/templates/home.html index 299fddd..e66bd13 100644 --- a/control/settings/templates/home.html +++ b/control/settings/templates/home.html @@ -1,16 +1,20 @@
-

- Allow Content Sharing -

-
- - -
+

+ Allow Content Sharing +

+
+
+ + +
+
+

Next Seminar Delay @@ -21,13 +25,25 @@

- +
+ +
\ No newline at end of file From 59dd2b97c344f15872d93d4e16ef8b357f053ab7 Mon Sep 17 00:00:00 2001 From: NenoR96 Date: Wed, 29 Sep 2021 18:34:27 +0200 Subject: [PATCH 8/8] designers feedback --- .../settings/assets/css/control.settings.css | 7 ++++ .../controllers/settings.home.controller.js | 3 +- control/settings/templates/home.html | 40 ++++++++++--------- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/control/settings/assets/css/control.settings.css b/control/settings/assets/css/control.settings.css index 3689964..75ffb81 100644 --- a/control/settings/assets/css/control.settings.css +++ b/control/settings/assets/css/control.settings.css @@ -57,6 +57,13 @@ left: 17px; } +.col-md-4 { + padding: 0 !important; +} + +.dropdown { + width: 200px; +} .toolbar { display: flex; diff --git a/control/settings/controllers/settings.home.controller.js b/control/settings/controllers/settings.home.controller.js index a56a823..68f3c06 100644 --- a/control/settings/controllers/settings.home.controller.js +++ b/control/settings/controllers/settings.home.controller.js @@ -46,7 +46,7 @@ if (!Settings.data.content.seminarDelay) { Settings.data.content.seminarDelay = Settings.seminarDelayOptions[0]; $scope.nextSeminarDelay = false; - } else $scope.nextSeminarDelay = true; + } else if(Settings.data.content.seminarDelay.value !== 0) $scope.nextSeminarDelay = true; if (!Settings.data.content.lockedClass) Settings.data.content.lockedClass = Settings.seminarLockedClassOptions[0]; } }, @@ -70,6 +70,7 @@ $scope.setSeminarSettings = () => { if($scope.nextSeminarDelay) Settings.setSeminarSettings('seminarDelay', Settings.seminarDelayOptions[1]); + else Settings.setSeminarSettings('seminarDelay', Settings.seminarDelayOptions[0]); } Settings.setSeminarSettings = (type, value) => { diff --git a/control/settings/templates/home.html b/control/settings/templates/home.html index e66bd13..5aa669d 100644 --- a/control/settings/templates/home.html +++ b/control/settings/templates/home.html @@ -3,7 +3,7 @@

Allow Content Sharing

-
+
@@ -24,30 +24,32 @@

-
+
- -
-
- +
+
+

+ Seminar Delay Amount +

+ +