waibu-db 1.2.2 → 1.2.3
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
CHANGED
|
@@ -7,7 +7,7 @@ async function addHandler ({ req, reply, model, params = {}, template, addOnsHan
|
|
|
7
7
|
const options = {}
|
|
8
8
|
model = model ?? pascalCase(req.params.model)
|
|
9
9
|
const { schema } = await getSchemaExt(model, 'add', { params })
|
|
10
|
-
if (schema.disabled.includes('create')) return reply.view(templateDisabled, { action: 'add' })
|
|
10
|
+
if (schema.disabled.includes('create')) return await reply.view(templateDisabled, { action: 'add' })
|
|
11
11
|
// req.query.attachment = true
|
|
12
12
|
options.fields = schema.view.fields
|
|
13
13
|
let def = {}
|
|
@@ -34,7 +34,7 @@ async function addHandler ({ req, reply, model, params = {}, template, addOnsHan
|
|
|
34
34
|
}
|
|
35
35
|
const addOns = addOnsHandler ? await addOnsHandler.call(this.app[req.ns], { req, reply, params, data: resp, schema, error }) : undefined
|
|
36
36
|
merge(params, { form, schema, error, addOns })
|
|
37
|
-
return reply.view(template, params)
|
|
37
|
+
return await reply.view(template, params)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export default addHandler
|
|
@@ -6,7 +6,7 @@ async function deleteHandler ({ req, reply, model, params = {}, templateDisabled
|
|
|
6
6
|
const options = {}
|
|
7
7
|
model = model ?? pascalCase(req.params.model)
|
|
8
8
|
const { schema } = await getSchemaExt(model, 'add', { params })
|
|
9
|
-
if (schema.disabled.includes('remove')) return reply.view(templateDisabled, { action: 'delete' })
|
|
9
|
+
if (schema.disabled.includes('remove')) return await reply.view(templateDisabled, { action: 'delete' })
|
|
10
10
|
options.fields = schema.view.fields
|
|
11
11
|
const ids = (req.body.ids ?? '').split(',')
|
|
12
12
|
if (ids.length > 0) {
|
|
@@ -7,7 +7,7 @@ async function detailsHandler ({ req, reply, model, params = {}, id, template, a
|
|
|
7
7
|
const options = {}
|
|
8
8
|
model = model ?? pascalCase(req.params.model)
|
|
9
9
|
const { schema } = await getSchemaExt(model, 'details', { params })
|
|
10
|
-
if (schema.disabled.includes('get')) return reply.view(templateDisabled, { action: 'details' })
|
|
10
|
+
if (schema.disabled.includes('get')) return await reply.view(templateDisabled, { action: 'details' })
|
|
11
11
|
// req.query.attachment = true
|
|
12
12
|
options.fields = schema.view.fields
|
|
13
13
|
id = id ?? req.params.id ?? req.query.id
|
|
@@ -16,7 +16,7 @@ async function detailsHandler ({ req, reply, model, params = {}, id, template, a
|
|
|
16
16
|
const addOns = addOnsHandler ? await addOnsHandler.call(this.app[req.ns], { req, reply, params, data: resp, schema }) : undefined
|
|
17
17
|
const attachments = await attachmentHandler.call(this, { schema, id })
|
|
18
18
|
merge(params, { form, schema, addOns, attachments })
|
|
19
|
-
return reply.view(template, params)
|
|
19
|
+
return await reply.view(template, params)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export default detailsHandler
|
package/lib/crud/edit-handler.js
CHANGED
|
@@ -14,7 +14,7 @@ async function editHandler ({ req, reply, model, id, params = {}, template, addO
|
|
|
14
14
|
let form
|
|
15
15
|
model = model ?? pascalCase(req.params.model)
|
|
16
16
|
const { schema } = await getSchemaExt(model, 'edit', options, { params })
|
|
17
|
-
if (schema.disabled.includes('update')) return reply.view(templateDisabled, { action: 'edit' })
|
|
17
|
+
if (schema.disabled.includes('update')) return await reply.view(templateDisabled, { action: 'edit' })
|
|
18
18
|
// req.query.attachment = true
|
|
19
19
|
options.fields = schema.view.fields
|
|
20
20
|
id = id ?? req.params.id ?? req.query.id
|
|
@@ -45,7 +45,7 @@ async function editHandler ({ req, reply, model, id, params = {}, template, addO
|
|
|
45
45
|
const addOns = addOnsHandler ? await addOnsHandler.call(this.app[req.ns], { req, reply, params, data: resp, schema, error }) : undefined
|
|
46
46
|
const attachments = await attachmentHandler.call(this, { schema, id })
|
|
47
47
|
merge(params, { form, schema, error, addOns, attachments })
|
|
48
|
-
return reply.view(template, params)
|
|
48
|
+
return await reply.view(template, params)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export default editHandler
|
|
@@ -5,7 +5,7 @@ async function exportHandler ({ req, reply, model, params = {}, templateDisabled
|
|
|
5
5
|
const options = {}
|
|
6
6
|
model = model ?? pascalCase(req.params.model)
|
|
7
7
|
const { schema } = await getSchemaExt(model, 'add', options, { params })
|
|
8
|
-
if (schema.disabled.includes('find')) return reply.view(templateDisabled, { action: 'list' })
|
|
8
|
+
if (schema.disabled.includes('find')) return await reply.view(templateDisabled, { action: 'list' })
|
|
9
9
|
options.fields = schema.view.fields
|
|
10
10
|
const url = buildUrl({ url: req.url, base: req.body.handler })
|
|
11
11
|
req.flash('notify', req.t('Data export in queue. You\'ll be notified once completed'))
|
package/lib/crud/list-handler.js
CHANGED
|
@@ -6,7 +6,7 @@ async function listHandler ({ req, reply, model, template, params = {}, addOnsHa
|
|
|
6
6
|
const options = { count: true, rels: '*' }
|
|
7
7
|
model = model ?? pascalCase(req.params.model)
|
|
8
8
|
const { schema } = await getSchemaExt(model, 'list', { params })
|
|
9
|
-
if (schema.disabled.includes('find')) return reply.view(templateDisabled, { action: 'list' })
|
|
9
|
+
if (schema.disabled.includes('find')) return await reply.view(templateDisabled, { action: 'list' })
|
|
10
10
|
for (const key of ['sort', 'limit', 'fields']) {
|
|
11
11
|
const sessKey = `wdb${model}${upperFirst(key)}`
|
|
12
12
|
if (!req.query[qsKey[key]]) req.query[qsKey[key]] = req.session[sessKey] ?? get(schema, `view.qs.${key}`)
|
|
@@ -21,7 +21,7 @@ async function listHandler ({ req, reply, model, template, params = {}, addOnsHa
|
|
|
21
21
|
if (!isArray(addOns)) addOns = [addOns]
|
|
22
22
|
}
|
|
23
23
|
merge(params, { list, schema, addOns })
|
|
24
|
-
return reply.view(template, params)
|
|
24
|
+
return await reply.view(template, params)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export default listHandler
|