This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/models/linkShare.ts

56 lines
1.1 KiB
TypeScript
Raw Normal View History

import AbstractModel, { type IAbstract } from './abstractModel'
2022-07-20 22:42:36 +00:00
import UserModel, { type IUser } from './user'
2022-08-13 13:26:57 +00:00
import {RIGHTS, type Right} from '@/constants/rights'
2019-09-09 17:55:43 +00:00
export interface ILinkShare extends IAbstract {
2022-06-23 01:22:21 +00:00
id: number
hash: string
right: Right
2022-07-20 22:42:36 +00:00
sharedBy: IUser
2022-06-23 01:22:21 +00:00
sharingType: number // FIXME: use correct numbers
listId: number
name: string
password: string
created: Date
updated: Date
2022-07-20 22:42:36 +00:00
}
export default class LinkShareModel extends AbstractModel implements ILinkShare {
id!: number
hash!: string
right!: Right
2022-07-20 22:42:36 +00:00
sharedBy: IUser
sharingType!: number // FIXME: use correct numbers
listId!: number
name!: string
password!: string
2022-07-20 22:42:36 +00:00
created: Date
updated: Date
2019-09-09 17:55:43 +00:00
constructor(data) {
// The constructor of AbstractModel handles all the default parsing.
super(data)
2019-09-09 17:55:43 +00:00
this.sharedBy = new UserModel(this.sharedBy)
this.created = new Date(this.created)
this.updated = new Date(this.updated)
}
2019-09-09 17:55:43 +00:00
// Default attributes that define the "empty" state.
defaults() {
return {
id: 0,
hash: '',
2022-06-23 01:14:58 +00:00
right: RIGHTS.READ,
sharedBy: UserModel,
sharingType: 0,
listId: 0,
name: '',
password: '',
2019-09-09 17:55:43 +00:00
created: null,
updated: null,
}
}
2019-09-09 17:55:43 +00:00
}