Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
af5e54f9
Commit
af5e54f9
authored
Sep 22, 2016
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert label creation from API to controller endpoint
parent
fd51f19c
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
26 additions
and
18 deletions
+26
-18
app/assets/javascripts/api.js
app/assets/javascripts/api.js
+5
-4
app/assets/javascripts/boards/components/new_list_dropdown.js.es6
...ts/javascripts/boards/components/new_list_dropdown.js.es6
+1
-2
app/assets/javascripts/create_label.js.es6
app/assets/javascripts/create_label.js.es6
+5
-4
app/assets/javascripts/labels_select.js
app/assets/javascripts/labels_select.js
+4
-3
app/controllers/projects/labels_controller.rb
app/controllers/projects/labels_controller.rb
+8
-2
app/views/shared/issuable/_filter.html.haml
app/views/shared/issuable/_filter.html.haml
+1
-1
app/views/shared/issuable/_label_dropdown.html.haml
app/views/shared/issuable/_label_dropdown.html.haml
+1
-1
app/views/shared/issuable/_sidebar.html.haml
app/views/shared/issuable/_sidebar.html.haml
+1
-1
No files found.
app/assets/javascripts/api.js
View file @
af5e54f9
...
...
@@ -5,7 +5,7 @@
namespacesPath
:
"
/api/:version/namespaces.json
"
,
groupProjectsPath
:
"
/api/:version/groups/:id/projects.json
"
,
projectsPath
:
"
/api/:version/projects.json?simple=true
"
,
labelsPath
:
"
/
api/:version/projects/:id
/labels
"
,
labelsPath
:
"
/
:namespace_path/:project_path
/labels
"
,
licensePath
:
"
/api/:version/licenses/:key
"
,
gitignorePath
:
"
/api/:version/gitignores/:key
"
,
gitlabCiYmlPath
:
"
/api/:version/gitlab_ci_ymls/:key
"
,
...
...
@@ -65,13 +65,14 @@
return
callback
(
projects
);
});
},
newLabel
:
function
(
project_id
,
data
,
callback
)
{
newLabel
:
function
(
namespace_path
,
project_path
,
data
,
callback
)
{
var
url
=
Api
.
buildUrl
(
Api
.
labelsPath
)
.
replace
(
'
:id
'
,
project_id
);
.
replace
(
'
:namespace_path
'
,
namespace_path
)
.
replace
(
'
:project_path
'
,
project_path
);
return
$
.
ajax
({
url
:
url
,
type
:
"
POST
"
,
data
:
data
,
data
:
{
'
label
'
:
data
}
,
dataType
:
"
json
"
}).
done
(
function
(
label
)
{
return
callback
(
label
);
...
...
app/assets/javascripts/boards/components/new_list_dropdown.js.es6
View file @
af5e54f9
...
...
@@ -3,8 +3,7 @@ $(() => {
$('.js-new-board-list').each(function () {
const $this = $(this);
new gl.CreateLabelDropdown($this.closest('.dropdown').find('.dropdown-new-label'), $this.data('project-id'));
new gl.CreateLabelDropdown($this.closest('.dropdown').find('.dropdown-new-label'), $this.data('namespace-path'), $this.data('project-path'));
$this.glDropdown({
data(term, callback) {
...
...
app/assets/javascripts/create_label.js.es6
View file @
af5e54f9
(function (w) {
class CreateLabelDropdown {
constructor ($el,
projectId
) {
constructor ($el,
namespacePath, projectPath
) {
this.$el = $el;
this.projectId = projectId;
this.namespacePath = namespacePath;
this.projectPath = projectPath;
this.$dropdownBack = $('.dropdown-menu-back', this.$el.closest('.dropdown'));
this.$cancelButton = $('.js-cancel-label-btn', this.$el);
this.$newLabelField = $('#new_label_name', this.$el);
...
...
@@ -91,8 +92,8 @@
e.preventDefault();
e.stopPropagation();
Api.newLabel(this.
projectId
, {
nam
e: this.$newLabelField.val(),
Api.newLabel(this.
namespacePath, this.projectPath
, {
titl
e: this.$newLabelField.val(),
color: this.$newColorField.val()
}, (label) => {
this.$newLabelCreateButton.enable();
...
...
app/assets/javascripts/labels_select.js
View file @
af5e54f9
...
...
@@ -4,9 +4,10 @@
var
_this
;
_this
=
this
;
$
(
'
.js-label-select
'
).
each
(
function
(
i
,
dropdown
)
{
var
$block
,
$colorPreview
,
$dropdown
,
$form
,
$loading
,
$selectbox
,
$sidebarCollapsedValue
,
$value
,
abilityName
,
defaultLabel
,
enableLabelCreateButton
,
issueURLSplit
,
issueUpdateURL
,
labelHTMLTemplate
,
labelNoneHTMLTemplate
,
labelUrl
,
projectId
,
saveLabelData
,
selectedLabel
,
showAny
,
showNo
,
$sidebarLabelTooltip
;
var
$block
,
$colorPreview
,
$dropdown
,
$form
,
$loading
,
$selectbox
,
$sidebarCollapsedValue
,
$value
,
abilityName
,
defaultLabel
,
enableLabelCreateButton
,
issueURLSplit
,
issueUpdateURL
,
labelHTMLTemplate
,
labelNoneHTMLTemplate
,
labelUrl
,
namespacePath
,
projectPath
,
saveLabelData
,
selectedLabel
,
showAny
,
showNo
,
$sidebarLabelTooltip
;
$dropdown
=
$
(
dropdown
);
projectId
=
$dropdown
.
data
(
'
project-id
'
);
namespacePath
=
$dropdown
.
data
(
'
namespace-path
'
);
projectPath
=
$dropdown
.
data
(
'
project-path
'
);
labelUrl
=
$dropdown
.
data
(
'
labels
'
);
issueUpdateURL
=
$dropdown
.
data
(
'
issueUpdate
'
);
selectedLabel
=
$dropdown
.
data
(
'
selected
'
);
...
...
@@ -35,7 +36,7 @@
$sidebarLabelTooltip
.
tooltip
();
if
(
$dropdown
.
closest
(
'
.dropdown
'
).
find
(
'
.dropdown-new-label
'
).
length
)
{
new
gl
.
CreateLabelDropdown
(
$dropdown
.
closest
(
'
.dropdown
'
).
find
(
'
.dropdown-new-label
'
),
projectId
);
new
gl
.
CreateLabelDropdown
(
$dropdown
.
closest
(
'
.dropdown
'
).
find
(
'
.dropdown-new-label
'
),
namespacePath
,
projectPath
);
}
saveLabelData
=
function
()
{
...
...
app/controllers/projects/labels_controller.rb
View file @
af5e54f9
...
...
@@ -30,9 +30,15 @@ class Projects::LabelsController < Projects::ApplicationController
@label
=
@project
.
labels
.
create
(
label_params
)
if
@label
.
valid?
redirect_to
namespace_project_labels_path
(
@project
.
namespace
,
@project
)
respond_to
do
|
format
|
format
.
html
{
redirect_to
namespace_project_labels_path
(
@project
.
namespace
,
@project
)
}
format
.
json
{
render
json:
@label
}
end
else
render
'new'
respond_to
do
|
format
|
format
.
html
{
render
'new'
}
format
.
json
{
render
json:
{
message:
@label
.
errors
.
messages
},
status:
400
}
end
end
end
...
...
app/views/shared/issuable/_filter.html.haml
View file @
af5e54f9
...
...
@@ -37,7 +37,7 @@
%input
.pull-left.form-control
{
type:
"search"
,
placeholder:
"Filter by name..."
,
"v-model"
=>
"filters.search"
,
"debounce"
=>
"250"
}
-
if
can?
(
current_user
,
:admin_list
,
@project
)
.dropdown.pull-right
%button
.btn.btn-create.js-new-board-list
{
type:
"button"
,
data:
{
toggle:
"dropdown"
,
labels:
labels_filter_path
,
project_id:
@project
.
try
(
:id
)
}
}
%button
.btn.btn-create.js-new-board-list
{
type:
"button"
,
data:
{
toggle:
"dropdown"
,
labels:
labels_filter_path
,
namespace_path:
@project
.
try
(
:namespace
).
try
(
:path
),
project_path:
@project
.
try
(
:path
)
}
}
Create new list
.dropdown-menu.dropdown-menu-paging.dropdown-menu-align-right.dropdown-menu-issues-board-new.dropdown-menu-selectable
=
render
partial:
"shared/issuable/label_page_default"
,
locals:
{
show_footer:
true
,
show_create:
true
,
show_boards_content:
true
,
title:
"Create a new list"
}
...
...
app/views/shared/issuable/_label_dropdown.html.haml
View file @
af5e54f9
...
...
@@ -4,7 +4,7 @@
-
show_footer
=
local_assigns
.
fetch
(
:show_footer
,
true
)
-
data_options
=
local_assigns
.
fetch
(
:data_options
,
{})
-
classes
=
local_assigns
.
fetch
(
:classes
,
[])
-
dropdown_data
=
{
toggle:
'dropdown'
,
field_name:
'label_name[]'
,
show_no:
"true"
,
show_any:
"true"
,
selected:
params
[
:label_name
],
project_id:
@project
.
try
(
:id
),
labels:
labels_filter_path
,
default_label:
"Label"
}
-
dropdown_data
=
{
toggle:
'dropdown'
,
field_name:
'label_name[]'
,
show_no:
"true"
,
show_any:
"true"
,
selected:
params
[
:label_name
],
namespace_path:
@project
.
try
(
:namespace
).
try
(
:path
),
project_path:
@project
.
try
(
:path
),
labels:
labels_filter_path
,
default_label:
"Label"
}
-
dropdown_data
.
merge!
(
data_options
)
-
classes
<<
'js-extra-options'
if
extra_options
-
classes
<<
'js-filter-submit'
if
filter_submit
...
...
app/views/shared/issuable/_sidebar.html.haml
View file @
af5e54f9
...
...
@@ -128,7 +128,7 @@
-
issuable
.
labels_array
.
each
do
|
label
|
=
hidden_field_tag
"
#{
issuable
.
to_ability_name
}
[label_names][]"
,
label
.
id
,
id:
nil
.dropdown
%button
.dropdown-menu-toggle.js-label-select.js-multiselect
{
type:
"button"
,
data:
{
toggle:
"dropdown"
,
field_name:
"#{issuable.to_ability_name}[label_names][]"
,
ability_name:
issuable
.
to_ability_name
,
show_no:
"true"
,
show_any:
"true"
,
project_id:
(
@project
.
id
if
@project
),
issue_update:
issuable_json_path
(
issuable
),
labels:
(
namespace_project_labels_path
(
@project
.
namespace
,
@project
,
:json
)
if
@project
)}}
%button
.dropdown-menu-toggle.js-label-select.js-multiselect
{
type:
"button"
,
data:
{
toggle:
"dropdown"
,
field_name:
"#{issuable.to_ability_name}[label_names][]"
,
ability_name:
issuable
.
to_ability_name
,
show_no:
"true"
,
show_any:
"true"
,
namespace_path:
@project
.
try
(
:namespace
).
try
(
:path
),
project_path:
@project
.
try
(
:path
),
issue_update:
issuable_json_path
(
issuable
),
labels:
(
namespace_project_labels_path
(
@project
.
namespace
,
@project
,
:json
)
if
@project
)}}
%span
.dropdown-toggle-text
Label
=
icon
(
'chevron-down'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment