#88 - fix edit comment system
This commit is contained in:
parent
dd6eff2904
commit
12562ed8da
3 changed files with 10 additions and 11 deletions
|
|
@ -21,13 +21,13 @@
|
|||
</p>
|
||||
</header>
|
||||
|
||||
<p v-if="!isEditCommentMode" class="comment__body">
|
||||
<p v-if="!comment.isEditMode" class="comment__body">
|
||||
{{ comment.text }}
|
||||
</p>
|
||||
|
||||
<textarea v-else class="comment__body" v-model="draftText"></textarea>
|
||||
|
||||
<footer v-if="!isEditCommentMode" class="comment__replies">
|
||||
<footer v-if="!comment.isEditMode" class="comment__replies">
|
||||
<p v-if="comment.replies?.length > 0">
|
||||
{{ comment.replies.length }} réponse{{
|
||||
comment.replies.length > 1 ? "s" : ""
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
<button
|
||||
class="btn btn--transparent btn--icon btn--sm"
|
||||
data-icon="edit"
|
||||
@click="isEditCommentMode = true"
|
||||
@click="comment.isEditMode = true"
|
||||
>
|
||||
<span class="sr-only">Éditer</span>
|
||||
</button>
|
||||
|
|
@ -89,7 +89,7 @@ const emits = defineEmits(["update:file", "close:comment"]);
|
|||
const userStore = useUserStore();
|
||||
const api = useApiStore();
|
||||
const dialog = useDialogStore();
|
||||
const { activeTracks, isEditCommentMode } = storeToRefs(useDialogStore());
|
||||
const { activeTracks } = storeToRefs(useDialogStore());
|
||||
const draftText = ref(comment.text);
|
||||
|
||||
// Functions
|
||||
|
|
@ -159,12 +159,12 @@ function saveEditedComment(event) {
|
|||
comment.text = draftText.value;
|
||||
comment.date = dayjs().format();
|
||||
api.updateComment(comment);
|
||||
isEditCommentMode.value = false;
|
||||
comment.isEditMode = false;
|
||||
}
|
||||
|
||||
function cancelEditComment(event) {
|
||||
event.stopImmediatePropagation();
|
||||
isEditCommentMode.value = false;
|
||||
comment.isEditMode = false;
|
||||
draftText.value = comment.text;
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -121,8 +121,9 @@ dayjs.locale("fr");
|
|||
const { user } = useUserStore();
|
||||
const { page } = usePageStore();
|
||||
const dialog = useDialogStore();
|
||||
const { comments, openedFile, draftComment, activeTracks, isEditCommentMode } =
|
||||
storeToRefs(useDialogStore());
|
||||
const { comments, openedFile, draftComment, activeTracks } = storeToRefs(
|
||||
useDialogStore()
|
||||
);
|
||||
const api = useApiStore();
|
||||
|
||||
const openedComment = ref(null);
|
||||
|
|
@ -304,7 +305,7 @@ function prepareDraftCommentInImage(event) {
|
|||
}
|
||||
|
||||
function openComment(comment) {
|
||||
if (isEditCommentMode.value) return;
|
||||
if (comment.isEditMode) return;
|
||||
|
||||
openedComment.value = comment;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ export const useDialogStore = defineStore("dialog", () => {
|
|||
const content = ref(null);
|
||||
const openedFile = ref(null);
|
||||
const activeTracks = ref(null);
|
||||
const isEditCommentMode = ref(false);
|
||||
|
||||
const comments = computed(() => {
|
||||
if (activeTracks.value?.length > 0) {
|
||||
|
|
@ -144,6 +143,5 @@ export const useDialogStore = defineStore("dialog", () => {
|
|||
isCommentsOpen,
|
||||
isCommentPanelEnabled,
|
||||
updateFile,
|
||||
isEditCommentMode,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue