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
def issue_params
params.require(:issue).permit(
:title, :assignee_id, :position, :description,
:title, :assignee_id, :position, :description, :weight,
:milestone_id, :state_event, :task_num, label_ids: []
)
end
......
......@@ -39,6 +39,7 @@ class IssuableFinder
items = by_assignee(items)
items = by_author(items)
items = by_label(items)
items = by_weight(items)
sort(items)
end
......@@ -265,6 +266,14 @@ class IssuableFinder
items
end
def by_weight(items)
if params[:weight].present?
items = items.where(weight: params[:weight])
end
items
end
def current_user_related?
params[:scope] == 'created-by-me' || params[:scope] == 'authored' || params[:scope] == 'assigned-to-me'
end
......
......@@ -121,6 +121,15 @@ module IssuesHelper
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
module_function :url_for_issue
end
......@@ -27,6 +27,7 @@ class Issue < ActiveRecord::Base
include Referable
include Sortable
include Taskable
WEIGHT_RANGE = 1..9
ActsAsTaggableOn.strict_case_match = true
......
......@@ -44,6 +44,11 @@
&nbsp;
%span.task-status
= issue.task_status
- if issue.weight
&nbsp;
%span
= icon('magnet')
= issue.weight
.pull-right.issue-updated-at
%span updated #{time_ago_with_tooltip(issue.updated_at, placement: 'bottom', html_class: 'issue_update_ago')}
......@@ -47,6 +47,12 @@
class: 'select2 trigger-submit', include_blank: true,
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
= render 'shared/sort_dropdown'
......
......@@ -54,6 +54,14 @@
&nbsp;
- 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
- 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
= f.label :label_ids, "Labels", class: 'control-label'
.col-sm-10
......@@ -75,7 +83,7 @@
.col-sm-10
= users_select_tag("merge_request[approver_ids]", multiple: true, class: 'input-large', scope: :all, email_user: true)
.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.
.panel.panel-default.prepend-top-10
......@@ -104,7 +112,7 @@
%li.no-approvers There are no approvers
.help-block.suggested-approvers
- if @suggested_approvers.any?
Suggested approvers:
Suggested approvers:
= raw @suggested_approvers.map{|approver| link_to sanitize(approver.name), "#", id: dom_id(approver) }.join(", ")
%hr
......
......@@ -54,6 +54,14 @@
= 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" }
- if issuable.respond_to?(:weight) && issuable.weight
.block
.title
%label Weight
.value
= icon('magnet')
= issuable.weight
.block
.title
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
t.string "state"
t.integer "iid"
t.integer "updated_by_id"
t.integer "weight"
end
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