mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 01:35:18 -04:00
feat: move title and description to revision entity
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
20197d36df
commit
90df9a4e32
8 changed files with 73 additions and 29 deletions
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsDate, IsNumber, IsString } from 'class-validator';
|
||||
import { IsArray, IsDate, IsNumber, IsString } from 'class-validator';
|
||||
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
import { Revision } from './revision.entity';
|
||||
|
@ -50,4 +50,31 @@ export class RevisionMetadataDto extends BaseDto {
|
|||
@IsNumber()
|
||||
@ApiProperty()
|
||||
anonymousAuthorCount: number;
|
||||
|
||||
/**
|
||||
* Title of the note
|
||||
* Does not contain any markup but might be empty
|
||||
* @example "Shopping List"
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
title: string;
|
||||
|
||||
/**
|
||||
* Description of the note
|
||||
* Does not contain any markup but might be empty
|
||||
* @example Everything I want to buy
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
description: string;
|
||||
|
||||
/**
|
||||
* List of tags assigned to this note
|
||||
* @example "['shopping', 'personal']
|
||||
*/
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
@ApiProperty()
|
||||
tags: string[];
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import {
|
|||
} from 'typeorm';
|
||||
|
||||
import { Note } from '../notes/note.entity';
|
||||
import { Tag } from '../notes/tag.entity';
|
||||
import { Edit } from './edit.entity';
|
||||
|
||||
/**
|
||||
|
@ -34,6 +35,23 @@ export class Revision {
|
|||
})
|
||||
patch: string;
|
||||
|
||||
@Column({
|
||||
type: 'text',
|
||||
})
|
||||
title: string;
|
||||
|
||||
@Column({
|
||||
type: 'text',
|
||||
})
|
||||
description: string;
|
||||
|
||||
@ManyToMany((_) => Tag, (tag) => tag.revisions, {
|
||||
eager: true,
|
||||
cascade: true,
|
||||
})
|
||||
@JoinTable()
|
||||
tags: Promise<Tag[]>;
|
||||
|
||||
/**
|
||||
* The note content at this revision.
|
||||
*/
|
||||
|
@ -77,12 +95,18 @@ export class Revision {
|
|||
content: string,
|
||||
patch: string,
|
||||
note: Note,
|
||||
yjsStateVector?: number[],
|
||||
yjsStateVector: number[] | null,
|
||||
title: string,
|
||||
description: string,
|
||||
tags: Tag[],
|
||||
): Omit<Revision, 'id' | 'createdAt'> {
|
||||
const newRevision = new Revision();
|
||||
newRevision.patch = patch;
|
||||
newRevision.content = content;
|
||||
newRevision.length = content.length;
|
||||
newRevision.title = title;
|
||||
newRevision.description = description;
|
||||
newRevision.tags = Promise.resolve(tags);
|
||||
newRevision.note = Promise.resolve(note);
|
||||
newRevision.edits = Promise.resolve([]);
|
||||
newRevision.yjsStateVector = yjsStateVector ?? null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue