Skip to content
Snippets Groups Projects
Commit bd706c91 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Make a list partial for listing RecurringItemRanges, and fix it.

parent ea0048eb
No related branches found
No related tags found
No related merge requests found
<% ignored_columns = [] %>
<% sorted_columns = ["recurring_item_id", "startdate", "enddate",
"amount", "schedule_id"] %>
<% for column in RecurringItemRange.content_columns %>
<% if not (ignored_columns + sorted_columns).include?(column.name) %>
<% sorted_columns << column.name %>
<% end %>
<% end %>
<table border="1">
<tr>
<th colspan="2">&nbsp;</th>
<% for column_name in sorted_columns %>
<% puts column_name %>
<th><%= RecurringItemRange.columns_hash[column_name].human_name %></th>
<%end%>
<th>&nbsp;</th>
</tr>
<% for recurring_item_range in @recurring_item_ranges %>
<tr>
<td><%= link_to 'Edit', :action => 'edit', :id => recurring_item_range %></td>
<td><%= link_to 'Show', :action => 'show', :id => recurring_item_range %></td>
<% for column_name in sorted_columns %>
<td class="<%= column_name %>">
<% case column_name
when "startdate": %>
<%= recurring_item_range["startdate"].strftime("%Y-%m-%d") %>
<% when "enddate": %>
<% if recurring_item_range["enddate"].nil? %>
---
<% else %>
<%= recurring_item_range["startdate"].strftime("%Y-%m-%d") %>
<% end %>
<% when "schedule_id": %>
<% if recurring_item_range.schedule.nil? %>
&nbsp;
<% else %>
<%=h recurring_item_range.schedule.name %>
<% end %>
<% when "recurring_item_id": %>
<% if recurring_item_range.recurring_item.nil? %>
---
<% else %>
<%=h recurring_item_range.recurring_item.description %>
<% end %>
<% else %>
<% if recurring_item_range[column_name].to_s != "" %>
<%=h recurring_item_range.send(column_name) %>
<% else %>
&nbsp;
<% end %>
<% end %>
</td>
<% end %>
<td><%= link_to 'Destroy', { :action => 'destroy', :id => recurring_item_range }, :confirm => 'Are you sure?', :post => true %></td>
</tr>
<% end %>
</table>
<% @heading = "Listing recurring_item_ranges" %>
<table>
<tr>
<% for column in RecurringItemRange.content_columns %>
<th><%= column.human_name %></th>
<% end %>
</tr>
<% for recurring_item_range in @recurring_item_ranges %>
<tr>
<% for column in RecurringItemRange.content_columns %>
<td><%=h recurring_item_range.send(column.name) %></td>
<% end %>
<td><%= link_to 'Show', :action => 'show', :id => recurring_item_range %></td>
<td><%= link_to 'Edit', :action => 'edit', :id => recurring_item_range %></td>
<td><%= link_to 'Destroy', { :action => 'destroy', :id => recurring_item_range }, :confirm => 'Are you sure?', :post => true %></td>
</tr>
<% end %>
</table>
<%= render :partial => 'list' %>
<%= link_to 'Previous page', { :page => @recurring_item_range_pages.current.previous } if @recurring_item_range_pages.current.previous %>
<%= link_to 'Next page', { :page => @recurring_item_range_pages.current.next } if @recurring_item_range_pages.current.next %>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment