From 4e099b84df34e7608245c033bac5cd90ac4e257b Mon Sep 17 00:00:00 2001 From: Per Cederqvist <ceder@lysator.liu.se> Date: Thu, 10 Aug 2006 19:55:35 +0000 Subject: [PATCH] Use an application layout. Use a list partial for the recurring_items view. --- app/views/layouts/application.rhtml | 24 +++++++++++ app/views/layouts/recurring_items.rhtml | 13 ------ app/views/layouts/schedules.rhtml | 13 ------ app/views/recurring_items/_list.rhtml | 55 +++++++++++++++++++++++++ app/views/recurring_items/edit.rhtml | 2 +- app/views/recurring_items/list.rhtml | 23 ++--------- app/views/recurring_items/new.rhtml | 2 +- app/views/recurring_items/show.rhtml | 2 + app/views/schedules/edit.rhtml | 2 +- app/views/schedules/list.rhtml | 2 +- app/views/schedules/new.rhtml | 2 +- app/views/schedules/show.rhtml | 2 + 12 files changed, 91 insertions(+), 51 deletions(-) create mode 100644 app/views/layouts/application.rhtml delete mode 100644 app/views/layouts/recurring_items.rhtml delete mode 100644 app/views/layouts/schedules.rhtml create mode 100644 app/views/recurring_items/_list.rhtml diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml new file mode 100644 index 0000000..408aae8 --- /dev/null +++ b/app/views/layouts/application.rhtml @@ -0,0 +1,24 @@ +<html> +<head> + <title><%= @heading %></title> + <%= stylesheet_link_tag 'scaffold' %> +</head> +<body> + +<p style="color: green"><%= flash[:notice] %></p> + +<h1><%= @heading %></h1> +<%= @content_for_layout %> + +<p/> +<% if not @back.nil? %> + <% if not @back_page.nil? %> + <%= link_to 'Back', :action => @back, :page => @back_page %> + <% else %> + <%= link_to 'Back', :action => @back %> + <% end %> +<% end %> +<br /> + +</body> +</html> diff --git a/app/views/layouts/recurring_items.rhtml b/app/views/layouts/recurring_items.rhtml deleted file mode 100644 index fc6177b..0000000 --- a/app/views/layouts/recurring_items.rhtml +++ /dev/null @@ -1,13 +0,0 @@ -<html> -<head> - <title>RecurringItems: <%= controller.action_name %></title> - <%= stylesheet_link_tag 'scaffold' %> -</head> -<body> - -<p style="color: green"><%= flash[:notice] %></p> - -<%= @content_for_layout %> - -</body> -</html> diff --git a/app/views/layouts/schedules.rhtml b/app/views/layouts/schedules.rhtml deleted file mode 100644 index af23b3a..0000000 --- a/app/views/layouts/schedules.rhtml +++ /dev/null @@ -1,13 +0,0 @@ -<html> -<head> - <title>Schedules: <%= controller.action_name %></title> - <%= stylesheet_link_tag 'scaffold' %> -</head> -<body> - -<p style="color: green"><%= flash[:notice] %></p> - -<%= @content_for_layout %> - -</body> -</html> diff --git a/app/views/recurring_items/_list.rhtml b/app/views/recurring_items/_list.rhtml new file mode 100644 index 0000000..8c2492e --- /dev/null +++ b/app/views/recurring_items/_list.rhtml @@ -0,0 +1,55 @@ +<% ignored_columns = ["created_on", "updated_on"] %> +<% sorted_columns = ["schedule_id"] %> + +<% for column in RecurringItems.content_columns %> + <% if not (ignored_columns + sorted_columns).include?(column.name) %> + <% sorted_columns << column.name %> + <% end %> +<% end %> + +<table border="1"> + <tr> + <th colspan="2"> </th> + <% for column_name in sorted_columns %> + <th><%= RecurringItems.columns_hash[column_name].human_name %></th> + <%end%> + <th> </th> + </tr> + +<% for recurring_item in @recurring_items %> + <tr class="<%= if recurring_item["amount"] < 0 then "debet" else "credit" end %>"> + <td><%= link_to 'Edit', :action => 'edit', :id => recurring_item %></td> + <td><%= link_to 'Show', :action => 'show', :id => recurring_item %></td> + + <% for column_name in sorted_columns %> + <td class="<%= column_name %>"> + <% case column_name + when "startdate": %> + <%= recurring_item["startdate"].strftime("%Y-%m-%d") %> + <% when "enddate": %> + <% if recurring_item["enddate"].nil? %> + --- + <% else %> + <%= recurring_item["startdate"].strftime("%Y-%m-%d") %> + <% end %> + <% when "schedule_id": %> + <% if recurring_item.schedule.nil? %> + + <% else %> + <%=h recurring_item.schedule.name %> + <% end %> + <% else %> + <% if recurring_item[column_name].to_s != "" %> + <%=h recurring_item.send(column_name) %> + <% else %> + + <% end %> + <% end %> + </td> + <% end %> + + <td><%= link_to 'Destroy', { :action => 'destroy', :id => recurring_item }, :confirm => 'Are you sure?', :post => true %></td> + + </tr> +<% end %> +</table> diff --git a/app/views/recurring_items/edit.rhtml b/app/views/recurring_items/edit.rhtml index 4ec015c..4ee50d0 100644 --- a/app/views/recurring_items/edit.rhtml +++ b/app/views/recurring_items/edit.rhtml @@ -1,4 +1,4 @@ -<h1>Editing recurring_items</h1> +<% @heading = "Editing recurring_items" %> <%= start_form_tag :action => 'update', :id => @recurring_items %> <%= render :partial => 'form' %> diff --git a/app/views/recurring_items/list.rhtml b/app/views/recurring_items/list.rhtml index e63673d..21096f2 100644 --- a/app/views/recurring_items/list.rhtml +++ b/app/views/recurring_items/list.rhtml @@ -1,27 +1,10 @@ -<h1>Listing recurring_items</h1> +<% @heading = "Listing recurring_items" %> -<table> - <tr> - <% for column in RecurringItems.content_columns %> - <th><%= column.human_name %></th> - <% end %> - </tr> - -<% for recurring_items in @recurring_items %> - <tr> - <% for column in RecurringItems.content_columns %> - <td><%=h recurring_items.send(column.name) %></td> - <% end %> - <td><%= link_to 'Show', :action => 'show', :id => recurring_items %></td> - <td><%= link_to 'Edit', :action => 'edit', :id => recurring_items %></td> - <td><%= link_to 'Destroy', { :action => 'destroy', :id => recurring_items }, :confirm => 'Are you sure?', :post => true %></td> - </tr> -<% end %> -</table> +<%= render :partial => 'list' %> <%= link_to 'Previous page', { :page => @recurring_items_pages.current.previous } if @recurring_items_pages.current.previous %> <%= link_to 'Next page', { :page => @recurring_items_pages.current.next } if @recurring_items_pages.current.next %> <br /> -<%= link_to 'New recurring_items', :action => 'new' %> +<%= link_to 'New recurring_item', :action => 'new' %> diff --git a/app/views/recurring_items/new.rhtml b/app/views/recurring_items/new.rhtml index c6b1bbb..daa51ff 100644 --- a/app/views/recurring_items/new.rhtml +++ b/app/views/recurring_items/new.rhtml @@ -1,4 +1,4 @@ -<h1>New recurring_items</h1> +<% @heading = "New recurring_item" %> <%= start_form_tag :action => 'create' %> <%= render :partial => 'form' %> diff --git a/app/views/recurring_items/show.rhtml b/app/views/recurring_items/show.rhtml index 8ce83ad..6603035 100644 --- a/app/views/recurring_items/show.rhtml +++ b/app/views/recurring_items/show.rhtml @@ -1,3 +1,5 @@ +<% @heading = "Showing recurring_item" %> + <% for column in RecurringItems.content_columns %> <p> <b><%= column.human_name %>:</b> <%=h @recurring_items.send(column.name) %> diff --git a/app/views/schedules/edit.rhtml b/app/views/schedules/edit.rhtml index d65c92d..c624eb9 100644 --- a/app/views/schedules/edit.rhtml +++ b/app/views/schedules/edit.rhtml @@ -1,4 +1,4 @@ -<h1>Editing schedules</h1> +<% @heading = "Editing schedule" %> <%= start_form_tag :action => 'update', :id => @schedules %> <%= render :partial => 'form' %> diff --git a/app/views/schedules/list.rhtml b/app/views/schedules/list.rhtml index 546c15d..2486d89 100644 --- a/app/views/schedules/list.rhtml +++ b/app/views/schedules/list.rhtml @@ -1,4 +1,4 @@ -<h1>Listing schedules</h1> +<% @heading = "Listing schedules" %> <table> <tr> diff --git a/app/views/schedules/new.rhtml b/app/views/schedules/new.rhtml index fd1eec8..fedc8a9 100644 --- a/app/views/schedules/new.rhtml +++ b/app/views/schedules/new.rhtml @@ -1,4 +1,4 @@ -<h1>New schedules</h1> +<% @heading = "New schedule" %> <%= start_form_tag :action => 'create' %> <%= render :partial => 'form' %> diff --git a/app/views/schedules/show.rhtml b/app/views/schedules/show.rhtml index f58027f..2f2bd9c 100644 --- a/app/views/schedules/show.rhtml +++ b/app/views/schedules/show.rhtml @@ -1,3 +1,5 @@ +<% @heading = "Show schedule" %> + <% for column in Schedules.content_columns %> <p> <b><%= column.human_name %>:</b> <%=h @schedules.send(column.name) %> -- GitLab