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
312d3370
Commit
312d3370
authored
Aug 17, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return correct input name for selected option
[ci skip]
parent
9a23da2d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
18 deletions
+37
-18
app/assets/javascripts/allowed_to_merge_dropdown.js.es6
app/assets/javascripts/allowed_to_merge_dropdown.js.es6
+18
-9
app/assets/javascripts/allowed_to_push_dropdown.js.es6
app/assets/javascripts/allowed_to_push_dropdown.js.es6
+18
-9
app/assets/javascripts/protected_branch_access_dropdown.js.es6
...ssets/javascripts/protected_branch_access_dropdown.js.es6
+1
-0
No files found.
app/assets/javascripts/allowed_to_merge_dropdown.js.es6
View file @
312d3370
...
...
@@ -5,11 +5,23 @@
class allowedToMergeDropdown extends gl.ProtectedBranchAccessDropdown {
fieldName(selectedItem) {
// Role by default
let fieldName = `protected_branch[merge_access_levels_attributes][${this.inputCount}][access_level]`;
if (selectedItem.type === 'user') {
fieldName = `protected_branch[merge_access_levels_attributes][${this.inputCount}][user_id]`;
let fieldName = '';
let typeToName = {
role: 'access_level',
user: 'user_id',
};
let $input = this.$wrap.find(`input[name$="[${typeToName[selectedItem.type]}]"][value="${selectedItem.id}"]`);
if ($input.length) {
// If input exists return actual name
fieldName = $input.attr('name');
} else {
// If not suggest a name
fieldName = `protected_branch[merge_access_levels_attributes][${this.inputCount}][access_level]`; // Role by default
if (selectedItem.type === 'user') {
fieldName = `protected_branch[merge_access_levels_attributes][${this.inputCount}][user_id]`;
}
}
return fieldName;
...
...
@@ -18,10 +30,7 @@
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]"]')
this.$wrap.find('input[name^="protected_branch[merge_access_levels_attributes]"]')
.map((i, el) => {
const $el = $(el);
selected.push({
...
...
app/assets/javascripts/allowed_to_push_dropdown.js.es6
View file @
312d3370
...
...
@@ -5,11 +5,23 @@
class allowedToPushDropdown extends gl.ProtectedBranchAccessDropdown {
fieldName(selectedItem) {
// Role by default
let fieldName = `protected_branch[push_access_levels_attributes][${this.inputCount}][access_level]`;
if (selectedItem.type === 'user') {
fieldName = `protected_branch[push_access_levels_attributes][${this.inputCount}][user_id]`;
let fieldName = '';
let typeToName = {
role: 'access_level',
user: 'user_id',
};
let $input = this.$wrap.find(`input[name$="[${typeToName[selectedItem.type]}]"][value="${selectedItem.id}"]`);
if ($input.length) {
// If input exists return actual name
fieldName = $input.attr('name');
} else {
// If not suggest a name
fieldName = `protected_branch[push_access_levels_attributes][${this.inputCount}][access_level]`; // Role by default
if (selectedItem.type === 'user') {
fieldName = `protected_branch[push_access_levels_attributes][${this.inputCount}][user_id]`;
}
}
return fieldName;
...
...
@@ -18,10 +30,7 @@
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]"]')
this.$wrap.find('input[name^="protected_branch[push_access_levels_attributes]"]')
.map((i, el) => {
const $el = $(el);
selected.push({
...
...
app/assets/javascripts/protected_branch_access_dropdown.js.es6
View file @
312d3370
...
...
@@ -7,6 +7,7 @@
const self = this;
this.$dropdown = $dropdown;
this.$wrap = this.$dropdown.parents().eq(1); // TODO: Find a better way to get the wrap element
this.usersPath = '/autocomplete/users.json';
this.inputCount = 0;
this.defaultLabel = this.$dropdown.data('defaultLabel');
...
...
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