@nocobase/plugin-map 0.8.1-alpha.4 → 0.9.0-alpha.2
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.
- package/LICENSE +661 -201
- package/lib/client/components/AMap.d.ts +1 -1
- package/lib/client/components/AMap.js +57 -57
- package/lib/client/components/Configuration.js +2 -2
- package/lib/client/components/Designer.js +6 -7
- package/lib/client/components/Search.js +14 -14
- package/lib/client/constants.js +3 -3
- package/lib/client/fields/circle.js +3 -3
- package/lib/client/fields/lineString.js +3 -3
- package/lib/client/fields/point.js +3 -3
- package/lib/client/fields/polygon.js +3 -3
- package/lib/client/fields/schema.js +2 -2
- package/lib/client/index.js +3 -3
- package/lib/client/initialize.d.ts +1 -1
- package/lib/client/initialize.js +9 -9
- package/lib/client/{locales → locale}/en-US.d.ts +0 -0
- package/lib/client/{locales → locale}/en-US.js +0 -0
- package/lib/client/{locales → locale}/index.d.ts +0 -0
- package/lib/client/{locales → locale}/index.js +2 -10
- package/lib/client/{locales → locale}/zh-CN.d.ts +0 -0
- package/lib/client/{locales → locale}/zh-CN.js +0 -0
- package/lib/server/plugin.js +9 -2
- package/package.json +9 -11
- package/src/client/components/AMap.tsx +7 -8
- package/src/client/components/Configuration.tsx +4 -4
- package/src/client/components/Designer.tsx +4 -4
- package/src/client/components/Search.tsx +3 -3
- package/src/client/constants.ts +1 -1
- package/src/client/fields/circle.ts +1 -1
- package/src/client/fields/lineString.ts +1 -1
- package/src/client/fields/point.ts +1 -2
- package/src/client/fields/polygon.ts +1 -1
- package/src/client/fields/schema.ts +1 -1
- package/src/client/index.tsx +3 -3
- package/src/client/initialize.tsx +3 -4
- package/src/client/{locales → locale}/en-US.ts +0 -0
- package/src/client/{locales → locale}/index.ts +2 -4
- package/src/client/{locales → locale}/zh-CN.ts +0 -0
- package/src/server/__tests__/fields.test.ts +8 -2
- package/src/server/fields/circle.ts +8 -9
- package/src/server/fields/index.ts +4 -4
- package/src/server/fields/lineString.ts +12 -12
- package/src/server/fields/point.ts +12 -12
- package/src/server/fields/polygon.ts +11 -12
- package/src/server/plugin.ts +17 -12
package/lib/server/plugin.js
CHANGED
|
@@ -15,8 +15,6 @@ function _server() {
|
|
|
15
15
|
return data;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
var _fields = require("./fields");
|
|
19
|
-
|
|
20
18
|
function _path() {
|
|
21
19
|
const data = require("path");
|
|
22
20
|
|
|
@@ -29,6 +27,8 @@ function _path() {
|
|
|
29
27
|
|
|
30
28
|
var _actions = require("./actions");
|
|
31
29
|
|
|
30
|
+
var _fields = require("./fields");
|
|
31
|
+
|
|
32
32
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
33
33
|
|
|
34
34
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -62,6 +62,13 @@ class MapPlugin extends _server().Plugin {
|
|
|
62
62
|
},
|
|
63
63
|
only: ['get', 'set']
|
|
64
64
|
});
|
|
65
|
+
|
|
66
|
+
_this.app.acl.registerSnippet({
|
|
67
|
+
name: `pm.${_this.name}.configuration`,
|
|
68
|
+
actions: ['map-configuration:set']
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
_this.app.acl.allow('map-configuration', 'get', 'loggedIn');
|
|
65
72
|
})();
|
|
66
73
|
}
|
|
67
74
|
|
package/package.json
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-map",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.9.0-alpha.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "AGPL-3.0",
|
|
6
|
+
"main": "./lib/index.js",
|
|
7
|
+
"types": "./lib/index.d.ts",
|
|
5
8
|
"devDependencies": {
|
|
6
|
-
"@nocobase/server": "0.
|
|
7
|
-
"@nocobase/test": "0.
|
|
9
|
+
"@nocobase/server": "0.9.0-alpha.2",
|
|
10
|
+
"@nocobase/test": "0.9.0-alpha.2"
|
|
8
11
|
},
|
|
9
12
|
"dependencies": {
|
|
10
13
|
"@amap/amap-jsapi-loader": "^1.0.1",
|
|
11
|
-
"@amap/amap-jsapi-types": "^0.0.10"
|
|
12
|
-
"@emotion/css": "^11.7.1",
|
|
13
|
-
"@formily/react": "2.0.20",
|
|
14
|
-
"ahooks": "^3.7.2",
|
|
15
|
-
"antd": "~4.19.5",
|
|
16
|
-
"sequelize": "^6.26.0"
|
|
14
|
+
"@amap/amap-jsapi-types": "^0.0.10"
|
|
17
15
|
},
|
|
18
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "b8f76ad38e60e677c5bb4aab0a4cdb28d98a0f49"
|
|
19
17
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useEffect, useRef, useState } from 'react';
|
|
3
1
|
import AMapLoader from '@amap/amap-jsapi-loader';
|
|
4
2
|
import '@amap/amap-jsapi-types';
|
|
3
|
+
import { SyncOutlined } from '@ant-design/icons';
|
|
4
|
+
import { css } from '@emotion/css';
|
|
5
5
|
import { useFieldSchema } from '@formily/react';
|
|
6
6
|
import { useCollection } from '@nocobase/client';
|
|
7
|
-
import { css } from '@emotion/css';
|
|
8
|
-
import { Alert, Button, Modal } from 'antd';
|
|
9
|
-
import { useMapTranslation } from '../locales';
|
|
10
|
-
import Search from './Search';
|
|
11
7
|
import { useMemoizedFn } from 'ahooks';
|
|
12
|
-
import {
|
|
8
|
+
import { Alert, Button, Modal } from 'antd';
|
|
9
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
13
10
|
import { useHistory } from 'react-router';
|
|
14
|
-
import {
|
|
11
|
+
import { useMapConfiguration } from '../hooks';
|
|
12
|
+
import { useMapTranslation } from '../locale';
|
|
13
|
+
import Search from './Search';
|
|
15
14
|
|
|
16
15
|
interface AMapComponentProps {
|
|
17
16
|
accessKey: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useAPIClient, useCompile
|
|
1
|
+
import { useAPIClient, useCompile } from '@nocobase/client';
|
|
2
2
|
import { useBoolean } from 'ahooks';
|
|
3
|
-
import {
|
|
4
|
-
import React, {
|
|
3
|
+
import { Button, Card, Form, Input, message, Tabs } from 'antd';
|
|
4
|
+
import React, { useEffect, useMemo } from 'react';
|
|
5
5
|
import { MapTypes } from '../constants';
|
|
6
6
|
import { MapConfigurationResourceKey, useMapConfiguration } from '../hooks';
|
|
7
|
-
import { useMapTranslation } from '../
|
|
7
|
+
import { useMapTranslation } from '../locale';
|
|
8
8
|
|
|
9
9
|
const AMapConfiguration = ({ type }) => {
|
|
10
10
|
const { t } = useMapTranslation();
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
useCollection,
|
|
7
7
|
useCollectionManager,
|
|
8
8
|
useDesignable,
|
|
9
|
-
useFormBlockContext
|
|
9
|
+
useFormBlockContext
|
|
10
10
|
} from '@nocobase/client';
|
|
11
|
-
import
|
|
11
|
+
import set from 'lodash/set';
|
|
12
12
|
import React from 'react';
|
|
13
|
-
import { useMapTranslation } from '../
|
|
13
|
+
import { useMapTranslation } from '../locale';
|
|
14
14
|
|
|
15
15
|
const Designer = () => {
|
|
16
16
|
const { getCollectionJoinField } = useCollectionManager();
|
|
@@ -230,7 +230,7 @@ const Designer = () => {
|
|
|
230
230
|
}
|
|
231
231
|
onSubmit={({ zoom }) => {
|
|
232
232
|
if (zoom) {
|
|
233
|
-
|
|
233
|
+
set(fieldSchema, 'x-component-props.zoom', zoom);
|
|
234
234
|
Object.assign(field.componentProps, fieldSchema['x-component-props']);
|
|
235
235
|
|
|
236
236
|
dn.emit('patch', {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { message, Select } from 'antd';
|
|
2
1
|
import { css } from '@emotion/css';
|
|
3
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
4
2
|
import { useDebounceFn } from 'ahooks';
|
|
5
|
-
import {
|
|
3
|
+
import { message, Select } from 'antd';
|
|
4
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { useMapTranslation } from '../locale';
|
|
6
6
|
|
|
7
7
|
interface SearchProps {
|
|
8
8
|
aMap: any;
|
package/src/client/constants.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ISchema } from '@formily/react';
|
|
2
2
|
import { interfacesProperties } from '@nocobase/client';
|
|
3
3
|
import { MapTypes } from '../constants';
|
|
4
|
-
import { generateNTemplate } from '../
|
|
4
|
+
import { generateNTemplate } from '../locale';
|
|
5
5
|
|
|
6
6
|
const { defaultProps } = interfacesProperties;
|
|
7
7
|
|
package/src/client/index.tsx
CHANGED
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
CollectionManagerContext,
|
|
3
3
|
CurrentAppInfoProvider,
|
|
4
4
|
SchemaComponentOptions,
|
|
5
|
-
SettingsCenterProvider
|
|
5
|
+
SettingsCenterProvider
|
|
6
6
|
} from '@nocobase/client';
|
|
7
7
|
import React, { useContext } from 'react';
|
|
8
8
|
import Configuration from './components/Configuration';
|
|
9
9
|
import Map from './components/Map';
|
|
10
10
|
import { interfaces } from './fields';
|
|
11
11
|
import { Initialize } from './initialize';
|
|
12
|
-
import { useMapTranslation } from './
|
|
12
|
+
import { useMapTranslation } from './locale';
|
|
13
13
|
|
|
14
14
|
export default React.memo((props) => {
|
|
15
15
|
const ctx = useContext(CollectionManagerContext);
|
|
@@ -19,7 +19,7 @@ export default React.memo((props) => {
|
|
|
19
19
|
<Initialize>
|
|
20
20
|
<SettingsCenterProvider
|
|
21
21
|
settings={{
|
|
22
|
-
|
|
22
|
+
map: {
|
|
23
23
|
title: t('Map Manager'),
|
|
24
24
|
icon: 'EnvironmentOutlined',
|
|
25
25
|
tabs: {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { registerField, registerGroup, useCurrentAppInfo } from '@nocobase/client';
|
|
3
|
-
import {
|
|
4
|
-
import './locales';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
5
3
|
import { fields } from './fields';
|
|
6
|
-
import
|
|
4
|
+
import './locale';
|
|
5
|
+
import { generateNTemplate } from './locale';
|
|
7
6
|
|
|
8
7
|
export const useRegisterInterface = () => {
|
|
9
8
|
const { data } = useCurrentAppInfo() || {};
|
|
File without changes
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { i18n } from '@nocobase/client';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
3
|
|
|
4
|
-
import enUS from './en-US';
|
|
5
|
-
import zhCN from './zh-CN';
|
|
6
4
|
|
|
7
5
|
export const NAMESPACE = 'map';
|
|
8
6
|
|
|
9
|
-
i18n.addResources('zh-CN', NAMESPACE, zhCN);
|
|
10
|
-
i18n.addResources('en-US', NAMESPACE, enUS);
|
|
7
|
+
// i18n.addResources('zh-CN', NAMESPACE, zhCN);
|
|
8
|
+
// i18n.addResources('en-US', NAMESPACE, enUS);
|
|
11
9
|
|
|
12
10
|
export function lang(key: string) {
|
|
13
11
|
return i18n.t(key, { ns: NAMESPACE });
|
|
File without changes
|
|
@@ -94,8 +94,14 @@ describe('fields', () => {
|
|
|
94
94
|
[3, 4],
|
|
95
95
|
[5, 6],
|
|
96
96
|
]);
|
|
97
|
-
model.set('lineString', [
|
|
98
|
-
|
|
97
|
+
model.set('lineString', [
|
|
98
|
+
[5, 6],
|
|
99
|
+
[7, 8],
|
|
100
|
+
]);
|
|
101
|
+
expect(model.get('lineString')).toMatchObject([
|
|
102
|
+
[5, 6],
|
|
103
|
+
[7, 8],
|
|
104
|
+
]);
|
|
99
105
|
model.set('circle', [1, 2, 0.5]);
|
|
100
106
|
expect(model.get('circle')).toMatchObject([1, 2, 0.5]);
|
|
101
107
|
});
|
|
@@ -6,29 +6,28 @@ class Circle extends DataTypes.ABSTRACT {
|
|
|
6
6
|
key = 'Circle';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
export class CircleField extends Field {
|
|
11
10
|
constructor(options?: any, context?: FieldContext) {
|
|
12
|
-
const { name } = options
|
|
11
|
+
const { name } = options;
|
|
13
12
|
super(
|
|
14
13
|
{
|
|
15
14
|
get() {
|
|
16
15
|
const value = this.getDataValue(name);
|
|
17
16
|
if (isPg(context)) {
|
|
18
17
|
if (typeof value === 'string') {
|
|
19
|
-
return toValue(`(${value})`)
|
|
18
|
+
return toValue(`(${value})`);
|
|
20
19
|
}
|
|
21
|
-
return value ? [value.x, value.y, value.radius] : null
|
|
20
|
+
return value ? [value.x, value.y, value.radius] : null;
|
|
22
21
|
} else {
|
|
23
|
-
return value
|
|
22
|
+
return value;
|
|
24
23
|
}
|
|
25
24
|
},
|
|
26
25
|
set(value) {
|
|
27
|
-
if (!value?.length) value = null
|
|
26
|
+
if (!value?.length) value = null;
|
|
28
27
|
else if (isPg(context)) {
|
|
29
|
-
value = value.join(',')
|
|
28
|
+
value = value.join(',');
|
|
30
29
|
}
|
|
31
|
-
this.setDataValue(name, value)
|
|
30
|
+
this.setDataValue(name, value);
|
|
32
31
|
},
|
|
33
32
|
...options,
|
|
34
33
|
},
|
|
@@ -40,7 +39,7 @@ export class CircleField extends Field {
|
|
|
40
39
|
if (isPg(this.context)) {
|
|
41
40
|
return Circle;
|
|
42
41
|
} else {
|
|
43
|
-
return DataTypes.JSON
|
|
42
|
+
return DataTypes.JSON;
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './point'
|
|
2
|
-
export * from './lineString'
|
|
3
|
-
export * from './polygon'
|
|
4
|
-
export * from './circle'
|
|
1
|
+
export * from './point';
|
|
2
|
+
export * from './lineString';
|
|
3
|
+
export * from './polygon';
|
|
4
|
+
export * from './circle';
|
|
@@ -8,30 +8,30 @@ class LineString extends DataTypes.ABSTRACT {
|
|
|
8
8
|
|
|
9
9
|
export class LineStringField extends Field {
|
|
10
10
|
constructor(options?: any, context?: FieldContext) {
|
|
11
|
-
const { name } = options
|
|
11
|
+
const { name } = options;
|
|
12
12
|
super(
|
|
13
13
|
{
|
|
14
14
|
get() {
|
|
15
15
|
const value = this.getDataValue(name);
|
|
16
16
|
if (isPg(context)) {
|
|
17
|
-
return toValue(value)
|
|
17
|
+
return toValue(value);
|
|
18
18
|
} else if (isMysql(context)) {
|
|
19
|
-
return value?.coordinates || null
|
|
19
|
+
return value?.coordinates || null;
|
|
20
20
|
} else {
|
|
21
|
-
return value
|
|
21
|
+
return value;
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
set(value) {
|
|
25
|
-
if (!value?.length) value = null
|
|
25
|
+
if (!value?.length) value = null;
|
|
26
26
|
else if (isPg(context)) {
|
|
27
|
-
value = joinComma(value.map(joinComma))
|
|
27
|
+
value = joinComma(value.map(joinComma));
|
|
28
28
|
} else if (isMysql(context)) {
|
|
29
29
|
value = {
|
|
30
30
|
type: 'LineString',
|
|
31
|
-
coordinates: value
|
|
32
|
-
}
|
|
31
|
+
coordinates: value,
|
|
32
|
+
};
|
|
33
33
|
}
|
|
34
|
-
this.setDataValue(name, value)
|
|
34
|
+
this.setDataValue(name, value);
|
|
35
35
|
},
|
|
36
36
|
...options,
|
|
37
37
|
},
|
|
@@ -41,14 +41,14 @@ export class LineStringField extends Field {
|
|
|
41
41
|
|
|
42
42
|
get dataType() {
|
|
43
43
|
if (isPg(this.context)) {
|
|
44
|
-
return LineString
|
|
45
|
-
}
|
|
44
|
+
return LineString;
|
|
45
|
+
}
|
|
46
|
+
if (isMysql(this.context)) {
|
|
46
47
|
return DataTypes.GEOMETRY('LINESTRING');
|
|
47
48
|
} else {
|
|
48
49
|
return DataTypes.JSON;
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export interface LineStringOptions extends BaseColumnFieldOptions {
|
|
@@ -8,33 +8,33 @@ class Point extends DataTypes.ABSTRACT {
|
|
|
8
8
|
|
|
9
9
|
export class PointField extends Field {
|
|
10
10
|
constructor(options?: any, context?: FieldContext) {
|
|
11
|
-
const { name } = options
|
|
11
|
+
const { name } = options;
|
|
12
12
|
super(
|
|
13
13
|
{
|
|
14
14
|
get() {
|
|
15
15
|
const value = this.getDataValue(name);
|
|
16
16
|
if (isPg(context)) {
|
|
17
17
|
if (typeof value === 'string') {
|
|
18
|
-
return toValue(value)
|
|
18
|
+
return toValue(value);
|
|
19
19
|
}
|
|
20
|
-
return value ? [value.x, value.y] : null
|
|
20
|
+
return value ? [value.x, value.y] : null;
|
|
21
21
|
} else if (isMysql(context)) {
|
|
22
|
-
return value?.coordinates || null
|
|
22
|
+
return value?.coordinates || null;
|
|
23
23
|
} else {
|
|
24
|
-
return value
|
|
24
|
+
return value;
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
set(value) {
|
|
28
|
-
if (!value?.length) value = null
|
|
28
|
+
if (!value?.length) value = null;
|
|
29
29
|
else if (isPg(context)) {
|
|
30
|
-
value = joinComma(value)
|
|
30
|
+
value = joinComma(value);
|
|
31
31
|
} else if (isMysql(context)) {
|
|
32
32
|
value = {
|
|
33
33
|
type: 'Point',
|
|
34
|
-
coordinates: value
|
|
35
|
-
}
|
|
34
|
+
coordinates: value,
|
|
35
|
+
};
|
|
36
36
|
}
|
|
37
|
-
this.setDataValue(name, value)
|
|
37
|
+
this.setDataValue(name, value);
|
|
38
38
|
},
|
|
39
39
|
...options,
|
|
40
40
|
},
|
|
@@ -45,13 +45,13 @@ export class PointField extends Field {
|
|
|
45
45
|
get dataType() {
|
|
46
46
|
if (isPg(this.context)) {
|
|
47
47
|
return Point;
|
|
48
|
-
}
|
|
48
|
+
}
|
|
49
|
+
if (isMysql(this.context)) {
|
|
49
50
|
return DataTypes.GEOMETRY('POINT');
|
|
50
51
|
} else {
|
|
51
52
|
return DataTypes.JSON;
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
|
-
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export interface PointFieldOptions extends BaseColumnFieldOptions {
|
|
@@ -3,35 +3,35 @@ import { DataTypes } from 'sequelize';
|
|
|
3
3
|
import { isMysql, isPg, joinComma, toValue } from '../helpers';
|
|
4
4
|
|
|
5
5
|
class Polygon extends DataTypes.ABSTRACT {
|
|
6
|
-
key = 'Polygon'
|
|
6
|
+
key = 'Polygon';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export class PolygonField extends Field {
|
|
10
10
|
constructor(options?: any, context?: FieldContext) {
|
|
11
|
-
const { name } = options
|
|
11
|
+
const { name } = options;
|
|
12
12
|
super(
|
|
13
13
|
{
|
|
14
14
|
get() {
|
|
15
|
-
const value = this.getDataValue(name)
|
|
15
|
+
const value = this.getDataValue(name);
|
|
16
16
|
if (isPg(context)) {
|
|
17
|
-
return toValue(value)
|
|
17
|
+
return toValue(value);
|
|
18
18
|
} else if (isMysql(context)) {
|
|
19
|
-
return value?.coordinates[0].slice(0, -1) || null
|
|
19
|
+
return value?.coordinates[0].slice(0, -1) || null;
|
|
20
20
|
} else {
|
|
21
|
-
return value
|
|
21
|
+
return value;
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
set(value) {
|
|
25
|
-
if (!value?.length) value = null
|
|
25
|
+
if (!value?.length) value = null;
|
|
26
26
|
else if (isPg(context)) {
|
|
27
|
-
value = joinComma(value.map((item: any) => joinComma(item)))
|
|
27
|
+
value = joinComma(value.map((item: any) => joinComma(item)));
|
|
28
28
|
} else if (isMysql(context)) {
|
|
29
29
|
value = {
|
|
30
30
|
type: 'Polygon',
|
|
31
|
-
coordinates: [value.concat([value[0]])]
|
|
32
|
-
}
|
|
31
|
+
coordinates: [value.concat([value[0]])],
|
|
32
|
+
};
|
|
33
33
|
}
|
|
34
|
-
this.setDataValue(name, value)
|
|
34
|
+
this.setDataValue(name, value);
|
|
35
35
|
},
|
|
36
36
|
...options,
|
|
37
37
|
},
|
|
@@ -48,7 +48,6 @@ export class PolygonField extends Field {
|
|
|
48
48
|
return DataTypes.JSON;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
export interface PolygonFieldOptions extends BaseColumnFieldOptions {
|
package/src/server/plugin.ts
CHANGED
|
@@ -1,46 +1,51 @@
|
|
|
1
1
|
import { InstallOptions, Plugin } from '@nocobase/server';
|
|
2
|
-
import { CircleField, LineStringField, PointField, PolygonField } from './fields';
|
|
3
2
|
import { resolve } from 'path';
|
|
4
3
|
import { getConfiguration, setConfiguration } from './actions';
|
|
4
|
+
import { CircleField, LineStringField, PointField, PolygonField } from './fields';
|
|
5
5
|
|
|
6
6
|
export class MapPlugin extends Plugin {
|
|
7
|
-
afterAdd() {
|
|
7
|
+
afterAdd() {}
|
|
8
8
|
|
|
9
9
|
beforeLoad() {
|
|
10
10
|
const fields = {
|
|
11
11
|
point: PointField,
|
|
12
12
|
polygon: PolygonField,
|
|
13
13
|
lineString: LineStringField,
|
|
14
|
-
circle: CircleField
|
|
14
|
+
circle: CircleField,
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
this.db.registerFieldTypes(fields);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
async load() {
|
|
22
21
|
await this.db.import({
|
|
23
22
|
directory: resolve(__dirname, 'collections'),
|
|
24
23
|
});
|
|
25
24
|
|
|
26
|
-
this.app.resource(
|
|
25
|
+
this.app.resource({
|
|
27
26
|
name: 'map-configuration',
|
|
28
27
|
actions: {
|
|
29
28
|
get: getConfiguration,
|
|
30
|
-
set: setConfiguration
|
|
29
|
+
set: setConfiguration,
|
|
31
30
|
},
|
|
32
|
-
only: ['get', 'set']
|
|
33
|
-
})
|
|
31
|
+
only: ['get', 'set'],
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
this.app.acl.registerSnippet({
|
|
35
|
+
name: `pm.${this.name}.configuration`,
|
|
36
|
+
actions: ['map-configuration:set'],
|
|
37
|
+
});
|
|
34
38
|
|
|
39
|
+
this.app.acl.allow('map-configuration', 'get', 'loggedIn');
|
|
35
40
|
}
|
|
36
41
|
|
|
37
|
-
async install(options?: InstallOptions) {
|
|
42
|
+
async install(options?: InstallOptions) {}
|
|
38
43
|
|
|
39
|
-
async afterEnable() {
|
|
44
|
+
async afterEnable() {}
|
|
40
45
|
|
|
41
|
-
async afterDisable() {
|
|
46
|
+
async afterDisable() {}
|
|
42
47
|
|
|
43
|
-
async remove() {
|
|
48
|
+
async remove() {}
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
export default MapPlugin;
|