mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-24 20:14:35 -04:00
Rename Authorship entity to Edit
As we now have a separate Author entity, which holds information about an author (the color), the Authorship name became confusing. Edit seems to be a better name, as the entity saves information about a change in a note. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
2b0fa17d03
commit
62e0530d2b
19 changed files with 67 additions and 73 deletions
|
@ -17,23 +17,23 @@ import { Author } from '../authors/author.entity';
|
|||
import { Revision } from './revision.entity';
|
||||
|
||||
/**
|
||||
* The Authorship represents a change in the content of a note by a particular {@link Author}
|
||||
* The Edit represents a change in the content of a note by a particular {@link Author}
|
||||
*/
|
||||
@Entity()
|
||||
export class Authorship {
|
||||
export class Edit {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Revisions this authorship appears in
|
||||
* Revisions this edit appears in
|
||||
*/
|
||||
@ManyToMany((_) => Revision, (revision) => revision.authorships)
|
||||
@ManyToMany((_) => Revision, (revision) => revision.edits)
|
||||
revisions: Revision[];
|
||||
|
||||
/**
|
||||
* Author that created the change
|
||||
*/
|
||||
@ManyToOne(() => Author, (author) => author.authorships)
|
||||
@ManyToOne(() => Author, (author) => author.edits)
|
||||
author: Author;
|
||||
|
||||
@Column()
|
||||
|
@ -52,10 +52,10 @@ export class Authorship {
|
|||
private constructor() {}
|
||||
|
||||
public static create(author: Author, startPos: number, endPos: number) {
|
||||
const newAuthorship = new Authorship();
|
||||
newAuthorship.author = author;
|
||||
newAuthorship.startPos = startPos;
|
||||
newAuthorship.endPos = endPos;
|
||||
return newAuthorship;
|
||||
const newEdit = new Edit();
|
||||
newEdit.author = author;
|
||||
newEdit.startPos = startPos;
|
||||
newEdit.endPos = endPos;
|
||||
return newEdit;
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ import {
|
|||
} from 'typeorm';
|
||||
import { JoinTable, ManyToMany } from 'typeorm';
|
||||
import { Note } from '../notes/note.entity';
|
||||
import { Authorship } from './authorship.entity';
|
||||
import { Edit } from './edit.entity';
|
||||
|
||||
/**
|
||||
* The state of a note at a particular point in time,
|
||||
|
@ -59,11 +59,11 @@ export class Revision {
|
|||
@ManyToOne((_) => Note, (note) => note.revisions, { onDelete: 'CASCADE' })
|
||||
note: Note;
|
||||
/**
|
||||
* All authorship objects which are used in the revision.
|
||||
* All edit objects which are used in the revision.
|
||||
*/
|
||||
@ManyToMany((_) => Authorship, (authorship) => authorship.revisions)
|
||||
@ManyToMany((_) => Edit, (edit) => edit.revisions)
|
||||
@JoinTable()
|
||||
authorships: Authorship[];
|
||||
edits: Edit[];
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
private constructor() {}
|
||||
|
|
|
@ -9,14 +9,14 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
|||
import { AuthorsModule } from '../authors/authors.module';
|
||||
import { LoggerModule } from '../logger/logger.module';
|
||||
import { NotesModule } from '../notes/notes.module';
|
||||
import { Authorship } from './authorship.entity';
|
||||
import { Edit } from './edit.entity';
|
||||
import { Revision } from './revision.entity';
|
||||
import { RevisionsService } from './revisions.service';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([Revision, Authorship]),
|
||||
TypeOrmModule.forFeature([Revision, Edit]),
|
||||
forwardRef(() => NotesModule),
|
||||
LoggerModule,
|
||||
ConfigModule,
|
||||
|
|
|
@ -17,7 +17,7 @@ import { AuthToken } from '../auth/auth-token.entity';
|
|||
import { Identity } from '../users/identity.entity';
|
||||
import { Session } from '../users/session.entity';
|
||||
import { User } from '../users/user.entity';
|
||||
import { Authorship } from './authorship.entity';
|
||||
import { Edit } from './edit.entity';
|
||||
import { Revision } from './revision.entity';
|
||||
import { RevisionsService } from './revisions.service';
|
||||
import { Tag } from '../notes/tag.entity';
|
||||
|
@ -49,7 +49,7 @@ describe('RevisionsService', () => {
|
|||
}),
|
||||
],
|
||||
})
|
||||
.overrideProvider(getRepositoryToken(Authorship))
|
||||
.overrideProvider(getRepositoryToken(Edit))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(User))
|
||||
.useValue({})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue