From d9be51b01bd71e94d0e10cc0637a4d3586e3b836 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 21 Jul 2020 18:04:20 +0200 Subject: [PATCH] [admin form] show if phone is required --- CHANGELOG.md | 1 + app/assets/javascripts/controllers/admin/members.js.erb | 6 +++++- app/assets/javascripts/router.js.erb | 3 +++ app/assets/templates/shared/_admin_form.html | 5 +++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa9746f8e..97a7c1667 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog Fab-manager +- Display an asterisk on the phone input field, in the admin creation form, if the phone is configured as required - Fix a bug: unable to export reservations - Fix a bug: unable to receive mails in development diff --git a/app/assets/javascripts/controllers/admin/members.js.erb b/app/assets/javascripts/controllers/admin/members.js.erb index 30c3a96b0..b4dbd8333 100644 --- a/app/assets/javascripts/controllers/admin/members.js.erb +++ b/app/assets/javascripts/controllers/admin/members.js.erb @@ -1070,7 +1070,8 @@ Application.Controllers.controller('ImportMembersResultController', ['$scope', ' /** * Controller used in the admin's creation page (admin view) */ -Application.Controllers.controller('NewAdminController', ['$state', '$scope', 'Admin', 'growl', '_t', function ($state, $scope, Admin, growl, _t) { +Application.Controllers.controller('NewAdminController', ['$state', '$scope', 'Admin', 'growl', '_t', 'phoneRequiredPromise', + function ($state, $scope, Admin, growl, _t, phoneRequiredPromise) { // default admin profile let getGender; $scope.admin = { @@ -1090,6 +1091,9 @@ Application.Controllers.controller('NewAdminController', ['$state', '$scope', 'A } }; + // is the phone number required in _admin_form? + $scope.phoneRequired = (phoneRequiredPromise.setting.value === 'true'); + /** * Shows the birth day datepicker * @param $event {Object} jQuery event object diff --git a/app/assets/javascripts/router.js.erb b/app/assets/javascripts/router.js.erb index 563920f9f..52bb3a9bc 100644 --- a/app/assets/javascripts/router.js.erb +++ b/app/assets/javascripts/router.js.erb @@ -947,6 +947,9 @@ angular.module('application.router', ['ui.router']) templateUrl: '<%= asset_path "admin/admins/new.html" %>', controller: 'NewAdminController' } + }, + resolve: { + phoneRequiredPromise: ['Setting', function (Setting) { return Setting.get({ name: 'phone_required' }).$promise; }] } }) .state('app.admin.managers_new', { diff --git a/app/assets/templates/shared/_admin_form.html b/app/assets/templates/shared/_admin_form.html index 53fb425cf..458a79a50 100644 --- a/app/assets/templates/shared/_admin_form.html +++ b/app/assets/templates/shared/_admin_form.html @@ -110,12 +110,13 @@
- + + placeholder="{{ 'app.admin.admins_new.phone_number' | translate }}" + ng-required="phoneRequired">