Skip to content

Commit 6f9620f

Browse files
committed
refactor(UserSettings): use NcSelect for batchtime
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 1482928 commit 6f9620f

1 file changed

Lines changed: 37 additions & 17 deletions

File tree

src/views/UserSettings.vue

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,19 @@
88
<div class="notification-frequency__warning">
99
<strong v-if="!config.is_email_set">{{ t('notifications', 'You need to set up your email address before you can receive notification emails.') }}</strong>
1010
</div>
11-
<p>
11+
<div class="notification-frequency__wrapper">
1212
<label for="notification_reminder_batchtime" class="notification-frequency__label">
1313
{{ t('notifications', 'Send email reminders about unhandled notifications after:') }}
1414
</label>
15-
<select
15+
<NcSelect
1616
id="notification_reminder_batchtime"
17-
v-model="config.setting_batchtime"
18-
name="notification_reminder_batchtime"
17+
v-model="currentBatchTime"
1918
class="notification-frequency__select"
20-
@change="updateSettings()">
21-
<option v-for="option in BATCHTIME_OPTIONS" :key="option.value" :value="option.value">
22-
{{ option.text }}
23-
</option>
24-
</select>
25-
</p>
19+
:clearable="false"
20+
label-outside
21+
:options="BATCHTIME_OPTIONS"
22+
@update:model-value="updateSettings" />
23+
</div>
2624

2725
<NcCheckboxRadioSwitch
2826
v-model="config.sound_notification"
@@ -68,7 +66,7 @@ import { loadState } from '@nextcloud/initial-state'
6866
import { t } from '@nextcloud/l10n'
6967
import { generateOcsUrl } from '@nextcloud/router'
7068
import { UAParser } from 'ua-parser-js'
71-
import { reactive, ref } from 'vue'
69+
import { computed, reactive, ref } from 'vue'
7270
import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwitch'
7371
import NcSelect from '@nextcloud/vue/components/NcSelect'
7472
import NcSettingsSection from '@nextcloud/vue/components/NcSettingsSection'
@@ -82,11 +80,11 @@ const EmailFrequency = {
8280
EMAIL_SEND_WEEKLY: 4,
8381
}
8482
const BATCHTIME_OPTIONS = [
85-
{ text: t('notifications', 'Never'), value: EmailFrequency.EMAIL_SEND_OFF },
86-
{ text: t('notifications', '1 hour'), value: EmailFrequency.EMAIL_SEND_HOURLY },
87-
{ text: t('notifications', '3 hours'), value: EmailFrequency.EMAIL_SEND_3HOURLY },
88-
{ text: t('notifications', '1 day'), value: EmailFrequency.EMAIL_SEND_DAILY },
89-
{ text: t('notifications', '1 week'), value: EmailFrequency.EMAIL_SEND_WEEKLY },
83+
{ label: t('notifications', 'Never'), value: EmailFrequency.EMAIL_SEND_OFF },
84+
{ label: t('notifications', '1 hour'), value: EmailFrequency.EMAIL_SEND_HOURLY },
85+
{ label: t('notifications', '3 hours'), value: EmailFrequency.EMAIL_SEND_3HOURLY },
86+
{ label: t('notifications', '1 day'), value: EmailFrequency.EMAIL_SEND_DAILY },
87+
{ label: t('notifications', '1 week'), value: EmailFrequency.EMAIL_SEND_WEEKLY },
9088
]
9189
const EMPTY_DEVICE_OPTION = { id: null, label: t('notifications', 'None') }
9290
const parser = new UAParser()
@@ -109,12 +107,23 @@ export default {
109107
})
110108
const devices = ref([])
111109
110+
const currentBatchTime = computed({
111+
get() {
112+
return BATCHTIME_OPTIONS.find(({ value }) => value === config.setting_batchtime)
113+
},
114+
set({ value }) {
115+
config.setting_batchtime = value
116+
},
117+
})
118+
112119
return {
113120
BATCHTIME_OPTIONS,
121+
114122
isSafari,
115123
config,
116-
storage,
124+
currentBatchTime,
117125
devices,
126+
storage,
118127
}
119128
},
120129
@@ -186,4 +195,15 @@ export default {
186195
.additional-margin-top {
187196
margin-top: 12px;
188197
}
198+
199+
.notification-frequency__wrapper {
200+
display: flex;
201+
flex-direction: column;
202+
gap: var(--default-grid-baseline);
203+
204+
.notification-frequency__select {
205+
margin-inline-start: calc(2 * var(--default-grid-baseline));
206+
width: fit-content;
207+
}
208+
}
189209
</style>

0 commit comments

Comments
 (0)