diff --git a/migrations/tenant/0036-note-settings@add-showNoteHierarchy.sql b/migrations/tenant/0036-note-settings@add-showNoteHierarchy.sql new file mode 100644 index 00000000..86c977ea --- /dev/null +++ b/migrations/tenant/0036-note-settings@add-showNoteHierarchy.sql @@ -0,0 +1,11 @@ +DO $$ +BEGIN + IF NOT EXISTS ( + SELECT * + FROM information_schema.columns + WHERE table_name = 'note_settings' AND column_name = 'show_note_hierarchy' + ) THEN + ALTER TABLE "public"."note_settings" + ADD COLUMN "show_note_hierarchy" BOOLEAN NOT NULL DEFAULT false; + END IF; +END $$; \ No newline at end of file diff --git a/src/domain/entities/noteSettings.ts b/src/domain/entities/noteSettings.ts index 97efef96..1c8dc9d4 100644 --- a/src/domain/entities/noteSettings.ts +++ b/src/domain/entities/noteSettings.ts @@ -43,12 +43,17 @@ export default interface NoteSettings { * Team members. Team is empty by default because note creator is not stored in team */ team?: Team; + + /** + * Note Heirarchy display + */ + showNoteHierarchy: boolean; } /** * Attributes of public note settings */ -type NoteSettingsPublicProperties = 'customHostname' | 'isPublic' | 'invitationHash' | 'team' | 'cover' ; +type NoteSettingsPublicProperties = 'customHostname' | 'isPublic' | 'invitationHash' | 'team' | 'cover' | 'showNoteHierarchy' ; export interface NoteSettingsPublic extends Pick {} @@ -63,6 +68,7 @@ export function definePublicNoteSettings(noteSettings: NoteSettings): NoteSettin invitationHash: noteSettings.invitationHash, team: noteSettings.team, cover: noteSettings.cover, + showNoteHierarchy: noteSettings.showNoteHierarchy, }; } diff --git a/src/domain/service/noteSettings.ts b/src/domain/service/noteSettings.ts index b6df79bf..ea2f0985 100644 --- a/src/domain/service/noteSettings.ts +++ b/src/domain/service/noteSettings.ts @@ -102,6 +102,7 @@ export default class NoteSettingsService { noteId: noteId, isPublic: isPublic, invitationHash: createInvitationHash(), + showNoteHierarchy: false, }); } diff --git a/src/presentation/http/router/noteSettings.ts b/src/presentation/http/router/noteSettings.ts index 00a1b17a..0115035d 100644 --- a/src/presentation/http/router/noteSettings.ts +++ b/src/presentation/http/router/noteSettings.ts @@ -216,7 +216,7 @@ const NoteSettingsRouter: FastifyPluginCallback = (fa * Patch noteSettings by note id */ fastify.patch<{ - Body: Pick; + Body: Pick; Params: { notePublicId: NotePublicId; }; @@ -263,12 +263,13 @@ const NoteSettingsRouter: FastifyPluginCallback = (fa /** * @todo validate data */ - const { customHostname, isPublic, cover } = request.body; + const { customHostname, isPublic, cover, showNoteHierarchy } = request.body; const updatedNoteSettings = await noteSettingsService.patchNoteSettingsByNoteId(noteId, { customHostname, isPublic, cover, + showNoteHierarchy, }); if (updatedNoteSettings === null) { diff --git a/src/presentation/http/schema/NoteSettings.ts b/src/presentation/http/schema/NoteSettings.ts index d87c9a2b..5e90d3bc 100644 --- a/src/presentation/http/schema/NoteSettings.ts +++ b/src/presentation/http/schema/NoteSettings.ts @@ -55,5 +55,8 @@ export const NoteSettingsSchema = { role: { type: 'number', }, + showNoteHierarchy: { + type: 'boolean', + }, }, }; diff --git a/src/repository/storage/postgres/orm/sequelize/noteSettings.ts b/src/repository/storage/postgres/orm/sequelize/noteSettings.ts index 50beb6bb..0a50e9af 100644 --- a/src/repository/storage/postgres/orm/sequelize/noteSettings.ts +++ b/src/repository/storage/postgres/orm/sequelize/noteSettings.ts @@ -38,6 +38,11 @@ export class NoteSettingsModel extends Model, * Id of the cover file */ public declare cover: CreationOptional; + + /** + * Note heirarchy + */ + public declare showNoteHierarchy: NoteSettings['showNoteHierarchy']; } /** @@ -105,6 +110,11 @@ export default class NoteSettingsSequelizeStorage { type: DataTypes.STRING, allowNull: true, }, + showNoteHierarchy: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: false, + }, }, { tableName: this.tableName, sequelize: this.database, @@ -194,6 +204,7 @@ export default class NoteSettingsSequelizeStorage { customHostname, isPublic, invitationHash, + showNoteHierarchy, }: NoteSettingsCreationAttributes ): Promise { const settings = await this.model.create({ @@ -201,6 +212,7 @@ export default class NoteSettingsSequelizeStorage { customHostname, isPublic, invitationHash, + showNoteHierarchy, }); return settings;