user-groups: Add function wrappers to reduce variable scope.

Extract set_up_typeahead function.
Extract pill_remove function.
This commit is contained in:
Tarun Kumar
2018-03-13 14:28:00 +05:30
committed by Tim Abbott
parent 9969762f01
commit 59b1f59605

View File

@@ -23,7 +23,6 @@ exports.reload = function () {
exports.populate_user_groups = function () {
var user_groups_section = $('#user-groups').expectOne();
var user_groups_array = user_groups.get_realm_user_groups();
_.each(user_groups_array, function (data) {
user_groups_section.append(templates.render('admin_user_group_list', {
user_group: {
@@ -197,7 +196,7 @@ exports.populate_user_groups = function () {
});
var input = pill_container.children('.input');
(function set_up_typeahead() {
input.typeahead({
items: 5,
fixed: true,
@@ -224,7 +223,9 @@ exports.populate_user_groups = function () {
},
stopAdvance: true,
});
}());
(function pill_remove() {
pills.onPillRemove(function () {
// onPillRemove is fired before the pill is removed from
// the DOM.
@@ -233,13 +234,12 @@ exports.populate_user_groups = function () {
input.focus();
}, 100);
});
}());
});
};
exports.set_up = function () {
meta.loaded = true;
exports.populate_user_groups();
$(".organization").on("submit", "form.admin-user-group-form", function (e) {