From d52f9fd43f7694a0802d0dfc3a2a846667da64d7 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Tue, 23 Jan 2018 20:02:55 +0000 Subject: [PATCH] Add enterprise limit modal --- .../enterprises/directives/enterprise_limit.js.coffee | 11 +++++++++++ app/views/admin/enterprises/_admin_index.html.haml | 2 +- .../enterprises/_enterprise_user_index.html.haml | 2 +- app/views/admin/enterprises/index.html.haml | 10 +++++++--- config/locales/en.yml | 1 + 5 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 app/assets/javascripts/admin/enterprises/directives/enterprise_limit.js.coffee diff --git a/app/assets/javascripts/admin/enterprises/directives/enterprise_limit.js.coffee b/app/assets/javascripts/admin/enterprises/directives/enterprise_limit.js.coffee new file mode 100644 index 0000000000..6bd2135030 --- /dev/null +++ b/app/assets/javascripts/admin/enterprises/directives/enterprise_limit.js.coffee @@ -0,0 +1,11 @@ +angular.module('admin.enterprises').directive 'enterpriseLimit', (InfoDialog) -> + restrict: 'A' + scope: { + limit_reached: '=enterpriseLimit', + modal_message: '@modalMessage' + } + link: (scope, element, attr) -> + element.bind 'click', (event)-> + if scope.limit_reached + event.preventDefault() + InfoDialog.open 'error', scope.modal_message diff --git a/app/views/admin/enterprises/_admin_index.html.haml b/app/views/admin/enterprises/_admin_index.html.haml index 5e1eb4c92c..3376601aaa 100644 --- a/app/views/admin/enterprises/_admin_index.html.haml +++ b/app/views/admin/enterprises/_admin_index.html.haml @@ -2,7 +2,7 @@ - if flash[:action] %p= flash[:action] -= form_for @enterprise_set, url: main_app.bulk_update_admin_enterprises_path, html: {"ng-app" => "admin.enterprises"} do |f| += form_for @enterprise_set, url: main_app.bulk_update_admin_enterprises_path do |f| %table#listing_enterprises.index %colgroup %col{style: "width: 25%;"}/ diff --git a/app/views/admin/enterprises/_enterprise_user_index.html.haml b/app/views/admin/enterprises/_enterprise_user_index.html.haml index b4bc32d2ad..4129da6b93 100644 --- a/app/views/admin/enterprises/_enterprise_user_index.html.haml +++ b/app/views/admin/enterprises/_enterprise_user_index.html.haml @@ -1,4 +1,4 @@ -%div{ ng: { app: 'admin.enterprises', controller: 'enterprisesCtrl' } } +%div{ ng: { controller: 'enterprisesCtrl' } } .row{ 'ng-hide' => '!loaded' } .controls{ :class => "sixteen columns alpha", :style => "margin-bottom: 15px;" } .four.columns.alpha diff --git a/app/views/admin/enterprises/index.html.haml b/app/views/admin/enterprises/index.html.haml index a233bc3146..d6e6d0fbb2 100644 --- a/app/views/admin/enterprises/index.html.haml +++ b/app/views/admin/enterprises/index.html.haml @@ -1,12 +1,16 @@ - content_for :page_title do = t('.title') +- content_for :app_wrapper_attrs do + = "ng-app='admin.enterprises'" + - content_for :page_actions do = render 'admin/shared/user_guide_link' - - if spree_current_user.can_own_more_enterprises? - %li#new_product_link - = button_link_to t('.new_enterprise'), main_app.new_admin_enterprise_path, icon: 'icon-plus', id: 'admin_new_enterprise_link' + %li#new_product_link + - button_href = spree_current_user.can_own_more_enterprises? ? main_app.new_admin_enterprise_path : '#' + - modal_message = t('js.admin.enterprise_limit_reached', contact_email: ContentConfig.footer_email) + = button_link_to t('.new_enterprise'), button_href, icon: 'icon-plus', id: 'admin_new_enterprise_link', 'enterprise-limit' => !spree_current_user.can_own_more_enterprises?, 'modal-message' => modal_message = admin_inject_monthly_bill_description = admin_inject_column_preferences module: 'admin.enterprises', action: "enterprises_index" diff --git a/config/locales/en.yml b/config/locales/en.yml index c38f528fd7..a00311555a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2203,6 +2203,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using resolve_errors: Please resolve the following errors more_items: "+ %{count} More" admin: + enterprise_limit_reached: "You have reached your enterprise limit. Write to %{contact_email} if you need to increase it." modals: got_it: Got it tag_rule_help: