Skip to content
Snippets Groups Projects
Commit 226ce752 authored by Viktoria Wiebe's avatar Viktoria Wiebe Committed by Jan-Hendrik Willms
Browse files

Courseware: Datum bei Verlängerung von Aufgaben

Closes #2553

Merge request studip/studip!3335
parent 4fb5564e
No related branches found
No related tags found
No related merge requests found
<template>
<input :value="formattedDate" @input="onInput" type="date" />
<input :value="formattedDate" @input="onInput" type="date" :min="formattedMinDate" />
</template>
<script>
......@@ -8,14 +8,18 @@ const toISO8601 = (date) => date.toISOString();
const pad = (what, length = 2) => `00000000${what}`.substr(-length);
export default {
props: ['value'],
props: ['value', 'min'],
data: () => ({
date: new Date(),
submissionDate: new Date()
}),
computed: {
formattedDate() {
return `${this.date.getFullYear()}-${pad(this.date.getMonth() + 1)}-${pad(this.date.getDate())}`;
},
formattedMinDate() {
return `${this.submissionDate.getFullYear()}-${pad(this.submissionDate.getMonth() + 1)}-${pad(this.submissionDate.getDate())}`;
}
},
methods: {
onInput({ target }) {
......@@ -29,6 +33,9 @@ export default {
if (this.value) {
this.date = fromISO8601(this.value);
}
if (this.min) {
this.submissionDate = fromISO8601(this.min);
}
},
};
</script>
......@@ -50,8 +50,8 @@
<RenewalDialog
v-if="renewalTask"
:renewalDate="renewalDate"
:renewalState="renewalTask.attributes.renewal"
:submissionDate="renewalTask.attributes['submission-date']"
@update="updateRenewal"
@close="closeDialogs"
/>
......
......@@ -24,7 +24,7 @@
</label>
<label v-if="state === 'granted'">
{{ $gettext('neue Frist') }}
<DateInput v-model="date" class="size-l" />
<DateInput v-model="date" class="size-l" :min="submissionDate" />
</label>
</form>
</template>
......@@ -34,7 +34,7 @@
<script>
import DateInput from '../layouts/CoursewareDateInput.vue';
export default {
props: ['renewalDate', 'renewalState'],
props: ['renewalState', 'submissionDate'],
components: {
DateInput,
},
......@@ -44,7 +44,7 @@ export default {
}),
methods: {
resetLocalVars() {
this.date = this.renewalDate ?? null;
this.date = this.submissionDate ?? null;
this.state = this.renewalState;
},
updateRenewal() {
......@@ -64,7 +64,7 @@ export default {
this.resetLocalVars();
},
watch: {
renewalDate(newValue) {
submissionDate(newValue) {
if (newValue !== this.date) {
this.resetLocalVars();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment