pdf > comments > new comments : show email address if no name

This commit is contained in:
isUnknown 2024-10-23 15:45:04 +02:00
parent 6bffbc1707
commit ea48094bc7
8 changed files with 52 additions and 43 deletions

View file

@ -6,31 +6,4 @@ Uuid: s0lNtRA0Z7ybTCWG
----
Template: document
----
Comments:
1:
m2lmqu2u:
text: test
username: Adrien Payet
date: 2024-10-23T10:46:08+02:00
m2lo4obv:
text: nouveau commentaire
username: Adrien Payet
date: 2024-10-23T11:24:53+02:00
m2lo6ckw:
text: Encore un autre commentaire
username: Adrien Payet
date: 2024-10-23T11:26:11+02:00
2:
m2loaj2f:
text: Autre commentaire
username: Adrien Payet
date: 2024-10-23T11:29:26+02:00
m2loam7s:
text: Autre commentaire
username: Adrien Payet
date: 2024-10-23T11:29:30+02:00
Template: document

View file

@ -1 +1,5 @@
title: Admin
title: Admin
fields:
notifications:
type: hidden

View file

@ -8,3 +8,5 @@ fields:
type: pages
max: 1
query: page('clients').children
notifications:
type: hidden

View file

@ -1,3 +1,7 @@
title:
title:
fr: Chef·fe de projet
en: Project Manager
en: Project Manager
fields:
notifications:
type: hidden

View file

@ -18,7 +18,7 @@ return [
$comments[$data->targetPage][$data->id] = [
'text' => $data->text,
'username' => (string) $user->name(),
'username' => $user->name()->isNotEmpty() ? (string) $user->name() : (string) $user->email(),
'date' => (string) $data->date,
];
@ -27,6 +27,6 @@ return [
'comments' => $comments
]);
return $comments;
return getFileData($newFile);
}
];

View file

@ -2,10 +2,7 @@
<aside id="comments-container" aria-labelledby="comments-label">
<h2 id="comments-label" class="sr-only">Commentaires</h2>
<div class="comments | flow">
<div
v-for="(page, pageIndex) in localComments"
class="comments__page-group"
>
<div v-for="(page, pageIndex) in comments" class="comments__page-group">
<article
v-for="(comment, commentIndex) in Object.values(page)"
:key="pageIndex + commentIndex"
@ -53,7 +50,9 @@
v-model="newCommentText"
></textarea>
<footer class="flex">
<button class="btn btn--white-20">Annuler</button>
<button class="btn btn--white-20" @click="closeAddField()">
Annuler
</button>
<input type="submit" class="btn btn--tranparent" />
</footer>
</form>
@ -80,7 +79,7 @@ const { page } = usePageStore();
const newCommentText = ref("");
const isAddOpen = ref(false);
const localComments = ref(comments);
const emits = defineEmits(["update:file"]);
// Functions
function addComment(event) {
@ -103,7 +102,11 @@ function addComment(event) {
fetch("/add-comment.json", headers)
.then((res) => res.json())
.then((json) => (localComments.value = json))
.then((newFile) => {
newCommentText.value = "";
isAddOpen.value = false;
emits("update:file", newFile);
})
.catch((error) => {
console.error("Erreur lors de la sauvegarde :", error);
});
@ -123,4 +126,9 @@ function formatDate(date) {
return dayjs(date).format("D MMM YY");
}
function closeAddField() {
isAddOpen.value = false;
newCommentText.value = "";
}
</script>

View file

@ -34,6 +34,7 @@
:current-page-index="currentPageIndex"
:file="file"
:comments="file.comments"
@update:file="changeFile"
/>
</div>
</Dialog>
@ -49,7 +50,7 @@ const { file } = defineProps({
file: Object,
});
const emit = defineEmits("close");
const emits = defineEmits(["close", "update:file"]);
const licenseKey = import.meta.env.VITE_VPV_LICENSE;
useLicense({ licenseKey });
@ -57,7 +58,7 @@ useLicense({ licenseKey });
// Variables
const isOpen = ref(true);
watch(isOpen, (newValue) => {
emit("close");
emits("close");
});
const isCommentsOpen = ref(false);
const currentPageIndex = ref(1);
@ -102,6 +103,10 @@ const onPdfLoaded = () => {
observePages();
};
function changeFile(newFile) {
emits("update:file", newFile);
}
</script>
<style>

View file

@ -3,7 +3,12 @@
<Header :title="page.content.title" />
<!-- Kanban: Status Brief Enrichi -->
<PdfViewer v-if="file" :file="file" @close="file = null" />
<PdfViewer
v-if="file"
:file="file"
@close="file = null"
@update:file="updateFile"
/>
<div class="kanban">
<ProjectStep
@ -181,6 +186,14 @@ function setStepStatus(stepName) {
function changeFile(newFile) {
file.value = newFile;
}
function updateFile(newFile) {
page.value.files = [];
page.value.files.push(newFile);
file.value = page.value.files[0];
console.log(file.value);
}
</script>
<style scope>