@onehat/ui 0.4.96 → 0.4.98
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/package.json +1 -1
- package/src/Components/Container/Container.js +137 -80
- package/src/Components/Form/Form.js +15 -6
- package/src/Components/Grid/Grid.js +71 -37
- package/src/Components/Hoc/withEditor.js +16 -4
- package/src/Components/Hoc/withPresetButtons.js +5 -0
- package/src/Components/Panel/TabPanel.js +1 -1
- package/src/Components/Panel/TreePanel.js +1 -1
- package/src/Components/Tree/Tree.js +26 -3
- package/src/Components/Tree/TreeNode.js +3 -0
- package/src/Components/Viewer/DateTimeViewer.js +25 -0
- package/src/Components/Viewer/DateViewer.js +25 -0
- package/src/Components/Viewer/PmCalcDebugViewer.js +299 -0
- package/src/Components/Viewer/PmStatusesViewer.js +51 -0
- package/src/Components/Viewer/TimeViewer.js +25 -0
- package/src/Components/Viewer/Viewer.js +8 -1
- package/src/Components/index.js +10 -0
- package/src/Constants/Dates.js +1 -0
- package/src/Constants/EditorModes.js +2 -0
- package/src/Constants/MeterSources.js +5 -0
- package/src/Constants/MeterTypes.js +4 -2
- package/src/Constants/PmEventTypes.js +11 -0
- package/src/Constants/PmScheduleModes.js +4 -0
- package/src/Constants/PmStatuses.js +16 -0
- package/src/PlatformImports/Web/Attachments.js +2 -1
|
@@ -339,6 +339,11 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
339
339
|
case DUPLICATE:
|
|
340
340
|
key = 'duplicateBtn';
|
|
341
341
|
text = 'Duplicate';
|
|
342
|
+
if (model) {
|
|
343
|
+
let inflected = Inflector.singularize(model); // can only add one at a time
|
|
344
|
+
inflected = Inflector.camel2words(Inflector.humanize(Inflector.underscore(inflected))); // Separate with spaces, capitalize each word
|
|
345
|
+
text += ' ' + inflected;
|
|
346
|
+
}
|
|
342
347
|
handler = (parent, e) => {
|
|
343
348
|
onDuplicate();
|
|
344
349
|
};
|
|
@@ -654,9 +654,23 @@ function TreeComponent(props) {
|
|
|
654
654
|
return;
|
|
655
655
|
}
|
|
656
656
|
|
|
657
|
-
// Create datum for the new entity and add it to parent's children
|
|
658
657
|
const newDatum = buildTreeNodeDatum(entity);
|
|
659
|
-
|
|
658
|
+
|
|
659
|
+
let isInserted = false;
|
|
660
|
+
if (entity._originalData?.previousSiblingId) {
|
|
661
|
+
// Insert datum in the correct position among parent's children
|
|
662
|
+
const siblingDatum = getDatumById(entity._originalData.previousSiblingId);
|
|
663
|
+
if (siblingDatum) {
|
|
664
|
+
const siblingIndex = parentDatum.children.findIndex(child => child.item.id === siblingDatum.item.id);
|
|
665
|
+
parentDatum.children.splice(siblingIndex + 1, 0, newDatum);
|
|
666
|
+
isInserted = true;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
if (!isInserted) {
|
|
670
|
+
// Insert datum at end of parent's children
|
|
671
|
+
parentDatum.children.push(newDatum);
|
|
672
|
+
}
|
|
673
|
+
|
|
660
674
|
|
|
661
675
|
// Update parent to show it has children and expand if needed
|
|
662
676
|
if (!entity.parent.hasChildren) {
|
|
@@ -1052,7 +1066,16 @@ function TreeComponent(props) {
|
|
|
1052
1066
|
return items;
|
|
1053
1067
|
},
|
|
1054
1068
|
getFooterToolbarItems = () => {
|
|
1055
|
-
|
|
1069
|
+
// Process additionalToolbarButtons to evaluate getIsButtonDisabled functions
|
|
1070
|
+
const processedButtons = _.map(additionalToolbarButtons, (config) => {
|
|
1071
|
+
const processedConfig = { ...config };
|
|
1072
|
+
// If the button has an getIsButtonDisabled function, evaluate it with current selection
|
|
1073
|
+
if (_.isFunction(config.getIsButtonDisabled)) {
|
|
1074
|
+
processedConfig.isDisabled = config.getIsButtonDisabled(selection);
|
|
1075
|
+
}
|
|
1076
|
+
return processedConfig;
|
|
1077
|
+
});
|
|
1078
|
+
return _.map(processedButtons, (config, ix) => getIconButtonFromConfig(config, ix, self));
|
|
1056
1079
|
},
|
|
1057
1080
|
renderTreeNode = (datum) => {
|
|
1058
1081
|
if (!datum.isVisible) {
|
|
@@ -148,6 +148,9 @@ export default function TreeNode(props) {
|
|
|
148
148
|
if (props.className) {
|
|
149
149
|
className += ' ' + props.className;
|
|
150
150
|
}
|
|
151
|
+
if (nodeProps.className) {
|
|
152
|
+
className += ' ' + nodeProps.className;
|
|
153
|
+
}
|
|
151
154
|
|
|
152
155
|
return <HStackNative
|
|
153
156
|
{...testProps('node' + (isSelected ? '-selected' : ''))}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import DisplayField from '../Form/Field/DisplayField.js';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import {
|
|
4
|
+
MOMENT_DATE_FORMAT_1,
|
|
5
|
+
} from '../../Constants/Dates';
|
|
6
|
+
|
|
7
|
+
export default function DateTimeViewer(props) {
|
|
8
|
+
const {
|
|
9
|
+
moment,
|
|
10
|
+
} = props;
|
|
11
|
+
if (!moment || !moment.isValid()) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
let className = clsx(
|
|
15
|
+
'flex-none',
|
|
16
|
+
);
|
|
17
|
+
if (props.className) {
|
|
18
|
+
className += ' ' + props.className;
|
|
19
|
+
}
|
|
20
|
+
return <DisplayField
|
|
21
|
+
text={moment.format(MOMENT_DATE_FORMAT_1)}
|
|
22
|
+
{...props}
|
|
23
|
+
className={className}
|
|
24
|
+
/>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import DisplayField from '../Form/Field/DisplayField.js';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import {
|
|
4
|
+
MOMENT_DATE_FORMAT_4,
|
|
5
|
+
} from '../../Constants/Dates';
|
|
6
|
+
|
|
7
|
+
export default function DateViewer(props) {
|
|
8
|
+
const {
|
|
9
|
+
moment,
|
|
10
|
+
} = props;
|
|
11
|
+
if (!moment || !moment.isValid()) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
let className = clsx(
|
|
15
|
+
'flex-none',
|
|
16
|
+
);
|
|
17
|
+
if (props.className) {
|
|
18
|
+
className += ' ' + props.className;
|
|
19
|
+
}
|
|
20
|
+
return <DisplayField
|
|
21
|
+
text={moment.format(MOMENT_DATE_FORMAT_4)}
|
|
22
|
+
{...props}
|
|
23
|
+
className={className}
|
|
24
|
+
/>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Text,
|
|
3
|
+
VStack,
|
|
4
|
+
} from '@project-components/Gluestack';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import {
|
|
7
|
+
MOMENT_DATE_FORMAT_6,
|
|
8
|
+
} from '../../Constants/Dates.js';
|
|
9
|
+
import {
|
|
10
|
+
PM_SCHEDULE_MODES__HISTORICAL_USAGE,
|
|
11
|
+
PM_SCHEDULE_MODES__EXPECTED_USAGE,
|
|
12
|
+
PM_SCHEDULE_MODES__NO_ESTIMATION,
|
|
13
|
+
PM_SCHEDULE_MODES__WILL_CALL,
|
|
14
|
+
} from '../../Constants/PmScheduleModes.js';
|
|
15
|
+
import {
|
|
16
|
+
PM_STATUSES__OK,
|
|
17
|
+
PM_STATUSES__PM_DUE,
|
|
18
|
+
PM_STATUSES__DELAYED,
|
|
19
|
+
PM_STATUSES__WILL_CALL,
|
|
20
|
+
PM_STATUSES__SCHEDULED,
|
|
21
|
+
PM_STATUSES__OVERDUE,
|
|
22
|
+
PM_STATUSES__COMPLETED,
|
|
23
|
+
} from '../../Constants/PmStatuses.js';
|
|
24
|
+
import {
|
|
25
|
+
METER_TYPES__HOURS,
|
|
26
|
+
METER_TYPES__HOURS_UNITS,
|
|
27
|
+
METER_TYPES__HOURS_TEXT,
|
|
28
|
+
METER_TYPES__MILES,
|
|
29
|
+
METER_TYPES__MILES_UNITS,
|
|
30
|
+
METER_TYPES__MILES_TEXT,
|
|
31
|
+
} from '../../Constants/MeterTypes.js';
|
|
32
|
+
import Button from '../Buttons/Button.js';
|
|
33
|
+
import Json from '../Form/Field/Json.js';
|
|
34
|
+
import Panel from '../Panel/Panel.js';
|
|
35
|
+
import Footer from '../Layout/Footer.js';
|
|
36
|
+
import Viewer from '../Viewer/Viewer.js';
|
|
37
|
+
import testProps from '../../Functions/testProps.js';
|
|
38
|
+
import moment from 'moment';
|
|
39
|
+
import _ from 'lodash';
|
|
40
|
+
|
|
41
|
+
export default function PmCalcDebugViewer(props) {
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
metersPmSchedule,
|
|
45
|
+
onClose,
|
|
46
|
+
} = props,
|
|
47
|
+
json = metersPmSchedule?.properties.meters_pm_schedules__debug_json.json,
|
|
48
|
+
flatten = (obj, prefix = '', result = {}) => {
|
|
49
|
+
for (const key in obj) {
|
|
50
|
+
if (obj.hasOwnProperty(key)) {
|
|
51
|
+
const
|
|
52
|
+
newKey = prefix ? `${prefix}.${key}` : key,
|
|
53
|
+
value = obj[key];
|
|
54
|
+
|
|
55
|
+
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
56
|
+
// Recursively flatten nested objects
|
|
57
|
+
flatten(value, newKey, result);
|
|
58
|
+
} else if (Array.isArray(value)) {
|
|
59
|
+
// Flatten arrays using index as key
|
|
60
|
+
value.forEach((item, index) => {
|
|
61
|
+
const arrayKey = `${newKey}.${index}`;
|
|
62
|
+
if (item !== null && typeof item === 'object') {
|
|
63
|
+
flatten(item, arrayKey, result);
|
|
64
|
+
} else {
|
|
65
|
+
result[arrayKey] = item;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
// Assign primitive values and null
|
|
70
|
+
result[newKey] = value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
},
|
|
76
|
+
ucfirst = (string) => {
|
|
77
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
78
|
+
},
|
|
79
|
+
getPmScheduleMode = (pm_schedule_mode_id) => {
|
|
80
|
+
switch(pm_schedule_mode_id) {
|
|
81
|
+
case PM_SCHEDULE_MODES__HISTORICAL_USAGE:
|
|
82
|
+
return 'Historical Usage';
|
|
83
|
+
case PM_SCHEDULE_MODES__EXPECTED_USAGE:
|
|
84
|
+
return 'Expected Usage';
|
|
85
|
+
case PM_SCHEDULE_MODES__NO_ESTIMATION:
|
|
86
|
+
return 'No Estimation';
|
|
87
|
+
case PM_SCHEDULE_MODES__WILL_CALL:
|
|
88
|
+
return 'Will Call';
|
|
89
|
+
default:
|
|
90
|
+
return 'Unknown Mode';
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
flattenedJson = flatten(json),
|
|
94
|
+
formatDaysValue = (value, record, self) => {
|
|
95
|
+
if (value === null || value === undefined) {
|
|
96
|
+
return value;
|
|
97
|
+
}
|
|
98
|
+
return parseInt(_.round(value), 10);
|
|
99
|
+
},
|
|
100
|
+
formatMeterValue = (value, record, self) => {
|
|
101
|
+
if (value === null || value === undefined) {
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
let ret;
|
|
105
|
+
const meterType = parseInt(record?.meter_type, 10);
|
|
106
|
+
switch(meterType) {
|
|
107
|
+
case METER_TYPES__HOURS:
|
|
108
|
+
ret = `${value} ${METER_TYPES__HOURS_UNITS}`;
|
|
109
|
+
break;
|
|
110
|
+
case METER_TYPES__MILES:
|
|
111
|
+
ret = `${value} ${METER_TYPES__MILES_UNITS}`;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
return ret;
|
|
115
|
+
},
|
|
116
|
+
formatDateValue = (value, record, self) => {
|
|
117
|
+
if (value === null || value === undefined) {
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// convert from datetime to pretty-printed date
|
|
122
|
+
return moment(value).format(MOMENT_DATE_FORMAT_6);
|
|
123
|
+
},
|
|
124
|
+
items = [
|
|
125
|
+
{
|
|
126
|
+
"type": "Column",
|
|
127
|
+
"flex": 1,
|
|
128
|
+
"defaults": {
|
|
129
|
+
labelWidth: 300,
|
|
130
|
+
},
|
|
131
|
+
"items": [
|
|
132
|
+
{
|
|
133
|
+
"type": "FieldSet",
|
|
134
|
+
"title": "General",
|
|
135
|
+
"reference": "general",
|
|
136
|
+
"defaults": {},
|
|
137
|
+
"items": [
|
|
138
|
+
{
|
|
139
|
+
label: 'PM Schedule',
|
|
140
|
+
name: 'pmSchedule.name',
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
label: 'Status',
|
|
144
|
+
name: 'pm_status_name',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
label: 'Next PM Date',
|
|
148
|
+
name: 'nextPmDate',
|
|
149
|
+
viewerFormatter: formatDateValue,
|
|
150
|
+
},
|
|
151
|
+
json?.overduePms > 0 && {
|
|
152
|
+
label: 'Overdue PMs',
|
|
153
|
+
name: 'overduePms',
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"type": "FieldSet",
|
|
159
|
+
"title": "Calculation Details",
|
|
160
|
+
"reference": "calcDetails",
|
|
161
|
+
"defaults": {},
|
|
162
|
+
"items": [
|
|
163
|
+
{
|
|
164
|
+
label: 'Controlling Method',
|
|
165
|
+
name: 'controllingMethod',
|
|
166
|
+
tooltip: 'Indicates whether the calculation was based on days or usage (meter). ' +
|
|
167
|
+
'If both methods are applicable, the one resulting in the earlier PM date is chosen.',
|
|
168
|
+
},
|
|
169
|
+
(json?.pm_status_id === PM_STATUSES__OVERDUE || json?.pm_status_id === PM_STATUSES__PM_DUE) && {
|
|
170
|
+
label: 'Grace Period End Date',
|
|
171
|
+
name: 'maxGracePeriodDateTime',
|
|
172
|
+
viewerFormatter: formatDateValue,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
label: 'Last Reset Date',
|
|
176
|
+
name: 'resetDate',
|
|
177
|
+
tooltip: 'Indicates whether the calculation was based on days or usage (meter). ' +
|
|
178
|
+
'If both methods are applicable, the one resulting in the earlier PM date is chosen.',
|
|
179
|
+
viewerFormatter: formatDateValue,
|
|
180
|
+
},
|
|
181
|
+
json?.workOrder?.title && {
|
|
182
|
+
label: 'Work Order',
|
|
183
|
+
name: 'workOrder.title',
|
|
184
|
+
},
|
|
185
|
+
json?.workOrder?.service_order && {
|
|
186
|
+
label: 'Work Order',
|
|
187
|
+
name: 'workOrder.service_order',
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
label: 'Meter Accrued Since Last PM',
|
|
191
|
+
name: 'meterAccruedSinceLatestPm',
|
|
192
|
+
viewerFormatter: formatMeterValue,
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
label: 'Meter Remaining Until Next PM',
|
|
196
|
+
name: 'meterRemainingUntilNextPm',
|
|
197
|
+
viewerFormatter: formatMeterValue,
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
label: 'Days Since Last PM',
|
|
201
|
+
name: 'daysSinceLatestPm',
|
|
202
|
+
viewerFormatter: formatDaysValue,
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
label: 'Days Left Until Next PM',
|
|
206
|
+
name: 'daysLeft',
|
|
207
|
+
viewerFormatter: formatDaysValue,
|
|
208
|
+
},
|
|
209
|
+
// json?.isDelayed && {
|
|
210
|
+
// label: 'Is Delayed',
|
|
211
|
+
// name: 'isDelayed',
|
|
212
|
+
// },
|
|
213
|
+
// json?.isOverride && {
|
|
214
|
+
// label: 'Is Override',
|
|
215
|
+
// name: 'isOverride',
|
|
216
|
+
// },
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"type": "FieldSet",
|
|
221
|
+
"title": "PM Schedule Config",
|
|
222
|
+
"reference": "pmSchedule",
|
|
223
|
+
"defaults": {},
|
|
224
|
+
"items": [
|
|
225
|
+
json?.pmSchedule?.interval_days && {
|
|
226
|
+
label: 'Interval Days',
|
|
227
|
+
name: 'pmSchedule.interval_days',
|
|
228
|
+
},
|
|
229
|
+
json?.pmSchedule?.interval_meter && {
|
|
230
|
+
label: 'Interval Meter',
|
|
231
|
+
name: 'pmSchedule.interval_meter',
|
|
232
|
+
viewerFormatter: formatMeterValue,
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
label: 'Mode',
|
|
236
|
+
name: 'pmScheduleMode',
|
|
237
|
+
},
|
|
238
|
+
]
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"type": "FieldSet",
|
|
242
|
+
"title": "Equipment",
|
|
243
|
+
"reference": "equipment",
|
|
244
|
+
"defaults": {},
|
|
245
|
+
"items": [
|
|
246
|
+
{
|
|
247
|
+
label: 'In Service Date',
|
|
248
|
+
name: 'inServiceDate',
|
|
249
|
+
viewerFormatter: formatDateValue,
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
label: 'Latest Meter Reading',
|
|
253
|
+
name: 'latestMeterReading',
|
|
254
|
+
viewerFormatter: formatMeterValue,
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
label: 'Avg Daily Meter',
|
|
258
|
+
name: 'avgDailyMeter',
|
|
259
|
+
viewerFormatter: formatMeterValue,
|
|
260
|
+
},
|
|
261
|
+
]
|
|
262
|
+
},
|
|
263
|
+
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
];
|
|
267
|
+
|
|
268
|
+
flattenedJson.pmScheduleMode = getPmScheduleMode(json?.pmSchedule.pm_schedule_mode_id);
|
|
269
|
+
|
|
270
|
+
return <Panel
|
|
271
|
+
title="PM Calculation Info"
|
|
272
|
+
className="PmCalcViewer-Panel"
|
|
273
|
+
isScrollable={true}
|
|
274
|
+
footer={<Footer className="justify-end">
|
|
275
|
+
<Button
|
|
276
|
+
{...testProps('closeBtn')}
|
|
277
|
+
key="closeBtn"
|
|
278
|
+
onPress={onClose}
|
|
279
|
+
className="text-white"
|
|
280
|
+
text="Close"
|
|
281
|
+
/>
|
|
282
|
+
</Footer>}
|
|
283
|
+
>
|
|
284
|
+
<Viewer
|
|
285
|
+
record={flattenedJson}
|
|
286
|
+
items={items}
|
|
287
|
+
/>
|
|
288
|
+
{/* <VStack className="PmCalcDebugViewer-VStack p-4">
|
|
289
|
+
|
|
290
|
+
<Text>Equipment: {metersPmSchedule.meters__nickname}</Text>
|
|
291
|
+
<Json
|
|
292
|
+
value={metersPmSchedule.meters_pm_schedules__debug_json}
|
|
293
|
+
displaySize="expanded"
|
|
294
|
+
editable={false}
|
|
295
|
+
collapsed={2}
|
|
296
|
+
/>
|
|
297
|
+
</VStack> */}
|
|
298
|
+
</Panel>;
|
|
299
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import DisplayField from '../Form/Field/DisplayField.js';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import {
|
|
4
|
+
PM_STATUSES__OK,
|
|
5
|
+
PM_STATUSES__PM_DUE,
|
|
6
|
+
PM_STATUSES__DELAYED,
|
|
7
|
+
PM_STATUSES__WILL_CALL,
|
|
8
|
+
PM_STATUSES__SCHEDULED,
|
|
9
|
+
PM_STATUSES__OVERDUE,
|
|
10
|
+
PM_STATUSES__COMPLETED,
|
|
11
|
+
} from '../../Constants/PmStatuses.js';
|
|
12
|
+
|
|
13
|
+
export default function PmStatusesViewer(props) {
|
|
14
|
+
let text = '';
|
|
15
|
+
switch(props.id) {
|
|
16
|
+
case PM_STATUSES__OK:
|
|
17
|
+
text = 'OK';
|
|
18
|
+
break;
|
|
19
|
+
case PM_STATUSES__PM_DUE:
|
|
20
|
+
text = 'Due';
|
|
21
|
+
break;
|
|
22
|
+
case PM_STATUSES__DELAYED:
|
|
23
|
+
text = 'Delayed';
|
|
24
|
+
break;
|
|
25
|
+
case PM_STATUSES__WILL_CALL:
|
|
26
|
+
text = 'Will Call';
|
|
27
|
+
break;
|
|
28
|
+
case PM_STATUSES__SCHEDULED:
|
|
29
|
+
text = 'Scheduled';
|
|
30
|
+
break;
|
|
31
|
+
case PM_STATUSES__OVERDUE:
|
|
32
|
+
text = 'Overdue';
|
|
33
|
+
break;
|
|
34
|
+
case PM_STATUSES__COMPLETED:
|
|
35
|
+
text = 'Completed';
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
text = 'Unknown';
|
|
39
|
+
}
|
|
40
|
+
let className = clsx(
|
|
41
|
+
'flex-none',
|
|
42
|
+
);
|
|
43
|
+
if (props.className) {
|
|
44
|
+
className += ' ' + props.className;
|
|
45
|
+
}
|
|
46
|
+
return <DisplayField
|
|
47
|
+
text={text}
|
|
48
|
+
{...props}
|
|
49
|
+
className={className}
|
|
50
|
+
/>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import DisplayField from '../Form/Field/DisplayField.js';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import {
|
|
4
|
+
MOMENT_DATE_FORMAT_5,
|
|
5
|
+
} from '../../Constants/Dates';
|
|
6
|
+
|
|
7
|
+
export default function TimeViewer(props) {
|
|
8
|
+
const {
|
|
9
|
+
moment,
|
|
10
|
+
} = props;
|
|
11
|
+
if (!moment || !moment.isValid()) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
let className = clsx(
|
|
15
|
+
'flex-none',
|
|
16
|
+
);
|
|
17
|
+
if (props.className) {
|
|
18
|
+
className += ' ' + props.className;
|
|
19
|
+
}
|
|
20
|
+
return <DisplayField
|
|
21
|
+
text={moment.format(MOMENT_DATE_FORMAT_5)}
|
|
22
|
+
{...props}
|
|
23
|
+
className={className}
|
|
24
|
+
/>;
|
|
25
|
+
}
|
|
@@ -114,6 +114,7 @@ function Viewer(props) {
|
|
|
114
114
|
}
|
|
115
115
|
let {
|
|
116
116
|
type,
|
|
117
|
+
viewerType,
|
|
117
118
|
title,
|
|
118
119
|
name,
|
|
119
120
|
label,
|
|
@@ -122,6 +123,7 @@ function Viewer(props) {
|
|
|
122
123
|
isHidden = false,
|
|
123
124
|
isHiddenInViewMode = false,
|
|
124
125
|
getDynamicProps,
|
|
126
|
+
viewerFormatter = null,
|
|
125
127
|
...itemPropsToPass
|
|
126
128
|
} = item,
|
|
127
129
|
viewerTypeProps = {};
|
|
@@ -137,7 +139,9 @@ function Viewer(props) {
|
|
|
137
139
|
}
|
|
138
140
|
const propertyDef = name && Repository?.getSchema().getPropertyDefinition(name);
|
|
139
141
|
if (!type) {
|
|
140
|
-
if (
|
|
142
|
+
if (viewerType) {
|
|
143
|
+
type = viewerType;
|
|
144
|
+
} else if (propertyDef?.viewerType?.type) {
|
|
141
145
|
const
|
|
142
146
|
{
|
|
143
147
|
type: t,
|
|
@@ -274,6 +278,9 @@ function Viewer(props) {
|
|
|
274
278
|
value = record.properties[fkDisplayField].displayValue;
|
|
275
279
|
}
|
|
276
280
|
}
|
|
281
|
+
if (viewerFormatter) {
|
|
282
|
+
value = viewerFormatter(value, record, self);
|
|
283
|
+
}
|
|
277
284
|
|
|
278
285
|
let elementClassName = clsx(
|
|
279
286
|
'Viewer-field',
|
package/src/Components/index.js
CHANGED
|
@@ -255,6 +255,8 @@ import Container from './Container/Container.js';
|
|
|
255
255
|
import ContainerColumn from './Container/ContainerColumn.js';
|
|
256
256
|
import DataMgt from './Screens/DataMgt.js';
|
|
257
257
|
import Date from './Form/Field/Date.js';
|
|
258
|
+
import DateViewer from './Viewer/DateViewer.js';
|
|
259
|
+
import DateTimeViewer from './Viewer/DateTimeViewer.js';
|
|
258
260
|
import DateRange from './Filter/DateRange.js';
|
|
259
261
|
import DisplayField from './Form/Field/DisplayField.js';
|
|
260
262
|
import ExpandButton from './Buttons/ExpandButton.js';
|
|
@@ -278,6 +280,8 @@ import NumberRange from './Filter/NumberRange.js';
|
|
|
278
280
|
import Panel from './Panel/Panel.js';
|
|
279
281
|
// import Picker from './Panel/Picker.js';
|
|
280
282
|
import PlusMinusButton from './Buttons/PlusMinusButton.js';
|
|
283
|
+
import PmCalcDebugViewer from './Viewer/PmCalcDebugViewer.js';
|
|
284
|
+
import PmStatusesViewer from './Viewer/PmStatusesViewer.js';
|
|
281
285
|
import RadioGroup from './Form/Field/RadioGroup/RadioGroup.js';
|
|
282
286
|
// import Slider from './Form/Field/Slider.js'; // Currently, Slider is not compatible with the new React architecture. Temporarily remove it from index.js to prevent issues.
|
|
283
287
|
import SquareButton from './Buttons/SquareButton.js';
|
|
@@ -286,6 +290,7 @@ import Tag from './Form/Field/Tag/Tag.js';
|
|
|
286
290
|
import TextArea from './Form/Field/TextArea.js';
|
|
287
291
|
import Text from './Form/Field/Text.js';
|
|
288
292
|
import TextWithLinks from './Viewer/TextWithLinks.js';
|
|
293
|
+
import TimeViewer from './Viewer/TimeViewer.js';
|
|
289
294
|
import TimezonesCombo from './Form/Field/Combo/TimezonesCombo.js';
|
|
290
295
|
import Toggle from './Form/Field/Toggle.js';
|
|
291
296
|
import Toolbar from './Toolbar/Toolbar.js';
|
|
@@ -550,6 +555,8 @@ const components = {
|
|
|
550
555
|
ContainerColumn,
|
|
551
556
|
DataMgt,
|
|
552
557
|
Date,
|
|
558
|
+
DateViewer,
|
|
559
|
+
DateTimeViewer,
|
|
553
560
|
DateRange,
|
|
554
561
|
DisplayField,
|
|
555
562
|
ExpandButton,
|
|
@@ -573,6 +580,8 @@ const components = {
|
|
|
573
580
|
Panel,
|
|
574
581
|
// Picker,
|
|
575
582
|
PlusMinusButton,
|
|
583
|
+
PmCalcDebugViewer,
|
|
584
|
+
PmStatusesViewer,
|
|
576
585
|
RadioGroup,
|
|
577
586
|
// Slider,
|
|
578
587
|
SquareButton,
|
|
@@ -581,6 +590,7 @@ const components = {
|
|
|
581
590
|
Text,
|
|
582
591
|
TextArea,
|
|
583
592
|
TextWithLinks,
|
|
593
|
+
TimeViewer,
|
|
584
594
|
TimezonesCombo,
|
|
585
595
|
Toggle,
|
|
586
596
|
Toolbar,
|
package/src/Constants/Dates.js
CHANGED
|
@@ -18,3 +18,4 @@ export const MOMENT_DATE_FORMAT_2 = 'MMM D YYYY, h:mm:ssa'; // pretty datetime
|
|
|
18
18
|
export const MOMENT_DATE_FORMAT_3 = 'h:mma'; // pretty time
|
|
19
19
|
export const MOMENT_DATE_FORMAT_4 = 'YYYY-MM-DD';
|
|
20
20
|
export const MOMENT_DATE_FORMAT_5 = 'HH:mm:ss';
|
|
21
|
+
export const MOMENT_DATE_FORMAT_6 = 'MMM D, YYYY'; // pretty date
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export const METER_TYPES__HOURS = 1;
|
|
2
|
+
export const METER_TYPES__HOURS_UNITS = 'hrs';
|
|
3
|
+
export const METER_TYPES__HOURS_TEXT = 'Time (' + METER_TYPES__HOURS_UNITS + ')';
|
|
2
4
|
export const METER_TYPES__MILES = 2;
|
|
3
|
-
export const
|
|
4
|
-
export const METER_TYPES__MILES_TEXT = 'Distance (
|
|
5
|
+
export const METER_TYPES__MILES_UNITS = 'mi-km';
|
|
6
|
+
export const METER_TYPES__MILES_TEXT = 'Distance (' + METER_TYPES__MILES_UNITS + ')';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const PM_EVENT_TYPES__INITIAL = 1;
|
|
2
|
+
export const PM_EVENT_TYPES__WORK_ORDER = 2;
|
|
3
|
+
export const PM_EVENT_TYPES__ALERT = 3;
|
|
4
|
+
export const PM_EVENT_TYPES__COMPLETE = 4;
|
|
5
|
+
export const PM_EVENT_TYPES__RESET = 5;
|
|
6
|
+
export const PM_EVENT_TYPES__DELAY_BY_DAYS = 6;
|
|
7
|
+
export const PM_EVENT_TYPES__DELAY_BY_METER = 7;
|
|
8
|
+
export const PM_EVENT_TYPES__SCHEDULE_PM = 8;
|
|
9
|
+
export const PM_EVENT_TYPES__WILL_CALL = 9;
|
|
10
|
+
export const PM_EVENT_TYPES__ASSIGN_TECHNICIAN = 10;
|
|
11
|
+
export const PM_EVENT_TYPES__COMMENT = 11;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const PM_STATUSES__OK = 1;
|
|
2
|
+
export const PM_STATUSES__OK_TEXT = 'OK';
|
|
3
|
+
export const PM_STATUSES__PM_DUE = 2;
|
|
4
|
+
export const PM_STATUSES__PM_DUE_TEXT = 'PM Due';
|
|
5
|
+
export const PM_STATUSES__DELAYED = 3;
|
|
6
|
+
export const PM_STATUSES__DELAYED_TEXT = 'Delayed';
|
|
7
|
+
export const PM_STATUSES__WILL_CALL = 4;
|
|
8
|
+
export const PM_STATUSES__WILL_CALL_TEXT = 'Will Call';
|
|
9
|
+
export const PM_STATUSES__SCHEDULED = 5;
|
|
10
|
+
export const PM_STATUSES__SCHEDULED_TEXT = 'Scheduled';
|
|
11
|
+
export const PM_STATUSES__OVERDUE = 6;
|
|
12
|
+
export const PM_STATUSES__OVERDUE_TEXT = 'Overdue';
|
|
13
|
+
export const PM_STATUSES__COMPLETED = 7;
|
|
14
|
+
export const PM_STATUSES__COMPLETED_TEXT = 'Completed';
|
|
15
|
+
export const PM_STATUSES__DISABLED = 8;
|
|
16
|
+
export const PM_STATUSES__DISABLED_TEXT = 'Disabled';
|
|
@@ -819,6 +819,7 @@ function AttachmentsElement(props) {
|
|
|
819
819
|
}
|
|
820
820
|
|
|
821
821
|
if (self) {
|
|
822
|
+
self.repository = Attachments;
|
|
822
823
|
self.getFiles = getFiles;
|
|
823
824
|
self.setFiles = setFiles;
|
|
824
825
|
self.clearFiles = clearFiles;
|
|
@@ -1211,7 +1212,7 @@ function AttachmentsElement(props) {
|
|
|
1211
1212
|
onChangeSelection: (selection) => {
|
|
1212
1213
|
setTreeSelection(selection);
|
|
1213
1214
|
},
|
|
1214
|
-
additionalToolbarButtons: canCrud ? [
|
|
1215
|
+
additionalToolbarButtons: canCrud && treeSelection[0] && !treeSelection[0].isDestroyed ? [
|
|
1215
1216
|
{
|
|
1216
1217
|
key: 'Plus',
|
|
1217
1218
|
text: 'New Directory',
|