Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions control/content/controllers/content.home.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

/**
Expand Down Expand Up @@ -81,6 +81,7 @@
if(data) {
var item = ContentHome.items[_index];
Deeplink.deleteById(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}}]};
Expand Down Expand Up @@ -191,8 +192,6 @@
else
editor.loadItems(ContentHome.data.content.carouselImages);
}
if(typeof ContentHome.data.content.sortBy == "undefined")
ContentHome.data.content.sortBy=SORT.MANUALLY;
ContentHome.itemSortableOptions.disabled = !(ContentHome.data.content.sortBy === SORT.MANUALLY);
RankOfLastItem.setRank(ContentHome.data.content.rankOfLastItem || 0);
updateMasterItem(ContentHome.data);
Expand Down Expand Up @@ -225,17 +224,35 @@
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

DataStore.search(ContentHome.searchOptions, TAG_NAMES.SEMINAR_ITEMS).then((result) => {

ContentHome.items = ContentHome.items ? ContentHome.items.concat(result) : result;
ContentHome.busy = false;

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;
ContentHome.busy = false;

// Make sure Items are sorted
if(typeof ContentHome.data.content.sortBy == "undefined"){
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, () => {});
}
}
}

if (!$scope.$$phase && !$scope.$root.$$phase) $scope.$apply();
Buildfire.spinner.hide();
}, function (error) {
Buildfire.spinner.hide();
Expand Down Expand Up @@ -358,7 +375,6 @@
}
};


/*
* Call the datastore to save the data object
*/
Expand Down
10 changes: 10 additions & 0 deletions control/content/controllers/content.item.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: `DOCUMENT_${result.id}_OPENED`,
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({
Expand Down
4 changes: 2 additions & 2 deletions control/content/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 1 addition & 1 deletion control/settings/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
(function (angular) {
angular
.module('seminarSettings', ['ngRoute'])
.module('seminarSettings', ['ngRoute', 'ui.bootstrap'])
.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/', {
Expand Down
67 changes: 67 additions & 0 deletions control/settings/assets/css/control.settings.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,70 @@

.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;
}

.col-md-4 {
padding: 0 !important;
}

.dropdown {
width: 200px;
}

.toolbar {
display: flex;
justify-content: space-between;
Expand Down
87 changes: 79 additions & 8 deletions control/settings/controllers/settings.home.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,117 @@
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 },
];

$scope.nextSeminarDelay = false;

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);
Settings.data = result.data;
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];
$scope.nextSeminarDelay = false;
} else if(Settings.data.content.seminarDelay.value !== 0) $scope.nextSeminarDelay = true;
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){
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]);
else Settings.setSeminarSettings('seminarDelay', Settings.seminarDelayOptions[0]);
}

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();
}
])
Expand Down
Loading