Skip to content
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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
26 changes: 26 additions & 0 deletions src/application/services/useNote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
*/
const parentNote = ref<Note | undefined>(undefined);

/**
* Note parents of the actual note
*
* Actual note by default
*/
const noteParents = ref<Note[]>([]);
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still actual


/**
* Load note by id
* @param id - Note identifier got from composable argument
Expand All @@ -172,6 +179,7 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
canEdit.value = response.accessRights.canEdit;
noteTools.value = response.tools;
parentNote.value = response.parentNote;
noteParents.value = response.parents;
}

/**
Expand Down Expand Up @@ -265,6 +273,23 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
parentNote.value = undefined;
}

/**
* Format the received note parents into presentation format
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description is not clear

*/
function formatNoteParents(): string {
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;
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Member

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

}

/**
* Get note by custom hostname
*/
Expand Down Expand Up @@ -315,6 +340,7 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
});

watch(noteTitle, (currentNoteTitle) => {
formatNoteParents();
patchOpenedPageByUrl(
route.path,
{
Expand Down
5 changes: 5 additions & 0 deletions src/domain/entities/NoteDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ export interface NoteDTO {
* Editor tools
*/
tools: EditorTool[];

/**
* Note parents
*/
parents: Note[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export type GetNoteResponsePayload = {
accessRights: NoteAccessRights;
parentNote: Note | undefined;
tools: EditorTool[];
parents: Note[];
};
Loading