--- /dev/null
+define([
+ 'components/common/modals',
+ 'components/common/select-list',
+ './templates'
+], function (Modal) {
+
+ return Modal.extend({
+ template: Templates['users-groups'],
+ itemTemplate: Templates['users-group'],
+
+ onRender: function () {
+ Modal.prototype.onRender.apply(this, arguments);
+ new window.SelectList({
+ el: this.$('#users-groups'),
+ width: '100%',
+ readOnly: false,
+ focusSearch: false,
+ format: function (item) {
+ return item.name + '<br><span class="note">' + item.description + '</span>';
+ },
+ searchUrl: baseUrl + '/api/users/groups?ps=100&login=' + this.model.id,
+ selectUrl: baseUrl + '/api/qualityprofiles/add_project',
+ deselectUrl: baseUrl + '/api/qualityprofiles/remove_project',
+ extra: {
+ profileKey: key
+ },
+ selectParameter: 'projectUuid',
+ selectParameterValue: 'uuid',
+ parse: function (r) {
+ this.more = false;
+ return r.groups;
+ }
+ });
+ }
+ });
+
+});
'./update-view',
'./change-password-view',
'./deactivate-view',
+ './groups-view',
'./templates'
-], function (UpdateView, ChangePasswordView, DeactivateView) {
+], function (UpdateView, ChangePasswordView, DeactivateView, GroupsView) {
return Marionette.ItemView.extend({
tagName: 'li',
'click .js-user-more-scm': 'onMoreScmClick',
'click .js-user-update': 'onUpdateClick',
'click .js-user-change-password': 'onChangePasswordClick',
- 'click .js-user-deactivate': 'onDeactivateClick'
+ 'click .js-user-deactivate': 'onDeactivateClick',
+ 'click .js-user-groups': 'onGroupsClick'
},
initialize: function () {
this.deactivateUser();
},
+ onGroupsClick: function (e) {
+ e.preventDefault();
+ this.showGroups();
+ },
+
showMoreScm: function () {
this.scmLimit = 10000;
this.render();
new DeactivateView({ model: this.model }).render();
},
+ showGroups: function () {
+ new GroupsView({ model: this.model }).render();
+ },
+
serializeData: function () {
var scmAccounts = this.model.get('scmAccounts'),
scmAccountsLimit = scmAccounts.length > this.scmLimit ? this.scmLimit - 1 : this.scmLimit;
--- /dev/null
+<div class="modal-head">
+ <h2>Update Groups</h2>
+</div>
+<div class="modal-body">
+ <div class="js-modal-messages"></div>
+ <div id="users-groups"></div>
+</div>
+<div class="modal-foot">
+ <a href="#" class="js-modal-close" id="users-groups-done">Done</a>
+</div>
<li class="spacer-left little-spacer-bottom">sonar-administrators ?</li>
<li class="spacer-left little-spacer-bottom">
<a class="js-user-more-groups" href="#">? more</a>
- <a class="icon-bullet-list spacer-left" title="Update Groups" data-toggle="tooltip" href="#"></a>
+ <a class="js-user-groups icon-bullet-list spacer-left" title="Update Groups" data-toggle="tooltip" href="#"></a>
</li>
</ul>
</div>
var SelectListCollection = Backbone.Collection.extend({
+ initialize: function (options) {
+ this.options = options;
+ },
+
parse: function (r) {
- this.more = r.more;
- return r.results;
+ return this.options.parse.call(this, r);
},
fetch: function (options) {
window.SelectList = function (options) {
this.settings = $.extend(window.SelectList.defaults, options);
- this.collection = new SelectListCollection();
+ this.collection = new SelectListCollection({
+ parse: this.settings.parse
+ });
this.view = new SelectListView({
el: this.settings.el,
return item.value;
},
+ parse: function (r) {
+ this.more = r.more;
+ return r.results;
+ },
+
labels: {
selected: 'Selected',
deselected: 'Deselected',