Add color to priority

pull/6336/head
Oliver Günther 7 years ago
parent 730d610e39
commit a101a67374
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 5
      app/cells/enumerations/row_cell.rb
  2. 2
      app/helpers/colors_helper.rb
  3. 7
      app/models/issue_priority.rb
  4. 14
      app/views/colors/_color_autocomplete_field.html.erb
  5. 8
      app/views/enumerations/_form.html.erb
  6. 2
      app/views/enumerations/index.html.erb
  7. 17
      app/views/statuses/_form.html.erb
  8. 19
      config/locales/en.yml
  9. 7
      db/migrate/20180504144320_add_color_to_statuses.rb
  10. 11
      db/migrate/20180504144320_add_color_to_statuses_and_enumerations.rb

@ -1,6 +1,7 @@
module Enumerations
class RowCell < ::RowCell
include ::IconsHelper
include ::ColorsHelper
include ReorderLinksHelper
def enumeration
@ -17,6 +18,10 @@ module Enumerations
end
end
def color
icon_for_color enumeration.color
end
def active
if enumeration.active?
op_icon 'icon icon-checkmark'

@ -29,7 +29,7 @@
#++
module ColorsHelper
def options_for_colors(colored_thing, default_label: I18n.t(:label_none_parentheses), default_color: nil)
def options_for_colors(colored_thing, default_label: I18n.t('colors.label_no_color'), default_color: nil)
s = content_tag(:option, default_label, value: default_color)
Color.find_each do |c|
options = {}

@ -29,11 +29,16 @@
class IssuePriority < Enumeration
has_many :work_packages, foreign_key: 'priority_id'
belongs_to :color
OptionName = :enumeration_work_package_priorities
def self.colored?
false
true
end
def color_label
I18n.t('prioritiies.edit.priority_color_text')
end
def option_name

@ -0,0 +1,14 @@
<% field_name = ActiveModel::Naming.param_key(object) %>
<div class="form--field">
<label class="form--label" for="<%= field_name %>_color_id">
<%= object.class.human_attribute_name 'color' %>
</label>
<div class="form--field-container">
<div class="form--select-container -middle">
<colors-autocompleter label="<%= object.class.human_attribute_name 'color' %>">
<%= select_tag "#{field_name}[color_id]", options_for_colors(object), hidden: true %>
</colors-autocompleter>
<div class="form--field-instructions -no-margin"><%= label %></div>
</div>
</div>

@ -39,6 +39,14 @@ See docs/COPYRIGHT.rdoc for more details.
<div class="form--field"><%= f.check_box 'active' %></div>
<div class="form--field"><%= f.check_box 'is_default' %></div>
<% if @enumeration.class.colored? %>
<%= render partial: '/colors/color_autocomplete_field',
locals: {
object: @enumeration,
label: @enumeration.color_label
} %>
<% end %>
<% @enumeration.custom_field_values.each do |value| %>
<div class="form--field"><%= custom_field_tag_with_label :enumeration, value %></div>
<% end %>

@ -30,5 +30,5 @@ See docs/COPYRIGHT.rdoc for more details.
<%= toolbar title: l(:label_enumerations) %>
<% Enumeration.descendants.each do |klass| %>
<h3 class="-no-border"><%= l(klass::OptionName) %></h3>
<%= cell ::Enumerations::TableCell, klass.shared %>
<%= cell ::Enumerations::TableCell, klass.shared, with_colors: klass.colored? %>
<% end %>

@ -42,18 +42,11 @@ See docs/COPYRIGHT.rdoc for more details.
<div class="form--field"><%= f.check_box 'is_default' %></div>
<% end %>
<div class="form--field">
<label class="form--label" for="status_color_id">
<%= Status.human_attribute_name 'color' %>
</label>
<div class="form--field-container">
<div class="form--select-container -middle">
<colors-autocompleter label="<%= Status.human_attribute_name 'color' %>">
<%= select_tag 'status[color_id]', options_for_colors(@status), hidden: true %>
</colors-autocompleter>
<div class="form--field-instructions -no-margin"><%= t('statuses.edit.status_color_text') %></div>
</div>
</div>
<%= render partial: '/colors/color_autocomplete_field',
locals: {
object: @status,
label: t('statuses.edit.status_color_text')
} %>
<%= call_hook(:view_statuses_form, status: @status) %>
</section>

@ -82,6 +82,9 @@ en:
show:
no_results_title_text: There are currently no posts for the board.
colors:
label_no_color: 'No color'
custom_actions:
actions:
name: 'Actions'
@ -107,16 +110,6 @@ en:
no_results_title_text: There are currently no custom fields.
no_results_content_text: Create a new custom field
deprecations:
old_timeline:
replacement: "This timelines module is being replaced by the interactive timeline embedded into the work packages module."
removal: "This module is going to be removed with OpenProject 8.0. The configuration for this view will NOT be migrated to the work package view."
further_information_before: "Please take a look at"
link_name: "how to migrate to the new timeline."
further_information_after: ""
calendar:
removal: "Please note: This module is going to be removed with OpenProject 8.0."
groups:
index:
no_results_title_text: There are currently no groups.
@ -179,6 +172,12 @@ en:
memberships:
no_results_title_text: This user is currently not a member of a project.
prioritiies:
edit:
priority_color_text: |
Click to assign or change the color of this priority.
It can be used for highlighting work packages in the table.
reportings:
index:
no_results_title_text: There are currently no status reportings.

@ -1,7 +0,0 @@
class AddColorToStatuses < ActiveRecord::Migration[5.1]
def change
change_table :statuses do |t|
t.belongs_to :color, type: :int
end
end
end

@ -0,0 +1,11 @@
class AddColorToStatusesAndEnumerations < ActiveRecord::Migration[5.1]
def change
change_table :statuses do |t|
t.belongs_to :color, type: :int
end
change_table :enumerations do |t|
t.belongs_to :color, type: :int
end
end
end
Loading…
Cancel
Save