add hide angeltype in shift view option for angeltypes (#1195)

This commit is contained in:
xuwhite 2023-09-27 20:25:10 +02:00 committed by GitHub
parent 8ebaffd71a
commit adf00b2739
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 87 additions and 14 deletions

View File

@ -27,6 +27,7 @@ class AngelTypeFactory extends Factory
'shift_self_signup' => $this->faker->boolean(), 'shift_self_signup' => $this->faker->boolean(),
'show_on_dashboard' => $this->faker->boolean(), 'show_on_dashboard' => $this->faker->boolean(),
'hide_register' => $this->faker->boolean(), 'hide_register' => $this->faker->boolean(),
'hide_on_shift_view' => $this->faker->boolean(),
]; ];
} }
} }

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace Engelsystem\Migrations;
use Engelsystem\Database\Migration\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddHideOnShiftViewToAngeltypes extends Migration
{
use Reference;
/**
* Run the migration
*/
public function up(): void
{
$this->schema->table('angel_types', function (Blueprint $table): void {
$table->boolean('hide_on_shift_view')->default(false)->after('hide_register');
});
}
/**
* Reverse the migration
*/
public function down(): void
{
$this->schema->table('angel_types', function (Blueprint $table): void {
$table->dropColumn('hide_on_shift_view');
});
}
}

View File

@ -121,6 +121,7 @@ function angeltype_edit_controller()
$angeltype->shift_self_signup = $request->has('shift_self_signup'); $angeltype->shift_self_signup = $request->has('shift_self_signup');
$angeltype->show_on_dashboard = $request->has('show_on_dashboard'); $angeltype->show_on_dashboard = $request->has('show_on_dashboard');
$angeltype->hide_register = $request->has('hide_register'); $angeltype->hide_register = $request->has('hide_register');
$angeltype->hide_on_shift_view = $request->has('hide_on_shift_view');
$angeltype->requires_driver_license = $request->has('requires_driver_license'); $angeltype->requires_driver_license = $request->has('requires_driver_license');
$angeltype->requires_ifsg_certificate = $request->has('requires_ifsg_certificate'); $angeltype->requires_ifsg_certificate = $request->has('requires_ifsg_certificate');
@ -145,7 +146,8 @@ function angeltype_edit_controller()
. $angeltype->contact_dect . ', ' . $angeltype->contact_dect . ', '
. $angeltype->contact_email . ', ' . $angeltype->contact_email . ', '
. $angeltype->show_on_dashboard . ', ' . $angeltype->show_on_dashboard . ', '
. $angeltype->hide_register . $angeltype->hide_register . ', '
. $angeltype->hide_on_shift_view
); );
throw_redirect(angeltype_link($angeltype->id)); throw_redirect(angeltype_link($angeltype->id));
} }

View File

@ -174,6 +174,7 @@ function load_days()
function load_types() function load_types()
{ {
$user = auth()->user(); $user = auth()->user();
$isShico = auth()->can('admin_shifts');
if (!AngelType::count()) { if (!AngelType::count()) {
error(__('The administration has not configured any angeltypes yet - or you are not subscribed to any angeltype.')); error(__('The administration has not configured any angeltypes yet - or you are not subscribed to any angeltype.'));
@ -197,8 +198,11 @@ function load_types()
ON ( ON (
`user_angel_type`.`angel_type_id`=`angel_types`.`id` `user_angel_type`.`angel_type_id`=`angel_types`.`id`
AND `user_angel_type`.`user_id`=? AND `user_angel_type`.`user_id`=?
) )'
ORDER BY `angel_types`.`name` . ($isShico ? '' :
'WHERE angel_types.hide_on_shift_view = 0
OR user_angel_type.user_id IS NOT NULL ') .
'ORDER BY `angel_types`.`name`
', ',
[ [
$user->id, $user->id,

View File

@ -90,12 +90,14 @@ function AngelType_edit_view(AngelType $angeltype, bool $supporter_mode)
? form_info(__('Name'), $angeltype->name) ? form_info(__('Name'), $angeltype->name)
: form_text('name', __('Name'), $angeltype->name), : form_text('name', __('Name'), $angeltype->name),
$supporter_mode $supporter_mode
? form_info(__('Requires introduction'), $angeltype->restricted ? __('Yes') : __('No')) ? form_info(__('angeltypes.restricted'), $angeltype->restricted ? __('Yes') : __('No'))
: form_checkbox('restricted', __('Requires introduction'), $angeltype->restricted), : form_checkbox(
form_info( 'restricted',
'', __('angeltypes.restricted') .
__('Angel types which require introduction can only be used by an angel if enabled by a supporter (double opt-in).') ' <span class="bi bi-info-circle-fill text-info" data-bs-toggle="tooltip" title="' .
), __('angeltypes.restricted.info') . '"></span>',
$angeltype->restricted
),
$supporter_mode $supporter_mode
? form_info(__('shift.self_signup'), $angeltype->shift_self_signup ? __('Yes') : __('No')) ? form_info(__('shift.self_signup'), $angeltype->shift_self_signup ? __('Yes') : __('No'))
: form_checkbox( : form_checkbox(
@ -135,6 +137,15 @@ function AngelType_edit_view(AngelType $angeltype, bool $supporter_mode)
$supporter_mode $supporter_mode
? form_info(__('Hide at Registration'), $angeltype->hide_register ? __('Yes') : __('No')) ? form_info(__('Hide at Registration'), $angeltype->hide_register ? __('Yes') : __('No'))
: form_checkbox('hide_register', __('Hide at Registration'), $angeltype->hide_register), : form_checkbox('hide_register', __('Hide at Registration'), $angeltype->hide_register),
$supporter_mode
? form_info(__('angeltypes.hide_on_shift_view'), $angeltype->hide_on_shift_view ? __('Yes') : __('No'))
: form_checkbox(
'hide_on_shift_view',
__('angeltypes.hide_on_shift_view') .
' <span class="bi bi-info-circle-fill text-info" data-bs-toggle="tooltip" title="' .
__('angeltypes.hide_on_shift_view.info') . '"></span>',
$angeltype->hide_on_shift_view
),
form_textarea('description', __('Description'), $angeltype->description), form_textarea('description', __('Description'), $angeltype->description),
form_info('', __('Please use markdown for the description.')), form_info('', __('Please use markdown for the description.')),
heading(__('Contact'), 3), heading(__('Contact'), 3),
@ -578,7 +589,7 @@ function AngelTypes_list_view($angeltypes, bool $admin_angeltypes)
]), ]),
table([ table([
'name' => __('Name'), 'name' => __('Name'),
'is_restricted' => icon('mortarboard-fill') . __('Requires introduction'), 'is_restricted' => icon('mortarboard-fill') . __('angeltypes.restricted'),
'shift_self_signup_allowed' => icon('pencil-square') . __('shift.self_signup.allowed'), 'shift_self_signup_allowed' => icon('pencil-square') . __('shift.self_signup.allowed'),
'membership' => __('Membership'), 'membership' => __('Membership'),
'actions' => '', 'actions' => '',

View File

@ -1293,12 +1293,10 @@ msgstr "Möchtest Du den Engeltypen %s löschen?"
msgid "cancel" msgid "cancel"
msgstr "abbrechen" msgstr "abbrechen"
msgid "Requires introduction" msgid "angeltypes.restricted"
msgstr "Benötigt Einführung" msgstr "Benötigt Einführung"
msgid "" msgid "angeltypes.restricted.info"
"Angel types which require introduction can only be used by an angel if "
"enabled by a supporter (double opt-in)."
msgstr "" msgstr ""
"Engeltypen, welche eine Einführung benötigen, müssen von einem Supporter freigeschaltet werden " "Engeltypen, welche eine Einführung benötigen, müssen von einem Supporter freigeschaltet werden "
"(double-opt-in)." "(double-opt-in)."
@ -2415,6 +2413,13 @@ msgstr "DECT"
msgid "angeltypes.email" msgid "angeltypes.email"
msgstr "E-Mail" msgstr "E-Mail"
msgid "angeltypes.hide_on_shift_view"
msgstr "Auf Schicht-Ansicht ausblenden"
msgid "angeltypes.hide_on_shift_view.info"
msgstr "Wenn ausgewählt, können nur Admins und Mitglieder des Engeltyps auf der "
"Schicht Seite die Filteroption für diesen Engeltyp sehen."
msgid "registration.register" msgid "registration.register"
msgstr "Registrieren" msgstr "Registrieren"

View File

@ -515,6 +515,13 @@ msgstr "Teams-/Job description"
msgid "angeltypes.about.text" msgid "angeltypes.about.text"
msgstr "Here you can find the list of teams and their tasks. If you have further questions, have a look at the FAQ." msgstr "Here you can find the list of teams and their tasks. If you have further questions, have a look at the FAQ."
msgid "angeltypes.restricted"
msgstr "Requires introduction"
msgid "angeltypes.restricted.info"
msgstr "Angel types which require introduction can only be used by an angel "
"if enabled by a supporter (double opt-in)."
msgid "angeltypes.restricted.hint" msgid "angeltypes.restricted.hint"
msgstr "This angeltype requires the attendance at an introduction meeting. " msgstr "This angeltype requires the attendance at an introduction meeting. "
"You might find additional information in the description." "You might find additional information in the description."
@ -541,6 +548,13 @@ msgstr "Shift self signup"
msgid "shift.self_signup.allowed" msgid "shift.self_signup.allowed"
msgstr "Shift self signup allowed" msgstr "Shift self signup allowed"
msgid "angeltypes.hide_on_shift_view"
msgstr "Hide on shift view"
msgid "angeltypes.hide_on_shift_view.info"
msgstr "If checked only admins and members of the angeltype "
"can see the filter option for this angeltype on the shifts page"
msgid "registration.register" msgid "registration.register"
msgstr "Register" msgstr "Register"

View File

@ -27,6 +27,7 @@ use Illuminate\Database\Query\Builder as QueryBuilder;
* @property boolean $shift_self_signup # Users can sign up for shifts * @property boolean $shift_self_signup # Users can sign up for shifts
* @property boolean $show_on_dashboard # Show on public dashboard * @property boolean $show_on_dashboard # Show on public dashboard
* @property boolean $hide_register # Hide from registration page * @property boolean $hide_register # Hide from registration page
* @property boolean $hide_on_shift_view # Hide from shift page
* *
* @property-read Collection|NeededAngelType[] $neededBy * @property-read Collection|NeededAngelType[] $neededBy
* @property-read UserAngelType $pivot * @property-read UserAngelType $pivot
@ -78,6 +79,7 @@ class AngelType extends BaseModel
'shift_self_signup', 'shift_self_signup',
'show_on_dashboard', 'show_on_dashboard',
'hide_register', 'hide_register',
'hide_on_shift_view',
]; ];
/** @var array<string, string> */ /** @var array<string, string> */
@ -88,6 +90,7 @@ class AngelType extends BaseModel
'shift_self_signup' => 'boolean', 'shift_self_signup' => 'boolean',
'show_on_dashboard' => 'boolean', 'show_on_dashboard' => 'boolean',
'hide_register' => 'boolean', 'hide_register' => 'boolean',
'hide_on_shift_view' => 'boolean',
]; ];
public function neededBy(): HasMany public function neededBy(): HasMany