Commit d79c0ea2 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Allow set labels from Issue/MR forms

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent d45a6b29
...@@ -152,7 +152,7 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -152,7 +152,7 @@ class Projects::IssuesController < Projects::ApplicationController
def issue_params def issue_params
params.require(:issue).permit( params.require(:issue).permit(
:title, :assignee_id, :position, :description, :title, :assignee_id, :position, :description,
:milestone_id, :label_list, :state_event :milestone_id, :state_event, label_ids: []
) )
end end
end end
...@@ -242,7 +242,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -242,7 +242,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
params.require(:merge_request).permit( params.require(:merge_request).permit(
:title, :assignee_id, :source_project_id, :source_branch, :title, :assignee_id, :source_project_id, :source_branch,
:target_project_id, :target_branch, :milestone_id, :target_project_id, :target_branch, :milestone_id,
:state_event, :description, :label_list :state_event, :description, label_ids: []
) )
end end
end end
...@@ -44,14 +44,11 @@ ...@@ -44,14 +44,11 @@
.col-sm-10= f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone" }, {class: 'select2'}) .col-sm-10= f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone" }, {class: 'select2'})
.form-group .form-group
= f.label :label_list, class: 'control-label' do = f.label :label_ids, class: 'control-label' do
%i.icon-tag %i.icon-tag
Labels Labels
.col-sm-10 .col-sm-10
= f.text_field :label_list, maxlength: 2000, class: "form-control" = f.collection_select :label_ids, @project.labels.all, :id, :name, { selected: @issue.label_ids }, multiple: true, class: 'select2'
%p.hint Separate labels with commas.
.form-actions .form-actions
- if @issue.new_record? - if @issue.new_record?
...@@ -63,35 +60,6 @@ ...@@ -63,35 +60,6 @@
= link_to "Cancel", cancel_path, class: 'btn btn-cancel' = link_to "Cancel", cancel_path, class: 'btn btn-cancel'
:javascript :javascript
$("#issue_label_list")
.bind( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).data( "autocomplete" ).menu.active ) {
event.preventDefault();
}
})
.bind("click", function(event) {
$(this).autocomplete("search", "");
})
.autocomplete({
minLength: 0,
source: function( request, response ) {
response( $.ui.autocomplete.filter(
#{raw labels_autocomplete_source}, extractLast( request.term ) ) );
},
focus: function() {
return false;
},
select: function(event, ui) {
var terms = split( this.value );
terms.pop();
terms.push( ui.item.value );
terms.push( "" );
this.value = terms.join( ", " );
return false;
}
});
$('.assign-to-me-link').on('click', function(e){ $('.assign-to-me-link').on('click', function(e){
$('#issue_assignee_id').val("#{current_user.id}").trigger("change"); $('#issue_assignee_id').val("#{current_user.id}").trigger("change");
e.preventDefault(); e.preventDefault();
......
...@@ -46,14 +46,12 @@ ...@@ -46,14 +46,12 @@
.col-sm-10= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'select2'}) .col-sm-10= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'select2'})
- if @merge_request.persisted? # Only allow labels on edit to avoid fork vs upstream repo labels issue
.form-group .form-group
= f.label :label_list, class: 'control-label' do = f.label :label_ids, class: 'control-label' do
%i.icon-tag %i.icon-tag
Labels Labels
.col-sm-10 .col-sm-10
= f.text_field :label_list, maxlength: 2000, class: "form-control" = f.collection_select :label_ids, @merge_request.target_project.labels.all, :id, :name, { selected: @merge_request.label_ids }, multiple: true, class: 'select2'
%p.hint Separate labels with commas.
.form-actions .form-actions
- if @merge_request.new_record? - if @merge_request.new_record?
...@@ -74,33 +72,4 @@ ...@@ -74,33 +72,4 @@
e.preventDefault(); e.preventDefault();
}); });
$("#merge_request_label_list")
.bind( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).data( "autocomplete" ).menu.active ) {
event.preventDefault();
}
})
.bind("click", function(event) {
$(this).autocomplete("search", "");
})
.autocomplete({
minLength: 0,
source: function( request, response ) {
response( $.ui.autocomplete.filter(
#{raw labels_autocomplete_source}, extractLast( request.term ) ) );
},
focus: function() {
return false;
},
select: function(event, ui) {
var terms = split( this.value );
terms.pop();
terms.push( ui.item.value );
terms.push( "" );
this.value = terms.join( ", " );
return false;
}
});
window.project_image_path_upload = "#{upload_image_project_path @project}"; window.project_image_path_upload = "#{upload_image_project_path @project}";
...@@ -43,6 +43,13 @@ ...@@ -43,6 +43,13 @@
%i.icon-time %i.icon-time
Milestone Milestone
%div= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'select2'}) %div= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'select2'})
.form-group
= f.label :label_ids do
%i.icon-tag
Labels
%div
= f.collection_select :label_ids, @merge_request.target_project.labels.all, :id, :name, { selected: @merge_request.label_ids }, multiple: true, class: 'select2'
.panel-footer .panel-footer
- if contribution_guide_url(@target_project) - if contribution_guide_url(@target_project)
%p %p
......
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