-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
189 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<script> | ||
import MarkdownEditor from '@/components/forms/MarkdownEditor.vue'; | ||
export default { | ||
name: 'CommentCard', | ||
props: { | ||
author: { | ||
required: true | ||
}, | ||
date: { | ||
required: true | ||
}, | ||
comment: { | ||
required: true | ||
}, | ||
editedBy: { | ||
required: false | ||
} | ||
}, | ||
emit: ['comment-edited'], | ||
data() { | ||
return { | ||
editMode: false, | ||
editedComment: this.comment, | ||
items: [ | ||
{ | ||
label: 'Edit', | ||
icon: 'fa fa-edit', | ||
command: () => { | ||
this.editMode = !this.editMode; | ||
} | ||
} | ||
] | ||
}; | ||
}, | ||
methods: { | ||
toggle(event) { | ||
this.$refs.menu.toggle(event); | ||
}, | ||
onCommentEdited() { | ||
this.$emit('comment-edited', this.editedComment); | ||
this.editMode = false; | ||
} | ||
}, | ||
components: { MarkdownEditor } | ||
}; | ||
</script> | ||
|
||
<template> | ||
<Card class="card p-0 surface-ground border-200 border-1 border-round mt-3"> | ||
<template #header> | ||
<div class="col-12 surface-card border-bottom-1 border-200"> | ||
<div class="grid"> | ||
<div class="col-10"> | ||
<div class="flex justify-content-start">{{ author }} commented on {{ date }}</div> | ||
</div> | ||
<div class="col-2"> | ||
<div class="flex justify-content-end"> | ||
<Button size="small" text type="button" class="text-color p-1" icon="fa fa-ellipsis" @click="toggle" aria-haspopup="true" aria-controls="comment_edit_menu" /> | ||
<Menu ref="menu" id="comment_edit_menu" :model="items" :popup="true"></Menu> | ||
</div> | ||
</div> | ||
<div class="col-12 mt-0 pt-0 pb-0 mb-0" v-if="editedBy"> | ||
<small>edited by {{ editedBy }}</small> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
<template #content> | ||
<div class="grid"> | ||
<div class="col-12" v-if="editMode !== true"> | ||
{{ comment }} | ||
</div> | ||
<div class="col-12" v-else> | ||
<MarkdownEditor v-model="editedComment"></MarkdownEditor> | ||
<Button label="Save" @click="onCommentEdited"></Button> | ||
</div> | ||
</div> | ||
</template> | ||
</Card> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
server/backend/migrations/0046_findingcomment_user_edit_alter_findingcomment_user.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated by Django 5.0.1 on 2024-02-04 06:41 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
import pecoret.core.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('backend', '0045_alter_user_managers'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='findingcomment', | ||
name='user_edit', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=pecoret.core.models.CASCADE_USER_TO_GHOST, | ||
related_name='finding_comment_edited_set', to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.AlterField( | ||
model_name='findingcomment', | ||
name='user', | ||
field=models.ForeignKey(on_delete=pecoret.core.models.CASCADE_USER_TO_GHOST, to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.AddField( | ||
model_name='advisorycomment', | ||
name='user_edit', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=pecoret.core.models.CASCADE_USER_TO_GHOST, | ||
related_name='advisory_comment_edited_set', to=settings.AUTH_USER_MODEL), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters