Commit 310db449 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add weight field to the issue

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 63cfe86e
...@@ -165,7 +165,7 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -165,7 +165,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, :weight,
:milestone_id, :state_event, :task_num, label_ids: [] :milestone_id, :state_event, :task_num, label_ids: []
) )
end end
......
...@@ -39,6 +39,7 @@ class IssuableFinder ...@@ -39,6 +39,7 @@ class IssuableFinder
items = by_assignee(items) items = by_assignee(items)
items = by_author(items) items = by_author(items)
items = by_label(items) items = by_label(items)
items = by_weight(items)
sort(items) sort(items)
end end
...@@ -265,6 +266,14 @@ class IssuableFinder ...@@ -265,6 +266,14 @@ class IssuableFinder
items items
end end
def by_weight(items)
if params[:weight].present?
items = items.where(weight: params[:weight])
end
items
end
def current_user_related? def current_user_related?
params[:scope] == 'created-by-me' || params[:scope] == 'authored' || params[:scope] == 'assigned-to-me' params[:scope] == 'created-by-me' || params[:scope] == 'authored' || params[:scope] == 'assigned-to-me'
end end
......
...@@ -121,6 +121,15 @@ module IssuesHelper ...@@ -121,6 +121,15 @@ module IssuesHelper
end end
end end
def projects_weight_options
options = (Issue::WEIGHT_RANGE).map do |i|
[i, i]
end
options.unshift(['Any', nil])
options_for_select(options, params[:weight])
end
# Required for Banzai::Filter::IssueReferenceFilter # Required for Banzai::Filter::IssueReferenceFilter
module_function :url_for_issue module_function :url_for_issue
end end
...@@ -27,6 +27,7 @@ class Issue < ActiveRecord::Base ...@@ -27,6 +27,7 @@ class Issue < ActiveRecord::Base
include Referable include Referable
include Sortable include Sortable
include Taskable include Taskable
WEIGHT_RANGE = 1..9
ActsAsTaggableOn.strict_case_match = true ActsAsTaggableOn.strict_case_match = true
......
...@@ -44,6 +44,11 @@ ...@@ -44,6 +44,11 @@
&nbsp; &nbsp;
%span.task-status %span.task-status
= issue.task_status = issue.task_status
- if issue.weight
&nbsp;
%span
= icon('magnet')
= issue.weight
.pull-right.issue-updated-at .pull-right.issue-updated-at
%span updated #{time_ago_with_tooltip(issue.updated_at, placement: 'bottom', html_class: 'issue_update_ago')} %span updated #{time_ago_with_tooltip(issue.updated_at, placement: 'bottom', html_class: 'issue_update_ago')}
...@@ -47,6 +47,12 @@ ...@@ -47,6 +47,12 @@
class: 'select2 trigger-submit', include_blank: true, class: 'select2 trigger-submit', include_blank: true,
data: {placeholder: 'Label'}) data: {placeholder: 'Label'})
- if controller.controller_name == 'issues'
.filter-item.inline.weight-filter
= select_tag('weight', projects_weight_options,
class: 'select2 trigger-submit', include_blank: true,
data: {placeholder: 'Weight'})
.pull-right .pull-right
= render 'shared/sort_dropdown' = render 'shared/sort_dropdown'
......
...@@ -54,6 +54,14 @@ ...@@ -54,6 +54,14 @@
&nbsp; &nbsp;
- if can? current_user, :admin_milestone, issuable.project - if can? current_user, :admin_milestone, issuable.project
= link_to 'Create new milestone', new_namespace_project_milestone_path(issuable.project.namespace, issuable.project), target: :blank = link_to 'Create new milestone', new_namespace_project_milestone_path(issuable.project.namespace, issuable.project), target: :blank
- if issuable.respond_to?(:weight)
.form-group
= f.label :label_ids, class: 'control-label' do
= icon('magnet')
Weight
.col-sm-10
= f.number_field :weight, in: Issue::WEIGHT_RANGE, class: 'form-control'
.form-group .form-group
= f.label :label_ids, "Labels", class: 'control-label' = f.label :label_ids, "Labels", class: 'control-label'
.col-sm-10 .col-sm-10
...@@ -75,7 +83,7 @@ ...@@ -75,7 +83,7 @@
.col-sm-10 .col-sm-10
= users_select_tag("merge_request[approver_ids]", multiple: true, class: 'input-large', scope: :all, email_user: true) = users_select_tag("merge_request[approver_ids]", multiple: true, class: 'input-large', scope: :all, email_user: true)
.help-block .help-block
Merge Request should be approved by these users. Merge Request should be approved by these users.
You can override the project settings by setting your own list of approvers. You can override the project settings by setting your own list of approvers.
.panel.panel-default.prepend-top-10 .panel.panel-default.prepend-top-10
...@@ -104,7 +112,7 @@ ...@@ -104,7 +112,7 @@
%li.no-approvers There are no approvers %li.no-approvers There are no approvers
.help-block.suggested-approvers .help-block.suggested-approvers
- if @suggested_approvers.any? - if @suggested_approvers.any?
Suggested approvers: Suggested approvers:
= raw @suggested_approvers.map{|approver| link_to sanitize(approver.name), "#", id: dom_id(approver) }.join(", ") = raw @suggested_approvers.map{|approver| link_to sanitize(approver.name), "#", id: dom_id(approver) }.join(", ")
%hr %hr
......
...@@ -54,6 +54,14 @@ ...@@ -54,6 +54,14 @@
= f.collection_select :label_ids, issuable.project.labels.all, :id, :name, = f.collection_select :label_ids, issuable.project.labels.all, :id, :name,
{ selected: issuable.label_ids }, multiple: true, class: 'select2 js-select2', data: { placeholder: "Select labels" } { selected: issuable.label_ids }, multiple: true, class: 'select2 js-select2', data: { placeholder: "Select labels" }
- if issuable.respond_to?(:weight) && issuable.weight
.block
.title
%label Weight
.value
= icon('magnet')
= issuable.weight
.block .block
.title .title
Cross-project reference Cross-project reference
......
class AddWeightToIssue < ActiveRecord::Migration
def change
add_column :issues, :weight, :integer
end
end
...@@ -434,6 +434,7 @@ ActiveRecord::Schema.define(version: 20151210125932) do ...@@ -434,6 +434,7 @@ ActiveRecord::Schema.define(version: 20151210125932) do
t.string "state" t.string "state"
t.integer "iid" t.integer "iid"
t.integer "updated_by_id" t.integer "updated_by_id"
t.integer "weight"
end end
add_index "issues", ["assignee_id"], name: "index_issues_on_assignee_id", using: :btree add_index "issues", ["assignee_id"], name: "index_issues_on_assignee_id", using: :btree
......
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