@operato/app 1.4.24 → 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/CHANGELOG.md +9 -0
- package/dist/src/grist-editor/ox-grist-editor-resource-code.js +3 -3
- package/dist/src/grist-editor/ox-grist-editor-resource-code.js.map +1 -1
- package/dist/src/grist-editor/ox-grist-renderer-resource-code.d.ts +1 -0
- package/dist/src/grist-editor/ox-grist-renderer-resource-code.js +29 -65
- package/dist/src/grist-editor/ox-grist-renderer-resource-code.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/grist-editor/ox-grist-editor-resource-code.ts +3 -6
- package/src/grist-editor/ox-grist-renderer-resource-code.ts +37 -81
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.
|
|
5
|
+
"version": "1.4.25",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"module": "dist/src/index.js",
|
|
8
8
|
"exports": {
|
|
@@ -178,5 +178,5 @@
|
|
|
178
178
|
"prettier --write"
|
|
179
179
|
]
|
|
180
180
|
},
|
|
181
|
-
"gitHead": "
|
|
181
|
+
"gitHead": "743929ab3c4459266bc8cb5ec6ab3402daeac10c"
|
|
182
182
|
}
|
|
@@ -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 = {
|
|
@@ -16,14 +13,14 @@ type CommonCodeDetail = {
|
|
|
16
13
|
@customElement('ox-grist-editor-resource-code')
|
|
17
14
|
export class OxGristEditorResourceCode extends OxGristEditor {
|
|
18
15
|
get editorTemplate() {
|
|
19
|
-
var { codes } = this.column.record || {}
|
|
16
|
+
var { codes, selectDispOpt = 'code-name' } = this.column.record || {}
|
|
20
17
|
|
|
21
18
|
return html`
|
|
22
19
|
<select>
|
|
23
|
-
${(codes || [
|
|
20
|
+
${(codes || []).map(
|
|
24
21
|
(code: CommonCodeDetail) => html`
|
|
25
22
|
<option ?selected=${code.name == this.value} value=${code.name}>
|
|
26
|
-
|
|
23
|
+
${code.name == '' ? '' : selectDispOpt.replace('name',code.description).replace('code',code.name)}
|
|
27
24
|
</option>
|
|
28
25
|
`
|
|
29
26
|
)}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import gql from 'graphql-tag'
|
|
2
|
-
import { html } from 'lit'
|
|
2
|
+
import { css, html } from 'lit'
|
|
3
3
|
import { client, gqlContext } from '@operato/graphql'
|
|
4
4
|
import { customElement } from 'lit/decorators.js'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { OxGristRenderer } from '@operato/data-grist'
|
|
7
|
+
import { detectOverflow } from '@operato/utils'
|
|
7
8
|
|
|
8
9
|
type CommonCodeDetail = {
|
|
9
10
|
name: string
|
|
@@ -23,8 +24,36 @@ const FETCH_COMMON_CODE_GQL = (codeName: string) => gql`
|
|
|
23
24
|
}
|
|
24
25
|
`
|
|
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
|
+
|
|
26
40
|
@customElement('ox-grist-renderer-resource-code')
|
|
27
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
|
+
|
|
28
57
|
async connectedCallback(){
|
|
29
58
|
var { codeName, codes } = this.column.record || {}
|
|
30
59
|
|
|
@@ -42,103 +71,30 @@ export class OxGristRendererResourceCode extends OxGristRenderer {
|
|
|
42
71
|
return a.rank - b.rank
|
|
43
72
|
})
|
|
44
73
|
)
|
|
45
|
-
|
|
46
|
-
console.log(this.column.record.codes)
|
|
47
74
|
}
|
|
48
75
|
|
|
49
76
|
super.connectedCallback();
|
|
50
77
|
}
|
|
51
|
-
|
|
78
|
+
|
|
52
79
|
get rendererTemplate() {
|
|
53
80
|
if(!this.value) {
|
|
54
81
|
return html``
|
|
55
82
|
}
|
|
56
83
|
|
|
57
|
-
var { codes } = this.column.record || {}
|
|
84
|
+
var { codes, renderDispOpt = 'name' } = this.column.record || {}
|
|
58
85
|
|
|
59
86
|
if(codes){
|
|
60
87
|
for(let idx = 0; idx < codes.length ; idx++){
|
|
61
88
|
let code = codes[idx];
|
|
62
89
|
|
|
63
90
|
if(code.name == this.value){
|
|
64
|
-
return html`<span>${code.description}</span> `
|
|
91
|
+
return html`<span @mouseover=${onmouseover} @mouseout=${onmouseout}>${code.name == '' ? '' : renderDispOpt.replace('name',code.description).replace('code',code.name)}</span> `
|
|
65
92
|
}
|
|
66
93
|
}
|
|
67
94
|
}
|
|
68
95
|
|
|
69
|
-
return html`<span>${this.value}</span> `
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
96
|
|
|
73
97
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
// }
|
|
98
|
+
return html`<span @mouseover=${onmouseover} @mouseout=${onmouseout}>${this.value}</span> `
|
|
99
|
+
}
|
|
100
|
+
}
|