From c1d04af5ccfc3003f7878a064de348caf8ea4bf2 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 28 Oct 2015 11:40:01 +1100 Subject: [PATCH] Implementing monthly billing description logic in required pages --- .../monthly_pricing_description.js.coffee | 8 +++++ .../admin/panels/enterprise_package.html.haml | 22 ++++++------- app/helpers/admin/injection_helper.rb | 6 ++++ .../enterprises/_change_type_form.html.haml | 32 ++++--------------- app/views/admin/enterprises/index.html.haml | 1 + 5 files changed, 32 insertions(+), 37 deletions(-) create mode 100644 app/assets/javascripts/admin/enterprises/directives/monthly_pricing_description.js.coffee diff --git a/app/assets/javascripts/admin/enterprises/directives/monthly_pricing_description.js.coffee b/app/assets/javascripts/admin/enterprises/directives/monthly_pricing_description.js.coffee new file mode 100644 index 0000000000..6331fa2ca5 --- /dev/null +++ b/app/assets/javascripts/admin/enterprises/directives/monthly_pricing_description.js.coffee @@ -0,0 +1,8 @@ +angular.module("admin.enterprises").directive "monthlyPricingDescription", (monthlyBillDescription) -> + restrict: 'E' + scope: + joiner: "@" + template: "" + link: (scope, element, attrs) -> + joiners = { comma: ", ", newline: "
" } + scope.billDescription = monthlyBillDescription.replace("{joiner}", joiners[scope.joiner]) diff --git a/app/assets/javascripts/templates/admin/panels/enterprise_package.html.haml b/app/assets/javascripts/templates/admin/panels/enterprise_package.html.haml index c42d8910e1..7f143d1071 100644 --- a/app/assets/javascripts/templates/admin/panels/enterprise_package.html.haml +++ b/app/assets/javascripts/templates/admin/panels/enterprise_package.html.haml @@ -15,7 +15,8 @@ %h3 Hub Shop %p - %strong COST: 2% OF SALES, CAPPED AT $50 PER MONTH + %strong + %monthly-pricing-description{ joiner: "comma" } %p Your enterprise is the backbone of your local food system. You aggregate produce from other enterprises and can sell it through your shop on the Open Food Network. @@ -53,7 +54,8 @@ %h3 Producer Shop %p - %strong COST: 2% OF SALES, CAPPED AT $50 PER MONTH + %strong + %monthly-pricing-description{ joiner: "comma" } %p Sell your products directly to customers through your very own Open Food Network shopfront. @@ -63,7 +65,8 @@ %h3 Producer Hub %p - %strong COST: 2% OF SALES, CAPPED AT $50 PER MONTH + %strong + %monthly-pricing-description{ joiner: "comma" } %p Your enterprise is the backbone of your local food system. You can sell your own produce as well as produce aggregated from other enterprises through your shopfront on the Open Food Network. @@ -94,9 +97,7 @@ %h3 Hub Shop %p Sell produce from others .bottom - \2% OF SALES - %br - CAPPED AT $50 PER MONTH + %monthly-pricing-description{ joiner: "newline" } %div{ ng: { switch: { when: "true" } } } %a.button.selector.producer-profile{ ng: { click: "enterprise.owned && (enterprise.sells='none')", class: "{selected: enterprise.sells=='none', disabled: !enterprise.owned}" } } @@ -109,17 +110,14 @@ %h3 Producer Shop %p Sell your own produce .bottom - \2% OF SALES - %br - CAPPED AT $50 PER MONTH + %monthly-pricing-description{ joiner: "newline" } + %a.button.selector.producer-hub{ ng: { click: "enterprise.owned && (enterprise.sells='any')", class: "{selected: enterprise.sells=='any', disabled: !enterprise.owned}" } } .top %h3 Producer Hub %p Sell produce from self and others .bottom - \2% OF SALES - %br - CAPPED AT $50 PER MONTH + %monthly-pricing-description{ joiner: "newline" } %a.button.update.fullwidth{ ng: { show: "enterprise.owned", class: "{disabled: saved() && !saving, saving: saving}", click: "save()" } } %span{ ng: {hide: "saved() || saving" } } diff --git a/app/helpers/admin/injection_helper.rb b/app/helpers/admin/injection_helper.rb index 490e3dc00b..6036447d9b 100644 --- a/app/helpers/admin/injection_helper.rb +++ b/app/helpers/admin/injection_helper.rb @@ -1,5 +1,7 @@ module Admin module InjectionHelper + include BusinessModelConfigurationHelper + def admin_inject_enterprise admin_inject_json_ams "admin.enterprises", "enterprise", @enterprise, Api::Admin::EnterpriseSerializer end @@ -78,6 +80,10 @@ module Admin admin_inject_json_ams_array "admin.orders", "orderCycles", @order_cycles, Api::Admin::BasicOrderCycleSerializer, current_user: spree_current_user end + def admin_inject_monthly_bill_description + render partial: "admin/json/injection_ams", locals: {ngModule: "admin.enterprises", name: "monthlyBillDescription", json: monthly_bill_description.to_json} + end + def admin_inject_spree_api_key render partial: "admin/json/injection_ams", locals: {ngModule: 'ofn.admin', name: 'SpreeApiKey', json: "'#{@spree_api_key.to_s}'"} end diff --git a/app/views/admin/enterprises/_change_type_form.html.haml b/app/views/admin/enterprises/_change_type_form.html.haml index 740857e381..6474af1344 100644 --- a/app/views/admin/enterprises/_change_type_form.html.haml +++ b/app/views/admin/enterprises/_change_type_form.html.haml @@ -1,4 +1,5 @@ = admin_inject_enterprise += admin_inject_monthly_bill_description = form_for @enterprise, url: main_app.register_admin_enterprise_path(@enterprise), html: { name: "change_type", id: "change_type", novalidate: true, "ng-app" => "admin.enterprises", "ng-controller"=> 'changeTypeFormCtrl' } do |change_type_form| @@ -16,9 +17,6 @@ .bottom ALWAYS FREE %p.description Add your products to Open Food Network, allowing hubs to stock your products in their stores. - %br - %br - Having a profile, and making connections within your local food system through the Open Food Network will always be free. .producer_shop.option.one-third.column %a.full-width.button.selector{ ng: { click: "sells='own'", class: "{selected: sells=='own'}" } } @@ -26,17 +24,13 @@ %h3 Producer Shop %p Sell your own produce .bottom - \%2 OF SALES - %br - CAPPED AT $50 PER MONTH + %monthly-pricing-description{ joiner: "newline" } + %p.description Sell your products directly to customers through your very own Open Food Network shopfront. %br %br A Producer Shop is for your produce only, if you want to sell produce grown/produced off site, select 'Producer Hub'. - %br - %br - You will be billed for 2% of your actual transactions, capped at $50 a month (so if you don’t sell anything you don’t pay anything, but you never pay more than $50 a month). .full_hub.option.one-third.column.omega %a.full-width.button.selector{ ng: { click: "sells='any'", class: "{selected: sells=='any'}" } } @@ -44,15 +38,10 @@ %h3 Producer Hub %p Sell produce from self and others .bottom - \%2 OF SALES - %br - CAPPED AT $50 PER MONTH + %monthly-pricing-description{ joiner: "newline" } + %p.description Your enterprise is the backbone of your local food system. You can sell your own produce as well as produce aggregated from other enterprises through your shopfront on the Open Food Network. - %br - %br - You will be billed for 2% of your actual transactions, capped at $50 a month (so if you don’t sell anything you don’t pay anything, but you never pay more than $50 a month). - -# %p.description -# Test out having your own shopfront with full access to all Shopfront features for 30 days. @@ -69,9 +58,6 @@ .bottom ALWAYS FREE %p.description People can find and contact you on the Open Food Network. Your enterprise will be visible on the map, and will be searchable in listings. - %br - %br - Having a profile, and making connections within your local food system through the Open Food Network will always be free. .full_hub.option.one-third.column %a.full-width.button.selector{ ng: { click: "sells='any'", class: "{selected: sells=='any'}" } } @@ -79,14 +65,10 @@ %h3 Hub Shop %p Sell produce from others .bottom - \%2 OF SALES - %br - CAPPED AT $50 PER MONTH + %monthly-pricing-description{ joiner: "newline" } + %p.description Your enterprise is the backbone of your local food system. You aggregate produce from other enterprises and can sell it through your shop on the Open Food Network. - %br - %br - You will be billed for 2% of your actual transactions, capped at $50 a month (so if you don’t sell anything you don’t pay anything, but you never pay more than $50 a month). .row diff --git a/app/views/admin/enterprises/index.html.haml b/app/views/admin/enterprises/index.html.haml index 826d09336c..62bc881728 100644 --- a/app/views/admin/enterprises/index.html.haml +++ b/app/views/admin/enterprises/index.html.haml @@ -8,6 +8,7 @@ %li#new_product_link = button_link_to "New Enterprise", main_app.new_admin_enterprise_path, :icon => 'icon-plus', :id => 'admin_new_enterprise_link' += admin_inject_monthly_bill_description = render 'admin/shared/enterprises_sub_menu' = render :partial => 'spree/shared/error_messages', :locals => { :target => @enterprise_set }