@operato/app 1.0.0-beta.1 → 1.0.0-beta.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 +27 -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/ox-grist-editor-code.js +5 -8
- package/dist/src/grist-editor/ox-grist-editor-code.js.map +1 -1
- package/dist/src/grist-editor/ox-grist-editor-partition-keys.js +3 -3
- package/dist/src/grist-editor/ox-grist-editor-partition-keys.js.map +1 -1
- package/dist/src/grist-editor/ox-grist-editor-resource-id.d.ts +1 -2
- package/dist/src/grist-editor/ox-grist-editor-resource-id.js +9 -7
- package/dist/src/grist-editor/ox-grist-editor-resource-id.js.map +1 -1
- package/dist/src/grist-editor/ox-grist-editor-resource-object.js +17 -15
- package/dist/src/grist-editor/ox-grist-editor-resource-object.js.map +1 -1
- package/dist/src/grist-editor/ox-selector-resource-id.d.ts +3 -2
- package/dist/src/grist-editor/ox-selector-resource-id.js +8 -3
- package/dist/src/grist-editor/ox-selector-resource-id.js.map +1 -1
- package/dist/src/grist-editor/ox-selector-resource-object.d.ts +3 -2
- package/dist/src/grist-editor/ox-selector-resource-object.js +8 -3
- package/dist/src/grist-editor/ox-selector-resource-object.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- 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/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -15
- package/src/filter-renderer/filter-resource-select.ts +95 -0
- package/src/filter-renderer/index.ts +6 -0
- package/src/grist-editor/ox-grist-editor-code.ts +6 -8
- package/src/grist-editor/ox-grist-editor-partition-keys.ts +4 -4
- package/src/grist-editor/ox-grist-editor-resource-id.ts +12 -10
- package/src/grist-editor/ox-grist-editor-resource-object.ts +19 -17
- package/src/grist-editor/ox-selector-resource-id.ts +10 -4
- package/src/grist-editor/ox-selector-resource-object.ts +11 -5
- package/src/index.ts +2 -1
- package/src/input/ox-input-resource.ts +169 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.0-beta.4](https://github.com/hatiolab/operato/compare/v1.0.0-beta.3...v1.0.0-beta.4) (2022-04-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
* resource-object filter ([c70a727](https://github.com/hatiolab/operato/commit/c70a7270d9b28e51d78d3831bd2f563160d010ef))
|
|
12
|
+
* search for relation fields ([7dc99fd](https://github.com/hatiolab/operato/commit/7dc99fd6df1a96faab4f44ea65c3837934fabc5b))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## [1.0.0-beta.3](https://github.com/hatiolab/operato/compare/v1.0.0-beta.2...v1.0.0-beta.3) (2022-04-12)
|
|
17
|
+
|
|
18
|
+
**Note:** Version bump only for package @operato/app
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## [1.0.0-beta.2](https://github.com/hatiolab/operato/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2022-04-12)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### :rocket: New Features
|
|
28
|
+
|
|
29
|
+
* add 'empty' button into ox-grist-editor-resource-object ([d739d23](https://github.com/hatiolab/operato/commit/d739d23686ea9487e2b9d887c451290638d3633e))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
## [1.0.0-beta.1](https://github.com/hatiolab/operato/compare/v1.0.0-beta.0...v1.0.0-beta.1) (2022-04-11)
|
|
7
34
|
|
|
8
35
|
**Note:** Version bump only for package @operato/app
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import '@operato/input/ox-checkbox.js';
|
|
2
|
+
import '../grist-editor/ox-selector-resource-id';
|
|
3
|
+
import { html } from 'lit-html';
|
|
4
|
+
import { i18next } from '@operato/i18n';
|
|
5
|
+
import { openPopup } from '@operato/layout';
|
|
6
|
+
function openResourceSelector(column, value, confirmCallback) {
|
|
7
|
+
const { queryName, select, list, basicArgs, valueField = 'id' } = column.record.options;
|
|
8
|
+
var actualValue;
|
|
9
|
+
if (typeof valueField === 'function') {
|
|
10
|
+
actualValue = valueField(value);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
actualValue = value === null || value === void 0 ? void 0 : value[valueField];
|
|
14
|
+
}
|
|
15
|
+
var template = html `
|
|
16
|
+
<ox-selector-resource-id
|
|
17
|
+
.value=${actualValue}
|
|
18
|
+
.confirmCallback=${confirmCallback}
|
|
19
|
+
.queryName=${queryName}
|
|
20
|
+
.select=${select}
|
|
21
|
+
.list=${list}
|
|
22
|
+
.basicArgs=${basicArgs}
|
|
23
|
+
.valueField=${valueField}
|
|
24
|
+
></ox-selector-resource-id>
|
|
25
|
+
`;
|
|
26
|
+
const popup = openPopup(template, {
|
|
27
|
+
backdrop: true,
|
|
28
|
+
size: 'large',
|
|
29
|
+
title: i18next.t('title.select_item')
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export const FilterResourceSelect = (column, value, owner) => {
|
|
33
|
+
const filter = column.filter;
|
|
34
|
+
const { operator = 'like' } = filter;
|
|
35
|
+
return operator === 'like'
|
|
36
|
+
? html ` <input
|
|
37
|
+
type="text"
|
|
38
|
+
name=${column.name}
|
|
39
|
+
.value=${value}
|
|
40
|
+
@change=${(e) => {
|
|
41
|
+
const input = e.target;
|
|
42
|
+
input.dispatchEvent(new CustomEvent('filter-change', {
|
|
43
|
+
bubbles: true,
|
|
44
|
+
composed: true,
|
|
45
|
+
detail: {
|
|
46
|
+
name: column.name,
|
|
47
|
+
operator,
|
|
48
|
+
value: input.value
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
}}
|
|
52
|
+
/>`
|
|
53
|
+
: operator == 'in'
|
|
54
|
+
? html ``
|
|
55
|
+
: operator === 'eq'
|
|
56
|
+
? html `
|
|
57
|
+
<input
|
|
58
|
+
style="min-width: 100px; min-height: 24px"
|
|
59
|
+
type="text"
|
|
60
|
+
name=${column.name}
|
|
61
|
+
.value=${value}
|
|
62
|
+
readonly
|
|
63
|
+
@click=${(e) => {
|
|
64
|
+
e.stopPropagation();
|
|
65
|
+
const confirmCallback = (selected) => {
|
|
66
|
+
var { idField = 'id', nameField = 'name', descriptionField = 'description' } = column.record.options || {};
|
|
67
|
+
owner.dispatchEvent(new CustomEvent('filter-change', {
|
|
68
|
+
bubbles: true,
|
|
69
|
+
composed: true,
|
|
70
|
+
detail: selected ? selected[idField] : ''
|
|
71
|
+
}));
|
|
72
|
+
};
|
|
73
|
+
openResourceSelector(column, value, confirmCallback);
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
`
|
|
77
|
+
: html ``;
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=filter-resource-select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-resource-select.js","sourceRoot":"","sources":["../../../src/filter-renderer/filter-resource-select.ts"],"names":[],"mappings":"AAAA,OAAO,+BAA+B,CAAA;AACtC,OAAO,yCAAyC,CAAA;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAG/B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAI3C,SAAS,oBAA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,CAAC,IAAI;oBACjB,QAAQ;oBACR,KAAK,EAAE,KAAK,CAAC,KAAK;iBACnB;aACF,CAAC,CACH,CAAA;QACH,CAAC;SACA;QACL,CAAC,CAAC,QAAQ,IAAI,IAAI;YAClB,CAAC,CAAC,IAAI,CAAA,EAAE;YACR,CAAC,CAAC,QAAQ,KAAK,IAAI;gBACnB,CAAC,CAAC,IAAI,CAAA;;;;iBAIO,MAAM,CAAC,IAAI;mBACT,KAAK;;mBAEL,CAAC,CAAQ,EAAE,EAAE;oBACpB,CAAC,CAAC,eAAe,EAAE,CAAA;oBAEnB,MAAM,eAAe,GAAG,CAAC,QAAmC,EAAE,EAAE;wBAC9D,IAAI,EAAE,OAAO,GAAG,IAAI,EAAE,SAAS,GAAG,MAAM,EAAE,gBAAgB,GAAG,aAAa,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAA;wBAE1G,KAAK,CAAC,aAAa,CACjB,IAAI,WAAW,CAAC,eAAe,EAAE;4BAC/B,OAAO,EAAE,IAAI;4BACb,QAAQ,EAAE,IAAI;4BACd,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;yBAC1C,CAAC,CACH,CAAA;oBACH,CAAC,CAAA;oBAED,oBAAoB,CAAC,MAAM,EAAE,KAAK,EAAE,eAAe,CAAC,CAAA;gBACtD,CAAC;;OAEJ;gBACH,CAAC,CAAC,IAAI,CAAA,EAAE,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import '@operato/input/ox-checkbox.js'\nimport '../grist-editor/ox-selector-resource-id'\n\nimport { html } from 'lit-html'\n\nimport { ColumnConfig, FilterConfigObject, FilterSelectRenderer } from '@operato/data-grist'\nimport { i18next } from '@operato/i18n'\nimport { openPopup } from '@operato/layout'\n\ntype SelectedCallback = (value: { id: string; name: string; description: string }) => void\n\nfunction openResourceSelector(column: ColumnConfig, value: any, confirmCallback: SelectedCallback) {\n const { queryName, select, list, basicArgs, valueField = 'id' } = column.record.options\n\n var actualValue\n if (typeof valueField === 'function') {\n actualValue = valueField(value)\n } else {\n actualValue = value?.[valueField]\n }\n\n var template = html`\n <ox-selector-resource-id\n .value=${actualValue}\n .confirmCallback=${confirmCallback}\n .queryName=${queryName}\n .select=${select}\n .list=${list}\n .basicArgs=${basicArgs}\n .valueField=${valueField}\n ></ox-selector-resource-id>\n `\n\n const popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.select_item')\n })\n}\n\nexport const FilterResourceSelect: FilterSelectRenderer = (column, value, owner) => {\n const filter = column.filter as FilterConfigObject\n const { operator = 'like' } = filter\n\n return operator === 'like'\n ? html` <input\n type=\"text\"\n name=${column.name}\n .value=${value}\n @change=${(e: CustomEvent) => {\n const input = e.target as HTMLInputElement\n input.dispatchEvent(\n new CustomEvent('filter-change', {\n bubbles: true,\n composed: true,\n detail: {\n name: column.name,\n operator,\n value: input.value\n }\n })\n )\n }}\n />`\n : operator == 'in'\n ? html``\n : operator === 'eq'\n ? html`\n <input\n style=\"min-width: 100px; min-height: 24px\"\n type=\"text\"\n name=${column.name}\n .value=${value}\n readonly\n @click=${(e: Event) => {\n e.stopPropagation()\n\n const confirmCallback = (selected?: { [field: string]: any }) => {\n var { idField = 'id', nameField = 'name', descriptionField = 'description' } = column.record.options || {}\n\n owner.dispatchEvent(\n new CustomEvent('filter-change', {\n bubbles: true,\n composed: true,\n detail: selected ? selected[idField] : ''\n })\n )\n }\n\n openResourceSelector(column, value, confirmCallback)\n }}\n />\n `\n : html``\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { registerFilterRenderer } from '@operato/data-grist';
|
|
2
|
+
import { FilterResourceSelect } from './filter-resource-select.js';
|
|
3
|
+
registerFilterRenderer('resource-object', [FilterResourceSelect]);
|
|
4
|
+
registerFilterRenderer('resource-id', [FilterResourceSelect]);
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/filter-renderer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAElE,sBAAsB,CAAC,iBAAiB,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAA;AACjE,sBAAsB,CAAC,aAAa,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAA","sourcesContent":["import { registerFilterRenderer } from '@operato/data-grist'\n\nimport { FilterResourceSelect } from './filter-resource-select.js'\n\nregisterFilterRenderer('resource-object', [FilterResourceSelect])\nregisterFilterRenderer('resource-id', [FilterResourceSelect])\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import './ox-popup-code-input.js';
|
|
3
|
-
import { OxGristEditor } from '@operato/data-grist';
|
|
4
|
-
import { customElement } from 'lit/decorators.js';
|
|
5
3
|
import { html } from 'lit';
|
|
4
|
+
import { customElement } from 'lit/decorators.js';
|
|
5
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
6
6
|
import { i18next } from '@operato/i18n';
|
|
7
7
|
import { openPopup } from '@operato/layout';
|
|
8
8
|
let OxGristEditorCode = class OxGristEditorCode extends OxGristEditor {
|
|
@@ -21,7 +21,7 @@ let OxGristEditorCode = class OxGristEditorCode extends OxGristEditor {
|
|
|
21
21
|
var _a;
|
|
22
22
|
var { mode } = ((_a = this.column.record) === null || _a === void 0 ? void 0 : _a.options) || {};
|
|
23
23
|
var change = (value) => {
|
|
24
|
-
this.dispatchEvent(new CustomEvent('change', {
|
|
24
|
+
this.dispatchEvent(new CustomEvent('field-change', {
|
|
25
25
|
bubbles: true,
|
|
26
26
|
composed: true,
|
|
27
27
|
detail: {
|
|
@@ -37,14 +37,11 @@ let OxGristEditorCode = class OxGristEditorCode extends OxGristEditor {
|
|
|
37
37
|
<ox-popup-code-input
|
|
38
38
|
.value=${this.value}
|
|
39
39
|
mode=${mode}
|
|
40
|
-
|
|
41
|
-
change(e.detail.value);
|
|
42
|
-
popup.close();
|
|
43
|
-
}}
|
|
40
|
+
.confirmCallback=${change.bind(this)}
|
|
44
41
|
></ox-popup-code-input>
|
|
45
42
|
`, {
|
|
46
43
|
backdrop: true,
|
|
47
|
-
title: i18next.t('title.
|
|
44
|
+
title: i18next.t('title.edit code'),
|
|
48
45
|
help: 'data-grist/grist-editor/code'
|
|
49
46
|
});
|
|
50
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-grist-editor-code.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-grist-editor-code.ts"],"names":[],"mappings":";AAAA,OAAO,0BAA0B,CAAA;AAEjC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ox-grist-editor-code.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-grist-editor-code.ts"],"names":[],"mappings":";AAAA,OAAO,0BAA0B,CAAA;AAEjC,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAG3C,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,aAAa;IAClD,IAAI,cAAc;QAChB,OAAO,IAAI,CAAA,8BAA8B,IAAI,CAAC,KAAK,IAAI,EAAE,MAAM,CAAA;IACjE,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,cAAc,CAAA;QAEzB,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE;YAC5C,CAAC,CAAC,eAAe,EAAE,CAAA;YAEnB,IAAI,CAAC,eAAe,EAAE,CAAA;QACxB,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,eAAe,EAAE,CAAA;IACxB,CAAC;IAED,eAAe;;QACb,IAAI,EAAE,IAAI,EAAE,GAAG,CAAA,MAAA,IAAI,CAAC,MAAM,CAAC,MAAM,0CAAE,OAAO,KAAI,EAAE,CAAA;QAEhD,IAAI,MAAM,GAAG,CAAC,KAAa,EAAE,EAAE;YAC7B,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,cAAc,EAAE;gBAC9B,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,IAAI;gBACd,MAAM,EAAE;oBACN,MAAM,EAAE,IAAI,CAAC,KAAK;oBAClB,KAAK,EAAE,KAAK;oBACZ,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,GAAG,EAAE,IAAI,CAAC,GAAG;iBACd;aACF,CAAC,CACH,CAAA;QACH,CAAC,CAAA;QAED,IAAI,KAAK,GAAG,SAAS,CACnB,IAAI,CAAA;;mBAES,IAAI,CAAC,KAAK;iBACZ,IAAI;6BACQ,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;;OAEvC,EACD;YACE,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC;YACnC,IAAI,EAAE,8BAA8B;SACrC,CACF,CAAA;IACH,CAAC;CACF,CAAA;AAnDY,iBAAiB;IAD7B,aAAa,CAAC,sBAAsB,CAAC;GACzB,iBAAiB,CAmD7B;SAnDY,iBAAiB","sourcesContent":["import './ox-popup-code-input.js'\n\nimport { html } from 'lit'\nimport { customElement } from 'lit/decorators.js'\n\nimport { OxGristEditor } from '@operato/data-grist'\nimport { i18next } from '@operato/i18n'\nimport { openPopup } from '@operato/layout'\n\n@customElement('ox-grist-editor-code')\nexport class OxGristEditorCode extends OxGristEditor {\n get editorTemplate() {\n return html` <input type=\"text\" .value=${this.value || ''} /> `\n }\n\n async firstUpdated() {\n await this.updateComplete\n\n this.renderRoot.addEventListener('click', e => {\n e.stopPropagation()\n\n this.showEditorPopup()\n })\n\n this.showEditorPopup()\n }\n\n showEditorPopup() {\n var { mode } = this.column.record?.options || {}\n\n var change = (value: string) => {\n this.dispatchEvent(\n new CustomEvent('field-change', {\n bubbles: true,\n composed: true,\n detail: {\n before: this.value,\n after: value,\n column: this.column,\n record: this.record,\n row: this.row\n }\n })\n )\n }\n\n var popup = openPopup(\n html`\n <ox-popup-code-input\n .value=${this.value}\n mode=${mode}\n .confirmCallback=${change.bind(this)}\n ></ox-popup-code-input>\n `,\n {\n backdrop: true,\n title: i18next.t('title.edit code'),\n help: 'data-grist/grist-editor/code'\n }\n )\n }\n}\n"]}
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __decorate } from "tslib";
|
|
5
5
|
import './ox-popup-partition-keys-input.js';
|
|
6
|
-
import {
|
|
6
|
+
import { html } from 'lit';
|
|
7
7
|
import { customElement } from 'lit/decorators.js';
|
|
8
|
-
import { OxGristEditor } from '@operato/data-grist';
|
|
9
8
|
import { cloneDeep } from 'lodash-es';
|
|
10
|
-
import {
|
|
9
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
11
10
|
import { i18next } from '@operato/i18n';
|
|
11
|
+
import { openPopup } from '@operato/layout';
|
|
12
12
|
let OxGristEditorPartitionKeys = class OxGristEditorPartitionKeys extends OxGristEditor {
|
|
13
13
|
get editorTemplate() {
|
|
14
14
|
const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-grist-editor-partition-keys.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-grist-editor-partition-keys.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,oCAAoC,CAAA;AAE3C,OAAO,
|
|
1
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IADtC,aAAa,CAAC,gCAAgC,CAAC;GACnC,0BAA0B,CAsEtC;SAtEY,0BAA0B","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-popup-partition-keys-input.js'\n\nimport { html } from 'lit'\nimport { customElement } from 'lit/decorators.js'\nimport { cloneDeep } from 'lodash-es'\n\nimport { OxGristEditor } from '@operato/data-grist'\nimport { i18next } from '@operato/i18n'\nimport { openPopup, PopupHandle } from '@operato/layout'\n\n@customElement('ox-grist-editor-partition-keys')\nexport class OxGristEditorPartitionKeys 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, 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-partition-keys-input .value=${value} .confirmCallback=${confirmCallback}>\n </ox-popup-partition-keys-input>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: `${name?.toUpperCase() || i18next.t('field.partition-keys')} `,\n help\n })\n }\n}\n"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import '@material/mwc-icon';
|
|
2
2
|
import './ox-selector-resource-id.js';
|
|
3
3
|
import { OxGristEditor } from '@operato/data-grist';
|
|
4
|
-
import { TemplateResult } from 'lit';
|
|
5
4
|
export declare class OxGristEditorResourceId extends OxGristEditor {
|
|
6
5
|
private popup?;
|
|
7
|
-
render(): TemplateResult<1>;
|
|
6
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
8
7
|
firstUpdated(): Promise<void>;
|
|
9
8
|
openSelector(): void;
|
|
10
9
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import '@material/mwc-icon';
|
|
3
3
|
import './ox-selector-resource-id.js';
|
|
4
|
-
import { OxGristEditor } from '@operato/data-grist';
|
|
5
|
-
import { openPopup } from '@operato/layout';
|
|
6
4
|
import { html } from 'lit';
|
|
7
5
|
import { customElement } from 'lit/decorators.js';
|
|
6
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
7
|
+
import { openPopup } from '@operato/layout';
|
|
8
8
|
let OxGristEditorResourceId = class OxGristEditorResourceId extends OxGristEditor {
|
|
9
9
|
render() {
|
|
10
10
|
var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {};
|
|
@@ -36,11 +36,13 @@ let OxGristEditorResourceId = class OxGristEditorResourceId extends OxGristEdito
|
|
|
36
36
|
composed: true,
|
|
37
37
|
detail: {
|
|
38
38
|
before: this.value,
|
|
39
|
-
after:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
after: selected
|
|
40
|
+
? {
|
|
41
|
+
[idField]: selected[idField],
|
|
42
|
+
[nameField]: selected[nameField],
|
|
43
|
+
[descriptionField]: selected[descriptionField]
|
|
44
|
+
}
|
|
45
|
+
: null,
|
|
44
46
|
record: this.record,
|
|
45
47
|
column: this.column,
|
|
46
48
|
row: this.row
|
|
@@ -1 +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,
|
|
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,CAAC,gBAAgB,CAAC,WAAW;;KAE1F,CAAA;IACH,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,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Q,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"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import '@material/mwc-icon';
|
|
3
3
|
import './ox-selector-resource-object.js';
|
|
4
|
-
import { openPopup } from '@operato/layout';
|
|
5
4
|
import { html } from 'lit';
|
|
6
|
-
import { OxGristEditor } from '@operato/data-grist';
|
|
7
5
|
import { customElement } from 'lit/decorators.js';
|
|
6
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
8
7
|
import { i18next } from '@operato/i18n';
|
|
8
|
+
import { openPopup } from '@operato/layout';
|
|
9
9
|
let OxGristEditorResourceObject = class OxGristEditorResourceObject extends OxGristEditor {
|
|
10
10
|
get editorTemplate() {
|
|
11
11
|
var value = this.value || {};
|
|
@@ -48,19 +48,21 @@ let OxGristEditorResourceObject = class OxGristEditorResourceObject extends OxGr
|
|
|
48
48
|
composed: true,
|
|
49
49
|
detail: {
|
|
50
50
|
before: this.value,
|
|
51
|
-
after:
|
|
52
|
-
|
|
53
|
-
.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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,
|
|
64
66
|
record: this.record,
|
|
65
67
|
column: this.column,
|
|
66
68
|
row: this.row
|
|
@@ -1 +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,
|
|
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,mBAAmB,CAAA;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,SAAS,EAAe,MAAM,iBAAiB,CAAA;AAGxD,IAAa,2BAA2B,GAAxC,MAAa,2BAA4B,SAAQ,aAAa;IAI5D,IAAI,cAAc;QAChB,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAA;QAE5B,IAAI,EAAE,SAAS,GAAG,MAAM,EAAE,gBAAgB,GAAG,aAAa,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAA;QAC/F,IAAI,IAAI,EAAE,WAAW,CAAA;QACrB,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;YACnC,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;SACxB;aAAM;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AI,QAAQ,GACV,IAAI,CAAC,QAAQ;YACb,IAAI,CAAA;;mBAES,WAAW;6BACD,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;uBAChC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS;oBACvC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM;kBACnC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI;uBAC1B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS;wBACnC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU;;OAEtD,CAAA;QAEH,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE;YAC/B,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC;SACtC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AA3GY,2BAA2B;IADvC,aAAa,CAAC,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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '@operato/data-grist';
|
|
2
|
-
import { DataGrist, FetchOption, GristData, GristRecord } from '@operato/data-grist';
|
|
3
2
|
import { LitElement } from 'lit';
|
|
3
|
+
import { DataGrist, FetchOption, GristData, GristRecord } from '@operato/data-grist';
|
|
4
4
|
export declare class OxSelectorResourceId extends LitElement {
|
|
5
5
|
static styles: import("lit").CSSResult;
|
|
6
6
|
value?: string;
|
|
@@ -8,10 +8,11 @@ export declare class OxSelectorResourceId extends LitElement {
|
|
|
8
8
|
data: GristData;
|
|
9
9
|
queryName: string;
|
|
10
10
|
basicArgs: any;
|
|
11
|
-
confirmCallback?: (record
|
|
11
|
+
confirmCallback?: (record?: GristRecord) => void;
|
|
12
12
|
selectedRecords: GristRecord[];
|
|
13
13
|
grist: DataGrist;
|
|
14
14
|
render(): import("lit-html").TemplateResult<1>;
|
|
15
|
+
onempty(): void;
|
|
15
16
|
oncancel(): void;
|
|
16
17
|
onconfirm(): void;
|
|
17
18
|
firstUpdated(): Promise<void>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import '@operato/data-grist';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import gql from 'graphql-tag';
|
|
4
|
+
import { css, html, LitElement } from 'lit';
|
|
5
5
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
6
|
+
import { ZERO_DATA } from '@operato/data-grist';
|
|
6
7
|
import { client } from '@operato/graphql';
|
|
7
|
-
import gql from 'graphql-tag';
|
|
8
8
|
import { i18next } from '@operato/i18n';
|
|
9
9
|
import { isMobileDevice } from '@operato/utils';
|
|
10
10
|
let OxSelectorResourceId = class OxSelectorResourceId extends LitElement {
|
|
@@ -27,11 +27,16 @@ let OxSelectorResourceId = class OxSelectorResourceId extends LitElement {
|
|
|
27
27
|
</ox-grist>
|
|
28
28
|
|
|
29
29
|
<div class="button-container">
|
|
30
|
+
<mwc-button @click=${this.onempty.bind(this)}>${i18next.t('button.empty')}</mwc-button>
|
|
30
31
|
<mwc-button @click=${this.oncancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
|
|
31
32
|
<mwc-button @click=${this.onconfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
|
|
32
33
|
</div>
|
|
33
34
|
`;
|
|
34
35
|
}
|
|
36
|
+
onempty() {
|
|
37
|
+
this.confirmCallback && this.confirmCallback();
|
|
38
|
+
history.back();
|
|
39
|
+
}
|
|
35
40
|
oncancel() {
|
|
36
41
|
history.back();
|
|
37
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-selector-resource-id.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-selector-resource-id.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,
|
|
1
|
+
{"version":3,"file":"ox-selector-resource-id.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-selector-resource-id.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAkD,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAG/C,IAAa,oBAAoB,GAAjC,MAAa,oBAAqB,SAAQ,UAAU;IAApD;;QAkC8B,SAAI,GAAc,SAAS,CAAA;QAI5B,oBAAe,GAAkB,EAAE,CAAA;IAgJhE,CAAC;IA5IC,MAAM;QACJ,OAAO,IAAI,CAAA;;gBAEC,cAAc,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;kBAChC,IAAI,CAAC,MAAM;wBACL,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;2BACzB,IAAI,CAAC,eAAe;;;;;;;;6B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sLhC;SAtLY,oBAAoB","sourcesContent":["import '@operato/data-grist'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { DataGrist, FetchOption, GristData, GristRecord, ZERO_DATA } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\nimport { isMobileDevice } from '@operato/utils'\n\n@customElement('ox-selector-resource-id')\nexport class OxSelectorResourceId extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n\n background-color: #fff;\n\n width: var(--overlay-center-normal-width, 50%);\n height: var(--overlay-center-normal-height, 50%);\n }\n\n ox-grist {\n flex: 1;\n }\n\n #filters {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n }\n\n #filters > * {\n padding: var(--padding-default) var(--padding-wide);\n }\n\n .button-container {\n display: flex;\n margin-left: auto;\n }\n `\n\n @property({ type: String }) value?: string\n @property({ type: Object }) config: any\n @property({ type: Object }) data: GristData = ZERO_DATA\n @property({ type: String }) queryName!: string\n @property({ type: Object }) basicArgs: any\n @property({ type: Object }) confirmCallback?: (record?: GristRecord) => void\n @property({ type: Array }) selectedRecords: GristRecord[] = []\n\n @query('ox-grist') grist!: DataGrist\n\n render() {\n return html`\n <ox-grist\n .mode=${isMobileDevice() ? 'LIST' : 'GRID'}\n .config=${this.config}\n .fetchHandler=${this.fetchHandler.bind(this)}\n .selectedRecords=${this.selectedRecords}\n >\n <div id=\"filters\" slot=\"headroom\">\n <ox-filters-form></ox-filters-form>\n </div>\n </ox-grist>\n\n <div class=\"button-container\">\n <mwc-button @click=${this.onempty.bind(this)}>${i18next.t('button.empty')}</mwc-button>\n <mwc-button @click=${this.oncancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>\n <mwc-button @click=${this.onconfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>\n </div>\n `\n }\n\n onempty() {\n this.confirmCallback && this.confirmCallback()\n history.back()\n }\n\n oncancel() {\n history.back()\n }\n\n onconfirm() {\n this.confirmCallback && this.confirmCallback(this.selected)\n history.back()\n }\n\n async firstUpdated() {\n this.config = {\n columns: [\n {\n type: 'gutter',\n gutterName: 'sequence'\n },\n {\n type: 'gutter',\n gutterName: 'row-selector',\n multiple: false\n },\n {\n type: 'string',\n name: 'id',\n header: i18next.t('field.id'),\n hidden: true\n },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: {\n align: 'left'\n },\n filter: 'search',\n sortable: true,\n width: 160\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: {\n align: 'left'\n },\n filter: 'search',\n sortable: true,\n width: 300\n }\n ],\n rows: {\n selectable: {\n multiple: false\n },\n handlers: {\n click: 'select-row'\n }\n },\n pagination: {\n infinite: true\n }\n }\n\n await this.updateComplete\n\n /* TODO config가 설정될 때, fetch() 가 동작하므로, fetch 완료 이벤트를 받아서, selected를 설정해주는 것이 좋겠다. \n 현재는 fetch() 가 두번 일어난다.\n */\n await this.grist.fetch()\n\n var selected = this.grist.data.records.find(item => this.value == item.id)\n if (selected) {\n this.selectedRecords = [selected]\n }\n /* TODO config가 설정될 때, fetch() 가 동작하므로, fetch 완료 이벤트를 받아서, selected를 설정해주는 것이 좋겠다. */\n\n await this.updateComplete\n this.grist.focus()\n }\n\n async fetchHandler({ page = 1, limit = 100, sorters = [], filters = [] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n q: ${this.queryName}(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination: { page, limit },\n sortings: sorters\n }\n })\n\n return {\n total: response.data.q.total || 0,\n records: response.data.q.items || []\n }\n }\n\n get selected() {\n var grist = this.renderRoot.querySelector('ox-grist') as DataGrist\n\n var selected = grist.selected\n\n return selected && selected.length > 0 ? selected[0] : undefined\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '@operato/data-grist';
|
|
2
2
|
import '@operato/form/ox-search-form.js';
|
|
3
|
-
import { DataGrist, FetchHandler, FetchOption, GristData, GristRecord } from '@operato/data-grist';
|
|
4
3
|
import { LitElement } from 'lit';
|
|
4
|
+
import { DataGrist, FetchHandler, FetchOption, GristData, GristRecord } from '@operato/data-grist';
|
|
5
5
|
import { SearchForm } from '@operato/form';
|
|
6
6
|
export declare class OxSelectorResourceObject extends LitElement {
|
|
7
7
|
static styles: import("lit").CSSResult[];
|
|
@@ -10,7 +10,7 @@ export declare class OxSelectorResourceObject extends LitElement {
|
|
|
10
10
|
data: GristData;
|
|
11
11
|
queryName: string;
|
|
12
12
|
basicArgs: any;
|
|
13
|
-
confirmCallback?: (record
|
|
13
|
+
confirmCallback?: (record?: GristRecord | null) => void;
|
|
14
14
|
selectedRecords: GristRecord[];
|
|
15
15
|
searchFields: any;
|
|
16
16
|
select: {
|
|
@@ -28,6 +28,7 @@ export declare class OxSelectorResourceObject extends LitElement {
|
|
|
28
28
|
grist: DataGrist;
|
|
29
29
|
searchForm: SearchForm;
|
|
30
30
|
render(): import("lit-html").TemplateResult<1>;
|
|
31
|
+
onempty(): void;
|
|
31
32
|
oncancel(): void;
|
|
32
33
|
onconfirm(): void;
|
|
33
34
|
fetchHandler: FetchHandler;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import '@operato/data-grist';
|
|
3
3
|
import '@operato/form/ox-search-form.js';
|
|
4
|
+
import gql from 'graphql-tag';
|
|
5
|
+
import { css, html, LitElement } from 'lit';
|
|
6
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
4
7
|
import { ZERO_DATA } from '@operato/data-grist';
|
|
5
|
-
import { LitElement, css, html } from 'lit';
|
|
6
8
|
import { MultiColumnFormStyles } from '@operato/form';
|
|
7
9
|
import { buildArgs, client, gqlContext } from '@operato/graphql';
|
|
8
|
-
import { customElement, property, query } from 'lit/decorators.js';
|
|
9
|
-
import gql from 'graphql-tag';
|
|
10
10
|
import { i18next } from '@operato/i18n';
|
|
11
11
|
import { isMobileDevice } from '@operato/utils';
|
|
12
12
|
let OxSelectorResourceObject = class OxSelectorResourceObject extends LitElement {
|
|
@@ -77,11 +77,16 @@ let OxSelectorResourceObject = class OxSelectorResourceObject extends LitElement
|
|
|
77
77
|
></ox-grist>
|
|
78
78
|
|
|
79
79
|
<div class="button-container">
|
|
80
|
+
<mwc-button @click=${this.onempty.bind(this)}>${i18next.t('button.empty')}</mwc-button>
|
|
80
81
|
<mwc-button @click=${this.oncancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
|
|
81
82
|
<mwc-button @click=${this.onconfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
|
|
82
83
|
</div>
|
|
83
84
|
`;
|
|
84
85
|
}
|
|
86
|
+
onempty() {
|
|
87
|
+
this.confirmCallback && this.confirmCallback();
|
|
88
|
+
history.back();
|
|
89
|
+
}
|
|
85
90
|
oncancel() {
|
|
86
91
|
history.back();
|
|
87
92
|
}
|