Commit Graph

4 Commits (0462a4808c83e39d88eca837ada86e96fb6eae85)

Author SHA1 Message Date
Takagi 9e33a81e2d
refactor: refactor the repeater component using the schema approach (#4702)
#### What type of PR is this?

/kind improvement

#### What this PR does / why we need it:

对 Formkit Repeater 组件使用 schema 的方式进行重构,重构后的 Repeater 组件将支持条件判断,按照下述方式定义即可。

```
const formSchema = [
  {
    $formkit: "repeater",
    name: "testing",
    min: 1,
    max: 2,
    addLabel: "添加",
    children: [
      {
        $formkit: "select",
        name: "things",
        id: "things",
        label: "Things",
        placeholder: "Select",
        options: ["Something", "Else"],
      },
      {
        $formkit: "number",
        if: "$value.things === Something",
        name: "show_1",
        id: "show_something_1",
        label: "Show something",
      },
      {
        $formkit: "number",
        if: "$value.things === Something",
        name: "show_2",
        id: "show_something_2",
        label: "Also show something",
      },
    ],
  },
];
```

同时额外增加了对 `addLabel`、`addButton`、`upControl`、`downControl`、`insertControl`、`removeControl`  属性的支持。

#### How to test it?

- 测试原有使用 `Repeater` 组件可否正常使用。
- 对 `Repeater` 条件判断功能进行测试。
- 查看保存的数据格式是否正确

#### Which issue(s) this PR fixes:

Fixes #4603 

#### Does this PR introduce a user-facing change?
```release-note
重构 Repeater 组件,使其支持条件判断
```
2023-10-12 08:08:33 +00:00
Ryan Wang 6dd98d2c0c
feat: add min and max props for repeater input (#3965)
#### What type of PR is this?

/area console
/kind feature
/milestone 2.6.x

#### What this PR does / why we need it:

Console 端的 FormKit Repeater 输入框支持 min 和 max 参数用于限制项目数量。

<img width="630" alt="image" src="https://github.com/halo-dev/halo/assets/21301288/541da770-0439-4731-a796-a58277c33e05">

#### Which issue(s) this PR fixes:

Fixes #3449 

#### Special notes for your reviewer:

定义方式:

```yaml
- $formkit: repeater
  name: test_repeater
  label: 测试 Repeater
  min: 2
  max: 3
  children:
    - $formkit: text
      name: test_text
      label: 测试 Text
    - $formkit: select
      name: test_select
      label: 测试 Select
      options:
        - value: prose-gray
          label: prose-gray
        - value: prose-slate
          label: prose-slate
        - value: prose-zinc
          label: prose-zinc
        - value: prose-neutral
          label: prose-neutral
        - value: prose-stone
          label: prose-stone
```

#### Does this PR introduce a user-facing change?

```release-note
Console 端的 FormKit Repeater 输入框支持 min 和 max 参数用于限制项目数量。
```
2023-05-25 14:38:19 +00:00
Ryan Wang d441e4731e
feat: add accepts and min,max props for attachment selector modal component (#3827)
#### What type of PR is this?

/kind feature
/area console
/milestone 2.5.x

#### What this PR does / why we need it:

附件选择组件(AttachmentSelectorModal)支持 accepts、min、max 参数用来限定文件格式和数量。同时也为 FormKit 的 attachment 类型添加同样的参数。

另外,Console 的部分表单也跟着做了修改,包括:文章/页面设置中的封面图、系统设置中的 Favicon 和 Logo、分类/标签编辑表单中的封面图、用户资料的头像。

FormKit 中使用:

1. Component

    ```vue
    <FormKit
      name="cover"
      type="attachment"
      :accepts="['image/*']"
    ></FormKit>
    ```

2. Schema
    
    ```yaml
    - $formkit: attachment
      name: cover
      accepts:
        - 'image/*'
    ```

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/3800

#### Special notes for your reviewer:

测试方式:

1. 按照上述 FormKit 中的使用方式,自行在主题或者插件配置文件中测试。
2. 测试 Console 中修改的表单:文章/页面设置中的封面图、系统设置中的 Favicon 和 Logo、分类/标签编辑表单中的封面图、用户资料的头像。(均设置为仅允许选择图片(image/*)和最多选择一个(max=1))。

#### Does this PR introduce a user-facing change?

```release-note
Console 端的附件选择组件支持 accepts、min、max 参数用来限定文件格式和数量。
```
2023-04-24 07:45:44 +00:00
johnniang 64919f9a1b Move root to console
Signed-off-by: johnniang <johnniang@fastmail.com>
2023-03-02 15:49:22 +08:00