diff --git a/app/controllers/admin/product_controller.rb b/app/controllers/admin/product_controller.rb new file mode 100644 index 0000000..aa58865 --- /dev/null +++ b/app/controllers/admin/product_controller.rb @@ -0,0 +1,4 @@ +class Admin::ProductController < Admin::AbstractModelController + model_class Product + +end diff --git a/app/controllers/store_controller.rb b/app/controllers/store_controller.rb deleted file mode 100644 index 05d1e69..0000000 --- a/app/controllers/store_controller.rb +++ /dev/null @@ -1,3 +0,0 @@ -class StoreController < ApplicationController - scaffold :product -end diff --git a/app/views/admin/product/edit.rhtml b/app/views/admin/product/edit.rhtml new file mode 100644 index 0000000..1454fca --- /dev/null +++ b/app/views/admin/product/edit.rhtml @@ -0,0 +1,35 @@ +<% if @product.new_record? -%> +

New Product

+<% else -%> +

Edit Product

+<% end -%> + +
+ + + + + + + + + + + + + + + + + + +
<%= text_field :product, :code, :size => 100, :class => 'textbox' %>Required. Only numbers an letters allowed
<%= text_area :product, :description, :size => '40x4' %>Optional
<%= text_field :product, :price %>Required, has to be > 0.01
+

+ <%= save_model_button(@product) %> + <%= save_model_and_continue_editing_button(@product) %> + or <%= link_to "Cancel", product_index_url %> +

+ +
+ +<%= focus 'product_code' %> \ No newline at end of file diff --git a/app/views/admin/product/index.rhtml b/app/views/admin/product/index.rhtml new file mode 100644 index 0000000..42ad724 --- /dev/null +++ b/app/views/admin/product/index.rhtml @@ -0,0 +1,39 @@ +

Products

+ + + + + + + + + + + <% unless @products.empty? -%> + <% for product in @products %> + + + + + + + <% end %> + <% else %> + + + + <% end %> + +
CodeDescriptionPriceModify
<%= link_to h(product.code), product_edit_path(:id => product) %><%= link_to product.description, product_edit_path(:id => product) %><%=h product.price %> + <%= link_to image_tag("admin/remove.png", :alt => 'Remove Product'), + product_remove_path(:id => product) %> +
No Products
+ + +

+ <%= link_to 'New product', product_new_url %> +

\ No newline at end of file diff --git a/app/views/admin/product/remove.rhtml b/app/views/admin/product/remove.rhtml new file mode 100644 index 0000000..f080cc0 --- /dev/null +++ b/app/views/admin/product/remove.rhtml @@ -0,0 +1,20 @@ +

Remove Product

+

Are you sure you want to permanently remove + the following product?

+ + + + + + + + + +
<%= link_to h(@product.code), product_edit_path(:id => @product) %><%= link_to @product.description, product_edit_path(:id => @product) %><%=h @product.price %>
+ +
+

<%= submit_tag "Delete Product", :class => 'button' %> + or <%= link_to 'Cancel', product_index_path %>

+
diff --git a/shopping_trike_extension.rb b/shopping_trike_extension.rb index 361e556..b683d47 100644 --- a/shopping_trike_extension.rb +++ b/shopping_trike_extension.rb @@ -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 @@ -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