From 7609fdbabf2dca556873a9c48df4c597f7df209a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien?= Date: Thu, 28 Jan 2021 16:59:20 +0100 Subject: Add Loading for searchUser and share Signed-off-by: Marco Nassabain --- css/app.css | 4 ++++ js/controller/ShareController.js | 12 ++++++++++-- templates/part.content.php | 4 ++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/css/app.css b/css/app.css index 7743d956a..fa6f5e8c1 100644 --- a/css/app.css +++ b/css/app.css @@ -101,3 +101,7 @@ background-color: rgba(0, 0, 0, 0.1); font-weight: bold; } + +.right { + float: right; +} diff --git a/js/controller/ShareController.js b/js/controller/ShareController.js index 57722f416..b5b252dd6 100644 --- a/js/controller/ShareController.js +++ b/js/controller/ShareController.js @@ -6,15 +6,19 @@ * * @author Marco Nassabain */ -app.controller('ShareController', function (ShareResource) { +app.controller('ShareController', function (ShareResource, Loading) { 'use strict'; this.userList = []; this.searchUsers = function(search) { + + Loading.setLoading('user', true); + // TODO: search === undefined 🤢 je pense pas que c'est ouf comme syntaxe if (search === '' || search === undefined) { this.userList = []; + Loading.setLoading('user', false); return; } @@ -22,13 +26,16 @@ app.controller('ShareController', function (ShareResource) { var response = ShareResource.getUsers(search); response.then((response) => { this.userList = response.ocs.data.users; + Loading.setLoading('user', false); }); }; - // Dict (user_id)>: Local mapping b/w users & articles: [Article 1 : , Article 2: <...>] + // Dict (user_id)>: Local mapping b/w users & articles: + //[Article 1 : , Article 2: <...>] this.usersSharedArticles = {}; this.shareItem = function(itemId, userId) { + Loading.setLoading(userId, true); if (this.usersSharedArticles[itemId] && this.usersSharedArticles[itemId].includes(userId)) {return ; } // quick initialization (instead of if (...) : []) @@ -38,6 +45,7 @@ app.controller('ShareController', function (ShareResource) { var response = ShareResource.shareItem(itemId, userId); response.then((result) => { + Loading.setLoading(userId, false); return result; }); }; diff --git a/templates/part.content.php b/templates/part.content.php index f210508c6..e41813b76 100644 --- a/templates/part.content.php +++ b/templates/part.content.php @@ -119,10 +119,14 @@ +
+
{{ user.value.shareWith }} +

t('Share on social media')) ?>

-- cgit v1.2.3