Teams: listAllTags and getTemplates

pull/1/head
yflory 5 years ago
parent 35a429d30c
commit 1d53e7d8a1

@ -407,6 +407,9 @@ define([
if (!store.loggedIn) { return cb(); } if (!store.loggedIn) { return cb(); }
if (store.rpc) { return void cb(account); } if (store.rpc) { return void cb(account); }
require(['/common/pinpad.js'], function (Pinpad) { require(['/common/pinpad.js'], function (Pinpad) {
// XXX Teams: we wont' pass the team's proxy directly here because all the users
// may not have access to the edPrivate key
// Users without edPrivate should not be able to create a pinpad object
Pinpad.create(store.network, store.proxy, function (e, call) { Pinpad.create(store.network, store.proxy, function (e, call) {
if (e) { return void cb({error: e}); } if (e) { return void cb({error: e}); }
@ -846,17 +849,33 @@ define([
// Tags // Tags
Store.listAllTags = function (clientId, data, cb) { Store.listAllTags = function (clientId, data, cb) {
cb(store.manager.getTagsList()); var tags = {};
getAllStores.forEach(function (s) {
var l = s.manager.getTagsList();
Object.keys(l).forEach(function (tag) {
tags[tag] = (tags[tag] || 0) + l[tag];
});
});
cb(tags);
}; };
// Templates // Templates
// Note: maybe we should get templates "per team" to avoid creating a document with a template
// from a different team
Store.getTemplates = function (clientId, data, cb) { Store.getTemplates = function (clientId, data, cb) {
// No templates in shared folders: we don't need the manager here // No templates in shared folders: we don't need the manager here
var templateFiles = store.userObject.getFiles(['template']);
var res = []; var res = [];
templateFiles.forEach(function (f) { var channels = [];
var data = store.userObject.getFileData(f); getAllStores.forEach(function (s) {
res.push(JSON.parse(JSON.stringify(data))); var templateFiles = s.userObject.getFiles(['template']);
templateFiles.forEach(function (f) {
var data = s.userObject.getFileData(f);
// Don't push duplicates
if (channels.indexOf(data.channel) !== -1) { return }
channels.push(data.channel);
// Puhs a copy of the data
res.push(JSON.parse(JSON.stringify(data)));
});
}); });
cb(res); cb(res);
}; };

@ -33,7 +33,8 @@ define([
// sanity check: do we have all the required keys? // sanity check: do we have all the required keys?
// initialize team rpc with pin, unpin, ... // initialize team rpc with pin, unpin, ...
// team.rpc = rpc // team.rpc = rpc
// load manager // load manager with userObject
// team.manager =... team.userObject = ....
// load shared folders // load shared folders
// ~resetPins for the team? // ~resetPins for the team?
// getPinLimit // getPinLimit
@ -73,6 +74,7 @@ define([
listmap: lm, listmap: lm,
clients: [], clients: [],
manager: undefined, // XXX manager: undefined, // XXX
userObject: undefined, // XXX
realtime: lm.realtime, realtime: lm.realtime,
handleSharedFolder: function (sfId, rt) { handleSharedFolder(ctx, id, sfId, rt); }, handleSharedFolder: function (sfId, rt) { handleSharedFolder(ctx, id, sfId, rt); },
sharedFolders: {}, // equivalent of store.sharedFolders in async-store sharedFolders: {}, // equivalent of store.sharedFolders in async-store

Loading…
Cancel
Save