Skip to content
Snippets Groups Projects
Commit 80c200c9 authored by milan.brabec's avatar milan.brabec
Browse files

Initial commit

parents
Branches master
No related tags found
No related merge requests found
= Sperling Semafor Plugin pro Redmine
Plugin zobrazuje barevnný terčík vlevo od hodnoty uživatelského atributu "Semafor".
Konfigurace:
Lze nastavit pro libovolný uživatelský atributy typu seznam.
Pro každý takový atribut lze ke každé jeho hodnotě zvolit barvu (CSS jméno barvy, např. <tt>lightblue</tt>, <tt>darkgreen</tt>).
Konfigurace je globální.
<% settings = Setting['plugin_traffic_lights'] %>
<% content_for :header_tags do %>
<%= stylesheet_link_tag 'traffic_lights', plugin: :traffic_lights %>
<style>
<% settings.each do |key,value| %>
<% unless key.include?("enabled") || value.blank? %>
<% class_suffix = "#{value}" %>
<% if value.start_with? "#" %>
<% class_suffix = "#{value.tr("#", "")}" %>
<% end %>
.semafor-<%= class_suffix %>::before {
background-color: <%= value %>;
}
<% end %>
<% end %>
</style>
<% end %>
<script type="text/javascript">
<% CustomField.where(:field_format => 'list').each do |custom_list| %>
<% unless settings["enabled_#{custom_list.id}"].blank? %>
<% custom_list.possible_values.each do |enum| %>
<% unless settings["#{custom_list.id}_#{enum}"].blank? %>
<% color = settings["#{custom_list.id}_#{enum}"] %>
<% color_class = color.start_with?("#") ? color.tr("#", "") : color %>
$(".cf_<%= custom_list.id %><%= selector_suffix %>:contains(<%= enum %>)").addClass("semafor semafor-<%= color_class %>");
<% end %>
<% end %>
<% end %>
<% end %>
</script>
\ No newline at end of file
<% content_for :header_tags do %>
<%= javascript_include_tag 'w3color', plugin: :traffic_lights %>
<% end %>
<% CustomField.where(:field_format => 'list').each do |custom_list| %>
<table>
<tbody>
<tr>
<th>
<%= custom_list.name %>
</th>
<td>
<%= check_box_tag "settings[enabled_#{custom_list.id.to_s}]",
"1",
@settings["enabled_" + custom_list.id.to_s],
id: "enabled_#{custom_list.id.to_s}",
class: 'lights_enable'
%>
</td>
</tr>
<% custom_list.possible_values.each do |enum| %>
<tr class="enabled_<%= custom_list.id.to_s %>" <%= "hidden" unless @settings["enabled_" + custom_list.id.to_s] %>>
<th>
<%= enum %>
</th>
<td><%= text_field_tag "settings[#{custom_list.id.to_s}_#{enum}]",
@settings[custom_list.id.to_s + "_" + enum],
id: "display_#{custom_list.id.to_s}_#{enum}",
size: 30
%>
<%= color_field_tag "color_#{custom_list.id.to_s}_#{enum}",
@settings[custom_list.id.to_s + "_" + enum],
id: "#{custom_list.id.to_s}_#{enum}",
class: "color_palet"
%>
</td>
<% end %>
</tr>
</tbody>
</table>
<% end %>
<script type="application/javascript">
$(".color_palet").each(function (i,v) {
var colorObj = w3color($("#display_" + v.id).val());
this.value = colorObj.toHexString();
});
$(".lights_enable").change(function () {
if (this.checked) {
$("." + this.id).removeAttr("hidden");
} else {
$("." + this.id).attr("hidden", true);
}
});
$(".color_palet").change(function () {
$("#display_" + this.id).val(this.value);
});
</script>
assets/images/semafor.png

621 B

assets/images/semafor_24.png

930 B

This diff is collapsed.
td.list.semafor {
text-align: left;
min-width: 92px;
padding-right: 5px;
}
.semafor::before {
content: "\00a0";
display: inline-block;
width: 12px;
height: 12px;
border-radius: 40%;
margin-right: 2px;
vertical-align: middle;
margin-top: -2px;
/* background-image: url("../images/semafor.png");
background-size: contain;*/
border: 1px solid var(--sparkline-edge);
overflow: hidden;
}
# English strings go here for Rails i18n
en:
# my_label: "My label"
# Plugin's routes
# See: http://guides.rubyonrails.org/routing.html
init.rb 0 → 100644
Redmine::Plugin.register :traffic_lights do
name 'Traffic Lights plugin'
author 'Sperling'
description 'Traffic lights plugin '
version '1.0.0'
url ''
author_url 'https://www.sperling.cz/'
settings default: {
}, partial: 'settings/traffic_lights/traffic_lights'
end
class TrafficLightsHookListener < Redmine::Hook::ViewListener
render_on :view_issues_index_bottom, partial: "hooks/traffic_lights_issues", locals: {:selector_suffix => ""}
render_on :view_issues_show_details_bottom, partial: "hooks/traffic_lights_issues", locals: {:selector_suffix => " .value"}
end
\ No newline at end of file
# Load the Redmine helper
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment