summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/protected_tags
diff options
context:
space:
mode:
authorKushal Pandya <kushal@gitlab.com>2017-04-06 19:09:48 +0530
committerKushal Pandya <kushal@gitlab.com>2017-04-06 19:09:48 +0530
commitca9cded45d78e821a1c778e22fde523873ffaf93 (patch)
tree3f154ac6129cfb6f8be816e0d26ea202608a0309 /app/assets/javascripts/protected_tags
parentf16377e7dc762462817dd0b34e36811c55988b10 (diff)
downloadgitlab-ce-ca9cded45d78e821a1c778e22fde523873ffaf93.tar.gz
Fixes as per feedback
Diffstat (limited to 'app/assets/javascripts/protected_tags')
-rw-r--r--app/assets/javascripts/protected_tags/index.js3
-rw-r--r--app/assets/javascripts/protected_tags/protected_tag_access_dropdown.js4
-rw-r--r--app/assets/javascripts/protected_tags/protected_tag_create.js4
-rw-r--r--app/assets/javascripts/protected_tags/protected_tag_dropdown.js3
-rw-r--r--app/assets/javascripts/protected_tags/protected_tag_edit.js16
-rw-r--r--app/assets/javascripts/protected_tags/protected_tag_edit_list.js5
6 files changed, 17 insertions, 18 deletions
diff --git a/app/assets/javascripts/protected_tags/index.js b/app/assets/javascripts/protected_tags/index.js
index da036f5437e..61e7ba53862 100644
--- a/app/assets/javascripts/protected_tags/index.js
+++ b/app/assets/javascripts/protected_tags/index.js
@@ -1,5 +1,2 @@
-export { default as ProtectedTagAccessDropdown } from './protected_tag_access_dropdown';
export { default as ProtectedTagCreate } from './protected_tag_create';
-export { default as ProtectedTagDropdown } from './protected_tag_dropdown';
-export { default as ProtectedTagEdit } from './protected_tag_edit';
export { default as ProtectedTagEditList } from './protected_tag_edit_list';
diff --git a/app/assets/javascripts/protected_tags/protected_tag_access_dropdown.js b/app/assets/javascripts/protected_tags/protected_tag_access_dropdown.js
index 681b060f859..fff83f3af3b 100644
--- a/app/assets/javascripts/protected_tags/protected_tag_access_dropdown.js
+++ b/app/assets/javascripts/protected_tags/protected_tag_access_dropdown.js
@@ -11,8 +11,8 @@ export default class ProtectedTagAccessDropdown {
selectable: true,
inputId: this.options.$dropdown.data('input-id'),
fieldName: this.options.$dropdown.data('field-name'),
- toggleLabel(item, el) {
- if (el.is('.is-active')) {
+ toggleLabel(item, $el) {
+ if ($el.is('.is-active')) {
return item.text;
}
return 'Select';
diff --git a/app/assets/javascripts/protected_tags/protected_tag_create.js b/app/assets/javascripts/protected_tags/protected_tag_create.js
index 964e67c9de0..91bd140bd12 100644
--- a/app/assets/javascripts/protected_tags/protected_tag_create.js
+++ b/app/assets/javascripts/protected_tags/protected_tag_create.js
@@ -3,7 +3,7 @@ import ProtectedTagDropdown from './protected_tag_dropdown';
export default class ProtectedTagCreate {
constructor() {
- this.$form = $('.new_protected_tag');
+ this.$form = $('.js-new-protected-tag');
this.buildDropdowns();
}
@@ -34,7 +34,7 @@ export default class ProtectedTagCreate {
onSelect() {
// Enable submit button
const $tagInput = this.$form.find('input[name="protected_tag[name]"]');
- const $allowedToCreateInput = this.$form.find('input[name="protected_tag[create_access_levels_attributes][0][access_level]"]');
+ const $allowedToCreateInput = this.$form.find('#create_access_levels_attributes');
this.$form.find('input[type="submit"]').attr('disabled', !($tagInput.val() && $allowedToCreateInput.length));
}
diff --git a/app/assets/javascripts/protected_tags/protected_tag_dropdown.js b/app/assets/javascripts/protected_tags/protected_tag_dropdown.js
index 9c78f2816a4..5ff4e443262 100644
--- a/app/assets/javascripts/protected_tags/protected_tag_dropdown.js
+++ b/app/assets/javascripts/protected_tags/protected_tag_dropdown.js
@@ -50,9 +50,10 @@ export default class ProtectedTagDropdown {
this.$protectedTag.on('click', this.onClickCreateWildcard.bind(this));
}
- onClickCreateWildcard() {
+ onClickCreateWildcard(e) {
this.$dropdown.data('glDropdown').remote.execute();
this.$dropdown.data('glDropdown').selectRowAtIndex();
+ e.preventDefault();
}
getProtectedTags(term, callback) {
diff --git a/app/assets/javascripts/protected_tags/protected_tag_edit.js b/app/assets/javascripts/protected_tags/protected_tag_edit.js
index b5092877138..624067a5a09 100644
--- a/app/assets/javascripts/protected_tags/protected_tag_edit.js
+++ b/app/assets/javascripts/protected_tags/protected_tag_edit.js
@@ -6,7 +6,8 @@ import ProtectedTagAccessDropdown from './protected_tag_access_dropdown';
export default class ProtectedTagEdit {
constructor(options) {
this.$wrap = options.$wrap;
- this.$allowedToCreateDropdown = this.$wrap.find('.js-allowed-to-create');
+ this.$allowedToCreateDropdownButton = this.$wrap.find('.js-allowed-to-create');
+ this.onSelectCallback = this.onSelect.bind(this);
this.buildDropdowns();
}
@@ -14,19 +15,19 @@ export default class ProtectedTagEdit {
buildDropdowns() {
// Allowed to create dropdown
this.protectedTagAccessDropdown = new ProtectedTagAccessDropdown({
- $dropdown: this.$allowedToCreateDropdown,
+ $dropdown: this.$allowedToCreateDropdownButton,
data: gon.create_access_levels,
- onSelect: this.onSelect.bind(this),
+ onSelect: this.onSelectCallback,
});
}
onSelect() {
- const $allowedToCreateInput = this.$wrap.find(`input[name="${this.$allowedToCreateDropdown.data('fieldName')}"]`);
+ const $allowedToCreateInput = this.$wrap.find(`input[name="${this.$allowedToCreateDropdownButton.data('fieldName')}"]`);
// Do not update if one dropdown has not selected any option
if (!$allowedToCreateInput.length) return;
- this.$allowedToCreateDropdown.disable();
+ this.$allowedToCreateDropdownButton.disable();
$.ajax({
type: 'POST',
@@ -36,17 +37,16 @@ export default class ProtectedTagEdit {
_method: 'PATCH',
protected_tag: {
create_access_levels_attributes: [{
- id: this.$allowedToCreateDropdown.data('access-level-id'),
+ id: this.$allowedToCreateDropdownButton.data('access-level-id'),
access_level: $allowedToCreateInput.val(),
}],
},
},
error() {
- $.scrollTo(0);
new Flash('Failed to update tag!');
},
}).always(() => {
- this.$allowedToCreateDropdown.enable();
+ this.$allowedToCreateDropdownButton.enable();
});
}
}
diff --git a/app/assets/javascripts/protected_tags/protected_tag_edit_list.js b/app/assets/javascripts/protected_tags/protected_tag_edit_list.js
index 88c7accdec6..bd9fc872266 100644
--- a/app/assets/javascripts/protected_tags/protected_tag_edit_list.js
+++ b/app/assets/javascripts/protected_tags/protected_tag_edit_list.js
@@ -1,15 +1,16 @@
+/* eslint-disable no-new */
+
import ProtectedTagEdit from './protected_tag_edit';
export default class ProtectedTagEditList {
constructor() {
this.$wrap = $('.protected-tags-list');
- this.protectedTagList = [];
this.initEditForm();
}
initEditForm() {
this.$wrap.find('.js-protected-tag-edit-form').each((i, el) => {
- this.protectedTagList[i] = new ProtectedTagEdit({
+ new ProtectedTagEdit({
$wrap: $(el),
});
});