diff options
author | Nick Thomas <nick@gitlab.com> | 2018-08-14 22:32:24 +0100 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-08-15 07:38:18 +0100 |
commit | 3422cca4b731cf9786822a5971dc1ada308c1b16 (patch) | |
tree | 6d1164e9a2d401e7d393065674c4f44e1140a9b5 /app/assets | |
parent | f6f6295027a5040f27a8cbb2b979d16b445a284b (diff) | |
download | gitlab-ce-3422cca4b731cf9786822a5971dc1ada308c1b16.tar.gz |
Allow the project_select_tag to specify an initial value and for the selection to be clear-able
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/project_select.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/assets/javascripts/project_select.js b/app/assets/javascripts/project_select.js index bce7556bd40..6f3b32f8eea 100644 --- a/app/assets/javascripts/project_select.js +++ b/app/assets/javascripts/project_select.js @@ -14,6 +14,7 @@ export default function projectSelect() { this.orderBy = $(select).data('orderBy') || 'id'; this.withIssuesEnabled = $(select).data('withIssuesEnabled'); this.withMergeRequestsEnabled = $(select).data('withMergeRequestsEnabled'); + this.allowClear = $(select).data('allowClear') || false; placeholder = "Search for project"; if (this.includeGroups) { @@ -71,6 +72,13 @@ export default function projectSelect() { text: function (project) { return project.name_with_namespace || project.name; }, + + initSelection: function(el, callback) { + return Api.project(el.val()).then(({ data }) => callback(data)); + }, + + allowClear: this.allowClear, + dropdownCssClass: "ajax-project-dropdown" }); if (simpleFilter) return select; |