@things-factory/dataset 6.0.36 → 6.0.38
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/client/activities/activity-data-collect-view.ts +2 -2
- package/dist-client/activities/activity-data-collect-view.d.ts +1 -1
- package/dist-client/activities/activity-data-collect-view.js +2 -2
- package/dist-client/activities/activity-data-collect-view.js.map +1 -1
- package/dist-client/components/ox-data-entry-view.d.ts +12 -0
- package/dist-client/components/ox-data-entry-view.js +181 -0
- package/dist-client/components/ox-data-entry-view.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
@@ -1,4 +1,4 @@
|
|
1
|
-
import '@operato/dataset/ox-data-entry-
|
1
|
+
import '@operato/dataset/ox-data-entry-view.js'
|
2
2
|
|
3
3
|
import gql from 'graphql-tag'
|
4
4
|
import { css, html, LitElement } from 'lit'
|
@@ -35,7 +35,7 @@ export class DataCollectActivityView extends localize(i18next)(LitElement) {
|
|
35
35
|
@state() dataSet?: DataSet & { id: string }
|
36
36
|
|
37
37
|
render() {
|
38
|
-
return html` <ox-data-entry-
|
38
|
+
return html` <ox-data-entry-view .dataSet=${this.dataSet} .value=${this.output}></ox-data-entry-view>`
|
39
39
|
}
|
40
40
|
|
41
41
|
updated(changes) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import '@operato/dataset/ox-data-entry-
|
1
|
+
import '@operato/dataset/ox-data-entry-view.js';
|
2
2
|
import { LitElement } from 'lit';
|
3
3
|
import { DataSet } from '@operato/dataset';
|
4
4
|
declare const DataCollectActivityView_base: (new (...args: any[]) => LitElement) & typeof LitElement;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
2
|
-
import '@operato/dataset/ox-data-entry-
|
2
|
+
import '@operato/dataset/ox-data-entry-view.js';
|
3
3
|
import gql from 'graphql-tag';
|
4
4
|
import { css, html, LitElement } from 'lit';
|
5
5
|
import { customElement, property, state } from 'lit/decorators.js';
|
@@ -8,7 +8,7 @@ import { i18next, localize } from '@operato/i18n';
|
|
8
8
|
import { ScrollbarStyles } from '@operato/styles';
|
9
9
|
let DataCollectActivityView = class DataCollectActivityView extends localize(i18next)(LitElement) {
|
10
10
|
render() {
|
11
|
-
return html ` <ox-data-entry-
|
11
|
+
return html ` <ox-data-entry-view .dataSet=${this.dataSet} .value=${this.output}></ox-data-entry-view>`;
|
12
12
|
}
|
13
13
|
updated(changes) {
|
14
14
|
if (changes.has('input')) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"activity-data-collect-view.js","sourceRoot":"","sources":["../../client/activities/activity-data-collect-view.ts"],"names":[],"mappings":";AAAA,OAAO,wCAAwC,CAAA;AAE/C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAS,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAI1C,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC;IAwBxE,MAAM;QACJ,OAAO,IAAI,CAAA,iCAAiC,IAAI,CAAC,OAAO,WAAW,IAAI,CAAC,MAAM,wBAAwB,CAAA;IACxG,CAAC;IAED,OAAO,CAAC,OAAO;QACb,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YACxB,IAAI,CAAC,YAAY,EAAE,CAAA;SACpB;IACH,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAA;QAE/B,IAAI,EAAE,EAAE;YACN,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;gBAClC,KAAK,EAAE,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;SAoBT;gBACD,SAAS,EAAE;oBACT,EAAE;iBACH;aACF,CAAC,CAAA;YAEF,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAA;SACrC;IACH,CAAC;;AAlEM,8BAAM,GAAG;IACd,eAAe;IACf,GAAG,CAAA;;;;;;;;;;;;;KAaF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sDAAY;AACvC;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;uDAAa;AAExC;IAAC,KAAK,EAAE;;wDAAmC;AAtBhC,uBAAuB;IADnC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,uBAAuB,CAoEnC;SApEY,uBAAuB","sourcesContent":["import '@operato/dataset/ox-data-entry-
|
1
|
+
{"version":3,"file":"activity-data-collect-view.js","sourceRoot":"","sources":["../../client/activities/activity-data-collect-view.ts"],"names":[],"mappings":";AAAA,OAAO,wCAAwC,CAAA;AAE/C,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAS,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAI1C,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC;IAwBxE,MAAM;QACJ,OAAO,IAAI,CAAA,iCAAiC,IAAI,CAAC,OAAO,WAAW,IAAI,CAAC,MAAM,wBAAwB,CAAA;IACxG,CAAC;IAED,OAAO,CAAC,OAAO;QACb,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YACxB,IAAI,CAAC,YAAY,EAAE,CAAA;SACpB;IACH,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAA;QAE/B,IAAI,EAAE,EAAE;YACN,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;gBAClC,KAAK,EAAE,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;SAoBT;gBACD,SAAS,EAAE;oBACT,EAAE;iBACH;aACF,CAAC,CAAA;YAEF,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAA;SACrC;IACH,CAAC;;AAlEM,8BAAM,GAAG;IACd,eAAe;IACf,GAAG,CAAA;;;;;;;;;;;;;KAaF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sDAAY;AACvC;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;uDAAa;AAExC;IAAC,KAAK,EAAE;;wDAAmC;AAtBhC,uBAAuB;IADnC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,uBAAuB,CAoEnC;SApEY,uBAAuB","sourcesContent":["import '@operato/dataset/ox-data-entry-view.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { ScrollbarStyles } from '@operato/styles'\nimport { DataSet } from '@operato/dataset'\n\n@customElement('activity-data-collect-view')\nexport class DataCollectActivityView extends localize(i18next)(LitElement) {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n background-color: #fff;\n }\n\n ox-data-entry-form {\n flex: 1;\n padding: 10px;\n overflow: auto;\n }\n `\n ]\n\n @property({ type: Object }) input?: any\n @property({ type: Object }) output?: any\n\n @state() dataSet?: DataSet & { id: string }\n\n render() {\n return html` <ox-data-entry-view .dataSet=${this.dataSet} .value=${this.output}></ox-data-entry-view>`\n }\n\n updated(changes) {\n if (changes.has('input')) {\n this.fetchDataSet()\n }\n }\n\n async fetchDataSet() {\n const id = this.input.dataSetId\n\n if (id) {\n const response = await client.query({\n query: gql`\n query ($id: String!) {\n dataSet(id: $id) {\n id\n name\n description\n useCase\n dataItems {\n name\n description\n active\n tag\n type\n unit\n options\n quota\n spec\n }\n }\n }\n `,\n variables: {\n id\n }\n })\n\n this.dataSet = response.data.dataSet\n }\n }\n}\n"]}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import '@operato/input/ox-input-file.js';
|
2
|
+
import { LitElement } from 'lit';
|
3
|
+
import { DataSet } from '@operato/dataset';
|
4
|
+
export declare class OxDataEntryView extends LitElement {
|
5
|
+
static styles: import("lit").CSSResult;
|
6
|
+
dataSet?: DataSet;
|
7
|
+
value?: {
|
8
|
+
[tag: string]: any;
|
9
|
+
};
|
10
|
+
render(): import("lit-html").TemplateResult<1>;
|
11
|
+
private buildEntryViews;
|
12
|
+
}
|
@@ -0,0 +1,181 @@
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
2
|
+
import '@operato/input/ox-input-file.js';
|
3
|
+
import { css, html, LitElement } from 'lit';
|
4
|
+
import { customElement, property } from 'lit/decorators.js';
|
5
|
+
let OxDataEntryView = class OxDataEntryView extends LitElement {
|
6
|
+
render() {
|
7
|
+
var _a, _b;
|
8
|
+
return html `<form>
|
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.buildEntryViews()}
|
12
|
+
</form> `;
|
13
|
+
}
|
14
|
+
buildEntryViews() {
|
15
|
+
var _a;
|
16
|
+
const dataItems = (_a = this.dataSet) === null || _a === void 0 ? void 0 : _a.dataItems.filter(item => item.active);
|
17
|
+
return (dataItems || []).map(dataItem => {
|
18
|
+
const { name, description, tag, type, quota = 1, options = {}, unit } = dataItem;
|
19
|
+
const samples = new Array(quota).fill(0);
|
20
|
+
const value = this.value && this.value[tag];
|
21
|
+
const elements = samples.map((_, idx) => {
|
22
|
+
const v = value instanceof Array ? value[idx] : idx === 0 ? value : undefined;
|
23
|
+
switch (type) {
|
24
|
+
case 'select':
|
25
|
+
return html ` <select .name=${tag} disabled>
|
26
|
+
<option value=""></option>
|
27
|
+
${(options.options || []).map(option => html `<option value=${option.value} ?selected=${option.value === v}>${option.text}</option>`)}
|
28
|
+
</select>`;
|
29
|
+
break;
|
30
|
+
case 'boolean':
|
31
|
+
return html ` <input type="checkbox" name=${tag} .checked=${v} disabled />`;
|
32
|
+
break;
|
33
|
+
case 'number':
|
34
|
+
return html ` <input type="number" name=${tag} value=${v} disabled />`;
|
35
|
+
break;
|
36
|
+
case 'file':
|
37
|
+
return html `<ox-input-file
|
38
|
+
name=${tag}
|
39
|
+
label="Attach Files"
|
40
|
+
accept="*/*"
|
41
|
+
multiple="true"
|
42
|
+
hide-filelist
|
43
|
+
disabled
|
44
|
+
></ox-input-file>`;
|
45
|
+
case 'string':
|
46
|
+
default:
|
47
|
+
return html ` <input type="text" name=${tag} value=${v} disabled />`;
|
48
|
+
}
|
49
|
+
});
|
50
|
+
return html ` <label .title=${description}>
|
51
|
+
<div name>${name}${unit ? `(${unit})` : ''}</div>
|
52
|
+
<div description><mwc-icon>info_outline</mwc-icon> ${description}</div>
|
53
|
+
<div elements>${elements}</div>
|
54
|
+
</label>`;
|
55
|
+
});
|
56
|
+
}
|
57
|
+
};
|
58
|
+
OxDataEntryView.styles = css `
|
59
|
+
:host {
|
60
|
+
display: flex;
|
61
|
+
flex-direction: row;
|
62
|
+
|
63
|
+
--item-description-font: normal 0.8rem/1rem var(--theme-font);
|
64
|
+
--item-description-color: var(--page-description-color);
|
65
|
+
}
|
66
|
+
|
67
|
+
h2 {
|
68
|
+
margin: var(--title-margin);
|
69
|
+
font: var(--title-font);
|
70
|
+
color: var(--title-text-color);
|
71
|
+
text-transform: capitalize;
|
72
|
+
text-align: center;
|
73
|
+
}
|
74
|
+
h3 {
|
75
|
+
margin: var(--page-description-margin);
|
76
|
+
font: var(--page-description-font);
|
77
|
+
color: var(--page-description-color);
|
78
|
+
text-transform: capitalize;
|
79
|
+
text-align: center;
|
80
|
+
}
|
81
|
+
|
82
|
+
form {
|
83
|
+
flex: 1;
|
84
|
+
|
85
|
+
display: flex;
|
86
|
+
flex-direction: column;
|
87
|
+
}
|
88
|
+
|
89
|
+
label {
|
90
|
+
display: grid;
|
91
|
+
|
92
|
+
grid-template-rows: auto 1fr;
|
93
|
+
grid-template-columns: 1fr 5fr;
|
94
|
+
grid-template-areas: 'name description' 'empty inputs';
|
95
|
+
|
96
|
+
grid-gap: 9px;
|
97
|
+
align-items: center;
|
98
|
+
margin-bottom: var(--margin-default);
|
99
|
+
}
|
100
|
+
|
101
|
+
label:nth-child(odd) {
|
102
|
+
background-color: var(--main-section-background-color);
|
103
|
+
padding: var(--padding-default) 0;
|
104
|
+
}
|
105
|
+
|
106
|
+
div[name] {
|
107
|
+
grid-area: name;
|
108
|
+
font: var(--label-font);
|
109
|
+
color: var(--label-color);
|
110
|
+
text-align: right;
|
111
|
+
}
|
112
|
+
|
113
|
+
div[description] {
|
114
|
+
grid-area: description;
|
115
|
+
opacity: 0.7;
|
116
|
+
font: var(--item-description-font);
|
117
|
+
color: var(--item-description-color);
|
118
|
+
text-align: left;
|
119
|
+
}
|
120
|
+
|
121
|
+
div[description] * {
|
122
|
+
vertical-align: middle;
|
123
|
+
}
|
124
|
+
|
125
|
+
div[description] mwc-icon {
|
126
|
+
margin-top: -3px;
|
127
|
+
font-size: 0.9rem;
|
128
|
+
}
|
129
|
+
|
130
|
+
div[elements] {
|
131
|
+
grid-area: inputs;
|
132
|
+
display: flex;
|
133
|
+
flex-direction: row;
|
134
|
+
flex-wrap: wrap;
|
135
|
+
gap: 10px;
|
136
|
+
padding-right: var(--padding-default);
|
137
|
+
}
|
138
|
+
|
139
|
+
div[elements] * {
|
140
|
+
flex: 1;
|
141
|
+
}
|
142
|
+
|
143
|
+
div[elements] input,
|
144
|
+
div[elements] select {
|
145
|
+
border: var(--input-field-border);
|
146
|
+
border-radius: var(--input-field-border-radius);
|
147
|
+
padding: var(--input-field-padding);
|
148
|
+
font: var(--input-field-font);
|
149
|
+
}
|
150
|
+
|
151
|
+
@media only screen and (max-width: 460px) {
|
152
|
+
label {
|
153
|
+
display: grid;
|
154
|
+
|
155
|
+
grid-template-rows: auto auto 1fr;
|
156
|
+
grid-template-columns: 1fr;
|
157
|
+
grid-template-areas: 'name' 'description' 'inputs';
|
158
|
+
|
159
|
+
grid-gap: 9px;
|
160
|
+
align-items: center;
|
161
|
+
margin-bottom: var(--margin-default);
|
162
|
+
}
|
163
|
+
|
164
|
+
div[name] {
|
165
|
+
text-align: left;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
`;
|
169
|
+
__decorate([
|
170
|
+
property({ type: Object }),
|
171
|
+
__metadata("design:type", Object)
|
172
|
+
], OxDataEntryView.prototype, "dataSet", void 0);
|
173
|
+
__decorate([
|
174
|
+
property({ type: Object }),
|
175
|
+
__metadata("design:type", Object)
|
176
|
+
], OxDataEntryView.prototype, "value", void 0);
|
177
|
+
OxDataEntryView = __decorate([
|
178
|
+
customElement('ox-data-entry-view')
|
179
|
+
], OxDataEntryView);
|
180
|
+
export { OxDataEntryView };
|
181
|
+
//# sourceMappingURL=ox-data-entry-view.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ox-data-entry-view.js","sourceRoot":"","sources":["../../client/components/ox-data-entry-view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AE,MAAM,EAAE,CAAC;;8CAA+B;AAlH/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 '@operato/dataset'\n\n@customElement('ox-data-entry-view')\nexport class OxDataEntryView extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-direction: row;\n\n --item-description-font: normal 0.8rem/1rem var(--theme-font);\n --item-description-color: var(--page-description-color);\n }\n\n h2 {\n margin: var(--title-margin);\n font: var(--title-font);\n color: var(--title-text-color);\n text-transform: capitalize;\n text-align: center;\n }\n h3 {\n margin: var(--page-description-margin);\n font: var(--page-description-font);\n color: var(--page-description-color);\n text-transform: capitalize;\n text-align: center;\n }\n\n form {\n flex: 1;\n\n display: flex;\n flex-direction: column;\n }\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\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\n div[description] {\n grid-area: description;\n opacity: 0.7;\n font: var(--item-description-font);\n color: var(--item-description-color);\n text-align: left;\n }\n\n div[description] * {\n vertical-align: middle;\n }\n\n div[description] mwc-icon {\n margin-top: -3px;\n font-size: 0.9rem;\n }\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\n div[elements] * {\n flex: 1;\n }\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>\n <h2>${this.dataSet?.name || ''}</h2>\n <h3>${this.dataSet?.description || ''}</h3>\n ${this.buildEntryViews()}\n </form> `\n }\n\n private buildEntryViews() {\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} disabled>\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} disabled />`\n break\n\n case 'number':\n return html` <input type=\"number\" name=${tag} value=${v} disabled />`\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 disabled\n ></ox-input-file>`\n\n case 'string':\n default:\n return html` <input type=\"text\" name=${tag} value=${v} disabled />`\n }\n })\n\n return html` <label .title=${description}>\n <div name>${name}${unit ? `(${unit})` : ''}</div>\n <div description><mwc-icon>info_outline</mwc-icon> ${description}</div>\n <div elements>${elements}</div>\n </label>`\n })\n }\n}\n"]}
|