diff --git a/db/factories/AngelTypeFactory.php b/db/factories/AngelTypeFactory.php index a25bac17..3f2cb20d 100644 --- a/db/factories/AngelTypeFactory.php +++ b/db/factories/AngelTypeFactory.php @@ -27,6 +27,7 @@ class AngelTypeFactory extends Factory 'shift_self_signup' => $this->faker->boolean(), 'show_on_dashboard' => $this->faker->boolean(), 'hide_register' => $this->faker->boolean(), + 'hide_on_shift_view' => $this->faker->boolean(), ]; } } diff --git a/db/migrations/2023_08_27_000000_add_hide_on_shift_view_to_angeltypes.php b/db/migrations/2023_08_27_000000_add_hide_on_shift_view_to_angeltypes.php new file mode 100644 index 00000000..459b022e --- /dev/null +++ b/db/migrations/2023_08_27_000000_add_hide_on_shift_view_to_angeltypes.php @@ -0,0 +1,33 @@ +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'); + }); + } +} diff --git a/includes/controller/angeltypes_controller.php b/includes/controller/angeltypes_controller.php index 89b6478a..3b0ffadb 100644 --- a/includes/controller/angeltypes_controller.php +++ b/includes/controller/angeltypes_controller.php @@ -121,6 +121,7 @@ function angeltype_edit_controller() $angeltype->shift_self_signup = $request->has('shift_self_signup'); $angeltype->show_on_dashboard = $request->has('show_on_dashboard'); $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_ifsg_certificate = $request->has('requires_ifsg_certificate'); @@ -145,7 +146,8 @@ function angeltype_edit_controller() . $angeltype->contact_dect . ', ' . $angeltype->contact_email . ', ' . $angeltype->show_on_dashboard . ', ' - . $angeltype->hide_register + . $angeltype->hide_register . ', ' + . $angeltype->hide_on_shift_view ); throw_redirect(angeltype_link($angeltype->id)); } diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index d1b7a08f..78c30f37 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -174,6 +174,7 @@ function load_days() function load_types() { $user = auth()->user(); + $isShico = auth()->can('admin_shifts'); if (!AngelType::count()) { 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 ( `user_angel_type`.`angel_type_id`=`angel_types`.`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, diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php index 0e43ce36..6483ad72 100644 --- a/includes/view/AngelTypes_view.php +++ b/includes/view/AngelTypes_view.php @@ -90,12 +90,14 @@ function AngelType_edit_view(AngelType $angeltype, bool $supporter_mode) ? form_info(__('Name'), $angeltype->name) : form_text('name', __('Name'), $angeltype->name), $supporter_mode - ? form_info(__('Requires introduction'), $angeltype->restricted ? __('Yes') : __('No')) - : form_checkbox('restricted', __('Requires introduction'), $angeltype->restricted), - form_info( - '', - __('Angel types which require introduction can only be used by an angel if enabled by a supporter (double opt-in).') - ), + ? form_info(__('angeltypes.restricted'), $angeltype->restricted ? __('Yes') : __('No')) + : form_checkbox( + 'restricted', + __('angeltypes.restricted') . + ' ', + $angeltype->restricted + ), $supporter_mode ? form_info(__('shift.self_signup'), $angeltype->shift_self_signup ? __('Yes') : __('No')) : form_checkbox( @@ -135,6 +137,15 @@ function AngelType_edit_view(AngelType $angeltype, bool $supporter_mode) $supporter_mode ? form_info(__('Hide at Registration'), $angeltype->hide_register ? __('Yes') : __('No')) : 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') . + ' ', + $angeltype->hide_on_shift_view + ), form_textarea('description', __('Description'), $angeltype->description), form_info('', __('Please use markdown for the description.')), heading(__('Contact'), 3), @@ -578,7 +589,7 @@ function AngelTypes_list_view($angeltypes, bool $admin_angeltypes) ]), table([ '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'), 'membership' => __('Membership'), 'actions' => '', diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index 365c2dd6..780beef4 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -1293,12 +1293,10 @@ msgstr "Möchtest Du den Engeltypen %s löschen?" msgid "cancel" msgstr "abbrechen" -msgid "Requires introduction" +msgid "angeltypes.restricted" msgstr "Benötigt Einführung" -msgid "" -"Angel types which require introduction can only be used by an angel if " -"enabled by a supporter (double opt-in)." +msgid "angeltypes.restricted.info" msgstr "" "Engeltypen, welche eine Einführung benötigen, müssen von einem Supporter freigeschaltet werden " "(double-opt-in)." @@ -2415,6 +2413,13 @@ msgstr "DECT" msgid "angeltypes.email" 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" msgstr "Registrieren" diff --git a/resources/lang/en_US/default.po b/resources/lang/en_US/default.po index d79e8a27..7d342302 100644 --- a/resources/lang/en_US/default.po +++ b/resources/lang/en_US/default.po @@ -515,6 +515,13 @@ msgstr "Teams-/Job description" 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." +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" msgstr "This angeltype requires the attendance at an introduction meeting. " "You might find additional information in the description." @@ -541,6 +548,13 @@ msgstr "Shift self signup" msgid "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" msgstr "Register" diff --git a/src/Models/AngelType.php b/src/Models/AngelType.php index bcbcc3f0..3fdca538 100644 --- a/src/Models/AngelType.php +++ b/src/Models/AngelType.php @@ -27,6 +27,7 @@ use Illuminate\Database\Query\Builder as QueryBuilder; * @property boolean $shift_self_signup # Users can sign up for shifts * @property boolean $show_on_dashboard # Show on public dashboard * @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 UserAngelType $pivot @@ -78,6 +79,7 @@ class AngelType extends BaseModel 'shift_self_signup', 'show_on_dashboard', 'hide_register', + 'hide_on_shift_view', ]; /** @var array */ @@ -88,6 +90,7 @@ class AngelType extends BaseModel 'shift_self_signup' => 'boolean', 'show_on_dashboard' => 'boolean', 'hide_register' => 'boolean', + 'hide_on_shift_view' => 'boolean', ]; public function neededBy(): HasMany