@operato/app 1.4.23 → 1.4.25

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.23",
5
+ "version": "1.4.25",
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,15 +125,15 @@
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.23",
125
- "@operato/data-grist": "^1.4.23",
126
- "@operato/font": "^1.4.23",
128
+ "@operato/attachment": "^1.4.24",
129
+ "@operato/data-grist": "^1.4.24",
130
+ "@operato/font": "^1.4.24",
127
131
  "@operato/form": "^1.4.23",
128
132
  "@operato/graphql": "^1.4.20",
129
133
  "@operato/i18n": "^1.4.5",
130
134
  "@operato/input": "^1.4.23",
131
135
  "@operato/layout": "^1.4.23",
132
- "@operato/property-editor": "^1.4.23",
136
+ "@operato/property-editor": "^1.4.24",
133
137
  "@operato/shell": "^1.4.23",
134
138
  "@operato/styles": "^1.4.11",
135
139
  "@operato/utils": "^1.4.23",
@@ -174,5 +178,5 @@
174
178
  "prettier --write"
175
179
  ]
176
180
  },
177
- "gitHead": "f490c222495c17c7e60103ed225a81ca3bbaf02b"
181
+ "gitHead": "743929ab3c4459266bc8cb5ec6ab3402daeac10c"
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)
@@ -1,10 +1,7 @@
1
1
  import '@material/mwc-icon'
2
-
3
2
  import { OxGristEditor, RecordConfig } from '@operato/data-grist'
4
- import { client, gqlContext } from '@operato/graphql'
5
3
 
6
4
  import { customElement } from 'lit/decorators.js'
7
- import gql from 'graphql-tag'
8
5
  import { html } from 'lit'
9
6
 
10
7
  type CommonCodeDetail = {
@@ -13,61 +10,17 @@ type CommonCodeDetail = {
13
10
  rank: number
14
11
  }
15
12
 
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
13
  @customElement('ox-grist-editor-resource-code')
35
14
  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
15
  get editorTemplate() {
63
- var { codes } = this.column.record || {}
16
+ var { codes, selectDispOpt = 'code-name' } = this.column.record || {}
64
17
 
65
18
  return html`
66
19
  <select>
67
- ${(codes || ['']).map(
68
- (code: CommonCode) => html`
20
+ ${(codes || []).map(
21
+ (code: CommonCodeDetail) => html`
69
22
  <option ?selected=${code.name == this.value} value=${code.name}>
70
- ${code.name}${code.description ? ` - ${code.description}` : ''}
23
+ ${code.name == '' ? '' : selectDispOpt.replace('name',code.description).replace('code',code.name)}
71
24
  </option>
72
25
  `
73
26
  )}
@@ -0,0 +1,100 @@
1
+ import gql from 'graphql-tag'
2
+ import { css, html } from 'lit'
3
+ import { client, gqlContext } from '@operato/graphql'
4
+ import { customElement } from 'lit/decorators.js'
5
+
6
+ import { OxGristRenderer } from '@operato/data-grist'
7
+ import { detectOverflow } from '@operato/utils'
8
+
9
+ type CommonCodeDetail = {
10
+ name: string
11
+ description: string
12
+ rank: number
13
+ }
14
+
15
+ const FETCH_COMMON_CODE_GQL = (codeName: string) => gql`
16
+ {
17
+ commonCode(name: "${codeName}") {
18
+ details {
19
+ name
20
+ description
21
+ rank
22
+ }
23
+ }
24
+ }
25
+ `
26
+
27
+ function onmouseover(e: Event) {
28
+ const element = e.target as HTMLSpanElement
29
+ if (detectOverflow(element)) {
30
+ element.setAttribute('data-tooltip', element.textContent!)
31
+ }
32
+ }
33
+
34
+ function onmouseout(e: Event) {
35
+ const element = e.target as HTMLSpanElement
36
+ element.removeAttribute('data-tooltip')
37
+ }
38
+
39
+
40
+ @customElement('ox-grist-renderer-resource-code')
41
+ export class OxGristRendererResourceCode extends OxGristRenderer {
42
+ static styles = css`
43
+ :host {
44
+ display: block;
45
+ position: relative;
46
+
47
+ width: 100%;
48
+ }
49
+
50
+ span {
51
+ text-overflow: ellipsis;
52
+ display: block;
53
+ overflow: hidden;
54
+ }
55
+ `
56
+
57
+ async connectedCallback(){
58
+ var { codeName, codes } = this.column.record || {}
59
+
60
+ if (!codes && codeName) {
61
+ /* codeName으로 fetch 해와서, this.column.record.codes에 보관한다. */
62
+ let response = await client.query({
63
+ query: FETCH_COMMON_CODE_GQL(codeName),
64
+ context: gqlContext()
65
+ })
66
+
67
+ var commonCode = response && response.data && response.data.commonCode
68
+
69
+ this.column.record.codes = [{ name: '', description: '' }].concat(
70
+ commonCode.details.sort(function (a: CommonCodeDetail, b: CommonCodeDetail) {
71
+ return a.rank - b.rank
72
+ })
73
+ )
74
+ }
75
+
76
+ super.connectedCallback();
77
+ }
78
+
79
+ get rendererTemplate() {
80
+ if(!this.value) {
81
+ return html``
82
+ }
83
+
84
+ var { codes, renderDispOpt = 'name' } = this.column.record || {}
85
+
86
+ if(codes){
87
+ for(let idx = 0; idx < codes.length ; idx++){
88
+ let code = codes[idx];
89
+
90
+ if(code.name == this.value){
91
+ return html`<span @mouseover=${onmouseover} @mouseout=${onmouseout}>${code.name == '' ? '' : renderDispOpt.replace('name',code.description).replace('code',code.name)}</span> `
92
+ }
93
+ }
94
+ }
95
+
96
+
97
+
98
+ return html`<span @mouseover=${onmouseover} @mouseout=${onmouseout}>${this.value}</span> `
99
+ }
100
+ }