-
Notifications
You must be signed in to change notification settings - Fork 2
/
PropertyDef.ts
168 lines (132 loc) · 4.45 KB
/
PropertyDef.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import { CellValue } from './CellValue';
import { TypeNames } from './types';
/**
* A property definition describes a particular value of a business entity. Business entities are transacted as records,
* therefore properties and lists of properties are referred to as fields and records. Moreover, a list of property definitions
* is referred to as a record definition and is the metadata describing the read/write capabilities of a specific dialog model
* in use by a specific user in a specific workflow.
* Contains information that 'defines' a property {@link Property} (name/value)
* An instance of the {@link Property} contains the actual data value.
*/
export class PropertyDef {
constructor(
readonly canCauseSideEffects: boolean,
readonly contentType: string,
readonly displayLength: number,
readonly displayScale: number,
readonly format: string,
readonly length: number,
readonly propertyName: string,
readonly propertyType: string,
readonly scale: number,
readonly semanticType: string,
readonly upperCaseOnly: boolean,
readonly writeAllowed: boolean,
readonly writeEnabled: boolean
) {}
get isBarcodeType(): boolean {
return this.semanticType === 'BARCODE';
}
get isByteFormat(): boolean {
return this.format === 'byte';
}
get isBooleanType(): boolean {
return this.propertyType === 'boolean';
}
get isCodeRefType(): boolean {
return this.format === 'code-ref'
}
get isDateType(): boolean {
return this.format === 'date';
}
get isDateTimeType(): boolean {
return this.format === 'date-time';
}
get isDecimalType(): boolean {
return this.format === 'decimal';
}
get isDoubleType(): boolean {
return this.format === 'double';
}
get isEmailType(): boolean {
return this.semanticType === 'EMAIL';
}
get isFileAttachment(): boolean {
return this.semanticType === 'FILE_UPLOAD';
}
get isFloatType(): boolean {
return this.format === 'float';
}
get isGpsReadingType(): boolean {
return this.propertyType === TypeNames.GpsReadingPropertyTypeName;
}
get isMapLocationType(): boolean {
return this.propertyType === TypeNames.MapLocationPropertyTypeName;
}
get isHTMLType(): boolean {
return this.semanticType === 'DATA_HTML';
}
// @TODO
get isInlineMediaStyle(): boolean {
return (
this.semanticType === CellValue.STYLE_INLINE_MEDIA || this.semanticType === CellValue.STYLE_INLINE_MEDIA2
);
}
get isListType(): boolean {
return this.propertyType === 'array';
}
get isIntType(): boolean {
return ['integer', 'int32', 'int64'].some(v => this.propertyType === v);
}
get isLongType(): boolean {
return this.format === 'int64';
}
get isMoneyType(): boolean {
return this.semanticType === 'MONEY';
}
get isNameType(): boolean {
return this.semanticType === 'NAME';
}
get isNumericType(): boolean {
return this.isDecimalType || this.isIntType || this.isDoubleType || this.isLongType || this.isFloatType;
}
get isLargePropertyType(): boolean {
return this.semanticType === 'LARGE_PROPERTY' || this.isSignatureType;
}
get isObjRefType(): boolean {
return this.format === 'object-ref';
}
get isPasswordType(): boolean {
return this.format === 'password' || this.semanticType === 'PASSWORD';
}
get isPercentType(): boolean {
return this.semanticType === 'PERCENTAGE';
}
get isReadOnly(): boolean {
return !this.writeAllowed || !this.writeEnabled;
}
get isWritable(): boolean {
return this.writeAllowed || this.writeEnabled;
}
get isSignatureType(): boolean {
return this.semanticType === 'USER_SIGNATURE';
}
get isStringType(): boolean {
return this.propertyType === 'string';
}
get isTelephoneType(): boolean {
return this.semanticType === 'TELEPHONE';
}
get isTextBlock(): boolean {
return this.semanticType === 'TEXT_BLOCK';
}
get isTimeType(): boolean {
return this.format === 'time';
}
get isUnformattedNumericType(): boolean {
return this.semanticType === 'UNFORMATTED';
}
get isURLType(): boolean {
return this.semanticType === 'URL';
}
}