fix initialComment with patch endpoint

This commit is contained in:
2021-05-19 10:34:17 +02:00
parent 9ef397e935
commit 27f49b2aa3
3 changed files with 30 additions and 54 deletions

View File

@@ -6,12 +6,12 @@
{{ errors[0] }}
</div>
<div v-if="firstComment">
créé par {{ firstComment.creator.text }}
le {{ $d(firstComment.createdAt.datetime, 'long') }}
<div v-if="firstComment.updatedAt.datetime !== firstComment.createdAt.datetime">
modifié par {{ firstComment.updatedBy.text }}
le {{ $d(firstComment.updatedAt.datetime, 'long') }}
<div v-if="initialComment">
créé par {{ initialComment.creator.text }}
le {{ $d(initialComment.createdAt.datetime, 'long') }}
<div v-if="initialComment.updatedAt.datetime !== initialComment.createdAt.datetime">
modifié par {{ initialComment.updatedBy.text }}
le {{ $d(initialComment.updatedAt.datetime, 'long') }}
</div>
</div>
@@ -28,9 +28,17 @@
<li>
<button type="submit" class="sc-button bt-save">{{ $t('action.save') }}</button>
</li>
<li id="xyz">
</li>
</ul>
</form>
<button
class="sc-button bt-delete"
@click="removeComment">
{{ $t('action.delete') }}
</button>
</div>
</template>
@@ -40,23 +48,21 @@ export default {
data() {
return {
formdata: {
type: "accompanying_period_comment",
content: ''
}
}
},
computed: {
comments() {
return this.$store.state.accompanyingCourse.comments;
},
firstComment() {
return this.comments[0];
initialComment() {
return this.$store.state.accompanyingCourse.initialComment;
},
content: {
set(value) {
this.formdata.content = value;
},
get() {
return (this.comments.length > 0) ? this.comments[0].content : null ;
return (this.initialComment)? this.initialComment.content : null;
}
},
errors() {
@@ -65,8 +71,12 @@ export default {
},
methods: {
submitform() {
this.formdata['method'] = (!this.firstComment)? 'POST' : 'PATCH';
console.log('submit');
this.$store.dispatch('postFirstComment', this.formdata);
},
removeComment() {
console.log('remove');
this.$store.dispatch('postFirstComment', null);
}
}
}