From 159acac9b671539e279cbb2d4347a22e9683b626 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Mon, 26 Aug 2013 12:08:33 +0200 Subject: [PATCH] add forms for new todo and multiple todos to modal AJAX is not enabled yet --- app/assets/stylesheets/tracks.css.scss | 7 ++ app/helpers/todos_helper.rb | 7 ++ app/views/shared/_add_new_action.html.erb | 31 ++++--- app/views/todos/_new_multi_todo_form.html.erb | 48 +++++----- app/views/todos/_new_todo_form.html.erb | 87 +++++++++---------- 5 files changed, 93 insertions(+), 87 deletions(-) diff --git a/app/assets/stylesheets/tracks.css.scss b/app/assets/stylesheets/tracks.css.scss index 5bbf0883..877c5412 100644 --- a/app/assets/stylesheets/tracks.css.scss +++ b/app/assets/stylesheets/tracks.css.scss @@ -200,6 +200,13 @@ div.paginate_header { text-align: center; } +/* Todo form */ +form#todo-form-new-action { + .control-group { + margin-bottom: 10px; + } +} + /* Generic */ div.hide_me { diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 91e702c7..e6e44aac 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -123,6 +123,13 @@ module TodosHelper } end + def todo_form_control_group (label_for, label) + content_tag(:div, class: "control-group") do + content_tag(:label, class: "control-label", for: label_for){label} + + content_tag(:div, class:"controls") { yield } + end + end + # === helpers for rendering a todo def todo_notes(todo) diff --git a/app/views/shared/_add_new_action.html.erb b/app/views/shared/_add_new_action.html.erb index 456593fb..ff17ab26 100644 --- a/app/views/shared/_add_new_action.html.erb +++ b/app/views/shared/_add_new_action.html.erb @@ -1,17 +1,22 @@ \ No newline at end of file diff --git a/app/views/todos/_new_multi_todo_form.html.erb b/app/views/todos/_new_multi_todo_form.html.erb index 1330999a..5924f46d 100644 --- a/app/views/todos/_new_multi_todo_form.html.erb +++ b/app/views/todos/_new_multi_todo_form.html.erb @@ -1,9 +1,9 @@ <%- todo = new_multi_todo_form -%> - - + +<% end -%> \ No newline at end of file diff --git a/app/views/todos/_new_todo_form.html.erb b/app/views/todos/_new_todo_form.html.erb index bc616a86..102f7574 100644 --- a/app/views/todos/_new_todo_form.html.erb +++ b/app/views/todos/_new_todo_form.html.erb @@ -1,65 +1,60 @@ <%- todo = new_todo_form -%> - -
- <%= form_for(todo, :html=> { :id=>'todo-form-new-action', :name=>'todo', :class => 'inline-form new_todo_form' }) do |t|%> - - - +<%= form_for(todo, :html=> { :id=>'todo-form-new-action', :name=>'todo', :class => 'form-horizontal' }) do |t|%> +
+ + + + <%= hidden_field_tag :_tag_name, @tag_name.underscore.gsub(/\s+/,'_') if source_view_is :tag -%> + <%= hidden_field_tag "initial_tag_list", @initial_tags%> + <%= source_view_tag( @source_view ) %>
<%= get_list_of_error_messages_for(todo) %>
- - <%= image_tag("blank.png", :title =>t('todos.star_action'), :class => "todo_star", :style=> "float: right")%> - <%= t.text_field("description", "size" => 30, "tabindex" => next_tab_index, "maxlength" => 100, "autocomplete" => "off", :autofocus => 1) %> + <%= todo_form_control_group("todo_starred", "Starred") do -%> + + <% end -%> - - <%= t.text_area("notes", "cols" => 29, "rows" => 6, "tabindex" => next_tab_index) %> + <%= todo_form_control_group("todo_description", Todo.human_attribute_name('description')) do -%> + <%= t.text_field("description", + "size" => 30, "maxlength" => 100, "autocomplete" => "off", + placeholder: "Description of action", :autofocus => 1) + %> + <% end -%> - - - + <%= todo_form_control_group("todo_notes", Todo.human_attribute_name('notes')) do -%> + <%= t.text_area("notes", "cols" => 29, "rows" => 6) %> + <% end -%> - - + <%= todo_form_control_group("todo_project_name", Todo.human_attribute_name('project')) do -%> + + <% end -%> - - <%= hidden_field_tag "initial_tag_list", @initial_tags%> - <%= text_field_tag "tag_list", @initial_tags, :size => 30, :tabindex => next_tab_index %> - <%= content_tag("div", "", :id => "tag_list_auto_complete", :class => "auto_complete") %> + <%= todo_form_control_group("todo_context_name", Todo.human_attribute_name('context')) do -%> + + <% end -%> -
- - <%= t.text_field("due", "size" => 12, "class" => "Date", "tabindex" => next_tab_index, "autocomplete" => "off") %> -
+ <%= todo_form_control_group("tag_list", Todo.human_attribute_name('tags')) do -%> + <%= text_field_tag "tag_list", @initial_tags, :size => 30, placeholder: t('shared.separate_tags_with_commas') %> + <% end -%> -
- - <%= t.text_field("show_from", "size" => 12, "class" => "Date", "tabindex" => next_tab_index, "autocomplete" => "off") %> -
+ <%= todo_form_control_group("todo_due", Todo.human_attribute_name('due')) do -%> + <%= t.text_field("due", "size" => 12, "class" => "Date", "autocomplete" => "off") %> + <% end -%> -
- + <%= todo_form_control_group("todo_show_from", Todo.human_attribute_name('show_from')) do -%> + <%= t.text_field("show_from", "size" => 12, "class" => "Date", "autocomplete" => "off") %> + <% end -%> + + <%= todo_form_control_group("predecessor_ul", Todo.human_attribute_name('predecessors')) do -%>
- <%= text_field_tag "predecessor_input", nil, :size => 30, :tabindex => next_tab_index %> - <%= hidden_field_tag "predecessor_list", ""%> -
+ <%= text_field_tag "predecessor_input", nil, :size => 30%> + <% end -%> - <%= source_view_tag( @source_view ) %> - <%= hidden_field_tag :_tag_name, @tag_name.underscore.gsub(/\s+/,'_') if source_view_is :tag %> - -
-
- -
-
- - <% end # form_for -%> -
+ +<% end # form_for -%> \ No newline at end of file