[#369] new issue page: labels; small fixes
This commit is contained in:
parent
65498ca47b
commit
5a2c4896ad
|
@ -1,4 +1,19 @@
|
||||||
IssueController = (dataservice, $http, Issue, $rootScope, Preview) ->
|
IssueController = (dataservice, $http, Issue, $rootScope, Preview, Label) ->
|
||||||
|
|
||||||
|
getLabels = ->
|
||||||
|
promise = Label.get_labels(vm.project)
|
||||||
|
promise.then (response) ->
|
||||||
|
old_labels = vm.labels
|
||||||
|
vm.labels = response.data
|
||||||
|
_.each(vm.labels, (l) ->
|
||||||
|
_.each(old_labels, (ol) ->
|
||||||
|
if l.id is ol.id
|
||||||
|
l.selected = ol.selected
|
||||||
|
l.style = ol.style
|
||||||
|
l.selected_id = ol.selected_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
true
|
||||||
|
|
||||||
vm = this
|
vm = this
|
||||||
|
|
||||||
|
@ -22,6 +37,18 @@ IssueController = (dataservice, $http, Issue, $rootScope, Preview) ->
|
||||||
vm.processing = false
|
vm.processing = false
|
||||||
false
|
false
|
||||||
|
|
||||||
|
vm.toggleLabel = (label) ->
|
||||||
|
label.selected = !label.selected
|
||||||
|
if label.selected
|
||||||
|
label.style = label.default_style
|
||||||
|
label.selected_id = label.id
|
||||||
|
else
|
||||||
|
label.selected_id = null
|
||||||
|
label.style = {}
|
||||||
|
|
||||||
|
$rootScope.$on "updateLabels", (event, args) ->
|
||||||
|
getLabels()
|
||||||
|
|
||||||
init = (dataservice) ->
|
init = (dataservice) ->
|
||||||
vm.project = dataservice.project
|
vm.project = dataservice.project
|
||||||
vm.labels = dataservice.labels
|
vm.labels = dataservice.labels
|
||||||
|
@ -34,4 +61,4 @@ angular
|
||||||
.module("RosaABF")
|
.module("RosaABF")
|
||||||
.controller "IssueController", IssueController
|
.controller "IssueController", IssueController
|
||||||
|
|
||||||
IssueController.$inject = ['IssueInitializer', '$http', 'Issue', '$rootScope', 'Preview']
|
IssueController.$inject = ['IssueInitializer', '$http', 'Issue', '$rootScope', 'Preview', 'Label']
|
||||||
|
|
|
@ -73,7 +73,7 @@ IssuesController = (dataservice, $http, $location, Issue, $rootScope) ->
|
||||||
label.style = {}
|
label.style = {}
|
||||||
getIssues()
|
getIssues()
|
||||||
|
|
||||||
$rootScope.$on "updateIssues", (event, args) ->
|
$rootScope.$on "updateLabels", (event, args) ->
|
||||||
getIssues()
|
getIssues()
|
||||||
|
|
||||||
init = (dataservice) ->
|
init = (dataservice) ->
|
||||||
|
|
|
@ -31,7 +31,11 @@ labelService = ($http) ->
|
||||||
remove: (project, label) ->
|
remove: (project, label) ->
|
||||||
path = Routes.project_issues_delete_label_path(project, label.id)
|
path = Routes.project_issues_delete_label_path(project, label.id)
|
||||||
$http.post(path)
|
$http.post(path)
|
||||||
}
|
|
||||||
|
get_labels: (project) ->
|
||||||
|
path = Routes.project_labels_path(project)
|
||||||
|
$http.get(path)
|
||||||
|
}
|
||||||
|
|
||||||
angular
|
angular
|
||||||
.module("RosaABF")
|
.module("RosaABF")
|
||||||
|
|
|
@ -41,7 +41,7 @@ LabelsController = (dataservice, $http, Label, $rootScope, $scope) ->
|
||||||
promise.success( (data) ->
|
promise.success( (data) ->
|
||||||
vm.labels = data
|
vm.labels = data
|
||||||
vm.errors = []
|
vm.errors = []
|
||||||
$rootScope.$broadcast('updateIssues')
|
$rootScope.$broadcast('updateLabels')
|
||||||
).error( (data) ->
|
).error( (data) ->
|
||||||
vm.errors = data
|
vm.errors = data
|
||||||
)
|
)
|
||||||
|
@ -52,24 +52,24 @@ LabelsController = (dataservice, $http, Label, $rootScope, $scope) ->
|
||||||
return false unless confirmMessage()
|
return false unless confirmMessage()
|
||||||
promise = Label.remove(vm.project, l)
|
promise = Label.remove(vm.project, l)
|
||||||
promise.success (data) ->
|
promise.success (data) ->
|
||||||
$rootScope.$broadcast('updateIssues')
|
$rootScope.$broadcast('updateLabels')
|
||||||
|
|
||||||
false
|
false
|
||||||
|
|
||||||
|
|
||||||
init = (dataservice) ->
|
init = (dataservice) ->
|
||||||
vm.project = dataservice.project
|
vm.project = dataservice.project
|
||||||
vm.labels = dataservice.labels
|
vm.labels = dataservice.labels
|
||||||
vm.vis_manage_block = false
|
vm.is_collapsed_manage_block = true
|
||||||
|
|
||||||
vm.default_colors = Label.default_colors
|
vm.default_colors = Label.default_colors
|
||||||
vm.label = {
|
vm.label = {
|
||||||
id: null
|
id: null
|
||||||
name: null
|
name: null
|
||||||
color: vm.default_colors[0]
|
color: vm.default_colors[0]
|
||||||
}
|
}
|
||||||
vm.is_new_label = true
|
vm.is_new_label = true
|
||||||
vm.processing = false
|
vm.processing = false
|
||||||
|
|
||||||
init(dataservice)
|
init(dataservice)
|
||||||
true
|
true
|
||||||
|
|
|
@ -69,6 +69,10 @@ class Projects::IssuesController < Projects::BaseController
|
||||||
index
|
index
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def labels
|
||||||
|
render partial: 'projects/issues/labels.json', locals: {project: @project}, layout: false
|
||||||
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -145,10 +149,12 @@ class Projects::IssuesController < Projects::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_label
|
def destroy_label
|
||||||
if @label.destroy
|
respond_to do |format|
|
||||||
format.json { render partial: 'labels', locals: {project: @project} }
|
if @label.destroy
|
||||||
else
|
format.json { render partial: 'labels', locals: {project: @project} }
|
||||||
render json: @label.errors.full_messages, status: 422
|
else
|
||||||
|
format.json { render json: @label.errors.full_messages, status: 422 }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,8 @@ class Issue < ActiveRecord::Base
|
||||||
before_update :update_statistic
|
before_update :update_statistic
|
||||||
|
|
||||||
attr_accessible :labelings_attributes, :title, :body, :assignee_id
|
attr_accessible :labelings_attributes, :title, :body, :assignee_id
|
||||||
accepts_nested_attributes_for :labelings, allow_destroy: true
|
accepts_nested_attributes_for :labelings,
|
||||||
|
reject_if: lambda {|attributes| attributes['label_id'].blank?}
|
||||||
|
|
||||||
scope :opened, -> { where(status: [STATUS_OPEN, STATUS_REOPEN]) }
|
scope :opened, -> { where(status: [STATUS_OPEN, STATUS_REOPEN]) }
|
||||||
scope :closed, -> { where(status: STATUS_CLOSED) }
|
scope :closed, -> { where(status: STATUS_CLOSED) }
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
tabset
|
tabset
|
||||||
tab heading = t('layout.edit')
|
tab heading = t('layout.edit')
|
||||||
.offset10
|
.offset10
|
||||||
= f.input_field :body,
|
= f.input :body, label: false,
|
||||||
class: 'form-control',
|
input_html: { rows: 10 }
|
||||||
rows: 10,
|
|
||||||
'ng-model' => 'issueCtrl.body'
|
|
||||||
|
|
||||||
tab[ heading = t('layout.preview')
|
tab[ heading = t('layout.preview')
|
||||||
select = 'issueCtrl.previewBody()' ]
|
select = 'issueCtrl.previewBody()' ]
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
h4=t('layout.issues.labels')
|
||||||
ul.nav.nav-pills.nav-stacked
|
ul.nav.nav-pills.nav-stacked
|
||||||
li[ role = 'presentation' ng-repeat = 'label in issuesCtrl.labels' ]
|
li[ role = 'presentation' ng-repeat = 'label in issuesCtrl.labels' ]
|
||||||
a[ href = '#'
|
a[ href = '#'
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
=render 'title_body', f: f, id: 'new'
|
=render 'title_body', f: f, id: 'new'
|
||||||
|
= submit_tag t(@issue.new_record? ? 'layout.create' : 'layout.update'),
|
||||||
|
class: 'btn btn-primary',
|
||||||
|
data: {'disable-with' => t('layout.processing')}
|
||||||
|
|
||||||
/
|
/
|
||||||
- if can?(:write, @project)
|
- if can?(:write, @project)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
div ng-controller = 'LabelsController as labelsCtrl' ng-cloak = true
|
div ng-controller = 'LabelsController as labelsCtrl' ng-cloak = true
|
||||||
hr
|
hr
|
||||||
button.btn.btn-primary ng-click = 'labelsCtrl.vis_manage_block = !labelsCtrl.vis_manage_block'
|
button.btn.btn-primary[ ng-click = 'labelsCtrl.is_collapsed_manage_block = !labelsCtrl.is_collapsed_manage_block'
|
||||||
=t('layout.issues.label_manage')
|
type = 'button' ]= t('layout.issues.label_manage')
|
||||||
|
|
||||||
.offset5 ng-show = 'labelsCtrl.vis_manage_block'
|
.offset5 collapse = 'labelsCtrl.is_collapsed_manage_block'
|
||||||
.row ng-repeat = "label in labelsCtrl.labels"
|
.row ng-repeat = "label in labelsCtrl.labels"
|
||||||
.col-md-10
|
.col-md-10
|
||||||
.update-label.lpadding-5[ ng-style = 'label.default_style'
|
.update-label.lpadding-5[ ng-style = 'label.default_style'
|
||||||
|
@ -47,7 +47,7 @@ div ng-controller = 'LabelsController as labelsCtrl' ng-cloak = true
|
||||||
|
|
||||||
p.text-warning[ ng-repeat = 'error in labelsCtrl.errors' ] {{ error }}
|
p.text-warning[ ng-repeat = 'error in labelsCtrl.errors' ] {{ error }}
|
||||||
|
|
||||||
button.btn.btn-primary[ type = 'submit'
|
button.btn.btn-primary[ type = 'button'
|
||||||
ng-click = 'labelsCtrl.saveLabel()'
|
ng-click = 'labelsCtrl.saveLabel()'
|
||||||
ng-disabled = 'labelsCtrl.processing' ]
|
ng-disabled = 'labelsCtrl.processing' ]
|
||||||
div[ ng-show = 'labelsCtrl.processing' ]= t('layout.processing')
|
div[ ng-show = 'labelsCtrl.processing' ]= t('layout.processing')
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
h4=t('layout.issues.labels')
|
||||||
|
ul.nav.nav-pills.nav-stacked
|
||||||
|
li[ role = 'presentation' ng-repeat = 'label in issueCtrl.labels' ]
|
||||||
|
a[ href = '#'
|
||||||
|
ng-click = 'issueCtrl.toggleLabel(label)'
|
||||||
|
ng-style = 'label.style' ]
|
||||||
|
.label-flag[ ng-style = 'label.default_style'
|
||||||
|
ng-show = '!label.selected' ]
|
||||||
|
| {{label.name}}
|
||||||
|
input.hidden[ name = 'issue[labelings_attributes][][label_id]'
|
||||||
|
ng-model = 'label.selected_id'
|
||||||
|
ng-value = 'label.selected_id' ]
|
|
@ -1,17 +1,20 @@
|
||||||
-set_meta_tags title: [title_object(@project), t('layout.issues.create_header')]
|
-set_meta_tags title: [title_object(@project), t('layout.issues.create_header')]
|
||||||
-render 'submenu'
|
-render 'submenu'
|
||||||
-render 'manage_sidebar'
|
|
||||||
|
|
||||||
.container ng-controller = 'IssueController as issueCtrl' ng-cloak = true
|
.container ng-controller = 'IssueController as issueCtrl' ng-cloak = true
|
||||||
.row
|
= simple_form_for @issue, url: project_issues_path(@project) do |f|
|
||||||
.col-md-3.col-sm-4.offset20
|
.row
|
||||||
= render 'manage_labels', project: @project
|
.col-md-3.col-sm-4.offset20
|
||||||
.col-md-9.col-sm-8.offset20
|
- if can?(:write, @project)
|
||||||
= simple_form_for @issue do |f|
|
|
||||||
h3= title t('layout.issues.create_header')
|
|
||||||
= render 'form', f: f
|
|
||||||
|
|
||||||
= render 'projects/comments/markdown_help'
|
== render 'select_labels'
|
||||||
|
== render 'manage_labels'
|
||||||
|
|
||||||
|
.col-md-9.col-sm-8.offset20
|
||||||
|
h3= title t('layout.issues.create_header')
|
||||||
|
== render 'form', f: f
|
||||||
|
|
||||||
|
== render 'projects/comments/markdown_help'
|
||||||
|
|
||||||
- content_for :additional_scripts do
|
- content_for :additional_scripts do
|
||||||
= render 'init_service.js.erb'
|
== render 'init_service.js.erb'
|
||||||
|
|
|
@ -327,10 +327,11 @@ Rosa::Application.routes.draw do
|
||||||
get :search_collaborators
|
get :search_collaborators
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
get 'pull_requests' => 'issues#pull_requests', as: :pull_requests
|
|
||||||
|
|
||||||
post "/labels/:label_id" => "issues#destroy_label", as: :issues_delete_label
|
get 'pull_requests' => 'issues#pull_requests', as: :pull_requests
|
||||||
post "/labels/:label_id/update" => "issues#update_label", as: :issues_update_label
|
get 'labels' => 'issues#labels', as: :labels
|
||||||
|
post 'labels/:label_id' => 'issues#destroy_label', as: :issues_delete_label
|
||||||
|
post 'labels/:label_id/update' => 'issues#update_label', as: :issues_update_label
|
||||||
|
|
||||||
resources :build_lists, only: [:index, :new, :create] do
|
resources :build_lists, only: [:index, :new, :create] do
|
||||||
get :list, on: :collection
|
get :list, on: :collection
|
||||||
|
|
Loading…
Reference in New Issue