Skip to content

Commit 32782a0

Browse files
authored
Merge pull request #126 from BuildFire/fix/post-images
Fix/post images - PLUG-5745
2 parents e170634 + 99c9acf commit 32782a0

9 files changed

Lines changed: 378 additions & 178 deletions

File tree

control/languages/controllers/stringsUI.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ const stringsUI = {
99
this._debouncers[key] = setTimeout(fn, 300);
1010
},
1111

12-
capitalize(input) {
13-
var words = input.split(' ');
14-
var CapitalizedWords = [];
15-
words.forEach(element => {
16-
CapitalizedWords.push(element[0].toUpperCase() + element.slice(1, element.length));
17-
});
18-
return CapitalizedWords.join(' ');
19-
}
20-
12+
capitalize(input) {
13+
var words = input.split(' ');
14+
var CapitalizedWords = [];
15+
words.forEach(element => {
16+
CapitalizedWords.push(element[0].toUpperCase() + element.slice(1, element.length));
17+
});
18+
return CapitalizedWords.join(' ');
19+
}
20+
2121
, init(containerId, strings, stringsConfig) {
2222
this.strings = strings;
2323
this.stringsConfig = stringsConfig;
@@ -47,14 +47,19 @@ const stringsUI = {
4747
let sec = this.createAndAppend("section", "", [], container);
4848

4949
this.createIfNotEmpty("h1", this.capitalize(sectionObj.title), ["section-title"], sec);
50-
for (let key in sectionObj.labels) this.buildLabel(sec, sectionProp + "." + key, sectionObj.labels[key]);
50+
for (let key in sectionObj.labels) {
51+
if (sectionObj.labels[key].subtitle) {
52+
this.createIfNotEmpty("h4", this.capitalize(sectionObj.labels[key].subtitle), ["section-sub-title"], sec);
53+
}
54+
this.buildLabel(sec, sectionProp + "." + key, sectionObj.labels[key]);
55+
}
5156
container.appendChild(sec);
5257
}
5358
, buildLabel(container, prop, labelObj) {
5459
let rowDiv = this.createAndAppend('div', '', ["item", "row", "margin-bottom-fifteen"], container);
5560
let labelDiv = this.createAndAppend('div', '', [], rowDiv);
5661
this.createAndAppend('span', labelObj.title, ["col-md-3", "labels", "pull-left"], labelDiv); // Label Text Span
57-
62+
5863
let inputDiv = this.createAndAppend('div', '', ["col-md-9", "pull-left"], rowDiv);
5964

6065
let inputElement;

control/languages/styles/bf_base.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ h4, h5, h6 {
5252
margin-top: 0;
5353
}
5454

55+
.section-sub-title {
56+
font-size: 16px;
57+
color: var(--c-info);
58+
margin-bottom: 2rem;
59+
margin-top: 2rem;
60+
}
61+
5562
.text-secondary {
5663
color: var(--c-gray6);
5764
}

widget/app.service.js

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
.factory('Location', [function () {
1313
var _location = location;
1414
return {
15-
go: function (path) {
15+
go: function (path, pushToHistory = true) {
1616
_location.href = path;
1717
let label = path.includes('thread') ? 'thread' : path.includes('members') ? 'members' : 'report';
18-
buildfire.history.push(label, {});
18+
if (pushToHistory) {
19+
buildfire.history.push(label, {});
20+
}
1921
},
2022
goToHome: function () {
2123
_location.href = _location.href.substr(0, _location.href.indexOf('#'));
@@ -134,8 +136,23 @@
134136
console.error('Error decoding deepLinkData:', error);
135137
return null;
136138
}
139+
},
140+
evaluateExpression(expression) {
141+
return new Promise((resolve, reject) => {
142+
buildfire.dynamic.expressions.evaluate({expression}, (err, result) => {
143+
if (err) return reject(err);
144+
resolve(result.evaluatedExpression);
145+
});
146+
})
147+
},
148+
setExpression(expression) {
149+
buildfire.dynamic.expressions.getContext = (options, callback) => {
150+
const context = {
151+
plugin: expression
152+
}
153+
callback(null, context)
154+
}
137155
}
138-
139156
}
140157
}])
141158
.factory("SubscribedUsersData", function () {
@@ -706,7 +723,7 @@
706723
}
707724
}
708725
}])
709-
.factory('SocialItems', ['Util', '$rootScope', function (Util, $rootScope) {
726+
.factory('SocialItems', ['Util', '$rootScope', '$timeout', function (Util, $rootScope, $timeout) {
710727
var _this;
711728
var SocialItems = function () {
712729
_this = this;
@@ -836,9 +853,8 @@
836853
if (error) return console.log(error);
837854

838855
if (data && data.result.length) {
839-
const result = data.result.filter(item => !_this.items.find(_item => _item.id === item.id));
856+
const result = data.result.filter(newItem => !_this.items.some(existItem => existItem.id === newItem.id));
840857
const newItems = result.map(item => {
841-
_this.setupImageList(item.data);
842858
return {...item.data, id: item.id};
843859
});
844860
_this.items = _this.items.concat(newItems);
@@ -869,6 +885,10 @@
869885
});
870886
}
871887

888+
SocialItems.prototype.getPostById = function (id, callback) {
889+
buildfire.publicData.getById(id, "posts", callback);
890+
}
891+
872892
function getSort() {
873893
if (_this.indexingUpdateDone)
874894
return {
@@ -920,16 +940,15 @@
920940
return filter;
921941
}
922942

923-
SocialItems.prototype.setupImageList = function(post) {
924-
post.imageListId = "imageList_" + post.id;
925-
if (post.imageUrl) {
926-
setTimeout(function () {
927-
let imageList = document.getElementById(post.imageListId);
943+
SocialItems.prototype.setupImageList = function(listId, item) {
944+
if (item.imageUrl) {
945+
$timeout(() => {
946+
let imageList = document.getElementById(listId);
928947
if (!imageList) return;
929-
if (Array.isArray(post.imageUrl)) {
930-
imageList.images = post.imageUrl;
948+
if (Array.isArray(item.imageUrl)) {
949+
imageList.images = item.imageUrl;
931950
} else {
932-
imageList.images = [post.imageUrl];
951+
imageList.images = [item.imageUrl];
933952
}
934953
imageList.addEventListener('imageSelected', (e) => {
935954
let selectedImage = e.detail.filter(image => image.selected);
@@ -939,13 +958,16 @@
939958
images: selectedImage
940959
});
941960
});
942-
}, 0);
961+
});
943962
}
944963
};
945964

946965
function startBackgroundService() {
947966
if (!_this.newPostTimerChecker) {
948967
_this.newPostTimerChecker = setInterval(function () {
968+
if (_this.items.length > _this.pageSize) {
969+
return clearInterval(_this.newPostTimerChecker);
970+
}
949971
let searchOptions = {
950972
filter: getFilter(),
951973
sort: {
@@ -963,11 +985,10 @@
963985
if (results.totalRecord > _this.pageSize) {
964986
_this.showMorePosts = true;
965987
} else _this.showMorePosts = false;
966-
988+
967989
if (data && data.length) {
968990
let items = data.map(item => {
969991
const existItem = _this.items.find(_item => _item.id === item.id) || {};
970-
_this.setupImageList(item.data);
971992
return {...existItem, ...item.data, id: item.id};
972993
});
973994

@@ -1015,16 +1036,30 @@
10151036
delete stringsCopy[defaultKey].labels;
10161037
});
10171038
let strings = {}
1018-
strings = Object.assign({}, stringsCopy.mainWall, stringsCopy.sideThread, stringsCopy.members, stringsCopy.input, stringsCopy.modal);
1039+
for (let key in stringsConfig) {
1040+
strings = Object.assign(strings, stringsCopy[key]);
1041+
}
10191042
Object.keys(strings).forEach(e => {
10201043
strings[e].value ? _this.languages[e] = strings[e].value : _this.languages[e] = strings[e].defaultValue;
10211044
});
10221045
} else {
10231046
let strings = {};
1024-
if (response.data && response.data.mainWall && response.data.sideThread && response.data.members && response.data.input && response.data.modal)
1047+
if (response.data && response.data.mainWall && response.data.sideThread && response.data.members && response.data.input && response.data.modal) {
10251048
strings = Object.assign({}, response.data.mainWall, response.data.sideThread, response.data.members, response.data.input, response.data.modal);
1026-
else
1027-
strings = Object.assign({}, stringsConfig.mainWall.labels, stringsConfig.sideThread.labels, stringsConfig.members.labels, stringsConfig.input.labels, stringsConfig.modal.labels);
1049+
1050+
const newProperties = ['pushNotifications'];
1051+
newProperties.forEach((key) => {
1052+
if (response.data[key]) {
1053+
strings = Object.assign(strings, response.data[key]);
1054+
} else {
1055+
strings = Object.assign(strings, stringsConfig[key].labels);
1056+
}
1057+
});
1058+
} else {
1059+
for (let key in stringsConfig) {
1060+
strings = Object.assign(strings, stringsCopy[key].labels);
1061+
}
1062+
}
10281063
Object.keys(strings).forEach(e => {
10291064
if (e == "specificChat" && strings[e].value == "")
10301065
_this.languages[e] = strings[e].value

widget/assets/js/shared/stringsConfig.js

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,108 @@ const stringsConfig = {
185185
}
186186
}
187187
},
188+
pushNotifications: {
189+
title: "Push Notifications",
190+
labels: {
191+
personalNotificationMessageTitle: {
192+
title: "Title"
193+
, subtitle: "Private Message Notification"
194+
, placeholder: "New Private Message"
195+
, maxLength: 25
196+
, defaultValue: "New Private Message"
197+
},
198+
personalNotificationMessageBody: {
199+
title: "Body"
200+
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} sent you a private message."
201+
, maxLength: 150
202+
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} sent you a private message."
203+
},
204+
personalInAppMessageBody: {
205+
title: "In App Message"
206+
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} sent you a private message."
207+
, maxLength: 150
208+
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} sent you a private message."
209+
},
188210

211+
publicNotificationMessageTitle: {
212+
title: "Title"
213+
, subtitle: "New Post Notification"
214+
, placeholder: "New Post"
215+
, maxLength: 25
216+
, defaultValue: "New Post"
217+
},
218+
publicNotificationMessageBody: {
219+
title: "Body"
220+
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} added a new post on ${context.plugin.title}"
221+
, maxLength: 150
222+
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} added a new post on ${context.plugin.title}"
223+
},
224+
publicInAppMessageBody: {
225+
title: "In App Message"
226+
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} added a new post on ${context.plugin.title}"
227+
, maxLength: 150
228+
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} added a new post on ${context.plugin.title}"
229+
},
230+
231+
commentNotificationMessageTitle: {
232+
title: "Title"
233+
, subtitle: "New Comment Notification"
234+
, placeholder: "New Comment"
235+
, maxLength: 25
236+
, defaultValue: "New Comment"
237+
},
238+
commentNotificationMessageBody: {
239+
title: "Body"
240+
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} commented on a post on ${context.plugin.title}"
241+
, maxLength: 150
242+
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} commented on a post on ${context.plugin.title}"
243+
},
244+
commentInAppMessageBody: {
245+
title: "In App Message"
246+
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} commented on a post on ${context.plugin.title}"
247+
, maxLength: 150
248+
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} commented on a post on ${context.plugin.title}"
249+
},
250+
251+
postLikeNotificationTitle: {
252+
title: "Title"
253+
, subtitle: "Post Like Notification"
254+
, placeholder: "Post Like"
255+
, maxLength: 25
256+
, defaultValue: "Post Like"
257+
},
258+
postLikeNotificationMessageBody: {
259+
title: "Body"
260+
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} liked your post."
261+
, maxLength: 150
262+
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} liked your post."
263+
},
264+
postLikeInAppMessageBody: {
265+
title: "In App Message"
266+
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} liked your post."
267+
, maxLength: 150
268+
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} liked your post."
269+
},
270+
271+
commentLikeNotificationTitle: {
272+
title: "Title"
273+
, subtitle: "Comment Like Notification"
274+
, placeholder: "Comment Like"
275+
, maxLength: 25
276+
, defaultValue: "Comment Like"
277+
},
278+
commentLikeNotificationMessageBody: {
279+
title: "Body"
280+
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} liked your comment."
281+
, maxLength: 150
282+
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} liked your comment."
283+
},
284+
commentLikeInAppMessageBody: {
285+
title: "In App Message"
286+
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} liked your comment."
287+
, maxLength: 150
288+
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} liked your comment."
289+
},
290+
}
291+
},
189292
};

0 commit comments

Comments
 (0)