fix(dav): Make ooo settings a form and the message required

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
pull/41759/head
Christoph Wurst 2 years ago
parent c13b748dea
commit ecc1576be6
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
  1. 25
      apps/dav/src/components/AbsenceForm.vue
  2. 4
      dist/dav-settings-personal-availability.js
  3. 21
      dist/dav-settings-personal-availability.js.LICENSE.txt
  4. 2
      dist/dav-settings-personal-availability.js.map

@ -21,24 +21,26 @@
--> -->
<template> <template>
<div class="absence"> <form class="absence" @submit.prevent="saveForm">
<div class="absence__dates"> <div class="absence__dates">
<NcDateTimePickerNative id="absence-first-day" <NcDateTimePickerNative id="absence-first-day"
v-model="firstDay" v-model="firstDay"
:label="$t('dav', 'First day')" :label="$t('dav', 'First day')"
class="absence__dates__picker" /> class="absence__dates__picker"
:required="true" />
<NcDateTimePickerNative id="absence-last-day" <NcDateTimePickerNative id="absence-last-day"
v-model="lastDay" v-model="lastDay"
:label="$t('dav', 'Last day (inclusive)')" :label="$t('dav', 'Last day (inclusive)')"
class="absence__dates__picker" /> class="absence__dates__picker"
:required="true" />
</div> </div>
<NcTextField :value.sync="status" :label="$t('dav', 'Short absence status')" /> <NcTextField :value.sync="status" :label="$t('dav', 'Short absence status')" :required="true" />
<NcTextArea :value.sync="message" :label="$t('dav', 'Long absence Message')" /> <NcTextArea :value.sync="message" :label="$t('dav', 'Long absence Message')" :required="true" />
<div class="absence__buttons"> <div class="absence__buttons">
<NcButton :disabled="loading || !valid" <NcButton :disabled="loading || !valid"
type="primary" type="primary"
@click="saveForm"> native-type="submit">
{{ $t('dav', 'Save') }} {{ $t('dav', 'Save') }}
</NcButton> </NcButton>
<NcButton :disabled="loading || !valid" <NcButton :disabled="loading || !valid"
@ -47,7 +49,7 @@
{{ $t('dav', 'Disable absence') }} {{ $t('dav', 'Disable absence') }}
</NcButton> </NcButton>
</div> </div>
</div> </form>
</template> </template>
<script> <script>
@ -59,7 +61,9 @@ import { generateUrl } from '@nextcloud/router'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { formatDateAsYMD } from '../utils/date.js' import { formatDateAsYMD } from '../utils/date.js'
import { loadState } from '@nextcloud/initial-state' import { loadState } from '@nextcloud/initial-state'
import { showError } from '@nextcloud/dialogs' import { showError, showSuccess } from '@nextcloud/dialogs'
import logger from '../service/logger.js'
export default { export default {
name: 'AbsenceForm', name: 'AbsenceForm',
@ -88,6 +92,7 @@ export default {
return !!this.firstDay return !!this.firstDay
&& !!this.lastDay && !!this.lastDay
&& !!this.status && !!this.status
&& !!this.message
&& this.lastDay > this.firstDay && this.lastDay > this.firstDay
}, },
}, },
@ -111,8 +116,10 @@ export default {
status: this.status, status: this.status,
message: this.message, message: this.message,
}) })
showSuccess(this.$t('dav', 'Absence saved'))
} catch (error) { } catch (error) {
showError(this.$t('dav', 'Failed to save your absence settings')) showError(this.$t('dav', 'Failed to save your absence settings'))
logger.error('Could not save absence', { error })
} finally { } finally {
this.loading = false this.loading = false
} }
@ -122,8 +129,10 @@ export default {
try { try {
await axios.delete(generateUrl('/apps/dav/settings/absence')) await axios.delete(generateUrl('/apps/dav/settings/absence'))
this.resetForm() this.resetForm()
showSuccess(this.$t('dav', 'Absence cleared'))
} catch (error) { } catch (error) {
showError(this.$t('dav', 'Failed to clear your absence settings')) showError(this.$t('dav', 'Failed to clear your absence settings'))
logger.error('Could not clear absence', { error })
} finally { } finally {
this.loading = false this.loading = false
} }

File diff suppressed because one or more lines are too long

@ -1,3 +1,24 @@
/*
* @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* /*
* @copyright Copyright (c) 2022 Richard Steinmetz <richard@steinmetz.cloud> * @copyright Copyright (c) 2022 Richard Steinmetz <richard@steinmetz.cloud>
* *

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save