Fix SingleSelect usage for configureRetention

This commit is contained in:
Girish Ramakrishnan
2025-10-07 14:53:44 +02:00
parent 15256ebbdf
commit 0458fee326
2 changed files with 7 additions and 10 deletions

View File

@@ -16,7 +16,7 @@ const dialog = useTemplateRef('dialog');
const scheduleEnabled = ref(false); const scheduleEnabled = ref(false);
const days = ref([]); const days = ref([]);
const hours = ref([]); const hours = ref([]);
const configureRetention = ref(''); const configureRetention = ref(''); // this is 'name' and not 'id' of backupRetentions because SingleSelect needs strings
const isConfigureValid = computed(() => { const isConfigureValid = computed(() => {
return !!days.value.length && !!hours.value.length; return !!days.value.length && !!hours.value.length;
}); });
@@ -48,7 +48,8 @@ async function onSubmit() {
return console.error(error); return console.error(error);
} }
[error] = await backupSitesModel.setRetention(id.value, configureRetention.value); const selectedRetention = BackupSitesModel.backupRetentions.find(function (x) { return x.name === configureRetention.value; });
[error] = await backupSitesModel.setRetention(id.value, selectedRetention.id);
if (error) { if (error) {
busy.value = false; busy.value = false;
formError.value = error.body ? error.body.message : 'Internal error'; formError.value = error.body ? error.body.message : 'Internal error';
@@ -68,9 +69,8 @@ defineExpose({
formError.value = false; formError.value = false;
const currentRetentionString = JSON.stringify(site.retention); const currentRetentionString = JSON.stringify(site.retention);
let selectedRetention = BackupSitesModel.backupRetentions.find(function (x) { return JSON.stringify(x.id) === currentRetentionString; }); const selectedRetention = BackupSitesModel.backupRetentions.find(function (x) { return JSON.stringify(x.id) === currentRetentionString; });
if (!selectedRetention) selectedRetention = BackupSitesModel.backupRetentions[0]; configureRetention.value = selectedRetention ? selectedRetention.name : BackupSitesModel.backupRetentions[0].name;
configureRetention.value = selectedRetention.id;
if (site.schedule === 'never') { if (site.schedule === 'never') {
scheduleEnabled.value = false; scheduleEnabled.value = false;
@@ -122,7 +122,8 @@ defineExpose({
<FormGroup> <FormGroup>
<label for="retentionInput">{{ $t('backups.configureBackupSchedule.retentionPolicy') }}</label> <label for="retentionInput">{{ $t('backups.configureBackupSchedule.retentionPolicy') }}</label>
<SingleSelect id="retentionInput" v-model="configureRetention" :options="BackupSitesModel.backupRetentions" option-key="id" option-label="name" /> <!-- we do not used id as key because SingleSelect can only handle strings -->
<SingleSelect id="retentionInput" v-model="configureRetention" :options="BackupSitesModel.backupRetentions" option-key="name" option-label="name" />
</FormGroup> </FormGroup>
</fieldset> </fieldset>
</form> </form>

View File

@@ -318,10 +318,6 @@ onMounted(async () => {
justify-content: space-between; justify-content: space-between;
} }
.backup-site:hover {
/*background-color: var(--pankow-color-background-hover);*/
}
.backup-site-details { .backup-site-details {
display: flex; display: flex;
flex-direction: column; flex-direction: column;