mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
[bug] unable to create a subscription plan for only one group
This commit is contained in:
parent
8f25c54402
commit
8945dbfb39
@ -5,6 +5,7 @@
|
||||
- Fix a bug: wallet tab is not shown in members dashboard
|
||||
- Fix a bug: slots duration is not shown when looking at a new availability
|
||||
- Fix a bug: user's manual URL is not up-to-date
|
||||
- Fix a bug: unable to create a subscription plan for only one group
|
||||
- Updated coveralls gem to a supported version
|
||||
|
||||
## v4.5.6 2020 September 1st
|
||||
|
@ -21,12 +21,20 @@
|
||||
/* COMMON CODE */
|
||||
|
||||
class PlanController {
|
||||
constructor ($scope, groups, prices, partners, CSRF) {
|
||||
constructor ($scope, groups, prices, partners, CSRF, _t) {
|
||||
// protection against request forgery
|
||||
CSRF.setMetaTags();
|
||||
|
||||
// groups list
|
||||
$scope.groups = groups.filter(function (g) { return (g.slug !== 'admins') && !g.disabled; });
|
||||
$scope.groups = groups
|
||||
.filter(function (g) { return (g.slug !== 'admins') && !g.disabled; })
|
||||
.map(e => Object.assign({}, e, { category: 'app.shared.plan.groups', id: `${e.id}` }))
|
||||
$scope.groups.push({ id: 'all', name: 'app.shared.plan.transversal_all_groups', category: 'app.shared.plan.all' });
|
||||
|
||||
// dynamically translate a label if needed
|
||||
$scope.translateLabel = function (group, prop) {
|
||||
return group[prop] && group[prop].match(/^app\./) ? _t(group[prop]) : group[prop];
|
||||
}
|
||||
|
||||
// users with role 'partner', notifiables for a partner plan
|
||||
$scope.partners = partners.users;
|
||||
@ -156,7 +164,7 @@ Application.Controllers.controller('NewPlanController', ['$scope', '$uibModal',
|
||||
}
|
||||
};
|
||||
|
||||
return new PlanController($scope, groups, prices, partners, CSRF);
|
||||
return new PlanController($scope, groups, prices, partners, CSRF, _t);
|
||||
}
|
||||
]);
|
||||
|
||||
@ -177,13 +185,13 @@ Application.Controllers.controller('EditPlanController', ['$scope', 'groups', 'p
|
||||
$scope.machines = machines;
|
||||
|
||||
// List of groups
|
||||
$scope.groups = groups;
|
||||
$scope.allGroups = groups;
|
||||
|
||||
// current form is used for edition mode
|
||||
$scope.mode = 'edition';
|
||||
|
||||
// edited plan data
|
||||
$scope.plan = planPromise;
|
||||
$scope.plan = Object.assign({}, planPromise, { group_id: `${planPromise.group_id}` });
|
||||
if ($scope.plan.type === null) { $scope.plan.type = 'Plan'; }
|
||||
if ($scope.plan.disabled) { $scope.plan.disabled = 'true'; }
|
||||
|
||||
@ -193,6 +201,11 @@ Application.Controllers.controller('EditPlanController', ['$scope', 'groups', 'p
|
||||
// HTTP method for the rest API
|
||||
$scope.method = 'PATCH';
|
||||
|
||||
$scope.selectedGroup = function () {
|
||||
const group = $scope.groups.filter(g => g.id === $scope.plan.group_id);
|
||||
return $scope.translateLabel(group[0], 'name');
|
||||
}
|
||||
|
||||
/**
|
||||
* If a parent plan was set ($scope.plan.parent), the prices will be copied from this parent plan into
|
||||
* the current plan prices list. Otherwise, the current plan prices will be erased.
|
||||
@ -281,6 +294,6 @@ Application.Controllers.controller('EditPlanController', ['$scope', 'groups', 'p
|
||||
};
|
||||
|
||||
// Using the PlansController
|
||||
return new PlanController($scope, groups, prices, partners, CSRF);
|
||||
return new PlanController($scope, groups, prices, partners, CSRF, _t);
|
||||
}
|
||||
]);
|
||||
|
@ -32,12 +32,19 @@
|
||||
class="form-control"
|
||||
ng-model="plan.group_id"
|
||||
required="required"
|
||||
ng-disabled="method == 'PATCH'">
|
||||
<option value="all" translate>{{ 'app.shared.plan.transversal_all_groups' }}</option>
|
||||
<optgroup label="Groupes">
|
||||
<option ng-repeat="group in groups" ng-value="group.id" ng-selected="plan.group_id == group.id">{{group.name}}</option>
|
||||
</optgroup>
|
||||
ng-if="method !== 'PATCH'"
|
||||
ng-options="item.id as translateLabel(item, 'name') group by translateLabel(item, 'category') for item in groups track by item.id">
|
||||
</select>
|
||||
<input type="text"
|
||||
id="plan[group_id]"
|
||||
ng-value="selectedGroup()"
|
||||
ng-if="method == 'PATCH'"
|
||||
class="form-control"
|
||||
disabled />
|
||||
<input type="hidden"
|
||||
name="plan[group_id]"
|
||||
ng-value="plan.group_id"
|
||||
ng-if="method == 'PATCH'"/>
|
||||
<span class="help-block" ng-show="planForm['plan[group_id]'].$dirty && planForm['plan[group_id]'].$error.required" translate>{{ 'app.shared.plan.group_is_required' }}</span>
|
||||
</div>
|
||||
|
||||
|
@ -48,7 +48,7 @@
|
||||
<div class="form-group col-md-6 col-lg-offset-6">
|
||||
<input type="hidden" ng-model="plan.parent" name="plan[parent_id]" ng-value="plan.parent"/>
|
||||
<label for="parentPlan" translate>{{ 'app.admin.plans.edit.copy_prices_from' }}</label>
|
||||
<select id="parentPlan" ng-options="plan.id as humanReadablePlanName(plan, groups) for plan in plans" ng-model="plan.parent" ng-change="copyPricesFromPlan()" class="form-control">
|
||||
<select id="parentPlan" ng-options="plan.id as humanReadablePlanName(plan, allGroups) for plan in plans" ng-model="plan.parent" ng-change="copyPricesFromPlan()" class="form-control">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
</div>
|
||||
|
@ -162,6 +162,8 @@ en:
|
||||
standard: "Standard"
|
||||
type_is_required: "Type is required."
|
||||
group: "Group"
|
||||
groups: "Groups"
|
||||
all: "All"
|
||||
transversal_all_groups: "Transversal (all groups)"
|
||||
group_is_required: "Group is required."
|
||||
number_of_periods: "Number of periods"
|
||||
|
Loading…
x
Reference in New Issue
Block a user