@operato/dataset 1.2.17 → 1.2.19

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.
@@ -0,0 +1,186 @@
1
+ import '@operato/input/ox-input-file.js'
2
+
3
+ import { css, html, LitElement } from 'lit'
4
+ import { customElement, property } from 'lit/decorators.js'
5
+
6
+ import { DataSet } from './types.js'
7
+
8
+ @customElement('ox-data-entry-view')
9
+ export class OxDataEntryView extends LitElement {
10
+ static styles = css`
11
+ :host {
12
+ display: flex;
13
+ flex-direction: row;
14
+
15
+ --item-description-font: normal 0.8rem/1rem var(--theme-font);
16
+ --item-description-color: var(--page-description-color);
17
+ }
18
+
19
+ h2 {
20
+ margin: var(--title-margin);
21
+ font: var(--title-font);
22
+ color: var(--title-text-color);
23
+ text-transform: capitalize;
24
+ text-align: center;
25
+ }
26
+ h3 {
27
+ margin: var(--page-description-margin);
28
+ font: var(--page-description-font);
29
+ color: var(--page-description-color);
30
+ text-transform: capitalize;
31
+ text-align: center;
32
+ }
33
+
34
+ form {
35
+ flex: 1;
36
+
37
+ display: flex;
38
+ flex-direction: column;
39
+ }
40
+
41
+ label {
42
+ display: grid;
43
+
44
+ grid-template-rows: auto 1fr;
45
+ grid-template-columns: 1fr 5fr;
46
+ grid-template-areas: 'name description' 'empty inputs';
47
+
48
+ grid-gap: 9px;
49
+ align-items: center;
50
+ margin-bottom: var(--margin-default);
51
+ }
52
+
53
+ label:nth-child(odd) {
54
+ background-color: var(--main-section-background-color);
55
+ padding: var(--padding-default) 0;
56
+ }
57
+
58
+ div[name] {
59
+ grid-area: name;
60
+ font: var(--label-font);
61
+ color: var(--label-color);
62
+ text-align: right;
63
+ }
64
+
65
+ div[description] {
66
+ grid-area: description;
67
+ opacity: 0.7;
68
+ font: var(--item-description-font);
69
+ color: var(--item-description-color);
70
+ text-align: left;
71
+ }
72
+
73
+ div[description] * {
74
+ vertical-align: middle;
75
+ }
76
+
77
+ div[description] mwc-icon {
78
+ margin-top: -3px;
79
+ font-size: 0.9rem;
80
+ }
81
+
82
+ div[elements] {
83
+ grid-area: inputs;
84
+ display: flex;
85
+ flex-direction: row;
86
+ flex-wrap: wrap;
87
+ gap: 10px;
88
+ padding-right: var(--padding-default);
89
+ }
90
+
91
+ div[elements] * {
92
+ flex: 1;
93
+ }
94
+
95
+ div[elements] input,
96
+ div[elements] select {
97
+ border: var(--input-field-border);
98
+ border-radius: var(--input-field-border-radius);
99
+ padding: var(--input-field-padding);
100
+ font: var(--input-field-font);
101
+ }
102
+
103
+ @media only screen and (max-width: 460px) {
104
+ label {
105
+ display: grid;
106
+
107
+ grid-template-rows: auto auto 1fr;
108
+ grid-template-columns: 1fr;
109
+ grid-template-areas: 'name' 'description' 'inputs';
110
+
111
+ grid-gap: 9px;
112
+ align-items: center;
113
+ margin-bottom: var(--margin-default);
114
+ }
115
+
116
+ div[name] {
117
+ text-align: left;
118
+ }
119
+ }
120
+ `
121
+
122
+ @property({ type: Object }) dataSet?: DataSet
123
+ @property({ type: Object }) value?: { [tag: string]: any }
124
+
125
+ render() {
126
+ return html`<form>
127
+ <h2>${this.dataSet?.name || ''}</h2>
128
+ <h3>${this.dataSet?.description || ''}</h3>
129
+ ${this.buildEntryViews()}
130
+ </form> `
131
+ }
132
+
133
+ private buildEntryViews() {
134
+ const dataItems = this.dataSet?.dataItems.filter(item => item.active)
135
+
136
+ return (dataItems || []).map(dataItem => {
137
+ const { name, description, tag, type, quota = 1, options = {}, unit } = dataItem
138
+
139
+ const samples = new Array(quota).fill(0)
140
+ const value = this.value && this.value[tag]
141
+
142
+ const elements = samples.map((_, idx) => {
143
+ const v = value instanceof Array ? value[idx] : idx === 0 ? value : undefined
144
+
145
+ switch (type) {
146
+ case 'select':
147
+ return html` <select .name=${tag} disabled>
148
+ <option value=""></option>
149
+ ${(options.options || []).map(
150
+ option => html`<option value=${option.value} ?selected=${option.value === v}>${option.text}</option>`
151
+ )}
152
+ </select>`
153
+ break
154
+
155
+ case 'boolean':
156
+ return html` <input type="checkbox" name=${tag} .checked=${v} disabled />`
157
+ break
158
+
159
+ case 'number':
160
+ return html` <input type="number" name=${tag} value=${v} disabled />`
161
+ break
162
+
163
+ case 'file':
164
+ return html`<ox-input-file
165
+ name=${tag}
166
+ label="Attach Files"
167
+ accept="*/*"
168
+ multiple="true"
169
+ hide-filelist
170
+ disabled
171
+ ></ox-input-file>`
172
+
173
+ case 'string':
174
+ default:
175
+ return html` <input type="text" name=${tag} value=${v} disabled />`
176
+ }
177
+ })
178
+
179
+ return html` <label .title=${description}>
180
+ <div name>${name}${unit ? `(${unit})` : ''}</div>
181
+ <div description><mwc-icon>info_outline</mwc-icon> ${description}</div>
182
+ <div elements>${elements}</div>
183
+ </label>`
184
+ })
185
+ }
186
+ }
@@ -0,0 +1,151 @@
1
+ import '@operato/input/ox-input-file.js'
2
+ import './ox-data-sample-view'
3
+ import '@material/mwc-icon'
4
+
5
+ import { css, html, LitElement } from 'lit'
6
+ import { customElement, property } from 'lit/decorators.js'
7
+
8
+ import { i18next } from '@operato/i18n'
9
+
10
+ import { DataOoc, DataSet } from './types.js'
11
+
12
+ @customElement('ox-data-ooc-brief-view')
13
+ export class OxDataOocBriefView extends LitElement {
14
+ static styles = css`
15
+ :host {
16
+ display: flex;
17
+ flex-direction: column;
18
+ background-color: var(--main-section-background-color);
19
+
20
+ position: relative;
21
+ }
22
+
23
+ h3 {
24
+ margin: var(--title-margin);
25
+ padding-top: 12px;
26
+ font: var(--title-font);
27
+ color: var(--title-text-color);
28
+ }
29
+
30
+ h3[state] {
31
+ position: absolute;
32
+ margin: 0;
33
+ padding: 0;
34
+ right: 10px;
35
+ width: 90px;
36
+ text-align: center;
37
+ }
38
+
39
+ mwc-icon {
40
+ font-size: 16px;
41
+ }
42
+ [state] mwc-icon {
43
+ font-size: 80px;
44
+ opacity: 0.4;
45
+ color: var(--primary-background-color);
46
+ }
47
+
48
+ [state] div {
49
+ position: absolute;
50
+ top: 22px;
51
+ left: 0;
52
+ right: 0;
53
+ font-size: 10px;
54
+ color: var(--theme-white-color);
55
+ }
56
+ [state] [field-state] {
57
+ display: block;
58
+ border-radius: 4px;
59
+ background-color: var(--primary-color);
60
+ box-shadow: var(--box-shadow);
61
+ margin-top: var(--margin-narrow);
62
+ padding: 1px 3px;
63
+ font-size: 0.8rem;
64
+ }
65
+ [danger] [field-state] {
66
+ background-color: var(--status-danger-color);
67
+ }
68
+ [complete] [field-state] {
69
+ background-color: var(--status-info-color);
70
+ }
71
+
72
+ div[instruction] {
73
+ display: flex;
74
+ flex-direction: column;
75
+
76
+ padding: var(--padding-wide);
77
+ }
78
+
79
+ div[instruction] div {
80
+ display: flex;
81
+ }
82
+
83
+ div[instruction] div[content] {
84
+ display: flex;
85
+ min-height: 50px;
86
+ }
87
+
88
+ div[action] {
89
+ display: flex;
90
+ flex-direction: column;
91
+
92
+ padding: var(--padding-wide);
93
+ }
94
+
95
+ div[action] div {
96
+ display: flex;
97
+ }
98
+
99
+ div[action] div[content] {
100
+ display: flex;
101
+ min-height: 50px;
102
+ }
103
+ `
104
+
105
+ @property({ type: Object }) dataSet?: DataSet
106
+ @property({ type: Object }) dataOoc?: DataOoc
107
+
108
+ render() {
109
+ const {
110
+ correctiveInstruction = '',
111
+ correctiveAction = '',
112
+ reviewer,
113
+ reviewedAt,
114
+ corrector,
115
+ correctedAt,
116
+ state
117
+ } = this.dataOoc || {}
118
+ const formatter = new Intl.DateTimeFormat(navigator.language, { dateStyle: 'full', timeStyle: 'short' })
119
+
120
+ return html`
121
+ <ox-data-sample-view .dataSample=${this.dataOoc}></ox-data-sample-view>
122
+
123
+ <h3 state ?danger=${state != 'CORRECTED'} ?complete=${state == 'CORRECTED'}>
124
+ <mwc-icon>shield</mwc-icon>
125
+ <div>DATA OOC <span field-state>${state || ''}</span></div>
126
+ </h3>
127
+
128
+ <div instruction>
129
+ <div><mwc-icon>build_circle</mwc-icon> <span>corrective instruction</span></div>
130
+ <div content>${correctiveInstruction}</div>
131
+ ${reviewer
132
+ ? html`<div>
133
+ <mwc-icon>alarm</mwc-icon> ${formatter.format(new Date(reviewedAt!))}
134
+ <mwc-icon>account_circle</mwc-icon>${reviewer.name}
135
+ </div>`
136
+ : html``}
137
+ </div>
138
+
139
+ <div action>
140
+ <div><mwc-icon>build_circle</mwc-icon> <span>corrective action</span></div>
141
+ <div content>${correctiveAction}</div>
142
+ ${corrector
143
+ ? html`<div>
144
+ <mwc-icon>alarm</mwc-icon> ${formatter.format(new Date(correctedAt!))}
145
+ <mwc-icon>account_circle</mwc-icon>${corrector.name}
146
+ </div>`
147
+ : html``}
148
+ </div>
149
+ `
150
+ }
151
+ }
@@ -9,6 +9,9 @@ import { i18next } from '@operato/i18n'
9
9
 
10
10
  import { DataOoc, DataSet } from './types.js'
11
11
 
12
+ /**
13
+ * @deprecated by ox-data-ooc-brief-view
14
+ */
12
15
  @customElement('ox-data-ooc-view')
13
16
  export class OxDataOocView extends LitElement {
14
17
  static styles = css`
@@ -65,7 +68,7 @@ export class OxDataOocView extends LitElement {
65
68
  [danger] [field-state] {
66
69
  background-color: var(--status-danger-color);
67
70
  }
68
- [complate] [field-state] {
71
+ [complete] [field-state] {
69
72
  background-color: var(--status-info-color);
70
73
  }
71
74
  [page-history] [field-state] {
@@ -104,23 +107,22 @@ export class OxDataOocView extends LitElement {
104
107
  @property({ type: Object }) dataOoc?: DataOoc
105
108
 
106
109
  render() {
107
- const history = this.dataOoc?.history || []
110
+ const { history = [], state } = this.dataOoc || {}
108
111
  const formatter = new Intl.DateTimeFormat(navigator.language, { dateStyle: 'full', timeStyle: 'short' })
109
112
 
110
113
  return html`
111
114
  <ox-data-sample-view .dataSample=${this.dataOoc}></ox-data-sample-view>
112
115
 
113
- <h3 state>
114
- <!--상태에 따라 추가로 danger, complate를 어트리뷰트로 추가시 배경컬러 변경되도록 해두었습니다-->
116
+ <h3 state ?danger=${state != 'CORRECTED'} ?complete=${state == 'CORRECTED'}>
115
117
  <mwc-icon>shield</mwc-icon>
116
- <div>${name} <span field-state>${this.dataOoc?.state || ''}</span></div>
118
+ <div>DATA OOC <span field-state>${state || ''}</span></div>
117
119
  </h3>
118
120
 
119
121
  <h3>${i18next.t('title.history')}</h3>
120
122
  ${history.map(
121
123
  ({ user, state, comment, timestamp }) => html`
122
124
  <p page-history>
123
- <!--상태에 따라 추가로 danger, complate를 어트리뷰트로 추가시 배경컬러 변경되도록 해두었습니다-->
125
+ <!--상태에 따라 추가로 danger, complete를 어트리뷰트로 추가시 배경컬러 변경되도록 해두었습니다-->
124
126
  <span field-info
125
127
  >${formatter.format(new Date(timestamp))} <mwc-icon>account_circle</mwc-icon>${user.name}</span
126
128
  >
package/src/types.ts CHANGED
@@ -82,7 +82,18 @@ export type DataOocState = 'CREATED' | 'REVIEWED' | 'CORRECTED'
82
82
 
83
83
  export type DataOoc = DataSample & {
84
84
  state: DataOocState
85
- correctiveAction: string
85
+ correctiveInstruction?: string
86
+ correctiveAction?: string
87
+ reviewer?: {
88
+ id: string
89
+ name: string
90
+ }
91
+ reviewedAt?: Date
92
+ corrector?: {
93
+ id: string
94
+ name: string
95
+ }
96
+ correctedAt?: Date
86
97
  history: {
87
98
  user: {
88
99
  id: string