summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/controller/ShareController.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/js/controller/ShareController.js b/js/controller/ShareController.js
index 23b8c525e..a60ea7ed3 100644
--- a/js/controller/ShareController.js
+++ b/js/controller/ShareController.js
@@ -45,6 +45,13 @@ app.controller('ShareController', function (ShareResource, Loading) {
/** Dictionary mapping articles to users they're shared with */
this.usersSharedArticles = [];
+ /**
+ * Test whether an item is shared with a user
+ *
+ * @param itemId ID of the item being shared
+ * @param userId User ID of the recipient
+ * @returns boolean
+ */
this.itemIsSharedWithUser = function(itemId, userId) {
let item = this.usersSharedArticles.find(i => i.id === itemId);
if (!item) {
@@ -57,6 +64,13 @@ app.controller('ShareController', function (ShareResource, Loading) {
return true;
};
+ /**
+ * Inserts an item share action into the dictionary
+ *
+ * @param itemId ID of the item being shared
+ * @param userId User ID of the recipient
+ * @param status boolean indicating if the share was successful
+ */
this.addItemShareWithUser = function(itemId, userId, status) {
let item = this.usersSharedArticles.find(i => i.id === itemId);
if (!item) {
@@ -102,10 +116,24 @@ app.controller('ShareController', function (ShareResource, Loading) {
});
};
+ /**
+ * Indicates whether the share action is in progress
+ *
+ * @param userId User ID of the recipient
+ * @returns boolean
+ */
this.isLoading = function(userId) {
return Loading.isLoading(userId);
};
+ /**
+ * Indicates whether the share actions matches the given status
+ *
+ * @param itemId ID of the item being shared
+ * @param userId User ID of the recipient
+ * @param status true (successful) / false (failed)
+ * @returns boolean
+ */
this.isStatus = function(itemId, userId, status) {
let item = this.usersSharedArticles.find(i => i.id === itemId);
if (!item) {