waibu-db 1.1.1 → 1.1.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/lib/crud/add-handler.js +1 -1
- package/lib/crud/all-handler.js +1 -1
- package/lib/crud/delete-handler.js +1 -1
- package/lib/crud/details-handler.js +1 -1
- package/lib/crud/edit-handler.js +1 -1
- package/lib/crud/helper/add-ons-handler.js +1 -1
- package/lib/crud/helper/build-params.js +1 -1
- package/lib/crud/list-handler.js +1 -1
- package/lib/prep-crud.js +1 -1
- package/package.json +1 -1
- package/plugin/method/admin-menu.js +1 -1
- package/plugin/method/get-lookup-data.js +1 -1
- package/plugin/method/get-params.js +1 -1
- package/plugin/method/get-schema-ext.js +5 -5
package/lib/crud/add-handler.js
CHANGED
|
@@ -2,7 +2,7 @@ async function addHandler ({ req, reply, model, params = {}, template, addOnsHan
|
|
|
2
2
|
const { pascalCase } = this.app.bajo
|
|
3
3
|
const { recordCreate, recordGet, getSchemaExt } = this.app.waibuDb
|
|
4
4
|
const { buildUrl } = this.app.waibuMpa
|
|
5
|
-
const { pick, map, merge, defaultsDeep, omit, isEmpty } = this.
|
|
5
|
+
const { pick, map, merge, defaultsDeep, omit, isEmpty } = this.lib._
|
|
6
6
|
const options = {}
|
|
7
7
|
model = model ?? pascalCase(req.params.model)
|
|
8
8
|
const { schema } = await getSchemaExt(model, 'add', options)
|
package/lib/crud/all-handler.js
CHANGED
|
@@ -18,7 +18,7 @@ const handler = {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
async function allHandler ({ model, action, req, reply, template, params = {} }) {
|
|
21
|
-
const { upperFirst, merge, keys } = this.
|
|
21
|
+
const { upperFirst, merge, keys } = this.lib._
|
|
22
22
|
if (!keys(handler).includes(action)) throw this.error('_notFound')
|
|
23
23
|
if (['delete', 'export'].includes(action)) {
|
|
24
24
|
if (req.method === 'GET') throw this.error('_notFound')
|
|
@@ -2,7 +2,7 @@ async function deleteHandler ({ req, reply, model, params = {}, templateDisabled
|
|
|
2
2
|
const { pascalCase } = this.app.bajo
|
|
3
3
|
const { recordRemove, getSchemaExt } = this.app.waibuDb
|
|
4
4
|
const { buildUrl } = this.app.waibuMpa
|
|
5
|
-
const { reduce } = this.
|
|
5
|
+
const { reduce } = this.lib._
|
|
6
6
|
const options = {}
|
|
7
7
|
model = model ?? pascalCase(req.params.model)
|
|
8
8
|
const { schema } = await getSchemaExt(model, 'add', options)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
async function detailsHandler ({ req, reply, model, params = {}, template, addOnsHandler, templateDisabled = 'waibuDb.template:/disabled.html' } = {}) {
|
|
2
2
|
const { pascalCase } = this.app.bajo
|
|
3
3
|
const { recordGet, getSchemaExt } = this.app.waibuDb
|
|
4
|
-
const { merge } = this.
|
|
4
|
+
const { merge } = this.lib._
|
|
5
5
|
const options = {}
|
|
6
6
|
model = model ?? pascalCase(req.params.model)
|
|
7
7
|
const { schema } = await getSchemaExt(model, 'details', options)
|
package/lib/crud/edit-handler.js
CHANGED
|
@@ -2,7 +2,7 @@ async function editHandler ({ req, reply, model, params = {}, template, addOnsHa
|
|
|
2
2
|
const { pascalCase } = this.app.bajo
|
|
3
3
|
const { recordUpdate, recordGet, getSchemaExt } = this.app.waibuDb
|
|
4
4
|
const { buildUrl } = this.app.waibuMpa
|
|
5
|
-
const { merge, defaultsDeep } = this.
|
|
5
|
+
const { merge, defaultsDeep } = this.lib._
|
|
6
6
|
const options = {}
|
|
7
7
|
model = model ?? pascalCase(req.params.model)
|
|
8
8
|
const { schema } = await getSchemaExt(model, 'edit', options)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
async function addOnsHandler ({ req, reply, data, schema }) {
|
|
2
2
|
const { base64JsonEncode } = this.app.waibuMpa
|
|
3
3
|
const { statAggregate } = this.app.waibuDb
|
|
4
|
-
const { get, map, pick, pullAt } = this.
|
|
4
|
+
const { get, map, pick, pullAt } = this.lib._
|
|
5
5
|
const opts = map(get(schema, 'view.stat.aggregate', []), item => {
|
|
6
6
|
const dbOpts = pick(item, ['fields', 'group', 'aggregate'])
|
|
7
7
|
const name = item.name ?? `field.${item.fields[0]}`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function buildParams ({ model, req, reply, action }) {
|
|
2
|
-
const { camelCase, kebabCase, map, upperFirst, get } = this.
|
|
2
|
+
const { camelCase, kebabCase, map, upperFirst, get } = this.lib._
|
|
3
3
|
const { getSchema } = this.app.dobo
|
|
4
4
|
const [alias, ...names] = map(kebabCase(model).split('-'), n => upperFirst(n))
|
|
5
5
|
const schema = getSchema(camelCase(model), false)
|
package/lib/crud/list-handler.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
async function listHandler ({ req, reply, model, template, params = {}, addOnsHandler, templateDisabled = 'waibuDb.template:/disabled.html' } = {}) {
|
|
2
2
|
const { pascalCase } = this.app.bajo
|
|
3
3
|
const { recordFind, getSchemaExt } = this.app.waibuDb
|
|
4
|
-
const { get, merge, isArray, upperFirst } = this.
|
|
4
|
+
const { get, merge, isArray, upperFirst } = this.lib._
|
|
5
5
|
const qsKey = this.app.waibu.config.qsKey
|
|
6
6
|
const options = { count: true }
|
|
7
7
|
model = model ?? pascalCase(req.params.model)
|
package/lib/prep-crud.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function prepCrud ({ model, body, id, req, reply, options = {}, args }) {
|
|
2
2
|
const { parseFilter } = this.app.waibu
|
|
3
3
|
const { pascalCase } = this.app.bajo
|
|
4
|
-
const { cloneDeep, has } = this.
|
|
4
|
+
const { cloneDeep, has } = this.lib._
|
|
5
5
|
const cfgWeb = this.app.waibu.config
|
|
6
6
|
const opts = cloneDeep(options)
|
|
7
7
|
const params = this.getParams(req, ...args)
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ function modelsMenu (req) {
|
|
|
2
2
|
const { getPluginPrefix } = this.app.waibu
|
|
3
3
|
const { titleize, pascalCase } = this.app.bajo
|
|
4
4
|
const { getAppTitle } = this.app.waibuMpa
|
|
5
|
-
const { map, pick, groupBy, keys, kebabCase, filter, get } = this.
|
|
5
|
+
const { map, pick, groupBy, keys, kebabCase, filter, get } = this.lib._
|
|
6
6
|
|
|
7
7
|
const prefix = getPluginPrefix(this.name)
|
|
8
8
|
const schemas = filter(this.app.dobo.schemas, s => {
|
|
@@ -3,7 +3,7 @@ import path from 'path'
|
|
|
3
3
|
const defReadonly = ['id', 'createdAt', 'updatedAt']
|
|
4
4
|
|
|
5
5
|
function getCommons (action, schema, ext, opts = {}) {
|
|
6
|
-
const { map, get, set, without, uniq } = this.
|
|
6
|
+
const { map, get, set, without, uniq } = this.lib._
|
|
7
7
|
const label = get(ext, `view.${action}.label`, get(ext, 'common.label', {}))
|
|
8
8
|
const hidden = get(ext, `view.${action}.hidden`, get(ext, 'common.hidden', []))
|
|
9
9
|
hidden.push(...schema.hidden, ...(opts.hidden ?? []))
|
|
@@ -37,7 +37,7 @@ function autoLayout ({ action, schema, ext, layout, allWidgets }) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function customLayout ({ action, schema, ext, layout, allWidgets, readonly }) {
|
|
40
|
-
const { find, omit, merge, isString } = this.
|
|
40
|
+
const { find, omit, merge, isString } = this.lib._
|
|
41
41
|
const items = [...layout]
|
|
42
42
|
layout.splice(0, layout.length)
|
|
43
43
|
for (const item of items) {
|
|
@@ -58,7 +58,7 @@ function customLayout ({ action, schema, ext, layout, allWidgets, readonly }) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
function applyLayout (action, schema, ext) {
|
|
61
|
-
const { set, get, isEmpty, map, find } = this.
|
|
61
|
+
const { set, get, isEmpty, map, find } = this.lib._
|
|
62
62
|
const { fields, label } = getCommons.call(this, action, schema, ext)
|
|
63
63
|
const layout = get(ext, `view.${action}.layout`, get(ext, 'common.layout', []))
|
|
64
64
|
const readonly = get(ext, `view.${action}.readonly`, get(ext, 'common.readonly', defReadonly))
|
|
@@ -95,7 +95,7 @@ function applyLayout (action, schema, ext) {
|
|
|
95
95
|
|
|
96
96
|
const handler = {
|
|
97
97
|
list: async function (schema, ext, opts) {
|
|
98
|
-
const { get, set } = this.
|
|
98
|
+
const { get, set } = this.lib._
|
|
99
99
|
const { fields, label } = getCommons.call(this, 'list', schema, ext, opts)
|
|
100
100
|
const qsFields = []
|
|
101
101
|
for (const f of get(schema, 'view.qs.fields', '').split(',')) {
|
|
@@ -123,7 +123,7 @@ const handler = {
|
|
|
123
123
|
async function getSchemaExt (model, view, opts) {
|
|
124
124
|
const { readConfig } = this.app.bajo
|
|
125
125
|
const { getSchema } = this.app.dobo
|
|
126
|
-
const { pick } = this.
|
|
126
|
+
const { pick } = this.lib._
|
|
127
127
|
|
|
128
128
|
let schema = getSchema(model)
|
|
129
129
|
const base = path.basename(schema.file, path.extname(schema.file))
|