1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-23 12:52:20 +01:00
Sylvain 78518e17fb read stripe_currency from the UI
We prevent the currency from being changed if any stripe payment was made, because a stripe user cannot made pay with different currencies. If we try to charge a user with a different currency than the currency he used for a previous payment, this will fail; so we must prevent this case
2020-06-10 16:37:11 +02:00

62 lines
1.8 KiB
Plaintext

Application.Directives.directive('textSetting', ['Setting', 'growl', '_t',
function (Setting, growl, _t) {
return ({
restrict: 'E',
scope: {
name: '@',
label: '@',
settings: '=',
classes: '@',
faIcon: '@',
placeholder: '@',
required: '<',
type: '@',
maxLength: '@',
minLength: '@',
readOnly: '<'
},
templateUrl: '<%= asset_path "admin/settings/text.html" %>',
link ($scope, element, attributes) {
// if type is not specified, use text as default
if (typeof $scope.type === 'undefined') {
$scope.type = 'text';
}
// The setting
$scope.setting = {
name: $scope.name,
value: $scope.settings[$scope.name]
};
$scope.$watch(`settings.${$scope.name}`, function (newValue, oldValue, scope) {
if (newValue !== oldValue) {
$scope.setting.value = newValue;
}
});
/**
* Callback to save the setting value to the database
* @param setting {{value:*, name:string}} note that the value will be stringified
*/
$scope.save = function (setting) {
let { value } = setting;
Setting.update(
{ name: setting.name },
{ value },
function () {
growl.success(_t('app.admin.settings.customization_of_SETTING_successfully_saved', { SETTING: _t(`app.admin.settings.${setting.name}`) }));
$scope.settings[$scope.name] = value;
},
function (error) {
if (error.status === 304) return;
growl.error(_t('app.admin.settings.an_error_occurred_saving_the_setting'));
console.log(error);
}
);
};
}
});
}
]);