Merge branch '38869-labels' into 'master'
Use ES6 modules in labels and labels manager See merge request gitlab-org/gitlab-ce!14794
This commit is contained in:
commit
a6b33275c0
4 changed files with 150 additions and 164 deletions
|
@ -29,7 +29,8 @@ import CILintEditor from './ci_lint_editor';
|
||||||
/* global ProjectNew */
|
/* global ProjectNew */
|
||||||
/* global ProjectShow */
|
/* global ProjectShow */
|
||||||
/* global ProjectImport */
|
/* global ProjectImport */
|
||||||
/* global Labels */
|
import Labels from './labels';
|
||||||
|
import LabelManager from './label_manager';
|
||||||
/* global Shortcuts */
|
/* global Shortcuts */
|
||||||
/* global ShortcutsFindFile */
|
/* global ShortcutsFindFile */
|
||||||
/* global Sidebar */
|
/* global Sidebar */
|
||||||
|
@ -459,7 +460,7 @@ import U2FAuthenticate from './u2f/authenticate';
|
||||||
case 'groups:labels:index':
|
case 'groups:labels:index':
|
||||||
case 'projects:labels:index':
|
case 'projects:labels:index':
|
||||||
if ($('.prioritized-labels').length) {
|
if ($('.prioritized-labels').length) {
|
||||||
new gl.LabelManager();
|
new LabelManager();
|
||||||
}
|
}
|
||||||
$('.label-subscription').each((i, el) => {
|
$('.label-subscription').each((i, el) => {
|
||||||
const $el = $(el);
|
const $el = $(el);
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
import Flash from './flash';
|
import Flash from './flash';
|
||||||
|
|
||||||
((global) => {
|
export default class LabelManager {
|
||||||
class LabelManager {
|
|
||||||
constructor({ togglePriorityButton, prioritizedLabels, otherLabels } = {}) {
|
constructor({ togglePriorityButton, prioritizedLabels, otherLabels } = {}) {
|
||||||
this.togglePriorityButton = togglePriorityButton || $('.js-toggle-priority');
|
this.togglePriorityButton = togglePriorityButton || $('.js-toggle-priority');
|
||||||
this.prioritizedLabels = prioritizedLabels || $('.js-prioritized-labels');
|
this.prioritizedLabels = prioritizedLabels || $('.js-prioritized-labels');
|
||||||
|
@ -120,6 +119,3 @@ import Flash from './flash';
|
||||||
return sortedIds;
|
return sortedIds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gl.LabelManager = LabelManager;
|
|
||||||
})(window.gl || (window.gl = {}));
|
|
||||||
|
|
|
@ -1,44 +1,35 @@
|
||||||
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, vars-on-top, no-unused-vars, max-len */
|
export default class Labels {
|
||||||
(function() {
|
constructor() {
|
||||||
this.Labels = (function() {
|
|
||||||
function Labels() {
|
|
||||||
this.setSuggestedColor = this.setSuggestedColor.bind(this);
|
this.setSuggestedColor = this.setSuggestedColor.bind(this);
|
||||||
this.updateColorPreview = this.updateColorPreview.bind(this);
|
this.updateColorPreview = this.updateColorPreview.bind(this);
|
||||||
var form;
|
|
||||||
form = $('.label-form');
|
|
||||||
this.cleanBinding();
|
this.cleanBinding();
|
||||||
this.addBinding();
|
this.addBinding();
|
||||||
this.updateColorPreview();
|
this.updateColorPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
Labels.prototype.addBinding = function() {
|
addBinding() {
|
||||||
$(document).on('click', '.suggest-colors a', this.setSuggestedColor);
|
$(document).on('click', '.suggest-colors a', this.setSuggestedColor);
|
||||||
return $(document).on('input', 'input#label_color', this.updateColorPreview);
|
return $(document).on('input', 'input#label_color', this.updateColorPreview);
|
||||||
};
|
}
|
||||||
|
// eslint-disable-next-line class-methods-use-this
|
||||||
Labels.prototype.cleanBinding = function() {
|
cleanBinding() {
|
||||||
$(document).off('click', '.suggest-colors a');
|
$(document).off('click', '.suggest-colors a');
|
||||||
return $(document).off('input', 'input#label_color');
|
return $(document).off('input', 'input#label_color');
|
||||||
};
|
}
|
||||||
|
// eslint-disable-next-line class-methods-use-this
|
||||||
Labels.prototype.updateColorPreview = function() {
|
updateColorPreview() {
|
||||||
var previewColor;
|
const previewColor = $('input#label_color').val();
|
||||||
previewColor = $('input#label_color').val();
|
|
||||||
return $('div.label-color-preview').css('background-color', previewColor);
|
return $('div.label-color-preview').css('background-color', previewColor);
|
||||||
// Updates the the preview color with the hex-color input
|
// Updates the the preview color with the hex-color input
|
||||||
};
|
}
|
||||||
|
|
||||||
// Updates the preview color with a click on a suggested color
|
// Updates the preview color with a click on a suggested color
|
||||||
Labels.prototype.setSuggestedColor = function(e) {
|
setSuggestedColor(e) {
|
||||||
var color;
|
const color = $(e.currentTarget).data('color');
|
||||||
color = $(e.currentTarget).data('color');
|
|
||||||
$('input#label_color').val(color);
|
$('input#label_color').val(color);
|
||||||
this.updateColorPreview();
|
this.updateColorPreview();
|
||||||
// Notify the form, that color has changed
|
// Notify the form, that color has changed
|
||||||
$('.label-form').trigger('keyup');
|
$('.label-form').trigger('keyup');
|
||||||
return e.preventDefault();
|
return e.preventDefault();
|
||||||
};
|
}
|
||||||
|
}
|
||||||
return Labels;
|
|
||||||
})();
|
|
||||||
}).call(window);
|
|
||||||
|
|
|
@ -79,8 +79,6 @@ import './issuable_context';
|
||||||
import './issuable_form';
|
import './issuable_form';
|
||||||
import './issue';
|
import './issue';
|
||||||
import './issue_status_select';
|
import './issue_status_select';
|
||||||
import './label_manager';
|
|
||||||
import './labels';
|
|
||||||
import './labels_select';
|
import './labels_select';
|
||||||
import './layout_nav';
|
import './layout_nav';
|
||||||
import LazyLoader from './lazy_loader';
|
import LazyLoader from './lazy_loader';
|
||||||
|
|
Loading…
Reference in a new issue