Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
67c343e7
Commit
67c343e7
authored
Aug 17, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark active items on dropdown
[ci skip]
parent
ff05f4bd
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
14 deletions
+50
-14
app/assets/javascripts/allowed_to_merge_dropdown.js.es6
app/assets/javascripts/allowed_to_merge_dropdown.js.es6
+18
-0
app/assets/javascripts/allowed_to_push_dropdown.js.es6
app/assets/javascripts/allowed_to_push_dropdown.js.es6
+18
-0
app/assets/javascripts/protected_branch_access_dropdown.js.es6
...ssets/javascripts/protected_branch_access_dropdown.js.es6
+13
-12
app/assets/javascripts/protected_branch_create.js.es6
app/assets/javascripts/protected_branch_create.js.es6
+1
-2
No files found.
app/assets/javascripts/allowed_to_merge_dropdown.js.es6
View file @
67c343e7
...
@@ -14,6 +14,24 @@
...
@@ -14,6 +14,24 @@
return fieldName;
return fieldName;
}
}
getActiveIds() {
let selected = [];
// Todo: Find a better way to get the wrap element of each dropdown
let $wrap = this.$dropdown.parents().eq(1); // Please, don't judge me
$wrap.find('input[name^="protected_branch[merge_access_levels_attributes]"]')
.map((i, el) => {
const $el = $(el);
selected.push({
id: parseInt($el.val()),
type: $el.data('type')
});
});
return selected;
}
}
}
global.gl.allowedToMergeDropdown = allowedToMergeDropdown;
global.gl.allowedToMergeDropdown = allowedToMergeDropdown;
...
...
app/assets/javascripts/allowed_to_push_dropdown.js.es6
View file @
67c343e7
...
@@ -14,6 +14,24 @@
...
@@ -14,6 +14,24 @@
return fieldName;
return fieldName;
}
}
getActiveIds() {
let selected = [];
// Todo: Find a better way to get the wrap element of each dropdown
let $wrap = this.$dropdown.parents().eq(1); // Please, don't judge me
$wrap.find('input[name^="protected_branch[push_access_levels_attributes]"]')
.map((i, el) => {
const $el = $(el);
selected.push({
id: parseInt($el.val()),
type: $el.data('type')
});
});
return selected;
}
}
}
global.gl.allowedToPushDropdown = allowedToPushDropdown;
global.gl.allowedToPushDropdown = allowedToPushDropdown;
...
...
app/assets/javascripts/protected_branch_access_dropdown.js.es6
View file @
67c343e7
...
@@ -20,7 +20,8 @@
...
@@ -20,7 +20,8 @@
renderRow: this.renderRow.bind(this),
renderRow: this.renderRow.bind(this),
toggleLabel: this.toggleLabel.bind(this),
toggleLabel: this.toggleLabel.bind(this),
fieldName: this.fieldName.bind(this),
fieldName: this.fieldName.bind(this),
setActiveIds() {
hidden() {
// Here because last selected item is not considered after first close
this.activeIds = self.getActiveIds();
this.activeIds = self.getActiveIds();
},
},
clicked(item, $el, e) {
clicked(item, $el, e) {
...
@@ -36,6 +37,10 @@
...
@@ -36,6 +37,10 @@
throw new Error('No fieldName method defined');
throw new Error('No fieldName method defined');
}
}
getActiveIds() {
throw new Error('No getActiveIds method defined');
}
toggleLabel(selectedItem, el) {
toggleLabel(selectedItem, el) {
let currentItems = this.$dropdown.siblings('.dropdown-menu').find('.is-active');
let currentItems = this.$dropdown.siblings('.dropdown-menu').find('.is-active');
let types = _.groupBy(currentItems, (item) => { return item.dataset.type; });
let types = _.groupBy(currentItems, (item) => { return item.dataset.type; });
...
@@ -100,27 +105,23 @@
...
@@ -100,27 +105,23 @@
}
}
renderRow(item, instance) {
renderRow(item, instance) {
const isActive = _.findWhere(instance.activeIds, {id: item.id, type: item.type}) ? 'is-active' : '';
if (item.type === 'user') {
if (item.type === 'user') {
return this.userRowHtml(item);
return this.userRowHtml(item
, isActive
);
} else if (item.type === 'role') {
} else if (item.type === 'role') {
return this.roleRowHtml(item);
return this.roleRowHtml(item
, isActive
);
}
}
}
}
userRowHtml(user) {
userRowHtml(user
, isActive
) {
const avatarHtml = `<img src='${user.avatar_url}' class='avatar avatar-inline' width='30'>`;
const avatarHtml = `<img src='${user.avatar_url}' class='avatar avatar-inline' width='30'>`;
const nameHtml = `<strong class='dropdown-menu-user-full-name'>${user.name}</strong>`;
const nameHtml = `<strong class='dropdown-menu-user-full-name'>${user.name}</strong>`;
const usernameHtml = `<span class='dropdown-menu-user-username'>${user.username}</span>`;
const usernameHtml = `<span class='dropdown-menu-user-username'>${user.username}</span>`;
return `<li><a href='#' class='${isActive ? 'is-active' : ''}' data-type='${user.type}'>${avatarHtml} ${nameHtml} ${usernameHtml}</a></li>`;
return `<li><a href='#' data-type='${user.type}'>${avatarHtml} ${nameHtml} ${usernameHtml}</a></li>`;
}
}
roleRowHtml(role) {
roleRowHtml(role, isActive) {
return `<li><a href='#' data-type='${role.type}'>${role.text}</a></li>`;
return `<li><a href='#' class='${isActive ? 'is-active' : ''}' data-type='${role.type}'>${role.text}</a></li>`;
}
getActiveIds() {
console.log('getActiveIds');
}
}
}
}
...
...
app/assets/javascripts/protected_branch_create.js.es6
View file @
67c343e7
...
@@ -40,9 +40,8 @@
...
@@ -40,9 +40,8 @@
const $branchInput = this.$wrap.find('input[name="protected_branch[name]"]');
const $branchInput = this.$wrap.find('input[name="protected_branch[name]"]');
const $allowedToMergeInputs = this.$wrap.find('input[name^="protected_branch[merge_access_levels_attributes]"]');
const $allowedToMergeInputs = this.$wrap.find('input[name^="protected_branch[merge_access_levels_attributes]"]');
const $allowedToPushInputs = this.$wrap.find('input[name^="protected_branch[push_access_levels_attributes]"]');
const $allowedToPushInputs = this.$wrap.find('input[name^="protected_branch[push_access_levels_attributes]"]');
console.log('x');
if ($branchInput.length && $allowedToMergeInputs.length && $allowedToPushInputs.length){
if ($branchInput.length && $allowedToMergeInputs.length && $allowedToPushInputs.length){
console.log('onSelect');
this.$form.find('input[type="submit"]').removeAttr('disabled');
this.$form.find('input[type="submit"]').removeAttr('disabled');
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment