@nocobase/plugin-map 0.9.1-alpha.1 → 0.9.2-alpha.1
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/docs/en-US/changelog.md +1 -0
- package/docs/en-US/index.md +1 -0
- package/docs/en-US/installation.md +1 -0
- package/docs/en-US/tabs.json +18 -0
- package/docs/en-US/usage.md +1 -0
- package/docs/zh-CN/changelog.md +1 -0
- package/docs/zh-CN/index.md +1 -0
- package/docs/zh-CN/installation.md +1 -0
- package/docs/zh-CN/tabs.json +18 -0
- package/docs/zh-CN/usage.md +1 -0
- package/lib/client/block/MapActionInitializers.d.ts +89 -0
- package/lib/client/block/MapActionInitializers.js +93 -0
- package/lib/client/block/MapBlock.d.ts +1 -0
- package/lib/client/block/MapBlock.js +358 -0
- package/lib/client/block/MapBlockDesigner.d.ts +1 -0
- package/lib/client/block/MapBlockDesigner.js +196 -0
- package/lib/client/block/MapBlockInitializer.d.ts +1 -0
- package/lib/client/block/MapBlockInitializer.js +122 -0
- package/lib/client/block/MapBlockProvider.d.ts +5 -0
- package/lib/client/block/MapBlockProvider.js +91 -0
- package/lib/client/block/index.d.ts +2 -0
- package/lib/client/block/index.js +58 -0
- package/lib/client/block/utils.d.ts +56 -0
- package/lib/client/block/utils.js +102 -0
- package/lib/client/components/AMap.d.ts +32 -6
- package/lib/client/components/AMap.js +152 -203
- package/lib/client/components/Configuration.js +11 -45
- package/lib/client/components/Designer.js +6 -40
- package/lib/client/components/Map.d.ts +4 -1
- package/lib/client/components/Map.js +4 -18
- package/lib/client/components/ReadPretty.js +12 -29
- package/lib/client/components/Search.js +31 -65
- package/lib/client/constants.js +0 -2
- package/lib/client/fields/circle.js +3 -8
- package/lib/client/fields/index.js +0 -5
- package/lib/client/fields/lineString.js +3 -8
- package/lib/client/fields/point.js +3 -8
- package/lib/client/fields/polygon.js +3 -8
- package/lib/client/fields/schema.d.ts +1 -2
- package/lib/client/fields/schema.js +3 -18
- package/lib/client/hooks/index.js +0 -2
- package/lib/client/hooks/useMapConfiguration.d.ts +1 -0
- package/lib/client/hooks/useMapConfiguration.js +28 -8
- package/lib/client/index.d.ts +1 -0
- package/lib/client/index.js +8 -26
- package/lib/client/initialize.d.ts +1 -1
- package/lib/client/initialize.js +4 -21
- package/lib/client/locale/index.js +6 -13
- package/lib/client/locale/pt-BR.d.ts +46 -0
- package/lib/client/locale/pt-BR.js +54 -0
- package/lib/client/locale/zh-CN.d.ts +5 -2
- package/lib/client/locale/zh-CN.js +21 -18
- package/lib/index.js +0 -2
- package/lib/server/actions/index.js +0 -11
- package/lib/server/collections/mapConfiguration.d.ts +1 -1
- package/lib/server/collections/mapConfiguration.js +1 -3
- package/lib/server/fields/circle.js +3 -22
- package/lib/server/fields/index.js +0 -8
- package/lib/server/fields/lineString.js +3 -22
- package/lib/server/fields/point.js +3 -23
- package/lib/server/fields/polygon.js +3 -21
- package/lib/server/helpers/index.js +0 -12
- package/lib/server/index.js +0 -2
- package/lib/server/plugin.js +0 -24
- package/lib/server/value-parsers/index.js +0 -21
- package/package.json +8 -5
- package/src/client/block/MapActionInitializers.tsx +97 -0
- package/src/client/block/MapBlock.tsx +308 -0
- package/src/client/block/MapBlockDesigner.tsx +161 -0
- package/src/client/block/MapBlockInitializer.tsx +76 -0
- package/src/client/block/MapBlockProvider.tsx +55 -0
- package/src/client/block/index.tsx +35 -0
- package/src/client/block/utils.ts +81 -0
- package/src/client/components/AMap.tsx +148 -71
- package/src/client/components/Configuration.tsx +2 -1
- package/src/client/components/Map.tsx +5 -2
- package/src/client/components/ReadPretty.tsx +6 -5
- package/src/client/fields/schema.ts +4 -7
- package/src/client/hooks/useMapConfiguration.ts +32 -9
- package/src/client/index.tsx +11 -7
- package/src/client/initialize.tsx +2 -2
- package/src/client/locale/index.ts +4 -3
- package/src/client/locale/pt-BR.ts +49 -0
- package/src/client/locale/zh-CN.ts +22 -19
- package/src/server/collections/mapConfiguration.ts +8 -8
|
@@ -7,32 +7,32 @@ exports.default = void 0;
|
|
|
7
7
|
const locale = {
|
|
8
8
|
'Map-based geometry': '基于地图的几何图形',
|
|
9
9
|
'Map type': '地图类型',
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
Point: '点',
|
|
11
|
+
Line: '线',
|
|
12
|
+
Circle: '圆',
|
|
13
|
+
Polygon: '多边形',
|
|
14
14
|
'Access key': '访问密钥',
|
|
15
15
|
'securityJsCode or serviceHost': 'securityJsCode 或 serviceHost',
|
|
16
|
-
|
|
16
|
+
AMap: '高德地图',
|
|
17
17
|
'Google Maps': '谷歌地图',
|
|
18
|
-
|
|
18
|
+
Clear: '清空',
|
|
19
19
|
'Click to select the starting point and double-click to end the drawing': '点击选择起点,双击结束绘制',
|
|
20
20
|
'Clear the canvas': '清空画布',
|
|
21
21
|
'Are you sure to clear the canvas?': '您确定要清空画布吗?',
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
Confirm: '确定',
|
|
23
|
+
Cancel: '取消',
|
|
24
24
|
'Enter keywords to search': '输入地方名关键字搜索(必须包含省/市)',
|
|
25
25
|
'The AccessKey is incorrect, please check it': '访问密钥不正确,请检查',
|
|
26
26
|
'Please configure the AMap securityCode or serviceHost correctly': '请正确配置高德地图 securityCode 或 serviceHost',
|
|
27
27
|
'Map Manager': '地图管理',
|
|
28
|
-
|
|
28
|
+
Configuration: '配置',
|
|
29
29
|
'Saved successfully': '保存成功',
|
|
30
30
|
'Saved failed': '保存失败',
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
Edit: '编辑',
|
|
32
|
+
Save: '保存',
|
|
33
33
|
'Please configure the AccessKey and SecurityJsCode first': '请先配置 AccessKey 和 SecurityJsCode',
|
|
34
34
|
'Go to the configuration page': '前往配置页面',
|
|
35
|
-
|
|
35
|
+
Zoom: '缩放',
|
|
36
36
|
'Set default zoom level': '设置默认缩放级别',
|
|
37
37
|
'The default zoom level of the map': '地图默认缩放级别',
|
|
38
38
|
// Designer
|
|
@@ -40,12 +40,15 @@ const locale = {
|
|
|
40
40
|
'Field title': '字段标题',
|
|
41
41
|
'Edit tooltip': '编辑提示信息',
|
|
42
42
|
'Delete field': '删除字段',
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
Required: '必填',
|
|
44
|
+
Pattern: '模式',
|
|
45
|
+
"Operator": "运算符",
|
|
46
|
+
Editable: '可编辑',
|
|
47
|
+
Readonly: '只读(禁止编辑)',
|
|
48
|
+
'Easy-reading': '只读(阅读模式)',
|
|
49
|
+
'Edit description': '编辑描述',
|
|
50
|
+
'Map field': '地图字段',
|
|
51
|
+
'Marker field': '标记字段'
|
|
49
52
|
};
|
|
50
53
|
var _default = locale;
|
|
51
54
|
exports.default = _default;
|
package/lib/index.js
CHANGED
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.setConfiguration = exports.getConfiguration = void 0;
|
|
7
|
-
|
|
8
7
|
var _constants = require("../constants");
|
|
9
|
-
|
|
10
8
|
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); } }
|
|
11
|
-
|
|
12
9
|
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); }); }; }
|
|
13
|
-
|
|
14
10
|
const getConfiguration = /*#__PURE__*/function () {
|
|
15
11
|
var _ref = _asyncToGenerator(function* (ctx, next) {
|
|
16
12
|
const type = ctx.action.params.type;
|
|
@@ -23,14 +19,11 @@ const getConfiguration = /*#__PURE__*/function () {
|
|
|
23
19
|
ctx.body = record;
|
|
24
20
|
return next();
|
|
25
21
|
});
|
|
26
|
-
|
|
27
22
|
return function getConfiguration(_x, _x2) {
|
|
28
23
|
return _ref.apply(this, arguments);
|
|
29
24
|
};
|
|
30
25
|
}();
|
|
31
|
-
|
|
32
26
|
exports.getConfiguration = getConfiguration;
|
|
33
|
-
|
|
34
27
|
const setConfiguration = /*#__PURE__*/function () {
|
|
35
28
|
var _ref2 = _asyncToGenerator(function* (ctx, next) {
|
|
36
29
|
const values = ctx.action.params;
|
|
@@ -40,7 +33,6 @@ const setConfiguration = /*#__PURE__*/function () {
|
|
|
40
33
|
type: values.type
|
|
41
34
|
}
|
|
42
35
|
});
|
|
43
|
-
|
|
44
36
|
if (record) {
|
|
45
37
|
yield repo.update({
|
|
46
38
|
values,
|
|
@@ -53,14 +45,11 @@ const setConfiguration = /*#__PURE__*/function () {
|
|
|
53
45
|
values
|
|
54
46
|
});
|
|
55
47
|
}
|
|
56
|
-
|
|
57
48
|
ctx.body = 'ok';
|
|
58
49
|
return next();
|
|
59
50
|
});
|
|
60
|
-
|
|
61
51
|
return function setConfiguration(_x3, _x4) {
|
|
62
52
|
return _ref2.apply(this, arguments);
|
|
63
53
|
};
|
|
64
54
|
}();
|
|
65
|
-
|
|
66
55
|
exports.setConfiguration = setConfiguration;
|
|
@@ -4,11 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _constants = require("../constants");
|
|
9
|
-
|
|
10
8
|
var _default = {
|
|
11
|
-
namespace: 'map',
|
|
9
|
+
namespace: 'map.mapConfiguration',
|
|
12
10
|
duplicator: 'optional',
|
|
13
11
|
name: _constants.MapConfigurationCollectionName,
|
|
14
12
|
title: '{{t("Map Manager")}}',
|
|
@@ -4,73 +4,56 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CircleField = void 0;
|
|
7
|
-
|
|
8
7
|
function _database() {
|
|
9
8
|
const data = require("@nocobase/database");
|
|
10
|
-
|
|
11
9
|
_database = function _database() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _sequelize() {
|
|
19
15
|
const data = require("sequelize");
|
|
20
|
-
|
|
21
16
|
_sequelize = function _sequelize() {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
var _helpers = require("../helpers");
|
|
29
|
-
|
|
30
22
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
-
|
|
32
23
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
|
-
|
|
34
|
-
function
|
|
35
|
-
|
|
24
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
26
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
36
27
|
class Circle extends _sequelize().DataTypes.ABSTRACT {
|
|
37
28
|
constructor(...args) {
|
|
38
29
|
super(...args);
|
|
39
30
|
this.key = 'Circle';
|
|
40
31
|
}
|
|
41
|
-
|
|
42
32
|
}
|
|
43
|
-
|
|
44
33
|
class CircleField extends _database().Field {
|
|
45
34
|
constructor(options, context) {
|
|
46
35
|
const name = options.name;
|
|
47
36
|
super(_objectSpread({
|
|
48
37
|
get() {
|
|
49
38
|
const value = this.getDataValue(name);
|
|
50
|
-
|
|
51
39
|
if ((0, _helpers.isPg)(context)) {
|
|
52
40
|
if (typeof value === 'string') {
|
|
53
41
|
return (0, _helpers.toValue)(`(${value})`);
|
|
54
42
|
}
|
|
55
|
-
|
|
56
43
|
return value ? [value.x, value.y, value.radius] : null;
|
|
57
44
|
} else {
|
|
58
45
|
return value;
|
|
59
46
|
}
|
|
60
47
|
},
|
|
61
|
-
|
|
62
48
|
set(value) {
|
|
63
49
|
var _value;
|
|
64
|
-
|
|
65
50
|
if (!((_value = value) === null || _value === void 0 ? void 0 : _value.length)) value = null;else if ((0, _helpers.isPg)(context)) {
|
|
66
51
|
value = value.join(',');
|
|
67
52
|
}
|
|
68
53
|
this.setDataValue(name, value);
|
|
69
54
|
}
|
|
70
|
-
|
|
71
55
|
}, options), context);
|
|
72
56
|
}
|
|
73
|
-
|
|
74
57
|
get dataType() {
|
|
75
58
|
if ((0, _helpers.isPg)(this.context)) {
|
|
76
59
|
return Circle;
|
|
@@ -78,7 +61,5 @@ class CircleField extends _database().Field {
|
|
|
78
61
|
return _sequelize().DataTypes.JSON;
|
|
79
62
|
}
|
|
80
63
|
}
|
|
81
|
-
|
|
82
64
|
}
|
|
83
|
-
|
|
84
65
|
exports.CircleField = CircleField;
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _point = require("./point");
|
|
8
|
-
|
|
9
7
|
Object.keys(_point).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _point[key]) return;
|
|
@@ -16,9 +14,7 @@ Object.keys(_point).forEach(function (key) {
|
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
16
|
});
|
|
19
|
-
|
|
20
17
|
var _lineString = require("./lineString");
|
|
21
|
-
|
|
22
18
|
Object.keys(_lineString).forEach(function (key) {
|
|
23
19
|
if (key === "default" || key === "__esModule") return;
|
|
24
20
|
if (key in exports && exports[key] === _lineString[key]) return;
|
|
@@ -29,9 +25,7 @@ Object.keys(_lineString).forEach(function (key) {
|
|
|
29
25
|
}
|
|
30
26
|
});
|
|
31
27
|
});
|
|
32
|
-
|
|
33
28
|
var _polygon = require("./polygon");
|
|
34
|
-
|
|
35
29
|
Object.keys(_polygon).forEach(function (key) {
|
|
36
30
|
if (key === "default" || key === "__esModule") return;
|
|
37
31
|
if (key in exports && exports[key] === _polygon[key]) return;
|
|
@@ -42,9 +36,7 @@ Object.keys(_polygon).forEach(function (key) {
|
|
|
42
36
|
}
|
|
43
37
|
});
|
|
44
38
|
});
|
|
45
|
-
|
|
46
39
|
var _circle = require("./circle");
|
|
47
|
-
|
|
48
40
|
Object.keys(_circle).forEach(function (key) {
|
|
49
41
|
if (key === "default" || key === "__esModule") return;
|
|
50
42
|
if (key in exports && exports[key] === _circle[key]) return;
|
|
@@ -4,50 +4,38 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.LineStringField = void 0;
|
|
7
|
-
|
|
8
7
|
function _database() {
|
|
9
8
|
const data = require("@nocobase/database");
|
|
10
|
-
|
|
11
9
|
_database = function _database() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _sequelize() {
|
|
19
15
|
const data = require("sequelize");
|
|
20
|
-
|
|
21
16
|
_sequelize = function _sequelize() {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
var _helpers = require("../helpers");
|
|
29
|
-
|
|
30
22
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
-
|
|
32
23
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
|
-
|
|
34
|
-
function
|
|
35
|
-
|
|
24
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
26
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
36
27
|
class LineString extends _sequelize().DataTypes.ABSTRACT {
|
|
37
28
|
constructor(...args) {
|
|
38
29
|
super(...args);
|
|
39
30
|
this.key = 'Path';
|
|
40
31
|
}
|
|
41
|
-
|
|
42
32
|
}
|
|
43
|
-
|
|
44
33
|
class LineStringField extends _database().Field {
|
|
45
34
|
constructor(options, context) {
|
|
46
35
|
const name = options.name;
|
|
47
36
|
super(_objectSpread({
|
|
48
37
|
get() {
|
|
49
38
|
const value = this.getDataValue(name);
|
|
50
|
-
|
|
51
39
|
if ((0, _helpers.isPg)(context)) {
|
|
52
40
|
return (0, _helpers.toValue)(value);
|
|
53
41
|
} else if ((0, _helpers.isMysql)(context)) {
|
|
@@ -56,10 +44,8 @@ class LineStringField extends _database().Field {
|
|
|
56
44
|
return value;
|
|
57
45
|
}
|
|
58
46
|
},
|
|
59
|
-
|
|
60
47
|
set(value) {
|
|
61
48
|
var _value;
|
|
62
|
-
|
|
63
49
|
if (!((_value = value) === null || _value === void 0 ? void 0 : _value.length)) value = null;else if ((0, _helpers.isPg)(context)) {
|
|
64
50
|
value = (0, _helpers.joinComma)(value.map(_helpers.joinComma));
|
|
65
51
|
} else if ((0, _helpers.isMysql)(context)) {
|
|
@@ -70,22 +56,17 @@ class LineStringField extends _database().Field {
|
|
|
70
56
|
}
|
|
71
57
|
this.setDataValue(name, value);
|
|
72
58
|
}
|
|
73
|
-
|
|
74
59
|
}, options), context);
|
|
75
60
|
}
|
|
76
|
-
|
|
77
61
|
get dataType() {
|
|
78
62
|
if ((0, _helpers.isPg)(this.context)) {
|
|
79
63
|
return LineString;
|
|
80
64
|
}
|
|
81
|
-
|
|
82
65
|
if ((0, _helpers.isMysql)(this.context)) {
|
|
83
66
|
return _sequelize().DataTypes.GEOMETRY('LINESTRING');
|
|
84
67
|
} else {
|
|
85
68
|
return _sequelize().DataTypes.JSON;
|
|
86
69
|
}
|
|
87
70
|
}
|
|
88
|
-
|
|
89
71
|
}
|
|
90
|
-
|
|
91
72
|
exports.LineStringField = LineStringField;
|
|
@@ -4,55 +4,42 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.PointField = void 0;
|
|
7
|
-
|
|
8
7
|
function _database() {
|
|
9
8
|
const data = require("@nocobase/database");
|
|
10
|
-
|
|
11
9
|
_database = function _database() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _sequelize() {
|
|
19
15
|
const data = require("sequelize");
|
|
20
|
-
|
|
21
16
|
_sequelize = function _sequelize() {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
var _helpers = require("../helpers");
|
|
29
|
-
|
|
30
22
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
-
|
|
32
23
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
|
-
|
|
34
|
-
function
|
|
35
|
-
|
|
24
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
26
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
36
27
|
class Point extends _sequelize().DataTypes.ABSTRACT {
|
|
37
28
|
constructor(...args) {
|
|
38
29
|
super(...args);
|
|
39
30
|
this.key = 'Point';
|
|
40
31
|
}
|
|
41
|
-
|
|
42
32
|
}
|
|
43
|
-
|
|
44
33
|
class PointField extends _database().Field {
|
|
45
34
|
constructor(options, context) {
|
|
46
35
|
const name = options.name;
|
|
47
36
|
super(_objectSpread({
|
|
48
37
|
get() {
|
|
49
38
|
const value = this.getDataValue(name);
|
|
50
|
-
|
|
51
39
|
if ((0, _helpers.isPg)(context)) {
|
|
52
40
|
if (typeof value === 'string') {
|
|
53
41
|
return (0, _helpers.toValue)(value);
|
|
54
42
|
}
|
|
55
|
-
|
|
56
43
|
return value ? [value.x, value.y] : null;
|
|
57
44
|
} else if ((0, _helpers.isMysql)(context)) {
|
|
58
45
|
return (value === null || value === void 0 ? void 0 : value.coordinates) || null;
|
|
@@ -60,10 +47,8 @@ class PointField extends _database().Field {
|
|
|
60
47
|
return value;
|
|
61
48
|
}
|
|
62
49
|
},
|
|
63
|
-
|
|
64
50
|
set(value) {
|
|
65
51
|
var _value;
|
|
66
|
-
|
|
67
52
|
if (!((_value = value) === null || _value === void 0 ? void 0 : _value.length)) value = null;else if ((0, _helpers.isPg)(context)) {
|
|
68
53
|
value = (0, _helpers.joinComma)(value);
|
|
69
54
|
} else if ((0, _helpers.isMysql)(context)) {
|
|
@@ -74,22 +59,17 @@ class PointField extends _database().Field {
|
|
|
74
59
|
}
|
|
75
60
|
this.setDataValue(name, value);
|
|
76
61
|
}
|
|
77
|
-
|
|
78
62
|
}, options), context);
|
|
79
63
|
}
|
|
80
|
-
|
|
81
64
|
get dataType() {
|
|
82
65
|
if ((0, _helpers.isPg)(this.context)) {
|
|
83
66
|
return Point;
|
|
84
67
|
}
|
|
85
|
-
|
|
86
68
|
if ((0, _helpers.isMysql)(this.context)) {
|
|
87
69
|
return _sequelize().DataTypes.GEOMETRY('POINT');
|
|
88
70
|
} else {
|
|
89
71
|
return _sequelize().DataTypes.JSON;
|
|
90
72
|
}
|
|
91
73
|
}
|
|
92
|
-
|
|
93
74
|
}
|
|
94
|
-
|
|
95
75
|
exports.PointField = PointField;
|
|
@@ -4,50 +4,38 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.PolygonField = void 0;
|
|
7
|
-
|
|
8
7
|
function _database() {
|
|
9
8
|
const data = require("@nocobase/database");
|
|
10
|
-
|
|
11
9
|
_database = function _database() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _sequelize() {
|
|
19
15
|
const data = require("sequelize");
|
|
20
|
-
|
|
21
16
|
_sequelize = function _sequelize() {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
var _helpers = require("../helpers");
|
|
29
|
-
|
|
30
22
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
-
|
|
32
23
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
|
-
|
|
34
|
-
function
|
|
35
|
-
|
|
24
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
26
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
36
27
|
class Polygon extends _sequelize().DataTypes.ABSTRACT {
|
|
37
28
|
constructor(...args) {
|
|
38
29
|
super(...args);
|
|
39
30
|
this.key = 'Polygon';
|
|
40
31
|
}
|
|
41
|
-
|
|
42
32
|
}
|
|
43
|
-
|
|
44
33
|
class PolygonField extends _database().Field {
|
|
45
34
|
constructor(options, context) {
|
|
46
35
|
const name = options.name;
|
|
47
36
|
super(_objectSpread({
|
|
48
37
|
get() {
|
|
49
38
|
const value = this.getDataValue(name);
|
|
50
|
-
|
|
51
39
|
if ((0, _helpers.isPg)(context)) {
|
|
52
40
|
return (0, _helpers.toValue)(value);
|
|
53
41
|
} else if ((0, _helpers.isMysql)(context)) {
|
|
@@ -56,10 +44,8 @@ class PolygonField extends _database().Field {
|
|
|
56
44
|
return value;
|
|
57
45
|
}
|
|
58
46
|
},
|
|
59
|
-
|
|
60
47
|
set(value) {
|
|
61
48
|
var _value;
|
|
62
|
-
|
|
63
49
|
if (!((_value = value) === null || _value === void 0 ? void 0 : _value.length)) value = null;else if ((0, _helpers.isPg)(context)) {
|
|
64
50
|
value = (0, _helpers.joinComma)(value.map(item => (0, _helpers.joinComma)(item)));
|
|
65
51
|
} else if ((0, _helpers.isMysql)(context)) {
|
|
@@ -70,10 +56,8 @@ class PolygonField extends _database().Field {
|
|
|
70
56
|
}
|
|
71
57
|
this.setDataValue(name, value);
|
|
72
58
|
}
|
|
73
|
-
|
|
74
59
|
}, options), context);
|
|
75
60
|
}
|
|
76
|
-
|
|
77
61
|
get dataType() {
|
|
78
62
|
if ((0, _helpers.isPg)(this.context)) {
|
|
79
63
|
return Polygon;
|
|
@@ -83,7 +67,5 @@ class PolygonField extends _database().Field {
|
|
|
83
67
|
return _sequelize().DataTypes.JSON;
|
|
84
68
|
}
|
|
85
69
|
}
|
|
86
|
-
|
|
87
70
|
}
|
|
88
|
-
|
|
89
71
|
exports.PolygonField = PolygonField;
|
|
@@ -4,41 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.toValue = exports.joinComma = exports.isSqlite = exports.isPg = exports.isMysql = exports.getDialect = void 0;
|
|
7
|
-
|
|
8
7
|
const joinComma = value => {
|
|
9
8
|
if (!value) return null;
|
|
10
9
|
return `(${value.join(',')})`;
|
|
11
10
|
};
|
|
12
|
-
|
|
13
11
|
exports.joinComma = joinComma;
|
|
14
|
-
|
|
15
12
|
const toValue = value => {
|
|
16
13
|
if (!value) return null;
|
|
17
14
|
return JSON.parse(value.replace(/\(/g, '[').replace(/\)/g, ']'));
|
|
18
15
|
};
|
|
19
|
-
|
|
20
16
|
exports.toValue = toValue;
|
|
21
|
-
|
|
22
17
|
const getDialect = ctx => {
|
|
23
18
|
return (ctx.db || ctx.database).sequelize.getDialect();
|
|
24
19
|
};
|
|
25
|
-
|
|
26
20
|
exports.getDialect = getDialect;
|
|
27
|
-
|
|
28
21
|
const isPg = ctx => {
|
|
29
22
|
return getDialect(ctx) === 'postgres';
|
|
30
23
|
};
|
|
31
|
-
|
|
32
24
|
exports.isPg = isPg;
|
|
33
|
-
|
|
34
25
|
const isSqlite = ctx => {
|
|
35
26
|
return getDialect(ctx) === 'sqlite';
|
|
36
27
|
};
|
|
37
|
-
|
|
38
28
|
exports.isSqlite = isSqlite;
|
|
39
|
-
|
|
40
29
|
const isMysql = ctx => {
|
|
41
30
|
return getDialect(ctx) === 'mysql';
|
|
42
31
|
};
|
|
43
|
-
|
|
44
32
|
exports.isMysql = isMysql;
|
package/lib/server/index.js
CHANGED