Skip to content

Commit

Permalink
Merge pull request #126 from BuildFire/fix/post-images
Browse files Browse the repository at this point in the history
Fix/post images - PLUG-5745
  • Loading branch information
mas-iota authored Dec 19, 2024
2 parents e170634 + 99c9acf commit 32782a0
Show file tree
Hide file tree
Showing 9 changed files with 378 additions and 178 deletions.
27 changes: 16 additions & 11 deletions control/languages/controllers/stringsUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const stringsUI = {
this._debouncers[key] = setTimeout(fn, 300);
},

capitalize(input) {
var words = input.split(' ');
var CapitalizedWords = [];
words.forEach(element => {
CapitalizedWords.push(element[0].toUpperCase() + element.slice(1, element.length));
});
return CapitalizedWords.join(' ');
}
capitalize(input) {
var words = input.split(' ');
var CapitalizedWords = [];
words.forEach(element => {
CapitalizedWords.push(element[0].toUpperCase() + element.slice(1, element.length));
});
return CapitalizedWords.join(' ');
}

, init(containerId, strings, stringsConfig) {
this.strings = strings;
this.stringsConfig = stringsConfig;
Expand Down Expand Up @@ -47,14 +47,19 @@ const stringsUI = {
let sec = this.createAndAppend("section", "", [], container);

this.createIfNotEmpty("h1", this.capitalize(sectionObj.title), ["section-title"], sec);
for (let key in sectionObj.labels) this.buildLabel(sec, sectionProp + "." + key, sectionObj.labels[key]);
for (let key in sectionObj.labels) {
if (sectionObj.labels[key].subtitle) {
this.createIfNotEmpty("h4", this.capitalize(sectionObj.labels[key].subtitle), ["section-sub-title"], sec);
}
this.buildLabel(sec, sectionProp + "." + key, sectionObj.labels[key]);
}
container.appendChild(sec);
}
, buildLabel(container, prop, labelObj) {
let rowDiv = this.createAndAppend('div', '', ["item", "row", "margin-bottom-fifteen"], container);
let labelDiv = this.createAndAppend('div', '', [], rowDiv);
this.createAndAppend('span', labelObj.title, ["col-md-3", "labels", "pull-left"], labelDiv); // Label Text Span

let inputDiv = this.createAndAppend('div', '', ["col-md-9", "pull-left"], rowDiv);

let inputElement;
Expand Down
7 changes: 7 additions & 0 deletions control/languages/styles/bf_base.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ h4, h5, h6 {
margin-top: 0;
}

.section-sub-title {
font-size: 16px;
color: var(--c-info);
margin-bottom: 2rem;
margin-top: 2rem;
}

.text-secondary {
color: var(--c-gray6);
}
Expand Down
77 changes: 56 additions & 21 deletions widget/app.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
.factory('Location', [function () {
var _location = location;
return {
go: function (path) {
go: function (path, pushToHistory = true) {
_location.href = path;
let label = path.includes('thread') ? 'thread' : path.includes('members') ? 'members' : 'report';
buildfire.history.push(label, {});
if (pushToHistory) {
buildfire.history.push(label, {});
}
},
goToHome: function () {
_location.href = _location.href.substr(0, _location.href.indexOf('#'));
Expand Down Expand Up @@ -134,8 +136,23 @@
console.error('Error decoding deepLinkData:', error);
return null;
}
},
evaluateExpression(expression) {
return new Promise((resolve, reject) => {
buildfire.dynamic.expressions.evaluate({expression}, (err, result) => {
if (err) return reject(err);
resolve(result.evaluatedExpression);
});
})
},
setExpression(expression) {
buildfire.dynamic.expressions.getContext = (options, callback) => {
const context = {
plugin: expression
}
callback(null, context)
}
}

}
}])
.factory("SubscribedUsersData", function () {
Expand Down Expand Up @@ -706,7 +723,7 @@
}
}
}])
.factory('SocialItems', ['Util', '$rootScope', function (Util, $rootScope) {
.factory('SocialItems', ['Util', '$rootScope', '$timeout', function (Util, $rootScope, $timeout) {
var _this;
var SocialItems = function () {
_this = this;
Expand Down Expand Up @@ -836,9 +853,8 @@
if (error) return console.log(error);

if (data && data.result.length) {
const result = data.result.filter(item => !_this.items.find(_item => _item.id === item.id));
const result = data.result.filter(newItem => !_this.items.some(existItem => existItem.id === newItem.id));
const newItems = result.map(item => {
_this.setupImageList(item.data);
return {...item.data, id: item.id};
});
_this.items = _this.items.concat(newItems);
Expand Down Expand Up @@ -869,6 +885,10 @@
});
}

SocialItems.prototype.getPostById = function (id, callback) {
buildfire.publicData.getById(id, "posts", callback);
}

function getSort() {
if (_this.indexingUpdateDone)
return {
Expand Down Expand Up @@ -920,16 +940,15 @@
return filter;
}

SocialItems.prototype.setupImageList = function(post) {
post.imageListId = "imageList_" + post.id;
if (post.imageUrl) {
setTimeout(function () {
let imageList = document.getElementById(post.imageListId);
SocialItems.prototype.setupImageList = function(listId, item) {
if (item.imageUrl) {
$timeout(() => {
let imageList = document.getElementById(listId);
if (!imageList) return;
if (Array.isArray(post.imageUrl)) {
imageList.images = post.imageUrl;
if (Array.isArray(item.imageUrl)) {
imageList.images = item.imageUrl;
} else {
imageList.images = [post.imageUrl];
imageList.images = [item.imageUrl];
}
imageList.addEventListener('imageSelected', (e) => {
let selectedImage = e.detail.filter(image => image.selected);
Expand All @@ -939,13 +958,16 @@
images: selectedImage
});
});
}, 0);
});
}
};

function startBackgroundService() {
if (!_this.newPostTimerChecker) {
_this.newPostTimerChecker = setInterval(function () {
if (_this.items.length > _this.pageSize) {
return clearInterval(_this.newPostTimerChecker);
}
let searchOptions = {
filter: getFilter(),
sort: {
Expand All @@ -963,11 +985,10 @@
if (results.totalRecord > _this.pageSize) {
_this.showMorePosts = true;
} else _this.showMorePosts = false;

if (data && data.length) {
let items = data.map(item => {
const existItem = _this.items.find(_item => _item.id === item.id) || {};
_this.setupImageList(item.data);
return {...existItem, ...item.data, id: item.id};
});

Expand Down Expand Up @@ -1015,16 +1036,30 @@
delete stringsCopy[defaultKey].labels;
});
let strings = {}
strings = Object.assign({}, stringsCopy.mainWall, stringsCopy.sideThread, stringsCopy.members, stringsCopy.input, stringsCopy.modal);
for (let key in stringsConfig) {
strings = Object.assign(strings, stringsCopy[key]);
}
Object.keys(strings).forEach(e => {
strings[e].value ? _this.languages[e] = strings[e].value : _this.languages[e] = strings[e].defaultValue;
});
} else {
let strings = {};
if (response.data && response.data.mainWall && response.data.sideThread && response.data.members && response.data.input && response.data.modal)
if (response.data && response.data.mainWall && response.data.sideThread && response.data.members && response.data.input && response.data.modal) {
strings = Object.assign({}, response.data.mainWall, response.data.sideThread, response.data.members, response.data.input, response.data.modal);
else
strings = Object.assign({}, stringsConfig.mainWall.labels, stringsConfig.sideThread.labels, stringsConfig.members.labels, stringsConfig.input.labels, stringsConfig.modal.labels);

const newProperties = ['pushNotifications'];
newProperties.forEach((key) => {
if (response.data[key]) {
strings = Object.assign(strings, response.data[key]);
} else {
strings = Object.assign(strings, stringsConfig[key].labels);
}
});
} else {
for (let key in stringsConfig) {
strings = Object.assign(strings, stringsCopy[key].labels);
}
}
Object.keys(strings).forEach(e => {
if (e == "specificChat" && strings[e].value == "")
_this.languages[e] = strings[e].value
Expand Down
103 changes: 103 additions & 0 deletions widget/assets/js/shared/stringsConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,108 @@ const stringsConfig = {
}
}
},
pushNotifications: {
title: "Push Notifications",
labels: {
personalNotificationMessageTitle: {
title: "Title"
, subtitle: "Private Message Notification"
, placeholder: "New Private Message"
, maxLength: 25
, defaultValue: "New Private Message"
},
personalNotificationMessageBody: {
title: "Body"
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} sent you a private message."
, maxLength: 150
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} sent you a private message."
},
personalInAppMessageBody: {
title: "In App Message"
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} sent you a private message."
, maxLength: 150
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} sent you a private message."
},

publicNotificationMessageTitle: {
title: "Title"
, subtitle: "New Post Notification"
, placeholder: "New Post"
, maxLength: 25
, defaultValue: "New Post"
},
publicNotificationMessageBody: {
title: "Body"
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} added a new post on ${context.plugin.title}"
, maxLength: 150
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} added a new post on ${context.plugin.title}"
},
publicInAppMessageBody: {
title: "In App Message"
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} added a new post on ${context.plugin.title}"
, maxLength: 150
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} added a new post on ${context.plugin.title}"
},

commentNotificationMessageTitle: {
title: "Title"
, subtitle: "New Comment Notification"
, placeholder: "New Comment"
, maxLength: 25
, defaultValue: "New Comment"
},
commentNotificationMessageBody: {
title: "Body"
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} commented on a post on ${context.plugin.title}"
, maxLength: 150
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} commented on a post on ${context.plugin.title}"
},
commentInAppMessageBody: {
title: "In App Message"
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} commented on a post on ${context.plugin.title}"
, maxLength: 150
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} commented on a post on ${context.plugin.title}"
},

postLikeNotificationTitle: {
title: "Title"
, subtitle: "Post Like Notification"
, placeholder: "Post Like"
, maxLength: 25
, defaultValue: "Post Like"
},
postLikeNotificationMessageBody: {
title: "Body"
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} liked your post."
, maxLength: 150
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} liked your post."
},
postLikeInAppMessageBody: {
title: "In App Message"
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} liked your post."
, maxLength: 150
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} liked your post."
},

commentLikeNotificationTitle: {
title: "Title"
, subtitle: "Comment Like Notification"
, placeholder: "Comment Like"
, maxLength: 25
, defaultValue: "Comment Like"
},
commentLikeNotificationMessageBody: {
title: "Body"
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} liked your comment."
, maxLength: 150
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} liked your comment."
},
commentLikeInAppMessageBody: {
title: "In App Message"
, placeholder: "${context.appUser?context.appUser.displayName:'Someone'} liked your comment."
, maxLength: 150
, defaultValue: "${context.appUser?context.appUser.displayName:'Someone'} liked your comment."
},
}
},
};
Loading

0 comments on commit 32782a0

Please sign in to comment.