sumba 1.1.15 → 1.1.17

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.
@@ -2,14 +2,15 @@ const doboBeforeRecordCreate = {
2
2
  level: 1000,
3
3
  handler: async function (model, body, options = {}) {
4
4
  const { get } = this.lib._
5
- const { hasColumn } = this
5
+ const { getField } = this.app.dobo
6
6
  const { req } = options
7
7
 
8
8
  if (options.noAutoFilter || !req) return
9
9
  const item = { siteId: 'site.id', userId: 'user.id' }
10
10
  for (const i in item) {
11
11
  const rec = get(req, item[i])
12
- if (rec && await hasColumn(i, model)) body[i] = rec
12
+ const field = getField(i, model)
13
+ if (rec && field) body[i] = field.type === 'string' ? (rec + '') : rec
13
14
  }
14
15
  }
15
16
  }
@@ -2,11 +2,11 @@ const useAdmin = ['waibuAdmin']
2
2
 
3
3
  export async function rebuildFilter (model, filter, req) {
4
4
  const { isEmpty, map, find, get } = this.lib._
5
- const { hasColumn } = this
5
+ const { hasField } = this.app.dobo
6
6
  filter.query = filter.query ?? {}
7
- const hasSiteId = await hasColumn('siteId', model)
8
- const hasUserId = await hasColumn('userId', model)
9
- const hasTeamId = await hasColumn('teamId', model)
7
+ const hasSiteId = hasField('siteId', model)
8
+ const hasUserId = hasField('userId', model)
9
+ const hasTeamId = hasField('teamId', model)
10
10
  const isAdmin = find(get(req, 'user.teams', []), { alias: 'administrator' }) && useAdmin.includes(get(req, 'routeOptions.config.ns'))
11
11
  if (!(hasSiteId || hasUserId || hasTeamId)) return filter
12
12
  const q = { $and: [] }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumba",
3
- "version": "1.1.15",
3
+ "version": "1.1.17",
4
4
  "description": "Bajo Framework's Biz Suite",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/plugin/factory.js CHANGED
@@ -49,7 +49,7 @@ async function factory (pkgName) {
49
49
  },
50
50
  pages: [{
51
51
  title: 'account',
52
- level: 80,
52
+ level: 9998,
53
53
  children: [
54
54
  // anonymous only
55
55
  { title: 'signin', href: 'sumba:/signin', visible: 'anon' },
@@ -65,7 +65,7 @@ async function factory (pkgName) {
65
65
  ]
66
66
  }, {
67
67
  title: 'help',
68
- level: 90,
68
+ level: 9999,
69
69
  children: [
70
70
  { title: 'contactForm', href: 'sumba:/help/contact-form' },
71
71
  { title: 'troubleTickets', href: 'sumba:/help/trouble-tickets', visible: 'auth' },
@@ -142,15 +142,6 @@ async function factory (pkgName) {
142
142
  }
143
143
  }
144
144
 
145
- hasColumn = async (name, model) => {
146
- const { getInfo } = this.app.dobo
147
- const { find } = this.lib._
148
- const { schema } = getInfo(model)
149
-
150
- const result = find(schema.properties, { name })
151
- return !!result
152
- }
153
-
154
145
  getUser = async (rec, safe = true) => {
155
146
  const { recordGet } = this.app.dobo
156
147
  const { omit, isPlainObject } = this.lib._
@@ -6,13 +6,7 @@
6
6
  { "name": "Person In Charge", "fields": ["picName:3-md 6-sm:Name", "picRole:3-md 6-sm:Role", "picPhone:3-md 6-sm:Phone", "picEmail:3-md 6-sm:Email"] },
7
7
  { "name": "Address", "fields": ["address1:12", "address2:12", "city:6-md 8-sm", "zipCode:2-md 4-sm", "provinceState:4-md", { "name": "country", "col": "6-md", "component": "form-select-country" }, "phone:6-md", "website:12"] },
8
8
  { "name": "Social Media", "fields": ["twitter:3-md 6-sm", "instagram:3-md 6-sm", "facebook:3-md 6-sm", "linkedIn:3-md 6-sm"] }
9
- ],
10
- "stat": {
11
- "aggregate": [
12
- { "fields": ["status"], "group": "status", "aggregate": ["count"] },
13
- { "fields": ["country"], "group": "country", "aggregate": ["count"] }
14
- ]
15
- }
9
+ ]
16
10
  },
17
11
  "view": {
18
12
  "list": {
@@ -20,7 +14,13 @@
20
14
  "sort": "hostname:1",
21
15
  "limit": 10
22
16
  },
23
- "fields": ["createdAt", "status", "hostname", "orgName", "email", "city", "zipCode", "provinceState", "country", "phone"]
17
+ "fields": ["createdAt", "status", "hostname", "orgName", "email", "city", "zipCode", "provinceState", "country", "phone"],
18
+ "stat": {
19
+ "aggregate": [
20
+ { "fields": ["status"], "group": "status", "aggregate": ["count"] },
21
+ { "fields": ["country"], "group": "country", "aggregate": ["count"] }
22
+ ]
23
+ }
24
24
  },
25
25
  "details": {
26
26
  },
@@ -5,13 +5,7 @@
5
5
  { "name": "account", "fields": ["username", "email", "status:4-md 6-sm", "siteId:4-md 6-sm", "firstName", "lastName"] },
6
6
  { "name": "address", "fields": ["address1:12", "address2:12", "city:6-md 8-sm", "zipCode:2-md 4-sm", "provinceState:4-md", { "name": "country", "col": "6-md", "component": "form-select-country" }, "phone:6-md", "website:12"] },
7
7
  { "name": "socialMedia", "fields": ["twitter:3-md 6-sm", "instagram:3-md 6-sm", "facebook:3-md 6-sm", "linkedIn:3-md 6-sm"] }
8
- ],
9
- "stat": {
10
- "aggregate": [
11
- { "fields": ["status"], "group": "status", "aggregate": ["count"] },
12
- { "fields": ["country"], "group": "country", "aggregate": ["count"] }
13
- ]
14
- }
8
+ ]
15
9
  },
16
10
  "view": {
17
11
  "list": {
@@ -19,7 +13,13 @@
19
13
  "sort": "username:1",
20
14
  "limit": 10
21
15
  },
22
- "fields": ["createdAt", "status", "siteId", "username", "email", "firstName", "lastName", "city", "zipCode", "provinceState", "country", "phone"]
16
+ "fields": ["createdAt", "status", "siteId", "username", "email", "firstName", "lastName", "city", "zipCode", "provinceState", "country", "phone"],
17
+ "stat": {
18
+ "aggregate": [
19
+ { "fields": ["status"], "group": "status", "aggregate": ["count"] },
20
+ { "fields": ["country"], "group": "country", "aggregate": ["count"] }
21
+ ]
22
+ }
23
23
  },
24
24
  "details": {
25
25
  },