From 93f3decfb0f58fb663ae476d6fb98c52c2483b6a Mon Sep 17 00:00:00 2001 From: Amos Folz <33728190+amosfolz@users.noreply.github.com> Date: Tue, 9 Apr 2019 23:58:44 +0000 Subject: [PATCH 01/14] Add migration --- .../Migrations/v430/UpdateUsersTable.php | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php diff --git a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php new file mode 100644 index 000000000..d4dcc6a30 --- /dev/null +++ b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php @@ -0,0 +1,53 @@ +schema->hasTable('users')) { + $this->schema->table('users', function (Blueprint $table) { + $table->integer('group_id')->unsigned()->default(null)->comment('The id of the user group.')->nullable()->change(); + }); + } + } + + /** + * {@inheritdoc} + */ + public function down() + { + $this->schema->table('users', function (Blueprint $table) { + $table->integer('group_id')->unsigned()->default(1)->comment('The id of the user group.')->nullable(false)->change(); + }); + } +} From eb5f57c0b27526ee3704aaa3e51a6d6acf5b39f9 Mon Sep 17 00:00:00 2001 From: Amos Folz Date: Thu, 11 Apr 2019 01:32:28 +0000 Subject: [PATCH 02/14] Updates to allow empty group_id --- .../admin/assets/userfrosting/js/widgets/users.js | 8 +++++++- .../admin/src/Controller/UserController.php | 13 ++++++++----- app/sprinkles/admin/templates/forms/user.html.twig | 3 ++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/sprinkles/admin/assets/userfrosting/js/widgets/users.js b/app/sprinkles/admin/assets/userfrosting/js/widgets/users.js index 6c05b91c7..6adbf32df 100644 --- a/app/sprinkles/admin/assets/userfrosting/js/widgets/users.js +++ b/app/sprinkles/admin/assets/userfrosting/js/widgets/users.js @@ -15,6 +15,12 @@ function attachUserForm() { width: '100%' }); + // Needed to allow select2 to render a 'empty' list item. + form.find(".js-select2-group").select2({ + width: '100%', + templateResult: item => item.text || '\u200B' + }); + // Set up the form for submission form.ufForm({ validator: page.validators @@ -113,7 +119,7 @@ function updateUser(userName, fieldName, fieldValue) { } else { $("#alerts-page").ufAlerts('clear'); } - + $("#alerts-page").ufAlerts('fetch').ufAlerts('render'); } diff --git a/app/sprinkles/admin/src/Controller/UserController.php b/app/sprinkles/admin/src/Controller/UserController.php index d6293ec49..069356f3a 100644 --- a/app/sprinkles/admin/src/Controller/UserController.php +++ b/app/sprinkles/admin/src/Controller/UserController.php @@ -1016,11 +1016,11 @@ public function pageInfo(Request $request, Response $response, $args) } return $this->ci->view->render($response, 'pages/user.html.twig', [ - 'user' => $user, - 'locales' => $locales, - 'fields' => $fields, - 'tools' => $editButtons, - 'widgets' => $widgets, + 'user' => $user, + 'locales' => $locales, + 'fields' => $fields, + 'tools' => $editButtons, + 'widgets' => $widgets, 'delete_redirect' => $this->ci->router->pathFor('uri_users') ]); } @@ -1155,6 +1155,9 @@ public function updateInfo(Request $request, Response $response, $args) return $response->withJson([], 400); } + if ($data['group_id'] == 0) { + $data['group_id'] = null; + } // Begin transaction - DB will be rolled back if an exception occurs Capsule::transaction(function () use ($data, $user, $currentUser) { // Update the user and generate success messages diff --git a/app/sprinkles/admin/templates/forms/user.html.twig b/app/sprinkles/admin/templates/forms/user.html.twig index 3ee7fc9d4..1aab5a94b 100644 --- a/app/sprinkles/admin/templates/forms/user.html.twig +++ b/app/sprinkles/admin/templates/forms/user.html.twig @@ -24,7 +24,8 @@ {% if 'group' in form.fields.disabled %} {% else %} - + {% for group in groups %} {% endfor %} From aec347997640f3176e62b621c01fd9e1b10aefc0 Mon Sep 17 00:00:00 2001 From: Amos Folz <33728190+amosfolz@users.noreply.github.com> Date: Thu, 11 Apr 2019 21:46:28 +0000 Subject: [PATCH 03/14] Add foreignkey migration to dependencies --- .../account/src/Database/Migrations/v430/UpdateUsersTable.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php index d4dcc6a30..7ab01132b 100644 --- a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php +++ b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php @@ -26,7 +26,8 @@ class UpdateUsersTable extends Migration * {@inheritdoc} */ public static $dependencies = [ - '\UserFrosting\Sprinkle\Account\Database\Migrations\v400\UsersTable' + '\UserFrosting\Sprinkle\Account\Database\Migrations\v400\UsersTable', + '\UserFrosting\Sprinkle\Account\Database\Migrations\v420\AddingForeignKeys' ]; /** From c08cf384526da15b1225a8a0b71d0a6e883b884a Mon Sep 17 00:00:00 2001 From: Amos Folz Date: Sat, 13 Apr 2019 18:06:40 +0000 Subject: [PATCH 04/14] Remove and then recreate foreign key constraint --- .../account/src/Database/Migrations/v430/UpdateUsersTable.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php index 7ab01132b..ce8ff4a9e 100644 --- a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php +++ b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php @@ -37,7 +37,9 @@ public function up() { if ($this->schema->hasTable('users')) { $this->schema->table('users', function (Blueprint $table) { + $table->dropForeign('users_group_id_foreign'); $table->integer('group_id')->unsigned()->default(null)->comment('The id of the user group.')->nullable()->change(); + $table->foreign('group_id')->references('id')->on('groups'); }); } } @@ -48,7 +50,9 @@ public function up() public function down() { $this->schema->table('users', function (Blueprint $table) { + $table->dropForeign('users_group_id_foreign'); $table->integer('group_id')->unsigned()->default(1)->comment('The id of the user group.')->nullable(false)->change(); + $table->foreign('group_id')->references('id')->on('groups'); }); } } From d207ca22fb4e70aa9bd7fcb23527f4b9cf5a2af2 Mon Sep 17 00:00:00 2001 From: Amos Folz Date: Sun, 14 Apr 2019 02:13:20 +0000 Subject: [PATCH 05/14] Change column type to --- .../src/Database/Migrations/v430/UpdateUsersTable.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php index ce8ff4a9e..a01333376 100644 --- a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php +++ b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php @@ -26,6 +26,7 @@ class UpdateUsersTable extends Migration * {@inheritdoc} */ public static $dependencies = [ + '\UserFrosting\Sprinkle\Account\Database\Migrations\v400\GroupsTable', '\UserFrosting\Sprinkle\Account\Database\Migrations\v400\UsersTable', '\UserFrosting\Sprinkle\Account\Database\Migrations\v420\AddingForeignKeys' ]; @@ -38,7 +39,7 @@ public function up() if ($this->schema->hasTable('users')) { $this->schema->table('users', function (Blueprint $table) { $table->dropForeign('users_group_id_foreign'); - $table->integer('group_id')->unsigned()->default(null)->comment('The id of the user group.')->nullable()->change(); + $table->unsignedInteger('group_id')->default(null)->comment('The id of the user group.')->nullable()->change(); $table->foreign('group_id')->references('id')->on('groups'); }); } @@ -51,7 +52,7 @@ public function down() { $this->schema->table('users', function (Blueprint $table) { $table->dropForeign('users_group_id_foreign'); - $table->integer('group_id')->unsigned()->default(1)->comment('The id of the user group.')->nullable(false)->change(); + $table->unsignedInteger('group_id')->default(1)->comment('The id of the user group.')->nullable(false)->change(); $table->foreign('group_id')->references('id')->on('groups'); }); } From 047258ba0e2332122eb2bc7fc2802e3bcc1564a0 Mon Sep 17 00:00:00 2001 From: Amos Folz Date: Sun, 14 Apr 2019 02:31:56 +0000 Subject: [PATCH 06/14] Changed foreign key to array value format --- .../src/Database/Migrations/v430/UpdateUsersTable.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php index a01333376..2f688ecae 100644 --- a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php +++ b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php @@ -38,8 +38,10 @@ public function up() { if ($this->schema->hasTable('users')) { $this->schema->table('users', function (Blueprint $table) { - $table->dropForeign('users_group_id_foreign'); + $table->dropForeign(['group_id']); $table->unsignedInteger('group_id')->default(null)->comment('The id of the user group.')->nullable()->change(); + }); + $this->schema->table('users', function (Blueprint $table) { $table->foreign('group_id')->references('id')->on('groups'); }); } @@ -51,8 +53,10 @@ public function up() public function down() { $this->schema->table('users', function (Blueprint $table) { - $table->dropForeign('users_group_id_foreign'); + $table->dropForeign(['group_id']); $table->unsignedInteger('group_id')->default(1)->comment('The id of the user group.')->nullable(false)->change(); + }); + $this->schema->table('users', function (Blueprint $table) { $table->foreign('group_id')->references('id')->on('groups'); }); } From abe23ccc75fe824e8d765b319de3c1d8d6c2eb87 Mon Sep 17 00:00:00 2001 From: Amos Folz Date: Sat, 15 Jun 2019 16:10:38 +0000 Subject: [PATCH 07/14] styleci fixes --- .../src/Database/Migrations/v430/UpdateUsersTable.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php index 2f688ecae..7cf8a0474 100644 --- a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php +++ b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php @@ -1,5 +1,6 @@ Date: Wed, 19 Jun 2019 02:45:23 +0000 Subject: [PATCH 08/14] Modify UpdateUsersTable.php --- .../Database/Migrations/v430/UpdateUsersTable.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php index 7cf8a0474..724e357ed 100644 --- a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php +++ b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php @@ -20,7 +20,7 @@ * * See https://laravel.com/docs/5.4/migrations#tables * - * @author Alex Weissman (https://alexanderweissman.com) + * @author Amos Folz */ class UpdateUsersTable extends Migration { @@ -40,11 +40,7 @@ public function up() { if ($this->schema->hasTable('users')) { $this->schema->table('users', function (Blueprint $table) { - $table->dropForeign(['group_id']); - $table->unsignedInteger('group_id')->default(null)->comment('The id of the user group.')->nullable()->change(); - }); - $this->schema->table('users', function (Blueprint $table) { - $table->foreign('group_id')->references('id')->on('groups'); + $table->unsignedInteger('group_id')->comment('The id of the user group.')->nullable()->change(); }); } } @@ -55,11 +51,7 @@ public function up() public function down() { $this->schema->table('users', function (Blueprint $table) { - $table->dropForeign(['group_id']); $table->unsignedInteger('group_id')->default(1)->comment('The id of the user group.')->nullable(false)->change(); }); - $this->schema->table('users', function (Blueprint $table) { - $table->foreign('group_id')->references('id')->on('groups'); - }); } } From 2de781a8be214821c8f9ce546dff7c58ace235a4 Mon Sep 17 00:00:00 2001 From: Amos Folz <33728190+amosfolz@users.noreply.github.com> Date: Wed, 19 Jun 2019 14:54:32 +0000 Subject: [PATCH 09/14] Create UpdateUsersTable.php --- .../Migrations/v430/UpdateUsersTable.php | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php diff --git a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php new file mode 100644 index 000000000..b419a8474 --- /dev/null +++ b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php @@ -0,0 +1,58 @@ +schema->hasTable('users')) { + $this->schema->table('users', function (Blueprint $table) { + $table->dropIndex(['group_id']); + $table->unsignedInteger('group_id')->comment('The id of the user group.')->nullable()->change(); + }); + } + } + + /** + * {@inheritdoc} + */ + public function down() + { + $this->schema->table('users', function (Blueprint $table) { + $table->unsignedInteger('group_id')->default(1)->comment('The id of the user group.')->nullable(false)->change(); + }); + } +} From 13fa23c1a283bba7d6bd47e85df8d850eb58ffce Mon Sep 17 00:00:00 2001 From: Amos Folz <33728190+amosfolz@users.noreply.github.com> Date: Wed, 19 Jun 2019 19:00:16 +0000 Subject: [PATCH 10/14] Migration, controller, template, and asset updates --- .../Migrations/v430/UpdateUsersTable.php | 3 +- .../assets/userfrosting/js/widgets/users.js | 82 ++++++++++--------- .../admin/src/Controller/UserController.php | 4 + .../admin/templates/forms/user.html.twig | 3 +- 4 files changed, 49 insertions(+), 43 deletions(-) diff --git a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php index b419a8474..94a61e64e 100644 --- a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php +++ b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php @@ -40,8 +40,7 @@ public function up() { if ($this->schema->hasTable('users')) { $this->schema->table('users', function (Blueprint $table) { - $table->dropIndex(['group_id']); - $table->unsignedInteger('group_id')->comment('The id of the user group.')->nullable()->change(); + $table->unsignedInteger('group_id')->default(null)->comment('The id of the user group.')->nullable()->change(); }); } } diff --git a/app/sprinkles/admin/assets/userfrosting/js/widgets/users.js b/app/sprinkles/admin/assets/userfrosting/js/widgets/users.js index 6c05b91c7..9f57d7c5c 100644 --- a/app/sprinkles/admin/assets/userfrosting/js/widgets/users.js +++ b/app/sprinkles/admin/assets/userfrosting/js/widgets/users.js @@ -6,7 +6,7 @@ * Set up the form in a modal after being successfully attached to the body. */ function attachUserForm() { - $("body").on('renderSuccess.ufModal', function (data) { + $("body").on('renderSuccess.ufModal', function(data) { var modal = $(this).ufModal('getModal'); var form = modal.find('.js-form'); @@ -15,6 +15,8 @@ function attachUserForm() { width: '100%' }); + + // Set up the form for submission form.ufForm({ validator: page.validators @@ -42,14 +44,14 @@ function toggleChangePasswordMode(el, userName, changePasswordMode) { if (validator) { //Iterate through named elements inside of the form, and mark them as error free el.find("input[type='password']").each(function() { - validator.successList.push(this); //mark as error free + validator.successList.push(this); //mark as error free }); - validator.resetForm();//remove error class on name elements and clear history - validator.reset();//remove all error and success data + validator.resetForm(); //remove error class on name elements and clear history + validator.reset(); //remove all error and success data } el.find("input[type='password']").closest('.form-group') - .removeClass('has-error has-success'); - el.find('.form-control-feedback').each(function () { + .removeClass('has-error has-success'); + el.find('.form-control-feedback').each(function() { $(this).remove(); }); } else { @@ -66,7 +68,7 @@ function toggleChangePasswordMode(el, userName, changePasswordMode) { * Update user field(s) */ function updateUser(userName, fieldName, fieldValue) { - var data = { + var data = { 'value': fieldValue }; @@ -92,19 +94,19 @@ function updateUser(userName, fieldName, fieldValue) { return $.parseJSON(result); } } catch (e) { - // statements to handle any exceptions - console.log("Warning: Could not parse expected JSON response."); - return {}; + // statements to handle any exceptions + console.log("Warning: Could not parse expected JSON response."); + return {}; } } } - }).fail(function (jqXHR) { + }).fail(function(jqXHR) { // Error messages if (debugAjax && jqXHR.responseText) { document.write(jqXHR.responseText); document.close(); } else { - console.log("Error (" + jqXHR.status + "): " + jqXHR.responseText ); + console.log("Error (" + jqXHR.status + "): " + jqXHR.responseText); // Display errors on failure // TODO: ufAlerts widget should have a 'destroy' method @@ -113,12 +115,12 @@ function updateUser(userName, fieldName, fieldValue) { } else { $("#alerts-page").ufAlerts('clear'); } - + $("#alerts-page").ufAlerts('fetch').ufAlerts('render'); } return jqXHR; - }).done(function (response) { + }).done(function(response) { window.location.reload(); }); } @@ -128,8 +130,8 @@ function updateUser(userName, fieldName, fieldValue) { * @param {module:jQuery} el jQuery wrapped element to target. * @param {{delete_redirect: string}} options Options used to modify behaviour of button actions. */ - function bindUserButtons(el, options) { - if (!options) options = {}; +function bindUserButtons(el, options) { + if (!options) options = {}; /** * Buttons that launch a modal dialog @@ -162,38 +164,38 @@ function updateUser(userName, fieldName, fieldValue) { msgTarget: $("#alerts-page") }); - $("body").on('renderSuccess.ufModal', function (data) { + $("body").on('renderSuccess.ufModal', function(data) { var modal = $(this).ufModal('getModal'); var form = modal.find('.js-form'); // Set up collection widget var roleWidget = modal.find('.js-form-roles'); roleWidget.ufCollection({ - dropdown : { + dropdown: { ajax: { - url : site.uri.public + '/api/roles' + url: site.uri.public + '/api/roles' }, - placeholder : "Select a role" + placeholder: "Select a role" }, dropdownTemplate: modal.find('#user-roles-select-option').html(), - rowTemplate : modal.find('#user-roles-row').html() + rowTemplate: modal.find('#user-roles-row').html() }); // Get current roles and add to widget $.getJSON(site.uri.public + '/api/users/u/' + userName + '/roles') - .done(function (data) { - $.each(data.rows, function (idx, role) { - role.text = role.name; - roleWidget.ufCollection('addRow', role); + .done(function(data) { + $.each(data.rows, function(idx, role) { + role.text = role.name; + roleWidget.ufCollection('addRow', role); + }); }); - }); // Set up form for submission form.ufForm() - .on("submitSuccess.ufForm", function() { - // Reload page on success - window.location.reload(); - }); + .on("submitSuccess.ufForm", function() { + // Reload page on success + window.location.reload(); + }); }); }); @@ -210,7 +212,7 @@ function updateUser(userName, fieldName, fieldValue) { msgTarget: $("#alerts-page") }); - $("body").on('renderSuccess.ufModal', function () { + $("body").on('renderSuccess.ufModal', function() { var modal = $(this).ufModal('getModal'); var form = modal.find('.js-form'); @@ -246,16 +248,16 @@ function updateUser(userName, fieldName, fieldValue) { msgTarget: $("#alerts-page") }); - $("body").on('renderSuccess.ufModal', function () { + $("body").on('renderSuccess.ufModal', function() { var modal = $(this).ufModal('getModal'); var form = modal.find('.js-form'); form.ufForm() - .on("submitSuccess.ufForm", function() { - // Navigate or reload page on success - if (options.delete_redirect) window.location.href = options.delete_redirect; - else window.location.reload(); - }); + .on("submitSuccess.ufForm", function() { + // Navigate or reload page on success + if (options.delete_redirect) window.location.href = options.delete_redirect; + else window.location.reload(); + }); }); }); @@ -269,12 +271,12 @@ function updateUser(userName, fieldName, fieldValue) { updateUser(btn.data('user_name'), 'flag_verified', '1'); }); - el.find('.js-user-enable').click(function () { + el.find('.js-user-enable').click(function() { var btn = $(this); updateUser(btn.data('user_name'), 'flag_enabled', '1'); }); - el.find('.js-user-disable').click(function () { + el.find('.js-user-disable').click(function() { var btn = $(this); updateUser(btn.data('user_name'), 'flag_enabled', '0'); }); @@ -292,4 +294,4 @@ function bindUserCreationButton(el) { attachUserForm(); }); -}; +}; \ No newline at end of file diff --git a/app/sprinkles/admin/src/Controller/UserController.php b/app/sprinkles/admin/src/Controller/UserController.php index caf9caba3..8037af948 100644 --- a/app/sprinkles/admin/src/Controller/UserController.php +++ b/app/sprinkles/admin/src/Controller/UserController.php @@ -1211,6 +1211,10 @@ public function updateInfo(Request $request, Response $response, $args) return $response->withJson([], 400); } + if (isset($data['group_id']) && $data['group_id'] == 0) { + $data['group_id'] = null; + } + // Begin transaction - DB will be rolled back if an exception occurs Capsule::transaction(function () use ($data, $user, $currentUser) { // Update the user and generate success messages diff --git a/app/sprinkles/admin/templates/forms/user.html.twig b/app/sprinkles/admin/templates/forms/user.html.twig index 3ee7fc9d4..707d0c1ae 100644 --- a/app/sprinkles/admin/templates/forms/user.html.twig +++ b/app/sprinkles/admin/templates/forms/user.html.twig @@ -24,7 +24,8 @@ {% if 'group' in form.fields.disabled %} {% else %} - + {% endfor %} From 8c87ba76cc496f91636756f9f41191c1aa92f4fd Mon Sep 17 00:00:00 2001 From: Amos Folz Date: Fri, 21 Jun 2019 01:05:15 +0000 Subject: [PATCH 11/14] Remove nullable in down --- .../account/src/Database/Migrations/v430/UpdateUsersTable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php index 94a61e64e..a533564d9 100644 --- a/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php +++ b/app/sprinkles/account/src/Database/Migrations/v430/UpdateUsersTable.php @@ -51,7 +51,7 @@ public function up() public function down() { $this->schema->table('users', function (Blueprint $table) { - $table->unsignedInteger('group_id')->default(1)->comment('The id of the user group.')->nullable(false)->change(); + $table->unsignedInteger('group_id')->default(1)->comment('The id of the user group.')->change(); }); } } From b26b70512089f7f21cd3d09f609684edf95cf9c5 Mon Sep 17 00:00:00 2001 From: amosfolz <33728190+amosfolz@users.noreply.github.com> Date: Wed, 10 Jul 2019 22:17:15 -0400 Subject: [PATCH 12/14] Fix invalid html --- app/sprinkles/admin/templates/forms/user.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/sprinkles/admin/templates/forms/user.html.twig b/app/sprinkles/admin/templates/forms/user.html.twig index 707d0c1ae..7c706a5e7 100644 --- a/app/sprinkles/admin/templates/forms/user.html.twig +++ b/app/sprinkles/admin/templates/forms/user.html.twig @@ -24,8 +24,8 @@ {% if 'group' in form.fields.disabled %} {% else %} - + {% for group in groups %} {% endfor %} From ce4c507e4593f377e8674aa9b7902542f3725b92 Mon Sep 17 00:00:00 2001 From: amosfolz <33728190+amosfolz@users.noreply.github.com> Date: Thu, 11 Jul 2019 10:28:29 -0400 Subject: [PATCH 13/14] Update user.html.twig Hide group name if user is not in a group. --- app/sprinkles/admin/templates/pages/user.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/sprinkles/admin/templates/pages/user.html.twig b/app/sprinkles/admin/templates/pages/user.html.twig index 16522084a..350eb5254 100644 --- a/app/sprinkles/admin/templates/pages/user.html.twig +++ b/app/sprinkles/admin/templates/pages/user.html.twig @@ -94,7 +94,7 @@ {% endif %} -

{{user.user_name}}{% if 'group' not in fields.hidden %} • {{user.group.name}}{% endif %}

+

{{user.user_name}}{% if 'group' not in fields.hidden and user.group.name is not null %} • {{user.group.name}}{% endif %}

{% if 'email' not in fields.hidden %}
From 71b2cd1d82771350da859fccffcac3beb71b2d2b Mon Sep 17 00:00:00 2001 From: amosfolz <33728190+amosfolz@users.noreply.github.com> Date: Thu, 11 Jul 2019 20:22:28 -0400 Subject: [PATCH 14/14] Add translation key for No group --- app/sprinkles/admin/locale/en_US/messages.php | 1 + app/sprinkles/admin/templates/forms/user.html.twig | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/sprinkles/admin/locale/en_US/messages.php b/app/sprinkles/admin/locale/en_US/messages.php index ffed268a1..6adde5b0e 100644 --- a/app/sprinkles/admin/locale/en_US/messages.php +++ b/app/sprinkles/admin/locale/en_US/messages.php @@ -59,6 +59,7 @@ 'MANAGE' => 'Manage group', 'NAME' => 'Group name', 'NAME_EXPLAIN' => 'Please enter a name for the group', + 'NONE' => 'No group', 'NOT_EMPTY' => "You can't do that because there are still users associated with the group {{name}}.", 'PAGE_DESCRIPTION' => 'A listing of the groups for your site. Provides management tools for editing and deleting groups.', 'SUMMARY' => 'Group Summary', diff --git a/app/sprinkles/admin/templates/forms/user.html.twig b/app/sprinkles/admin/templates/forms/user.html.twig index 7c706a5e7..f9b2a2f9d 100644 --- a/app/sprinkles/admin/templates/forms/user.html.twig +++ b/app/sprinkles/admin/templates/forms/user.html.twig @@ -25,7 +25,8 @@ {% else %}