nocobase/packages/core/database/src/view-collection.ts

38 lines
983 B
TypeScript
Raw Normal View History

/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
feat: database view collection (#1587) * test: create view collection * feat: view collection class * feat: list view * chore: skip sync view collection * test: should create view collection in difference schema * test: create view collection in collection manager * feat: create view collection by user sql * test: view resourcer * feat: view collection * feat: view collection cannot be added, deleted, or modified * feat: view collection cannot be added, deleted, or modified * feat: view collection cannot be added, deleted, or modified * feat: view collection cannot be added, deleted, or modified * refactor: connect to database view * refactor: sync from database * chore: rename list view sql * chore: list view fields api * chore: create collection without viewName * feat: bring out fields when selecting a view * chore: bring out fields when selecting a view * feat: view field inference class * chore: bring out fields when selecting a view * chore: sync form database view * chore: sync form database view * refactor: view collection local * feat: view get api * feat: database type infer * feat: integer map * chore: remove from in view list * chore: build error * chore: uniq collection * fix: typo * chore: replace collection list source field * fix: destroy view collection * chore: timestamp field map * refactor: interface avalableTypes * refactor: interface avalableTypes * chore: list fields test * refactor: interface avalableTypes * chore: uiSchema response in field source * fix: view query * chore: collection snippet * refactor: view collection support preview * fix: handle field source * fix: typo * fix: configure fileds title * fix: configure fileds title * fix: configure fileds title * fix: sync from databse interface * fix: sync from databse interface * feat: set fields api * fix: sync from databse fix * feat: possibleTypes * chore: fields get * fix: sync from databse * fix: list view test * fix: view test in difference schema * chore: comment * feat: when there is only one source collection, the view is a subset of a Collection * feat: view collection add field * fix: inherit query with schema * fix: test * fix: ci test * fix: test with schema * chore: set pg default search path * chore: mysql test * fix: test with schema * chore: test * chore: action test * chore: view column usage return type * feat: mysql field inference * fix: tableName * chore: node sql parser * fix: sql build * fix: database build * fix: mysql test * feat: view collection uiSchema title * fix: incorrect field source display when switching views * refactor: view collection not allow modify * fix: view collection is allow add, delete, and modify * fix: mysql test * fix: sqlite test * fix: sqlite test * fix: sqlite test * fix: sqlite test * chore: add id field as default target key * style: style improve * feat: load source field options * style: style improve * chore: disable remove column in view collection * chore: support creating view collection with different schemas with the same name * chore: support creating view collection with different schemas with the same name * fix: query view in difference schema * refactor: view collection viewname * fix: query view collection in difference schema * fix: field load * chore: field options * fix: mysql test * fix: uiSchema component error when using a view field in a block * fix: sqlite test * chore: test * fix: dump user views * fix: view collection can be updated and edited in table block * chore: sync from database display last field configuration * chore: loadCollections * chore: sync from database display last field configuration * fix: field options merge issues * style: preview table * fix: view collection is allow using in kanban blocks * refactor: code improve * fix: view collection can be updated an edited in calendar block * chore: disable infer field without interface * feat: preview only shows source or interface fields * fix: test * refactor: locale * feat: sql parser * chore: remove node-sql-parser * fix: yarn.lock * test: view repository * fix: view repository test * chore: console.log * chore: console.log * fix: mysql without schema * fix: mysql without schema * chore: preview with field schema * chore: tableActionInitializers * style: preview style improve * chore: parameter is filter when there is no filterByTk * fix: preview pagination * fix: preview pagination * style: preview table style improve * fix: sync from database loading * chore: preview performance optimization * chore: preview performance optimization * feat: limit & offset * chore: preview performance optimization * test: field with dot column * fix: datetime interface display * fix: missing boolean type * fix: sync * fix: sync from database * style: style improve * style: style improve * style: style improve * chore: preview table * chore: preview table * chore: preview table * fix: styling --------- Co-authored-by: katherinehhh <katherine_15995@163.com> Co-authored-by: chenos <chenlinxh@gmail.com>
2023-04-01 13:56:01 +00:00
import { Collection, CollectionContext, CollectionOptions } from './collection';
export class ViewCollection extends Collection {
constructor(options: CollectionOptions, context: CollectionContext) {
options.autoGenId = false;
options.timestamps = false;
super(options, context);
}
isView() {
return true;
}
chore: data source api (#4588) * refactor: support api datasource * refactor: support api datasource * refactor: support api datasource * feat: url support preview (#4559) * feat: url support preview * feat: add settings for Input.Preview * refactor: refactor CollectionField.tsx to use dynamic component * Revert "refactor: refactor CollectionField.tsx to use dynamic component" This reverts commit 37719eb28e5866762459da3b269288340a21b661. * test: add e2e test * refactor(e2e): extract template --------- Co-authored-by: Zeke Zhang <958414905@qq.com> * fix(map): amap reset (#4574) * chore: volta node version * chore: data source api * refactor: support api datasource * chore: data source api * chore: data source api * chore: field options * refactor: support api data source * refactor: support api data source * refactor: support api data source * refactor: support api data source * refactor: support api data source * refactor: support api data source * refactor: support api data source * fix: load data source fields * refactor: support api data source * feat(data-vi): support for using url params and current role variables (#4586) * feat(data-vi): support for using url params and current role variable * fix: bug * fix(variable): should remove through collection field (#4590) * fix: style issues for gridCard in mobile client (#4593) * fix: style issiues for gridCard in mobile client * fix: bug * fix: bug * fix: bug * fix: style issues for gridCard in mobile client (#4599) * fix: style issiues for gridCard in mobile client * fix: bug * fix: bug * fix: bug * fix: style improve * chore: update lerna * chore(versions): 😊 publish v1.0.1-alpha.1 * chore: update changelog * chore: fix typo (#4589) * feat(plugin-workflow-smtp-mailer): add new plugin for sending email in workflow (#4584) * feat(plugin-workflow-smtp-mailer): add new plugin for sending email in workflow * refactor(plugin-workflow-mailer): change plugin name and locales * fix(plugin-workflow-mailer): fix parameters * fix(preset): add new plugin to preset * fix(plugin-workflow-mailer): fix locale namespace * fix: iframe block loses height when set to default (#4602) * fix: iframe block loses height when set to default * refactor: local improve * feat(client): allow JSON5 value in Form Input of type JSONTextArea (#4600) * feat(client): allow json5 value in form-item type json component * test: fix tests * chore: set json5 default as false * chore: add demo --------- Co-authored-by: xilesun <2013xile@gmail.com> * fix: remove grid wrap (#4612) * refactor(plugin-workflow): change variable getter from collection fields (#4567) * refactor(plugin-workflow): change variable getter from collection fields * fix(plugin-workflow): fix import * chore(plugin-workflow-action-trigger): remove unused import * fix(plugin-workflow): fix collection field in workflow variable * refactor(plugin-workflow-manual): avoid tslint error * fix(client): fix text wrap in variable input (#4605) * fix(client): fix text wrap in variable input * fix(client): revert css * feat(tree-block): support filtering child nodes (#4603) * feat(tree-block): support filtering child nodes * test: add list test * test: remove only * fix: use isValidFilter * fix(export): export button remaining in loading state after cancel (#4615) * chore: rebase * chore: collection option * fix: update data source fields * chore: console.log * refactor: support api data source * fix: data source test * fix: sync field in data source * chore: unavailableActions in collection option * chore: unavailableActions in data source collections * chore: file collection unavailableActions * fix: test * chore: unavailableActions in actionInitializers * fix: bug * fix: destroy action * chore: unavailableActions in plugin actionInitializers * fix: view * chore: unavailableActions in actionInitializers * fix: missing removeCollection * chore: test name * fix: bug * fix: bug * chore: test * refactor: availableTypes * refactor: availableTypes * chore: datasource options * refactor: get current data source * refactor: code improve * fix: update collection with fields * refactor: code improve * refactor: code improve * refactor: code improve * refactor: code improve * chore: datasource logger * chore: export Schema * refactor: rawTextArea * refactor: loadFilterTargetKeys in external data source * chore: unavailableFunctions * refactor: support unAvailableFunctions * refactor: support unAvailableFunctions * refactor: support unAvailableFunctions * refactor: support unAvailableFunctions * refactor: support unAvailableFunctions * revert: unavailableFunctions * refactor: code improve * fix: test * chore: operation * chore: operation * fix: input support json field * refactor: blockInitializers support unavailableActions * chore: availableActions * chore: availableActions * refactor: support availableActions * refactor: support availableActions * chore: magic model test case * fix: unixTimestamp support integer * fix: disassociate * fix: input readPretty * fix: resolve error when opening modal via URL * style: input readPretty style improve * chore: support simple pagination * chore: skip test * refactor: details support pagination * refactor: details support pagination * chore: useActionAvailable * fix: bug * test: fix test * fix: detailsBlockInitializer useActionAvailable * chore: fix unit test * refactor: pagination * refactor: pagination * test: fix test --------- Co-authored-by: katherinehhh <katherine_15995@163.com> Co-authored-by: chenos <chenlinxh@gmail.com> Co-authored-by: Zeke Zhang <958414905@qq.com> Co-authored-by: YANG QIA <2013xile@gmail.com> Co-authored-by: Katherine <shunai.tang@hand-china.com> Co-authored-by: GitHub Actions Bot <actions@github.com> Co-authored-by: Junyi <mytharcher@users.noreply.github.com> Co-authored-by: David Fecke <david.fecke@eyecook.net>
2024-07-19 14:26:27 +00:00
unavailableActions(): Array<string> {
if (this.options.writableView) {
return [];
}
return ['create', 'update', 'destroy'];
}
feat: database view collection (#1587) * test: create view collection * feat: view collection class * feat: list view * chore: skip sync view collection * test: should create view collection in difference schema * test: create view collection in collection manager * feat: create view collection by user sql * test: view resourcer * feat: view collection * feat: view collection cannot be added, deleted, or modified * feat: view collection cannot be added, deleted, or modified * feat: view collection cannot be added, deleted, or modified * feat: view collection cannot be added, deleted, or modified * refactor: connect to database view * refactor: sync from database * chore: rename list view sql * chore: list view fields api * chore: create collection without viewName * feat: bring out fields when selecting a view * chore: bring out fields when selecting a view * feat: view field inference class * chore: bring out fields when selecting a view * chore: sync form database view * chore: sync form database view * refactor: view collection local * feat: view get api * feat: database type infer * feat: integer map * chore: remove from in view list * chore: build error * chore: uniq collection * fix: typo * chore: replace collection list source field * fix: destroy view collection * chore: timestamp field map * refactor: interface avalableTypes * refactor: interface avalableTypes * chore: list fields test * refactor: interface avalableTypes * chore: uiSchema response in field source * fix: view query * chore: collection snippet * refactor: view collection support preview * fix: handle field source * fix: typo * fix: configure fileds title * fix: configure fileds title * fix: configure fileds title * fix: sync from databse interface * fix: sync from databse interface * feat: set fields api * fix: sync from databse fix * feat: possibleTypes * chore: fields get * fix: sync from databse * fix: list view test * fix: view test in difference schema * chore: comment * feat: when there is only one source collection, the view is a subset of a Collection * feat: view collection add field * fix: inherit query with schema * fix: test * fix: ci test * fix: test with schema * chore: set pg default search path * chore: mysql test * fix: test with schema * chore: test * chore: action test * chore: view column usage return type * feat: mysql field inference * fix: tableName * chore: node sql parser * fix: sql build * fix: database build * fix: mysql test * feat: view collection uiSchema title * fix: incorrect field source display when switching views * refactor: view collection not allow modify * fix: view collection is allow add, delete, and modify * fix: mysql test * fix: sqlite test * fix: sqlite test * fix: sqlite test * fix: sqlite test * chore: add id field as default target key * style: style improve * feat: load source field options * style: style improve * chore: disable remove column in view collection * chore: support creating view collection with different schemas with the same name * chore: support creating view collection with different schemas with the same name * fix: query view in difference schema * refactor: view collection viewname * fix: query view collection in difference schema * fix: field load * chore: field options * fix: mysql test * fix: uiSchema component error when using a view field in a block * fix: sqlite test * chore: test * fix: dump user views * fix: view collection can be updated and edited in table block * chore: sync from database display last field configuration * chore: loadCollections * chore: sync from database display last field configuration * fix: field options merge issues * style: preview table * fix: view collection is allow using in kanban blocks * refactor: code improve * fix: view collection can be updated an edited in calendar block * chore: disable infer field without interface * feat: preview only shows source or interface fields * fix: test * refactor: locale * feat: sql parser * chore: remove node-sql-parser * fix: yarn.lock * test: view repository * fix: view repository test * chore: console.log * chore: console.log * fix: mysql without schema * fix: mysql without schema * chore: preview with field schema * chore: tableActionInitializers * style: preview style improve * chore: parameter is filter when there is no filterByTk * fix: preview pagination * fix: preview pagination * style: preview table style improve * fix: sync from database loading * chore: preview performance optimization * chore: preview performance optimization * feat: limit & offset * chore: preview performance optimization * test: field with dot column * fix: datetime interface display * fix: missing boolean type * fix: sync * fix: sync from database * style: style improve * style: style improve * style: style improve * chore: preview table * chore: preview table * chore: preview table * fix: styling --------- Co-authored-by: katherinehhh <katherine_15995@163.com> Co-authored-by: chenos <chenlinxh@gmail.com>
2023-04-01 13:56:01 +00:00
protected sequelizeModelOptions(): any {
const modelOptions = super.sequelizeModelOptions();
modelOptions.tableName = this.options.viewName || this.options.name;
return modelOptions;
}
}