waibu-db 2.25.1 → 2.26.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.
- package/extend/bajoTemplate/partial/crud/_edit-btns.html +3 -3
- package/extend/waibuBootstrap/theme/component/widget/data-table.js +2 -1
- package/extend/waibuBootstrap/theme/component/widget/form.js +4 -1
- package/lib/method/get-schema-ext.js +21 -12
- package/package.json +1 -1
- package/wiki/CHANGES.md +7 -0
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
</c:grid-col>
|
|
18
18
|
<c:grid-col col="6-lg" flex="justify-content:end-lg align-items:center">
|
|
19
19
|
<% if (!_getSetting('waibuDb:/control/wdbBtnDelete/disabled')) { %>
|
|
20
|
-
<c:wdb-btn-delete href="<%= _getSetting('waibuDb:/control/wdbBtnDelete/href', 'undefined') %>" <%= _.get(form, '_immutable.0') === '*' ? 'disabled' : '' %>/>
|
|
20
|
+
<c:wdb-btn-delete href="<%= _getSetting('waibuDb:/control/wdbBtnDelete/href', 'undefined') %>" <%= !_meta.routeOpts.xSite && _.get(form, '_immutable.0') === '*' ? 'disabled' : '' %>/>
|
|
21
21
|
<% } %>
|
|
22
22
|
<% if (!_getSetting('waibuDb:/control/wdbBtnReset/disabled')) { %>
|
|
23
|
-
<c:btn type="reset" color="secondary" t:content="reset" margin="start-2" <%= _.get(form, '_immutable.0') === '*' ? 'disabled' : '' %>/>
|
|
23
|
+
<c:btn type="reset" color="secondary" t:content="reset" margin="start-2" <%= !_meta.routeOpts.xSite && _.get(form, '_immutable.0') === '*' ? 'disabled' : '' %>/>
|
|
24
24
|
<% } %>
|
|
25
25
|
<% if (!_getSetting('waibuDb:/control/wdbBtnSubmit/disabled')) { %>
|
|
26
|
-
<c:btn type="submit" color="primary" t:content="submit" margin="start-2" <%= _.get(form, '_immutable.0') === '*' ? 'disabled' : '' %>/>
|
|
26
|
+
<c:btn type="submit" color="primary" t:content="submit" margin="start-2" <%= !_meta.routeOpts.xSite && _.get(form, '_immutable.0') === '*' ? 'disabled' : '' %>/>
|
|
27
27
|
<% } %>
|
|
28
28
|
</c:grid-col>
|
|
29
29
|
</c:grid-row>
|
|
@@ -31,6 +31,7 @@ async function table () {
|
|
|
31
31
|
this.params.attr = group._
|
|
32
32
|
const prettyUrl = this.params.attr.prettyUrl
|
|
33
33
|
|
|
34
|
+
const hasXSite = get(req, 'routeOptions.config.xSite')
|
|
34
35
|
const schema = get(locals, 'schema', {})
|
|
35
36
|
const data = get(locals, 'list.data', [])
|
|
36
37
|
const filter = get(locals, 'list.filter', {})
|
|
@@ -144,7 +145,7 @@ async function table () {
|
|
|
144
145
|
const noWrap = this.isNoWrap(f, schema, group.body.nowrap) ? 'nowrap' : ''
|
|
145
146
|
if (this.isRightAligned(f, schema)) attr.text = `align:end ${noWrap}`
|
|
146
147
|
else attr.text = `${noWrap}`
|
|
147
|
-
if (d._immutable && d._immutable.length > 0) {
|
|
148
|
+
if (!hasXSite && d._immutable && d._immutable.length > 0) {
|
|
148
149
|
if (d._immutable[0] === '*' || d._immutable.includes(f)) attr.text += ' color:body-tertiary'
|
|
149
150
|
}
|
|
150
151
|
if (f === 'id') attr.text += ' color:body-tertiary'
|
|
@@ -22,6 +22,7 @@ async function form () {
|
|
|
22
22
|
build = async () => {
|
|
23
23
|
const { get, find, filter, forOwn, isEmpty, omit, isArray } = this.app.lib._
|
|
24
24
|
const { base64JsonEncode } = this.app.waibu
|
|
25
|
+
const { req } = this.component
|
|
25
26
|
const body = []
|
|
26
27
|
const xModels = get(this.schema, 'view.x.model', [])
|
|
27
28
|
const xOns = get(this.schema, 'view.x.on', [])
|
|
@@ -53,7 +54,9 @@ async function form () {
|
|
|
53
54
|
if (widget.componentOpts) attr['c-opts'] = base64JsonEncode(widget.componentOpts)
|
|
54
55
|
if (prop.virtual) widget.component = 'form-plaintext'
|
|
55
56
|
const immutable = get(this, 'formData._immutable') || []
|
|
56
|
-
if (
|
|
57
|
+
if (!req.routeOptions.config.xSite) {
|
|
58
|
+
if ((immutable.length === 1 && immutable[0] === '*') || immutable.includes(prop.name)) widget.component = 'form-plaintext'
|
|
59
|
+
}
|
|
57
60
|
widget.addons = widget.addons ?? []
|
|
58
61
|
if (!isArray(widget.addons)) widget.addons = [widget.addons]
|
|
59
62
|
for (const ao of widget.addons) {
|
|
@@ -16,9 +16,15 @@ function getCommons (action, schema, ext, options = {}) {
|
|
|
16
16
|
const disabled = get(ext, `view.${action}.disabled`, get(ext, 'common.disabled', []))
|
|
17
17
|
const x = defaultsDeep(get(ext, `view.${action}.x`), get(ext, 'common.x', {}))
|
|
18
18
|
const aggregate = get(ext, `view.${action}.stat.aggregate`, get(ext, 'common.stat.aggregate', []))
|
|
19
|
+
const hasXSite = get(options, 'args.0.req.routeOptions.config.xSite')
|
|
20
|
+
const hasSiteId = schema.model.hasProperty('siteId')
|
|
21
|
+
const hasImmutable = schema.model.hasProperty('_immutable')
|
|
22
|
+
|
|
19
23
|
let attachment = get(ext, `view.${action}.attachment`, get(ext, 'common.attachment', schema.attachment))
|
|
20
24
|
if (!schema.options.attachment || action === 'list') attachment = false
|
|
21
|
-
hidden.push(
|
|
25
|
+
hidden.push(...schema.hidden, ...(options.hidden ?? []))
|
|
26
|
+
if (hasSiteId && !hasXSite) hidden.push('siteId')
|
|
27
|
+
if (hasImmutable && !hasXSite) hidden.push('_immutable')
|
|
22
28
|
hidden = uniq(hidden)
|
|
23
29
|
pull(hidden, ...forceVisible)
|
|
24
30
|
const allFields = without(map(schema.properties, 'name'), ...hidden)
|
|
@@ -33,11 +39,7 @@ function getCommons (action, schema, ext, options = {}) {
|
|
|
33
39
|
set(schema, 'view.control', control)
|
|
34
40
|
set(schema, 'view.x', x)
|
|
35
41
|
if (schema.disabled.length > 0) schema.view.disabled.push(...schema.disabled)
|
|
36
|
-
let fields =
|
|
37
|
-
for (const f of forFields) {
|
|
38
|
-
if (['_immutable'].includes(f)) continue
|
|
39
|
-
if (allFields.includes(f)) fields.push(f)
|
|
40
|
-
}
|
|
42
|
+
let fields = forFields.filter(f => allFields.includes(f))
|
|
41
43
|
fields = uniq(without(fields, ...hidden))
|
|
42
44
|
|
|
43
45
|
options.forceShowId = options.forceShowId ?? true
|
|
@@ -49,9 +51,9 @@ function getCommons (action, schema, ext, options = {}) {
|
|
|
49
51
|
return { fields, allFields, card }
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
function autoLayout ({ action, schema, ext, layout }) {
|
|
54
|
+
function autoLayout ({ action, schema, ext, layout, options }) {
|
|
53
55
|
const { forOwn, keys } = this.app.lib._
|
|
54
|
-
const matches = ['id', 'createdAt', 'updatedAt']
|
|
56
|
+
const matches = ['id', 'createdAt', 'updatedAt', 'siteId']
|
|
55
57
|
const meta = []
|
|
56
58
|
const general = []
|
|
57
59
|
forOwn(schema.view.widget, (w, f) => {
|
|
@@ -86,7 +88,7 @@ function customLayout ({ action, schema, ext, layout, readonly }) {
|
|
|
86
88
|
async function applyLayout (action, schema, ext, options) {
|
|
87
89
|
const { defaultsDeep } = this.app.lib.aneka
|
|
88
90
|
const { set, get, isEmpty, find } = this.app.lib._
|
|
89
|
-
const { fields, card } = getCommons.call(this, action, schema, ext)
|
|
91
|
+
const { fields, card } = getCommons.call(this, action, schema, ext, options)
|
|
90
92
|
const layout = get(ext, `view.${action}.layout`, get(ext, 'common.layout', []))
|
|
91
93
|
const readonly = get(ext, `view.${action}.readonly`, get(ext, 'common.readonly', defReadonly))
|
|
92
94
|
const widget = {}
|
|
@@ -152,8 +154,8 @@ async function applyLayout (action, schema, ext, options) {
|
|
|
152
154
|
widget[f] = result
|
|
153
155
|
}
|
|
154
156
|
set(schema, 'view.widget', widget)
|
|
155
|
-
if (isEmpty(layout)) autoLayout.call(this, { layout, schema, action, ext })
|
|
156
|
-
else customLayout.call(this, { layout, schema, action, ext, readonly })
|
|
157
|
+
if (isEmpty(layout)) autoLayout.call(this, { layout, schema, action, ext, options })
|
|
158
|
+
else customLayout.call(this, { layout, schema, action, ext, readonly, options })
|
|
157
159
|
set(schema, 'view.layout', layout)
|
|
158
160
|
set(schema, 'view.fields', fields)
|
|
159
161
|
set(schema, 'view.card', card)
|
|
@@ -194,16 +196,23 @@ const handler = {
|
|
|
194
196
|
async function getSchemaExt (modelName, view, options = {}) {
|
|
195
197
|
const { readConfig } = this.app.bajo
|
|
196
198
|
const { defaultsDeep } = this.app.lib.aneka
|
|
197
|
-
const { pick, isString } = this.app.lib._
|
|
199
|
+
const { pick, isString, get } = this.app.lib._
|
|
198
200
|
|
|
199
201
|
const model = isString(modelName) ? this.app.dobo.getModel(modelName) : modelName
|
|
200
202
|
const ns = model.plugin.ns
|
|
201
203
|
const schema = pick(model, ['name', 'properties', 'indexes', 'disabled', 'sortables', 'scanables', 'view', 'hidden', 'options'])
|
|
202
204
|
schema.ns = ns
|
|
205
|
+
schema.model = model
|
|
203
206
|
const parserOpts = { args: options.args }
|
|
204
207
|
let ext = await readConfig(`${ns}:/extend/waibuDb/schema/${model.baseName}.*`, { ns, baseNs: 'waibuDb', parserOpts })
|
|
205
208
|
ext = defaultsDeep(options.schema ?? {}, ext)
|
|
206
209
|
await handler[view].call(this, schema, ext, options)
|
|
210
|
+
delete schema.model
|
|
211
|
+
const req = get(options, 'args.0.req')
|
|
212
|
+
if (req && req.routeOptions.config.mainSiteEdit && req.site.alias !== 'default') {
|
|
213
|
+
schema.disabled = schema.disabled ?? []
|
|
214
|
+
schema.disabled.push('create', 'update', 'remove')
|
|
215
|
+
}
|
|
207
216
|
return { schema, ext, model }
|
|
208
217
|
}
|
|
209
218
|
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-06-17
|
|
4
|
+
|
|
5
|
+
- [2.25.2] Bug fix in ```wdb-data-table``` widget
|
|
6
|
+
- [2.25.2] Bug fix in ```wdb-form``` widget
|
|
7
|
+
- [2.25.2] Bug fix in ```get-schema-ext.js```
|
|
8
|
+
- [2.26.0] Add feature to edit schema only on main site
|
|
9
|
+
|
|
3
10
|
## 2026-06-13
|
|
4
11
|
|
|
5
12
|
- [2.25.1] Bug fix in ```transaction```: only applicable to ```CUD```
|