@operato/app 1.4.22 → 1.4.24

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/app",
3
3
  "description": "WebApplication production supporting components following open-wc recommendations",
4
4
  "author": "heartyoh",
5
- "version": "1.4.22",
5
+ "version": "1.4.24",
6
6
  "main": "dist/src/index.js",
7
7
  "module": "dist/src/index.js",
8
8
  "exports": {
@@ -18,6 +18,7 @@
18
18
  "./property-editor/ox-property-editor-resource-object.js": "./dist/src/property-editor/ox-property-editor-resource-object.js",
19
19
  "./grist-editor.js": "./dist/src/grist-editor/index.js",
20
20
  "./grist-editor/ox-grist-editor-resource-id.js": "./dist/src/grist-editor/ox-grist-editor-resource-id.js",
21
+ "./grist-editor/ox-grist-renderer-resource-code.js": "./dist/src/grist-editor/ox-grist-renderer-resource-code.js",
21
22
  "./grist-editor/ox-grist-renderer-resource-id.js": "./dist/src/grist-editor/ox-grist-renderer-resource-id.js",
22
23
  "./grist-editor/ox-grist-renderer-resource-object.js": "./dist/src/grist-editor/ox-grist-renderer-resource-object.js",
23
24
  "./grist-editor/ox-grist-renderer-crontab.js": "./dist/src/grist-editor/ox-grist-renderer-crontab.js",
@@ -64,6 +65,9 @@
64
65
  "grist-editor/ox-grist-editor-resource-id.js": [
65
66
  "dist/src/grist-editor/ox-grist-editor-resource-id.d.ts"
66
67
  ],
68
+ "grist-editor/ox-grist-renderer-resource-code.js": [
69
+ "dist/src/grist-editor/ox-grist-renderer-resource-code.d.ts"
70
+ ],
67
71
  "grist-editor/ox-grist-renderer-resource-id.js": [
68
72
  "dist/src/grist-editor/ox-grist-renderer-resource-id.d.ts"
69
73
  ],
@@ -121,18 +125,18 @@
121
125
  "@material/mwc-button": "^0.27.0",
122
126
  "@material/mwc-icon": "^0.27.0",
123
127
  "@material/mwc-icon-button": "^0.27.0",
124
- "@operato/attachment": "^1.4.21",
125
- "@operato/data-grist": "^1.4.21",
126
- "@operato/font": "^1.4.21",
127
- "@operato/form": "^1.4.20",
128
+ "@operato/attachment": "^1.4.24",
129
+ "@operato/data-grist": "^1.4.24",
130
+ "@operato/font": "^1.4.24",
131
+ "@operato/form": "^1.4.23",
128
132
  "@operato/graphql": "^1.4.20",
129
133
  "@operato/i18n": "^1.4.5",
130
- "@operato/input": "^1.4.21",
131
- "@operato/layout": "^1.4.20",
132
- "@operato/property-editor": "^1.4.21",
133
- "@operato/shell": "^1.4.20",
134
+ "@operato/input": "^1.4.23",
135
+ "@operato/layout": "^1.4.23",
136
+ "@operato/property-editor": "^1.4.24",
137
+ "@operato/shell": "^1.4.23",
134
138
  "@operato/styles": "^1.4.11",
135
- "@operato/utils": "^1.4.5",
139
+ "@operato/utils": "^1.4.23",
136
140
  "codemirror": "^5.64.0",
137
141
  "codemirror-graphql": "^2.0.9",
138
142
  "cronstrue": "^2.2.0",
@@ -174,5 +178,5 @@
174
178
  "prettier --write"
175
179
  ]
176
180
  },
177
- "gitHead": "c2e65b014ba739813243d5e78cb4bc543c971ae0"
181
+ "gitHead": "544e0036454d0bb2117ef0bfa727a4dfbc82900c"
178
182
  }
@@ -6,15 +6,17 @@ import { OxGristEditorResourceId } from './ox-grist-editor-resource-id.js'
6
6
  import { OxGristEditorResourceObject } from './ox-grist-editor-resource-object.js'
7
7
  import { OxGristRendererCrontab } from './ox-grist-renderer-crontab'
8
8
  import { OxGristRendererResourceId } from './ox-grist-renderer-resource-id.js'
9
+ import { OxGristRendererResourceCode } from './ox-grist-renderer-resource-code.js'
9
10
  import { OxGristRendererResourceObject } from './ox-grist-renderer-resource-object.js'
10
11
 
11
12
  /* register grist renderer/editor for id */
12
13
  registerEditor('resource-id', OxGristEditorResourceId)
13
- registerEditor('resource-object', OxGristEditorResourceObject)
14
14
  registerEditor('resource-code', OxGristEditorResourceCode)
15
+ registerEditor('resource-object', OxGristEditorResourceObject)
15
16
  registerEditor('json', OxGristEditorJson)
16
17
 
17
18
  registerRenderer('resource-id', OxGristRendererResourceId)
19
+ registerRenderer('resource-code', OxGristRendererResourceId)
18
20
  registerRenderer('resource-object', OxGristRendererResourceObject)
19
21
  registerRenderer('parameters', OxGristRendererJson5)
20
22
  registerRenderer('value-map', OxGristRendererJson5)
@@ -13,59 +13,15 @@ type CommonCodeDetail = {
13
13
  rank: number
14
14
  }
15
15
 
16
- type CommonCode = {
17
- name: string
18
- description: string
19
- details: CommonCodeDetail[]
20
- }
21
-
22
- const FETCH_COMMON_CODE_GQL = (codeName: string) => gql`
23
- {
24
- commonCode(name: "${codeName}") {
25
- details {
26
- name
27
- description
28
- rank
29
- }
30
- }
31
- }
32
- `
33
-
34
16
  @customElement('ox-grist-editor-resource-code')
35
17
  export class OxGristEditorResourceCode extends OxGristEditor {
36
- async firstUpdated() {
37
- super.firstUpdated()
38
-
39
- var { codeName, codes } = this.column.record || {}
40
-
41
- if (!codes && codeName) {
42
- /* codeName으로 fetch 해와서, this.column.record.codes에 보관한다. */
43
- var response = await client.query({
44
- query: FETCH_COMMON_CODE_GQL(codeName),
45
- context: gqlContext()
46
- })
47
-
48
- var commonCode = response && response.data && response.data.commonCode
49
-
50
- if (commonCode) {
51
- this.column.record.codes = [{ name: '', description: '' }].concat(
52
- commonCode.details.sort(function (a: CommonCodeDetail, b: CommonCodeDetail) {
53
- return a.rank - b.rank
54
- })
55
- )
56
-
57
- this.requestUpdate()
58
- }
59
- }
60
- }
61
-
62
18
  get editorTemplate() {
63
19
  var { codes } = this.column.record || {}
64
20
 
65
21
  return html`
66
22
  <select>
67
23
  ${(codes || ['']).map(
68
- (code: CommonCode) => html`
24
+ (code: CommonCodeDetail) => html`
69
25
  <option ?selected=${code.name == this.value} value=${code.name}>
70
26
  ${code.name}${code.description ? ` - ${code.description}` : ''}
71
27
  </option>
@@ -0,0 +1,144 @@
1
+ import gql from 'graphql-tag'
2
+ import { html } from 'lit'
3
+ import { client, gqlContext } from '@operato/graphql'
4
+ import { customElement } from 'lit/decorators.js'
5
+
6
+ import { FieldRenderer, OxGristRenderer } from '@operato/data-grist'
7
+
8
+ type CommonCodeDetail = {
9
+ name: string
10
+ description: string
11
+ rank: number
12
+ }
13
+
14
+ const FETCH_COMMON_CODE_GQL = (codeName: string) => gql`
15
+ {
16
+ commonCode(name: "${codeName}") {
17
+ details {
18
+ name
19
+ description
20
+ rank
21
+ }
22
+ }
23
+ }
24
+ `
25
+
26
+ @customElement('ox-grist-renderer-resource-code')
27
+ export class OxGristRendererResourceCode extends OxGristRenderer {
28
+ async connectedCallback(){
29
+ var { codeName, codes } = this.column.record || {}
30
+
31
+ if (!codes && codeName) {
32
+ /* codeName으로 fetch 해와서, this.column.record.codes에 보관한다. */
33
+ let response = await client.query({
34
+ query: FETCH_COMMON_CODE_GQL(codeName),
35
+ context: gqlContext()
36
+ })
37
+
38
+ var commonCode = response && response.data && response.data.commonCode
39
+
40
+ this.column.record.codes = [{ name: '', description: '' }].concat(
41
+ commonCode.details.sort(function (a: CommonCodeDetail, b: CommonCodeDetail) {
42
+ return a.rank - b.rank
43
+ })
44
+ )
45
+
46
+ console.log(this.column.record.codes)
47
+ }
48
+
49
+ super.connectedCallback();
50
+ }
51
+
52
+ get rendererTemplate() {
53
+ if(!this.value) {
54
+ return html``
55
+ }
56
+
57
+ var { codes } = this.column.record || {}
58
+
59
+ if(codes){
60
+ for(let idx = 0; idx < codes.length ; idx++){
61
+ let code = codes[idx];
62
+
63
+ if(code.name == this.value){
64
+ return html`<span>${code.description}</span> `
65
+ }
66
+ }
67
+ }
68
+
69
+ return html`<span>${this.value}</span> `
70
+ }
71
+ }
72
+
73
+
74
+ // type CommonCodeDetail = {
75
+ // name: string
76
+ // description: string
77
+ // rank: number
78
+ // }
79
+
80
+ // const FETCH_COMMON_CODE_GQL = (codeName: string) => gql`
81
+ // {
82
+ // commonCode(name: "${codeName}") {
83
+ // details {
84
+ // name
85
+ // description
86
+ // rank
87
+ // }
88
+ // }
89
+ // }
90
+ // `
91
+
92
+ // const codeGetterPromise = (codeName:string) => new Promise((resolve, reject) => {
93
+ // /* codeName으로 fetch 해와서, this.column.record.codes에 보관한다. */
94
+ // client.query({
95
+ // query: FETCH_COMMON_CODE_GQL(codeName),
96
+ // context: gqlContext()
97
+ // }).then(({ loading, error, data }) => {
98
+ // var commonCode = data && data.commonCode
99
+
100
+ // let codes:any[] = []
101
+
102
+ // if (commonCode) {
103
+ // codes = [{ name: '', description: '' }].concat(
104
+ // commonCode.details.sort(function (a: CommonCodeDetail, b: CommonCodeDetail) {
105
+ // return a.rank - b.rank
106
+ // })
107
+ // )
108
+ // resolve(codes)
109
+ // }
110
+ // });
111
+ // });
112
+
113
+ // export const OxGristRendererResourceCode: FieldRenderer = (value, column, record, rowIndex, field) => {
114
+ // if (!value) return html``
115
+
116
+ // var { codeName, codes } = column.record || {}
117
+ // if(codes){
118
+ // return getRenderHtml(value, codes);
119
+ // }
120
+
121
+ // if (!codes && codeName) {
122
+ // codeGetterPromise(codeName).then(codeList=> {
123
+ // console.log('getCodes')
124
+ // column.record.codes = codeList
125
+ // codes = codeList
126
+ // })
127
+ // }
128
+
129
+ // return getRenderHtml(value, codes);
130
+ // }
131
+
132
+ // function getRenderHtml(value:string, codes:any[]){
133
+ // if(codes){
134
+ // for(let idx = 0; idx < codes.length ; idx++){
135
+ // let code = codes[idx];
136
+
137
+ // if(code.name == value){
138
+ // return html`<span>${code.description}</span> `
139
+ // }
140
+ // }
141
+ // }
142
+
143
+ // return html`<span>${value}</span> `
144
+ // }