From 890dad24d6c095c41e6358b2a6cb61f1b6c2f6ad Mon Sep 17 00:00:00 2001 From: winter Date: Sun, 26 Jan 2025 15:25:17 +0000 Subject: add user settings / preferences --- templates/left_side_navigation.php | 4 ++++ templates/preferences_form.php | 37 +++++++++++++++++++++++++++++++++++++ templates/preferences_page.php | 4 ++++ templates/settings_field.php | 14 ++++++++++---- templates/unread_indicator.php | 12 +++++++++++- 5 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 templates/preferences_form.php create mode 100644 templates/preferences_page.php (limited to 'templates') diff --git a/templates/left_side_navigation.php b/templates/left_side_navigation.php index 012cf23..4cf8b55 100644 --- a/templates/left_side_navigation.php +++ b/templates/left_side_navigation.php @@ -11,6 +11,10 @@ if ($user != null) { 'icon' => 'person-add-outline', 'label' => __('navigation.followRequests'), 'unreadCount' => FollowRelation::countWhere("object = ? AND status = 'pending'", [$user->actor->id]) + ], [ + 'href' => '/preferences', + 'icon' => 'tune', + 'label' => __('preferences.pageTitle') ]]; if ($user->isAdmin) { $links[] = ['href' => '/admin/settings/instance', 'icon' => 'settings-outline', 'label' => __('navigation.instanceSettings')]; diff --git a/templates/preferences_form.php b/templates/preferences_form.php new file mode 100644 index 0000000..8c8f203 --- /dev/null +++ b/templates/preferences_form.php @@ -0,0 +1,37 @@ + +
+ + 'pref-requestToFollow', + 'fieldName' => 'requestToFollow', + 'name' => __('preferences.requestToFollow.name'), + 'description' => __('preferences.requestToFollow.description'), + 'value' => $user->actor->requestToFollow, + 'type' => 'boolean' + ]); + call_template('settings_field', [ + 'id' => 'pref-smallIndicators', + 'fieldName' => 'smallIndicators', + 'name' => __('preferences.smallIndicators.name'), + 'description' => __('preferences.smallIndicators.description'), + 'value' => $settings->getBool('interface.smallUnreadIndicators'), + 'type' => 'boolean' + ]); + ?> + +
+
+ + + +
+ +
+ +
\ No newline at end of file diff --git a/templates/preferences_page.php b/templates/preferences_page.php new file mode 100644 index 0000000..bcb39b6 --- /dev/null +++ b/templates/preferences_page.php @@ -0,0 +1,4 @@ + __('preferences.pageTitle')], function () { + global $user, $saved; + call_template('preferences_form', ['user' => $user, 'saved' => $saved ?? false]); +}); \ No newline at end of file diff --git a/templates/settings_field.php b/templates/settings_field.php index 1ebbfb3..fe68a52 100644 --- a/templates/settings_field.php +++ b/templates/settings_field.php @@ -1,13 +1,14 @@ ', $key); +$fieldName ??= str_replace('.', '', $key); ?>
@@ -24,6 +25,11 @@ $fieldName = str_replace('.', '', $key); + + + + autocomplete="off"> + diff --git a/templates/unread_indicator.php b/templates/unread_indicator.php index bacacc3..ecfcb43 100644 --- a/templates/unread_indicator.php +++ b/templates/unread_indicator.php @@ -1 +1,11 @@ - \ No newline at end of file +getBool('interface.smallUnreadIndicators') ?? false; +} +?> + \ No newline at end of file -- cgit v1.3