@operato/app 0.4.3 → 0.4.4
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/filter-renderer/filter-resource-select.d.ts +4 -0
- package/dist/src/filter-renderer/filter-resource-select.js +79 -0
- package/dist/src/filter-renderer/filter-resource-select.js.map +1 -0
- package/dist/src/filter-renderer/index.d.ts +1 -0
- package/dist/src/filter-renderer/index.js +5 -0
- package/dist/src/filter-renderer/index.js.map +1 -0
- package/dist/src/grist-editor/index.d.ts +1 -0
- package/dist/src/grist-editor/index.js +28 -0
- package/dist/src/grist-editor/index.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-editor-code.d.ts +7 -0
- package/dist/src/grist-editor/ox-grist-editor-code.js +53 -0
- package/dist/src/grist-editor/ox-grist-editor-code.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-editor-crontab.d.ts +8 -0
- package/dist/src/grist-editor/ox-grist-editor-crontab.js +50 -0
- package/dist/src/grist-editor/ox-grist-editor-crontab.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-editor-json.d.ts +7 -0
- package/dist/src/grist-editor/ox-grist-editor-json.js +54 -0
- package/dist/src/grist-editor/ox-grist-editor-json.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-editor-parameters.d.ts +12 -0
- package/dist/src/grist-editor/ox-grist-editor-parameters.js +84 -0
- package/dist/src/grist-editor/ox-grist-editor-parameters.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-editor-partition-keys.d.ts +11 -0
- package/dist/src/grist-editor/ox-grist-editor-partition-keys.js +74 -0
- package/dist/src/grist-editor/ox-grist-editor-partition-keys.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-editor-resource-code.d.ts +6 -0
- package/dist/src/grist-editor/ox-grist-editor-resource-code.js +55 -0
- package/dist/src/grist-editor/ox-grist-editor-resource-code.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-editor-resource-id.d.ts +9 -0
- package/dist/src/grist-editor/ox-grist-editor-resource-id.js +72 -0
- package/dist/src/grist-editor/ox-grist-editor-resource-id.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-editor-resource-object.d.ts +11 -0
- package/dist/src/grist-editor/ox-grist-editor-resource-object.js +104 -0
- package/dist/src/grist-editor/ox-grist-editor-resource-object.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-editor-value-map.d.ts +11 -0
- package/dist/src/grist-editor/ox-grist-editor-value-map.js +74 -0
- package/dist/src/grist-editor/ox-grist-editor-value-map.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-renderer-crontab.d.ts +2 -0
- package/dist/src/grist-editor/ox-grist-renderer-crontab.js +26 -0
- package/dist/src/grist-editor/ox-grist-renderer-crontab.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-renderer-resource-id.d.ts +2 -0
- package/dist/src/grist-editor/ox-grist-renderer-resource-id.js +9 -0
- package/dist/src/grist-editor/ox-grist-renderer-resource-id.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-renderer-resource-object.d.ts +2 -0
- package/dist/src/grist-editor/ox-grist-renderer-resource-object.js +22 -0
- package/dist/src/grist-editor/ox-grist-renderer-resource-object.js.map +1 -0
- package/dist/src/grist-editor/ox-parameters-builder.d.ts +4 -0
- package/dist/src/grist-editor/ox-parameters-builder.js +118 -0
- package/dist/src/grist-editor/ox-parameters-builder.js.map +1 -0
- package/dist/src/grist-editor/ox-popup-code-input.d.ts +12 -0
- package/dist/src/grist-editor/ox-popup-code-input.js +71 -0
- package/dist/src/grist-editor/ox-popup-code-input.js.map +1 -0
- package/dist/src/grist-editor/ox-popup-crontab-input.d.ts +11 -0
- package/dist/src/grist-editor/ox-popup-crontab-input.js +74 -0
- package/dist/src/grist-editor/ox-popup-crontab-input.js.map +1 -0
- package/dist/src/grist-editor/ox-popup-parameters-builder.d.ts +13 -0
- package/dist/src/grist-editor/ox-popup-parameters-builder.js +111 -0
- package/dist/src/grist-editor/ox-popup-parameters-builder.js.map +1 -0
- package/dist/src/grist-editor/ox-popup-partition-keys-input.d.ts +12 -0
- package/dist/src/grist-editor/ox-popup-partition-keys-input.js +98 -0
- package/dist/src/grist-editor/ox-popup-partition-keys-input.js.map +1 -0
- package/dist/src/grist-editor/ox-popup-value-map-input.d.ts +12 -0
- package/dist/src/grist-editor/ox-popup-value-map-input.js +104 -0
- package/dist/src/grist-editor/ox-popup-value-map-input.js.map +1 -0
- package/dist/src/grist-editor/ox-selector-resource-id.d.ts +24 -0
- package/dist/src/grist-editor/ox-selector-resource-id.js +202 -0
- package/dist/src/grist-editor/ox-selector-resource-id.js.map +1 -0
- package/dist/src/grist-editor/ox-selector-resource-object.d.ts +39 -0
- package/dist/src/grist-editor/ox-selector-resource-object.js +343 -0
- package/dist/src/grist-editor/ox-selector-resource-object.js.map +1 -0
- package/dist/src/input/index.d.ts +3 -0
- package/dist/src/input/index.js +4 -0
- package/dist/src/input/index.js.map +1 -0
- package/dist/src/input/ox-input-background-pattern.d.ts +31 -0
- package/dist/src/input/ox-input-background-pattern.js +150 -0
- package/dist/src/input/ox-input-background-pattern.js.map +1 -0
- package/dist/src/input/ox-input-fill-style.d.ts +41 -0
- package/dist/src/input/ox-input-fill-style.js +325 -0
- package/dist/src/input/ox-input-fill-style.js.map +1 -0
- package/dist/src/input/ox-input-graphql.d.ts +36 -0
- package/dist/src/input/ox-input-graphql.js +161 -0
- package/dist/src/input/ox-input-graphql.js.map +1 -0
- package/dist/src/input/ox-input-resource.d.ts +36 -0
- package/dist/src/input/ox-input-resource.js +161 -0
- package/dist/src/input/ox-input-resource.js.map +1 -0
- package/dist/src/property-editor/index.d.ts +24 -0
- package/dist/src/property-editor/index.js +58 -0
- package/dist/src/property-editor/index.js.map +1 -0
- package/dist/src/property-editor/ox-property-editor-graphql.d.ts +5 -0
- package/dist/src/property-editor/ox-property-editor-graphql.js +15 -0
- package/dist/src/property-editor/ox-property-editor-graphql.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -8
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '@material/mwc-icon';
|
|
3
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
4
|
+
import { client, gqlContext } from '@operato/graphql';
|
|
5
|
+
import { customElement } from 'lit/decorators.js';
|
|
6
|
+
import gql from 'graphql-tag';
|
|
7
|
+
import { html } from 'lit';
|
|
8
|
+
const FETCH_COMMON_CODE_GQL = (codeName) => gql `
|
|
9
|
+
{
|
|
10
|
+
commonCode(name: "${codeName}") {
|
|
11
|
+
details {
|
|
12
|
+
name
|
|
13
|
+
description
|
|
14
|
+
rank
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
let OxGristEditorResourceCode = class OxGristEditorResourceCode extends OxGristEditor {
|
|
20
|
+
async firstUpdated() {
|
|
21
|
+
super.firstUpdated();
|
|
22
|
+
var { codeName, codes } = this.column.record || {};
|
|
23
|
+
if (!codes && codeName) {
|
|
24
|
+
/* codeName으로 fetch 해와서, this.column.record.codes에 보관한다. */
|
|
25
|
+
var response = await client.query({
|
|
26
|
+
query: FETCH_COMMON_CODE_GQL(codeName),
|
|
27
|
+
context: gqlContext()
|
|
28
|
+
});
|
|
29
|
+
var commonCode = response && response.data && response.data.commonCode;
|
|
30
|
+
if (commonCode) {
|
|
31
|
+
this.column.record.codes = [{ name: '', description: '' }].concat(commonCode.details.sort(function (a, b) {
|
|
32
|
+
return a.rank - b.rank;
|
|
33
|
+
}));
|
|
34
|
+
this.requestUpdate();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
get editorTemplate() {
|
|
39
|
+
var { codes } = this.column.record || {};
|
|
40
|
+
return html `
|
|
41
|
+
<select>
|
|
42
|
+
${(codes || ['']).map((code) => html `
|
|
43
|
+
<option ?selected=${code.name == this.value} value=${code.name}>
|
|
44
|
+
${code.name}${code.description ? ` - ${code.description}` : ''}
|
|
45
|
+
</option>
|
|
46
|
+
`)}
|
|
47
|
+
</select>
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
OxGristEditorResourceCode = __decorate([
|
|
52
|
+
customElement('ox-grist-editor-resource-code')
|
|
53
|
+
], OxGristEditorResourceCode);
|
|
54
|
+
export { OxGristEditorResourceCode };
|
|
55
|
+
//# sourceMappingURL=ox-grist-editor-resource-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-grist-editor-resource-code.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-grist-editor-resource-code.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAE3B,OAAO,EAAE,aAAa,EAAgB,MAAM,qBAAqB,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAc1B,MAAM,qBAAqB,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,GAAG,CAAA;;sBAEjC,QAAQ;;;;;;;;CAQ7B,CAAA;AAGD,IAAa,yBAAyB,GAAtC,MAAa,yBAA0B,SAAQ,aAAa;IAC1D,KAAK,CAAC,YAAY;QAChB,KAAK,CAAC,YAAY,EAAE,CAAA;QAEpB,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAA;QAElD,IAAI,CAAC,KAAK,IAAI,QAAQ,EAAE;YACtB,2DAA2D;YAC3D,IAAI,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;gBAChC,KAAK,EAAE,qBAAqB,CAAC,QAAQ,CAAC;gBACtC,OAAO,EAAE,UAAU,EAAE;aACtB,CAAC,CAAA;YAEF,IAAI,UAAU,GAAG,QAAQ,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAA;YAEtE,IAAI,UAAU,EAAE;gBACd,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,CAC/D,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAmB,EAAE,CAAmB;oBACxE,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAA;gBACxB,CAAC,CAAC,CACH,CAAA;gBAED,IAAI,CAAC,aAAa,EAAE,CAAA;aACrB;SACF;IACH,CAAC;IAED,IAAI,cAAc;QAChB,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAA;QAExC,OAAO,IAAI,CAAA;;UAEL,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CACnB,CAAC,IAAgB,EAAE,EAAE,CAAC,IAAI,CAAA;gCACJ,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,UAAU,IAAI,CAAC,IAAI;gBAC1D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE;;WAEjE,CACF;;KAEJ,CAAA;IACH,CAAC;CACF,CAAA;AA1CY,yBAAyB;IADrC,aAAa,CAAC,+BAA+B,CAAC;GAClC,yBAAyB,CA0CrC;SA1CY,yBAAyB","sourcesContent":["import '@material/mwc-icon'\n\nimport { OxGristEditor, RecordConfig } from '@operato/data-grist'\nimport { client, gqlContext } from '@operato/graphql'\n\nimport { customElement } from 'lit/decorators.js'\nimport gql from 'graphql-tag'\nimport { html } from 'lit'\n\ntype CommonCodeDetail = {\n name: string\n description: string\n rank: number\n}\n\ntype CommonCode = {\n name: string\n description: string\n details: CommonCodeDetail[]\n}\n\nconst FETCH_COMMON_CODE_GQL = (codeName: string) => gql`\n{\n commonCode(name: \"${codeName}\") {\n details {\n name\n description\n rank\n }\n }\n}\n`\n\n@customElement('ox-grist-editor-resource-code')\nexport class OxGristEditorResourceCode extends OxGristEditor {\n async firstUpdated() {\n super.firstUpdated()\n\n var { codeName, codes } = this.column.record || {}\n\n if (!codes && codeName) {\n /* codeName으로 fetch 해와서, this.column.record.codes에 보관한다. */\n var response = await client.query({\n query: FETCH_COMMON_CODE_GQL(codeName),\n context: gqlContext()\n })\n\n var commonCode = response && response.data && response.data.commonCode\n\n if (commonCode) {\n this.column.record.codes = [{ name: '', description: '' }].concat(\n commonCode.details.sort(function (a: CommonCodeDetail, b: CommonCodeDetail) {\n return a.rank - b.rank\n })\n )\n\n this.requestUpdate()\n }\n }\n }\n\n get editorTemplate() {\n var { codes } = this.column.record || {}\n\n return html`\n <select>\n ${(codes || ['']).map(\n (code: CommonCode) => html`\n <option ?selected=${code.name == this.value} value=${code.name}>\n ${code.name}${code.description ? ` - ${code.description}` : ''}\n </option>\n `\n )}\n </select>\n `\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import '@material/mwc-icon';
|
|
2
|
+
import './ox-selector-resource-id.js';
|
|
3
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
4
|
+
export declare class OxGristEditorResourceId extends OxGristEditor {
|
|
5
|
+
private popup?;
|
|
6
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
7
|
+
firstUpdated(): Promise<void>;
|
|
8
|
+
openSelector(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '@material/mwc-icon';
|
|
3
|
+
import './ox-selector-resource-id.js';
|
|
4
|
+
import { html } from 'lit';
|
|
5
|
+
import { customElement } from 'lit/decorators.js';
|
|
6
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
7
|
+
import { openPopup } from '@operato/layout';
|
|
8
|
+
let OxGristEditorResourceId = class OxGristEditorResourceId extends OxGristEditor {
|
|
9
|
+
render() {
|
|
10
|
+
var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {};
|
|
11
|
+
var value = this.value;
|
|
12
|
+
return html `
|
|
13
|
+
${!value ? html `` : html ` <span>${value[nameField]} (${value[descriptionField]})</span> `}
|
|
14
|
+
<mwc-icon>arrow_drop_down</mwc-icon>
|
|
15
|
+
`;
|
|
16
|
+
}
|
|
17
|
+
async firstUpdated() {
|
|
18
|
+
await this.updateComplete;
|
|
19
|
+
this.renderRoot.addEventListener('click', e => {
|
|
20
|
+
e.stopPropagation();
|
|
21
|
+
this.openSelector();
|
|
22
|
+
});
|
|
23
|
+
this.openSelector();
|
|
24
|
+
}
|
|
25
|
+
openSelector() {
|
|
26
|
+
if (this.popup) {
|
|
27
|
+
delete this.popup;
|
|
28
|
+
}
|
|
29
|
+
const confirmCallback = selected => {
|
|
30
|
+
if (!selected) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
var { idField = 'id', nameField = 'name', descriptionField = 'description' } = this.column.record.options || {};
|
|
34
|
+
this.dispatchEvent(new CustomEvent('field-change', {
|
|
35
|
+
bubbles: true,
|
|
36
|
+
composed: true,
|
|
37
|
+
detail: {
|
|
38
|
+
before: this.value,
|
|
39
|
+
after: selected
|
|
40
|
+
? {
|
|
41
|
+
[idField]: selected[idField],
|
|
42
|
+
[nameField]: selected[nameField],
|
|
43
|
+
[descriptionField]: selected[descriptionField]
|
|
44
|
+
}
|
|
45
|
+
: null,
|
|
46
|
+
record: this.record,
|
|
47
|
+
column: this.column,
|
|
48
|
+
row: this.row
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
var value = this.value || {};
|
|
53
|
+
var template = html `
|
|
54
|
+
<ox-selector-resource-id
|
|
55
|
+
.value=${value.id}
|
|
56
|
+
.confirmCallback=${confirmCallback.bind(this)}
|
|
57
|
+
.queryName=${this.column.record.options.queryName}
|
|
58
|
+
.basicArgs=${this.column.record.options.basicArgs}
|
|
59
|
+
></ox-selector-resource-id>
|
|
60
|
+
`;
|
|
61
|
+
this.popup = openPopup(template, {
|
|
62
|
+
backdrop: true,
|
|
63
|
+
size: 'large',
|
|
64
|
+
title: 'select item'
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
OxGristEditorResourceId = __decorate([
|
|
69
|
+
customElement('ox-input-resource-id')
|
|
70
|
+
], OxGristEditorResourceId);
|
|
71
|
+
export { OxGristEditorResourceId };
|
|
72
|
+
//# sourceMappingURL=ox-grist-editor-resource-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-grist-editor-resource-id.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-grist-editor-resource-id.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,8BAA8B,CAAA;AAErC,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAe,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EAAE,SAAS,EAAe,MAAM,iBAAiB,CAAA;AAGxD,IAAa,uBAAuB,GAApC,MAAa,uBAAwB,SAAQ,aAAa;IAGxD,MAAM;QACJ,IAAI,EAAE,SAAS,GAAG,MAAM,EAAE,gBAAgB,GAAG,aAAa,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAA;QAC/F,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;QAEtB,OAAO,IAAI,CAAA;QACP,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA,UAAU,KAAK,CAAC,SAAS,CAAC,KAAK,KAAK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CAAC,CAAA;QAED,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAA;QAC5B,IAAI,QAAQ,GAAG,IAAI,CAAA;;iBAEN,KAAK,CAAC,EAAE;2BACE,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;qBAChC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS;qBACpC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS;;KAEpD,CAAA;QAED,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE;YAC/B,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,aAAa;SACrB,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AA1EY,uBAAuB;IADnC,aAAa,CAAC,sBAAsB,CAAC;GACzB,uBAAuB,CA0EnC;SA1EY,uBAAuB","sourcesContent":["import '@material/mwc-icon'\nimport './ox-selector-resource-id.js'\n\nimport { html } from 'lit'\nimport { customElement } from 'lit/decorators.js'\n\nimport { GristRecord, OxGristEditor } from '@operato/data-grist'\nimport { openPopup, PopupHandle } from '@operato/layout'\n\n@customElement('ox-input-resource-id')\nexport class OxGristEditorResourceId extends OxGristEditor {\n private popup?: PopupHandle\n\n render() {\n var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}\n var value = this.value\n\n return html`\n ${!value ? html`` : html` <span>${value[nameField]} (${value[descriptionField]})</span> `}\n <mwc-icon>arrow_drop_down</mwc-icon>\n `\n }\n\n async firstUpdated() {\n await this.updateComplete\n\n this.renderRoot.addEventListener('click', e => {\n e.stopPropagation()\n\n this.openSelector()\n })\n\n this.openSelector()\n }\n\n openSelector() {\n if (this.popup) {\n delete this.popup\n }\n\n const confirmCallback: (record?: GristRecord) => void = selected => {\n if (!selected) {\n return\n }\n\n var { idField = 'id', nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}\n\n this.dispatchEvent(\n new CustomEvent('field-change', {\n bubbles: true,\n composed: true,\n detail: {\n before: this.value,\n after: selected\n ? {\n [idField]: selected[idField],\n [nameField]: selected[nameField],\n [descriptionField]: selected[descriptionField]\n }\n : null,\n record: this.record,\n column: this.column,\n row: this.row\n }\n })\n )\n }\n\n var value = this.value || {}\n var template = html`\n <ox-selector-resource-id\n .value=${value.id}\n .confirmCallback=${confirmCallback.bind(this)}\n .queryName=${this.column.record.options.queryName}\n .basicArgs=${this.column.record.options.basicArgs}\n ></ox-selector-resource-id>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: 'select item'\n })\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import '@material/mwc-icon';
|
|
2
|
+
import './ox-selector-resource-object.js';
|
|
3
|
+
import { TemplateResult } from 'lit';
|
|
4
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
5
|
+
export declare class OxGristEditorResourceObject extends OxGristEditor {
|
|
6
|
+
private popup?;
|
|
7
|
+
private template?;
|
|
8
|
+
get editorTemplate(): TemplateResult<1>;
|
|
9
|
+
firstUpdated(): Promise<void>;
|
|
10
|
+
openSelector(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '@material/mwc-icon';
|
|
3
|
+
import './ox-selector-resource-object.js';
|
|
4
|
+
import { html } from 'lit';
|
|
5
|
+
import { customElement } from 'lit/decorators.js';
|
|
6
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
7
|
+
import { i18next } from '@operato/i18n';
|
|
8
|
+
import { openPopup } from '@operato/layout';
|
|
9
|
+
let OxGristEditorResourceObject = class OxGristEditorResourceObject extends OxGristEditor {
|
|
10
|
+
get editorTemplate() {
|
|
11
|
+
var value = this.value || {};
|
|
12
|
+
var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {};
|
|
13
|
+
var name, description;
|
|
14
|
+
if (typeof nameField === 'function') {
|
|
15
|
+
name = nameField(value);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
name = value[nameField];
|
|
19
|
+
}
|
|
20
|
+
if (typeof descriptionField === 'function') {
|
|
21
|
+
description = descriptionField(value);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
description = value[descriptionField] && `(${value[descriptionField]})`;
|
|
25
|
+
}
|
|
26
|
+
return html `
|
|
27
|
+
${!value ? html `` : html ` <span>${name || ''}${description || ''}</span> `}
|
|
28
|
+
<mwc-icon>arrow_drop_down</mwc-icon>
|
|
29
|
+
`;
|
|
30
|
+
}
|
|
31
|
+
async firstUpdated() {
|
|
32
|
+
this.template = ((this.column.record || {}).options || {}).template;
|
|
33
|
+
await this.updateComplete;
|
|
34
|
+
this.renderRoot.addEventListener('click', e => {
|
|
35
|
+
e.stopPropagation();
|
|
36
|
+
this.openSelector();
|
|
37
|
+
});
|
|
38
|
+
this.openSelector();
|
|
39
|
+
}
|
|
40
|
+
openSelector() {
|
|
41
|
+
if (this.popup) {
|
|
42
|
+
delete this.popup;
|
|
43
|
+
}
|
|
44
|
+
const confirmCallback = (selected) => {
|
|
45
|
+
var { idField = 'id', nameField = 'name', descriptionField = 'description' } = this.column.record.options || {};
|
|
46
|
+
this.dispatchEvent(new CustomEvent('field-change', {
|
|
47
|
+
bubbles: true,
|
|
48
|
+
composed: true,
|
|
49
|
+
detail: {
|
|
50
|
+
before: this.value,
|
|
51
|
+
after: selected
|
|
52
|
+
? {
|
|
53
|
+
...(this.column.record.options.select || [])
|
|
54
|
+
.map((field) => field.name)
|
|
55
|
+
.reduce((obj, fieldName) => {
|
|
56
|
+
return (obj = {
|
|
57
|
+
...obj,
|
|
58
|
+
[fieldName]: selected[fieldName]
|
|
59
|
+
});
|
|
60
|
+
}, {}),
|
|
61
|
+
[idField]: selected[idField],
|
|
62
|
+
[nameField]: selected[nameField],
|
|
63
|
+
[descriptionField]: selected[descriptionField]
|
|
64
|
+
}
|
|
65
|
+
: null,
|
|
66
|
+
record: this.record,
|
|
67
|
+
column: this.column,
|
|
68
|
+
row: this.row
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
};
|
|
72
|
+
var value = this.value || {};
|
|
73
|
+
var valueField = this.column.record.options.valueField || 'id';
|
|
74
|
+
var actualValue;
|
|
75
|
+
if (typeof valueField === 'function') {
|
|
76
|
+
actualValue = valueField(value);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
actualValue = value[valueField];
|
|
80
|
+
}
|
|
81
|
+
var template = this.template ||
|
|
82
|
+
html `
|
|
83
|
+
<ox-selector-resource-object
|
|
84
|
+
.value=${actualValue}
|
|
85
|
+
.confirmCallback=${confirmCallback.bind(this)}
|
|
86
|
+
.queryName=${this.column.record.options.queryName}
|
|
87
|
+
.select=${this.column.record.options.select}
|
|
88
|
+
.list=${this.column.record.options.list}
|
|
89
|
+
.basicArgs=${this.column.record.options.basicArgs}
|
|
90
|
+
.valueField=${this.column.record.options.valueField}
|
|
91
|
+
></ox-selector-resource-object>
|
|
92
|
+
`;
|
|
93
|
+
this.popup = openPopup(template, {
|
|
94
|
+
backdrop: true,
|
|
95
|
+
size: 'large',
|
|
96
|
+
title: i18next.t('title.select_item')
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
OxGristEditorResourceObject = __decorate([
|
|
101
|
+
customElement('ox-grist-editor-resource-object')
|
|
102
|
+
], OxGristEditorResourceObject);
|
|
103
|
+
export { OxGristEditorResourceObject };
|
|
104
|
+
//# sourceMappingURL=ox-grist-editor-resource-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-grist-editor-resource-object.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-grist-editor-resource-object.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,kCAAkC,CAAA;AAEzC,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,mBA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AAC,iCAAiC,CAAC;GACpC,2BAA2B,CA2GvC;SA3GY,2BAA2B","sourcesContent":["import '@material/mwc-icon'\nimport './ox-selector-resource-object.js'\n\nimport { html, TemplateResult } from 'lit'\nimport { customElement } from 'lit/decorators.js'\n\nimport { OxGristEditor } from '@operato/data-grist'\nimport { i18next } from '@operato/i18n'\nimport { openPopup, PopupHandle } from '@operato/layout'\n\n@customElement('ox-grist-editor-resource-object')\nexport class OxGristEditorResourceObject extends OxGristEditor {\n private popup?: PopupHandle\n private template?: TemplateResult\n\n get editorTemplate() {\n var value = this.value || {}\n\n var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}\n var name, description\n if (typeof nameField === 'function') {\n name = nameField(value)\n } else {\n name = value[nameField]\n }\n\n if (typeof descriptionField === 'function') {\n description = descriptionField(value)\n } else {\n description = value[descriptionField] && `(${value[descriptionField]})`\n }\n\n return html`\n ${!value ? html`` : html` <span>${name || ''}${description || ''}</span> `}\n <mwc-icon>arrow_drop_down</mwc-icon>\n `\n }\n\n async firstUpdated() {\n this.template = ((this.column.record || {}).options || {}).template\n\n await this.updateComplete\n\n this.renderRoot.addEventListener('click', e => {\n e.stopPropagation()\n\n this.openSelector()\n })\n\n this.openSelector()\n }\n\n openSelector() {\n if (this.popup) {\n delete this.popup\n }\n\n const confirmCallback = (selected?: { [field: string]: any }) => {\n var { idField = 'id', nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}\n\n this.dispatchEvent(\n new CustomEvent('field-change', {\n bubbles: true,\n composed: true,\n detail: {\n before: this.value,\n after: selected\n ? {\n ...(this.column.record.options.select || [])\n .map((field: any) => field.name)\n .reduce((obj: { [field: string]: any }, fieldName: string) => {\n return (obj = {\n ...obj,\n [fieldName]: selected[fieldName]\n })\n }, {} as { [field: string]: any }),\n [idField]: selected[idField],\n [nameField]: selected[nameField],\n [descriptionField]: selected[descriptionField]\n }\n : null,\n record: this.record,\n column: this.column,\n row: this.row\n }\n })\n )\n }\n\n var value = this.value || {}\n var valueField: string | ((item: any) => any) = this.column.record.options.valueField || 'id'\n var actualValue\n if (typeof valueField === 'function') {\n actualValue = valueField(value)\n } else {\n actualValue = value[valueField]\n }\n\n var template =\n this.template ||\n html`\n <ox-selector-resource-object\n .value=${actualValue}\n .confirmCallback=${confirmCallback.bind(this)}\n .queryName=${this.column.record.options.queryName}\n .select=${this.column.record.options.select}\n .list=${this.column.record.options.list}\n .basicArgs=${this.column.record.options.basicArgs}\n .valueField=${this.column.record.options.valueField}\n ></ox-selector-resource-object>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.select_item')\n })\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import './ox-popup-value-map-input.js';
|
|
5
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
6
|
+
export declare class OxGristEditorValueMap extends OxGristEditor {
|
|
7
|
+
private popup?;
|
|
8
|
+
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
9
|
+
firstUpdated(): Promise<void>;
|
|
10
|
+
openSelector(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { __decorate } from "tslib";
|
|
5
|
+
import './ox-popup-value-map-input.js';
|
|
6
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
7
|
+
import { openPopup } from '@operato/layout';
|
|
8
|
+
import { html } from 'lit';
|
|
9
|
+
import { customElement } from 'lit/decorators.js';
|
|
10
|
+
import { cloneDeep } from 'lodash-es';
|
|
11
|
+
import { i18next } from '@operato/i18n';
|
|
12
|
+
let OxGristEditorValueMap = class OxGristEditorValueMap extends OxGristEditor {
|
|
13
|
+
get editorTemplate() {
|
|
14
|
+
const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value;
|
|
15
|
+
return html ` ${value || ''} `;
|
|
16
|
+
}
|
|
17
|
+
async firstUpdated() {
|
|
18
|
+
await this.updateComplete;
|
|
19
|
+
this.renderRoot.addEventListener('click', e => {
|
|
20
|
+
e.stopPropagation();
|
|
21
|
+
this.openSelector();
|
|
22
|
+
});
|
|
23
|
+
this.openSelector();
|
|
24
|
+
}
|
|
25
|
+
async openSelector() {
|
|
26
|
+
var _a;
|
|
27
|
+
if (this.popup) {
|
|
28
|
+
delete this.popup;
|
|
29
|
+
}
|
|
30
|
+
const { name, help, valuetype = 'string', objectified = false } = ((_a = this.column.record) === null || _a === void 0 ? void 0 : _a.options) || {};
|
|
31
|
+
const confirmCallback = (newval) => {
|
|
32
|
+
this.dispatchEvent(new CustomEvent('field-change', {
|
|
33
|
+
bubbles: true,
|
|
34
|
+
composed: true,
|
|
35
|
+
detail: {
|
|
36
|
+
before: this.value,
|
|
37
|
+
after: !objectified ? JSON.stringify(newval) : newval,
|
|
38
|
+
record: this.record,
|
|
39
|
+
column: this.column,
|
|
40
|
+
row: this.row
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
try {
|
|
45
|
+
var value = !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(this.value || {});
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
var value = {};
|
|
49
|
+
}
|
|
50
|
+
/*
|
|
51
|
+
주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
|
|
52
|
+
layout의 구성에 변화가 발생하면, 다시 render된다.
|
|
53
|
+
이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
|
|
54
|
+
이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
|
|
55
|
+
만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
|
|
56
|
+
따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
|
|
57
|
+
*/
|
|
58
|
+
var template = html `
|
|
59
|
+
<ox-popup-value-map-input .value=${value} .valuetype=${valuetype} .confirmCallback=${confirmCallback}>
|
|
60
|
+
</ox-popup-value-map-input>
|
|
61
|
+
`;
|
|
62
|
+
this.popup = openPopup(template, {
|
|
63
|
+
backdrop: true,
|
|
64
|
+
size: 'large',
|
|
65
|
+
title: `${(name === null || name === void 0 ? void 0 : name.toUpperCase()) || i18next.t('field.value-map')} `,
|
|
66
|
+
help
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
OxGristEditorValueMap = __decorate([
|
|
71
|
+
customElement('ox-grist-editor-value-map')
|
|
72
|
+
], OxGristEditorValueMap);
|
|
73
|
+
export { OxGristEditorValueMap };
|
|
74
|
+
//# sourceMappingURL=ox-grist-editor-value-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-grist-editor-value-map.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-grist-editor-value-map.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,+BAA+B,CAAA;AAEtC,OAAO,EAA6B,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAC9E,OAAO,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAO,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAY,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,IAAa,qBAAqB,GAAlC,MAAa,qBAAsB,SAAQ,aAAa;IAGtD,IAAI,cAAc;QAChB,MAAM,KAAK,GAAG,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,C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W,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;SACxG;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,KAAK,GAAQ,EAAE,CAAA;SACpB;QAED;;;;;;;UAOE;QACF,IAAI,QAAQ,GAAG,IAAI,CAAA;yCACkB,KAAK,eAAe,SAAS,qBAAqB,eAAe;;KAErG,CAAA;QAED,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE;YAC/B,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,EAAE,KAAI,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG;YAChE,IAAI;SACL,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAtEY,qBAAqB;IADjC,aAAa,CAAC,2BAA2B,CAAC;GAC9B,qBAAqB,CAsEjC;SAtEY,qBAAqB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-popup-value-map-input.js'\n\nimport { ColumnConfig, GristRecord, OxGristEditor } from '@operato/data-grist'\nimport { PopupHandle, openPopup } from '@operato/layout'\nimport { css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { cloneDeep } from 'lodash-es'\nimport { i18next } from '@operato/i18n'\n\n@customElement('ox-grist-editor-value-map')\nexport class OxGristEditorValueMap extends OxGristEditor {\n private popup?: PopupHandle\n\n get editorTemplate() {\n const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value\n return html` ${value || ''} `\n }\n\n async firstUpdated() {\n await this.updateComplete\n\n this.renderRoot.addEventListener('click', e => {\n e.stopPropagation()\n\n this.openSelector()\n })\n\n this.openSelector()\n }\n\n async openSelector() {\n if (this.popup) {\n delete this.popup\n }\n\n const { name, help, valuetype = 'string', objectified = false } = this.column.record?.options || {}\n\n const confirmCallback = (newval: any) => {\n this.dispatchEvent(\n new CustomEvent('field-change', {\n bubbles: true,\n composed: true,\n detail: {\n before: this.value,\n after: !objectified ? JSON.stringify(newval) : newval,\n record: this.record,\n column: this.column,\n row: this.row\n }\n })\n )\n }\n\n try {\n var value: any =\n !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(this.value || {})\n } catch (e) {\n var value: any = {}\n }\n\n /* \n 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로, \n layout의 구성에 변화가 발생하면, 다시 render된다.\n 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)\n 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,\n 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.\n 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.\n */\n var template = html`\n <ox-popup-value-map-input .value=${value} .valuetype=${valuetype} .confirmCallback=${confirmCallback}>\n </ox-popup-value-map-input>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: `${name?.toUpperCase() || i18next.t('field.value-map')} `,\n help\n })\n }\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import cronstrue from 'cronstrue/i18n';
|
|
2
|
+
import { detectOverflow } from '@operato/utils';
|
|
3
|
+
import { html } from 'lit';
|
|
4
|
+
import i18next from 'i18next';
|
|
5
|
+
function onmouseover(e) {
|
|
6
|
+
const element = e.target;
|
|
7
|
+
if (detectOverflow(element)) {
|
|
8
|
+
element.setAttribute('data-tooltip', element.textContent);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function onmouseout(e) {
|
|
12
|
+
const element = e.target;
|
|
13
|
+
element.removeAttribute('data-tooltip');
|
|
14
|
+
}
|
|
15
|
+
export const OxGristRendererCrontab = (value, column, record, rowIndex, field) => {
|
|
16
|
+
let text = '';
|
|
17
|
+
try {
|
|
18
|
+
const language = (i18next.language || 'en').substring(0, 2);
|
|
19
|
+
text = value === undefined ? '' : cronstrue.toString(value, { locale: language || 'en' });
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
console.error(e);
|
|
23
|
+
}
|
|
24
|
+
return html `<span @mouseover=${onmouseover} @mouseout=${onmouseout}>${text}</span>`;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=ox-grist-renderer-crontab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-grist-renderer-crontab.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-grist-renderer-crontab.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,SAAS,WAAW,CAAC,CAAQ;IAC3B,MAAM,OAAO,GAAG,CAAC,CAAC,MAAyB,CAAA;IAC3C,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE;QAC3B,OAAO,CAAC,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,WAAY,CAAC,CAAA;KAC3D;AACH,CAAC;AAED,SAAS,UAAU,CAAC,CAAQ;IAC1B,MAAM,OAAO,GAAG,CAAC,CAAC,MAAyB,CAAA;IAC3C,OAAO,CAAC,eAAe,CAAC,cAAc,CAAC,CAAA;AACzC,CAAC;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;IAC9F,IAAI,IAAI,GAAG,EAAE,CAAA;IAEb,IAAI;QACF,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAC3D,IAAI,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAA;KAC1F;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;KACjB;IAED,OAAO,IAAI,CAAA,oBAAoB,WAAW,cAAc,UAAU,IAAI,IAAI,SAAS,CAAA;AACrF,CAAC,CAAA","sourcesContent":["import { FieldRenderer } from '@operato/data-grist'\nimport cronstrue from 'cronstrue/i18n'\nimport { detectOverflow } from '@operato/utils'\nimport { html } from 'lit'\nimport i18next from 'i18next'\n\nfunction onmouseover(e: Event) {\n const element = e.target as HTMLSpanElement\n if (detectOverflow(element)) {\n element.setAttribute('data-tooltip', element.textContent!)\n }\n}\n\nfunction onmouseout(e: Event) {\n const element = e.target as HTMLSpanElement\n element.removeAttribute('data-tooltip')\n}\n\nexport const OxGristRendererCrontab: FieldRenderer = (value, column, record, rowIndex, field) => {\n let text = ''\n\n try {\n const language = (i18next.language || 'en').substring(0, 2)\n text = value === undefined ? '' : cronstrue.toString(value, { locale: language || 'en' })\n } catch (e) {\n console.error(e)\n }\n\n return html`<span @mouseover=${onmouseover} @mouseout=${onmouseout}>${text}</span>`\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
export const OxGristRendererResourceId = (value, column, record, rowIndex, field) => {
|
|
3
|
+
if (!value) {
|
|
4
|
+
return '';
|
|
5
|
+
}
|
|
6
|
+
var { nameField = 'name', descriptionField = 'description' } = column.record.options || {};
|
|
7
|
+
return html `<span>${value[nameField] || ''}(${value[descriptionField] || ''})</span> `;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=ox-grist-renderer-resource-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-grist-renderer-resource-id.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-grist-renderer-resource-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAI1B,MAAM,CAAC,MAAM,yBAAyB,GAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;IACjG,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAAE,CAAA;KACV;IAED,IAAI,EAAE,SAAS,GAAG,MAAM,EAAE,gBAAgB,GAAG,aAAa,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAA;IAE1F,OAAO,IAAI,CAAA,SAAS,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,gBAAgB,CAAC,IAAI,EAAE,WAAW,CAAA;AACxF,CAAC,CAAA","sourcesContent":["import { html } from 'lit'\n\nimport { FieldRenderer } from '@operato/data-grist'\n\nexport const OxGristRendererResourceId: FieldRenderer = (value, column, record, rowIndex, field) => {\n if (!value) {\n return ''\n }\n\n var { nameField = 'name', descriptionField = 'description' } = column.record.options || {}\n\n return html`<span>${value[nameField] || ''}(${value[descriptionField] || ''})</span> `\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { html } from 'lit-html';
|
|
2
|
+
export const OxGristRendererResourceObject = (value, column, record, rowIndex, field) => {
|
|
3
|
+
if (!value) {
|
|
4
|
+
return '';
|
|
5
|
+
}
|
|
6
|
+
var { nameField = 'name', descriptionField = 'description' } = column.record.options || {};
|
|
7
|
+
var name, description;
|
|
8
|
+
if (typeof nameField === 'function') {
|
|
9
|
+
name = nameField(value);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
name = value[nameField];
|
|
13
|
+
}
|
|
14
|
+
if (typeof descriptionField === 'function') {
|
|
15
|
+
description = descriptionField(value);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
description = value[descriptionField] && `(${value[descriptionField]})`;
|
|
19
|
+
}
|
|
20
|
+
return html `<span>${name || ''}${description || ''}</span> `;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=ox-grist-renderer-resource-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-grist-renderer-resource-object.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-grist-renderer-resource-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAI/B,MAAM,CAAC,MAAM,6BAA6B,GAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;IACrG,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAAE,CAAA;KACV;IAED,IAAI,EAAE,SAAS,GAAG,MAAM,EAAE,gBAAgB,GAAG,aAAa,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAA;IAC1F,IAAI,IAAI,EAAE,WAAW,CAAA;IAErB,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;QACnC,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;KACxB;SAAM;QACL,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAA;KACxB;IAED,IAAI,OAAO,gBAAgB,KAAK,UAAU,EAAE;QAC1C,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;KACtC;SAAM;QACL,WAAW,GAAG,KAAK,CAAC,gBAAgB,CAAC,IAAI,IAAI,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAA;KACxE;IAED,OAAO,IAAI,CAAA,SAAS,IAAI,IAAI,EAAE,GAAG,WAAW,IAAI,EAAE,UAAU,CAAA;AAC9D,CAAC,CAAA","sourcesContent":["import { html } from 'lit-html'\n\nimport { FieldRenderer } from '@operato/data-grist'\n\nexport const OxGristRendererResourceObject: FieldRenderer = (value, column, record, rowIndex, field) => {\n if (!value) {\n return ''\n }\n\n var { nameField = 'name', descriptionField = 'description' } = column.record.options || {}\n var name, description\n\n if (typeof nameField === 'function') {\n name = nameField(value)\n } else {\n name = value[nameField]\n }\n\n if (typeof descriptionField === 'function') {\n description = descriptionField(value)\n } else {\n description = value[descriptionField] && `(${value[descriptionField]})`\n }\n\n return html`<span>${name || ''}${description || ''}</span> `\n}\n"]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { __decorate } from "tslib";
|
|
5
|
+
import { LitElement, html } from 'lit';
|
|
6
|
+
import { OxPropertyEditor } from '@operato/property-editor';
|
|
7
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
8
|
+
import { connect } from 'pwa-helpers/connect-mixin';
|
|
9
|
+
import { store } from '@operato/shell';
|
|
10
|
+
/**
|
|
11
|
+
모든 에디터들은 change 이벤트를 지원해야 한다. 또한, 모든 에디터들은 value속성에 값을 가져야 한다.
|
|
12
|
+
|
|
13
|
+
Example:
|
|
14
|
+
|
|
15
|
+
<ox-parameters-builder value="{{value}}">
|
|
16
|
+
<label>Center X</label>
|
|
17
|
+
<input type="number" .value="${value.cx}">
|
|
18
|
+
<label>Width</label>
|
|
19
|
+
<input type="number" .value="${value.width}">
|
|
20
|
+
</ox-parameters-builder>
|
|
21
|
+
*/
|
|
22
|
+
const DEFAULT_VALUE = {
|
|
23
|
+
legend: '',
|
|
24
|
+
number: 0,
|
|
25
|
+
angle: 0,
|
|
26
|
+
string: '',
|
|
27
|
+
text: '',
|
|
28
|
+
textarea: '',
|
|
29
|
+
checkbox: false,
|
|
30
|
+
select: '',
|
|
31
|
+
color: '#000000',
|
|
32
|
+
'solidcolor-stops': null,
|
|
33
|
+
'gradientcolor-stops': null,
|
|
34
|
+
'gltf-selector': '',
|
|
35
|
+
'image-selector': '',
|
|
36
|
+
multiplecolor: null,
|
|
37
|
+
editortable: null,
|
|
38
|
+
imageselector: '',
|
|
39
|
+
options: null,
|
|
40
|
+
date: null
|
|
41
|
+
};
|
|
42
|
+
let OxParametersBuilder = class OxParametersBuilder extends connect(store)(LitElement) {
|
|
43
|
+
render() {
|
|
44
|
+
return html `<slot></slot>`;
|
|
45
|
+
}
|
|
46
|
+
firstUpdated() {
|
|
47
|
+
this.addEventListener('change', this._onValueChanged.bind(this));
|
|
48
|
+
}
|
|
49
|
+
updated(changes) {
|
|
50
|
+
changes.has('props') && this._onPropsChanged(this.props);
|
|
51
|
+
changes.has('value') && this._setValues();
|
|
52
|
+
}
|
|
53
|
+
_onPropsChanged(props) {
|
|
54
|
+
this.textContent = '';
|
|
55
|
+
(props || []).forEach(prop => {
|
|
56
|
+
let elementType = OxPropertyEditor.getEditor(prop.type);
|
|
57
|
+
if (!elementType) {
|
|
58
|
+
console.warn('Property Editor not defined', prop.type);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
let element = document.createElement(elementType);
|
|
62
|
+
element.label = prop.label;
|
|
63
|
+
element.type = prop.type;
|
|
64
|
+
element.placeholder = prop.placeholder;
|
|
65
|
+
element.host = this.host;
|
|
66
|
+
// element.context = this.context
|
|
67
|
+
element.setAttribute('name', prop.name);
|
|
68
|
+
if (prop.observe) {
|
|
69
|
+
element.observe = prop.observe;
|
|
70
|
+
}
|
|
71
|
+
element.property = prop.property;
|
|
72
|
+
element.setAttribute('property-editor', '');
|
|
73
|
+
this.appendChild(element);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
_setValues() {
|
|
77
|
+
var value = this.value || {};
|
|
78
|
+
Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {
|
|
79
|
+
const editor = propertyEditor;
|
|
80
|
+
let name = editor.getAttribute('name');
|
|
81
|
+
editor.value = value[name] === undefined ? DEFAULT_VALUE[editor.type] : value[name];
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
_getValues() {
|
|
85
|
+
var value = {};
|
|
86
|
+
Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {
|
|
87
|
+
const editor = propertyEditor;
|
|
88
|
+
let name = editor.getAttribute('name');
|
|
89
|
+
value[name] = editor.value === undefined ? DEFAULT_VALUE[editor.type] : editor.value;
|
|
90
|
+
});
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
_onValueChanged(e) {
|
|
94
|
+
e.stopPropagation();
|
|
95
|
+
var prop = e.target;
|
|
96
|
+
if (!prop || !prop.hasAttribute('property-editor')) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.dispatchEvent(new CustomEvent('property-change', {
|
|
100
|
+
bubbles: true,
|
|
101
|
+
composed: true,
|
|
102
|
+
detail: this._getValues()
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
__decorate([
|
|
107
|
+
property({ type: Object })
|
|
108
|
+
], OxParametersBuilder.prototype, "value", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
property({ type: Array })
|
|
111
|
+
], OxParametersBuilder.prototype, "props", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
property({ type: Object })
|
|
114
|
+
], OxParametersBuilder.prototype, "host", void 0);
|
|
115
|
+
OxParametersBuilder = __decorate([
|
|
116
|
+
customElement('ox-parameters-builder')
|
|
117
|
+
], OxParametersBuilder);
|
|
118
|
+
//# sourceMappingURL=ox-parameters-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-parameters-builder.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-parameters-builder.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAE,UAAU,EAAkB,IAAI,EAAE,MAAM,KAAK,CAAA;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,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;kDAAuB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAAU;AAHjC,mBAAmB;IADxB,aAAa,CAAC,uBAAuB,CAAC;GACjC,mBAAmB,CAiFxB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { LitElement, PropertyValues, html } from 'lit'\nimport { OxPropertyEditor, PropertySpec } from '@operato/property-editor'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport { store } from '@operato/shell'\n\n/**\n모든 에디터들은 change 이벤트를 지원해야 한다. 또한, 모든 에디터들은 value속성에 값을 가져야 한다.\n\nExample:\n\n <ox-parameters-builder value=\"{{value}}\">\n <label>Center X</label>\n <input type=\"number\" .value=\"${value.cx}\">\n <label>Width</label>\n <input type=\"number\" .value=\"${value.width}\">\n </ox-parameters-builder>\n*/\n\nconst DEFAULT_VALUE = {\n legend: '',\n number: 0,\n angle: 0,\n string: '',\n text: '',\n textarea: '',\n checkbox: false,\n select: '',\n color: '#000000',\n 'solidcolor-stops': null,\n 'gradientcolor-stops': null,\n 'gltf-selector': '',\n 'image-selector': '',\n multiplecolor: null,\n editortable: null,\n imageselector: '',\n options: null,\n date: null\n} as any\n\n@customElement('ox-parameters-builder')\nclass OxParametersBuilder extends connect(store)(LitElement) {\n @property({ type: Object }) value: any\n @property({ type: Array }) props?: PropertySpec[]\n @property({ type: Object }) host: any\n\n render() {\n return html`<slot></slot>`\n }\n\n firstUpdated() {\n this.addEventListener('change', this._onValueChanged.bind(this))\n }\n\n updated(changes: PropertyValues<this>) {\n changes.has('props') && this._onPropsChanged(this.props)\n changes.has('value') && this._setValues()\n }\n\n _onPropsChanged(props: PropertySpec[] | undefined) {\n this.textContent = ''\n ;(props || []).forEach(prop => {\n let elementType = OxPropertyEditor.getEditor(prop.type)\n if (!elementType) {\n console.warn('Property Editor not defined', prop.type)\n return\n }\n let element = document.createElement(elementType) as OxPropertyEditor\n\n element.label = prop.label\n element.type = prop.type\n element.placeholder = prop.placeholder\n element.host = this.host\n // element.context = this.context\n element.setAttribute('name', prop.name)\n\n if (prop.observe) {\n element.observe = prop.observe\n }\n element.property = prop.property\n element.setAttribute('property-editor', '')\n\n this.appendChild(element)\n })\n }\n\n _setValues() {\n var value = this.value || {}\n Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {\n const editor = propertyEditor as OxPropertyEditor\n let name = editor.getAttribute('name')\n editor.value = value[name!] === undefined ? DEFAULT_VALUE[editor.type] : value[name!]\n })\n }\n\n _getValues() {\n var value = {} as any\n Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {\n const editor = propertyEditor as OxPropertyEditor\n let name = editor.getAttribute('name')\n value[name!] = editor.value === undefined ? DEFAULT_VALUE[editor.type] : editor.value\n })\n\n return value\n }\n\n _onValueChanged(e: Event) {\n e.stopPropagation()\n var prop = e.target as HTMLElement\n\n if (!prop || !prop.hasAttribute('property-editor')) {\n return\n }\n\n this.dispatchEvent(\n new CustomEvent('property-change', {\n bubbles: true,\n composed: true,\n detail: this._getValues()\n })\n )\n }\n}\n"]}
|