diff options
author | Jimmy Huynh <jimmy.huynh@etu.unistra.fr> | 2021-01-04 15:16:30 +0100 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2021-04-08 23:17:31 +0200 |
commit | cf00206da0b95c3c3e51f37982bc7f076e5f4b28 (patch) | |
tree | 42a0985576a59fa25e4330e62afb45bac262a236 | |
parent | 2e151f6e14f822fcf686c3d46cc1f9340f4f6659 (diff) |
(+) Dynamic userlist on input change
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
-rw-r--r-- | js/controller/ContentController.js | 14 | ||||
-rw-r--r-- | templates/part.content.php | 25 |
2 files changed, 26 insertions, 13 deletions
diff --git a/js/controller/ContentController.js b/js/controller/ContentController.js index 018c15238..0def46a15 100644 --- a/js/controller/ContentController.js +++ b/js/controller/ContentController.js @@ -223,8 +223,18 @@ app.controller('ContentController', function (Publisher, FeedResource, ItemResou this.activeItem = this.getFirstItem(); + this.userList = []; + this.searchUsers = function(search) { - return UserResource.getUsers(search); + if (search === '') { + this.userList = []; + return; + } + + var response = UserResource.getUsers(search); + response.then((response) => { + this.userList = response.ocs.data.users; + }); }; -}); +});
\ No newline at end of file diff --git a/templates/part.content.php b/templates/part.content.php index a61441ccb..a21ef3a29 100644 --- a/templates/part.content.php +++ b/templates/part.content.php @@ -103,22 +103,25 @@ <p class="label-group">Contacts</p> <form ng-submit="" name="contactForm"> <fieldset> - <input type="text" - class="contact-input" - placeholder="Nom de contact" - title="Nom de contact" - name="contactName" - required> + <input + ng-model="nameQuery" + ng-change="Content.searchUsers(nameQuery)" + type="text" + class="contact-input" + placeholder="Nom de contact" + title="Nom de contact" + name="contactName" + required> <input type="submit" - value="Ajouter" - class="primary"> + value="Ajouter" + class="primary"> </fieldset> </form> - <a>Arnaud</a> - <a>Antoine</a> - <a>Adrien</a> + <a ng-repeat="user in Content.userList"> + {{ user }} + </a> <p class="label-group">Partage réseaux sociaux</p> |