Set case-insensitive sorting as default & Add a user pref to restore legacy behavior - Closes #347

This commit is contained in:
Bubka 2024-06-19 14:31:17 +02:00
parent 98ef297dc7
commit 2f05f4993c
4 changed files with 17 additions and 4 deletions

View File

@ -125,6 +125,7 @@
'notifyOnNewAuthDevice' => false,
'notifyOnFailedLogin' => false,
'timezone' => env('APP_TIMEZONE', 'UTC'),
'sortCaseSensitive' => false,
],
];

View File

@ -181,7 +181,10 @@ export const useTwofaccounts = defineStore({
* Sorts accounts ascending
*/
sortAsc() {
this.items.sort((a, b) => a.service > b.service ? 1 : -1)
if (useUserStore().preferences.sortCaseSensitive) {
this.items.sort((a, b) => a.service > b.service ? 1 : -1)
}
else this.items.sort((a, b) => a.service.toLowerCase() > b.service.toLowerCase() ? 1 : -1)
this.saveOrder()
},
@ -189,7 +192,10 @@ export const useTwofaccounts = defineStore({
* Sorts accounts descending
*/
sortDesc() {
this.items.sort((a, b) => a.service < b.service ? 1 : -1)
if (useUserStore().preferences.sortCaseSensitive) {
this.items.sort((a, b) => a.service < b.service ? 1 : -1)
}
else this.items.sort((a, b) => a.service.toLowerCase() < b.service.toLowerCase() ? 1 : -1)
this.saveOrder()
},

View File

@ -137,9 +137,11 @@
<!-- password format -->
<FormCheckbox v-model="user.preferences.formatPassword" @update:model-value="val => savePreference('formatPassword', val)" fieldName="formatPassword" label="settings.forms.password_format.label" help="settings.forms.password_format.help" />
<FormToggle v-model="user.preferences.formatPasswordBy" @update:model-value="val => savePreference('formatPasswordBy', val)" :choices="passwordFormats" fieldName="formatPasswordBy" :isDisabled="!user.preferences.formatPassword" />
<!-- clear search on copy -->
<FormCheckbox v-model="user.preferences.clearSearchOnCopy" @update:model-value="val => savePreference('clearSearchOnCopy', val)" fieldName="clearSearchOnCopy" label="settings.forms.clear_search_on_copy.label" help="settings.forms.clear_search_on_copy.help" />
<!-- copy otp on get -->
<!-- sort case sensitive -->
<FormCheckbox v-model="user.preferences.sortCaseSensitive" @update:model-value="val => savePreference('sortCaseSensitive', val)" fieldName="sortCaseSensitive" label="settings.forms.sort_case_sensitive.label" help="settings.forms.sort_case_sensitive.help" />
<h4 class="title is-4 pt-4 has-text-grey-light">{{ $t('groups.groups') }}</h4>
<!-- default group -->
<FormSelect v-model="user.preferences.defaultGroup" @update:model-value="val => savePreference('defaultGroup', val)" :options="groupsList" fieldName="defaultGroup" label="settings.forms.default_group.label" help="settings.forms.default_group.help" />

View File

@ -73,6 +73,10 @@
'label' => 'Clear Search on copy',
'help' => 'Empty the Search box right after a code has been copied to the clipboard'
],
'sort_case_sensitive' => [
'label' => 'Sort case sensitive',
'help' => 'When invoked, force the Sort function to sort accounts on a case-sensitive basis'
],
'copy_otp_on_display' => [
'label' => 'Copy <abbr title="One-Time Password">OTP</abbr> on display',
'help' => 'Automatically copy a generated password right after it appears on screen. Due to browsers limitations, only the first <abbr title="Time-based One-Time Password">TOTP</abbr> password will be copied, not the rotating ones'