mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Display admin table of enterprise fees with enterprise, fee type and name columns
This commit is contained in:
10
app/controllers/admin/enterprise_fees_controller.rb
Normal file
10
app/controllers/admin/enterprise_fees_controller.rb
Normal 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
|
||||
5
app/helpers/enterprise_fees_helper.rb
Normal file
5
app/helpers/enterprise_fees_helper.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
module EnterpriseFeesHelper
|
||||
def enterprise_fee_options
|
||||
EnterpriseFee::FEE_TYPES.map { |f| [f.capitalize, f] }
|
||||
end
|
||||
end
|
||||
@@ -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
|
||||
|
||||
20
app/views/admin/enterprise_fees/index.html.haml
Normal file
20
app/views/admin/enterprise_fees/index.html.haml
Normal 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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user