@steedos/service-ui 2.7.27-beta.6 → 3.0.0-beta.8
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/main/default/routes/apps.router.js +2 -2
- package/main/default/routes/objects.router.js +9 -13
- package/main/default/routes/objects.router.todo.js +2 -2
- package/package.json +5 -5
- package/src/routes/apps.router.ts +2 -2
- package/src/routes/objects.router.ts +18 -16
- package/main/default/client/cordova.push.client.js +0 -112
- package/public/steedos-init.js +0 -181
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
4
|
+
const auth_1 = require("@steedos/auth");
|
|
5
5
|
const objectql_1 = require("@steedos/objectql");
|
|
6
6
|
const express = require('express');
|
|
7
7
|
const router = express.Router();
|
|
8
|
-
router.get('/service/api/apps/menus',
|
|
8
|
+
router.get('/service/api/apps/menus', auth_1.requireAuthentication, function (req, res) {
|
|
9
9
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
10
|
const userSession = req.user;
|
|
11
11
|
const mobile = req.query && req.query.mobile;
|
|
@@ -4,7 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const objectql_1 = require("@steedos/objectql");
|
|
5
5
|
const express = require('express');
|
|
6
6
|
const router = express.Router();
|
|
7
|
-
const
|
|
7
|
+
const auth = require('@steedos/auth');
|
|
8
8
|
const callObjectServiceAction = function (actionName, userSession, data) {
|
|
9
9
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
10
|
const broker = (0, objectql_1.getSteedosSchema)().broker;
|
|
@@ -14,7 +14,7 @@ const callObjectServiceAction = function (actionName, userSession, data) {
|
|
|
14
14
|
const getObjectName = function (objectServiceName) {
|
|
15
15
|
return objectServiceName.substring(1);
|
|
16
16
|
};
|
|
17
|
-
router.get('/service/api/:objectServiceName/fields',
|
|
17
|
+
router.get('/service/api/:objectServiceName/fields', auth.requireAuthentication, function (req, res) {
|
|
18
18
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
const userSession = req.user;
|
|
20
20
|
try {
|
|
@@ -27,7 +27,7 @@ router.get('/service/api/:objectServiceName/fields', core.requireAuthentication,
|
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
|
-
router.get('/service/api/:objectServiceName/getUserObjectPermission',
|
|
30
|
+
router.get('/service/api/:objectServiceName/getUserObjectPermission', auth.requireAuthentication, function (req, res) {
|
|
31
31
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
32
32
|
const userSession = req.user;
|
|
33
33
|
try {
|
|
@@ -40,7 +40,7 @@ router.get('/service/api/:objectServiceName/getUserObjectPermission', core.requi
|
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
|
-
router.get('/service/api/:objectServiceName/recordPermissions/:recordId',
|
|
43
|
+
router.get('/service/api/:objectServiceName/recordPermissions/:recordId', auth.requireAuthentication, function (req, res) {
|
|
44
44
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
45
45
|
const userSession = req.user;
|
|
46
46
|
try {
|
|
@@ -56,19 +56,15 @@ router.get('/service/api/:objectServiceName/recordPermissions/:recordId', core.r
|
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
|
-
router.get('/service/api/:objectServiceName/uiSchema',
|
|
59
|
+
router.get('/service/api/:objectServiceName/uiSchema', auth.requireAuthentication, function (req, res) {
|
|
60
60
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
61
|
const userSession = req.user;
|
|
62
62
|
try {
|
|
63
63
|
const { objectServiceName } = req.params;
|
|
64
64
|
const objectName = objectServiceName.substring(1);
|
|
65
|
-
const [result
|
|
65
|
+
const [result] = yield Promise.all([
|
|
66
66
|
callObjectServiceAction(`objectql.getRecordView`, userSession, { objectName }),
|
|
67
|
-
callObjectServiceAction(`@steedos/data-import.hasImportTemplates`, userSession, {
|
|
68
|
-
objectName: objectName
|
|
69
|
-
})
|
|
70
67
|
]);
|
|
71
|
-
result.hasImportTemplates = hasImportTemplates;
|
|
72
68
|
res.status(200).send(result);
|
|
73
69
|
}
|
|
74
70
|
catch (error) {
|
|
@@ -76,7 +72,7 @@ router.get('/service/api/:objectServiceName/uiSchema', core.requireAuthenticatio
|
|
|
76
72
|
}
|
|
77
73
|
});
|
|
78
74
|
});
|
|
79
|
-
router.post('/service/api/:objectServiceName/defUiSchema',
|
|
75
|
+
router.post('/service/api/:objectServiceName/defUiSchema', auth.requireAuthentication, function (req, res) {
|
|
80
76
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
81
77
|
const userSession = req.user;
|
|
82
78
|
try {
|
|
@@ -89,7 +85,7 @@ router.post('/service/api/:objectServiceName/defUiSchema', core.requireAuthentic
|
|
|
89
85
|
}
|
|
90
86
|
});
|
|
91
87
|
});
|
|
92
|
-
router.get('/service/api/:objectServiceName/uiSchemaTemplate',
|
|
88
|
+
router.get('/service/api/:objectServiceName/uiSchemaTemplate', auth.requireAuthentication, function (req, res) {
|
|
93
89
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
94
90
|
const userSession = req.user;
|
|
95
91
|
try {
|
|
@@ -102,7 +98,7 @@ router.get('/service/api/:objectServiceName/uiSchemaTemplate', core.requireAuthe
|
|
|
102
98
|
}
|
|
103
99
|
});
|
|
104
100
|
});
|
|
105
|
-
router.get('/service/api/:objectServiceName/relateds',
|
|
101
|
+
router.get('/service/api/:objectServiceName/relateds', auth.requireAuthentication, function (req, res) {
|
|
106
102
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
107
103
|
const userSession = req.user;
|
|
108
104
|
try {
|
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
const express = require("express");
|
|
11
11
|
const router =require('@steedos/router').staticRouter()
|
|
12
|
-
const
|
|
13
|
-
router.get('/service/api/:objectServiceName/uiSchema',
|
|
12
|
+
const auth = require('@steedos/auth');
|
|
13
|
+
router.get('/service/api/:objectServiceName/uiSchema', auth.requireAuthentication, function (req, res) {
|
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
// const userSession = req.user;
|
|
16
16
|
// const spaceId = userSession.spaceId;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.8",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"steedos"
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"description": "steedos package",
|
|
12
12
|
"repository": {},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@steedos/
|
|
15
|
-
"@steedos/i18n": "
|
|
16
|
-
"@steedos/objectql": "
|
|
14
|
+
"@steedos/auth": "3.0.0-beta.8",
|
|
15
|
+
"@steedos/i18n": "3.0.0-beta.8",
|
|
16
|
+
"@steedos/objectql": "3.0.0-beta.8",
|
|
17
17
|
"express": "4.18.1"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "723d92765db5342a374c7aacb5b835e69f77ca4b"
|
|
25
25
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* @Author: baozhoutao@steedos.com
|
|
3
3
|
* @Date: 2022-06-08 23:28:39
|
|
4
4
|
* @LastEditors: baozhoutao@steedos.com
|
|
5
|
-
* @LastEditTime:
|
|
5
|
+
* @LastEditTime: 2025-01-21 17:24:29
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
|
-
import { requireAuthentication } from '@steedos/
|
|
8
|
+
import { requireAuthentication } from '@steedos/auth';
|
|
9
9
|
import { getSteedosSchema } from '@steedos/objectql';
|
|
10
10
|
const express = require('express');
|
|
11
11
|
const router =express.Router();
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: baozhoutao@steedos.com
|
|
3
3
|
* @Date: 2022-06-09 10:19:47
|
|
4
|
-
* @LastEditors:
|
|
5
|
-
* @LastEditTime:
|
|
4
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
5
|
+
* @LastEditTime: 2025-02-18 11:47:54
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
import { getSteedosSchema } from "@steedos/objectql";
|
|
9
9
|
const express = require('express');
|
|
10
10
|
const router =express.Router();
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const auth = require('@steedos/auth');
|
|
13
12
|
|
|
14
13
|
const callObjectServiceAction = async function(actionName, userSession, data?){
|
|
15
14
|
const broker = getSteedosSchema().broker;
|
|
@@ -20,7 +19,7 @@ const getObjectName = function(objectServiceName){
|
|
|
20
19
|
return objectServiceName.substring(1);
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
router.get('/service/api/:objectServiceName/fields',
|
|
22
|
+
router.get('/service/api/:objectServiceName/fields', auth.requireAuthentication, async function (req, res) {
|
|
24
23
|
const userSession = req.user;
|
|
25
24
|
try {
|
|
26
25
|
const { objectServiceName } = req.params;
|
|
@@ -31,7 +30,7 @@ router.get('/service/api/:objectServiceName/fields', core.requireAuthentication,
|
|
|
31
30
|
}
|
|
32
31
|
});
|
|
33
32
|
|
|
34
|
-
router.get('/service/api/:objectServiceName/getUserObjectPermission',
|
|
33
|
+
router.get('/service/api/:objectServiceName/getUserObjectPermission', auth.requireAuthentication, async function (req, res) {
|
|
35
34
|
const userSession = req.user;
|
|
36
35
|
try {
|
|
37
36
|
const { objectServiceName } = req.params;
|
|
@@ -42,7 +41,7 @@ router.get('/service/api/:objectServiceName/getUserObjectPermission', core.requi
|
|
|
42
41
|
}
|
|
43
42
|
});
|
|
44
43
|
|
|
45
|
-
router.get('/service/api/:objectServiceName/recordPermissions/:recordId',
|
|
44
|
+
router.get('/service/api/:objectServiceName/recordPermissions/:recordId', auth.requireAuthentication, async function (req, res) {
|
|
46
45
|
const userSession = req.user;
|
|
47
46
|
try {
|
|
48
47
|
const { objectServiceName, recordId } = req.params;
|
|
@@ -56,25 +55,28 @@ router.get('/service/api/:objectServiceName/recordPermissions/:recordId', core.r
|
|
|
56
55
|
}
|
|
57
56
|
});
|
|
58
57
|
|
|
59
|
-
router.get('/service/api/:objectServiceName/uiSchema',
|
|
58
|
+
router.get('/service/api/:objectServiceName/uiSchema', auth.requireAuthentication, async function (req, res) {
|
|
60
59
|
const userSession = req.user;
|
|
61
60
|
try {
|
|
62
61
|
const { objectServiceName } = req.params;
|
|
63
62
|
const objectName = objectServiceName.substring(1);
|
|
64
|
-
const [ result, hasImportTemplates ] = await Promise.all([
|
|
63
|
+
// const [ result, hasImportTemplates ] = await Promise.all([
|
|
64
|
+
// callObjectServiceAction(`objectql.getRecordView`, userSession, { objectName }),
|
|
65
|
+
// callObjectServiceAction(`@steedos/data-import.hasImportTemplates`, userSession, {
|
|
66
|
+
// objectName: objectName
|
|
67
|
+
// })
|
|
68
|
+
// ])
|
|
69
|
+
// result.hasImportTemplates = hasImportTemplates //TODO 这段查的有点多
|
|
70
|
+
const [ result ] = await Promise.all([
|
|
65
71
|
callObjectServiceAction(`objectql.getRecordView`, userSession, { objectName }),
|
|
66
|
-
callObjectServiceAction(`@steedos/data-import.hasImportTemplates`, userSession, {
|
|
67
|
-
objectName: objectName
|
|
68
|
-
})
|
|
69
72
|
])
|
|
70
|
-
result.hasImportTemplates = hasImportTemplates
|
|
71
73
|
res.status(200).send(result);
|
|
72
74
|
} catch (error) {
|
|
73
75
|
res.status(500).send(error.message);
|
|
74
76
|
}
|
|
75
77
|
});
|
|
76
78
|
|
|
77
|
-
router.post('/service/api/:objectServiceName/defUiSchema',
|
|
79
|
+
router.post('/service/api/:objectServiceName/defUiSchema', auth.requireAuthentication, async function (req, res) {
|
|
78
80
|
const userSession = req.user;
|
|
79
81
|
try {
|
|
80
82
|
const { objectServiceName } = req.params;
|
|
@@ -85,7 +87,7 @@ router.post('/service/api/:objectServiceName/defUiSchema', core.requireAuthentic
|
|
|
85
87
|
}
|
|
86
88
|
});
|
|
87
89
|
|
|
88
|
-
router.get('/service/api/:objectServiceName/uiSchemaTemplate',
|
|
90
|
+
router.get('/service/api/:objectServiceName/uiSchemaTemplate', auth.requireAuthentication, async function (req, res) {
|
|
89
91
|
const userSession = req.user;
|
|
90
92
|
try {
|
|
91
93
|
const { objectServiceName } = req.params;
|
|
@@ -96,7 +98,7 @@ router.get('/service/api/:objectServiceName/uiSchemaTemplate', core.requireAuthe
|
|
|
96
98
|
}
|
|
97
99
|
});
|
|
98
100
|
|
|
99
|
-
router.get('/service/api/:objectServiceName/relateds',
|
|
101
|
+
router.get('/service/api/:objectServiceName/relateds', auth.requireAuthentication, async function (req, res) {
|
|
100
102
|
const userSession = req.user;
|
|
101
103
|
try {
|
|
102
104
|
const { objectServiceName } = req.params;
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
if (Meteor.isCordova) {
|
|
2
|
-
Meteor.startup(function () {
|
|
3
|
-
const hasRegister = function () {
|
|
4
|
-
let has = false;
|
|
5
|
-
if (Push.push.handlers.notification && Push.push.handlers.notification.length > 0) {
|
|
6
|
-
Push.push.handlers.notification.forEach(function (handler) {
|
|
7
|
-
if (handler.toString().indexOf('push.setApplicationIconBadgeNumber') > 0) {
|
|
8
|
-
has = true
|
|
9
|
-
}
|
|
10
|
-
})
|
|
11
|
-
}
|
|
12
|
-
return has;
|
|
13
|
-
}
|
|
14
|
-
document.addEventListener("deviceready", function () {
|
|
15
|
-
return window.setTimeout(function () {
|
|
16
|
-
var ref, ref1;
|
|
17
|
-
|
|
18
|
-
if (hasRegister() == true) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
console.log('app注册push失败, 由client js注册push')
|
|
22
|
-
Push.push.on("notification", function (data) {
|
|
23
|
-
var host, path;
|
|
24
|
-
if (data.additionalData.foreground === true) {
|
|
25
|
-
if (data.count > -1) {
|
|
26
|
-
push.setApplicationIconBadgeNumber(
|
|
27
|
-
function () { },
|
|
28
|
-
function () { },
|
|
29
|
-
data.count
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
if (typeof data.additionalData.ejson === "string") {
|
|
35
|
-
data.additionalData.ejson = JSON.parse(data.additionalData.ejson);
|
|
36
|
-
}
|
|
37
|
-
host = data.additionalData.ejson.host;
|
|
38
|
-
if (host == null) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
host = host.replace(/\/$/, "");
|
|
42
|
-
if (Servers.serverExists(host) !== true) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
window.AUTOLOAD = false;
|
|
46
|
-
if (data.additionalData.ejson.url) {
|
|
47
|
-
return FlowRouter.go(data.additionalData.ejson.url);
|
|
48
|
-
} else {
|
|
49
|
-
path = "";
|
|
50
|
-
if (
|
|
51
|
-
data.additionalData.ejson.space &&
|
|
52
|
-
data.additionalData.ejson.instance
|
|
53
|
-
) {
|
|
54
|
-
path =
|
|
55
|
-
"workflow/space/" +
|
|
56
|
-
data.additionalData.ejson.space +
|
|
57
|
-
"/inbox/" +
|
|
58
|
-
data.additionalData.ejson.instance;
|
|
59
|
-
}
|
|
60
|
-
navigator.splashscreen.hide();
|
|
61
|
-
if (window.Session && window.Session.get("spaceId")) {
|
|
62
|
-
return FlowRouter.go("/" + path);
|
|
63
|
-
} else {
|
|
64
|
-
return Servers.startServer(host, path, function (err, url) {
|
|
65
|
-
if (err != null) {
|
|
66
|
-
return console.log(err);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
if (
|
|
73
|
-
((ref = device.manufacturer) != null ? ref.toLowerCase() : void 0) ===
|
|
74
|
-
"huawei" &&
|
|
75
|
-
cordova.plugins.huaweipush
|
|
76
|
-
) {
|
|
77
|
-
cordova.plugins.huaweipush.init();
|
|
78
|
-
return document.addEventListener(
|
|
79
|
-
"huaweipush.receiveRegisterResult",
|
|
80
|
-
function (event) {
|
|
81
|
-
var registrationId;
|
|
82
|
-
console.log(event);
|
|
83
|
-
registrationId = "huawei:" + event.token;
|
|
84
|
-
Push.push.emit("registration", {
|
|
85
|
-
registrationId: registrationId,
|
|
86
|
-
});
|
|
87
|
-
}.bind(this),
|
|
88
|
-
false
|
|
89
|
-
);
|
|
90
|
-
} else if (
|
|
91
|
-
((ref1 = device.manufacturer) != null ? ref1.toLowerCase() : void 0) ===
|
|
92
|
-
"xiaomi" &&
|
|
93
|
-
window.plugins.MiPushPlugin
|
|
94
|
-
) {
|
|
95
|
-
window.plugins.MiPushPlugin.init();
|
|
96
|
-
return document.addEventListener(
|
|
97
|
-
"mipush.receiveRegisterResult",
|
|
98
|
-
function (data) {
|
|
99
|
-
var registrationId;
|
|
100
|
-
console.log(data);
|
|
101
|
-
registrationId = "mi:" + data.regId;
|
|
102
|
-
Push.push.emit("registration", {
|
|
103
|
-
registrationId: registrationId,
|
|
104
|
-
});
|
|
105
|
-
},
|
|
106
|
-
false
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
}, 1000);
|
|
110
|
-
});
|
|
111
|
-
})
|
|
112
|
-
}
|
package/public/steedos-init.js
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: baozhoutao@steedos.com
|
|
3
|
-
* @Date: 2023-02-26 15:22:12
|
|
4
|
-
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
5
|
-
* @LastEditTime: 2024-01-04 16:44:08
|
|
6
|
-
* @Description:
|
|
7
|
-
*/
|
|
8
|
-
try {
|
|
9
|
-
Steedos.authRequest = function (url, options) {
|
|
10
|
-
var userSession = Creator.USER_CONTEXT;
|
|
11
|
-
var spaceId = userSession.spaceId;
|
|
12
|
-
var authToken = userSession.authToken
|
|
13
|
-
? userSession.authToken
|
|
14
|
-
: userSession.user.authToken;
|
|
15
|
-
var result = null;
|
|
16
|
-
url = Steedos.absoluteUrl(url);
|
|
17
|
-
try {
|
|
18
|
-
var authorization = "Bearer " + spaceId + "," + authToken;
|
|
19
|
-
var headers = [
|
|
20
|
-
{
|
|
21
|
-
name: "Content-Type",
|
|
22
|
-
value: "application/json",
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: "Authorization",
|
|
26
|
-
value: authorization,
|
|
27
|
-
},
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
var defOptions = {
|
|
31
|
-
type: "get",
|
|
32
|
-
url: url,
|
|
33
|
-
dataType: "json",
|
|
34
|
-
contentType: "application/json",
|
|
35
|
-
beforeSend: function (XHR) {
|
|
36
|
-
if (headers && headers.length) {
|
|
37
|
-
return headers.forEach(function (header) {
|
|
38
|
-
return XHR.setRequestHeader(header.name, header.value);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
success: function (data) {
|
|
43
|
-
result = data;
|
|
44
|
-
},
|
|
45
|
-
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
46
|
-
console.error(XMLHttpRequest.responseJSON);
|
|
47
|
-
if (
|
|
48
|
-
XMLHttpRequest.responseJSON &&
|
|
49
|
-
XMLHttpRequest.responseJSON.error
|
|
50
|
-
) {
|
|
51
|
-
const errorInfo = XMLHttpRequest.responseJSON.error;
|
|
52
|
-
result = { error: errorInfo };
|
|
53
|
-
let errorMsg;
|
|
54
|
-
if (errorInfo.reason) {
|
|
55
|
-
errorMsg = errorInfo.reason;
|
|
56
|
-
} else if (errorInfo.message) {
|
|
57
|
-
errorMsg = errorInfo.message;
|
|
58
|
-
} else {
|
|
59
|
-
errorMsg = errorInfo;
|
|
60
|
-
}
|
|
61
|
-
toastr.error(t(errorMsg.replace(/:/g, ":")));
|
|
62
|
-
} else {
|
|
63
|
-
toastr.error(XMLHttpRequest.responseJSON);
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
$.ajax(Object.assign({}, defOptions, options));
|
|
68
|
-
return result;
|
|
69
|
-
} catch (err) {
|
|
70
|
-
console.error(err);
|
|
71
|
-
toastr.error(err);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
window.UI_SCHEMA_CACHE = {};
|
|
76
|
-
|
|
77
|
-
const setUISchemaCache = (key, value) => {
|
|
78
|
-
UI_SCHEMA_CACHE[key] = value;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const getUISchemaCache = (key) => {
|
|
82
|
-
return _.cloneDeep(UI_SCHEMA_CACHE[key]);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const hasUISchemaCache = (key) => {
|
|
86
|
-
return _.has(UI_SCHEMA_CACHE, key);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
function formatUISchemaCache(objectName, uiSchema) {
|
|
90
|
-
setUISchemaCache(objectName, uiSchema);
|
|
91
|
-
_.each(uiSchema.fields, (field) => {
|
|
92
|
-
try {
|
|
93
|
-
if (
|
|
94
|
-
field.type === "lookup" &&
|
|
95
|
-
field._reference_to &&
|
|
96
|
-
_.isString(field._reference_to)
|
|
97
|
-
) {
|
|
98
|
-
field.reference_to = eval(`(${field._reference_to})`)();
|
|
99
|
-
}
|
|
100
|
-
} catch (exception) {
|
|
101
|
-
field.reference_to = undefined;
|
|
102
|
-
console.error(exception);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
_.each(uiSchema.list_views, (v, k) => {
|
|
106
|
-
v.name = k;
|
|
107
|
-
if (!_.has(v, "columns")) {
|
|
108
|
-
v.columns = uiSchema.list_views.all.columns;
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
window.getUISchemaSync = (objectName, force) => {
|
|
114
|
-
if (!objectName) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
if (hasUISchemaCache(objectName) && !force) {
|
|
118
|
-
return getUISchemaCache(objectName);
|
|
119
|
-
}
|
|
120
|
-
let uiSchema = null;
|
|
121
|
-
try {
|
|
122
|
-
const url = `/service/api/@${objectName.replace(/\./g, "_")}/uiSchema`;
|
|
123
|
-
uiSchema = Steedos.authRequest(url, {
|
|
124
|
-
type: "GET",
|
|
125
|
-
async: false,
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
if (!uiSchema) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
formatUISchemaCache(objectName, uiSchema);
|
|
132
|
-
} catch (error) {
|
|
133
|
-
console.error(`getUISchema`, objectName, error);
|
|
134
|
-
setUISchemaCache(objectName, null);
|
|
135
|
-
}
|
|
136
|
-
return getUISchemaCache(objectName);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
window.getFirstListView = (objectName) => {
|
|
140
|
-
const uiSchema = window.getUISchemaSync(objectName);
|
|
141
|
-
const disabled_list_views = uiSchema.permissions.disabled_list_views;
|
|
142
|
-
return _.first(_.sortBy(_.values(
|
|
143
|
-
_.filter(uiSchema.list_views, function (o, k) {
|
|
144
|
-
return disabled_list_views.indexOf(o._id) < 0 && k !== "lookup";
|
|
145
|
-
})
|
|
146
|
-
), "sort_no"));
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
window.getAppsSync = () => {
|
|
150
|
-
const isMobile = Steedos.isMobile()
|
|
151
|
-
let data = { };
|
|
152
|
-
if(isMobile){
|
|
153
|
-
data.mobile = isMobile
|
|
154
|
-
}
|
|
155
|
-
const url = "/service/api/apps/menus";
|
|
156
|
-
const apps = Steedos.authRequest(url, {
|
|
157
|
-
type: "GET",
|
|
158
|
-
async: false,
|
|
159
|
-
data
|
|
160
|
-
});
|
|
161
|
-
return apps;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
window.Steedos.getFirstApp = ()=>{
|
|
165
|
-
const apps = window.getAppsSync();
|
|
166
|
-
return _.first(apps);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
window.Creator.getObjectRecord = (objectName, recordId, select_fields, expand)=>{
|
|
170
|
-
return Creator.odata.get(objectName, recordId, select_fields, expand)
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
window.Creator.isSpaceAdmin = ()=>{
|
|
174
|
-
return Creator.USER_CONTEXT.user.is_space_admin;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
Creator.steedosInit.set(true);
|
|
179
|
-
} catch (error) {
|
|
180
|
-
console.error(error);
|
|
181
|
-
}
|