Commit be04a810 authored by Mike Greiling's avatar Mike Greiling

Merge branch '284792-remove-unused-weight-select' into 'master'

Remove unused weight select

See merge request gitlab-org/gitlab!61492
parents e0b661b6 42472db6
import initEpicsSelect from 'ee/vue_shared/components/sidebar/epics_select/epics_select_bundle';
import WeightSelect from 'ee/weight_select';
import initForm from '~/pages/projects/issues/form';
export default () => {
initEpicsSelect();
// eslint-disable-next-line no-new
new WeightSelect();
initForm();
};
/* eslint-disable no-shadow */
import $ from 'jquery';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
function WeightSelect(els, options = {}) {
const $els = $(els || '.js-weight-select');
$els.each((i, dropdown) => {
const $dropdown = $(dropdown);
const $selectbox = $dropdown.closest('.selectbox');
const $block = $selectbox.closest('.block');
const $value = $block.find('.value');
$block.find('.block-loading').addClass('gl-display-none');
const fieldName = options.fieldName || $dropdown.data('fieldName');
const inputField = $dropdown.closest('.selectbox').find(`input[name='${fieldName}']`);
if (Object.keys(options).includes('selected')) {
inputField.val(options.selected);
}
return initDeprecatedJQueryDropdown($dropdown, {
selectable: true,
fieldName,
toggleLabel(selected, el) {
return $(el).data('id');
},
hidden() {
$selectbox.hide();
return $value.css('display', '');
},
id(obj, el) {
if ($(el).data('none') == null) {
return $(el).data('id');
}
return '';
},
clicked(deprecatedJQueryDropdownEvt) {
const { e } = deprecatedJQueryDropdownEvt;
let selected = deprecatedJQueryDropdownEvt.selectedObj;
const inputField = $dropdown.closest('.selectbox').find(`input[name='${fieldName}']`);
if (options.handleClick) {
e.preventDefault();
selected = inputField.val();
options.handleClick(selected);
} else if ($dropdown.is('.js-issuable-form-weight')) {
e.preventDefault();
}
},
});
});
}
export default WeightSelect;
......@@ -4,33 +4,6 @@ module EE
module IssuesHelper
extend ::Gitlab::Utils::Override
def weight_dropdown_tag(issuable, opts = {}, &block)
title = issuable.weight || 'Weight'
additional_toggle_class = opts.delete(:toggle_class)
options = {
toggle_class: "js-weight-select #{additional_toggle_class}",
dropdown_class: 'dropdown-menu-selectable dropdown-menu-weight',
title: 'Select weight',
placeholder: 'Search weight',
data: {
field_name: "#{issuable.class.model_name.param_key}[weight]",
default_label: 'Weight'
}
}.deep_merge(opts)
dropdown_tag(title, options: options) do
capture(&block)
end
end
def weight_dropdown_label(weight)
if Issue.weight_options.include?(weight)
weight
else
h(weight.presence || 'Weight')
end
end
def issue_in_subepic?(issue, epic_id)
# This helper is used if a list of issues are filtered by epic id
return false if epic_id.blank?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment