summaryrefslogtreecommitdiffstats
path: root/js/controller/ShareController.js
blob: 2977dc2c2c9d10417d237abd611d7376a79f8503 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
 * Nextcloud - News
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author Marco Nassabain <marco.nassabain@hotmail.com>
 */
app.controller('ShareController', function (ShareResource) {
    'use strict';

    this.userList = [];

    this.searchUsers = function(search) {
        // TODO: search === undefined 🤢 je pense pas que c'est ouf comme syntaxe
        if (search === '' || search === undefined) {
            this.userList = [];
            return;
        }

        // TODO: bug - requetes retardataires (regarder issues git)
        var response = ShareResource.getUsers(search);
        response.then((response) => {
            this.userList = response.ocs.data.users;
        });
    };

    this.shareItem = function(itemId, userId) {
        var response = ShareResource.shareItem(itemId, userId);
        response.then((result) => {
            return result;
        });
    };

});