Skip to content
This repository has been archived by the owner on Mar 29, 2018. It is now read-only.

Commit

Permalink
adding more polished admin interface for products
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.trike.com.au/code/radiant/extensions/shopping_trike@77 dec4ba91-d232-0410-a499-b0f1e7490611
  • Loading branch information
gerrit committed Mar 12, 2008
1 parent ad5250e commit 870be22
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/controllers/admin/product_controller.rb
@@ -0,0 +1,4 @@
class Admin::ProductController < Admin::AbstractModelController
model_class Product

end
3 changes: 0 additions & 3 deletions app/controllers/store_controller.rb

This file was deleted.

35 changes: 35 additions & 0 deletions app/views/admin/product/edit.rhtml
@@ -0,0 +1,35 @@
<% if @product.new_record? -%>
<h1>New Product</h1>
<% else -%>
<h1>Edit Product</h1>
<% end -%>

<form method="post" action="">
<table class="fieldset">
<tbody>
<tr>
<td class="label"><label for="product_code">Code</label></td>
<td class="field"><%= text_field :product, :code, :size => 100, :class => 'textbox' %></td>
<td class="help">Required. Only numbers an letters allowed</td>
</tr>
<tr>
<td class="label"><label class="optional" for="product_description">Description</label></td>
<td class="field"><%= text_area :product, :description, :size => '40x4' %></td>
<td class="help">Optional</td>
</tr>
<tr>
<td class="label"><label for="product_price">Price</label></td>
<td class="field"><%= text_field :product, :price %></td>
<td class="help">Required, has to be > 0.01</td>
</tr>
</tbody>
</table>
<p class="buttons">
<%= save_model_button(@product) %>
<%= save_model_and_continue_editing_button(@product) %>
or <%= link_to "Cancel", product_index_url %>
</p>

</form>

<%= focus 'product_code' %>
39 changes: 39 additions & 0 deletions app/views/admin/product/index.rhtml
@@ -0,0 +1,39 @@
<h1>Products</h1>
<table id="products" class="index">
<thead>
<tr>
<th>Code</th>
<th>Description</th>
<th>Price</th>
<th>Modify</th>
</tr>
</thead>
<tbody>
<% unless @products.empty? -%>
<% for product in @products %>
<tr class="node">
<td class="code"><%= link_to h(product.code), product_edit_path(:id => product) %></td>
<td class="description"><%= link_to product.description, product_edit_path(:id => product) %></td>
<td><%=h product.price %></td>
<td class="remove">
<%= link_to image_tag("admin/remove.png", :alt => 'Remove Product'),
product_remove_path(:id => product) %>
</td>
</tr>
<% end %>
<% else %>
<tr>
<td colspan="4" class="note">No Products</td>
</tr>
<% end %>
</tbody>
</table>
<script type="text/javascript">
// <![CDATA[
new RuledTable('products');
// ]]>
</script>

<p>
<%= link_to 'New product', product_new_url %>
</p>
20 changes: 20 additions & 0 deletions app/views/admin/product/remove.rhtml
@@ -0,0 +1,20 @@
<h1>Remove Product</h1>
<p>Are you sure you want to <strong class="warning">permanently remove</strong>
the following product?</p>

<table id="products" class="index">
<tbody>
<tr class="node level-1"
onmouseover="Element.addClassName(this, 'highlight');"
onmouseout="Element.removeClassName(this, 'highlight');">
<td class="code"><%= link_to h(@product.code), product_edit_path(:id => @product) %></td>
<td class="description"><%= link_to @product.description, product_edit_path(:id => @product) %></td>
<td><%=h @product.price %></td>
</tr>
</tbody>
</table>

<form method="post" action="">
<p class="buttons"><%= submit_tag "Delete Product", :class => 'button' %>
or <%= link_to 'Cancel', product_index_path %></p>
</form>
12 changes: 10 additions & 2 deletions shopping_trike_extension.rb
Expand Up @@ -7,7 +7,15 @@ class ShoppingTrikeExtension < Radiant::Extension
url "http://code.trike.com.au/svn/radiant/extensions/shopping_trike/"

define_routes do |map|
map.connect 'admin/store/:action', :controller => 'store'
# map.connect 'admin/store/:action', :controller => 'store'
# Product Routes
map.with_options(:controller => 'admin/product') do |product|
product.product_index 'admin/products', :action => 'index'
product.product_edit 'admin/products/edit/:id', :action => 'edit'
product.product_new 'admin/products/new', :action => 'new'
product.product_remove 'admin/products/remove/:id', :action => 'remove'
end

map.connect 'shopping_trike/cart/:action', :controller => 'cart'
end

Expand All @@ -17,7 +25,7 @@ def activate
session :disabled => false
end

admin.tabs.add "Products", "/admin/store", :after => "Layouts", :visibility => [:all]
admin.tabs.add "Products", "/admin/products", :after => "Layouts", :visibility => [:all]
end

def deactivate
Expand Down

0 comments on commit 870be22

Please sign in to comment.