Permalink
Browse files

Update color button for wiki formatter

Fix some bugs
  • Loading branch information...
1 parent fc09f21 commit 3783fde044aa0f56b5f7b3930240cd949e54fbd4 HaTrinh committed Jul 15, 2010
@@ -46,79 +46,81 @@ def all_users
end
@daily_todo_no_todo_has_user = @daily_todo_no_todo_has_user || !@no_todo_ungroup_users.empty?
@daily_todo_todo_has_user = @daily_todo_todo_has_user || !@todo_ungroup_users.empty?
+ @reported = @reported || @todo_ungroup_users.any? { |user|
+ user.id == User.current.id
+ }
+ end
-end
-
-# Shows TODOs within one week of a specified user.
-#
-# If there is no TODOs for a date:
-# * If the current user is the specified user: display link to create TODOS for that date
-# * Else shows that the user has not created TODOs for that date
-def one_user
- @user = User.find(params[:user_id])
- @date = (params[:date])? Date.parse(params[:date]) : Date.today
+ # Shows TODOs within one week of a specified user.
+ #
+ # If there is no TODOs for a date:
+ # * If the current user is the specified user: display link to create TODOS for that date
+ # * Else shows that the user has not created TODOs for that date
+ def one_user
+ @user = User.find(params[:user_id])
+ @date = (params[:date])? Date.parse(params[:date]) : Date.today
- next_3_days_date = @date + 3
- todos = DailyTodo.all(
- :conditions => ["user_id = ? AND (date <= ? AND date >= ?)", params[:user_id], next_3_days_date, @date - ONE_WEEK + 1],
+ next_3_days_date = @date + 3
+ todos = DailyTodo.all(
+ :conditions => ["user_id = ? AND (date <= ? AND date >= ?)", params[:user_id], next_3_days_date, @date - ONE_WEEK + 1],
:order => 'date' # ASC because "range" below is increasing
- )
- range = (@date - ONE_WEEK + 1)..next_3_days_date
+ )
+ range = (@date - ONE_WEEK + 1)..next_3_days_date
- @todos = if todos.empty?
- range.map do |date|
- DailyTodo.new(:user_id => @user.id, :date => date)
- end
- else
- i = 0
- range.map do |date|
- if i >= todos.size || date < todos[i].date
+ @todos = if todos.empty?
+ range.map do |date|
DailyTodo.new(:user_id => @user.id, :date => date)
- else
- i += 1
- todos[i - 1]
+ end
+ else
+ i = 0
+ range.map do |date|
+ if i >= todos.size || date < todos[i].date
+ DailyTodo.new(:user_id => @user.id, :date => date)
+ else
+ i += 1
+ todos[i - 1]
+ end
end
end
- end
- @todos.reverse!
-end
+ @todos.reverse!
+ end
-def create_todo
- if request.post?
- date = (params[:date])? Date.parse(params[:date]) : Date.today
- time = Time.now
- reported = (DailyTodo.find(:first, :conditions => {:user_id => User.current.id, :date => date}) != nil)
- if reported
- flash[:error] = l(:'daily_todos.todo.create_error')
- else
- todo = DailyTodo.new(:date => date, :lunch => time, :user_id => User.current.id )
- todo.save
+ def create_todo
+ if request.post?
+ date = (params[:date])? Date.parse(params[:date]) : Date.today
+ time = Time.now
+ reported = (DailyTodo.find(:first, :conditions => {:user_id => User.current.id, :date => date}) != nil)
+ if reported
+ flash[:error] = l(:'daily_todos.todo.create_error')
+ else
+ todo = DailyTodo.new(:date => date, :lunch => time, :user_id => User.current.id )
+ todo.save
+ end
+ render :js => "window.location = '" + url_for(:action => 'one_user', :user_id => User.current.id, :date => date) + "'"
end
- render :js => "window.location = '" + url_for(:action => 'one_user', :user_id => User.current.id, :date => date) + "'"
end
-end
-def update
- if request.put?
- @todo = DailyTodo.find(params[:id])
- pdr = params[:daily_todo]
- @todo.lunch = Time.mktime(@todo.date.year, @todo.date.month,@todo.date.day, pdr['lunch(4i)'], pdr['lunch(5i)'])
- @todo.save
- redirect_to(:action => 'one_user', :user_id => User.current.id)
+ def update
+ if request.put?
+ @todo = DailyTodo.find(params[:id])
+ pdr = params[:daily_todo]
+ @todo.lunch = Time.mktime(@todo.date.year, @todo.date.month,@todo.date.day, pdr['lunch(4i)'], pdr['lunch(5i)'])
+ @todo.save
+ redirect_to(:action => 'one_user', :user_id => User.current.id)
+ end
end
-end
-def destroy
- if request.delete?
- todo = DailyTodo.find(params[:id])
- if todo.user_id != User.current.id
- flash[:error] = l(:'daily_todos.todo.delete_error')
- else
- flash[:notice] = l(:'daily_todos.todo.delete')
- todo.destroy
+ def destroy
+ if request.delete?
+ todo = DailyTodo.find(params[:id])
+ if todo.user_id != User.current.id
+ flash[:error] = l(:'daily_todos.todo.delete_error')
+ else
+ flash[:notice] = l(:'daily_todos.todo.delete')
+ todo.destroy
+ end
+ render :js => "window.location = '" + url_for(:action => 'one_user', :user_id => User.current.id) + "'"
end
- render :js => "window.location = '" + url_for(:action => 'one_user', :user_id => User.current.id) + "'"
end
end
-end
@@ -13,18 +13,18 @@ def add_color_picker_lib()
javascript_include_tag('color_picker/colorpicker', :plugin => 'redmine_daily_todos')
end
- def wikitoolbar_with_color_for(field_id, color_picker_text_id)
+ def wikitoolbar_with_color_for(field_id, jstoolbar_obj_name ,color_picker_text_id)
url = "#{Redmine::Utils.relative_url_root}/help/wiki_syntax.html"
help_link = l(:setting_text_formatting) + ': ' +
link_to(l(:label_help), url,
:onclick => "window.open(\"#{ url }\", \"\", \"resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes\"); return false;")
javascript_tag("var colorPickerTextId = '#{color_picker_text_id}';") +
- javascript_include_tag('jstoolbar/jstoolbar', :plugin => 'redmine_daily_todos') +
+ javascript_include_tag('jstoolbar/jstoolbar', :plugin => 'redmine_daily_todos') +
javascript_include_tag('jstoolbar/textile', :plugin => 'redmine_daily_todos') +
- javascript_include_tag("jstoolbar/lang/jstoolbar-#{current_language.to_s.downcase}") +
- javascript_tag("var wikiToolbar = new jsToolBar($('#{field_id}')); wikiToolbar.setColorPickerTextId('#{color_picker_text_id}') ; wikiToolbar.setHelpLink('#{help_link}'); wikiToolbar.draw();") +
- javascript_tag("new Control.ColorPicker('#{color_picker_text_id}', { IMAGE_BASE : '/javascripts/color_picker/' });")
+ javascript_include_tag("jstoolbar/lang/jstoolbar-#{current_language.to_s.downcase}", :plugin => 'redmine_daily_todos') +
+ javascript_tag("var #{jstoolbar_obj_name} = new jsToolBar($('#{field_id}')); #{jstoolbar_obj_name}.setColorPickerTextId('#{color_picker_text_id}') ; #{jstoolbar_obj_name}.setHelpLink('#{help_link}'); #{jstoolbar_obj_name}.draw();") +
+ javascript_tag("var #{jstoolbar_obj_name}_colorPicker = new Control.ColorPicker('#{color_picker_text_id}', #{jstoolbar_obj_name}, { IMAGE_BASE : '/plugin_assets/redmine_daily_todos/images/color_picker/' });")
end
end
@@ -12,4 +12,4 @@
<% end %>
<%= add_color_picker_lib %>
-<%= wikitoolbar_with_color_for('daily_todo_comment_body','colorTextCommentBody') %>
+<%= wikitoolbar_with_color_for('daily_todo_comment_body', 'jstoolbar_comment_body' ,'color_button_comment_body') %>
@@ -39,5 +39,5 @@
<% end %>
<%= add_color_picker_lib %>
-<%= wikitoolbar_with_color_for('daily_todo_entry_plan','colorTextPlan') %>
-<%= wikitoolbar_with_color_for('daily_todo_entry_result','colorTextResult') %>
+<%= wikitoolbar_with_color_for('daily_todo_entry_plan', 'jstoolbar_plan', 'color_button_plan') %>
+<%= wikitoolbar_with_color_for('daily_todo_entry_result', 'jstoolbar_result', 'color_button_result') %>
@@ -23,7 +23,7 @@
<% @daily_todo_groups.each_with_index do |group, i| %>
<% unless @daily_todo_users_todo[i].empty? %>
<div style="font-weight: bold;">
- <%= h(group) %>
+ <%= group %>
</div>
<ol>
<% @daily_todo_users_todo[i].each do |user| %>
Oops, something went wrong.

0 comments on commit 3783fde

Please sign in to comment.