diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-10-25 02:13:24 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-10-25 02:13:24 +0800 |
commit | 600da9ee0bb823e4b14fd45d6ff0e5f0b61b9737 (patch) | |
tree | f91eeeee22da72eed5bdf5b87ca27bdc95b136a0 /app/assets/javascripts/LabelManager.js | |
parent | 40ff7579e9ba025610dfada9703386b4dc657d6d (diff) | |
parent | cb38290ababe43aca0c635fb87d3a38c4c5debcd (diff) | |
download | gitlab-ce-19737-read-only-auditor.tar.gz |
Merge remote-tracking branch 'upstream/master' into 19737-read-only-auditor19737-read-only-auditor
* upstream/master: (1277 commits)
Grapify the labels API
Fix typo in project settings that prevents users from enabling container registry.
Fix old monitoring links to point to the new location
Added path parameter to Commits API
fixes build with cache:clear issue
Merge branch 'security-fix-leaking-namespace-name' into 'security'
Fix authored vote from notes
Grapify builds API
Add changelog item for groups 404 on relative url
Add relative url support to routing contrainers
Update project member controller to match recent master logic
Add parentheses around return redirect_to method
Trigger change even in select2 test helper to produce production-like behaviour
Refactor js that disable form submit if no members selected
Improve create project member test at project_members_controller_spec
Move changelog item to 8.14
Refactor create member tests from group_members_controller_spec
Refactor groups/projects members controller
Gracefully handle adding of no users to projects and groups
Revert "Change "Group#web_url" to return "/groups/twitter" rather than "/twitter"."
...
Diffstat (limited to 'app/assets/javascripts/LabelManager.js')
-rw-r--r-- | app/assets/javascripts/LabelManager.js | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/app/assets/javascripts/LabelManager.js b/app/assets/javascripts/LabelManager.js deleted file mode 100644 index d4a4c7abaa1..00000000000 --- a/app/assets/javascripts/LabelManager.js +++ /dev/null @@ -1,115 +0,0 @@ -(function() { - this.LabelManager = (function() { - LabelManager.prototype.errorMessage = 'Unable to update label prioritization at this time'; - - function LabelManager(opts) { - // Defaults - var ref, ref1, ref2; - if (opts == null) { - opts = {}; - } - this.togglePriorityButton = (ref = opts.togglePriorityButton) != null ? ref : $('.js-toggle-priority'), this.prioritizedLabels = (ref1 = opts.prioritizedLabels) != null ? ref1 : $('.js-prioritized-labels'), this.otherLabels = (ref2 = opts.otherLabels) != null ? ref2 : $('.js-other-labels'); - this.prioritizedLabels.sortable({ - items: 'li', - placeholder: 'list-placeholder', - axis: 'y', - update: this.onPrioritySortUpdate.bind(this) - }); - this.bindEvents(); - } - - LabelManager.prototype.bindEvents = function() { - return this.togglePriorityButton.on('click', this, this.onTogglePriorityClick); - }; - - LabelManager.prototype.onTogglePriorityClick = function(e) { - var $btn, $label, $tooltip, _this, action; - e.preventDefault(); - _this = e.data; - $btn = $(e.currentTarget); - $label = $("#" + ($btn.data('domId'))); - action = $btn.parents('.js-prioritized-labels').length ? 'remove' : 'add'; - // Make sure tooltip will hide - $tooltip = $("#" + ($btn.find('.has-tooltip:visible').attr('aria-describedby'))); - $tooltip.tooltip('destroy'); - return _this.toggleLabelPriority($label, action); - }; - - LabelManager.prototype.toggleLabelPriority = function($label, action, persistState) { - var $from, $target, _this, url, xhr; - if (persistState == null) { - persistState = true; - } - _this = this; - url = $label.find('.js-toggle-priority').data('url'); - $target = this.prioritizedLabels; - $from = this.otherLabels; - // Optimistic update - if (action === 'remove') { - $target = this.otherLabels; - $from = this.prioritizedLabels; - } - if ($from.find('li').length === 1) { - $from.find('.empty-message').removeClass('hidden'); - } - if (!$target.find('li').length) { - $target.find('.empty-message').addClass('hidden'); - } - $label.detach().appendTo($target); - // Return if we are not persisting state - if (!persistState) { - return; - } - if (action === 'remove') { - xhr = $.ajax({ - url: url, - type: 'DELETE' - }); - // Restore empty message - if (!$from.find('li').length) { - $from.find('.empty-message').removeClass('hidden'); - } - } else { - xhr = this.savePrioritySort($label, action); - } - return xhr.fail(this.rollbackLabelPosition.bind(this, $label, action)); - }; - - LabelManager.prototype.onPrioritySortUpdate = function() { - var xhr; - xhr = this.savePrioritySort(); - return xhr.fail(function() { - return new Flash(this.errorMessage, 'alert'); - }); - }; - - LabelManager.prototype.savePrioritySort = function() { - return $.post({ - url: this.prioritizedLabels.data('url'), - data: { - label_ids: this.getSortedLabelsIds() - } - }); - }; - - LabelManager.prototype.rollbackLabelPosition = function($label, originalAction) { - var action; - action = originalAction === 'remove' ? 'add' : 'remove'; - this.toggleLabelPriority($label, action, false); - return new Flash(this.errorMessage, 'alert'); - }; - - LabelManager.prototype.getSortedLabelsIds = function() { - var sortedIds; - sortedIds = []; - this.prioritizedLabels.find('li').each(function() { - return sortedIds.push($(this).data('id')); - }); - return sortedIds; - }; - - return LabelManager; - - })(); - -}).call(this); |