From 2d628d882669701d452a4cd2ff98278740ffdae8 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 26 May 2020 18:07:07 +0200 Subject: [PATCH] disable the invoicing module from the UI config panel --- app/assets/javascripts/app.js | 2 -- .../controllers/admin/invoices.js.erb | 4 ++-- .../controllers/admin/pricing.js.erb | 2 +- .../controllers/admin/statistics.js.erb | 4 ++-- app/assets/javascripts/controllers/home.js | 2 +- .../javascripts/controllers/main_nav.js | 6 +++--- app/assets/javascripts/router.js.erb | 19 ++++++++++--------- .../admin/calendar/calendar.html.erb | 2 +- .../admin/calendar/eventModal.html.erb | 2 +- .../templates/admin/invoices/index.html.erb | 2 +- .../admin/invoices/settings.html.erb | 2 +- .../templates/admin/members/edit.html.erb | 4 ++-- .../templates/admin/members/members.html.erb | 2 +- .../templates/admin/plans/edit.html.erb | 4 ++-- .../templates/admin/pricing/credits.html.erb | 6 +++--- .../templates/admin/pricing/index.html.erb | 2 +- .../admin/pricing/subscriptions.html.erb | 2 +- .../templates/admin/settings/general.html | 12 +++++++++++- .../admin/statistics/graphs.html.erb | 2 +- app/assets/templates/calendar/filter.html.erb | 2 +- app/assets/templates/dashboard/nav.html.erb | 2 +- .../templates/dashboard/settings.html.erb | 2 +- .../templates/machines/reserve.html.erb | 2 +- app/assets/templates/shared/_cart.html.erb | 2 +- app/assets/templates/shared/header.html.erb | 2 +- app/assets/templates/shared/leftnav.html.erb | 2 +- app/assets/templates/spaces/reserve.html.erb | 2 +- .../templates/trainings/reserve.html.erb | 2 +- .../templates/wallet/credit_modal.html.erb | 2 +- app/models/invoice.rb | 2 +- app/models/setting.rb | 3 ++- app/services/health_service.rb | 2 +- app/views/application/index.html.erb | 1 - config/locales/app.admin.en.yml | 7 ++++--- config/locales/app.admin.fr.yml | 4 ++++ config/secrets.yml | 4 ---- db/seeds.rb | 4 ++++ doc/environment.md | 7 ------- env.example | 1 - lib/tasks/fablab/setup.rake | 3 ++- setup/env.example | 1 - setup/setup.sh | 2 +- 42 files changed, 74 insertions(+), 68 deletions(-) diff --git a/app/assets/javascripts/app.js b/app/assets/javascripts/app.js index 8064c4877..0ba1f0f21 100644 --- a/app/assets/javascripts/app.js +++ b/app/assets/javascripts/app.js @@ -83,8 +83,6 @@ angular.module('application', ['ngCookies', 'ngResource', 'ngSanitize', 'ui.rout // Global config: if true, all payments will be disabled in the application for the members (only admins will be able to proceed reservations) $rootScope.fablabWithoutOnlinePayment = Fablab.withoutOnlinePayment; - // Global config: if true, no invoices will be generated - $rootScope.fablabWithoutInvoices = Fablab.withoutInvoices; // Global config: if true, user must confirm his email to sign in $rootScope.userConfirmationNeededToSignIn = Fablab.userConfirmationNeededToSignIn; // Global config: if true, wallet will be disabled diff --git a/app/assets/javascripts/controllers/admin/invoices.js.erb b/app/assets/javascripts/controllers/admin/invoices.js.erb index a2c7236df..d1b1d782c 100644 --- a/app/assets/javascripts/controllers/admin/invoices.js.erb +++ b/app/assets/javascripts/controllers/admin/invoices.js.erb @@ -28,7 +28,7 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I // default active tab $scope.tabs = { - active: Fablab.withoutInvoices ? 1 : 0 + active: settings.invoicing_module === 'true' ? 0 : 1 }; // List of all invoices @@ -612,7 +612,7 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I orphan: true }); } - if (!Fablab.withoutInvoices && $scope.invoices.length > 0) { + if (settings.invoicing_module === 'true' && $scope.invoices.length > 0) { uitour.createStep({ selector: '.invoices-management .invoices-list', stepId: 'list', diff --git a/app/assets/javascripts/controllers/admin/pricing.js.erb b/app/assets/javascripts/controllers/admin/pricing.js.erb index d09d2230d..46a394642 100644 --- a/app/assets/javascripts/controllers/admin/pricing.js.erb +++ b/app/assets/javascripts/controllers/admin/pricing.js.erb @@ -676,7 +676,7 @@ Application.Controllers.controller('EditPricingController', ['$scope', '$state', content: _t('app.admin.tour.pricing.machines.content'), placement: 'bottom' }); - if ($scope.spacesModule) { + if ($scope.modules.spaces) { uitour.createStep({ selector: '.plans-pricing .spaces-tab', stepId: 'spaces', diff --git a/app/assets/javascripts/controllers/admin/statistics.js.erb b/app/assets/javascripts/controllers/admin/statistics.js.erb index 4d04a1a13..429d37801 100644 --- a/app/assets/javascripts/controllers/admin/statistics.js.erb +++ b/app/assets/javascripts/controllers/admin/statistics.js.erb @@ -179,9 +179,9 @@ Application.Controllers.controller('StatisticsController', ['$scope', '$state', */ $scope.hiddenTab = function (tab) { if (tab.table) { - if ((tab.es_type_key === 'subscription') && !$rootScope.plansModule) { + if ((tab.es_type_key === 'subscription') && !$rootScope.modules.plans) { return true; - } else return (tab.es_type_key === 'space') && !$rootScope.spacesModule; + } else return (tab.es_type_key === 'space') && !$rootScope.modules.spaces; } else { return true; } diff --git a/app/assets/javascripts/controllers/home.js b/app/assets/javascripts/controllers/home.js index bbaabca59..6b58bf3c8 100644 --- a/app/assets/javascripts/controllers/home.js +++ b/app/assets/javascripts/controllers/home.js @@ -140,7 +140,7 @@ Application.Controllers.controller('HomeController', ['$scope', '$stateParams', content: _t('app.public.tour.welcome.machines.content'), placement: 'right' }); - if ($scope.spacesModule) { + if ($scope.modules.spaces) { uitour.createStep({ selector: '.nav-primary li.reserve-space-link', stepId: 'spaces', diff --git a/app/assets/javascripts/controllers/main_nav.js b/app/assets/javascripts/controllers/main_nav.js index e19c5844c..1f77ff640 100644 --- a/app/assets/javascripts/controllers/main_nav.js +++ b/app/assets/javascripts/controllers/main_nav.js @@ -58,7 +58,7 @@ Application.Controllers.controller('MainNavController', ['$scope', function ($sc ]; - if ($scope.plansModule) { + if ($scope.modules.plans) { $scope.navLinks.push({ state: 'app.public.plans', linkText: 'app.public.common.subscriptions', @@ -67,7 +67,7 @@ Application.Controllers.controller('MainNavController', ['$scope', function ($sc }); } - if ($scope.spacesModule) { + if ($scope.modules.spaces) { $scope.navLinks.splice(4, 0, { state: 'app.public.spaces_list', linkText: 'app.public.common.reserve_a_space', @@ -153,7 +153,7 @@ Application.Controllers.controller('MainNavController', ['$scope', function ($sc $scope.adminNavLinks = adminNavLinks; - if ($scope.spacesModule) { + if ($scope.modules.spaces) { return $scope.adminNavLinks.splice(3, 0, { state: 'app.public.spaces_list', linkText: 'app.public.common.manage_the_spaces', diff --git a/app/assets/javascripts/router.js.erb b/app/assets/javascripts/router.js.erb index 78ea4fad5..3b7bbbd5e 100644 --- a/app/assets/javascripts/router.js.erb +++ b/app/assets/javascripts/router.js.erb @@ -37,17 +37,19 @@ angular.module('application.router', ['ui.router']) logoFile: ['CustomAsset', function (CustomAsset) { return CustomAsset.get({ name: 'logo-file' }).$promise; }], logoBlackFile: ['CustomAsset', function (CustomAsset) { return CustomAsset.get({ name: 'logo-black-file' }).$promise; }], sharedTranslations: ['Translations', function (Translations) { return Translations.query(['app.shared', 'app.public.common']).$promise; }], - spacesModulePromise: ['Setting', function (Setting) { return Setting.get({ name: 'spaces_module' }).$promise; }], - plansModulePromise: ['Setting', function (Setting) { return Setting.get({ name: 'plans_module' }).$promise; }] + modulesPromise: ['Setting', function (Setting) { return Setting.query({ names: "['spaces_module', 'plans_module', 'invoicing_module']" }).$promise; }] }, - onEnter: ['$rootScope', 'logoFile', 'logoBlackFile', 'spacesModulePromise', 'plansModulePromise', 'CSRF', function ($rootScope, logoFile, logoBlackFile, spacesModulePromise, plansModulePromise, CSRF) { + onEnter: ['$rootScope', 'logoFile', 'logoBlackFile', 'modulesPromise', 'CSRF', function ($rootScope, logoFile, logoBlackFile, modulesPromise, CSRF) { // Retrieve Anti-CSRF tokens from cookies CSRF.setMetaTags(); // Application logo $rootScope.logo = logoFile.custom_asset; $rootScope.logoBlack = logoBlackFile.custom_asset; - $rootScope.spacesModule = (spacesModulePromise.setting.value === 'true'); - $rootScope.plansModule = (plansModulePromise.setting.value === 'true'); + $rootScope.modules = { + spaces: (modulesPromise.spaces_module === 'true'), + plans: (modulesPromise.plans_module === 'true'), + invoicing: (modulesPromise.invoicing_module === 'true'), + }; }] }) .state('app.public', { @@ -761,8 +763,7 @@ angular.module('application.router', ['ui.router']) spacesPromise: ['Space', function (Space) { return Space.query().$promise; }], spacesPricesPromise: ['Price', function (Price) { return Price.query({ priceable_type: 'Space', plan_id: 'null' }).$promise; }], spacesCreditsPromise: ['Credit', function (Credit) { return Credit.query({ creditable_type: 'Space' }).$promise; }], - slotDurationPromise: ['Setting', function (Setting) { return Setting.get({ name: 'slot_duration' }).$promise; }], - spacesModulePromise: ['Setting', function (Setting) { return Setting.get({ name: 'spaces_module' }).$promise; }] + slotDurationPromise: ['Setting', function (Setting) { return Setting.get({ name: 'slot_duration' }).$promise; }] } }) @@ -837,7 +838,7 @@ angular.module('application.router', ['ui.router']) return Setting.query({ names: `['invoice_legals', 'invoice_text', 'invoice_VAT-rate', 'invoice_VAT-active', 'invoice_order-nb', 'invoice_code-value', \ 'invoice_code-active', 'invoice_reference', 'invoice_logo', 'accounting_journal_code', 'accounting_card_client_code', \ - 'accounting_card_client_label', 'accounting_wallet_client_code', 'accounting_wallet_client_label', \ + 'accounting_card_client_label', 'accounting_wallet_client_code', 'accounting_wallet_client_label', 'invoicing_module', \ 'accounting_other_client_code', 'accounting_other_client_label', 'accounting_wallet_code', 'accounting_wallet_label', \ 'accounting_VAT_code', 'accounting_VAT_label', 'accounting_subscription_code', 'accounting_subscription_label', \ 'accounting_Machine_code', 'accounting_Machine_label', 'accounting_Training_code', 'accounting_Training_label', \ @@ -1024,7 +1025,7 @@ angular.module('application.router', ['ui.router']) settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: `['twitter_name', 'about_title', 'about_body', 'tracking_id', \ - 'privacy_body', 'privacy_dpo', 'about_contacts', 'book_overlapping_slots', \ + 'privacy_body', 'privacy_dpo', 'about_contacts', 'book_overlapping_slots', 'invoicing_module', \ 'home_blogpost', 'machine_explications_alert', 'training_explications_alert', 'slot_duration', \ 'training_information_message', 'subscription_explications_alert', 'event_explications_alert', \ 'space_explications_alert', 'booking_window_start', 'booking_window_end', 'events_in_calendar', \ diff --git a/app/assets/templates/admin/calendar/calendar.html.erb b/app/assets/templates/admin/calendar/calendar.html.erb index 1ce39e10f..0d9b85507 100644 --- a/app/assets/templates/admin/calendar/calendar.html.erb +++ b/app/assets/templates/admin/calendar/calendar.html.erb @@ -38,7 +38,7 @@
{{ 'app.admin.calendar.trainings' }}
{{ 'app.admin.calendar.machines' }}
- {{ 'app.admin.calendar.spaces' }} + {{ 'app.admin.calendar.spaces' }} {{ 'app.admin.calendar.events' }}
diff --git a/app/assets/templates/admin/calendar/eventModal.html.erb b/app/assets/templates/admin/calendar/eventModal.html.erb index 596d44bb4..a47859435 100644 --- a/app/assets/templates/admin/calendar/eventModal.html.erb +++ b/app/assets/templates/admin/calendar/eventModal.html.erb @@ -18,7 +18,7 @@ {{ 'app.admin.calendar.machine' }} -
+