mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-18 07:52:23 +01:00
admin can subscribe in member/edit w/ schedule
This commit is contained in:
parent
b48a2738ec
commit
fa686187cd
@ -810,12 +810,17 @@ Application.Controllers.controller('EditMemberController', ['$scope', '$state',
|
||||
templateUrl: '/admin/subscriptions/create_modal.html',
|
||||
size: 'lg',
|
||||
controller: ['$scope', '$uibModalInstance', 'Subscription', function ($scope, $uibModalInstance, Subscription) {
|
||||
// selected user
|
||||
// selected user
|
||||
$scope.user = user;
|
||||
|
||||
// available plans for the selected user
|
||||
$scope.plans = plans;
|
||||
|
||||
// default parameters for the new subscription
|
||||
$scope.subscription = {
|
||||
payment_schedule: false
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate a string identifying the given plan by literal human-readable name
|
||||
* @param plan {Object} Plan object, as recovered from GET /api/plan/:id
|
||||
@ -826,6 +831,29 @@ Application.Controllers.controller('EditMemberController', ['$scope', '$state',
|
||||
*/
|
||||
$scope.humanReadablePlanName = function (plan, groups, short) { return `${$filter('humanReadablePlanName')(plan, groups, short)}`; };
|
||||
|
||||
/**
|
||||
* Check if the currently selected plan can be paid with a payment schedule or not
|
||||
* @return {boolean}
|
||||
*/
|
||||
$scope.allowMonthlySchedule = function () {
|
||||
if (!$scope.subscription) return false;
|
||||
|
||||
const plan = plans.find(p => p.id === $scope.subscription.plan_id);
|
||||
return plan && plan.monthly_payment;
|
||||
};
|
||||
|
||||
/**
|
||||
* Triggered by the <switch> component.
|
||||
* We must use a setTimeout to workaround the react integration.
|
||||
* @param checked {Boolean}
|
||||
*/
|
||||
$scope.toggleSchedule = function (checked) {
|
||||
setTimeout(() => {
|
||||
$scope.subscription.payment_schedule = checked;
|
||||
$scope.$apply();
|
||||
}, 50);
|
||||
};
|
||||
|
||||
/**
|
||||
* Modal dialog validation callback
|
||||
*/
|
||||
|
@ -7,11 +7,15 @@
|
||||
{{ 'app.admin.members_edit.you_are_about_to_purchase_a_subscription_to_NAME' }}
|
||||
</p>
|
||||
</div>
|
||||
<form role="form" name="subscriptionForm" class="form-horizontal col-md-8" novalidate>
|
||||
<form role="form" name="subscriptionForm" class="form-horizontal" novalidate>
|
||||
<div class="form-group">
|
||||
<select ng-model="subscription.plan_id" ng-options="plan.id as humanReadablePlanName(plan) for plan in plans" class="form-control" required>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" ng-show="allowMonthlySchedule()">
|
||||
<label for="schedule" class="control-label m-r-md">{{ 'app.admin.members_edit.with_schedule' | translate }}</label>
|
||||
<switch id="schedule" checked="subscription.payment_schedule" on-change="toggleSchedule"></switch>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
@ -830,6 +830,7 @@ en:
|
||||
a_problem_occurred_while_saving_the_date: "A problem occurred while saving the date."
|
||||
new_subscription: "New subscription"
|
||||
you_are_about_to_purchase_a_subscription_to_NAME: "You are about to purchase a subscription to {NAME}."
|
||||
with_schedule: "Subscribe with a monthly payment schedule"
|
||||
subscription_successfully_purchased: "Subscription successfully purchased."
|
||||
a_problem_occurred_while_taking_the_subscription: "A problem occurred while taking the subscription"
|
||||
wallet: "Wallet"
|
||||
|
@ -830,6 +830,7 @@ fr:
|
||||
a_problem_occurred_while_saving_the_date: "Il y a eu un problème lors de l'enregistrement de la date."
|
||||
new_subscription: "Nouvelle souscription"
|
||||
you_are_about_to_purchase_a_subscription_to_NAME: "Vous êtes sur le point de souscrire à un abonnement l'utilisateur {NAME}."
|
||||
with_schedule: "Souscrire via un échéancier mensuel"
|
||||
subscription_successfully_purchased: "La souscription à l'abonnement a été réalisée avec succès."
|
||||
a_problem_occurred_while_taking_the_subscription: "Il y a eu un problème lors de la souscription à l'abonnement"
|
||||
wallet: "Porte-monnaie"
|
||||
|
Loading…
x
Reference in New Issue
Block a user