new window.SelectList({
el: this.$('#users-groups'),
width: '100%',
- readOnly: false,
+ readOnly: true,
focusSearch: false,
format: function (item) {
return item.name + '<br><span class="note">' + item.description + '</span>';
events: {
'click .js-user-more-scm': 'onMoreScmClick',
+ 'click .js-user-more-groups': 'onMoreGroupsClick',
'click .js-user-update': 'onUpdateClick',
'click .js-user-change-password': 'onChangePasswordClick',
'click .js-user-deactivate': 'onDeactivateClick',
initialize: function () {
this.scmLimit = 3;
+ this.groupsLimit = 3;
},
onRender: function () {
this.showMoreScm();
},
+ onMoreGroupsClick: function (e) {
+ e.preventDefault();
+ this.showMoreGroups();
+ },
+
onUpdateClick: function (e) {
e.preventDefault();
this.updateUser();
this.render();
},
+ showMoreGroups: function () {
+ this.groupsLimit = 10000;
+ this.render();
+ },
+
updateUser: function () {
new UpdateView({
model: this.model,
serializeData: function () {
var scmAccounts = this.model.get('scmAccounts'),
- scmAccountsLimit = scmAccounts.length > this.scmLimit ? this.scmLimit - 1 : this.scmLimit;
+ scmAccountsLimit = scmAccounts.length > this.scmLimit ? this.scmLimit - 1 : this.scmLimit,
+ groups = this.model.get('groups'),
+ groupsLimit = groups.length > this.groupsLimit ? this.groupsLimit - 1 : this.groupsLimit;
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
firstScmAccounts: _.first(scmAccounts, scmAccountsLimit),
- moreScmAccountsCount: scmAccounts.length - scmAccountsLimit
+ moreScmAccountsCount: scmAccounts.length - scmAccountsLimit,
+ firstGroups: _.first(groups, groupsLimit),
+ moreGroupsCount: groups.length - groupsLimit
});
}
});
<strong>Groups</strong>
</div>
<ul class="overflow-hidden bordered-left">
- <li class="spacer-left little-spacer-bottom">sonar-users ?</li>
- <li class="spacer-left little-spacer-bottom">sonar-administrators ?</li>
+ {{#each firstGroups}}
+ <li class="spacer-left little-spacer-bottom">{{this}}</li>
+ {{/each}}
<li class="spacer-left little-spacer-bottom">
- <a class="js-user-more-groups" href="#">? more</a>
- <a class="js-user-groups icon-bullet-list spacer-left" title="Update Groups" data-toggle="tooltip" href="#"></a>
+ {{#gt moreGroupsCount 0}}
+ <a class="js-user-more-groups spacer-right" href="#">{{moreGroupsCount}} more</a>
+ {{/gt}}
+ <a class="js-user-groups icon-bullet-list" title="Update Groups" data-toggle="tooltip" href="#"></a>
</li>
</ul>
</div>
defaults: function () {
return {
- groupsCount: 0,
+ groups: [],
scmAccounts: []
};
},
.search-navigator-workspace {
padding-left: @sideWidth;
- overflow-x: hidden;
}
.search-navigator-workspace-header {
lib.changeWorkingDirectory('users-spec');
lib.configureCasper();
-casper.test.begin(testName('List'), 11, function (test) {
+casper.test.begin(testName('List'), 13, function (test) {
casper
.start(lib.buildUrl('users'), function () {
lib.setDefaultViewport();
test.assertSelectorContains('[data-login="ryan"]', 'another@example.com');
})
+ .then(function () {
+ test.assertSelectorDoesntContain('[data-login="ryan"]', 'four');
+ casper.click('[data-login="ryan"] .js-user-more-groups');
+ test.assertSelectorContains('[data-login="ryan"]', 'four');
+ })
+
.then(function () {
lib.sendCoverage();
})
"login": "ryan",
"name": "John",
"email": "john@example.com",
- "scmAccounts": ["ryan@example.com", "ryan", "john", "another@example.com"]
+ "scmAccounts": ["ryan@example.com", "ryan", "john", "another@example.com"],
+ "groups": ["one", "two", "three", "four"]
}
]
}