Commit 891f78be authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'ph-ee-only-modules' into 'master'

EE specific JS modules

See merge request gitlab-org/gitlab-ee!3828
parents f49c8fea 1196a073
/* eslint-disable no-var, wrap-iife, func-names, space-before-function-paren, camelcase, no-unused-vars, quotes, object-shorthand, one-var, one-var-declaration-per-line, prefer-arrow-callback, comma-dangle, prefer-template, no-else-return, yoda, prefer-rest-params, prefer-spread, max-len */
import Api from './api';
var slice = [].slice;
window.AdminEmailSelect = (function() {
function AdminEmailSelect() {
$('.ajax-admin-email-select').each((function(_this) {
return function(i, select) {
var skip_ldap;
skip_ldap = $(select).hasClass('skip_ldap');
return $(select).select2({
placeholder: "Select group or project",
multiple: $(select).hasClass('multiselect'),
minimumInputLength: 0,
query: function(query) {
var group_result, project_result;
group_result = Api.groups(query.term, {}, function(groups) {
return groups;
});
project_result = Api.projects(query.term, {
order_by: 'id',
membership: false
}, function(projects) {
return projects;
});
return $.when(project_result, group_result).done(function(projects, groups) {
var all, data;
all = {
id: "all"
};
data = [all].concat(groups[0], projects[0]);
return query.callback({
results: data
});
});
},
id: function(object) {
if (object.path_with_namespace) {
return "project-" + object.id;
} else if (object.path) {
return "group-" + object.id;
} else {
return "all";
}
},
formatResult: function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return _this.formatResult.apply(_this, args);
},
formatSelection: function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return _this.formatSelection.apply(_this, args);
},
dropdownCssClass: "ajax-admin-email-dropdown",
escapeMarkup: function(m) {
return m;
}
});
};
})(this));
}
AdminEmailSelect.prototype.formatResult = function(object) {
if (object.path_with_namespace) {
return "<div class='project-result'> <div class='project-name'>" + object.name + "</div> <div class='project-path'>" + object.path_with_namespace + "</div> </div>";
} else if (object.path) {
return "<div class='group-result'> <div class='group-name'>" + object.name + "</div> <div class='group-path'>" + object.path + "</div> </div>";
} else {
return "<div class='group-result'> <div class='group-name'>All</div> <div class='group-path'>All groups and projects</div> </div>";
}
};
AdminEmailSelect.prototype.formatSelection = function(object) {
if (object.path_with_namespace) {
return "Project: " + object.name;
} else if (object.path) {
return "Group: " + object.name;
} else {
return "All groups and projects";
}
};
return AdminEmailSelect;
})();
function ApplicationSettings() {
const usageDataUrl = $('.usage-data').data('endpoint');
$.ajax({
type: 'GET',
url: usageDataUrl,
dataType: 'html',
success(html) {
$('.usage-data').html(html);
},
});
}
window.gl = window.gl || {};
window.gl.ApplicationSettings = ApplicationSettings;
/* eslint-disable func-names, prefer-arrow-callback, space-before-function-paren, quotes, no-var, comma-spacing, keyword-spacing, one-var, one-var-declaration-per-line, no-unused-vars, camelcase, prefer-template, max-len */
$(function() {
$(".approver-list").on("click", ".unsaved-approvers.approver .btn-remove", function(ev) {
var removeElement = $(this).closest("li");
var approverId = parseInt(removeElement.attr("id").replace("user_",""), 10);
var approverIds = $("input#merge_request_approver_ids");
var skipUsers = approverIds.data("skip-users") || [];
var approverIndex = skipUsers.indexOf(approverId);
removeElement.remove();
if(approverIndex > -1) {
approverIds.data("skip-users", skipUsers.splice(approverIndex, 1));
}
ev.preventDefault();
});
$(".approver-list").on("click", ".unsaved-approvers.approver-group .btn-remove", function(ev) {
var removeElement = $(this).closest("li");
var approverGroupId = parseInt(removeElement.attr("id").replace("group_",""), 10);
var approverGroupIds = $("input#merge_request_approver_group_ids");
var skipGroups = approverGroupIds.data("skip-groups") || [];
var approverGroupIndex = skipGroups.indexOf(approverGroupId);
removeElement.remove();
if(approverGroupIndex > -1) {
approverGroupIds.data("skip-groups", skipGroups.splice(approverGroupIndex, 1));
}
ev.preventDefault();
});
$("form.merge-request-form").submit(function() {
var approverIds, approversInput, approverGroupIds, approverGroupsInput;
if ($("input#merge_request_approver_ids").length) {
approverIds = $.map($("li.unsaved-approvers.approver").not(".approver-template"), function(li, i) {
return li.id.replace("user_", "");
});
approversInput = $(this).find("input#merge_request_approver_ids");
approverIds = approverIds.concat(approversInput.val().split(","));
approversInput.val(_.compact(approverIds).join(","));
}
if ($("input#merge_request_approver_group_ids").length) {
approverGroupIds = $.map($("li.unsaved-approvers.approver-group"), function(li, i) {
return li.id.replace("group_", "");
});
approverGroupsInput = $(this).find("input#merge_request_approver_group_ids");
approverGroupIds = approverGroupIds.concat(approverGroupsInput.val().split(","));
approverGroupsInput.val(_.compact(approverGroupIds).join(","));
}
});
return $(".suggested-approvers a").click(function() {
var approver_item_html, user_id, user_name;
user_id = this.id.replace("user_", "");
user_name = this.text;
if ($(".approver-list #user_" + user_id).length) {
return false;
}
approver_item_html = $(".unsaved-approvers.approver-template").clone().removeClass("hide approver-template")[0].outerHTML.replace(/\{approver_name\}/g, user_name).replace(/\{user_id\}/g, user_id);
$(".no-approvers").remove();
$(".approver-list").append(approver_item_html);
return false;
});
});
<script>
/* global BoardService, WeightSelect */
/* global BoardService */
import '~/weight_select';
import WeightSelect from 'ee/weight_select';
import loadingIcon from '~/vue_shared/components/loading_icon.vue';
const ANY_WEIGHT = 'Any Weight';
......
......@@ -24,15 +24,12 @@ import projectAvatar from './project_avatar';
import MergeRequest from './merge_request';
import Compare from './compare';
import initCompareAutocomplete from './compare_autocomplete';
/* global PathLocks */
import ProjectFindFile from './project_find_file';
import ProjectNew from './project_new';
import projectImport from './project_import';
import Labels from './labels';
import LabelManager from './label_manager';
import Sidebar from './right_sidebar';
/* global WeightSelect */
/* global AdminEmailSelect */
import IssuableTemplateSelectors from './templates/issuable_template_selectors';
import Flash from './flash';
......@@ -99,10 +96,15 @@ import SearchAutocomplete from './search_autocomplete';
import Activities from './activities';
// EE-only
import ApproversSelect from './approvers_select';
import AuditLogs from './audit_logs';
import initGeoInfoModal from './init_geo_info_modal';
import initGroupAnalytics from './init_group_analytics';
import ApproversSelect from 'ee/approvers_select'; // eslint-disable-line import/first
import AuditLogs from 'ee/audit_logs'; // eslint-disable-line import/first
import initGeoInfoModal from 'ee/init_geo_info_modal'; // eslint-disable-line import/first
import initGroupAnalytics from 'ee/init_group_analytics'; // eslint-disable-line import/first
import AdminEmailSelect from 'ee/admin_email_select'; // eslint-disable-line import/first
import initPathLocks from 'ee/path_locks'; // eslint-disable-line import/first
import WeightSelect from 'ee/weight_select'; // eslint-disable-line import/first
import initApprovals from 'ee/approvals'; // eslint-disable-line import/first
import initLDAPGroupsSelect from 'ee/ldap_groups_select'; // eslint-disable-line import/first
(function() {
var Dispatcher;
......@@ -146,7 +148,7 @@ import initGroupAnalytics from './init_group_analytics';
path,
} = JSON.parse(dataEl.innerHTML);
PathLocks.init(toggle_path, path);
initPathLocks(toggle_path, path);
}
}
......@@ -323,6 +325,8 @@ import initGroupAnalytics from './init_group_analytics';
new MilestoneSelect();
new IssuableTemplateSelectors();
new AutoWidthDropdownSelect($('.js-target-branch-select')).init();
initApprovals();
break;
case 'projects:tags:new':
new ZenMode();
......@@ -492,7 +496,7 @@ import initGroupAnalytics from './init_group_analytics';
new NewCommitForm($('.js-create-dir-form'));
if (document.querySelector('.js-tree-content').dataset.pathLocksAvailable === 'true') {
PathLocks.init(
initPathLocks(
document.querySelector('.js-tree-content').dataset.pathLocksToggle,
document.querySelector('.js-tree-content').dataset.pathLocksPath,
);
......@@ -653,6 +657,9 @@ import initGroupAnalytics from './init_group_analytics';
case 'groups:analytics:show':
initGroupAnalytics();
break;
case 'groups:ldap_group_links:index':
initLDAPGroupsSelect();
break;
}
switch (path[0]) {
case 'sessions':
......@@ -679,6 +686,13 @@ import initGroupAnalytics from './init_group_analytics';
break;
case 'groups':
new UsersSelect();
switch (path[2]) {
case 'edit':
initLDAPGroupsSelect();
break;
}
break;
case 'projects':
document.querySelectorAll('.js-namespace-select')
......
/* eslint-disable no-new */
/* global MilestoneSelect */
/* global WeightSelect */
import LabelsSelect from './labels_select';
import IssuableContext from './issuable_context';
import Sidebar from './right_sidebar';
import DueDateSelectors from './due_date_select';
import WeightSelect from 'ee/weight_select'; // eslint-disable-line import/first
export default () => {
const sidebarOptions = JSON.parse(document.querySelector('.js-sidebar-options').innerHTML);
......
/* eslint-disable no-new */
import LabelsSelect from './labels_select';
/* global MilestoneSelect */
/* global WeightSelect */
import subscriptionSelect from './subscription_select';
import UsersSelect from './users_select';
import issueStatusSelect from './issue_status_select';
import WeightSelect from 'ee/weight_select'; // eslint-disable-line import/first
export default () => {
new UsersSelect();
new LabelsSelect();
......
/* eslint-disable space-before-function-paren, prefer-arrow-callback, no-var, one-var, one-var-declaration-per-line, object-shorthand, quotes, comma-dangle, consistent-return, no-unused-vars, padded-blocks, func-names, max-len */
import Api from './api';
(function() {
$(function() {
var groupFormatSelection, ldapGroupResult;
ldapGroupResult = function(group) {
return group.cn;
};
groupFormatSelection = function(group) {
return group.cn;
};
$('.ajax-ldap-groups-select').each(function(i, select) {
return $(select).select2({
id: function(group) {
return group.cn;
},
placeholder: "Search for a LDAP group",
minimumInputLength: 1,
query: function(query) {
var provider;
provider = $('#ldap_group_link_provider').val();
return Api.ldap_groups(query.term, provider, function(groups) {
var data;
data = {
results: groups
};
return query.callback(data);
});
},
initSelection: function(element, callback) {
var id;
id = $(element).val();
if (id !== "") {
return callback({
cn: id
});
}
},
formatResult: ldapGroupResult,
formatSelection: groupFormatSelection,
dropdownCssClass: "ajax-groups-dropdown",
formatNoMatches: function(nomatch) {
return "Match not found; try refining your search query.";
}
});
});
return $('#ldap_group_link_provider').on('change', function() {
return $('.ajax-ldap-groups-select').select2('data', null);
});
});
}).call(window);
......@@ -52,13 +52,7 @@ import './render_gfm';
import initBreadcrumbs from './breadcrumb';
// EE-only scripts
import './admin_email_select';
import './application_settings';
import './approvals';
import './ee_trial_banner';
import './ldap_groups_select';
import './path_locks';
import './weight_select';
import initEETrialBanner from 'ee/ee_trial_banner';
import './dispatcher';
......@@ -295,4 +289,7 @@ $(function () {
removeFlashClickListener(flashEl);
});
}
// EE specific calls
initEETrialBanner();
});
/* eslint-disable space-before-function-paren, wrap-iife, one-var, no-var, one-var-declaration-per-line, no-unused-vars, object-shorthand, comma-dangle, prefer-arrow-callback, padded-blocks, func-names, max-len */
(function() {
this.PathLocks = (function() {
function PathLocks() {}
PathLocks.init = function(url, path) {
return $('a.path-lock').on('click', function(e) {
var $lockBtn, currentState, toggleAction;
e.preventDefault();
$lockBtn = $(this);
currentState = $lockBtn.data('state');
toggleAction = currentState === 'lock' ? 'unlock' : 'lock';
return $.post(url, {
path: path
}, function() {
location.reload();
});
});
};
return PathLocks;
})();
}).call(window);
/* eslint-disable space-before-function-paren, wrap-iife, prefer-arrow-callback, max-len, one-var, no-var, one-var-declaration-per-line, object-shorthand, comma-dangle, no-shadow, quotes, no-unused-vars, no-else-return, consistent-return, no-param-reassign, prefer-template, padded-blocks, func-names */
(function() {
this.WeightSelect = (function() {
function WeightSelect(els, options = {}) {
const $els = $(els || '.js-weight-select');
$els.each(function(i, dropdown) {
var $block, $dropdown, $loading, $selectbox, $sidebarCollapsedValue, $value, abilityName, updateUrl, updateWeight;
$dropdown = $(dropdown);
updateUrl = $dropdown.data('issueUpdate');
$selectbox = $dropdown.closest('.selectbox');
$block = $selectbox.closest('.block');
$sidebarCollapsedValue = $block.find('.sidebar-collapsed-icon span');
$value = $block.find('.value');
abilityName = $dropdown.data('ability-name');
$loading = $block.find('.block-loading').fadeOut();
const fieldName = options.fieldName || $dropdown.data("field-name");
const inputField = $dropdown.closest('.selectbox').find(`input[name='${fieldName}']`);
if (Object.keys(options).includes('selected')) {
inputField.val(options.selected);
}
updateWeight = function(selected) {
var data;
data = {};
data[abilityName] = {};
data[abilityName].weight = selected != null ? selected : null;
$loading.fadeIn();
$dropdown.trigger('loading.gl.dropdown');
return $.ajax({
type: 'PUT',
dataType: 'json',
url: updateUrl,
data: data
}).done(function(data) {
$dropdown.trigger('loaded.gl.dropdown');
$loading.fadeOut();
$selectbox.hide();
if (data.weight != null) {
$value.html(`<strong>${data.weight}</strong>`);
} else {
$value.html('<span class="no-value">None</span>');
}
return $sidebarCollapsedValue.html(data.weight);
});
};
return $dropdown.glDropdown({
selectable: true,
fieldName,
toggleLabel: function (selected, el) {
return $(el).data("id");
},
hidden: function(e) {
$selectbox.hide();
return $value.css('display', '');
},
id: function(obj, el) {
if ($(el).data("none") == null) {
return $(el).data("id");
} else {
return '';
}
},
clicked: function(glDropdownEvt) {
const e = glDropdownEvt.e;
let selected = glDropdownEvt.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-filter-submit")) {
return $(dropdown).parents('form').submit();
} else if ($dropdown.is('.js-issuable-form-weight')) {
e.preventDefault();
} else {
selected = inputField.val();
return updateWeight(selected);
}
}
});
});
}
return WeightSelect;
})();
}).call(window);
/* eslint-disable no-var, wrap-iife, func-names, space-before-function-paren, camelcase, no-unused-vars, quotes, object-shorthand, one-var, one-var-declaration-per-line, prefer-arrow-callback, comma-dangle, prefer-template, no-else-return, yoda, prefer-rest-params, prefer-spread, max-len */
import Api from '~/api';
var slice = [].slice;
function AdminEmailSelect() {
$('.ajax-admin-email-select').each((function(_this) {
return function(i, select) {
var skip_ldap;
skip_ldap = $(select).hasClass('skip_ldap');
return $(select).select2({
placeholder: "Select group or project",
multiple: $(select).hasClass('multiselect'),
minimumInputLength: 0,
query: function(query) {
var group_result, project_result;
group_result = Api.groups(query.term, {}, function(groups) {
return groups;
});
project_result = Api.projects(query.term, {
order_by: 'id',
membership: false
}, function(projects) {
return projects;
});
return $.when(project_result, group_result).done(function(projects, groups) {
var all, data;
all = {
id: "all"
};
data = [all].concat(groups[0], projects[0]);
return query.callback({
results: data
});
});
},
id: function(object) {
if (object.path_with_namespace) {
return "project-" + object.id;
} else if (object.path) {
return "group-" + object.id;
} else {
return "all";
}
},
formatResult: function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return _this.formatResult.apply(_this, args);
},
formatSelection: function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return _this.formatSelection.apply(_this, args);
},
dropdownCssClass: "ajax-admin-email-dropdown",
escapeMarkup: function(m) {
return m;
}
});
};
})(this));
}
AdminEmailSelect.prototype.formatResult = function(object) {
if (object.path_with_namespace) {
return "<div class='project-result'> <div class='project-name'>" + object.name + "</div> <div class='project-path'>" + object.path_with_namespace + "</div> </div>";
} else if (object.path) {
return "<div class='group-result'> <div class='group-name'>" + object.name + "</div> <div class='group-path'>" + object.path + "</div> </div>";
} else {
return "<div class='group-result'> <div class='group-name'>All</div> <div class='group-path'>All groups and projects</div> </div>";
}
};
AdminEmailSelect.prototype.formatSelection = function(object) {
if (object.path_with_namespace) {
return "Project: " + object.name;
} else if (object.path) {
return "Group: " + object.name;
} else {
return "All groups and projects";
}
};
export default AdminEmailSelect;
export default () => {
$('.approver-list').on('click', '.unsaved-approvers.approver .btn-remove', function approverListClickCallback(ev) {
const removeElement = $(this).closest('li');
const approverId = parseInt(removeElement.attr('id').replace('user_', ''), 10);
const approverIds = $('input#merge_request_approver_ids');
const skipUsers = approverIds.data('skip-users') || [];
const approverIndex = skipUsers.indexOf(approverId);
removeElement.remove();
if (approverIndex > -1) {
approverIds.data('skip-users', skipUsers.splice(approverIndex, 1));
}
ev.preventDefault();
});
$('.approver-list').on('click', '.unsaved-approvers.approver-group .btn-remove', function approverListRemoveClickCallback(ev) {
const removeElement = $(this).closest('li');
const approverGroupId = parseInt(removeElement.attr('id').replace('group_', ''), 10);
const approverGroupIds = $('input#merge_request_approver_group_ids');
const skipGroups = approverGroupIds.data('skip-groups') || [];
const approverGroupIndex = skipGroups.indexOf(approverGroupId);
removeElement.remove();
if (approverGroupIndex > -1) {
approverGroupIds.data('skip-groups', skipGroups.splice(approverGroupIndex, 1));
}
ev.preventDefault();
});
$('form.merge-request-form').on('submit', function mergeRequestFormSubmitCallback() {
if ($('input#merge_request_approver_ids').length) {
let approverIds = $.map($('li.unsaved-approvers.approver').not('.approver-template'), li => li.id.replace('user_', ''));
const approversInput = $(this).find('input#merge_request_approver_ids');
approverIds = approverIds.concat(approversInput.val().split(','));
approversInput.val(_.compact(approverIds).join(','));
}
if ($('input#merge_request_approver_group_ids').length) {
let approverGroupIds = $.map($('li.unsaved-approvers.approver-group'), li => li.id.replace('group_', ''));
const approverGroupsInput = $(this).find('input#merge_request_approver_group_ids');
approverGroupIds = approverGroupIds.concat(approverGroupsInput.val().split(','));
approverGroupsInput.val(_.compact(approverGroupIds).join(','));
}
});
$('.suggested-approvers a').on('click', function sugestedApproversClickCallback() {
const userId = this.id.replace('user_', '');
const username = this.text;
if ($(`.approver-list #user_${userId}`).length) {
return false;
}
const approverItemHTML = $('.unsaved-approvers.approver-template').clone()
.removeClass('hide approver-template')[0]
.outerHTML.replace(/\{approver_name\}/g, username).replace(/\{user_id\}/g, userId);
$('.no-approvers').remove();
$('.approver-list').append(approverItemHTML);
return false;
});
};
import Api from './api';
import Api from '~/api';
export default class ApproversSelect {
constructor() {
......
/* eslint-disable class-methods-use-this, no-unneeded-ternary, quote-props, no-new */
import UsersSelect from './users_select';
import groupsSelect from './groups_select';
import projectSelect from './project_select';
import UsersSelect from '~/users_select';
import groupsSelect from '~/groups_select';
import projectSelect from '~/project_select';
class AuditLogs {
constructor() {
......
import EETrialBanner from './ee_trial_banner';
$(() => {
export default function initEETrialBanner() {
const $trialBanner = $('.js-gitlab-ee-license-banner');
if ($trialBanner.length) {
const eeTrialBanner = new EETrialBanner($trialBanner);
eeTrialBanner.init();
}
});
}
/* eslint-disable space-before-function-paren, prefer-arrow-callback, no-var, one-var, one-var-declaration-per-line, object-shorthand, quotes, comma-dangle, consistent-return, no-unused-vars, padded-blocks, func-names, max-len */
import Api from '~/api';
export default function initLDAPGroupsSelect() {
var groupFormatSelection, ldapGroupResult;
ldapGroupResult = function(group) {
return group.cn;
};
groupFormatSelection = function(group) {
return group.cn;
};
$('.ajax-ldap-groups-select').each(function(i, select) {
return $(select).select2({
id: function(group) {
return group.cn;
},
placeholder: "Search for a LDAP group",
minimumInputLength: 1,
query: function(query) {
var provider;
provider = $('#ldap_group_link_provider').val();
return Api.ldap_groups(query.term, provider, function(groups) {
var data;
data = {
results: groups
};
return query.callback(data);
});
},
initSelection: function(element, callback) {
var id;
id = $(element).val();
if (id !== "") {
return callback({
cn: id
});
}
},
formatResult: ldapGroupResult,
formatSelection: groupFormatSelection,
dropdownCssClass: "ajax-groups-dropdown",
formatNoMatches: function(nomatch) {
return "Match not found; try refining your search query.";
}
});
});
return $('#ldap_group_link_provider').on('change', function() {
return $('.ajax-ldap-groups-select').select2('data', null);
});
}
export default function initPathLocks(url, path) {
$('a.path-lock').on('click', (e) => {
e.preventDefault();
$.post(url, {
path,
}, () => {
location.reload();
});
});
}
/* eslint-disable space-before-function-paren, wrap-iife, prefer-arrow-callback, max-len, one-var, no-var, one-var-declaration-per-line, object-shorthand, comma-dangle, no-shadow, quotes, no-unused-vars, no-else-return, consistent-return, no-param-reassign, prefer-template, padded-blocks, func-names */
function WeightSelect(els, options = {}) {
const $els = $(els || '.js-weight-select');
$els.each(function(i, dropdown) {
var $block, $dropdown, $loading, $selectbox, $sidebarCollapsedValue, $value, abilityName, updateUrl, updateWeight;
$dropdown = $(dropdown);
updateUrl = $dropdown.data('issueUpdate');
$selectbox = $dropdown.closest('.selectbox');
$block = $selectbox.closest('.block');
$sidebarCollapsedValue = $block.find('.sidebar-collapsed-icon span');
$value = $block.find('.value');
abilityName = $dropdown.data('ability-name');
$loading = $block.find('.block-loading').fadeOut();
const fieldName = options.fieldName || $dropdown.data("field-name");
const inputField = $dropdown.closest('.selectbox').find(`input[name='${fieldName}']`);
if (Object.keys(options).includes('selected')) {
inputField.val(options.selected);
}
updateWeight = function(selected) {
var data;
data = {};
data[abilityName] = {};
data[abilityName].weight = selected != null ? selected : null;
$loading.fadeIn();
$dropdown.trigger('loading.gl.dropdown');
return $.ajax({
type: 'PUT',
dataType: 'json',
url: updateUrl,
data: data
}).done(function(data) {
$dropdown.trigger('loaded.gl.dropdown');
$loading.fadeOut();
$selectbox.hide();
if (data.weight != null) {
$value.html(`<strong>${data.weight}</strong>`);
} else {
$value.html('<span class="no-value">None</span>');
}
return $sidebarCollapsedValue.html(data.weight);
});
};
return $dropdown.glDropdown({
selectable: true,
fieldName,
toggleLabel: function (selected, el) {
return $(el).data("id");
},
hidden: function(e) {
$selectbox.hide();
return $value.css('display', '');
},
id: function(obj, el) {
if ($(el).data("none") == null) {
return $(el).data("id");
} else {
return '';
}
},
clicked: function(glDropdownEvt) {
const e = glDropdownEvt.e;
let selected = glDropdownEvt.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-filter-submit")) {
return $(dropdown).parents('form').submit();
} else if ($dropdown.is('.js-issuable-form-weight')) {
e.preventDefault();
} else {
selected = inputField.val();
return updateWeight(selected);
}
}
});
});
}
export default WeightSelect;
import ApproversSelect from '~/approvers_select';
import ApproversSelect from 'ee/approvers_select';
import ClassSpecHelper from './helpers/class_spec_helper';
describe('ApproversSelect', () => {
......
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