Skip to content

Commit e09caaa

Browse files
committed
fix meta field
1 parent 546bd4d commit e09caaa

18 files changed

Lines changed: 105 additions & 24 deletions

File tree

apps/app-mobile/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@flow-example/app-mobile",
3-
"version": "0.0.44",
3+
"version": "0.0.45",
44
"private": true,
55
"type": "module",
66
"scripts": {

apps/app-pc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@flow-example/app-pc",
3-
"version": "0.0.44",
3+
"version": "0.0.45",
44
"private": true,
55
"type": "module",
66
"scripts": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coding-flow/root",
3-
"version": "0.0.44",
3+
"version": "0.0.45",
44
"description": "flow-engine root",
55
"main": "index.js",
66
"scripts": {

packages/flow-approval-presenter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coding-flow/flow-approval-presenter",
3-
"version": "0.0.44",
3+
"version": "0.0.45",
44
"description": "flow-engine approval presenter framework ",
55
"type": "module",
66
"keywords": [

packages/flow-approval-presenter/src/context/approval.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from "react";
22
import {ApprovalLayoutProps, ApprovalState} from "@/typings";
33
import {ApprovalPresenter} from "@/presenters";
4+
import { FieldPermission,FlowForm } from "@coding-flow/flow-types";
5+
import { MetaService } from "@/service/meta-service";
46

57
export class ApprovalContextScope {
68
private readonly presenter: ApprovalPresenter;
@@ -24,6 +26,12 @@ export class ApprovalContextScope {
2426
return this.props.initData;
2527
}
2628

29+
public convertMeta(form:FlowForm | undefined, permissions: FieldPermission[]){
30+
const metaService = new MetaService(form, permissions);
31+
const data = metaService.getFormMeta();
32+
return data;
33+
}
34+
2735

2836
public close() {
2937
this.props.onClose?.();
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { FieldPermission, FlowForm, FormField } from "@coding-flow/flow-types";
2+
3+
export class MetaService {
4+
5+
private readonly flowForm: FlowForm|undefined;
6+
private readonly fieldPermissions: FieldPermission[];
7+
8+
constructor(flowForm: FlowForm|undefined, fieldPermissions: FieldPermission[]) {
9+
this.flowForm = flowForm;
10+
this.fieldPermissions = fieldPermissions;
11+
}
12+
13+
14+
public getFormMeta() {
15+
if (!this.flowForm) {
16+
return undefined;
17+
}
18+
return this.convertForm(this.flowForm);
19+
}
20+
21+
22+
private convertForm(form: FlowForm) {
23+
const formCode = form.code;
24+
const subForms = form.subForms || [];
25+
26+
const list: FlowForm[] = [];
27+
28+
if (subForms.length > 0) {
29+
for (const subForm of subForms) {
30+
list.push(this.convertForm(subForm));
31+
}
32+
}
33+
34+
return {
35+
...form,
36+
fields: form.fields.map(field => this.mapFormField(formCode, field)),
37+
subForms: list,
38+
} as FlowForm;
39+
}
40+
41+
42+
43+
private mapFormField(formCode: string, field: FormField) {
44+
const permission = this.fieldPermissions.find(p => p.formCode === formCode && p.fieldCode === field.code);
45+
if (permission) {
46+
if (permission.type === 'HIDDEN') {
47+
return {
48+
...field,
49+
hidden: true,
50+
required: false,
51+
}
52+
}
53+
if (permission.type === 'READ') {
54+
return {
55+
...field,
56+
readonly: true,
57+
required: false,
58+
}
59+
}
60+
return field;
61+
}
62+
return field;
63+
}
64+
65+
}

packages/flow-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coding-flow/flow-core",
3-
"version": "0.0.44",
3+
"version": "0.0.45",
44
"description": "flow-engine core lib framework ",
55
"type": "module",
66
"keywords": [

packages/flow-design/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coding-flow/flow-design",
3-
"version": "0.0.44",
3+
"version": "0.0.45",
44
"description": "flow-engine design components ",
55
"type": "module",
66
"keywords": [

packages/flow-icons/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coding-flow/flow-icons",
3-
"version": "0.0.44",
3+
"version": "0.0.45",
44
"description": "flow-engine icons ",
55
"type": "module",
66
"keywords": [

packages/flow-mobile/flow-mobile-approval/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coding-flow/flow-mobile-approval",
3-
"version": "0.0.44",
3+
"version": "0.0.45",
44
"description": "flow-engine pc mobile approval components",
55
"type": "module",
66
"keywords": [

0 commit comments

Comments
 (0)