@steedos/steedos-plugin-schema-builder 2.3.0-beta.9 → 2.3.0

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.
Files changed (44) hide show
  1. package/package.json +2 -2
  2. package/src/objects.action.js +5 -0
  3. package/src/objects.object.yml +6 -0
  4. package/webapp/src/g6/behavior/activate-relations/index.tsx +160 -0
  5. package/webapp/src/g6/behavior/darg/index.tsx +146 -0
  6. package/webapp/src/g6/behavior/index.tsx +5 -0
  7. package/webapp/src/g6/model/editor-background.png +0 -0
  8. package/webapp/src/g6/model/index.tsx +574 -0
  9. package/webapp/src/g6/model/model-node.tsx +1080 -0
  10. package/webapp/src/g6/model/model.scss +163 -0
  11. package/webapp/src/g6/model/toolbar.tsx +360 -0
  12. package/webapp/src/g6/shape/base-sharp/index.tsx +19 -0
  13. package/webapp/src/g6/shape/index.tsx +0 -0
  14. package/webapp/src/g6/util/graph.tsx +60 -0
  15. package/webapp/src/g6/util/hooks.tsx +26 -0
  16. package/webapp/src/g6/util/index.tsx +20 -0
  17. package/webapp/src/hook/index.tsx +47 -0
  18. package/webapp/src/index.tsx +25 -0
  19. package/webapp/src/page/dva-model/index.tsx +70 -0
  20. package/webapp/src/page/dva-model/reducer/arrange.tsx +16 -0
  21. package/webapp/src/page/dva-model/reducer/index.tsx +7 -0
  22. package/webapp/src/page/dva-model/reducer/init.tsx +61 -0
  23. package/webapp/src/page/dva-model/reducer/model.tsx +126 -0
  24. package/webapp/src/page/dva-model/reducer/on-expand.tsx +27 -0
  25. package/webapp/src/page/dva-model/style.tsx +88 -0
  26. package/webapp/src/page/hooks/callback.tsx +54 -0
  27. package/webapp/src/page/hooks/fullscreen.tsx +34 -0
  28. package/webapp/src/page/hooks/pagehooks.tsx +127 -0
  29. package/webapp/src/page/hooks/resize.tsx +20 -0
  30. package/webapp/src/page/index.tsx +393 -0
  31. package/webapp/src/page/model-navi/index.tsx +329 -0
  32. package/webapp/src/page/model-navi/style.scss +111 -0
  33. package/webapp/src/page/util/index.tsx +234 -0
  34. package/webapp/src/page/util/layout-nodes/index.tsx +185 -0
  35. package/webapp/src/pdm/index.tsx +50 -0
  36. package/webapp/src/pdm/pdm-json/index.js +224 -0
  37. package/webapp/src/pdm/pdm-json/removeDiacritics.js +96 -0
  38. package/webapp/src/style.less +14 -0
  39. package/webapp/src/tree/index.tsx +46 -0
  40. package/webapp/src/tree/style.scss +26 -0
  41. package/webapp/src/type/field.tsx +10 -0
  42. package/webapp/src/type/index.tsx +3 -0
  43. package/webapp/src/type/model.tsx +12 -0
  44. package/webapp/src/type/module.tsx +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/steedos-plugin-schema-builder",
3
- "version": "2.3.0-beta.9",
3
+ "version": "2.3.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "",
@@ -10,5 +10,5 @@
10
10
  "access": "public"
11
11
  },
12
12
  "homepage": "https://www.steedos.com",
13
- "gitHead": "4a38ff2adeb167f850b33633810bbcfe89383136"
13
+ "gitHead": "b00e79e6fb8549b2fabed7b6cd6d4847775ba5df"
14
14
  }
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ schemaBuilder: function (object_name, record_id, fields) {
3
+ Steedos.openWindow(Steedos.absoluteUrl('/schema-builder'))
4
+ }
5
+ }
@@ -0,0 +1,6 @@
1
+ extend: objects
2
+ actions:
3
+ schemaBuilder:
4
+ label: 对象关系图
5
+ visible: true
6
+ on: list
@@ -0,0 +1,160 @@
1
+
2
+ export default {
3
+ getDefaultCfg() {
4
+ return {
5
+ trigger: 'mouseenter',
6
+ // 可选 mouseenter || click
7
+ activeState: 'active',
8
+ inactiveState: 'inactive',
9
+
10
+ shouldUpdate() {
11
+ return true
12
+ },
13
+
14
+ }
15
+ },
16
+
17
+ getEvents() {
18
+ if (this.get('trigger') === 'mouseenter') {
19
+ return {
20
+ 'node:mouseenter': 'setAllItemStates',
21
+ 'node:mouseleave': 'clearAllItemStates',
22
+ }
23
+ }
24
+
25
+ return {
26
+ 'node:click': 'setAllItemStates',
27
+ 'canvas:click': 'clearAllItemStates',
28
+ }
29
+ },
30
+
31
+ setAllItemStates(e) {
32
+ // return
33
+ const graph = this.get('graph')
34
+ const item = e.item
35
+ this.item = item
36
+
37
+ if (!this.shouldUpdate(e.item, {
38
+ event: e,
39
+ action: 'activate',
40
+ })) {
41
+ return
42
+ }
43
+
44
+ const activeState = this.get('activeState')
45
+ const inactiveState = this.get('inactiveState')
46
+ const autoPaint = graph.get('autoPaint')
47
+ graph.setAutoPaint(false)
48
+ graph.getNodes().filter((a) => !a.isSys).forEach((node) => {
49
+ // graph.setItemState(node, activeState, false)
50
+ // inactiveState && graph.setItemState(node, inactiveState, true)
51
+ graph.updateItem(node, {
52
+ active: false,
53
+ inactive: true,
54
+ })
55
+ })
56
+ graph.getEdges().filter((a) => !a.isSys).forEach((edge) => {
57
+ graph.setItemState(edge, 'init', false)
58
+ // graph.updateItem(edge, { active: false, into : false })
59
+ graph.setItemState(edge, inactiveState, true)
60
+ graph.setItemState(edge, activeState, false) // inactiveState && graph.setItemState(edge, inactiveState, true)
61
+ }) // inactiveState && graph.setItemState(item, inactiveState, false)
62
+ // graph.setItemState(item, activeState, true)
63
+
64
+ graph.updateItem(item, {
65
+ active: true,
66
+ }) // const { target } = e
67
+ // // alert(target.attr('text'))
68
+ // if (target.attr('text')) {
69
+ // target.attr('fill_old', target.attr('fill'))
70
+ // target.attr('fill', 'red')
71
+ // }
72
+
73
+ graph.getEdges().forEach((edge) => {
74
+ if (edge.getSource() === item) {
75
+ // inactiveState && graph.setItemState(edge.getTarget(), inactiveState, false)
76
+ // graph.updateItem(edge.getTarget(), { active: true })
77
+ graph.setItemState(edge.getTarget(), activeState, true)
78
+ graph.setItemState(edge, activeState, true)
79
+ graph.setItemState(edge, inactiveState, false) // graph.updateItem(edge, { active: true, into : true })
80
+
81
+ graph.updateItem(edge.getTarget(), {
82
+ out: false,
83
+ into: true,
84
+ })
85
+ edge.toFront()
86
+ } else if (edge.getTarget() === item) {
87
+ graph.updateItem(edge.getSource(), {
88
+ into: false,
89
+ out: true,
90
+ })
91
+ // inactiveState && graph.setItemState(edge.getSource(), inactiveState, false)
92
+
93
+ graph.setItemState(edge.getSource(), activeState, true)
94
+ graph.setItemState(edge, activeState, true)
95
+ graph.setItemState(edge, inactiveState, true) // graph.updateItem(edge, { active: true, out : true })
96
+
97
+ edge.toFront()
98
+ }
99
+ })
100
+ graph.paint()
101
+ graph.setAutoPaint(autoPaint)
102
+ graph.emit('afteractivaterelations', {
103
+ item: e.item,
104
+ action: 'activate',
105
+ })
106
+ },
107
+
108
+ clearAllItemStates(e) {
109
+ // return
110
+ // const { target } = e
111
+ // // alert(target.attr('text'))
112
+ // if (target.attr('text')) {
113
+ // // target.attr('fill_old', target.attr('fill'))
114
+ // if (target.attr('fill_old'))
115
+ // target.attr('fill', target.attr('fill_old'))
116
+ // }
117
+ const graph = this.get('graph')
118
+
119
+ if (!this.shouldUpdate(e.item, {
120
+ event: e,
121
+ action: 'deactivate',
122
+ })) {
123
+ return
124
+ }
125
+
126
+ const autoPaint = graph.get('autoPaint')
127
+ graph.setAutoPaint(false)
128
+ const activeState = this.get('activeState')
129
+ const inactiveState = this.get('inactiveState')
130
+ graph.getNodes().filter((a) => !a.isSys).forEach((n) => {
131
+ // graph.clearItemStates(node, [activeState , inactiveState ])
132
+ // graph.setItemState(n, activeState, false)
133
+ // graph.setItemState(n, inactiveState, false)
134
+ graph.updateItem(n, {
135
+ active: false,
136
+ into: false,
137
+ out: false,
138
+ inactive: false,
139
+ })
140
+
141
+ })
142
+ // alert(graph.getEdges().length)
143
+ graph.getEdges().forEach((n) => {
144
+ // graph.updateItem(n, { active: false, into : false , out : false })
145
+ // graph.clearItemStates(edge, [activeState , inactiveState ])
146
+ graph.clearItemStates(n, [activeState, inactiveState])
147
+ graph.setItemState(n, 'init', true)
148
+ // graph.setItemState(n, activeState, false)
149
+ // graph.setItemState(n, inactiveState, false)
150
+ })
151
+ graph.paint()
152
+ graph.setAutoPaint(autoPaint) // alert(activeState)
153
+
154
+ graph.emit('afteractivaterelations', {
155
+ item: e.item || this.item,
156
+ action: 'deactivate',
157
+ })
158
+ },
159
+
160
+ }
@@ -0,0 +1,146 @@
1
+
2
+ import { Util } from '@antv/g6';
3
+ import _ from 'lodash';
4
+ const abs = Math.abs;
5
+ const DRAG_OFFSET = 10;
6
+ const body = document.body;
7
+ export default {
8
+ getDefaultCfg() {
9
+ return {
10
+ direction: 'both'
11
+ };
12
+ },
13
+
14
+ getEvents() {
15
+ return {
16
+ 'canvas:mousedown': 'onMouseDown',
17
+ 'canvas:mousemove': 'onMouseMove',
18
+ 'canvas:mouseup': 'onMouseUp',
19
+ 'canvas:click': 'onMouseUp',
20
+ 'canvas:mouseleave': 'onOutOfRange'
21
+ };
22
+ },
23
+
24
+ updateViewport(e) {
25
+ const origin = this.origin;
26
+ const clientX = +e.clientX;
27
+ const clientY = +e.clientY;
28
+
29
+ if (isNaN(clientX) || isNaN(clientY)) {
30
+ return;
31
+ }
32
+
33
+ let dx = clientX - origin.x;
34
+ let dy = clientY - origin.y;
35
+
36
+ if (this.get('direction') === 'x') {
37
+ dy = 0;
38
+ } else if (this.get('direction') === 'y') {
39
+ dx = 0;
40
+ }
41
+
42
+ this.origin = {
43
+ x: clientX,
44
+ y: clientY
45
+ };
46
+ this.graph.translate(dx, dy);
47
+ this.graph.paint();
48
+ },
49
+
50
+ onMouseDown(e) {
51
+ this.origin = {
52
+ x: e.clientX,
53
+ y: e.clientY
54
+ };
55
+ this.dragging = false;
56
+ },
57
+
58
+ onMouseMove(e) {
59
+ e = Util.cloneEvent(e);
60
+ const graph = this.graph;
61
+
62
+ if (!this.origin) {
63
+ return;
64
+ }
65
+
66
+ if (this.origin && !this.dragging) {
67
+ if (abs(this.origin.x - e.clientX) + abs(this.origin.y - e.clientY) < DRAG_OFFSET) {
68
+ return;
69
+ }
70
+
71
+ if (this.shouldBegin.call(this, e)) {
72
+ e.type = 'dragstart';
73
+ graph.emit('canvas:dragstart', e);
74
+ this.dragging = true;
75
+ }
76
+ }
77
+
78
+ if (this.dragging) {
79
+ e.type = 'drag';
80
+ const self = this;
81
+ const canvasElement = self.graph.get('canvas').get('el');
82
+ canvasElement.style.cursor = 'grabbing';
83
+ graph.emit('canvas:drag', e);
84
+ }
85
+
86
+ if (this.shouldUpdate.call(this, e)) {
87
+ this.updateViewport(e); // console.log(e)
88
+ // _.throttle(() => {
89
+ // this.updateViewport(e)
90
+ // }, 0)
91
+ }
92
+ },
93
+
94
+ onMouseUp(e) {
95
+ if (!this.dragging) {
96
+ this.origin = null;
97
+ return;
98
+ }
99
+
100
+ e = Util.cloneEvent(e);
101
+ const graph = this.graph;
102
+
103
+ if (this.shouldEnd.call(this, e)) {
104
+ this.updateViewport(e);
105
+ }
106
+
107
+ e.type = 'dragend';
108
+ graph.emit('canvas:dragend', e);
109
+ this.endDrag();
110
+ },
111
+
112
+ endDrag() {
113
+ if (this.dragging) {
114
+ const self = this;
115
+ const canvasElement = self.graph.get('canvas').get('el');
116
+ canvasElement.style.cursor = 'grab';
117
+ this.origin = null;
118
+ this.dragging = false; // 终止时需要判断此时是否在监听画布外的 mouseup 事件,若有则解绑
119
+
120
+ const fn = this.fn;
121
+
122
+ if (fn) {
123
+ body.removeEventListener('mouseup', fn, false);
124
+ this.fn = null;
125
+ }
126
+ }
127
+ },
128
+
129
+ // 若在拖拽时,鼠标移出画布区域,此时放开鼠标无法终止 drag 行为。在画布外监听 mouseup 事件,放开则终止
130
+ onOutOfRange(e) {
131
+ if (this.dragging) {
132
+ const self = this;
133
+ const canvasElement = self.graph.get('canvas').get('el');
134
+
135
+ const fn = ev => {
136
+ if (ev.target !== canvasElement) {
137
+ self.onMouseUp(e);
138
+ }
139
+ };
140
+
141
+ this.fn = fn;
142
+ body.addEventListener('mouseup', fn, false);
143
+ }
144
+ }
145
+
146
+ };
@@ -0,0 +1,5 @@
1
+ import G6 from '@antv/g6';
2
+ import ActivateRelations from './activate-relations';
3
+ import Darg from './darg';
4
+ G6.registerBehavior('console-activate-relations', ActivateRelations);
5
+ G6.registerBehavior('console-darg', Darg);