@operato/dataset 7.1.31 → 7.1.33
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 +18 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/.editorconfig +0 -29
- package/.storybook/main.js +0 -3
- package/.storybook/preview.js +0 -52
- package/.storybook/server.mjs +0 -8
- package/demo/favicon.ico +0 -0
- package/demo/index.html +0 -349
- package/demo/ox-data-ooc-brief-view-test.html +0 -349
- package/src/grist-editor/index.ts +0 -10
- package/src/grist-editor/ox-grist-editor-data-item-spec.ts +0 -93
- package/src/grist-editor/ox-popup-data-item-spec.ts +0 -93
- package/src/index.ts +0 -2
- package/src/ox-data-entry-form.ts +0 -303
- package/src/ox-data-entry-subgroup-form.ts +0 -157
- package/src/ox-data-entry-subgroup-view.ts +0 -221
- package/src/ox-data-entry-view.ts +0 -241
- package/src/ox-data-item-spec.ts +0 -131
- package/src/ox-data-ooc-badge.ts +0 -73
- package/src/ox-data-ooc-brief-view.ts +0 -43
- package/src/ox-data-ooc-correction-part.ts +0 -107
- package/src/ox-data-ooc-history.ts +0 -74
- package/src/ox-data-ooc-view.ts +0 -51
- package/src/ox-data-sample-subgroup-view.ts +0 -210
- package/src/ox-data-sample-view.ts +0 -271
- package/src/ox-data-summary-view.ts +0 -198
- package/src/types.ts +0 -178
- package/src/usecase/ccp/index.ts +0 -10
- package/src/usecase/ccp/ox-data-use-case-ccp.ts +0 -147
- package/src/usecase/ccp/ox-input-ccp-limits.ts +0 -184
- package/src/usecase/ccp/ox-property-editor-ccp-limits.ts +0 -23
- package/src/usecase/ox-data-use-case.ts +0 -178
- package/src/usecase/qc/index.ts +0 -10
- package/src/usecase/qc/ox-data-use-case-qc.ts +0 -76
- package/src/usecase/qc/ox-input-qc-limits.ts +0 -183
- package/src/usecase/qc/ox-property-editor-qc-limits.ts +0 -23
- package/src/usecase/spc/index.ts +0 -10
- package/src/usecase/spc/ox-data-use-case-spc.ts +0 -147
- package/src/usecase/spc/ox-input-spc-limits.ts +0 -184
- package/src/usecase/spc/ox-property-editor-spc-limits.ts +0 -23
- package/stories/ox-data-entry-form.stories.ts +0 -253
- package/stories/ox-data-item-spec.stories.ts +0 -257
- package/stories/ox-data-ooc-brief-view.stories.ts +0 -333
- package/stories/ox-data-ooc-view.stories.ts +0 -327
- package/stories/ox-data-sample-view.stories.ts +0 -313
- package/stories/ox-grist-editor-data-item-spec.stories.ts +0 -412
- package/tsconfig.json +0 -24
- package/web-dev-server.config.mjs +0 -27
- package/web-test-runner.config.mjs +0 -41
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import '@operato/input/ox-input-file.js'
|
|
2
|
-
import '@operato/input/ox-input-signature.js'
|
|
3
|
-
|
|
4
|
-
import { css, html, LitElement } from 'lit'
|
|
5
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
6
|
-
|
|
7
|
-
import { i18next } from '@operato/i18n'
|
|
8
|
-
|
|
9
|
-
import { DataSummary, DataSpecLimitSet } from './types.js'
|
|
10
|
-
import { OxDataUseCase } from './usecase/ox-data-use-case.js'
|
|
11
|
-
|
|
12
|
-
@customElement('ox-data-summary-view')
|
|
13
|
-
export class OxDataSummaryView extends LitElement {
|
|
14
|
-
static styles = css`
|
|
15
|
-
:host {
|
|
16
|
-
display: flex;
|
|
17
|
-
flex-direction: column;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
form {
|
|
21
|
-
flex: 1;
|
|
22
|
-
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-direction: column;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
h2 {
|
|
28
|
-
margin: var(--title-margin);
|
|
29
|
-
font: var(--title-font);
|
|
30
|
-
color: var(--title-text-color);
|
|
31
|
-
text-transform: capitalize;
|
|
32
|
-
}
|
|
33
|
-
[page-description] {
|
|
34
|
-
margin: var(--page-description-margin);
|
|
35
|
-
opacity: 0.7;
|
|
36
|
-
font: var(--page-description-font);
|
|
37
|
-
color: var(--md-sys-color-on-secondary-container);
|
|
38
|
-
text-transform: capitalize;
|
|
39
|
-
}
|
|
40
|
-
[page-description] * {
|
|
41
|
-
vertical-align: middle;
|
|
42
|
-
}
|
|
43
|
-
[page-description] md-icon {
|
|
44
|
-
margin-top: -2px;
|
|
45
|
-
font-size: 0.9rem;
|
|
46
|
-
color: var(--page-description-color);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
table {
|
|
50
|
-
border-collapse: collapse;
|
|
51
|
-
margin-bottom: var(--spacing-medium);
|
|
52
|
-
}
|
|
53
|
-
th {
|
|
54
|
-
padding: var(--th-padding);
|
|
55
|
-
border-top: var(--th-border-top);
|
|
56
|
-
border-bottom: var(--td-border-bottom);
|
|
57
|
-
text-transform: var(--th-text-transform);
|
|
58
|
-
font: var(--th-font);
|
|
59
|
-
color: var(--th-color);
|
|
60
|
-
text-align: left;
|
|
61
|
-
}
|
|
62
|
-
th[item] {
|
|
63
|
-
min-width: 100px;
|
|
64
|
-
}
|
|
65
|
-
th[value] {
|
|
66
|
-
min-width: 100px;
|
|
67
|
-
}
|
|
68
|
-
tr {
|
|
69
|
-
background-color: var(--tr-background-color);
|
|
70
|
-
}
|
|
71
|
-
tr:nth-child(odd) {
|
|
72
|
-
background-color: var(--tr-background-odd-color);
|
|
73
|
-
}
|
|
74
|
-
tr:hover {
|
|
75
|
-
background-color: var(--tr-background-hover-color);
|
|
76
|
-
}
|
|
77
|
-
tr[ooc],
|
|
78
|
-
tr[oos] {
|
|
79
|
-
background-color: #fefbdf;
|
|
80
|
-
}
|
|
81
|
-
td {
|
|
82
|
-
border-bottom: var(--td-border-bottom);
|
|
83
|
-
padding: var(--td-padding);
|
|
84
|
-
font: var(--td-font);
|
|
85
|
-
color: var(--td-color);
|
|
86
|
-
}
|
|
87
|
-
td[name] {
|
|
88
|
-
font-weight: bold;
|
|
89
|
-
}
|
|
90
|
-
td md-icon {
|
|
91
|
-
color: var(--md-sys-color-error);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
pre {
|
|
95
|
-
tab-size: 2;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
@media screen and (max-width: 480px) {
|
|
99
|
-
th {
|
|
100
|
-
min-width: 50px;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
`
|
|
104
|
-
|
|
105
|
-
@property({ type: Object }) dataSummary?: DataSummary
|
|
106
|
-
|
|
107
|
-
render() {
|
|
108
|
-
if (!this.dataSummary) {
|
|
109
|
-
return html``
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const { name, description, date, period, summary = {}, dataItems = [], useCase } = this.dataSummary
|
|
113
|
-
const useCaseNames = useCase?.split(',').filter(useCase => useCase.trim()) || []
|
|
114
|
-
|
|
115
|
-
return html` <h2>${name}</h2>
|
|
116
|
-
<p page-description>
|
|
117
|
-
<md-icon>info</md-icon> ${description}<br />
|
|
118
|
-
<md-icon>alarm</md-icon> ${i18next.t('field.date')}: ${date} ${period}
|
|
119
|
-
</p>
|
|
120
|
-
|
|
121
|
-
<form>
|
|
122
|
-
<table>
|
|
123
|
-
<tr>
|
|
124
|
-
<th item>${i18next.t('field.item')}</th>
|
|
125
|
-
<th>${i18next.t('field.description')}</th>
|
|
126
|
-
<th>${i18next.t('field.finalizing-function')}</th>
|
|
127
|
-
<th>${i18next.t('field.unit')}</th>
|
|
128
|
-
<th value>${i18next.t('field.value')}</th>
|
|
129
|
-
<th>${i18next.t('field.spec')}</th>
|
|
130
|
-
</tr>
|
|
131
|
-
${dataItems
|
|
132
|
-
.filter(dataItem => dataItem.stat)
|
|
133
|
-
.map(dataItem => {
|
|
134
|
-
const { name = '', tag = '', description = '', stat, unit = '', spec = {}, type } = dataItem
|
|
135
|
-
const value = summary[tag]
|
|
136
|
-
|
|
137
|
-
return html`
|
|
138
|
-
<tr>
|
|
139
|
-
<td name>${name}</td>
|
|
140
|
-
<td>${description}</td>
|
|
141
|
-
<td>${stat}</td>
|
|
142
|
-
<td>${unit}</td>
|
|
143
|
-
<td>${this.buildValue(type, value)}</td>
|
|
144
|
-
<td><pre>${this.buildSpec(useCaseNames, spec)}</pre></td>
|
|
145
|
-
</tr>
|
|
146
|
-
`
|
|
147
|
-
})}
|
|
148
|
-
</table>
|
|
149
|
-
</form>`
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
private buildSpec(useCaseNames: string[], spec: DataSpecLimitSet): string {
|
|
153
|
-
return OxDataUseCase.elaborateDataItemSpec(useCaseNames, spec)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
private download(file: { mimetype: string; name: string; fullpath: string }) {
|
|
157
|
-
const element = document.createElement('a')
|
|
158
|
-
element.setAttribute('href', file.fullpath)
|
|
159
|
-
element.setAttribute('download', file.name!)
|
|
160
|
-
document.body.appendChild(element)
|
|
161
|
-
element.click()
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
private buildValue(type: string, value: any | any[]) {
|
|
165
|
-
if (value === undefined) {
|
|
166
|
-
return ''
|
|
167
|
-
}
|
|
168
|
-
const values = value instanceof Array ? value : [value]
|
|
169
|
-
|
|
170
|
-
if (type == 'file') {
|
|
171
|
-
const files = values.flat() as { mimetype: string; name: string; fullpath: string }[]
|
|
172
|
-
|
|
173
|
-
return files.filter(Boolean).map(file => html`<a @click=${() => this.download(file)}>${file.name}</a></br>`)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (type == 'signature') {
|
|
177
|
-
return html` <ox-input-signature .value=${value} disabled></ox-input-signature>`
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const elements = values.map((v: any, idx) => {
|
|
181
|
-
switch (typeof v) {
|
|
182
|
-
case 'boolean':
|
|
183
|
-
return html` <input type="checkbox" .checked=${v} disabled />`
|
|
184
|
-
break
|
|
185
|
-
|
|
186
|
-
default:
|
|
187
|
-
if (type == 'date') {
|
|
188
|
-
return new Date(v).toLocaleDateString()
|
|
189
|
-
} else if (type == 'datetime') {
|
|
190
|
-
return new Date(v).toLocaleString()
|
|
191
|
-
}
|
|
192
|
-
return v ?? ''
|
|
193
|
-
}
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
return typeof values[0] === 'boolean' ? elements : elements.join(', ')
|
|
197
|
-
}
|
|
198
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents a selectable option with a text label and a value.
|
|
3
|
-
*/
|
|
4
|
-
export type SelectOption = {
|
|
5
|
-
text: string
|
|
6
|
-
value: string
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* An array of selectable options.
|
|
10
|
-
*/
|
|
11
|
-
export type SelectOptions = SelectOption[]
|
|
12
|
-
/**
|
|
13
|
-
* Defines the options and additional properties for a type.
|
|
14
|
-
*/
|
|
15
|
-
export type TypeOptions = {
|
|
16
|
-
options?: SelectOptions
|
|
17
|
-
[prop: string]: any
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Describes the structure and properties of a data item.
|
|
21
|
-
*/
|
|
22
|
-
export type DataItem = {
|
|
23
|
-
name: string
|
|
24
|
-
description: string
|
|
25
|
-
sequence: number
|
|
26
|
-
tag: string
|
|
27
|
-
group: string
|
|
28
|
-
type: string
|
|
29
|
-
stat: string
|
|
30
|
-
active: boolean
|
|
31
|
-
options: TypeOptions
|
|
32
|
-
unit: string
|
|
33
|
-
quota: number
|
|
34
|
-
hidden: boolean
|
|
35
|
-
spec: {
|
|
36
|
-
[useCase: string]: {
|
|
37
|
-
[limit: string]: number | string | string[] | boolean
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Defines the structure of a dataset, including its name, description, type, use case, and data items.
|
|
43
|
-
*/
|
|
44
|
-
export type DataSet = {
|
|
45
|
-
name: string
|
|
46
|
-
description: string
|
|
47
|
-
type: 'manual' | 'automatic'
|
|
48
|
-
useCase: string
|
|
49
|
-
active: boolean
|
|
50
|
-
dataItems: DataItem[]
|
|
51
|
-
spec: {
|
|
52
|
-
[dataItem: string]: {
|
|
53
|
-
[useCase: string]: any
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Describes the definition of a data specification, including its type, label, name, and optional properties.
|
|
59
|
-
*/
|
|
60
|
-
export type DataSpecDefinition = {
|
|
61
|
-
type: string
|
|
62
|
-
label: string
|
|
63
|
-
name: string
|
|
64
|
-
property?: {
|
|
65
|
-
[option: string]: any
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Describes a use case definition, including its name, description, help text, and specifications.
|
|
70
|
-
*/
|
|
71
|
-
export type UseCaseDefinition = {
|
|
72
|
-
name: string
|
|
73
|
-
description: string
|
|
74
|
-
help: string
|
|
75
|
-
specs: DataSpecDefinition[]
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Represents the limits for a data specification.
|
|
79
|
-
*/
|
|
80
|
-
export type DataSpecLimit = {
|
|
81
|
-
[limit: string]: number | string | string[] | boolean
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* A set of data specification limits, keyed by use case.
|
|
85
|
-
*/
|
|
86
|
-
export type DataSpecLimitSet = {
|
|
87
|
-
[useCase: string]: DataSpecLimit
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Represents a collection of data, keyed by a tag.
|
|
91
|
-
*/
|
|
92
|
-
export type DataCollection = {
|
|
93
|
-
[tag: string]: any
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Represents a judgment on data, indicating if it is out of control or out of specification.
|
|
97
|
-
*/
|
|
98
|
-
export type Judgment = {
|
|
99
|
-
[tag: string]: {
|
|
100
|
-
ooc: boolean
|
|
101
|
-
oos: boolean
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Describes a data sample, including its name, description, use case, and associated data and judgments.
|
|
106
|
-
*/
|
|
107
|
-
export type DataSample = {
|
|
108
|
-
name?: string
|
|
109
|
-
description?: string
|
|
110
|
-
useCase?: string
|
|
111
|
-
data?: DataCollection
|
|
112
|
-
judgment?: Judgment
|
|
113
|
-
dataItems?: DataItem[]
|
|
114
|
-
quota?: number
|
|
115
|
-
workDate?: string
|
|
116
|
-
workShift?: string
|
|
117
|
-
collectedAt?: Date
|
|
118
|
-
reviewActivityInstance?: any
|
|
119
|
-
dataOoc?: DataOoc
|
|
120
|
-
}
|
|
121
|
-
export type DataOocState = 'ISSUED' | 'REVIEWED' | 'CORRECTED'
|
|
122
|
-
/**
|
|
123
|
-
* Extends DataSample with additional fields specific to an out of control state, including state, corrective actions, and review history.
|
|
124
|
-
*/
|
|
125
|
-
export type DataOoc = DataSample & {
|
|
126
|
-
state?: DataOocState
|
|
127
|
-
correctiveInstruction?: string
|
|
128
|
-
correctiveAction?: string
|
|
129
|
-
reviewer?: {
|
|
130
|
-
id: string
|
|
131
|
-
name: string
|
|
132
|
-
}
|
|
133
|
-
reviewedAt?: Date
|
|
134
|
-
corrector?: {
|
|
135
|
-
id: string
|
|
136
|
-
name: string
|
|
137
|
-
}
|
|
138
|
-
correctedAt?: Date
|
|
139
|
-
history?: {
|
|
140
|
-
user: {
|
|
141
|
-
id: string
|
|
142
|
-
name: string
|
|
143
|
-
}
|
|
144
|
-
state: DataOocState
|
|
145
|
-
comment: string
|
|
146
|
-
timestamp: number
|
|
147
|
-
}[]
|
|
148
|
-
resolveActivityInstance?: any
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Describes a summary of data, including its name, description, relevant data items, and key metrics.
|
|
152
|
-
*/
|
|
153
|
-
export type DataSummary = {
|
|
154
|
-
name: string
|
|
155
|
-
description: string
|
|
156
|
-
dataItems?: DataItem[]
|
|
157
|
-
date?: string
|
|
158
|
-
period?: string
|
|
159
|
-
key01?: string
|
|
160
|
-
key02?: string
|
|
161
|
-
key03?: string
|
|
162
|
-
key04?: string
|
|
163
|
-
key05?: string
|
|
164
|
-
count?: number
|
|
165
|
-
countOoc?: number
|
|
166
|
-
countOos?: number
|
|
167
|
-
useCase?: string
|
|
168
|
-
summary?: {
|
|
169
|
-
[key: string]: any
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Represents the result of an evaluation, indicating if data is out of specification or out of control.
|
|
174
|
-
*/
|
|
175
|
-
export type EvaluationResult = {
|
|
176
|
-
oos: boolean
|
|
177
|
-
ooc: boolean
|
|
178
|
-
}
|
package/src/usecase/ccp/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/* Here, only the common module of client and server is imported/exported. Be careful not to use a module dedicated to client or server. */
|
|
2
|
-
|
|
3
|
-
import { OxDataUseCase } from '../ox-data-use-case'
|
|
4
|
-
import { OxDataUseCaseCCP } from './ox-data-use-case-ccp'
|
|
5
|
-
|
|
6
|
-
// OxPropertyEditor.register({
|
|
7
|
-
// 'ccp-limits': 'ox-property-editor-ccp-limits'
|
|
8
|
-
// })
|
|
9
|
-
|
|
10
|
-
OxDataUseCase.registerUseCase('CCP', new OxDataUseCaseCCP())
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import i18next from 'i18next' // Since this is a common module, @operato/i18n was deliberately avoided.
|
|
2
|
-
|
|
3
|
-
import { DataItem, EvaluationResult, UseCaseDefinition } from '../../types'
|
|
4
|
-
import { OxDataUseCase } from '../ox-data-use-case.js'
|
|
5
|
-
|
|
6
|
-
export class OxDataUseCaseCCP extends OxDataUseCase {
|
|
7
|
-
getSpecification(dataItem: DataItem): UseCaseDefinition {
|
|
8
|
-
return {
|
|
9
|
-
name: 'CCP',
|
|
10
|
-
description: 'Critical Control Point Data Spec',
|
|
11
|
-
help: '',
|
|
12
|
-
specs: [
|
|
13
|
-
{
|
|
14
|
-
type: 'ccp-limits' /* A value which seperates acceptability from unacceptability */,
|
|
15
|
-
label: 'critical-limits',
|
|
16
|
-
name: 'criticalLimits',
|
|
17
|
-
property: dataItem
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
type: 'ccp-limits',
|
|
21
|
-
label: 'target-limits',
|
|
22
|
-
name: 'targetLimits',
|
|
23
|
-
property: dataItem
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
evaluate(spec: any, values: any | any[]): EvaluationResult | undefined {
|
|
30
|
-
if (!spec || typeof values === 'undefined') {
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!(values instanceof Array)) {
|
|
35
|
-
values = [values]
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const {
|
|
39
|
-
minimum: criticalMinimum,
|
|
40
|
-
maximum: criticalMaximum,
|
|
41
|
-
acceptables: criticalAcceptables
|
|
42
|
-
} = spec['criticalLimits'] || {}
|
|
43
|
-
|
|
44
|
-
const {
|
|
45
|
-
minimum: targetMinimum,
|
|
46
|
-
maximum: targetMaximum,
|
|
47
|
-
acceptables: targetAcceptables
|
|
48
|
-
} = spec['targetLimits'] || {}
|
|
49
|
-
|
|
50
|
-
var oos = false
|
|
51
|
-
var ooc = false
|
|
52
|
-
|
|
53
|
-
for (let i = 0; i < values.length; i++) {
|
|
54
|
-
const value = values[i]
|
|
55
|
-
|
|
56
|
-
if (criticalMinimum != null && value < criticalMinimum) {
|
|
57
|
-
oos = true
|
|
58
|
-
break
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (criticalMaximum != null && value > criticalMaximum) {
|
|
62
|
-
oos = true
|
|
63
|
-
break
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (criticalAcceptables != null && !criticalAcceptables.includes(value)) {
|
|
67
|
-
oos = true
|
|
68
|
-
break
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
for (let i = 0; i < values.length; i++) {
|
|
73
|
-
const value = values[i]
|
|
74
|
-
|
|
75
|
-
if (targetMinimum != null && value < targetMinimum) {
|
|
76
|
-
ooc = true
|
|
77
|
-
break
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (targetMaximum != null && value > targetMaximum) {
|
|
81
|
-
ooc = true
|
|
82
|
-
break
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (targetAcceptables != null && !targetAcceptables.includes(value)) {
|
|
86
|
-
ooc = true
|
|
87
|
-
break
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return { oos, ooc }
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
elaborateUseCaseSpec(limits: any): string | undefined {
|
|
95
|
-
if (!limits) {
|
|
96
|
-
return
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
var text = ''
|
|
100
|
-
|
|
101
|
-
const {
|
|
102
|
-
minimum: criticalMinimum,
|
|
103
|
-
maximum: criticalMaximum,
|
|
104
|
-
acceptables: criticalAcceptables
|
|
105
|
-
} = limits['criticalLimits'] || {}
|
|
106
|
-
|
|
107
|
-
if (criticalMinimum != null || criticalMaximum != null || criticalAcceptables != null) {
|
|
108
|
-
text += `${i18next.t('label.critical-limits')}\n`
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (criticalMinimum != null) {
|
|
112
|
-
text += `\t${i18next.t('label.minimum value')} : ${criticalMinimum}\n`
|
|
113
|
-
}
|
|
114
|
-
if (criticalMaximum != null) {
|
|
115
|
-
text += `\t${i18next.t('label.maximum value')} : ${criticalMaximum}\n`
|
|
116
|
-
}
|
|
117
|
-
if (criticalAcceptables != null) {
|
|
118
|
-
text += `\t${i18next.t('label.acceptables')} : ${
|
|
119
|
-
criticalAcceptables instanceof Array ? criticalAcceptables.join(', ') : criticalAcceptables
|
|
120
|
-
}\n`
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const {
|
|
124
|
-
minimum: targetMinimum,
|
|
125
|
-
maximum: targetMaximum,
|
|
126
|
-
acceptables: targetAcceptables
|
|
127
|
-
} = limits['targetLimits'] || {}
|
|
128
|
-
|
|
129
|
-
if (targetMinimum != null || targetMaximum != null || targetAcceptables != null) {
|
|
130
|
-
text += `${i18next.t('label.target-limits')}\n`
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (targetMinimum != null) {
|
|
134
|
-
text += `\t${i18next.t('label.minimum value')} : ${targetMinimum}\n`
|
|
135
|
-
}
|
|
136
|
-
if (targetMaximum != null) {
|
|
137
|
-
text += `\t${i18next.t('label.maximum value')} : ${targetMaximum}\n`
|
|
138
|
-
}
|
|
139
|
-
if (targetAcceptables != null) {
|
|
140
|
-
text += `\t${i18next.t('label.acceptables')} : ${
|
|
141
|
-
targetAcceptables instanceof Array ? targetAcceptables.join(', ') : targetAcceptables
|
|
142
|
-
}\n`
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return text
|
|
146
|
-
}
|
|
147
|
-
}
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { css, html, LitElement } from 'lit'
|
|
6
|
-
import { customElement, property, query, queryAll } from 'lit/decorators.js'
|
|
7
|
-
|
|
8
|
-
import { i18next } from '@operato/i18n'
|
|
9
|
-
|
|
10
|
-
export enum DataItemType {
|
|
11
|
-
number = 'number',
|
|
12
|
-
text = 'text',
|
|
13
|
-
boolean = 'boolean',
|
|
14
|
-
select = 'select',
|
|
15
|
-
radio = 'radio',
|
|
16
|
-
file = 'file',
|
|
17
|
-
signature = 'signature'
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type CcpLimitValue = {
|
|
21
|
-
minimum?: number
|
|
22
|
-
maximum?: number
|
|
23
|
-
acceptables?: string[] | boolean[]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
element for CCP limits
|
|
28
|
-
|
|
29
|
-
Example:
|
|
30
|
-
|
|
31
|
-
<ox-input-ccp-limits
|
|
32
|
-
.value=${value}
|
|
33
|
-
.type=${type}>
|
|
34
|
-
</ox-input-ccp-limits>
|
|
35
|
-
*/
|
|
36
|
-
@customElement('ox-input-ccp-limits')
|
|
37
|
-
export class OxInputCcpLimits extends LitElement {
|
|
38
|
-
static styles = css`
|
|
39
|
-
:host {
|
|
40
|
-
display: flex;
|
|
41
|
-
flex-direction: column;
|
|
42
|
-
align-content: center;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
label {
|
|
46
|
-
margin: 0 var(--margin-default) var(--margin-default) 0;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
label div > * {
|
|
50
|
-
vertical-align: middle;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
button {
|
|
54
|
-
width: 20px;
|
|
55
|
-
text-align: center;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
div[name],
|
|
59
|
-
input[type='checkbox'] + span {
|
|
60
|
-
display: inline-block;
|
|
61
|
-
font: var(--label-font);
|
|
62
|
-
color: var(--label-color, var(--md-sys-color-on-surface));
|
|
63
|
-
text-align: right;
|
|
64
|
-
}
|
|
65
|
-
input,
|
|
66
|
-
select {
|
|
67
|
-
border: var(--input-field-border);
|
|
68
|
-
border-radius: var(--input-field-border-radius);
|
|
69
|
-
padding: var(--input-field-padding);
|
|
70
|
-
font: var(--input-field-font);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
input[type='checkbox'] {
|
|
74
|
-
width: initial;
|
|
75
|
-
}
|
|
76
|
-
input[checked] + span {
|
|
77
|
-
font-weight: bold;
|
|
78
|
-
}
|
|
79
|
-
[unit],
|
|
80
|
-
[value] {
|
|
81
|
-
display: inline-block;
|
|
82
|
-
opacity: 0.7;
|
|
83
|
-
font: var(--form-sublabel-font);
|
|
84
|
-
}
|
|
85
|
-
[properties] {
|
|
86
|
-
font: var(--input-field-font);
|
|
87
|
-
color: var(--label-color, var(--md-sys-color-on-surface));
|
|
88
|
-
}
|
|
89
|
-
`
|
|
90
|
-
|
|
91
|
-
@property({ type: Object }) value: CcpLimitValue = {}
|
|
92
|
-
@property({ type: String }) type: DataItemType = DataItemType.number
|
|
93
|
-
@property({ type: String }) unit?: string
|
|
94
|
-
@property({ type: Object }) options: { options?: { text: string; value: string }[] } = {}
|
|
95
|
-
|
|
96
|
-
@query('[name=minimum]') minimum!: HTMLInputElement
|
|
97
|
-
@query('[name=maximum]') maximum!: HTMLInputElement
|
|
98
|
-
@queryAll('[type=checkbox]:checked') checkedAll!: NodeListOf<HTMLInputElement>
|
|
99
|
-
|
|
100
|
-
firstUpdated() {
|
|
101
|
-
this.renderRoot.addEventListener('change', this.onChange.bind(this))
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
render() {
|
|
105
|
-
const { minimum, maximum, acceptables = [] } = this.value || {}
|
|
106
|
-
|
|
107
|
-
return html`
|
|
108
|
-
<div>
|
|
109
|
-
${this.type === DataItemType.number
|
|
110
|
-
? html`
|
|
111
|
-
<label>
|
|
112
|
-
<div name>${i18next.t('text.minimum value')}</div>
|
|
113
|
-
<input type="number" name="minimum" .value=${minimum} />
|
|
114
|
-
<div unit>${this.unit}</div>
|
|
115
|
-
</select>
|
|
116
|
-
</label>
|
|
117
|
-
<label>
|
|
118
|
-
<div name>${i18next.t('text.maximum value')}</div>
|
|
119
|
-
<input type="number" name="maximum" .value=${maximum} />
|
|
120
|
-
<div unit>${this.unit}</div>
|
|
121
|
-
</label>
|
|
122
|
-
`
|
|
123
|
-
: this.type === DataItemType.select || this.type === DataItemType.radio
|
|
124
|
-
? html`
|
|
125
|
-
<!-- <div>Acceptables</div> -->
|
|
126
|
-
${this.options?.options?.map(
|
|
127
|
-
option => html`
|
|
128
|
-
<div>
|
|
129
|
-
<input
|
|
130
|
-
type="checkbox"
|
|
131
|
-
data-value=${option.value}
|
|
132
|
-
?checked=${(acceptables as string[]).includes(option.value)}
|
|
133
|
-
/>
|
|
134
|
-
<span>${option.text}</span>
|
|
135
|
-
<span value>(${option.value})</span>
|
|
136
|
-
</div>
|
|
137
|
-
`
|
|
138
|
-
)}
|
|
139
|
-
`
|
|
140
|
-
: this.type === DataItemType.boolean
|
|
141
|
-
? html`
|
|
142
|
-
<div>
|
|
143
|
-
<input type="checkbox" data-value=${true} ?checked=${(acceptables as boolean[]).includes(true)} />
|
|
144
|
-
<span value>true</span>
|
|
145
|
-
</div>
|
|
146
|
-
<div>
|
|
147
|
-
<input type="checkbox" data-value=${false} ?checked=${(acceptables as boolean[]).includes(false)} />
|
|
148
|
-
<span value>false</span>
|
|
149
|
-
</div>
|
|
150
|
-
`
|
|
151
|
-
: html` <div properties>${i18next.t('text.no properties to set')}</div> `}
|
|
152
|
-
</div>
|
|
153
|
-
`
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
private onChange(e: Event) {
|
|
157
|
-
if (this.type === DataItemType.number) {
|
|
158
|
-
this.value = {
|
|
159
|
-
minimum: this.minimum.valueAsNumber,
|
|
160
|
-
maximum: this.maximum.valueAsNumber
|
|
161
|
-
}
|
|
162
|
-
} else if (this.type === DataItemType.select) {
|
|
163
|
-
this.value = {
|
|
164
|
-
acceptables: Array.from(this.checkedAll).map(checked => {
|
|
165
|
-
const x = checked.getAttribute('data-value')!
|
|
166
|
-
console.log(x)
|
|
167
|
-
return x
|
|
168
|
-
})
|
|
169
|
-
}
|
|
170
|
-
} else if (this.type === DataItemType.boolean) {
|
|
171
|
-
this.value = {
|
|
172
|
-
acceptables: Array.from(this.checkedAll).map(checked => {
|
|
173
|
-
const x = checked.getAttribute('data-value')! === 'true'
|
|
174
|
-
console.log(x)
|
|
175
|
-
return x
|
|
176
|
-
})
|
|
177
|
-
}
|
|
178
|
-
} else {
|
|
179
|
-
this.value = {}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))
|
|
183
|
-
}
|
|
184
|
-
}
|