Skip to content

Commit 1722708

Browse files
committed
Note hierarchy appreance
1 parent 391f5bd commit 1722708

6 files changed

Lines changed: 38 additions & 3 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
DO $$
2+
BEGIN
3+
IF NOT EXISTS (
4+
SELECT *
5+
FROM information_schema.columns
6+
WHERE table_name = 'note_settings' AND column_name = 'show_note_hierarchy'
7+
) THEN
8+
ALTER TABLE "public"."note_settings"
9+
ADD COLUMN "show_note_hierarchy" BOOLEAN NOT NULL DEFAULT false;
10+
END IF;
11+
END $$;

src/domain/entities/noteSettings.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,17 @@ export default interface NoteSettings {
4343
* Team members. Team is empty by default because note creator is not stored in team
4444
*/
4545
team?: Team;
46+
47+
/**
48+
* Note Heirarchy display
49+
*/
50+
showNoteHierarchy: boolean;
4651
}
4752

4853
/**
4954
* Attributes of public note settings
5055
*/
51-
type NoteSettingsPublicProperties = 'customHostname' | 'isPublic' | 'invitationHash' | 'team' | 'cover' ;
56+
type NoteSettingsPublicProperties = 'customHostname' | 'isPublic' | 'invitationHash' | 'team' | 'cover' | 'showNoteHierarchy' ;
5257

5358
export interface NoteSettingsPublic extends Pick<NoteSettings, NoteSettingsPublicProperties> {}
5459

@@ -63,6 +68,7 @@ export function definePublicNoteSettings(noteSettings: NoteSettings): NoteSettin
6368
invitationHash: noteSettings.invitationHash,
6469
team: noteSettings.team,
6570
cover: noteSettings.cover,
71+
showNoteHierarchy: noteSettings.showNoteHierarchy,
6672
};
6773
}
6874

src/domain/service/noteSettings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export default class NoteSettingsService {
102102
noteId: noteId,
103103
isPublic: isPublic,
104104
invitationHash: createInvitationHash(),
105+
showNoteHierarchy: false,
105106
});
106107
}
107108

src/presentation/http/router/noteSettings.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ const NoteSettingsRouter: FastifyPluginCallback<NoteSettingsRouterOptions> = (fa
216216
* Patch noteSettings by note id
217217
*/
218218
fastify.patch<{
219-
Body: Pick<NoteSettings, 'customHostname' | 'isPublic' | 'cover'>;
219+
Body: Pick<NoteSettings, 'customHostname' | 'isPublic' | 'cover' | 'showNoteHierarchy'>;
220220
Params: {
221221
notePublicId: NotePublicId;
222222
};
@@ -263,12 +263,13 @@ const NoteSettingsRouter: FastifyPluginCallback<NoteSettingsRouterOptions> = (fa
263263
/**
264264
* @todo validate data
265265
*/
266-
const { customHostname, isPublic, cover } = request.body;
266+
const { customHostname, isPublic, cover, showNoteHierarchy } = request.body;
267267

268268
const updatedNoteSettings = await noteSettingsService.patchNoteSettingsByNoteId(noteId, {
269269
customHostname,
270270
isPublic,
271271
cover,
272+
showNoteHierarchy,
272273
});
273274

274275
if (updatedNoteSettings === null) {

src/presentation/http/schema/NoteSettings.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,9 @@ export const NoteSettingsSchema = {
5555
role: {
5656
type: 'number',
5757
},
58+
showNoteHierarchy: {
59+
type: 'boolean',
60+
default: false,
61+
},
5862
},
5963
};

src/repository/storage/postgres/orm/sequelize/noteSettings.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ export class NoteSettingsModel extends Model<InferAttributes<NoteSettingsModel>,
3838
* Id of the cover file
3939
*/
4040
public declare cover: CreationOptional<NoteSettings['cover']>;
41+
42+
/**
43+
* Note heirarchy
44+
*/
45+
public declare showNoteHierarchy: NoteSettings['showNoteHierarchy'];
4146
}
4247

4348
/**
@@ -105,6 +110,11 @@ export default class NoteSettingsSequelizeStorage {
105110
type: DataTypes.STRING,
106111
allowNull: true,
107112
},
113+
showNoteHierarchy: {
114+
type: DataTypes.BOOLEAN,
115+
allowNull: false,
116+
defaultValue: false,
117+
},
108118
}, {
109119
tableName: this.tableName,
110120
sequelize: this.database,
@@ -194,13 +204,15 @@ export default class NoteSettingsSequelizeStorage {
194204
customHostname,
195205
isPublic,
196206
invitationHash,
207+
showNoteHierarchy,
197208
}: NoteSettingsCreationAttributes
198209
): Promise<NoteSettings> {
199210
const settings = await this.model.create({
200211
noteId,
201212
customHostname,
202213
isPublic,
203214
invitationHash,
215+
showNoteHierarchy,
204216
});
205217

206218
return settings;

0 commit comments

Comments
 (0)