@coding-flow/flow-design 0.0.60 → 0.0.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,7 @@ export declare class PromissionPresenter {
17
17
  private getFieldName;
18
18
  private convertFieldsToColumns;
19
19
  initFormPromission(): void;
20
+ private isSameData;
20
21
  private changeFieldValue;
21
22
  changeHidden(formCode: string, fieldCode: string, value: boolean): void;
22
23
  changeReadable(formCode: string, fieldCode: string, value: boolean): void;
@@ -44,37 +44,40 @@ class PromissionPresenter {
44
44
  });
45
45
  }
46
46
  initFormPromission() {
47
- if (this.data && this.data.length > 0) return;
48
- const form = this.form;
49
- let data = [];
50
- const mainList = form.fields.map((field)=>({
51
- id: field.id,
52
- fieldName: field.name,
53
- fieldCode: field.code,
54
- formCode: form.code,
55
- type: 'WRITE'
56
- }));
57
- data.push(...mainList);
58
- if (form.subForms) for (const subForm of form.subForms || []){
59
- const list = subForm.fields.map((field)=>({
60
- id: field.id,
61
- formCode: subForm.code,
62
- fieldName: field.name,
47
+ const data = this.formList.flatMap((form)=>(form.fields || []).map((field)=>{
48
+ const permission = this.data.find((item)=>item.formCode === form.code && item.fieldCode === field.code);
49
+ return permission || {
50
+ formCode: form.code,
63
51
  fieldCode: field.code,
64
52
  type: 'WRITE'
65
- }));
66
- data.push(...list);
67
- }
68
- this.onChange(data);
53
+ };
54
+ }));
55
+ if (!this.isSameData(data)) this.onChange(data);
69
56
  this.data = data;
70
57
  }
58
+ isSameData(data) {
59
+ return this.data.length === data.length && this.data.every((item, index)=>{
60
+ const target = data[index];
61
+ return item.formCode === target.formCode && item.fieldCode === target.fieldCode && item.type === target.type;
62
+ });
63
+ }
71
64
  changeFieldValue(code, fieldCode, value) {
72
- let newData = [];
73
- for (const item of this.data)if (item['formCode'] === code && item['fieldCode'] === fieldCode) newData.push({
74
- ...item,
65
+ let exist = false;
66
+ const newData = this.data.map((item)=>{
67
+ if (item.formCode === code && item.fieldCode === fieldCode) {
68
+ exist = true;
69
+ return {
70
+ ...item,
71
+ type: value
72
+ };
73
+ }
74
+ return item;
75
+ });
76
+ if (!exist && this.getFormFields(code).some((field)=>field.code === fieldCode)) newData.push({
77
+ formCode: code,
78
+ fieldCode,
75
79
  type: value
76
80
  });
77
- else newData.push(item);
78
81
  this.onChange(newData);
79
82
  this.data = newData;
80
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coding-flow/flow-design",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "description": "flow-engine design components ",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -49,16 +49,16 @@
49
49
  "nanoid": "^5.1.6",
50
50
  "react-redux": "^9.2.0",
51
51
  "styled-components": "^5.3.11",
52
- "@coding-flow/flow-core": "0.0.60",
53
- "@coding-flow/flow-icons": "0.0.60",
54
- "@coding-flow/flow-types": "0.0.60",
55
- "@coding-flow/flow-pc-ui": "0.0.60"
52
+ "@coding-flow/flow-core": "0.0.62",
53
+ "@coding-flow/flow-pc-ui": "0.0.62",
54
+ "@coding-flow/flow-icons": "0.0.62",
55
+ "@coding-flow/flow-types": "0.0.62"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/lodash-es": "^4.17.12",
59
59
  "@types/styled-components": "^5.1.36",
60
- "@coding-flow/flow-core": "0.0.60",
61
- "@coding-flow/flow-types": "0.0.60"
60
+ "@coding-flow/flow-core": "0.0.62",
61
+ "@coding-flow/flow-types": "0.0.62"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "rslib build",