From db32afe21a4ac4439f0f0d25a610d28fd098b347 Mon Sep 17 00:00:00 2001 From: MoisesMachado Date: Sat, 1 Dec 2007 21:01:07 +0000 Subject: [PATCH] ActionItem: added blocks and visualization of categories --- app/controllers/my_profile/consumed_products_controller.rb | 33 +++++++++++++++++++++++++++++++++ app/design_blocks/list_block/views/edit.rhtml | 15 +++++++++++++++ app/design_blocks/list_block/views/show.rhtml | 1 + app/helpers/consumed_products_helper.rb | 2 ++ app/views/category/_category.rhtml | 10 ++++++++++ app/views/category/_product_category.rhtml | 11 +++++++++++ app/views/search/_product.rhtml | 11 +++++++++++ 7 files changed, 83 insertions(+), 0 deletions(-) create mode 100644 app/controllers/my_profile/consumed_products_controller.rb create mode 100644 app/design_blocks/list_block/views/edit.rhtml create mode 100644 app/design_blocks/list_block/views/show.rhtml create mode 100644 app/helpers/consumed_products_helper.rb create mode 100644 app/views/category/_category.rhtml create mode 100644 app/views/category/_product_category.rhtml create mode 100644 app/views/search/_product.rhtml diff --git a/app/controllers/my_profile/consumed_products_controller.rb b/app/controllers/my_profile/consumed_products_controller.rb new file mode 100644 index 0000000..0504e40 --- /dev/null +++ b/app/controllers/my_profile/consumed_products_controller.rb @@ -0,0 +1,33 @@ +class ConsumedProductsController < ApplicationController + needs_profile + +# protect 'manage_products', :profile + + def index + @consumptions = @profile.consumptions + @product_categories = @profile.consumed_product_categories + end + + def new + @consumption = @profile.consumptions.build(params[:consumption]) + if request.post? + if @consumption.save + flash[:notice] = _('Product succesfully created') + redirect_to :action => 'index' + else + flash[:notice] = _('Could not create the product') + end + end + end + + def destroy + @consumption = @profile.consumptions.find(params[:id]) + if @consumption.destroy + flash[:notice] = _('Product succesfully removed') + else + flash[:notice] = _('Could not remove the product') + end + redirect_back_or_default :action => 'index' + end + +end diff --git a/app/design_blocks/list_block/views/edit.rhtml b/app/design_blocks/list_block/views/edit.rhtml new file mode 100644 index 0000000..2dda4db --- /dev/null +++ b/app/design_blocks/list_block/views/edit.rhtml @@ -0,0 +1,15 @@ +

<%= _('Editing list of people') %>

+ +<% design_form_remote_tag( :url => {:action => 'save'}) do %> +

+ + <%= text_field 'design_block', 'title'%> +

+ +

+ + <%= text_field 'design_block', 'limit_number'%> +

+ + <%= submit_tag _('Save') %> +<% end %> diff --git a/app/design_blocks/list_block/views/show.rhtml b/app/design_blocks/list_block/views/show.rhtml new file mode 100644 index 0000000..8265d66 --- /dev/null +++ b/app/design_blocks/list_block/views/show.rhtml @@ -0,0 +1 @@ +

<%= _('Limit number of people: ') %> <%= @design_block.limit_number %>

diff --git a/app/helpers/consumed_products_helper.rb b/app/helpers/consumed_products_helper.rb new file mode 100644 index 0000000..ce17972 --- /dev/null +++ b/app/helpers/consumed_products_helper.rb @@ -0,0 +1,2 @@ +module ConsumedProductsHelper +end diff --git a/app/views/category/_category.rhtml b/app/views/category/_category.rhtml new file mode 100644 index 0000000..76f9d00 --- /dev/null +++ b/app/views/category/_category.rhtml @@ -0,0 +1,10 @@ +<%# FIXME %> +

+This page will list everything (articles, documents, photos, etc) that is +related to <%= @category.full_name %>. Actually generating this content is not +implement yet, though. +

+ +

+And yes, this placeholder text is not translated. +

diff --git a/app/views/category/_product_category.rhtml b/app/views/category/_product_category.rhtml new file mode 100644 index 0000000..f75e59e --- /dev/null +++ b/app/views/category/_product_category.rhtml @@ -0,0 +1,11 @@ +<%= @products.size.to_s + " products in this category" %> +<%= @enterprises.size.to_s + " enterprises sells products in this category" %> + + diff --git a/app/views/search/_product.rhtml b/app/views/search/_product.rhtml new file mode 100644 index 0000000..9706b0d --- /dev/null +++ b/app/views/search/_product.rhtml @@ -0,0 +1,11 @@ +<%# FIXME add photo if available %> +<%# FIXME add more information %> + +
+ <%= icon('product') %> +
+ + <%= link_to( hit.name, :profile => hit.enterprise.identifier, :controller => 'catalog', :action => 'show', :id => hit) %> + +
+
-- libgit2 0.21.2