nocobase/packages/plugins/@nocobase/plugin-action-import
ChengLei Shao dd08a1f5c7
Some checks are pending
Build Docker Image / build-and-push (push) Waiting to run
Build Pro Image / build-and-push (push) Waiting to run
E2E / Build (push) Waiting to run
E2E / Core and plugins (push) Blocked by required conditions
E2E / plugin-workflow (push) Blocked by required conditions
E2E / plugin-workflow-approval (push) Blocked by required conditions
E2E / plugin-data-source-main (push) Blocked by required conditions
E2E / Comment on PR (push) Blocked by required conditions
NocoBase Backend Test / sqlite-test (20, false) (push) Waiting to run
NocoBase Backend Test / sqlite-test (20, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, nocobase, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, nocobase, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, public, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (public, 20, public, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, nocobase, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, nocobase, true) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, public, false) (push) Waiting to run
NocoBase Backend Test / postgres-test (user_schema, 20, public, true) (push) Waiting to run
NocoBase Backend Test / mysql-test (20, false) (push) Waiting to run
NocoBase Backend Test / mysql-test (20, true) (push) Waiting to run
NocoBase Backend Test / mariadb-test (20, false) (push) Waiting to run
NocoBase Backend Test / mariadb-test (20, true) (push) Waiting to run
NocoBase FrontEnd Test / frontend-test (18) (push) Waiting to run
Test on Windows / build (push) Waiting to run
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 37719eb28e.

* 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 22:26:27 +08:00
..
src chore: data source api (#4588) 2024-07-19 22:26:27 +08:00
.npmignore chore(versions): 😊 publish v1.0.0-alpha.1 (#4186) 2024-04-29 00:46:21 +08:00
client.d.ts chore(versions): 😊 publish v1.0.0-alpha.1 (#4186) 2024-04-29 00:46:21 +08:00
client.js chore(versions): 😊 publish v1.0.0-alpha.1 (#4186) 2024-04-29 00:46:21 +08:00
LICENSE chore(versions): 😊 publish v1.0.0-alpha.1 (#4186) 2024-04-29 00:46:21 +08:00
package.json chore(versions): 😊 publish v1.2.16-alpha 2024-07-12 09:04:56 +00:00
README.md chore(versions): 😊 publish v1.0.0-alpha.1 (#4186) 2024-04-29 00:46:21 +08:00
README.zh-CN.md chore(versions): 😊 publish v1.0.0-alpha.1 (#4186) 2024-04-29 00:46:21 +08:00
server.d.ts chore(versions): 😊 publish v1.0.0-alpha.1 (#4186) 2024-04-29 00:46:21 +08:00
server.js chore(versions): 😊 publish v1.0.0-alpha.1 (#4186) 2024-04-29 00:46:21 +08:00

import

English | 中文

Excel 数据导入插件。

安装激活

内置插件无需手动安装激活。

导入说明

数字类型字段

支持数字和百分比,N/A- 的文案会被过滤掉

数字1 百分比 数字2 数字3
123 25% N/A -

转 JSON 之后为

{
  "数字1": 123,
  "百分比": 0.25,
  "数字2": null,
  "数字3": null,
}

布尔类型字段

输入文案支持(英文不区分大小写):

  • Yes Y True 1
  • No N False 0
字段1 字段2 字段3 字段4 字段4
Y true 0

转 JSON 之后为

{
  "字段1": false,
  "字段2": true,
  "字段3": true,
  "字段4": true,
  "字段5": false,
}

日期类型字段

DateOnly Local(+08:00) GMT
2023-01-18 22:22:22 2023-01-18 22:22:22 2023-01-18 22:22:22

转 JSON 之后为

{
  "DateOnly": "2023-01-18T00:00:00.000Z",
  "Local(+08:00)": "2023-01-18T14:22:22.000Z",
  "GMT": "2023-01-18T22:22:22.000Z",
}

选择类型字段

选项值和选项标签都可作为导入文案,多个选项之间以以逗号(, )或顿号()区分

如字段 优先级 的可选项包括:

选项值 选项标签
low
medium
high

选项值和选项标签都可作为导入文案

优先级
low

转 JSON 之后为

[
  { "优先级": "high" },
  { "优先级": "low" },
]

中国行政区字段

地区1 地区2
北京市/市辖区 天津市/市辖区

转 JSON 之后为

{
  "地区1": ["11","1101"],
  "地区2": ["12","1201"]
}

附件字段

附件
https://www.nocobase.com/images/logo.png

转 JSON 之后为

{
  "附件": [
    {
      "filename": "logo.png",
      "title": "logo.png",
      "extname": ".png",
      "url": "https://www.nocobase.com/images/logo.png"
    }
  ]
}

关系类型字段

多条数据以逗号(, )或顿号()区分

部门/名称 分类/标题
开发组 分类1、分类2

转 JSON 之后为

{
  "部门": [1], // 1 为部门名称为「开发组」的记录 ID
  "分类": [1,2], // 1,2 为分类标题为「分类1」和「分类2」的记录 ID
}

JSON 类型字段

JSON1
{"key":"value"}

转 JSON 之后为

{
  "JSON": {"key":"value"}
}

地图几何图形类型

Point Line Polygon Circle
1,2 (1,2),(3,4) (1,2),(3,4),(1,2) 1,2,3

转 JSON 之后为

{
  "Point": [1,2],
  "Line": [[1,2], [3,4]],
  "Polygon": [[1,2], [3,4], [1,2]],
  "Circle": [1,2,3]
}

自定义导入格式

通过 db.registerFieldValueParsers() 方法注册自定义的 ValueParser,如:

import { BaseValueParser } from '@nocobase/database';

class PointValueParser extends BaseValueParser {
  async setValue(value) {
    if (Array.isArray(value)) {
      this.value = value;
    } else if (typeof value === 'string') {
      this.value = value.split(',');
    } else {
      this.errors.push('Value invalid');
    }
  }
}

const db = new Database();

// type=point 的字段导入时,将通过 PointValueParser 解析数据
db.registerFieldValueParsers({
  point: PointValueParser,
});

导入示例

Point
1,2

转 JSON 之后为

{
  "Point": [1,2]
}