From ec301ba07e794953b7cb1c84adfd07786739b0a4 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 14 Jun 2021 14:40:54 +0200 Subject: [PATCH] [bug] unable to list user's payment schedules in the dashboard --- CHANGELOG.md | 1 + Procfile | 2 +- .../api/payment_schedules_controller.rb | 2 +- .../src/javascript/controllers/dashboard.js | 115 +++++++++--------- 4 files changed, 61 insertions(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fe0f8944..c8442766a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Updated user's manual for v5 - Fix a bug: unable to process stripe payments with 3DS authentication - Fix a bug: unable to book an event +- Fix a bug: unable to list user's payment schedules in the dashboard ## v5.0.2 2021 June 11 diff --git a/Procfile b/Procfile index e68a73938..bbda6f44f 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/controllers/api/payment_schedules_controller.rb b/app/controllers/api/payment_schedules_controller.rb index f195ed22b..1b909bd8d 100644 --- a/app/controllers/api/payment_schedules_controller.rb +++ b/app/controllers/api/payment_schedules_controller.rb @@ -8,7 +8,7 @@ class API::PaymentSchedulesController < API::ApiController def index @payment_schedules = PaymentSchedule.where('invoicing_profile_id = ?', current_user.invoicing_profile.id) - .includes(:invoicing_profile, :payment_schedule_items, :subscription) + .includes(:invoicing_profile, :payment_schedule_items, :payment_schedule_objects) .joins(:invoicing_profile) .order('payment_schedules.created_at DESC') .page(params[:page]) diff --git a/app/frontend/src/javascript/controllers/dashboard.js b/app/frontend/src/javascript/controllers/dashboard.js index f589b4cf8..5fbb80328 100644 --- a/app/frontend/src/javascript/controllers/dashboard.js +++ b/app/frontend/src/javascript/controllers/dashboard.js @@ -12,72 +12,73 @@ */ 'use strict'; -Application.Controllers.controller('DashboardController', ['$scope', 'memberPromise', 'trainingsPromise', 'SocialNetworks', function ($scope, memberPromise, trainingsPromise, SocialNetworks) { - // Current user's profile - $scope.user = memberPromise; +Application.Controllers.controller('DashboardController', ['$scope', 'memberPromise', 'trainingsPromise', 'SocialNetworks', 'growl', + function ($scope, memberPromise, trainingsPromise, SocialNetworks, growl) { + // Current user's profile + $scope.user = memberPromise; - // List of social networks associated with this user and toggle 'show all' state - $scope.social = { - showAllLinks: false, - networks: SocialNetworks - }; + // List of social networks associated with this user and toggle 'show all' state + $scope.social = { + showAllLinks: false, + networks: SocialNetworks + }; - /** - * Check if the member has used his training credits for the given credit - * @param trainingCredits array of credits used by the member - * @param trainingId id of the training to find - */ - $scope.hasUsedTrainingCredit = function (trainingCredits, trainingId) { - return trainingCredits.find(tc => tc.training_id === trainingId); - }; + /** + * Check if the member has used his training credits for the given credit + * @param trainingCredits array of credits used by the member + * @param trainingId id of the training to find + */ + $scope.hasUsedTrainingCredit = function (trainingCredits, trainingId) { + return trainingCredits.find(tc => tc.training_id === trainingId); + }; - /** - * Return the name associated with the provided training ID - * @param trainingId training identifier - * @return {string} - */ - $scope.getTrainingName = function (trainingId) { - return trainingsPromise.find(t => t.id === trainingId).name; - }; + /** + * Return the name associated with the provided training ID + * @param trainingId training identifier + * @return {string} + */ + $scope.getTrainingName = function (trainingId) { + return trainingsPromise.find(t => t.id === trainingId).name; + }; - /* PRIVATE SCOPE */ + /* PRIVATE SCOPE */ - /** - * Kind of constructor: these actions will be realized first when the controller is loaded - */ - const initialize = () => $scope.social.networks = filterNetworks(); + /** + * Kind of constructor: these actions will be realized first when the controller is loaded + */ + const initialize = () => $scope.social.networks = filterNetworks(); - /** - * Filter the social networks or websites that are associated with the profile of the user provided in promise - * and return the filtered networks - * @return {Array} - */ - const filterNetworks = function () { - const networks = []; - for (const network of Array.from(SocialNetworks)) { - if ($scope.user.profile[network] && ($scope.user.profile[network].length > 0)) { - networks.push(network); + /** + * Filter the social networks or websites that are associated with the profile of the user provided in promise + * and return the filtered networks + * @return {Array} + */ + const filterNetworks = function () { + const networks = []; + for (const network of Array.from(SocialNetworks)) { + if ($scope.user.profile[network] && ($scope.user.profile[network].length > 0)) { + networks.push(network); + } } - } - return networks; - }; + return networks; + }; - /** - * Callback used in PaymentScheduleDashboard, in case of error - */ - $scope.onError = function (message) { - growl.error(message); - }; + /** + * Callback used in PaymentScheduleDashboard, in case of error + */ + $scope.onError = function (message) { + growl.error(message); + }; - /** - * Callback triggered when the user has successfully updated his card - */ - $scope.onCardUpdateSuccess = function (message) { - growl.success(message); - }; + /** + * Callback triggered when the user has successfully updated his card + */ + $scope.onCardUpdateSuccess = function (message) { + growl.success(message); + }; - // !!! MUST BE CALLED AT THE END of the controller - return initialize(); -} + // !!! MUST BE CALLED AT THE END of the controller + return initialize(); + } ]);