|
|
|
@ -571,6 +571,9 @@ export default class View implements ViewType {
|
|
|
|
|
case ViewTypes.KANBAN: |
|
|
|
|
await KanbanViewColumn.insert(modifiedInsertObj, ncMeta); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.CALENDAR: |
|
|
|
|
await CalendarViewColumn.insert(modifiedInsertObj, ncMeta); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -1503,191 +1506,6 @@ export default class View implements ViewType {
|
|
|
|
|
await NocoCache.del(deleteKeys); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static extractViewColumnsTableName(view: View) { |
|
|
|
|
let table; |
|
|
|
|
switch (view.type) { |
|
|
|
|
case ViewTypes.GRID: |
|
|
|
|
table = MetaTable.GRID_VIEW_COLUMNS; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.GALLERY: |
|
|
|
|
table = MetaTable.GALLERY_VIEW_COLUMNS; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.KANBAN: |
|
|
|
|
table = MetaTable.KANBAN_VIEW_COLUMNS; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.FORM: |
|
|
|
|
table = MetaTable.FORM_VIEW_COLUMNS; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.MAP: |
|
|
|
|
table = MetaTable.MAP_VIEW_COLUMNS; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.CALENDAR: |
|
|
|
|
table = MetaTable.CALENDAR_VIEW_COLUMNS; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return table; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static extractViewTableName(view: View) { |
|
|
|
|
let table; |
|
|
|
|
switch (view.type) { |
|
|
|
|
case ViewTypes.GRID: |
|
|
|
|
table = MetaTable.GRID_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.GALLERY: |
|
|
|
|
table = MetaTable.GALLERY_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.KANBAN: |
|
|
|
|
table = MetaTable.KANBAN_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.FORM: |
|
|
|
|
table = MetaTable.FORM_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.MAP: |
|
|
|
|
table = MetaTable.MAP_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.CALENDAR: |
|
|
|
|
table = MetaTable.CALENDAR_VIEW; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return table; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static extractViewColumnsTableNameScope(view: View) { |
|
|
|
|
let scope; |
|
|
|
|
switch (view.type) { |
|
|
|
|
case ViewTypes.GRID: |
|
|
|
|
scope = CacheScope.GRID_VIEW_COLUMN; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.GALLERY: |
|
|
|
|
scope = CacheScope.GALLERY_VIEW_COLUMN; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.MAP: |
|
|
|
|
scope = CacheScope.MAP_VIEW_COLUMN; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.KANBAN: |
|
|
|
|
scope = CacheScope.KANBAN_VIEW_COLUMN; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.FORM: |
|
|
|
|
scope = CacheScope.FORM_VIEW_COLUMN; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.CALENDAR: |
|
|
|
|
scope = CacheScope.CALENDAR_VIEW_COLUMN; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return scope; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static extractViewTableNameScope(view: View) { |
|
|
|
|
let scope; |
|
|
|
|
switch (view.type) { |
|
|
|
|
case ViewTypes.GRID: |
|
|
|
|
scope = CacheScope.GRID_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.GALLERY: |
|
|
|
|
scope = CacheScope.GALLERY_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.MAP: |
|
|
|
|
scope = CacheScope.MAP_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.KANBAN: |
|
|
|
|
scope = CacheScope.KANBAN_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.FORM: |
|
|
|
|
scope = CacheScope.FORM_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.CALENDAR: |
|
|
|
|
scope = CacheScope.CALENDAR_VIEW; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return scope; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getModel(ncMeta = Noco.ncMeta): Promise<Model> { |
|
|
|
|
return (this.model = await Model.getByIdOrName( |
|
|
|
|
{ id: this.fk_model_id }, |
|
|
|
|
ncMeta, |
|
|
|
|
)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getModelWithInfo(ncMeta = Noco.ncMeta): Promise<Model> { |
|
|
|
|
return (this.model = await Model.getWithInfo( |
|
|
|
|
{ id: this.fk_model_id }, |
|
|
|
|
ncMeta, |
|
|
|
|
)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getView<T>(): Promise<T> { |
|
|
|
|
switch (this.type) { |
|
|
|
|
case ViewTypes.GRID: |
|
|
|
|
this.view = await GridView.get(this.id); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.KANBAN: |
|
|
|
|
this.view = await KanbanView.get(this.id); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.GALLERY: |
|
|
|
|
this.view = await GalleryView.get(this.id); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.MAP: |
|
|
|
|
this.view = await MapView.get(this.id); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.FORM: |
|
|
|
|
this.view = await FormView.get(this.id); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.CALENDAR: |
|
|
|
|
this.view = await CalendarView.get(this.id); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return <T>this.view; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getViewWithInfo( |
|
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
|
): Promise<FormView | GridView | KanbanView | GalleryView> { |
|
|
|
|
switch (this.type) { |
|
|
|
|
case ViewTypes.GRID: |
|
|
|
|
this.view = await GridView.getWithInfo(this.id, ncMeta); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.KANBAN: |
|
|
|
|
this.view = await KanbanView.get(this.id, ncMeta); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.GALLERY: |
|
|
|
|
this.view = await GalleryView.get(this.id, ncMeta); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.MAP: |
|
|
|
|
this.view = await MapView.get(this.id, ncMeta); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.FORM: |
|
|
|
|
this.view = await FormView.get(this.id, ncMeta); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.CALENDAR: |
|
|
|
|
this.view = await CalendarView.get(this.id, ncMeta); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return this.view; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async getFilters(ncMeta = Noco.ncMeta) { |
|
|
|
|
return (this.filter = (await Filter.getFilterObject( |
|
|
|
|
{ |
|
|
|
|
viewId: this.id, |
|
|
|
|
}, |
|
|
|
|
ncMeta, |
|
|
|
|
)) as any); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async getSorts(ncMeta = Noco.ncMeta) { |
|
|
|
|
return (this.sorts = await Sort.list({ viewId: this.id }, ncMeta)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getColumns(ncMeta = Noco.ncMeta) { |
|
|
|
|
return (this.columns = await View.getColumns(this.id, ncMeta)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async delete(ncMeta = Noco.ncMeta) { |
|
|
|
|
await View.delete(this.id, ncMeta); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static async bulkColumnInsertToViews( |
|
|
|
|
{ |
|
|
|
|
columns, |
|
|
|
@ -1705,6 +1523,7 @@ export default class View implements ViewType {
|
|
|
|
|
| FormViewColumn |
|
|
|
|
| KanbanViewColumn |
|
|
|
|
| MapViewColumn |
|
|
|
|
| CalendarViewColumn |
|
|
|
|
)[]; |
|
|
|
|
}, |
|
|
|
|
view: View, |
|
|
|
@ -1811,6 +1630,16 @@ export default class View implements ViewType {
|
|
|
|
|
} |
|
|
|
|
} else if (view.type === ViewTypes.FORM && isSystemColumn(column)) { |
|
|
|
|
show = false; |
|
|
|
|
} else if (view.type === ViewTypes.CALENDAR && !copyFromView) { |
|
|
|
|
const calendarRange = await CalendarRange.read(view.id, ncMeta); |
|
|
|
|
if (!calendarRange) break; |
|
|
|
|
const calendarRangeColumns = calendarRange.ranges |
|
|
|
|
.map((range) => [range.fk_from_column_id, range.fk_to_column_id]) |
|
|
|
|
.flat(); |
|
|
|
|
|
|
|
|
|
if (calendarRangeColumns.includes(column.id)) { |
|
|
|
|
show = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
insertObjs.push({ |
|
|
|
@ -1865,14 +1694,24 @@ export default class View implements ViewType {
|
|
|
|
|
insertObjs, |
|
|
|
|
); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.CALENDAR: |
|
|
|
|
await ncMeta.bulkMetaInsert( |
|
|
|
|
null, |
|
|
|
|
null, |
|
|
|
|
MetaTable.CALENDAR_VIEW_COLUMNS, |
|
|
|
|
insertObjs, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static async insertMetaOnly( |
|
|
|
|
view: Partial<View> & |
|
|
|
|
Partial<FormView | GridView | GalleryView | KanbanView | MapView> & { |
|
|
|
|
Partial< |
|
|
|
|
FormView | GridView | GalleryView | KanbanView | MapView | CalendarView |
|
|
|
|
> & { |
|
|
|
|
copy_from_id?: string; |
|
|
|
|
fk_grp_col_id?: string; |
|
|
|
|
calendar_range?: Partial<CalendarRange>[]; |
|
|
|
|
}, |
|
|
|
|
model: { |
|
|
|
|
getColumns: () => Promise<Column[]>; |
|
|
|
@ -1978,8 +1817,28 @@ export default class View implements ViewType {
|
|
|
|
|
}, |
|
|
|
|
ncMeta, |
|
|
|
|
); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.CALENDAR: { |
|
|
|
|
const obj = extractProps(view, ['calendar_range']); |
|
|
|
|
if (!obj.calendar_range) break; |
|
|
|
|
const calendarRange = obj.calendar_range as Partial<CalendarRange>[]; |
|
|
|
|
calendarRange.forEach((range) => { |
|
|
|
|
range.fk_view_id = view_id; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
await CalendarRange.bulkInsert(calendarRange, ncMeta); |
|
|
|
|
await CalendarView.insert( |
|
|
|
|
{ |
|
|
|
|
...(copyFromView?.view || {}), |
|
|
|
|
...view, |
|
|
|
|
fk_view_id: view_id, |
|
|
|
|
}, |
|
|
|
|
ncMeta, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// copy from view
|
|
|
|
|
if (copyFromView) { |
|
|
|
@ -2065,4 +1924,189 @@ export default class View implements ViewType {
|
|
|
|
|
|
|
|
|
|
return insertedView; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static extractViewColumnsTableName(view: View) { |
|
|
|
|
let table; |
|
|
|
|
switch (view.type) { |
|
|
|
|
case ViewTypes.GRID: |
|
|
|
|
table = MetaTable.GRID_VIEW_COLUMNS; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.GALLERY: |
|
|
|
|
table = MetaTable.GALLERY_VIEW_COLUMNS; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.KANBAN: |
|
|
|
|
table = MetaTable.KANBAN_VIEW_COLUMNS; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.FORM: |
|
|
|
|
table = MetaTable.FORM_VIEW_COLUMNS; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.MAP: |
|
|
|
|
table = MetaTable.MAP_VIEW_COLUMNS; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.CALENDAR: |
|
|
|
|
table = MetaTable.CALENDAR_VIEW_COLUMNS; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return table; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static extractViewTableName(view: View) { |
|
|
|
|
let table; |
|
|
|
|
switch (view.type) { |
|
|
|
|
case ViewTypes.GRID: |
|
|
|
|
table = MetaTable.GRID_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.GALLERY: |
|
|
|
|
table = MetaTable.GALLERY_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.KANBAN: |
|
|
|
|
table = MetaTable.KANBAN_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.FORM: |
|
|
|
|
table = MetaTable.FORM_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.MAP: |
|
|
|
|
table = MetaTable.MAP_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.CALENDAR: |
|
|
|
|
table = MetaTable.CALENDAR_VIEW; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return table; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static extractViewColumnsTableNameScope(view: View) { |
|
|
|
|
let scope; |
|
|
|
|
switch (view.type) { |
|
|
|
|
case ViewTypes.GRID: |
|
|
|
|
scope = CacheScope.GRID_VIEW_COLUMN; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.GALLERY: |
|
|
|
|
scope = CacheScope.GALLERY_VIEW_COLUMN; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.MAP: |
|
|
|
|
scope = CacheScope.MAP_VIEW_COLUMN; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.KANBAN: |
|
|
|
|
scope = CacheScope.KANBAN_VIEW_COLUMN; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.FORM: |
|
|
|
|
scope = CacheScope.FORM_VIEW_COLUMN; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.CALENDAR: |
|
|
|
|
scope = CacheScope.CALENDAR_VIEW_COLUMN; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return scope; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static extractViewTableNameScope(view: View) { |
|
|
|
|
let scope; |
|
|
|
|
switch (view.type) { |
|
|
|
|
case ViewTypes.GRID: |
|
|
|
|
scope = CacheScope.GRID_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.GALLERY: |
|
|
|
|
scope = CacheScope.GALLERY_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.MAP: |
|
|
|
|
scope = CacheScope.MAP_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.KANBAN: |
|
|
|
|
scope = CacheScope.KANBAN_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.FORM: |
|
|
|
|
scope = CacheScope.FORM_VIEW; |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.CALENDAR: |
|
|
|
|
scope = CacheScope.CALENDAR_VIEW; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return scope; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getModel(ncMeta = Noco.ncMeta): Promise<Model> { |
|
|
|
|
return (this.model = await Model.getByIdOrName( |
|
|
|
|
{ id: this.fk_model_id }, |
|
|
|
|
ncMeta, |
|
|
|
|
)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getModelWithInfo(ncMeta = Noco.ncMeta): Promise<Model> { |
|
|
|
|
return (this.model = await Model.getWithInfo( |
|
|
|
|
{ id: this.fk_model_id }, |
|
|
|
|
ncMeta, |
|
|
|
|
)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getView<T>(): Promise<T> { |
|
|
|
|
switch (this.type) { |
|
|
|
|
case ViewTypes.GRID: |
|
|
|
|
this.view = await GridView.get(this.id); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.KANBAN: |
|
|
|
|
this.view = await KanbanView.get(this.id); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.GALLERY: |
|
|
|
|
this.view = await GalleryView.get(this.id); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.MAP: |
|
|
|
|
this.view = await MapView.get(this.id); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.FORM: |
|
|
|
|
this.view = await FormView.get(this.id); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.CALENDAR: |
|
|
|
|
this.view = await CalendarView.get(this.id); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return <T>this.view; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getViewWithInfo( |
|
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
|
): Promise<FormView | GridView | KanbanView | GalleryView> { |
|
|
|
|
switch (this.type) { |
|
|
|
|
case ViewTypes.GRID: |
|
|
|
|
this.view = await GridView.getWithInfo(this.id, ncMeta); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.KANBAN: |
|
|
|
|
this.view = await KanbanView.get(this.id, ncMeta); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.GALLERY: |
|
|
|
|
this.view = await GalleryView.get(this.id, ncMeta); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.MAP: |
|
|
|
|
this.view = await MapView.get(this.id, ncMeta); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.FORM: |
|
|
|
|
this.view = await FormView.get(this.id, ncMeta); |
|
|
|
|
break; |
|
|
|
|
case ViewTypes.CALENDAR: |
|
|
|
|
this.view = await CalendarView.get(this.id, ncMeta); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return this.view; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async getFilters(ncMeta = Noco.ncMeta) { |
|
|
|
|
return (this.filter = (await Filter.getFilterObject( |
|
|
|
|
{ |
|
|
|
|
viewId: this.id, |
|
|
|
|
}, |
|
|
|
|
ncMeta, |
|
|
|
|
)) as any); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async getSorts(ncMeta = Noco.ncMeta) { |
|
|
|
|
return (this.sorts = await Sort.list({ viewId: this.id }, ncMeta)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getColumns(ncMeta = Noco.ncMeta) { |
|
|
|
|
return (this.columns = await View.getColumns(this.id, ncMeta)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async delete(ncMeta = Noco.ncMeta) { |
|
|
|
|
await View.delete(this.id, ncMeta); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|