From 749002b76862e80ee8f2b32551c78ad8511569bc Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 21 Aug 2023 20:09:48 +0100 Subject: [PATCH 01/12] Added migration to add name order to settings Signed-off-by: snipe --- ...1_064609_add_name_ordering_to_settings.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 database/migrations/2023_08_21_064609_add_name_ordering_to_settings.php diff --git a/database/migrations/2023_08_21_064609_add_name_ordering_to_settings.php b/database/migrations/2023_08_21_064609_add_name_ordering_to_settings.php new file mode 100644 index 0000000000..7a0afc5456 --- /dev/null +++ b/database/migrations/2023_08_21_064609_add_name_ordering_to_settings.php @@ -0,0 +1,32 @@ +string('name_display_format', 10)->after('alert_threshold')->nullable()->default('first_last'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('settings', function (Blueprint $table) { + $table->dropColumn('name_display_format'); + }); + } +} From 474c03e3fcc48889d7616d01d51d5f9b794832d7 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 21 Aug 2023 20:10:03 +0100 Subject: [PATCH 02/12] Added name order to settings save controller method Signed-off-by: snipe --- app/Http/Controllers/SettingsController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 497ab7cea6..7a7aa45b6e 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -590,6 +590,7 @@ class SettingsController extends Controller $setting->date_display_format = $request->input('date_display_format'); $setting->time_display_format = $request->input('time_display_format'); $setting->digit_separator = $request->input('digit_separator'); + $setting->name_display_format = $request->input('name_display_format'); if ($setting->save()) { return redirect()->route('settings.index') From f3460b5a4f33713be8b655937bc27975d86840af Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 21 Aug 2023 20:10:48 +0100 Subject: [PATCH 03/12] Switch to getFullNameAttribute() in user transformer Signed-off-by: snipe --- app/Http/Transformers/UsersTransformer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Transformers/UsersTransformer.php b/app/Http/Transformers/UsersTransformer.php index 76c0288073..45de50fa7d 100644 --- a/app/Http/Transformers/UsersTransformer.php +++ b/app/Http/Transformers/UsersTransformer.php @@ -24,7 +24,7 @@ class UsersTransformer $array = [ 'id' => (int) $user->id, 'avatar' => e($user->present()->gravatar), - 'name' => e($user->first_name).' '.e($user->last_name), + 'name' => e($user->getFullNameAttribute()), 'first_name' => e($user->first_name), 'last_name' => e($user->last_name), 'username' => e($user->username), From 354550b52e830d5c139ef259c1c9a03838aaa2ef Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 21 Aug 2023 20:11:17 +0100 Subject: [PATCH 04/12] Removed getCompleteNameAttribute(), modified getFullNameAttribute() Signed-off-by: snipe --- app/Models/User.php | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index 98a3ec346b..0d49b977c4 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -247,21 +247,12 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function getFullNameAttribute() { - return $this->first_name.' '.$this->last_name; - } + $setting = Setting::getSettings(); - /** - * Returns the complete name attribute with username - * - * @todo refactor this so it's less repetitive and dumb - * - * @author A. Gianotto - * @since [v2.0] - * @return string - */ - public function getCompleteNameAttribute() - { - return $this->last_name.', '.$this->first_name.' ('.$this->username.')'; + if ($setting->name_display_format=='last_first') { + return ($this->last_name) ? $this->last_name.' '.$this->first_name : $this->first_name; + } + return $this->last_name ? $this->first_name.' '.$this->last_name : $this->first_name; } From c39579b1701d3907f483bc5336c4f58c362365b6 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 21 Aug 2023 20:11:25 +0100 Subject: [PATCH 05/12] New strings Signed-off-by: snipe --- resources/lang/en/general.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 4831845721..1b60951d29 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -120,6 +120,10 @@ return [ 'firstname_lastname_underscore_format' => 'First Name Last Name (jane_smith@example.com)', 'lastnamefirstinitial_format' => 'Last Name First Initial (smithj@example.com)', 'firstintial_dot_lastname_format' => 'First Initial Last Name (j.smith@example.com)', + 'firstname_lastname_display' => 'First Name Last Name (Jane Smith)', + 'lastname_firstname_display' => 'Last Name First Name (Smith Jane)', + 'name_display_format' => 'Name Display Format', + 'name_display_help' => 'This is generally only used in countries where it is common to write ', 'first' => 'First', 'firstnamelastname' => 'First Name Last Name (janesmith@example.com)', 'lastname_firstinitial' => 'Last Name First Initial (smith_j@example.com)', From 8660d41aa369857db0b6b7b3e91d5d1c18ceb77e Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 21 Aug 2023 20:11:45 +0100 Subject: [PATCH 06/12] Changed width of locale field Signed-off-by: snipe --- resources/macros/macros.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/macros/macros.php b/resources/macros/macros.php index 43dc2cc2e0..92c8ecedac 100644 --- a/resources/macros/macros.php +++ b/resources/macros/macros.php @@ -11,7 +11,7 @@ Form::macro('locales', function ($name = 'locale', $selected = null, $class = nu $idclause = (!is_null($id)) ? $id : ''; - $select = ''; $select .= ''; // Pull the autoglossonym array from the localizations translation file From d73d15b8a2436ef3de45592d93cb42eb50a9bae6 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 21 Aug 2023 20:11:59 +0100 Subject: [PATCH 07/12] Added form macro for name format Signed-off-by: snipe --- resources/macros/macros.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/resources/macros/macros.php b/resources/macros/macros.php index 92c8ecedac..c5c7824edc 100644 --- a/resources/macros/macros.php +++ b/resources/macros/macros.php @@ -109,6 +109,23 @@ Form::macro('digit_separator', function ($name = 'digit_separator', $selected = return $select; }); + +Form::macro('name_display_format', function ($name = 'name_display_format', $selected = null, $class = null) { + $formats = [ + 'first_last' => trans('general.firstname_lastname_display'), + 'last_first' => trans('general.lastname_firstname_display'), + ]; + + $select = ''; + + return $select; +}); + /** * Barcode macro * Generates the dropdown menu of available 1D barcodes From bfd674b622d08b50c59b8a86a7363b4567ef40a2 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 21 Aug 2023 20:12:25 +0100 Subject: [PATCH 08/12] Switched to getFullNameAttribute() from fullName() in User Presenter Signed-off-by: snipe --- app/Presenters/UserPresenter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Presenters/UserPresenter.php b/app/Presenters/UserPresenter.php index 080a2d10e9..f70ddf8af6 100644 --- a/app/Presenters/UserPresenter.php +++ b/app/Presenters/UserPresenter.php @@ -433,7 +433,7 @@ class UserPresenter extends Presenter */ public function nameUrl() { - return (string) link_to_route('users.show', $this->fullName(), $this->id); + return (string) link_to_route('users.show', $this->getFullNameAttribute(), $this->id); } /** From ba0643f6a40e422113d3f9394f4ef02b281dbf9c Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 21 Aug 2023 20:13:28 +0100 Subject: [PATCH 09/12] Added name display format, tweaked some Signed-off-by: snipe --- .../views/settings/localization.blade.php | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/resources/views/settings/localization.blade.php b/resources/views/settings/localization.blade.php index a74387b32d..4f800511f1 100644 --- a/resources/views/settings/localization.blade.php +++ b/resources/views/settings/localization.blade.php @@ -42,26 +42,39 @@
-
+
{{ Form::label('site_name', trans('admin/settings/general.default_language')) }}
-
+
{!! Form::locales('locale', Request::old('locale', $setting->locale), 'select2') !!} {!! $errors->first('locale', '') !!}
+ +
+
+ {{ Form::label('name_display_format', trans('general.name_display_format')) }} +
+
+ {!! Form::name_display_format('name_display_format', Request::old('name_display_format', $setting->name_display_format), 'select2') !!} + + {!! $errors->first('name_display_format', '') !!} +
+
+ +
-
+
{{ Form::label('time_display_format', trans('general.time_and_date_display')) }}
-
+
{!! Form::date_display_format('date_display_format', Request::old('date_display_format', $setting->date_display_format), 'select2') !!}
-
+
{!! Form::time_display_format('time_display_format', Request::old('time_display_format', $setting->time_display_format), 'select2') !!}
@@ -71,10 +84,10 @@
-
+
{{ Form::label('default_currency', trans('admin/settings/general.default_currency')) }}
-
+
{{ Form::text('default_currency', old('default_currency', $setting->default_currency), array('class' => 'form-control select2-container','placeholder' => 'USD', 'maxlength'=>'3', 'style'=>'width: 60px; display: inline-block; ')) }} {!! Form::digit_separator('digit_separator', old('digit_separator', $setting->digit_separator), 'select2') !!} @@ -84,9 +97,6 @@
- - -
From c617bf89b6d5202ff9f0c430d159066cd4158adf Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 21 Aug 2023 20:13:45 +0100 Subject: [PATCH 10/12] Tweak layout Signed-off-by: snipe --- resources/views/account/profile.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/account/profile.blade.php b/resources/views/account/profile.blade.php index 2c3158c88f..a42c91e7a1 100755 --- a/resources/views/account/profile.blade.php +++ b/resources/views/account/profile.blade.php @@ -46,7 +46,7 @@
-
+
@if (!config('app.lock_passwords')) {!! Form::locales('locale', old('locale', $user->locale), 'select2') !!} From 36a343365e7777f4b914e1fa67a6d09e1bd067af Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 21 Aug 2023 20:14:07 +0100 Subject: [PATCH 11/12] Switched from fullName() to getFullNameAttribute() Signed-off-by: snipe --- resources/views/account/view-assets.blade.php | 2 +- resources/views/layouts/default.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/account/view-assets.blade.php b/resources/views/account/view-assets.blade.php index b77bddcf0d..10b09602ab 100755 --- a/resources/views/account/view-assets.blade.php +++ b/resources/views/account/view-assets.blade.php @@ -2,7 +2,7 @@ {{-- Page title --}} @section('title') -{{ trans('general.hello_name', array('name' => $user->present()->fullName())) }} +{{ trans('general.hello_name', array('name' => $user->present()->getFullNameAttribute())) }} @parent @stop diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index 13a65bf28b..a9f547f4f5 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -328,7 +328,7 @@ @endif -