Skip to content

Commit

Permalink
text colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Treubert committed May 17, 2024
1 parent ae84134 commit efdcbf5
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 6 deletions.
32 changes: 30 additions & 2 deletions app/controllers/calendar_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,24 @@ def get_events
end
@events = []
def_holiday = '#' + Setting.plugin_mega_calendar['default_holiday_color']
def_holiday_text = '#' + Setting.plugin_mega_calendar['default_holiday_text_color']
def_color = '#' + Setting.plugin_mega_calendar['default_event_color']
@events = @events + holidays.collect {|h| {:id => h.id.to_s, :controller_name => 'holiday', :title => (h.user.blank? ? '' : h.user.name + ' - ') + (translate 'holiday'), :start => h.start.to_date.to_s, :end => (h.end + 1.day).to_date.to_s, :allDay => true, :color => def_holiday, :url => Setting.plugin_mega_calendar['sub_path'] + 'holidays/show?id=' + h.id.to_s, :className => 'mega_calendar_event', :description => form_holiday(h) }}
def_text_color = '#' + Setting.plugin_mega_calendar['default_event_text_color']
@events = @events + holidays.collect {|h|
{
:id => h.id.to_s,
:controller_name => 'holiday',
:title => (h.user.blank? ? '' : h.user.name + ' - ') + (translate 'holiday'),
:start => h.start.to_date.to_s,
:end => (h.end + 1.day).to_date.to_s,
:allDay => true,
:color => def_holiday,
:textColor => def_holiday_text,
:url => Setting.plugin_mega_calendar['sub_path'] + 'holidays/show?id=' + h.id.to_s,
:className => 'mega_calendar_event',
:description => form_holiday(h)
}
}
issues = issues + issues2 + issues3 + issues4
issues = issues.compact.uniq
issues.each do |i|
Expand All @@ -243,7 +259,19 @@ def get_events
i.due_date = i.created_on
end
color = '#' + UserColor.where({:user_id => i.assigned_to_id}).first.color_code rescue def_color
i_event = {:id => i.id.to_s, :controller_name => 'issue', :title => i.id.to_s + ' - ' + i.subject, :start => i.start_date.to_date.to_s + tbegin, :end => i.due_date.to_date.to_s + tend, :color => color, :url => Setting.plugin_mega_calendar['sub_path'] + 'issues/' + i.id.to_s, :className => css_classes, :description => form_issue(i) }
text_color = '#' + UserColor.where({:user_id => i.assigned_to_id}).first.text_color_code rescue def_text_color
i_event = {
:id => i.id.to_s,
:controller_name => 'issue',
:title => i.id.to_s + ' - ' + i.subject,
:start => i.start_date.to_date.to_s + tbegin,
:end => i.due_date.to_date.to_s + tend,
:color => color,
:textColor => text_color,
:url => Setting.plugin_mega_calendar['sub_path'] + 'issues/' + i.id.to_s,
:className => css_classes,
:description => form_issue(i)
}
if tbegin.blank? || tend.blank?
i_event[:allDay] = true
if !i.due_date.blank? && tend.blank?
Expand Down
16 changes: 14 additions & 2 deletions app/views/settings/_mega_calendar_settings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,24 @@
<input type="text" id="settings_default_holiday_color" value="<%= settings['default_holiday_color'] %>" name="settings[default_holiday_color]" class="color" />
</td>
</tr>
<tr>
<th><%= translate 'def_holiday_text_color' %></th>
<td>
<input type="text" id="settings_default_holiday_text_color" value="<%= settings['default_holiday_text_color'] %>" name="settings[default_holiday_text_color]" class="color" />
</td>
</tr>
<tr>
<th><%= translate 'def_color' %></th>
<td>
<input type="text" id="settings_default_event_color" value="<%= settings['default_event_color'] %>" name="settings[default_event_color]" class="color" />
</td>
</tr>
<tr>
<th><%= translate 'def_text_color' %></th>
<td>
<input type="text" id="settings_default_event_text_color" value="<%= settings['default_event_text_color'] %>" name="settings[default_event_text_color]" class="color" />
</td>
</tr>
<tr>
<th><%= translate 'sub_path' %></th>
<td>
Expand All @@ -31,11 +43,11 @@
<tr>
<th><%= translate 'week_start' %></th>
<td>
<select id="settings_week_start" name="settings[week_start]">
<select id="settings_week_start" name="settings[week_start]">
<% (0..6).each do |d| %>
<option value="<%= d.to_s %>" <%= (!Setting.plugin_mega_calendar['week_start'].blank? && Setting.plugin_mega_calendar['week_start'] == d.to_s ? 'selected' : '') %>><%= translate 'day'+d.to_s %></option>
<% end %>
</select>
</select>
</td>
</tr>
<tr>
Expand Down
2 changes: 2 additions & 0 deletions app/views/users/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<%= error_messages_for 'user' %>
<%
user_color = UserColor.where({:user_id => @user.id}).first.color_code rescue ''
text_color = UserColor.where({:user_id => @user.id}).first.text_color_code rescue ''
%>

<div id="user_form">
Expand All @@ -14,6 +15,7 @@
<p><%= f.text_field :lastname, :required => true %></p>
<p><%= f.text_field :mail, :required => true %></p>
<p><label>Color:</label><input name="user[color]" class="color" type="text" value="<%= user_color %>" /></p>
<p><label>TextColor:</label><input name="user[text_color]" class="color" type="text" value="<%= text_color %>" /></p>
<% unless @user.force_default_language? %>
<p><%= f.select :language, lang_options_for_select %></p>
<% end %>
Expand Down
2 changes: 2 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ de:
display_empty_dates: "Tickets ohne Abgabedatum anzeigen"
displayed_within_calendar: "Im Kalender angezeigt"
def_holiday_color: "Standard Farbe für Urlaubseinträge"
def_holiday_text_color: "Standard Text-Farbe für Urlaubseinträge"
def_color: "Standard Farbe"
def_text_color: "Standard Text-Farbe"
project: "Projekt"
status: "Status"
save_question: "Möchten Sie das Objekt speichern?"
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ en:
use_saved_filter: "Use filter"
display_empty_dates: "Show tasks without date"
def_holiday_color: "Default color for holiday"
def_holiday_text_color: "Default text color for holiday"
def_color: "Default color"
def_text_color: "Default text color"
project: "Project"
status: "Status"
save_question: "Do you really want to save?"
Expand Down
8 changes: 8 additions & 0 deletions db/migrate/005_add_text_color_to_user_colors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class AddTextColorToUserColors < ActiveRecord::Migration[ActiveRecord::VERSION::MAJOR.to_s + '.' + ActiveRecord::VERSION::MINOR.to_s]
def up
add_column :user_colors, :text_color_code, :string
end
def down
drop_column :user_colors, :text_color_code
end
end
13 changes: 12 additions & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,18 @@
requires_redmine :version_or_higher => '5.1.1'
menu(:top_menu, :calendar, { :controller => 'calendar', :action => 'index' }, :caption => :calendar, :if => Proc.new {(!Setting.plugin_mega_calendar['allowed_users'].blank? && Setting.plugin_mega_calendar['allowed_users'].include?(User.current.id.to_s) ? true : false)})
menu(:top_menu, :holidays, { :controller => 'holidays', :action => 'index' }, :caption => :holidays, :if => Proc.new {(!Setting.plugin_mega_calendar['allowed_users'].blank? && Setting.plugin_mega_calendar['allowed_users'].include?(User.current.id.to_s) ? true : false)})
settings :default => {'display_empty_dates' => 0, 'displayed_type' => 'users', 'displayed_users' => User.where(["users.login IS NOT NULL AND users.login <> ''"]).collect {|x| x.id.to_s}, 'default_holiday_color' => 'D59235', 'default_event_color' => '4F90FF', 'sub_path' => '/', 'week_start' => '1', 'allowed_users' => User.where(["users.login IS NOT NULL AND users.login <> ''"]).collect {|x| x.id.to_s}}, :partial => 'settings/mega_calendar_settings'
settings :default => {
'display_empty_dates' => 0,
'displayed_type' => 'users',
'displayed_users' => User.where(["users.login IS NOT NULL AND users.login <> ''"]).collect {|x| x.id.to_s},
'default_holiday_color' => 'D59235',
'default_holiday_text_color' => '000000',
'default_event_color' => '4F90FF',
'default_event_text_color' => '000000',
'sub_path' => '/',
'week_start' => '1',
'allowed_users' => User.where(["users.login IS NOT NULL AND users.login <> ''"]).collect {|x| x.id.to_s}
}, :partial => 'settings/mega_calendar_settings'
end

UsersController.prepend(MegaCalendar::UsersControllerPatch)
Expand Down
3 changes: 2 additions & 1 deletion lib/mega_calendar/users_controller_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module UsersControllerPatch
def create
super
unless @user.id.blank?
UserColor.create({:user_id => @user.id, :color_code => params[:user][:color]})
UserColor.create({:user_id => @user.id, :color_code => params[:user][:color], :text_color_code => params[:user][:text_color]})
end
end
def update
Expand All @@ -15,6 +15,7 @@ def update
uc = UserColor.new({:user_id => @user.id})
end
uc.color_code = params[:user][:color]
uc.text_color_code = params[:user][:text_color]
uc.save
end
end
Expand Down

0 comments on commit efdcbf5

Please sign in to comment.