From 72be638869cc1a6c4fde0117ed6684eb394347b4 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 15 Jun 2021 09:22:41 +0200 Subject: [PATCH] [bug] unable to select no category in plan creation/edition after a category selection Also: Display the category in the plans list instead of the plan type --- CHANGELOG.md | 3 +++ Procfile | 2 +- .../src/javascript/controllers/admin/plans.js | 4 ++++ .../javascript/controllers/admin/pricing.js | 22 +++++++++++-------- app/frontend/src/javascript/router.js | 3 ++- .../admin/pricing/subscriptions.html | 4 ++-- config/locales/app.admin.en.yml | 4 +--- config/locales/app.admin.fr.yml | 4 +--- 8 files changed, 27 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d71278269..ed0d1e73d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog Fab-manager +- Display the category in the plans list +- Do not display the type in the plans list - Fix a bug: a message tells that creating a new plan fails, but it worked +- Fix a bug: unable to select no category in plan creation/edition after a category selection ## v5.0.3 2021 June 14 diff --git a/Procfile b/Procfile index bbda6f44f..e68a73938 100644 --- a/Procfile +++ b/Procfile @@ -1,4 +1,4 @@ -#web: bundle exec rails server puma -p $PORT +web: bundle exec rails server puma -p $PORT worker: bundle exec sidekiq -C ./config/sidekiq.yml wp-client: bin/webpack-dev-server wp-server: SERVER_BUNDLE_ONLY=yes bin/webpack --watch diff --git a/app/frontend/src/javascript/controllers/admin/plans.js b/app/frontend/src/javascript/controllers/admin/plans.js index 48cf70b04..57364ede2 100644 --- a/app/frontend/src/javascript/controllers/admin/plans.js +++ b/app/frontend/src/javascript/controllers/admin/plans.js @@ -87,6 +87,8 @@ Application.Controllers.controller('NewPlanController', ['$scope', '$uibModal', // list of all plan categories $scope.planCategories = planCategories; + // we add an empty element to let the user select 'no category' + $scope.planCategories.unshift({ id: null, name: '' }); // prices bindings $scope.prices = { @@ -239,6 +241,8 @@ Application.Controllers.controller('EditPlanController', ['$scope', 'groups', 'p // list of all plan categories $scope.planCategories = planCategories; + // we add an empty element to let the user select 'no category' + $scope.planCategories.unshift({ id: null, name: '' }); // current form is used for edition mode $scope.mode = 'edition'; diff --git a/app/frontend/src/javascript/controllers/admin/pricing.js b/app/frontend/src/javascript/controllers/admin/pricing.js index da31903eb..3eaf3eed6 100644 --- a/app/frontend/src/javascript/controllers/admin/pricing.js +++ b/app/frontend/src/javascript/controllers/admin/pricing.js @@ -18,8 +18,8 @@ /** * Controller used in the prices edition page */ -Application.Controllers.controller('EditPricingController', ['$scope', '$state', '$uibModal', '$filter', 'TrainingsPricing', 'Credit', 'Pricing', 'Plan', 'Coupon', 'plans', 'groups', 'growl', 'machinesPricesPromise', 'Price', 'dialogs', 'trainingsPricingsPromise', 'trainingsPromise', 'machineCreditsPromise', 'machinesPromise', 'trainingCreditsPromise', 'couponsPromise', 'spacesPromise', 'spacesPricesPromise', 'spacesCreditsPromise', 'settingsPromise', '_t', 'Member', 'uiTourService', - function ($scope, $state, $uibModal, $filter, TrainingsPricing, Credit, Pricing, Plan, Coupon, plans, groups, growl, machinesPricesPromise, Price, dialogs, trainingsPricingsPromise, trainingsPromise, machineCreditsPromise, machinesPromise, trainingCreditsPromise, couponsPromise, spacesPromise, spacesPricesPromise, spacesCreditsPromise, settingsPromise, _t, Member, uiTourService) { +Application.Controllers.controller('EditPricingController', ['$scope', '$state', '$uibModal', '$filter', 'TrainingsPricing', 'Credit', 'Pricing', 'Plan', 'Coupon', 'plans', 'groups', 'growl', 'machinesPricesPromise', 'Price', 'dialogs', 'trainingsPricingsPromise', 'trainingsPromise', 'machineCreditsPromise', 'machinesPromise', 'trainingCreditsPromise', 'couponsPromise', 'spacesPromise', 'spacesPricesPromise', 'spacesCreditsPromise', 'settingsPromise', '_t', 'Member', 'uiTourService', 'planCategories', + function ($scope, $state, $uibModal, $filter, TrainingsPricing, Credit, Pricing, Plan, Coupon, plans, groups, growl, machinesPricesPromise, Price, dialogs, trainingsPricingsPromise, trainingsPromise, machineCreditsPromise, machinesPromise, trainingCreditsPromise, couponsPromise, spacesPromise, spacesPricesPromise, spacesCreditsPromise, settingsPromise, _t, Member, uiTourService, planCategories) { /* PUBLIC SCOPE */ // List of machines prices (not considering any plan) @@ -36,6 +36,9 @@ Application.Controllers.controller('EditPricingController', ['$scope', '$state', $scope.groups = groups.filter(function (g) { return g.slug !== 'admins'; }); $scope.enabledGroups = groups.filter(function (g) { return (g.slug !== 'admins') && !g.disabled; }); + // List of all plan-categories + $scope.planCategories = planCategories; + // Associate free machine hours with subscriptions $scope.machineCredits = machineCreditsPromise; @@ -433,14 +436,15 @@ Application.Controllers.controller('EditPricingController', ['$scope', '$state', }; /** - * If the plan does not have a type, return a default value for display purposes - * @param type {string|undefined|null} plan's type (eg. 'partner') - * @returns {string} + * Return the name of the plan-category, from its ID + * @param id {number|undefined} plan-category's id + * @returns {string} the name */ - $scope.getPlanType = function (type) { - if (type === 'PartnerPlan') { - return _t('app.admin.pricing.partner'); - } else { return _t('app.admin.pricing.standard'); } + $scope.getPlanCategory = function (id) { + const cat = $scope.planCategories.find(c => c.id === id); + if (cat) { + return cat.name; + } }; /** diff --git a/app/frontend/src/javascript/router.js b/app/frontend/src/javascript/router.js index 6625b81c1..a82b2d777 100644 --- a/app/frontend/src/javascript/router.js +++ b/app/frontend/src/javascript/router.js @@ -780,7 +780,8 @@ 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; }], - settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: "['feature_tour_display', 'slot_duration']" }).$promise; }] + settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: "['feature_tour_display', 'slot_duration']" }).$promise; }], + planCategories: ['PlanCategory', function (PlanCategory) { return PlanCategory.query().$promise; }] } }) diff --git a/app/frontend/templates/admin/pricing/subscriptions.html b/app/frontend/templates/admin/pricing/subscriptions.html index f6e4050de..72fefcc09 100644 --- a/app/frontend/templates/admin/pricing/subscriptions.html +++ b/app/frontend/templates/admin/pricing/subscriptions.html @@ -23,10 +23,10 @@ - + @@ -36,10 +36,10 @@ - + diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml index 238d820b7..fed821fe9 100644 --- a/config/locales/app.admin.en.yml +++ b/config/locales/app.admin.en.yml @@ -300,12 +300,10 @@ en: list_of_the_subscription_plans: "List of the subscription plans" disabled_plans_info_html: "

Warning: the subscriptions are disabled on this application.

You can still create some, but they won't be available until the activation of the plans module, from the « Customization » section.

" add_a_new_subscription_plan: "Add a new subscription plan" - type: "Type" - partner: "Partner" - standard: "Standard" name: "Name" duration: "Duration" group: "Group" + category: "Category" prominence: "Prominence" price: "Price" machine_hours: "Machine slots" diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml index 2a337ce0b..68cf49b0e 100644 --- a/config/locales/app.admin.fr.yml +++ b/config/locales/app.admin.fr.yml @@ -300,12 +300,10 @@ fr: list_of_the_subscription_plans: "Liste des formules d'abonnements" disabled_plans_info_html: "

Attention : les abonnements sont désactivés sur cette application.

Vous pouvez tout de même en créer mais ils ne seront disponibles qu'après l'activation du module abonnements depuis la section « Personnalisation ».

" add_a_new_subscription_plan: "Ajouter une nouvelle formule d'abonnement" - type: "Type" - partner: "Partenaire" - standard: "Standard" name: "Nom" duration: "Durée" group: "Groupe" + category: "Catégorie" prominence: "Importance" price: "Prix" machine_hours: "Créneaux machines"
{{ 'app.admin.pricing.type' | translate }} {{ 'app.admin.pricing.name' | translate }} {{ 'app.admin.pricing.duration' | translate }} {{ 'app.admin.pricing.group' | translate }} {{ 'app.admin.pricing.category' | translate }} {{ 'app.admin.pricing.price' | translate }}
{{getPlanType(plan.type)}} {{plan.base_name}} {{ plan.interval | planIntervalFilter:plan.interval_count }} {{group.name}}{{getPlanCategory(plan.plan_category_id)}} {{plan.amount | currency}}