From 972210326af7df49e87cd7b2be17a516d21042cc Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Thu, 27 Jun 2013 22:47:11 +0200 Subject: [PATCH] change look of todo --- Gemfile | 5 +- Gemfile.lock | 10 ++- app/assets/stylesheets/tracks.css.scss | 63 ++++++++++++++++++- app/helpers/application_helper.rb | 58 +++++++---------- app/helpers/todos_helper.rb | 30 ++++----- .../todos/_container_empty_message.html.erb | 5 ++ app/views/todos/_container_items.html.erb | 4 ++ app/views/todos/_todo.html.erb | 35 ++++++----- app/views/todos/index.html.erb | 5 -- app/views/todos/tag.html.erb | 5 -- 10 files changed, 136 insertions(+), 84 deletions(-) create mode 100644 app/views/todos/_container_empty_message.html.erb create mode 100644 app/views/todos/_container_items.html.erb diff --git a/Gemfile b/Gemfile index 1d6d06ee..12dac8d3 100644 --- a/Gemfile +++ b/Gemfile @@ -17,9 +17,10 @@ gem 'jquery-rails' # Twitter Bootstrap gem 'therubyracer' gem 'less-rails' + # use dev version to get fontawsome 3.2.1 #gem 'twitter-bootstrap-rails' -gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git' +gem 'twitter-bootstrap-rails', github: 'seyhunak/twitter-bootstrap-rails', branch: "master" # you may comment out the database driver you will not be using. # This will prevent a native build of the driver. Building native drivers is not @@ -45,7 +46,7 @@ gem "rack-mini-profiler" gem 'bcrypt-ruby', '~> 3.0.0' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks -# gem 'turbolinks' +gem 'turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder # gem 'jbuilder', '~> 1.2' diff --git a/Gemfile.lock b/Gemfile.lock index 77360a0f..0d69728e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,7 +7,8 @@ GIT GIT remote: git://github.com/seyhunak/twitter-bootstrap-rails.git - revision: 61c14a7a853abefcaa9e6878ade5a48a6856fb55 + revision: dfc45d21fac4178240bc3f6ec037969b49fa54c2 + branch: master specs: twitter-bootstrap-rails (2.2.7) actionpack (>= 3.1) @@ -51,7 +52,7 @@ GEM childprocess (>= 0.3.6) cucumber (>= 1.1.1) rspec-expectations (>= 2.7.0) - atomic (1.1.9) + atomic (1.1.10) bcrypt-ruby (3.0.1) builder (3.1.4) bullet (4.6.0) @@ -125,7 +126,7 @@ GEM mini_portile (~> 0.5.0) polyglot (0.3.3) rack (1.5.2) - rack-mini-profiler (0.1.26) + rack-mini-profiler (0.1.27) rack (>= 1.1.3) rack-test (0.6.2) rack (>= 1.0) @@ -193,6 +194,8 @@ GEM treetop (1.4.14) polyglot polyglot (>= 0.3.1) + turbolinks (1.2.0) + coffee-rails tzinfo (0.3.37) uglifier (2.1.1) execjs (>= 0.3.0) @@ -240,6 +243,7 @@ DEPENDENCIES therubyracer timecop tolk + turbolinks twitter-bootstrap-rails! uglifier (>= 1.3.0) will_paginate diff --git a/app/assets/stylesheets/tracks.css.scss b/app/assets/stylesheets/tracks.css.scss index 3731643a..a02264d3 100644 --- a/app/assets/stylesheets/tracks.css.scss +++ b/app/assets/stylesheets/tracks.css.scss @@ -2,6 +2,16 @@ * Tracks CSS */ +body { + background-color: #DDD; +} + +div.tracks-middle { + background-color: #FFF; + padding: 15px; + border-radius: 10px; +} + /* Header */ .navbar-inner { @@ -36,7 +46,46 @@ footer { background-image: linear-gradient(to bottom, #FFFFFF, #F2F2F2); } -/* Todo tags */ +/* Todo */ +div.todo-item { + margin-top: 7px; + margin-left: 0px; + border: 3px solid #EEE; + border-width: 0px 0px 1px; + + min-height: none; + line-height: none; + [class*="span"] { + min-height: 0px; + } + + i.icon-check-empty { + margin-right: 10px; + } + i.icon-check-sign { + margin-right: 10px; + color: #666; + } + i.icon-star-empty, i.icon-play-sign, i.icon-book, i.icon-refresh { + color: #BBB; /* light gray */ + } + i.icon-star { + color: #F89406; /* orange */ + } + span.todo-description { + margin-right: 10px; + } + div.todo-item-icons { + display: block; + margin-right: 10px; + float:left; + } + div.todo-item-description-container { + display: inline-block; + float:left; + } +} + span.tags { .label { a:hover, a:focus { @@ -48,11 +97,19 @@ span.tags { font-weight: normal; } margin-right: 1px; + background-color: #BBB; } } /* Container */ -h4 a { - color: #222; +div.todos-container { + margin-bottom: 25px; + h4 { + margin-bottom: 0px; + color: #444; + a { + color: #444; + } + } } \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4fd7697e..f5e2e80b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -16,13 +16,6 @@ module ApplicationHelper {:id => "group_view_by_link", :accesskey => "g", :title => t('layouts.navigation.group_view_by_title'), :x_current_group_by => @group_view_by} ) end end - - def container_toggle(id) - link_to( - image_tag("blank.png", :alt => t('common.collapse_expand')), - "#", - {:class => "container_toggle", :id => id} ) - end def navigation_link(name, options = {}, html_options = nil, *parameters_for_method_reference) link_to name, options, html_options @@ -39,38 +32,31 @@ module ApplicationHelper return "" if due.nil? days = days_from_today(due) + days_limited = days + days_limited = -2 if days < -2 + days_limited = 2 if days > 2 - colors = ['amber','amber','orange','orange','orange','orange','orange','orange'] - color = :red if days < 0 - color = :green if days > 7 + colors = [:warning, :warning, :warning, :info, :info, :info] + color = :important if days < 0 + color = :default if days > 7 color = colors[days] if color.nil? - + + if prefs.due_style == Preference.due_styles[:due_on] + # TODO: internationalize strftime here + due_text = Hash.new( t('models.preference.due_on', :date => due.strftime("%A")) ) + else + due_text = Hash.new( t('models.preference.due_in', :days => days) ) + end + + due_text = Hash.new(t('models.preference.due_in', :days => days)).merge({ + "-2" => t('todos.next_actions_due_date.overdue_by_plural', :days => days * -1), + "-1" => t('todos.next_actions_due_date.overdue_by', :days => days * -1), + "0" => t('todos.next_actions_due_date.due_today'), + "1" => t('todos.next_actions_due_date.due_tomorrow') + }) + return content_tag(:a, {:title => format_date(due)}) { - content_tag(:span, {:class => color}) { - case days - when 0 - t('todos.next_actions_due_date.due_today') - when 1 - t('todos.next_actions_due_date.due_tomorrow') - when 2..7 - if prefs.due_style == Preference.due_styles[:due_on] - # TODO: internationalize strftime here - t('models.preference.due_on', :date => due.strftime("%A")) - else - t('models.preference.due_in', :days => days) - end - else - # overdue or due very soon! sound the alarm! - if days == -1 - t('todos.next_actions_due_date.overdue_by', :days => days * -1) - elsif days < -1 - t('todos.next_actions_due_date.overdue_by_plural', :days => days * -1) - else - # more than a week away - relax - t('models.preference.due_in', :days => days) - end - end - } + content_tag(:span, {:class => "badge badge-#{color}"}) { due_text[days_limited.to_s] } } end diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 30763d77..2da4e780 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -12,13 +12,8 @@ module TodosHelper end def todos_container_empty_message(container_name, container_id, show_message) - content_tag(:div, :id=>"#{container_id}-empty-d", :style=>"display:#{show_message ? 'block' : 'none'}") do - content_tag(:div, :class=>"message") do - content_tag(:p) do - t("todos.no_actions.#{container_name}") - end - end - end + render partial: "todos/container_empty_message", locals: + {container_id: container_id, container_name: container_name, show_message: show_message} end def show_grouped_todos(settings = {}) @@ -93,8 +88,8 @@ module TodosHelper def todos_container(settings={}) settings.reverse_merge!({ - :id => "#{settings[:container_name]}_container", - :class => "container #{settings[:container_name]}", + :id => "#{settings[:container_name]}-container", + :class => "todos-container #{settings[:container_name]}", }) if settings[:collapsible] @@ -115,7 +110,8 @@ module TodosHelper }) header = settings[:link_in_header].nil? ? "" : content_tag(:div, :class=>"add_note_link"){settings[:link_in_header]} header += content_tag(:h4) do - toggle = settings[:collapsible] ? container_toggle("toggle_#{settings[:id]}") : "" + toggle = "" + # toggle = settings[:collapsible] ? container_toggle("toggle_#{settings[:id]}") : "" "#{toggle} #{settings[:title]} #{settings[:append_descriptor]}".html_safe end header.html_safe @@ -126,10 +122,14 @@ module TodosHelper # do not pass :class to partial locals settings.delete(:class) - content_tag(:div, :id =>settings[:id]+"_items", :class=>"items toggle_target") do - todos_container_empty_message(settings[:container_name], settings[:id], collection.empty?) + - render(:partial => "todos/todo", :collection => collection, :locals => settings) - end + render :partial => 'todos/container_items', :locals => { + div_id: settings[:id]+"_items", + container_name: settings[:container_name], + todo_id: settings[:id], + hide_empty_message: collection.empty?, + collection: collection, + settings: settings + } end def todos_calendar_container(period, collection) @@ -281,7 +281,7 @@ module TodosHelper end def tag_span (tag, mobile=false) - content_tag(:span, :class => "label label-info #{tag.label}") { link_to(tag.name, tag_path(tag.name, :format => mobile ? :m : nil)) } + content_tag(:span, :class => "label #{tag.label}") { link_to(tag.name, tag_path(tag.name, :format => mobile ? :m : nil)) } end def tag_list(todo=@todo, mobile=false) diff --git a/app/views/todos/_container_empty_message.html.erb b/app/views/todos/_container_empty_message.html.erb new file mode 100644 index 00000000..85d7e703 --- /dev/null +++ b/app/views/todos/_container_empty_message.html.erb @@ -0,0 +1,5 @@ +
+
+

<%=t("todos.no_actions.#{container_name}")%>

+
+
\ No newline at end of file diff --git a/app/views/todos/_container_items.html.erb b/app/views/todos/_container_items.html.erb new file mode 100644 index 00000000..f51bf9f1 --- /dev/null +++ b/app/views/todos/_container_items.html.erb @@ -0,0 +1,4 @@ +
+ <%= todos_container_empty_message(container_name, todo_id, hide_empty_message) %> + <%= render(:partial => "todos/todo", :collection => collection, :locals => settings) %> +
\ No newline at end of file diff --git a/app/views/todos/_todo.html.erb b/app/views/todos/_todo.html.erb index 3e4a46ab..68e8005f 100644 --- a/app/views/todos/_todo.html.erb +++ b/app/views/todos/_todo.html.erb @@ -1,18 +1,23 @@ <% - suppress_context ||= false - suppress_project ||= false + suppress_context ||= false + suppress_project ||= false -%> -
- "> - "> - - - <%= date_span(todo) -%> - <%= todo.description %> - <%= content_tag(:i, {class: "icon-refresh"}){} if todo.from_recurring_todo? %> - <%= tag_list(todo) %> - <%= deferred_due_date(todo) %> - <%= project_and_context_links( todo, parent_container_type, :suppress_context => suppress_context, :suppress_project => suppress_project ) %> - - <%= content_tag(:i, {class: "icon-play-sign"}){} if todo.has_pending_successors %> +
+
+
+ "> + "> +
+
+ <%= todo.description %> + <%= content_tag(:i, {class: "icon-refresh"}){} if todo.from_recurring_todo? %> + <%= deferred_due_date(todo) %> + <%= content_tag(:i, {class: "icon-play-sign"}){} if todo.has_pending_successors %> + <%= content_tag(:i, {class: "icon-book"}){} unless todo.notes.blank? %> +
+
+
+ <%= date_span(todo) -%> + <%= tag_list(todo) %> +
\ No newline at end of file diff --git a/app/views/todos/index.html.erb b/app/views/todos/index.html.erb index 11b85cca..5811f272 100644 --- a/app/views/todos/index.html.erb +++ b/app/views/todos/index.html.erb @@ -8,9 +8,4 @@ <% end -%> <%= show_done_todos(@done, {:parent_container_type => @group_view_by, :collapsible => true}) unless @done.nil? %> -
- -
- <%= render :partial => "shared/add_new_item_form" %> - <%= render :file => "sidebar/sidebar" %>
\ No newline at end of file diff --git a/app/views/todos/tag.html.erb b/app/views/todos/tag.html.erb index 7eee6668..bfbdbff7 100644 --- a/app/views/todos/tag.html.erb +++ b/app/views/todos/tag.html.erb @@ -23,9 +23,4 @@ <%= show_done_todos(@done, done_options) unless @done.nil? %> - - -
- <%= render :partial => "shared/add_new_item_form" %> - <%= render :file => "sidebar/sidebar" %>
\ No newline at end of file