@onehat/ui 0.4.102 → 0.4.103
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/Accordion/Accordion.js +65 -6
- package/src/Components/Container/Container.js +10 -4
- package/src/Components/Form/Form.js +8 -3
- package/src/Components/Grid/Grid.js +230 -154
- package/src/Components/Hoc/withPresetButtons.js +18 -6
- package/src/Components/Icons/ArrowsLeftRight.js +10 -0
- package/src/Components/Icons/Bar.js +10 -0
- package/src/Components/Icons/Box.js +11 -0
- package/src/Components/Icons/BoxOpen.js +11 -0
- package/src/Components/Icons/Bucket.js +10 -0
- package/src/Components/Icons/Bump.js +21 -0
- package/src/Components/Icons/Calculator.js +12 -0
- package/src/Components/Icons/Dots.js +20 -0
- package/src/Components/Icons/Fleets.js +26 -0
- package/src/Components/Icons/Microchip.js +12 -0
- package/src/Components/Icons/Num1.js +10 -0
- package/src/Components/Icons/Num2.js +10 -0
- package/src/Components/Icons/Num3.js +10 -0
- package/src/Components/Icons/Num4.js +10 -0
- package/src/Components/Icons/OilCan.js +11 -0
- package/src/Components/Icons/Operations.js +10 -0
- package/src/Components/Icons/OverduePms.js +10 -0
- package/src/Components/Icons/SackDollar.js +11 -0
- package/src/Components/Icons/ShortBar.js +15 -0
- package/src/Components/Icons/Tower.js +10 -0
- package/src/Components/Icons/UpcomingPms.js +10 -0
- package/src/Components/Layout/ScreenHeader.js +35 -3
- package/src/Components/Layout/SetupButton.js +31 -0
- package/src/Components/Layout/UserIndicator.js +35 -0
- package/src/Components/Pms/Editor/BumpPmsEditor.js +9 -0
- package/src/Components/Pms/Editor/MetersEditor.js +173 -0
- package/src/Components/Pms/Editor/PmEventsEditor.js +291 -0
- package/src/Components/Pms/Grid/UpcomingPmsGrid.js +569 -0
- package/src/Components/Pms/Layout/TreeSpecific/MakeTreeSelection.js +11 -0
- package/src/Components/Pms/Layout/TreeSpecific/TreeSpecific.js +30 -0
- package/src/Components/Pms/Modals/BulkAssignTechnician.js +104 -0
- package/src/Components/Pms/Screens/PmsManager.js +136 -0
- package/src/Components/Pms/Window/BumpPmsEditorWindow.js +25 -0
- package/src/Components/Screens/Manager.js +3 -0
- package/src/Components/Tree/Tree.js +15 -6
- package/src/Components/Viewer/PmCalcDebugViewer.js +164 -146
- package/src/Components/Viewer/TextWithLinks.js +9 -1
- package/src/Components/Viewer/Viewer.js +38 -30
- package/src/Functions/flatten.js +39 -0
- package/src/Functions/verifyCanCrudPmEvents.js +33 -0
|
@@ -278,39 +278,47 @@ function Viewer(props) {
|
|
|
278
278
|
value = record.properties[fkDisplayField].displayValue;
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
|
+
let element = null,
|
|
282
|
+
viewerFormatterReturnedReactComponent = false;
|
|
281
283
|
if (viewerFormatter) {
|
|
282
|
-
value = viewerFormatter(value, record, self);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
'grow',
|
|
289
|
-
'shrink',
|
|
290
|
-
);
|
|
291
|
-
const defaultsClassName = defaults.className;
|
|
292
|
-
if (defaultsClassName) {
|
|
293
|
-
elementClassName += ' ' + defaultsClassName;
|
|
294
|
-
}
|
|
295
|
-
const itemPropsToPassClassName = itemPropsToPass.className;
|
|
296
|
-
if (itemPropsToPassClassName) {
|
|
297
|
-
elementClassName += ' ' + itemPropsToPassClassName;
|
|
284
|
+
value = viewerFormatter(value, record, self); // viewerFormatter can return either a primitive value or a React component.
|
|
285
|
+
if (isValidElement(value)) {
|
|
286
|
+
// if it's a React component, render it directly
|
|
287
|
+
element = value;
|
|
288
|
+
viewerFormatterReturnedReactComponent = true;
|
|
289
|
+
}
|
|
298
290
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
291
|
+
if (!viewerFormatterReturnedReactComponent) {
|
|
292
|
+
let elementClassName = clsx(
|
|
293
|
+
'Viewer-field',
|
|
294
|
+
'basis-auto',
|
|
295
|
+
'grow',
|
|
296
|
+
'shrink',
|
|
297
|
+
);
|
|
298
|
+
const defaultsClassName = defaults.className;
|
|
299
|
+
if (defaultsClassName) {
|
|
300
|
+
elementClassName += ' ' + defaultsClassName;
|
|
301
|
+
}
|
|
302
|
+
const itemPropsToPassClassName = itemPropsToPass.className;
|
|
303
|
+
if (itemPropsToPassClassName) {
|
|
304
|
+
elementClassName += ' ' + itemPropsToPassClassName;
|
|
305
|
+
}
|
|
306
|
+
const viewerTypeClassName = viewerTypeProps.className;
|
|
307
|
+
if (viewerTypeClassName) {
|
|
308
|
+
elementClassName += ' ' + viewerTypeClassName;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
element = <Element
|
|
312
|
+
{...testProps('field-' + name)}
|
|
313
|
+
value={value}
|
|
314
|
+
isEditable={false}
|
|
315
|
+
parent={self}
|
|
316
|
+
reference={name}
|
|
317
|
+
{...itemPropsToPass}
|
|
318
|
+
{...viewerTypeProps}
|
|
319
|
+
className={elementClassName}
|
|
320
|
+
/>;
|
|
302
321
|
}
|
|
303
|
-
|
|
304
|
-
let element = <Element
|
|
305
|
-
{...testProps('field-' + name)}
|
|
306
|
-
value={value}
|
|
307
|
-
isEditable={false}
|
|
308
|
-
parent={self}
|
|
309
|
-
reference={name}
|
|
310
|
-
{...itemPropsToPass}
|
|
311
|
-
{...viewerTypeProps}
|
|
312
|
-
className={elementClassName}
|
|
313
|
-
/>;
|
|
314
322
|
|
|
315
323
|
if (item.additionalViewButtons) {
|
|
316
324
|
element = <HStack className="Viewer-HStack1 flex-wrap">
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// This function takes a nested JSON object and flattens it into a single-level object with dot notation keys.
|
|
2
|
+
// For example, { a: { b: 1 } } becomes { 'a.b': 1 }
|
|
3
|
+
// or { a: [ { b: 1 }, { c: 2 } ] } becomes { 'a.0.b': 1, 'a.1.c': 2 }
|
|
4
|
+
function isPlainObject(value) {
|
|
5
|
+
if (value === null || typeof value !== 'object') {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const prototype = Object.getPrototypeOf(value);
|
|
10
|
+
return prototype === Object.prototype || prototype === null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default function flatten(obj, prefix = '', result = {}) {
|
|
14
|
+
if (obj === null || typeof obj !== 'object') {
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
for (const key of Object.keys(obj)) {
|
|
19
|
+
const
|
|
20
|
+
newKey = prefix ? `${prefix}.${key}` : key,
|
|
21
|
+
value = obj[key];
|
|
22
|
+
|
|
23
|
+
if (isPlainObject(value)) {
|
|
24
|
+
flatten(value, newKey, result);
|
|
25
|
+
} else if (Array.isArray(value)) {
|
|
26
|
+
value.forEach((item, index) => {
|
|
27
|
+
const arrayKey = `${newKey}.${index}`;
|
|
28
|
+
if (isPlainObject(item) || Array.isArray(item)) {
|
|
29
|
+
flatten(item, arrayKey, result);
|
|
30
|
+
} else {
|
|
31
|
+
result[arrayKey] = item;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
result[newKey] = value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PM_EVENT_TYPES__COMPLETE,
|
|
3
|
+
PM_EVENT_TYPES__RESET,
|
|
4
|
+
PM_EVENT_TYPES__DELAY_BY_DAYS,
|
|
5
|
+
PM_EVENT_TYPES__DELAY_BY_METER,
|
|
6
|
+
PM_EVENT_TYPES__SCHEDULE_PM,
|
|
7
|
+
PM_EVENT_TYPES__WILL_CALL,
|
|
8
|
+
PM_EVENT_TYPES__ASSIGN_TECHNICIAN,
|
|
9
|
+
PM_EVENT_TYPES__COMMENT,
|
|
10
|
+
} from '../Constants/PmEventTypes.js';
|
|
11
|
+
import inArray from './inArray.js';
|
|
12
|
+
import _ from 'lodash';
|
|
13
|
+
|
|
14
|
+
export default function verifyCanCrudPmEvents(selection) {
|
|
15
|
+
let canCrud = true;
|
|
16
|
+
_.each(selection, (entity) => {
|
|
17
|
+
if (!inArray(entity.pm_events__pm_event_type_id, [
|
|
18
|
+
// manual types
|
|
19
|
+
PM_EVENT_TYPES__COMPLETE,
|
|
20
|
+
PM_EVENT_TYPES__RESET,
|
|
21
|
+
PM_EVENT_TYPES__DELAY_BY_DAYS,
|
|
22
|
+
PM_EVENT_TYPES__DELAY_BY_METER,
|
|
23
|
+
PM_EVENT_TYPES__SCHEDULE_PM,
|
|
24
|
+
PM_EVENT_TYPES__WILL_CALL,
|
|
25
|
+
PM_EVENT_TYPES__ASSIGN_TECHNICIAN,
|
|
26
|
+
PM_EVENT_TYPES__COMMENT,
|
|
27
|
+
])) {
|
|
28
|
+
canCrud = false;
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return canCrud;
|
|
33
|
+
};
|