2020-10-25 23:42:27 +00:00
|
|
|
import {Model} from './Model';
|
|
|
|
|
|
|
|
export interface IPage {
|
|
|
|
id?: number;
|
|
|
|
UUID: string;
|
|
|
|
Name: string;
|
|
|
|
OrgUserId: string;
|
|
|
|
IsPublic: boolean;
|
|
|
|
IsVisibleInMenu: boolean;
|
|
|
|
ParentId: string;
|
|
|
|
NodeIds: string[];
|
|
|
|
CreatedAt: string;
|
|
|
|
UpdatedAt: string;
|
|
|
|
Active: boolean;
|
|
|
|
CreatedUserId: string;
|
|
|
|
UpdateUserId: string;
|
|
|
|
ChildPageIds: string[];
|
|
|
|
noDelete: boolean;
|
|
|
|
virtual: boolean;
|
2020-10-29 04:48:46 +00:00
|
|
|
needsServerUpdate?: 0 | 1;
|
2020-10-25 23:42:27 +00:00
|
|
|
deleted?: boolean;
|
2020-10-31 03:26:42 +00:00
|
|
|
offlineUpdatedAt?: string;
|
2020-10-25 23:42:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export class Page extends Model<IPage> implements IPage {
|
|
|
|
id?: number;
|
|
|
|
UUID: string;
|
|
|
|
Name: string;
|
|
|
|
OrgUserId: string;
|
|
|
|
IsPublic: boolean;
|
|
|
|
IsVisibleInMenu: boolean;
|
|
|
|
ParentId: string;
|
|
|
|
NodeIds: string[];
|
|
|
|
CreatedAt: string;
|
|
|
|
UpdatedAt: string;
|
|
|
|
Active: boolean;
|
|
|
|
CreatedUserId: string;
|
|
|
|
UpdateUserId: string;
|
|
|
|
ChildPageIds: string[];
|
|
|
|
noDelete: boolean;
|
|
|
|
virtual: boolean;
|
2020-10-29 04:48:46 +00:00
|
|
|
needsServerUpdate?: 0 | 1;
|
2020-10-25 23:42:27 +00:00
|
|
|
deleted?: boolean;
|
2020-10-31 03:26:42 +00:00
|
|
|
offlineUpdatedAt?: string;
|
2020-10-25 23:42:27 +00:00
|
|
|
|
|
|
|
public static getTableName() {
|
|
|
|
return 'pages';
|
|
|
|
}
|
|
|
|
|
|
|
|
public static getSchema() {
|
|
|
|
// tslint:disable-next-line:max-line-length
|
2020-10-31 03:26:42 +00:00
|
|
|
return '++id, UUID, Name, OrgUserId, IsPublic, IsVisibleInMenu, ParentId, NodeIds, CreatedAt, UpdatedAt, Active, CreatedUserId, UpdateUserId, ChildPageIds, noDelete, virtual, needsServerUpdate, deleted, offlineUpdatedAt';
|
2020-10-25 23:42:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
UUID: string,
|
|
|
|
Name: string,
|
|
|
|
OrgUserId: string,
|
|
|
|
IsPublic: boolean,
|
|
|
|
IsVisibleInMenu: boolean,
|
|
|
|
ParentId: string,
|
|
|
|
NodeIds: string[],
|
|
|
|
CreatedAt: string,
|
|
|
|
UpdatedAt: string,
|
|
|
|
Active: boolean,
|
|
|
|
CreatedUserId: string,
|
|
|
|
UpdateUserId: string,
|
|
|
|
ChildPageIds: string[],
|
|
|
|
noDelete: boolean,
|
|
|
|
virtual: boolean,
|
2020-10-29 04:48:46 +00:00
|
|
|
needsServerUpdate?: 0 | 1,
|
2020-10-25 23:42:27 +00:00
|
|
|
deleted?: boolean,
|
2020-10-31 03:26:42 +00:00
|
|
|
offlineUpdatedAt?: string,
|
2020-10-25 23:42:27 +00:00
|
|
|
id?: number
|
|
|
|
) {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.UUID = UUID;
|
|
|
|
this.Name = Name;
|
|
|
|
this.OrgUserId = OrgUserId;
|
|
|
|
this.IsPublic = IsPublic;
|
|
|
|
this.IsVisibleInMenu = IsVisibleInMenu;
|
|
|
|
this.ParentId = ParentId;
|
|
|
|
this.NodeIds = NodeIds;
|
|
|
|
this.CreatedAt = CreatedAt;
|
|
|
|
this.UpdatedAt = UpdatedAt;
|
|
|
|
this.Active = Active;
|
|
|
|
this.CreatedUserId = CreatedUserId;
|
|
|
|
this.UpdateUserId = UpdateUserId;
|
|
|
|
this.ChildPageIds = ChildPageIds;
|
|
|
|
this.noDelete = noDelete;
|
|
|
|
this.virtual = virtual;
|
|
|
|
|
|
|
|
if ( typeof needsServerUpdate !== 'undefined' ) {
|
|
|
|
this.needsServerUpdate = needsServerUpdate;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( typeof deleted !== 'undefined' ) {
|
|
|
|
this.deleted = deleted;
|
|
|
|
}
|
|
|
|
|
2020-10-31 03:26:42 +00:00
|
|
|
if ( typeof offlineUpdatedAt !== 'undefined' ) {
|
|
|
|
this.offlineUpdatedAt = offlineUpdatedAt;
|
|
|
|
}
|
|
|
|
|
2020-10-25 23:42:27 +00:00
|
|
|
if ( id ) {
|
|
|
|
this.id = id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public fillFromRecord(record: any) {
|
|
|
|
this.UUID = record.UUID;
|
|
|
|
this.Name = record.Name;
|
|
|
|
this.OrgUserId = record.OrgUserId;
|
|
|
|
this.IsPublic = record.IsPublic;
|
|
|
|
this.IsVisibleInMenu = record.IsVisibleInMenu;
|
|
|
|
this.ParentId = record.ParentId;
|
|
|
|
this.NodeIds = record.NodeIds;
|
|
|
|
this.CreatedAt = String(record.CreatedAt);
|
|
|
|
this.UpdatedAt = String(record.UpdatedAt);
|
|
|
|
this.Active = record.Active;
|
|
|
|
this.CreatedUserId = record.CreatedUserId;
|
|
|
|
this.UpdateUserId = record.UpdateUserId;
|
|
|
|
this.ChildPageIds = record.ChildPageIds;
|
|
|
|
this.noDelete = record.noDelete;
|
|
|
|
this.virtual = record.virtual;
|
|
|
|
}
|
|
|
|
|
|
|
|
public getSaveRecord(): any {
|
|
|
|
return {
|
|
|
|
...(this.id ? { id: this.id } : {}),
|
|
|
|
UUID: this.UUID,
|
|
|
|
Name: this.Name,
|
|
|
|
OrgUserId: this.OrgUserId,
|
|
|
|
IsPublic: this.IsPublic,
|
|
|
|
IsVisibleInMenu: this.IsVisibleInMenu,
|
|
|
|
ParentId: this.ParentId,
|
|
|
|
NodeIds: this.NodeIds,
|
|
|
|
CreatedAt: new Date(this.CreatedAt),
|
|
|
|
UpdatedAt: new Date(this.UpdatedAt),
|
|
|
|
Active: this.Active,
|
|
|
|
CreatedUserId: this.CreatedUserId,
|
|
|
|
UpdateUserId: this.UpdateUserId,
|
|
|
|
ChildPageIds: this.ChildPageIds,
|
|
|
|
noDelete: this.noDelete,
|
|
|
|
virtual: this.virtual,
|
|
|
|
...(typeof this.needsServerUpdate === 'undefined' ? {} : { needsServerUpdate: this.needsServerUpdate }),
|
|
|
|
...(typeof this.deleted === 'undefined' ? {} : { deleted: this.deleted }),
|
2020-10-31 03:26:42 +00:00
|
|
|
...(typeof this.offlineUpdatedAt === 'undefined' ? {} : { offlineUpdatedAt: this.offlineUpdatedAt }),
|
2020-10-25 23:42:27 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public getDatabase(): Dexie.Table<IPage, number> {
|
|
|
|
return this.staticClass().dbService.table('pages') as Dexie.Table<IPage, number>;
|
|
|
|
}
|
|
|
|
}
|