@saltcorn/server 0.7.4-beta.0 → 0.7.4-beta.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/locales/en.json +19 -1
- package/locales/it.json +2 -1
- package/locales/ru.json +42 -6
- package/markup/plugin-store.js +5 -5
- package/package.json +7 -7
- package/public/saltcorn-builder.css +75 -0
- package/public/saltcorn.css +4 -0
- package/routes/admin.js +131 -108
- package/routes/fields.js +11 -13
- package/routes/homepage.js +60 -60
- package/routes/menu.js +65 -4
- package/routes/packs.js +4 -4
- package/routes/plugins.js +116 -118
- package/routes/settings.js +3 -3
- package/routes/tables.js +187 -187
- package/routes/tenant.js +27 -27
- package/routes/viewedit.js +68 -68
- package/tests/admin.test.js +1 -1
- package/tests/plugins.test.js +1 -1
- package/tests/viewedit.test.js +1 -1
- package/wrapper.js +57 -55
package/routes/viewedit.js
CHANGED
|
@@ -145,57 +145,57 @@ router.get(
|
|
|
145
145
|
const viewMarkup =
|
|
146
146
|
views.length > 0
|
|
147
147
|
? mkTable(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
148
|
+
[
|
|
149
|
+
{
|
|
150
|
+
label: req.__("Name"),
|
|
151
|
+
key: (r) => link(`/view/${encodeURIComponent(r.name)}`, r.name),
|
|
152
|
+
sortlink: `javascript:set_state_field('_sortby', 'name')`,
|
|
153
|
+
},
|
|
154
|
+
// description - currently I dont want to show description in view list
|
|
155
|
+
// because description can be long
|
|
156
|
+
/*
|
|
157
|
+
{
|
|
158
|
+
label: req.__("Description"),
|
|
159
|
+
key: "description",
|
|
160
|
+
// this is sorting by column
|
|
161
|
+
sortlink: `javascript:set_state_field('_sortby', 'description')`,
|
|
162
|
+
},
|
|
163
|
+
*/
|
|
164
|
+
// template
|
|
165
|
+
{
|
|
166
|
+
label: req.__("Pattern"),
|
|
167
|
+
key: "viewtemplate",
|
|
168
|
+
sortlink: `javascript:set_state_field('_sortby', 'viewtemplate')`,
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
label: req.__("Table"),
|
|
172
|
+
key: (r) => link(`/table/${r.table}`, r.table),
|
|
173
|
+
sortlink: `javascript:set_state_field('_sortby', 'table')`,
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
label: req.__("Role to access"),
|
|
177
|
+
key: (row) => editViewRoleForm(row, roles, req),
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
label: "",
|
|
181
|
+
key: (r) =>
|
|
182
|
+
link(
|
|
183
|
+
`/viewedit/config/${encodeURIComponent(r.name)}`,
|
|
184
|
+
req.__("Configure")
|
|
185
|
+
),
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
label: "",
|
|
189
|
+
key: (r) => view_dropdown(r, req),
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
views,
|
|
193
|
+
{ hover: true }
|
|
194
|
+
)
|
|
195
195
|
: div(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
h4(req.__("No views defined")),
|
|
197
|
+
p(req.__("Views define how table rows are displayed to the user"))
|
|
198
|
+
);
|
|
199
199
|
res.sendWrap(req.__(`Views`), {
|
|
200
200
|
above: [
|
|
201
201
|
{
|
|
@@ -210,14 +210,14 @@ router.get(
|
|
|
210
210
|
viewMarkup,
|
|
211
211
|
tables.length > 0
|
|
212
212
|
? a(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
{ href: `/viewedit/new`, class: "btn btn-primary" },
|
|
214
|
+
req.__("Create view")
|
|
215
|
+
)
|
|
216
216
|
: p(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
req.__(
|
|
218
|
+
"You must create at least one table before you can create views."
|
|
219
|
+
)
|
|
220
|
+
),
|
|
221
221
|
],
|
|
222
222
|
},
|
|
223
223
|
],
|
|
@@ -270,10 +270,10 @@ const viewForm = async (req, tableOptions, roles, pages, values) => {
|
|
|
270
270
|
),
|
|
271
271
|
}),
|
|
272
272
|
new Field({
|
|
273
|
-
label: req.__("
|
|
273
|
+
label: req.__("View pattern"),
|
|
274
274
|
name: "viewtemplate",
|
|
275
275
|
input_type: "select",
|
|
276
|
-
sublabel: req.__("
|
|
276
|
+
sublabel: req.__("The view pattern sets the foundation of how the view relates to the table and the behaviour of the view"),
|
|
277
277
|
options: Object.keys(getState().viewtemplates),
|
|
278
278
|
attributes: {
|
|
279
279
|
explainers: mapObjectValues(
|
|
@@ -327,15 +327,15 @@ const viewForm = async (req, tableOptions, roles, pages, values) => {
|
|
|
327
327
|
}),
|
|
328
328
|
...(isEdit
|
|
329
329
|
? [
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
330
|
+
new Field({
|
|
331
|
+
name: "viewtemplate",
|
|
332
|
+
input_type: "hidden",
|
|
333
|
+
}),
|
|
334
|
+
new Field({
|
|
335
|
+
name: "table_name",
|
|
336
|
+
input_type: "hidden",
|
|
337
|
+
}),
|
|
338
|
+
]
|
|
339
339
|
: []),
|
|
340
340
|
],
|
|
341
341
|
values,
|
package/tests/admin.test.js
CHANGED
|
@@ -57,7 +57,7 @@ describe("admin page", () => {
|
|
|
57
57
|
await request(app)
|
|
58
58
|
.get("/settings")
|
|
59
59
|
.set("Cookie", loginCookie)
|
|
60
|
-
.expect(toInclude("
|
|
60
|
+
.expect(toInclude("Module installation and control"));
|
|
61
61
|
});
|
|
62
62
|
it("show admin page", async () => {
|
|
63
63
|
const app = await getApp({ disableCsrf: true });
|
package/tests/plugins.test.js
CHANGED
package/tests/viewedit.test.js
CHANGED
|
@@ -54,7 +54,7 @@ describe("viewedit new List", () => {
|
|
|
54
54
|
await request(app)
|
|
55
55
|
.get("/viewedit/new")
|
|
56
56
|
.set("Cookie", loginCookie)
|
|
57
|
-
.expect(toInclude("
|
|
57
|
+
.expect(toInclude("View pattern"));
|
|
58
58
|
});
|
|
59
59
|
it("submit new view", async () => {
|
|
60
60
|
const loginCookie = await getAdminLoginCookie();
|
package/wrapper.js
CHANGED
|
@@ -13,7 +13,7 @@ const renderLayout = require("@saltcorn/markup/layout");
|
|
|
13
13
|
* @returns {T[]}
|
|
14
14
|
*/
|
|
15
15
|
const getFlashes = (req) =>
|
|
16
|
-
["error", "success", "danger", "warning","information"]
|
|
16
|
+
["error", "success", "danger", "warning", "information"]
|
|
17
17
|
.map((type) => {
|
|
18
18
|
return { type, msg: req.flash(type) };
|
|
19
19
|
})
|
|
@@ -44,11 +44,13 @@ const get_extra_menu = (role, state, req) => {
|
|
|
44
44
|
link:
|
|
45
45
|
item.type === "Link"
|
|
46
46
|
? item.url
|
|
47
|
-
: item.type === "
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
: item.type === "Action"
|
|
48
|
+
? `javascript:ajax_post_json('/menu/runaction/${item.action_name}')`
|
|
49
|
+
: item.type === "View"
|
|
50
|
+
? `/view/${encodeURIComponent(item.viewname)}`
|
|
51
|
+
: item.type === "Page"
|
|
52
|
+
? `/page/${encodeURIComponent(item.pagename)}`
|
|
53
|
+
: undefined,
|
|
52
54
|
...(item.subitems ? { subitems: transform(item.subitems) } : {}),
|
|
53
55
|
}));
|
|
54
56
|
return transform(cfg);
|
|
@@ -68,41 +70,41 @@ const get_menu = (req) => {
|
|
|
68
70
|
const extra_menu = get_extra_menu(role, state, req);
|
|
69
71
|
const authItems = isAuth
|
|
70
72
|
? [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
{
|
|
74
|
+
label: req.__("User"),
|
|
75
|
+
icon: "far fa-user",
|
|
76
|
+
isUser: true,
|
|
77
|
+
subitems: [
|
|
78
|
+
{ label: small((req.user.email || "").split("@")[0]) },
|
|
79
|
+
{
|
|
80
|
+
label: req.__("User Settings"),
|
|
81
|
+
icon: "fas fa-user-cog",
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
link: "/auth/settings",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
link: "/auth/logout",
|
|
87
|
+
icon: "fas fa-sign-out-alt",
|
|
88
|
+
label: req.__("Logout"),
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
]
|
|
91
93
|
: [
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
...(allow_signup
|
|
95
|
+
? [{ link: "/auth/signup", label: req.__("Sign up") }]
|
|
96
|
+
: []),
|
|
97
|
+
...(login_menu
|
|
98
|
+
? [{ link: "/auth/login", label: req.__("Login") }]
|
|
99
|
+
: []),
|
|
100
|
+
];
|
|
99
101
|
// const schema = db.getTenantSchema();
|
|
100
102
|
// Admin role id (todo move to common constants)
|
|
101
103
|
const isAdmin = role === 1;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
/*
|
|
105
|
+
* Admin Menu items
|
|
106
|
+
*
|
|
107
|
+
*/
|
|
106
108
|
const adminItems = [
|
|
107
109
|
{ link: "/table", icon: "fas fa-table", label: req.__("Tables") },
|
|
108
110
|
{ link: "/viewedit", icon: "far fa-eye", label: req.__("Views") },
|
|
@@ -116,7 +118,7 @@ const get_menu = (req) => {
|
|
|
116
118
|
icon: "fas fa-tools",
|
|
117
119
|
label: req.__("About application"),
|
|
118
120
|
},
|
|
119
|
-
{ link: "/plugins", icon: "fas fa-
|
|
121
|
+
{ link: "/plugins", icon: "fas fa-cubes", label: req.__("Modules") },
|
|
120
122
|
{
|
|
121
123
|
link: "/useradmin",
|
|
122
124
|
icon: "fas fa-users-cog",
|
|
@@ -177,17 +179,17 @@ const get_headers = (req, version_tag, description, extras = []) => {
|
|
|
177
179
|
|
|
178
180
|
const iconHeader = favicon
|
|
179
181
|
? [
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
{
|
|
183
|
+
headerTag: `<link rel="icon" type="image/png" href="/files/serve/${favicon}">`,
|
|
184
|
+
},
|
|
185
|
+
]
|
|
184
186
|
: [];
|
|
185
187
|
const meta_description = description
|
|
186
188
|
? [
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
{
|
|
190
|
+
headerTag: `<meta name="description" content="${description}">`,
|
|
191
|
+
},
|
|
192
|
+
]
|
|
191
193
|
: [];
|
|
192
194
|
const stdHeaders = [
|
|
193
195
|
{
|
|
@@ -228,12 +230,12 @@ const get_brand = (state) => {
|
|
|
228
230
|
};
|
|
229
231
|
};
|
|
230
232
|
module.exports = (version_tag) =>
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
233
|
+
/**
|
|
234
|
+
*
|
|
235
|
+
* @param req
|
|
236
|
+
* @param res
|
|
237
|
+
* @param next
|
|
238
|
+
*/
|
|
237
239
|
function (req, res, next) {
|
|
238
240
|
const role = (req.user || {}).role_id || 10;
|
|
239
241
|
|
|
@@ -349,7 +351,7 @@ const defaultRenderToHtml = (s, role) =>
|
|
|
349
351
|
typeof s === "string"
|
|
350
352
|
? s
|
|
351
353
|
: renderLayout({
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
354
|
+
blockDispatch: {},
|
|
355
|
+
role,
|
|
356
|
+
layout: s,
|
|
357
|
+
});
|