mirror of https://github.com/zulip/zulip.git
user-groups: Create static/js/user_groups.js.
This commit is contained in:
parent
ad8f5650a3
commit
0e21cbc5d9
|
@ -39,6 +39,7 @@
|
||||||
"input_pill": false,
|
"input_pill": false,
|
||||||
"stream_color": false,
|
"stream_color": false,
|
||||||
"people": false,
|
"people": false,
|
||||||
|
"user_groups": false,
|
||||||
"navigate": false,
|
"navigate": false,
|
||||||
"settings_account": false,
|
"settings_account": false,
|
||||||
"settings_display": false,
|
"settings_display": false,
|
||||||
|
|
|
@ -249,6 +249,7 @@ $(function () {
|
||||||
reload.initialize();
|
reload.initialize();
|
||||||
server_events.initialize();
|
server_events.initialize();
|
||||||
people.initialize();
|
people.initialize();
|
||||||
|
user_groups.initialize();
|
||||||
unread.initialize();
|
unread.initialize();
|
||||||
bot_data.initialize(); // Must happen after people.initialize()
|
bot_data.initialize(); // Must happen after people.initialize()
|
||||||
message_fetch.initialize();
|
message_fetch.initialize();
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
var user_groups = (function () {
|
||||||
|
|
||||||
|
var exports = {};
|
||||||
|
|
||||||
|
var user_group_name_dict;
|
||||||
|
var user_group_by_id_dict;
|
||||||
|
|
||||||
|
// We have an init() function so that our automated tests
|
||||||
|
// can easily clear data.
|
||||||
|
exports.init = function () {
|
||||||
|
user_group_name_dict = new Dict({fold_case: true});
|
||||||
|
user_group_by_id_dict = new Dict();
|
||||||
|
};
|
||||||
|
|
||||||
|
// WE INITIALIZE DATA STRUCTURES HERE!
|
||||||
|
exports.init();
|
||||||
|
|
||||||
|
exports.add = function add(user_group) {
|
||||||
|
user_group_name_dict.set(user_group.name, user_group);
|
||||||
|
user_group_by_id_dict.set(user_group.id, user_group);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.get_user_group_from_id = function (group_id) {
|
||||||
|
if (!user_group_by_id_dict.has(group_id)) {
|
||||||
|
blueslip.error('Unknown group_id in get_user_group_from_id: ' + group_id);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return user_group_by_id_dict.get(group_id);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.get_user_group_from_name = function (name) {
|
||||||
|
if (!user_group_name_dict.has(name)) {
|
||||||
|
blueslip.error('Unknown name in get_user_group_from_name: ' + name);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return user_group_name_dict.get(name);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.get_realm_user_groups = function () {
|
||||||
|
return user_group_name_dict.values();
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.initialize = function () {
|
||||||
|
_.each(page_params.realm_user_groups, function (user_group) {
|
||||||
|
exports.add(user_group);
|
||||||
|
});
|
||||||
|
|
||||||
|
delete page_params.realm_user_groups; // We are the only consumer of this.
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.is_user_group = function (item) {
|
||||||
|
return item.hasOwnProperty('members');
|
||||||
|
};
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
|
||||||
|
}());
|
||||||
|
if (typeof module !== 'undefined') {
|
||||||
|
module.exports = user_groups;
|
||||||
|
}
|
|
@ -943,6 +943,7 @@ JS_SPECS = {
|
||||||
'js/message_viewport.js',
|
'js/message_viewport.js',
|
||||||
'js/rows.js',
|
'js/rows.js',
|
||||||
'js/people.js',
|
'js/people.js',
|
||||||
|
'js/user_groups.js',
|
||||||
'js/unread.js',
|
'js/unread.js',
|
||||||
'js/topic_list.js',
|
'js/topic_list.js',
|
||||||
'js/pm_list.js',
|
'js/pm_list.js',
|
||||||
|
|
Loading…
Reference in New Issue