@operato/dataset 1.0.0-alpha.9 → 1.0.0-beta.10
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 +735 -0
- package/demo/index.html +8 -90
- package/demo/ox-data-entry-form.html +118 -0
- package/demo/ox-data-item-spec.html +152 -0
- package/demo/ox-data-ooc-view.html +185 -0
- package/demo/ox-data-sample-view.html +150 -0
- package/demo/ox-grist-editor-data-item-spec.html +476 -0
- package/dist/src/grist-editor/index.d.ts +1 -0
- package/dist/src/grist-editor/index.js +7 -0
- package/dist/src/grist-editor/index.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-editor-data-item-spec.d.ts +11 -0
- package/dist/src/grist-editor/ox-grist-editor-data-item-spec.js +77 -0
- package/dist/src/grist-editor/ox-grist-editor-data-item-spec.js.map +1 -0
- package/dist/src/grist-editor/ox-popup-data-item-spec.d.ts +13 -0
- package/dist/src/grist-editor/ox-popup-data-item-spec.js +91 -0
- package/dist/src/grist-editor/ox-popup-data-item-spec.js.map +1 -0
- package/dist/src/index.d.ts +6 -1
- package/dist/src/index.js +6 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/ox-data-entry-form.d.ts +1 -24
- package/dist/src/ox-data-entry-form.js +52 -26
- package/dist/src/ox-data-entry-form.js.map +1 -1
- package/dist/src/ox-data-item-spec.d.ts +18 -0
- package/dist/src/ox-data-item-spec.js +77 -0
- package/dist/src/ox-data-item-spec.js.map +1 -0
- package/dist/src/ox-data-ooc-view.d.ts +11 -0
- package/dist/src/ox-data-ooc-view.js +75 -0
- package/dist/src/ox-data-ooc-view.js.map +1 -0
- package/dist/src/ox-data-sample-view copy.d.ts +13 -0
- package/dist/src/ox-data-sample-view copy.js +214 -0
- package/dist/src/ox-data-sample-view copy.js.map +1 -0
- package/dist/src/ox-data-sample-view.d.ts +13 -0
- package/dist/src/ox-data-sample-view.js +169 -0
- package/dist/src/ox-data-sample-view.js.map +1 -0
- package/dist/src/ox-data-use-case.d.ts +16 -0
- package/dist/src/ox-data-use-case.js +111 -0
- package/dist/src/ox-data-use-case.js.map +1 -0
- package/dist/src/types.d.ts +78 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -12
- package/src/grist-editor/index.ts +10 -0
- package/src/grist-editor/ox-grist-editor-data-item-spec.ts +92 -0
- package/src/grist-editor/ox-popup-data-item-spec.ts +92 -0
- package/src/index.ts +6 -1
- package/src/ox-data-entry-form.ts +52 -47
- package/src/ox-data-item-spec.ts +74 -0
- package/src/ox-data-ooc-view.ts +75 -0
- package/src/ox-data-sample-view.ts +177 -0
- package/src/ox-data-use-case.ts +147 -0
- package/src/types.ts +72 -0
- package/themes/grist-theme.css +194 -0
- package/themes/oops-theme.css +26 -0
- package/themes/report-theme.css +47 -0
- package/translations/en.json +57 -0
- package/translations/ko.json +56 -0
- package/translations/ms.json +56 -0
- package/translations/zh.json +56 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { __decorate } from "tslib";
|
|
5
|
+
import './ox-popup-data-item-spec.js';
|
|
6
|
+
import { html } from 'lit';
|
|
7
|
+
import { customElement } from 'lit/decorators.js';
|
|
8
|
+
import { cloneDeep } from 'lodash-es';
|
|
9
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
10
|
+
import { i18next } from '@operato/i18n';
|
|
11
|
+
import { openPopup } from '@operato/layout';
|
|
12
|
+
let OxGristEditorDataItemSpec = class OxGristEditorDataItemSpec 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
|
+
if (this.popup) {
|
|
27
|
+
delete this.popup;
|
|
28
|
+
}
|
|
29
|
+
var { options } = this.column.record;
|
|
30
|
+
if (typeof options === 'function') {
|
|
31
|
+
options = await options.call(this, this.value, this.column, this.record, this.row, this.field);
|
|
32
|
+
}
|
|
33
|
+
const { name, help, objectified = false } = options;
|
|
34
|
+
const confirmCallback = (newval) => {
|
|
35
|
+
this.dispatchEvent(new CustomEvent('field-change', {
|
|
36
|
+
bubbles: true,
|
|
37
|
+
composed: true,
|
|
38
|
+
detail: {
|
|
39
|
+
before: this.value,
|
|
40
|
+
after: !objectified ? JSON.stringify(newval) : newval,
|
|
41
|
+
record: this.record,
|
|
42
|
+
column: this.column,
|
|
43
|
+
row: this.row
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
try {
|
|
48
|
+
var value = !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(this.value || {});
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
var value = {};
|
|
52
|
+
}
|
|
53
|
+
/*
|
|
54
|
+
주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
|
|
55
|
+
layout의 구성에 변화가 발생하면, 다시 render된다.
|
|
56
|
+
이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
|
|
57
|
+
이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
|
|
58
|
+
만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
|
|
59
|
+
따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
|
|
60
|
+
*/
|
|
61
|
+
var template = html `
|
|
62
|
+
<ox-popup-data-item-spec .value=${value} .dataItem=${this.record} .confirmCallback=${confirmCallback}>
|
|
63
|
+
</ox-popup-data-item-spec>
|
|
64
|
+
`;
|
|
65
|
+
this.popup = openPopup(template, {
|
|
66
|
+
backdrop: true,
|
|
67
|
+
size: 'large',
|
|
68
|
+
title: `${(name === null || name === void 0 ? void 0 : name.toUpperCase()) || ''} ${i18next.t('field.spec')}`,
|
|
69
|
+
help
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
OxGristEditorDataItemSpec = __decorate([
|
|
74
|
+
customElement('ox-grist-editor-data-item-spec')
|
|
75
|
+
], OxGristEditorDataItemSpec);
|
|
76
|
+
export { OxGristEditorDataItemSpec };
|
|
77
|
+
//# sourceMappingURL=ox-grist-editor-data-item-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-grist-editor-data-item-spec.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-grist-editor-data-item-spec.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,8BAA8B,CAAA;AAErC,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,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,yBAAyB,GAAtC,MAAa,yBAA0B,SAAQ,aAAa;IAG1D,IAAI,cAAc;QAChB,MAAM,KAAK,GAAG,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,C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AAI,CAAC,MAAM;oBACnB,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,GAAG,EAAE,IAAI,CAAC,GAAG;iBACd;aACF,CAAC,CACH,CAAA;QACH,CAAC,CAAA;QAED,IAAI;YACF,IAAI,KAAK,GACP,CAAC,WAAW,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;wCACiB,KAAK,cAAc,IAAI,CAAC,MAAM,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,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE;YAChE,IAAI;SACL,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AA5EY,yBAAyB;IADrC,aAAa,CAAC,gCAAgC,CAAC;GACnC,yBAAyB,CA4ErC;SA5EY,yBAAyB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-popup-data-item-spec.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-data-item-spec')\nexport class OxGristEditorDataItemSpec 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: Event) => {\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 var { options } = this.column.record\n\n if (typeof options === 'function') {\n options = await options.call(this, this.value, this.column, this.record, this.row, this.field)\n }\n\n const { name, help, objectified = false } = 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-data-item-spec .value=${value} .dataItem=${this.record} .confirmCallback=${confirmCallback}>\n </ox-popup-data-item-spec>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: `${name?.toUpperCase() || ''} ${i18next.t('field.spec')}`,\n help\n })\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import '../ox-data-item-spec.js';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import { DataItem } from '../types.js';
|
|
4
|
+
export declare class OxPopupDataItemSpec extends LitElement {
|
|
5
|
+
static styles: import("lit").CSSResult[];
|
|
6
|
+
value: any;
|
|
7
|
+
dataItem?: DataItem;
|
|
8
|
+
confirmCallback: (newval: any) => void;
|
|
9
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
10
|
+
private onChange;
|
|
11
|
+
private onCancel;
|
|
12
|
+
private onConfirm;
|
|
13
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '../ox-data-item-spec.js';
|
|
3
|
+
import { css, html, LitElement } from 'lit';
|
|
4
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
5
|
+
import { i18next } from '@operato/i18n';
|
|
6
|
+
import { ScrollbarStyles } from '@operato/styles';
|
|
7
|
+
let OxPopupDataItemSpec = class OxPopupDataItemSpec extends LitElement {
|
|
8
|
+
render() {
|
|
9
|
+
var dataItem = this.dataItem || {};
|
|
10
|
+
return html `
|
|
11
|
+
<ox-data-item-spec .value=${this.value} .dataItem=${dataItem} @change=${this.onChange.bind(this)}>
|
|
12
|
+
</ox-data-item-spec>
|
|
13
|
+
|
|
14
|
+
<div class="button-container">
|
|
15
|
+
<mwc-button @click=${this.onCancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
|
|
16
|
+
<mwc-button @click=${this.onConfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
|
|
17
|
+
</div>
|
|
18
|
+
`;
|
|
19
|
+
}
|
|
20
|
+
onChange(e) {
|
|
21
|
+
e.stopPropagation();
|
|
22
|
+
/*
|
|
23
|
+
주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
|
|
24
|
+
layout의 구성에 변화가 발생하면, 다시 render된다.
|
|
25
|
+
이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
|
|
26
|
+
이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
|
|
27
|
+
만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
|
|
28
|
+
따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
|
|
29
|
+
(이 팝업 클래스를 템플릿으로 사용한 곳의 코드를 참조하세요.)
|
|
30
|
+
=>
|
|
31
|
+
이런 이유로, Object.assign(...)을 사용하였다.
|
|
32
|
+
*/
|
|
33
|
+
this.value = e.detail;
|
|
34
|
+
}
|
|
35
|
+
onCancel(e) {
|
|
36
|
+
history.back();
|
|
37
|
+
}
|
|
38
|
+
onConfirm(e) {
|
|
39
|
+
this.confirmCallback && this.confirmCallback(this.value);
|
|
40
|
+
history.back();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
OxPopupDataItemSpec.styles = [
|
|
44
|
+
ScrollbarStyles,
|
|
45
|
+
css `
|
|
46
|
+
:host {
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-direction: column;
|
|
49
|
+
|
|
50
|
+
background-color: #fff;
|
|
51
|
+
|
|
52
|
+
width: var(--overlay-center-normal-width, 50%);
|
|
53
|
+
height: var(--overlay-center-normal-height, 50%);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
ox-data-item-spec {
|
|
57
|
+
flex: 1;
|
|
58
|
+
overflow-y: auto;
|
|
59
|
+
padding: var(--padding-wide);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
span {
|
|
63
|
+
flex: 1;
|
|
64
|
+
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
|
|
69
|
+
color: var(--primary-color);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.button-container {
|
|
73
|
+
display: flex;
|
|
74
|
+
margin-left: auto;
|
|
75
|
+
}
|
|
76
|
+
`
|
|
77
|
+
];
|
|
78
|
+
__decorate([
|
|
79
|
+
property({ type: Object })
|
|
80
|
+
], OxPopupDataItemSpec.prototype, "value", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
property({ type: Object })
|
|
83
|
+
], OxPopupDataItemSpec.prototype, "dataItem", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
property({ type: Object })
|
|
86
|
+
], OxPopupDataItemSpec.prototype, "confirmCallback", void 0);
|
|
87
|
+
OxPopupDataItemSpec = __decorate([
|
|
88
|
+
customElement('ox-popup-data-item-spec')
|
|
89
|
+
], OxPopupDataItemSpec);
|
|
90
|
+
export { OxPopupDataItemSpec };
|
|
91
|
+
//# sourceMappingURL=ox-popup-data-item-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-popup-data-item-spec.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-popup-data-item-spec.ts"],"names":[],"mappings":";AAAA,OAAO,yBAAyB,CAAA;AAEhC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAKjD,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,UAAU;IAyCjD,MAAM;QACJ,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAA;QAElC,OAAO,IAAI,CAAA;kCACmB,IAAI,CAAC,KAAK,cAAc,QAAQ,YAAY,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;;;;6BAIzE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;6BACtD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC;;KAEhF,CAAA;IACH,CAAC;IAEO,QAAQ,CAAC,CAAc;QAC7B,CAAC,CAAC,eAAe,EAAE,CAAA;QAEnB;;;;;;;;;;UAUE;QACF,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,MAAM,CAAA;IACvB,CAAC;IAEO,QAAQ,CAAC,CAAQ;QACvB,OAAO,CAAC,IAAI,EAAE,CAAA;IAChB,CAAC;IAEO,SAAS,CAAC,CAAQ;QACxB,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACxD,OAAO,CAAC,IAAI,EAAE,CAAA;IAChB,CAAC;CACF,CAAA;AA/EQ,0BAAM,GAAG;IACd,eAAe;IACf,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+BF;CACF,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAW;AACV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAoB;AACnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAwC;AAvCxD,mBAAmB;IAD/B,aAAa,CAAC,yBAAyB,CAAC;GAC5B,mBAAmB,CAgF/B;SAhFY,mBAAmB","sourcesContent":["import '../ox-data-item-spec.js'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\nimport { ScrollbarStyles } from '@operato/styles'\n\nimport { DataItem } from '../types.js'\n\n@customElement('ox-popup-data-item-spec')\nexport class OxPopupDataItemSpec extends LitElement {\n static styles = [\n ScrollbarStyles,\n 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-data-item-spec {\n flex: 1;\n overflow-y: auto;\n padding: var(--padding-wide);\n }\n\n span {\n flex: 1;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n color: var(--primary-color);\n }\n\n .button-container {\n display: flex;\n margin-left: auto;\n }\n `\n ]\n\n @property({ type: Object }) value: any\n @property({ type: Object }) dataItem?: DataItem\n @property({ type: Object }) confirmCallback!: (newval: any) => void\n\n render() {\n var dataItem = this.dataItem || {}\n\n return html`\n <ox-data-item-spec .value=${this.value} .dataItem=${dataItem} @change=${this.onChange.bind(this)}>\n </ox-data-item-spec>\n\n <div class=\"button-container\">\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 private onChange(e: CustomEvent) {\n e.stopPropagation()\n\n /* \n 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로, \n layout의 구성에 변화가 발생하면, 다시 render된다.\n 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)\n 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,\n 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.\n 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.\n (이 팝업 클래스를 템플릿으로 사용한 곳의 코드를 참조하세요.)\n => \n 이런 이유로, Object.assign(...)을 사용하였다.\n */\n this.value = e.detail\n }\n\n private onCancel(e: Event) {\n history.back()\n }\n\n private onConfirm(e: Event) {\n this.confirmCallback && this.confirmCallback(this.value)\n history.back()\n }\n}\n"]}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
export * from './ox-data-entry-form';
|
|
1
|
+
export * from './ox-data-entry-form.js';
|
|
2
|
+
export * from './ox-data-sample-view.js';
|
|
3
|
+
export * from './ox-data-ooc-view.js';
|
|
4
|
+
export * from './ox-data-item-spec.js';
|
|
5
|
+
export * from './ox-data-use-case';
|
|
6
|
+
export * from './types.js';
|
package/dist/src/index.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export * from './ox-data-entry-form';
|
|
1
|
+
export * from './ox-data-entry-form.js';
|
|
2
|
+
export * from './ox-data-sample-view.js';
|
|
3
|
+
export * from './ox-data-ooc-view.js';
|
|
4
|
+
export * from './ox-data-item-spec.js';
|
|
5
|
+
export * from './ox-data-use-case';
|
|
6
|
+
export * from './types.js';
|
|
2
7
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA","sourcesContent":["export * from './ox-data-entry-form.js'\nexport * from './ox-data-sample-view.js'\nexport * from './ox-data-ooc-view.js'\nexport * from './ox-data-item-spec.js'\nexport * from './ox-data-use-case'\nexport * from './types.js'\n"]}
|
|
@@ -1,28 +1,6 @@
|
|
|
1
1
|
import '@operato/input/ox-input-file.js';
|
|
2
2
|
import { LitElement } from 'lit';
|
|
3
|
-
|
|
4
|
-
text: string;
|
|
5
|
-
value: string;
|
|
6
|
-
};
|
|
7
|
-
declare type SelectOptions = SelectOption[];
|
|
8
|
-
declare type TypeOptions = {
|
|
9
|
-
options?: SelectOptions;
|
|
10
|
-
[prop: string]: any;
|
|
11
|
-
};
|
|
12
|
-
export declare type DataItem = {
|
|
13
|
-
name: string;
|
|
14
|
-
description: string;
|
|
15
|
-
sequence: number;
|
|
16
|
-
tag: string;
|
|
17
|
-
type: string;
|
|
18
|
-
options: TypeOptions;
|
|
19
|
-
quota: number;
|
|
20
|
-
};
|
|
21
|
-
export declare type DataSet = {
|
|
22
|
-
name: string;
|
|
23
|
-
description: string;
|
|
24
|
-
dataItems: DataItem[];
|
|
25
|
-
};
|
|
3
|
+
import { DataSet } from './types.js';
|
|
26
4
|
export declare class OxDataEntryForm extends LitElement {
|
|
27
5
|
static styles: import("lit").CSSResult;
|
|
28
6
|
dataSet?: DataSet;
|
|
@@ -34,4 +12,3 @@ export declare class OxDataEntryForm extends LitElement {
|
|
|
34
12
|
private buildInputs;
|
|
35
13
|
private buildValue;
|
|
36
14
|
}
|
|
37
|
-
export {};
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import '@operato/input/ox-input-file.js';
|
|
3
|
-
import {
|
|
3
|
+
import { css, html, LitElement } from 'lit';
|
|
4
4
|
import { customElement, property } from 'lit/decorators.js';
|
|
5
5
|
let OxDataEntryForm = class OxDataEntryForm extends LitElement {
|
|
6
6
|
render() {
|
|
7
|
-
|
|
7
|
+
var _a, _b;
|
|
8
|
+
return html ` <form @change=${(e) => this.onChange(e)}>
|
|
9
|
+
<h2>${((_a = this.dataSet) === null || _a === void 0 ? void 0 : _a.name) || ''}</h2>
|
|
10
|
+
<h3>${((_b = this.dataSet) === null || _b === void 0 ? void 0 : _b.description) || ''}</h3>
|
|
11
|
+
${this.buildInputs()}
|
|
12
|
+
</form>`;
|
|
8
13
|
}
|
|
9
14
|
onChange(e) {
|
|
10
|
-
|
|
15
|
+
this.value = this.buildValue();
|
|
11
16
|
this.dispatchEvent(new CustomEvent('change', {
|
|
12
17
|
bubbles: true,
|
|
13
18
|
composed: true,
|
|
14
|
-
detail: value
|
|
19
|
+
detail: this.value
|
|
15
20
|
}));
|
|
16
21
|
}
|
|
17
22
|
buildInputs() {
|
|
18
|
-
const dataItems = this.dataSet.dataItems;
|
|
23
|
+
const dataItems = this.dataSet.dataItems.filter(item => item.active);
|
|
19
24
|
return (dataItems || []).map(dataItem => {
|
|
20
|
-
|
|
21
|
-
const { name, description, tag, type, quota = 1, options = {} } = dataItem;
|
|
25
|
+
const { name, description, tag, type, quota = 1, options = {}, unit } = dataItem;
|
|
22
26
|
const samples = new Array(quota).fill(0);
|
|
23
|
-
const value =
|
|
27
|
+
const value = this.value && this.value[tag];
|
|
24
28
|
const elements = samples.map((_, idx) => {
|
|
25
|
-
const v =
|
|
29
|
+
const v = value instanceof Array ? value[idx] : idx === 0 ? value : undefined;
|
|
26
30
|
switch (type) {
|
|
27
31
|
case 'select':
|
|
28
32
|
return html ` <select .name=${tag}>
|
|
@@ -50,7 +54,8 @@ let OxDataEntryForm = class OxDataEntryForm extends LitElement {
|
|
|
50
54
|
}
|
|
51
55
|
});
|
|
52
56
|
return html ` <label .title=${description}>
|
|
53
|
-
<div name>${name}</div>
|
|
57
|
+
<div name>${name}${unit ? `(${unit})` : ''}</div>
|
|
58
|
+
<div description>${description}</div>
|
|
54
59
|
<div elements>${elements}</div>
|
|
55
60
|
</label>`;
|
|
56
61
|
});
|
|
@@ -58,15 +63,10 @@ let OxDataEntryForm = class OxDataEntryForm extends LitElement {
|
|
|
58
63
|
buildValue() {
|
|
59
64
|
const dataItems = this.dataSet.dataItems;
|
|
60
65
|
return (dataItems || []).reduce((sum, dataItem) => {
|
|
61
|
-
const { tag,
|
|
66
|
+
const { tag, type } = dataItem;
|
|
62
67
|
const editors = Array.prototype.slice.call(this.renderRoot.querySelectorAll(`[name=${tag}]`));
|
|
63
68
|
if (editors.length > 0) {
|
|
64
|
-
sum[tag] =
|
|
65
|
-
editors.length > 1
|
|
66
|
-
? editors.map(editor => (type === 'boolean' ? editor.checked : editor.value))
|
|
67
|
-
: type === 'boolean'
|
|
68
|
-
? editors[0].checked
|
|
69
|
-
: editors[0].value;
|
|
69
|
+
sum[tag] = editors.map(editor => (type === 'boolean' ? editor.checked : editor.value));
|
|
70
70
|
}
|
|
71
71
|
return sum;
|
|
72
72
|
}, {});
|
|
@@ -78,6 +78,11 @@ OxDataEntryForm.styles = css `
|
|
|
78
78
|
flex-direction: row;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
h2,
|
|
82
|
+
h3 {
|
|
83
|
+
text-align: center;
|
|
84
|
+
}
|
|
85
|
+
|
|
81
86
|
form {
|
|
82
87
|
flex: 1;
|
|
83
88
|
|
|
@@ -86,23 +91,34 @@ OxDataEntryForm.styles = css `
|
|
|
86
91
|
}
|
|
87
92
|
label {
|
|
88
93
|
display: grid;
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
|
|
95
|
+
grid-template-rows: auto 1fr;
|
|
96
|
+
grid-template-columns: 1fr 5fr;
|
|
97
|
+
grid-template-areas: 'name description' 'empty inputs';
|
|
98
|
+
|
|
99
|
+
grid-gap: 9px;
|
|
91
100
|
align-items: center;
|
|
92
101
|
margin-bottom: var(--margin-default);
|
|
93
102
|
}
|
|
94
|
-
label:nth-child(
|
|
103
|
+
label:nth-child(odd) {
|
|
95
104
|
background-color: var(--main-section-background-color);
|
|
96
105
|
padding: var(--padding-default) 0;
|
|
97
106
|
}
|
|
107
|
+
|
|
98
108
|
div[name] {
|
|
99
|
-
grid-
|
|
109
|
+
grid-area: name;
|
|
100
110
|
font: var(--label-font);
|
|
101
111
|
color: var(--label-color);
|
|
102
112
|
text-align: right;
|
|
103
113
|
}
|
|
114
|
+
div[description] {
|
|
115
|
+
grid-area: description;
|
|
116
|
+
font: var(--page-description-font);
|
|
117
|
+
color: var(--page-description-color);
|
|
118
|
+
text-align: left;
|
|
119
|
+
}
|
|
104
120
|
div[elements] {
|
|
105
|
-
grid-
|
|
121
|
+
grid-area: inputs;
|
|
106
122
|
display: flex;
|
|
107
123
|
flex-direction: row;
|
|
108
124
|
flex-wrap: wrap;
|
|
@@ -119,12 +135,22 @@ OxDataEntryForm.styles = css `
|
|
|
119
135
|
padding: var(--input-field-padding);
|
|
120
136
|
font: var(--input-field-font);
|
|
121
137
|
}
|
|
138
|
+
|
|
122
139
|
@media only screen and (max-width: 460px) {
|
|
123
|
-
|
|
124
|
-
|
|
140
|
+
label {
|
|
141
|
+
display: grid;
|
|
142
|
+
|
|
143
|
+
grid-template-rows: auto auto 1fr;
|
|
144
|
+
grid-template-columns: 1fr;
|
|
145
|
+
grid-template-areas: 'name' 'description' 'inputs';
|
|
146
|
+
|
|
147
|
+
grid-gap: 9px;
|
|
148
|
+
align-items: center;
|
|
149
|
+
margin-bottom: var(--margin-default);
|
|
125
150
|
}
|
|
126
|
-
|
|
127
|
-
|
|
151
|
+
|
|
152
|
+
div[name] {
|
|
153
|
+
text-align: left;
|
|
128
154
|
}
|
|
129
155
|
}
|
|
130
156
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-data-entry-form.js","sourceRoot":"","sources":["../../src/ox-data-entry-form.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AAExC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ox-data-entry-form.js","sourceRoot":"","sources":["../../src/ox-data-entry-form.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAK3D,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,UAAU;IAuF7C,MAAM;;QACJ,OAAO,IAAI,CAAA,kBAAkB,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnD,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,KAAI,EAAE;YACxB,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,WAAW,KA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G,CAAC,EAAE;gBACtB,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;aACvF;YAED,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAA4B,CAAC,CAAA;IAClC,CAAC;CACF,CAAA;AAhLQ,sBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFlB,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAA+B;AArF/C,eAAe;IAD3B,aAAa,CAAC,oBAAoB,CAAC;GACvB,eAAe,CAiL3B;SAjLY,eAAe","sourcesContent":["import '@operato/input/ox-input-file.js'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { DataSet } from './types.js'\n\n@customElement('ox-data-entry-form')\nexport class OxDataEntryForm extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-direction: row;\n }\n\n h2,\n h3 {\n text-align: center;\n }\n\n form {\n flex: 1;\n\n display: flex;\n flex-direction: column;\n }\n label {\n display: grid;\n\n grid-template-rows: auto 1fr;\n grid-template-columns: 1fr 5fr;\n grid-template-areas: 'name description' 'empty inputs';\n\n grid-gap: 9px;\n align-items: center;\n margin-bottom: var(--margin-default);\n }\n label:nth-child(odd) {\n background-color: var(--main-section-background-color);\n padding: var(--padding-default) 0;\n }\n\n div[name] {\n grid-area: name;\n font: var(--label-font);\n color: var(--label-color);\n text-align: right;\n }\n div[description] {\n grid-area: description;\n font: var(--page-description-font);\n color: var(--page-description-color);\n text-align: left;\n }\n div[elements] {\n grid-area: inputs;\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n gap: 10px;\n padding-right: var(--padding-default);\n }\n div[elements] * {\n flex: 1;\n }\n div[elements] input,\n div[elements] select {\n border: var(--input-field-border);\n border-radius: var(--input-field-border-radius);\n padding: var(--input-field-padding);\n font: var(--input-field-font);\n }\n\n @media only screen and (max-width: 460px) {\n label {\n display: grid;\n\n grid-template-rows: auto auto 1fr;\n grid-template-columns: 1fr;\n grid-template-areas: 'name' 'description' 'inputs';\n\n grid-gap: 9px;\n align-items: center;\n margin-bottom: var(--margin-default);\n }\n\n div[name] {\n text-align: left;\n }\n }\n `\n\n @property({ type: Object }) dataSet?: DataSet\n @property({ type: Object }) value?: { [tag: string]: any }\n\n render() {\n return html` <form @change=${(e: Event) => this.onChange(e)}>\n <h2>${this.dataSet?.name || ''}</h2>\n <h3>${this.dataSet?.description || ''}</h3>\n ${this.buildInputs()}\n </form>`\n }\n\n private onChange(e: Event) {\n this.value = this.buildValue()\n\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n }\n\n private buildInputs() {\n const dataItems = this.dataSet!.dataItems.filter(item => item.active)\n\n return (dataItems || []).map(dataItem => {\n const { name, description, tag, type, quota = 1, options = {}, unit } = dataItem\n\n const samples = new Array(quota).fill(0)\n const value = this.value && this.value[tag]\n\n const elements = samples.map((_, idx) => {\n const v = value instanceof Array ? value[idx] : idx === 0 ? value : undefined\n\n switch (type) {\n case 'select':\n return html` <select .name=${tag}>\n <option value=\"\"></option>\n ${(options.options || []).map(\n option => html`<option value=${option.value} ?selected=${option.value === v}>${option.text}</option>`\n )}\n </select>`\n break\n\n case 'boolean':\n return html` <input type=\"checkbox\" name=${tag} .checked=${v} />`\n break\n\n case 'number':\n return html` <input type=\"number\" name=${tag} value=${v} />`\n break\n\n case 'file':\n return html`<ox-input-file\n name=${tag}\n label=\"Attach Files\"\n accept=\"*/*\"\n multiple=\"true\"\n hide-filelist\n ></ox-input-file>`\n\n case 'string':\n default:\n return html` <input type=\"string\" name=${tag} value=${v} />`\n }\n })\n\n return html` <label .title=${description}>\n <div name>${name}${unit ? `(${unit})` : ''}</div>\n <div description>${description}</div>\n <div elements>${elements}</div>\n </label>`\n })\n }\n\n private buildValue() {\n const dataItems = this.dataSet!.dataItems\n\n return (dataItems || []).reduce((sum, dataItem) => {\n const { tag, type } = dataItem\n\n const editors = Array.prototype.slice.call(\n this.renderRoot.querySelectorAll(`[name=${tag}]`) as NodeListOf<HTMLInputElement>\n ) as HTMLInputElement[]\n\n if (editors.length > 0) {\n sum[tag] = editors.map(editor => (type === 'boolean' ? editor.checked : editor.value))\n }\n\n return sum\n }, {} as { [tag: string]: any })\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import '@operato/property-editor/ox-properties-dynamic-view.js';
|
|
2
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
3
|
+
import { DataItem, DataItemSpecSet } from './types.js';
|
|
4
|
+
export declare class OxDataItemSpec extends LitElement {
|
|
5
|
+
static styles: import("lit").CSSResult;
|
|
6
|
+
value?: {
|
|
7
|
+
[specSetName: string]: any;
|
|
8
|
+
};
|
|
9
|
+
dataItem?: DataItem;
|
|
10
|
+
dataItemSpecSets: DataItemSpecSet[];
|
|
11
|
+
specSetViews: NodeListOf<HTMLElement & {
|
|
12
|
+
value: any;
|
|
13
|
+
}>;
|
|
14
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
15
|
+
updated(changes: PropertyValues<this>): void;
|
|
16
|
+
private onChange;
|
|
17
|
+
private buildValue;
|
|
18
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '@operato/property-editor/ox-properties-dynamic-view.js';
|
|
3
|
+
import { css, html, LitElement } from 'lit';
|
|
4
|
+
import { customElement, property, queryAll, state } from 'lit/decorators.js';
|
|
5
|
+
import { OxDataUseCase } from './ox-data-use-case.js';
|
|
6
|
+
let OxDataItemSpec = class OxDataItemSpec extends LitElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.dataItemSpecSets = [];
|
|
10
|
+
}
|
|
11
|
+
render() {
|
|
12
|
+
return html `<form @property-change=${(e) => this.onChange(e)}>
|
|
13
|
+
${this.dataItemSpecSets.map(({ name, description, specs }) => {
|
|
14
|
+
var _a;
|
|
15
|
+
return html ` <div specName>${name}</div>
|
|
16
|
+
<div description>${description}</div>
|
|
17
|
+
<ox-properties-dynamic-view data-name=${name} .props=${specs} .value=${(_a = this.value) === null || _a === void 0 ? void 0 : _a[name]}>
|
|
18
|
+
</ox-properties-dynamic-view>`;
|
|
19
|
+
})}
|
|
20
|
+
</form>`;
|
|
21
|
+
}
|
|
22
|
+
updated(changes) {
|
|
23
|
+
if (changes.has('dataItem')) {
|
|
24
|
+
this.dataItemSpecSets = OxDataUseCase.getUseCases().map(useCase => useCase.getSpecification(this.dataItem));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
onChange(e) {
|
|
28
|
+
this.value = this.buildValue();
|
|
29
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
30
|
+
bubbles: true,
|
|
31
|
+
composed: true,
|
|
32
|
+
detail: { ...this.value }
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
buildValue() {
|
|
36
|
+
var value = {};
|
|
37
|
+
this.specSetViews.forEach(view => (value[view.getAttribute('data-name')] = view.value));
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
OxDataItemSpec.styles = css `
|
|
42
|
+
:host {
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: row;
|
|
45
|
+
border-bottom: var(--border-dark-color);
|
|
46
|
+
padding: var(--margin-default) 0;
|
|
47
|
+
}
|
|
48
|
+
[specName] {
|
|
49
|
+
font: var(--legend-font);
|
|
50
|
+
color: var(--legend-text-color);
|
|
51
|
+
}
|
|
52
|
+
[description] {
|
|
53
|
+
font: var(--form-sublabel-font);
|
|
54
|
+
opacity: 0.8;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
form {
|
|
58
|
+
flex: 1;
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
__decorate([
|
|
62
|
+
property({ type: Object })
|
|
63
|
+
], OxDataItemSpec.prototype, "value", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
property({ type: Object })
|
|
66
|
+
], OxDataItemSpec.prototype, "dataItem", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
state()
|
|
69
|
+
], OxDataItemSpec.prototype, "dataItemSpecSets", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
queryAll('ox-properties-dynamic-view')
|
|
72
|
+
], OxDataItemSpec.prototype, "specSetViews", void 0);
|
|
73
|
+
OxDataItemSpec = __decorate([
|
|
74
|
+
customElement('ox-data-item-spec')
|
|
75
|
+
], OxDataItemSpec);
|
|
76
|
+
export { OxDataItemSpec };
|
|
77
|
+
//# sourceMappingURL=ox-data-item-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-data-item-spec.js","sourceRoot":"","sources":["../../src/ox-data-item-spec.ts"],"names":[],"mappings":";AAAA,OAAO,wDAAwD,CAAA;AAE/D,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAIrD,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,UAAU;IAA9C;;QAyBW,qBAAgB,GAAsB,EAAE,CAAA;IAuCnD,CAAC;IAnCC,MAAM;QACJ,OAAO,IAAI,CAAA,0BAA0B,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,C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MAAM,EAAE,CAAC;6CAAuC;AACtC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAoB;AAEtC;IAAR,KAAK,EAAE;wDAAyC;AAET;IAAvC,QAAQ,CAAC,4BAA4B,CAAC;oDAAwD;AA3BpF,cAAc;IAD1B,aAAa,CAAC,mBAAmB,CAAC;GACtB,cAAc,CAgE1B;SAhEY,cAAc","sourcesContent":["import '@operato/property-editor/ox-properties-dynamic-view.js'\n\nimport { css, html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, queryAll, state } from 'lit/decorators.js'\n\nimport { OxDataUseCase } from './ox-data-use-case.js'\nimport { DataItem, DataItemSpecSet } from './types.js'\n\n@customElement('ox-data-item-spec')\nexport class OxDataItemSpec extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-direction: row;\n border-bottom: var(--border-dark-color);\n padding: var(--margin-default) 0;\n }\n [specName] {\n font: var(--legend-font);\n color: var(--legend-text-color);\n }\n [description] {\n font: var(--form-sublabel-font);\n opacity: 0.8;\n }\n\n form {\n flex: 1;\n }\n `\n\n @property({ type: Object }) value?: { [specSetName: string]: any }\n @property({ type: Object }) dataItem?: DataItem\n\n @state() dataItemSpecSets: DataItemSpecSet[] = []\n\n @queryAll('ox-properties-dynamic-view') specSetViews!: NodeListOf<HTMLElement & { value: any }>\n\n render() {\n return html`<form @property-change=${(e: Event) => this.onChange(e)}>\n ${this.dataItemSpecSets.map(\n ({ name, description, specs }) => html` <div specName>${name}</div>\n <div description>${description}</div>\n <ox-properties-dynamic-view data-name=${name} .props=${specs} .value=${this.value?.[name]}>\n </ox-properties-dynamic-view>`\n )}\n </form>`\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('dataItem')) {\n this.dataItemSpecSets = OxDataUseCase.getUseCases().map(useCase => useCase.getSpecification(this.dataItem!))\n }\n }\n\n private onChange(e: Event) {\n this.value = this.buildValue()\n\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: { ...this.value }\n })\n )\n }\n\n private buildValue() {\n var value = {} as any\n this.specSetViews.forEach(view => (value[view.getAttribute('data-name')!] = view.value))\n\n return value\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import '@operato/input/ox-input-file.js';
|
|
2
|
+
import './ox-data-sample-view';
|
|
3
|
+
import '@material/mwc-icon';
|
|
4
|
+
import { LitElement } from 'lit';
|
|
5
|
+
import { DataOoc, DataSet } from './types.js';
|
|
6
|
+
export declare class OxDataOocView extends LitElement {
|
|
7
|
+
static styles: import("lit").CSSResult;
|
|
8
|
+
dataSet?: DataSet;
|
|
9
|
+
dataOoc?: DataOoc;
|
|
10
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '@operato/input/ox-input-file.js';
|
|
3
|
+
import './ox-data-sample-view';
|
|
4
|
+
import '@material/mwc-icon';
|
|
5
|
+
import { css, html, LitElement } from 'lit';
|
|
6
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
7
|
+
import { i18next } from '@operato/i18n';
|
|
8
|
+
let OxDataOocView = class OxDataOocView extends LitElement {
|
|
9
|
+
render() {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const history = ((_a = this.dataOoc) === null || _a === void 0 ? void 0 : _a.history) || [];
|
|
12
|
+
const formatter = new Intl.DateTimeFormat(navigator.language, { dateStyle: 'full', timeStyle: 'short' });
|
|
13
|
+
return html `
|
|
14
|
+
<ox-data-sample-view .dataSample=${this.dataOoc} .dataSet=${this.dataSet}></ox-data-sample-view>
|
|
15
|
+
|
|
16
|
+
<h3 state>${((_b = this.dataOoc) === null || _b === void 0 ? void 0 : _b.state) || ''}</h3>
|
|
17
|
+
|
|
18
|
+
<h3>${i18next.t('title.history')}</h3>
|
|
19
|
+
${history.map(({ user, state, comment, timestamp }) => html `
|
|
20
|
+
<p page-description>
|
|
21
|
+
${formatter.format(new Date(timestamp))}
|
|
22
|
+
<br />
|
|
23
|
+
${state} <mwc-icon>account_circle</mwc-icon> ${user.name}
|
|
24
|
+
<br />
|
|
25
|
+
${comment}
|
|
26
|
+
</p>
|
|
27
|
+
`)}
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
OxDataOocView.styles = css `
|
|
32
|
+
:host {
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
background-color: var(--main-section-background-color);
|
|
36
|
+
padding: var(--padding-wide);
|
|
37
|
+
|
|
38
|
+
position: relative;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
h3 {
|
|
42
|
+
margin: var(--title-margin);
|
|
43
|
+
padding-top: 12px;
|
|
44
|
+
font: var(--title-font);
|
|
45
|
+
color: var(--title-text-color);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
h3[state] {
|
|
49
|
+
position: absolute;
|
|
50
|
+
|
|
51
|
+
right: 20px;
|
|
52
|
+
top: 25px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
mwc-icon {
|
|
56
|
+
font-size: 16px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
[page-description] {
|
|
60
|
+
margin: var(--page-description-margin);
|
|
61
|
+
font: var(--page-description-font);
|
|
62
|
+
color: var(--page-description-color);
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
__decorate([
|
|
66
|
+
property({ type: Object })
|
|
67
|
+
], OxDataOocView.prototype, "dataSet", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
property({ type: Object })
|
|
70
|
+
], OxDataOocView.prototype, "dataOoc", void 0);
|
|
71
|
+
OxDataOocView = __decorate([
|
|
72
|
+
customElement('ox-data-ooc-view')
|
|
73
|
+
], OxDataOocView);
|
|
74
|
+
export { OxDataOocView };
|
|
75
|
+
//# sourceMappingURL=ox-data-ooc-view.js.map
|