summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Nassabain <marco.nassabain@etu.unistra.fr>2021-01-17 19:52:14 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-04-08 23:17:31 +0200
commit5342837d40a68fa1ecc1bad0a8e8224feca3a96d (patch)
treea4265255a84b7432373e1277c7d17c740cd92f9e
parentea4178620be71ce993144fad600647491ba1b3fb (diff)
✨ NewsItem: share with user on click (front-end)
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
-rw-r--r--js/controller/ShareController.js7
-rw-r--r--js/service/ShareResource.js10
-rw-r--r--templates/part.content.php4
3 files changed, 20 insertions, 1 deletions
diff --git a/js/controller/ShareController.js b/js/controller/ShareController.js
index 4b7f15d0e..2977dc2c2 100644
--- a/js/controller/ShareController.js
+++ b/js/controller/ShareController.js
@@ -25,4 +25,11 @@ app.controller('ShareController', function (ShareResource) {
});
};
+ this.shareItem = function(itemId, userId) {
+ var response = ShareResource.shareItem(itemId, userId);
+ response.then((result) => {
+ return result;
+ });
+ };
+
}); \ No newline at end of file
diff --git a/js/service/ShareResource.js b/js/service/ShareResource.js
index d497c18f7..4ccf90e11 100644
--- a/js/service/ShareResource.js
+++ b/js/service/ShareResource.js
@@ -22,6 +22,16 @@ app.factory('ShareResource', function (Resource, $http, BASE_URL) {
});
};
+ ShareResource.prototype.shareItem = function (itemId, userId) {
+ var url = this.BASE_URL +
+ '/items/' + itemId + '/share/' + userId;
+
+ return this.http({
+ url: url,
+ method: 'POST',
+ });
+ };
+
return new ShareResource($http, BASE_URL);
}); \ No newline at end of file
diff --git a/templates/part.content.php b/templates/part.content.php
index 3dcea9bd1..d3aaf0295 100644
--- a/templates/part.content.php
+++ b/templates/part.content.php
@@ -121,7 +121,9 @@
</form>
- <a ng-repeat="user in Share.userList">
+ <a
+ ng-repeat="user in Share.userList"
+ ng-click="Share.shareItem(item.id, user.value.shareWith)">
{{ user.value.shareWith }}
</a>