Display admin table of enterprise fees with enterprise, fee type and name columns

This commit is contained in:
Rohan Mitchell
2012-11-15 15:03:12 +11:00
parent 03764881c8
commit 6247bd2541
6 changed files with 42 additions and 2 deletions

View File

@@ -0,0 +1,10 @@
module Admin
class EnterpriseFeesController < ResourceController
before_filter :load_enterprise_fees_set, :only => :index
private
def load_enterprise_fees_set
@enterprise_fees_set = ModelSet.new EnterpriseFee.all, :collection => collection
end
end
end

View File

@@ -0,0 +1,5 @@
module EnterpriseFeesHelper
def enterprise_fee_options
EnterpriseFee::FEE_TYPES.map { |f| [f.capitalize, f] }
end
end

View File

@@ -1,7 +1,7 @@
class EnterpriseFee < ActiveRecord::Base
belongs_to :enterprise
FEE_TYPES = %w(Packing Transport Admin Sales)
FEE_TYPES = %w(packing transport admin sales)
validates_inclusion_of :fee_type, :in => FEE_TYPES
validates_presence_of :name

View File

@@ -0,0 +1,20 @@
= form_for @enterprise_fees_set, :url => main_app.bulk_update_admin_enterprise_fees_path do |enterprise_fees_set_form|
%table.index#listing_enterprise_fees
%thead
%tr
%th Enterprise
%th Fee Type
%th Name
%th Calculator
%th Calculator values
%th
%tbody
= enterprise_fees_set_form.fields_for :collection do |f|
- enterprise_fee = f.object
%tr
%td= f.collection_select :enterprise_id, Enterprise.all, :id, :name
%td= f.select :fee_type, enterprise_fee_options
%td= f.text_field :name
%td TODO
%td TODO
%td TODO

View File

@@ -12,7 +12,9 @@ Openfoodweb::Application.routes.draw do
resources :enterprises do
post :bulk_update, :on => :collection, :as => :bulk_update
end
resources :enterprise_fees
resources :enterprise_fees do
post :bulk_update, :on => :collection, :as => :bulk_update
end
end
# Mount Spree's routes

View File

@@ -21,6 +21,9 @@ FactoryGirl.define do
end
factory :enterprise_fee, :class => EnterpriseFee do
enterprise { Enterprise.first || FactoryGirl.create(:supplier_enterprise) }
fee_type 'packing'
name '$0.50 / kg'
end
factory :product_distribution, :class => ProductDistribution do