-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: display the note parents structure #275
base: main
Are you sure you want to change the base?
Conversation
* | ||
* Actual note by default | ||
*/ | ||
const noteParents = ref<Note[]>([]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think that making noteParents
reactive is a bad thing to do
We can update them only by request to api /GET note
so i can't see the case, when we update noteParents and imidiately change displayed content somewhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still actual
src/application/services/useNote.ts
Outdated
if (currentId.value === null) { | ||
throw new Error('note id is not defined'); | ||
} | ||
let presentationFormat = ''; | ||
|
||
for (let value of noteParents.value) { | ||
presentationFormat += getTitle(value.content) + ' > '; | ||
} | ||
presentationFormat += noteTitle.value; | ||
|
||
return presentationFormat; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parentNote
title should be clickable so just merge titles into one string is not a solution.
Also can't see the case with RootNoteTitle > ... > CurrentNote
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can use anchor tag <a>
can solve the merge of titles into one string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's better to do it in a component
src/application/services/useNote.ts
Outdated
@@ -265,6 +273,23 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt | |||
parentNote.value = undefined; | |||
} | |||
|
|||
/** | |||
* Format the received note parents into presentation format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description is not clear
…n useNoteComposableState interface
…pplied, still need work to be done
src/application/services/useNote.ts
Outdated
/** | ||
* Returns an array of Note objects representing the formatted note parents. | ||
*/ | ||
formatNoteParents: () => Note[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from the "composable" pattern its better to export "noteParents" object instead
src/application/services/useNote.ts
Outdated
/** | ||
* Reform the received note parents from api into presentation format. | ||
* @returns An array of Note objects representing the formatted note parents. | ||
* @throws {Error} If the note id is not defined. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont really understand what this method is doing. Could you please improve jsdoc to make it more clear? Why API format is not suitable?
src/presentation/pages/Note.vue
Outdated
v-for="(parent, index) in displayedParents" | ||
:key="parent.id" | ||
> | ||
<a @click="handleParentClick(parent)">{{ newGetTitle(parent.content) }}</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use RouterLink instead of a
src/presentation/pages/Note.vue
Outdated
: t('note.lastEdit') + ' ' + 'a few seconds ago' | ||
}} | ||
<div v-if="noteParents.length"> | ||
<span |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
span seems redunant
src/presentation/pages/Note.vue
Outdated
* @param {string} parent.id - The ID of the parent note | ||
*/ | ||
function handleParentClick(parent: { id: string }): void { | ||
if (parent.id !== 'ellipsis') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like a magic string
src/presentation/pages/Note.vue
Outdated
* @param {OutputData | { title: string }} content - The content of the note | ||
* @returns {string} - The title of the note | ||
*/ | ||
function newGetTitle(content: OutputData | { title: string }): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have such a method
presentationFormat.push({ | ||
id: currentId.value, | ||
content: note.value?.content as NoteContent, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why you are adding current note as a parent? I don't think that it is a good idea
@@ -265,6 +278,35 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt | |||
parentNote.value = undefined; | |||
} | |||
|
|||
/** | |||
* Reform the array of note parents by adding the actual note id and content. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still don't understand the problem. API returns id and content, why do we need to change them?
? t('note.lastEdit') + ' ' + getTimeFromNow(note.updatedAt) | ||
: t('note.lastEdit') + ' ' + 'a few seconds ago' | ||
}} | ||
<div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
div seems redundant
v-for="(parent, index) in displayedParents" | ||
:key="index" | ||
:to="{ path: `/note/${parent.id ? parent.id : noteId}` }" | ||
@click.prevent="handleParentClick($event, parent)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably you don't need to handle click manually since you are using router link
* | ||
* @param {number} parentId - The ID of the parent note to navigate to | ||
*/ | ||
function navigateToParent(parentId: string): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems redundant
} | ||
|
||
/** | ||
* Displayed parents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad description
* | ||
* Actual note by default | ||
*/ | ||
const noteParents = ref<Note[]>([]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still actual
const displayedParents = computed(() => { | ||
if (noteParents.value.length > 3) { | ||
const newNoteContent = { blocks: [] } as OutputData; | ||
|
||
newNoteContent.blocks.push({ type: 'paraghraph', | ||
data: { text: '...' } }); | ||
|
||
return [ | ||
noteParents.value[0], | ||
{ id: '', | ||
content: newNoteContent }, | ||
noteParents.value[noteParents.value.length - 1], | ||
]; | ||
} | ||
|
||
return noteParents.value; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would suggest moving all of this logic to different component of Notex (not codex-ui), then we will not overcomplicate Note page
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this is discussable, @neSpecc what do you think about this?
* @returns An array of Note objects representing the formatted note parents. | ||
* @throws {Error} If the note id is not defined. | ||
*/ | ||
function formatNoteParents(): Note[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method would be used only in component, so we should move this logic to computable displayedParents
no need to produce extra entities (such as presentationFormat
)
Problem:
The issue is that when accessing a note, you would not know the note parent hierarchy, or the note parent of the actual note you are accessing.
Solution:
As describe in issue #256, we will be displaying the parent note structure at the top left of the note, following the tasks required to insure that the display of the note structure would be efficient.
Resolves #256