@etsoo/materialui 1.0.67 → 1.0.69
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/lib/AuditDisplay.d.ts +11 -13
- package/lib/AuditDisplay.js +3 -3
- package/lib/ShowDataComparison.d.ts +5 -10
- package/lib/ShowDataComparison.js +6 -3
- package/lib/TwoFieldInput.js +2 -4
- package/package.json +3 -3
- package/src/AuditDisplay.tsx +30 -17
- package/src/ShowDataComparison.tsx +13 -14
- package/src/TwoFieldInput.tsx +2 -2
package/lib/AuditDisplay.d.ts
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
|
+
import { AuditLineDto } from '@etsoo/appscript';
|
|
1
2
|
import { Theme } from '@mui/material';
|
|
2
3
|
import React, { CSSProperties } from 'react';
|
|
3
4
|
import { ListMoreDisplayProps } from './ListMoreDisplay';
|
|
4
|
-
import { AuditLineUpdateData } from './ShowDataComparison';
|
|
5
|
-
/**
|
|
6
|
-
* Audit line data model
|
|
7
|
-
*/
|
|
8
|
-
export interface AuditLine {
|
|
9
|
-
id: number;
|
|
10
|
-
creation: Date;
|
|
11
|
-
user: string;
|
|
12
|
-
action: string;
|
|
13
|
-
changes?: AuditLineUpdateData;
|
|
14
|
-
}
|
|
15
5
|
/**
|
|
16
6
|
* Audit display props
|
|
17
7
|
*/
|
|
18
|
-
export interface AuditDisplayProps extends Omit<ListMoreDisplayProps<
|
|
8
|
+
export interface AuditDisplayProps extends Omit<ListMoreDisplayProps<AuditLineDto>, 'children'> {
|
|
19
9
|
/**
|
|
20
10
|
* Get list item style callback
|
|
21
11
|
*/
|
|
22
12
|
getItemStyle?: (index: number, theme: Theme) => CSSProperties;
|
|
13
|
+
/**
|
|
14
|
+
* Get column label
|
|
15
|
+
*/
|
|
16
|
+
getColumnLabel?: (field: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Equal check
|
|
19
|
+
*/
|
|
20
|
+
equalCheck?: boolean;
|
|
23
21
|
/**
|
|
24
22
|
* Item/line renderer
|
|
25
23
|
*/
|
|
26
|
-
itemRenderer?: (data:
|
|
24
|
+
itemRenderer?: (data: AuditLineDto, index: number) => React.ReactNode;
|
|
27
25
|
}
|
|
28
26
|
/**
|
|
29
27
|
* Audit display
|
package/lib/AuditDisplay.js
CHANGED
|
@@ -31,10 +31,10 @@ export function AuditDisplay(props) {
|
|
|
31
31
|
background: index % 2 === 0
|
|
32
32
|
? theme.palette.grey[100]
|
|
33
33
|
: theme.palette.grey[50]
|
|
34
|
-
}), itemRenderer = (data) => {
|
|
35
|
-
const changes = data
|
|
34
|
+
}), getColumnLabel, equalCheck, itemRenderer = (data) => {
|
|
35
|
+
const { newData, oldData, changes = { newData: newData !== null && newData !== void 0 ? newData : {}, oldData: oldData !== null && oldData !== void 0 ? oldData : {} } } = data;
|
|
36
36
|
return (React.createElement(React.Fragment, null,
|
|
37
|
-
changes != null && (React.createElement(Button, { variant: "outlined", size: "small", onClick: () => ShowDataComparison(changes, title), sx: {
|
|
37
|
+
changes != null && (React.createElement(Button, { variant: "outlined", size: "small", onClick: () => ShowDataComparison(changes, title, getColumnLabel, equalCheck), sx: {
|
|
38
38
|
marginLeft: theme.spacing(1),
|
|
39
39
|
marginTop: theme.spacing(-0.5),
|
|
40
40
|
float: 'right'
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
+
import { AuditLineChangesDto } from '@etsoo/appscript';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*/
|
|
4
|
-
export interface AuditLineUpdateData {
|
|
5
|
-
oldData: Record<string, unknown>;
|
|
6
|
-
newData: Record<string, unknown>;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Check obj is instance of AuditLineUpdateData
|
|
3
|
+
* Check obj is instance of AuditLineChangesDto
|
|
10
4
|
* @param obj Input
|
|
11
5
|
* @returns Result
|
|
12
6
|
*/
|
|
13
|
-
export declare function IsAuditLineUpdateData(obj: any): obj is
|
|
7
|
+
export declare function IsAuditLineUpdateData(obj: any): obj is AuditLineChangesDto;
|
|
14
8
|
/**
|
|
15
9
|
* Show data comparison
|
|
16
10
|
* @param data Data
|
|
17
11
|
* @param modelTitle Model window title
|
|
18
12
|
* @param getLabel Get label callback
|
|
13
|
+
* @param equalCheck Equal check for properties
|
|
19
14
|
*/
|
|
20
|
-
export declare const ShowDataComparison: (data:
|
|
15
|
+
export declare const ShowDataComparison: (data: AuditLineChangesDto, modelTitle?: string, getLabel?: ((field: string) => string) | undefined, equalCheck?: boolean) => void;
|
|
@@ -4,7 +4,7 @@ import { Table, TableBody, TableCell, TableHead, TableRow } from '@mui/material'
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { globalApp } from './app/ReactApp';
|
|
6
6
|
/**
|
|
7
|
-
* Check obj is instance of
|
|
7
|
+
* Check obj is instance of AuditLineChangesDto
|
|
8
8
|
* @param obj Input
|
|
9
9
|
* @returns Result
|
|
10
10
|
*/
|
|
@@ -28,8 +28,9 @@ const formatValue = (value, app) => {
|
|
|
28
28
|
* @param data Data
|
|
29
29
|
* @param modelTitle Model window title
|
|
30
30
|
* @param getLabel Get label callback
|
|
31
|
+
* @param equalCheck Equal check for properties
|
|
31
32
|
*/
|
|
32
|
-
export const ShowDataComparison = (data, modelTitle, getLabel) => {
|
|
33
|
+
export const ShowDataComparison = (data, modelTitle, getLabel, equalCheck = true) => {
|
|
33
34
|
modelTitle !== null && modelTitle !== void 0 ? modelTitle : (modelTitle = globalApp.get('dataComparison'));
|
|
34
35
|
getLabel !== null && getLabel !== void 0 ? getLabel : (getLabel = (key) => {
|
|
35
36
|
var _a;
|
|
@@ -39,11 +40,13 @@ export const ShowDataComparison = (data, modelTitle, getLabel) => {
|
|
|
39
40
|
...Object.keys(data.oldData),
|
|
40
41
|
...Object.keys(data.newData)
|
|
41
42
|
]);
|
|
42
|
-
|
|
43
|
+
let rows = Array.from(keys).map((field) => ({
|
|
43
44
|
field,
|
|
44
45
|
oldValue: data.oldData[field],
|
|
45
46
|
newValue: data.newData[field]
|
|
46
47
|
}));
|
|
48
|
+
if (equalCheck)
|
|
49
|
+
rows = rows.filter((item) => !Utils.equals(item.oldValue, item.newValue));
|
|
47
50
|
const inputs = (React.createElement(Table, null,
|
|
48
51
|
React.createElement(TableHead, null,
|
|
49
52
|
React.createElement(TableRow, null,
|
package/lib/TwoFieldInput.js
CHANGED
|
@@ -44,10 +44,8 @@ export function TwoFieldInput(props) {
|
|
|
44
44
|
return '';
|
|
45
45
|
if (typeof v === 'number')
|
|
46
46
|
return v;
|
|
47
|
-
if (type === 'date')
|
|
48
|
-
return DateUtils.formatForInput(v);
|
|
49
|
-
if (type === 'datetime-local')
|
|
50
|
-
return DateUtils.formatForInput(v, true);
|
|
47
|
+
if (type === 'date' || type === 'datetime-local')
|
|
48
|
+
return DateUtils.formatForInput(v, type);
|
|
51
49
|
return v;
|
|
52
50
|
};
|
|
53
51
|
React.useEffect(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.69",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"@emotion/css": "^11.10.5",
|
|
52
52
|
"@emotion/react": "^11.10.5",
|
|
53
53
|
"@emotion/styled": "^11.10.5",
|
|
54
|
-
"@etsoo/appscript": "^1.3.
|
|
54
|
+
"@etsoo/appscript": "^1.3.30",
|
|
55
55
|
"@etsoo/notificationbase": "^1.1.14",
|
|
56
56
|
"@etsoo/react": "^1.6.24",
|
|
57
|
-
"@etsoo/shared": "^1.1.
|
|
57
|
+
"@etsoo/shared": "^1.1.75",
|
|
58
58
|
"@mui/icons-material": "^5.10.9",
|
|
59
59
|
"@mui/material": "^5.10.13",
|
|
60
60
|
"@types/pica": "^9.0.1",
|
package/src/AuditDisplay.tsx
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
+
import { AuditLineDto } from '@etsoo/appscript';
|
|
1
2
|
import { Utils } from '@etsoo/shared';
|
|
2
3
|
import { Button, Divider, Theme, Typography, useTheme } from '@mui/material';
|
|
3
4
|
import React, { CSSProperties } from 'react';
|
|
4
5
|
import { globalApp } from './app/ReactApp';
|
|
5
6
|
import { ListMoreDisplay, ListMoreDisplayProps } from './ListMoreDisplay';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Audit line data model
|
|
10
|
-
*/
|
|
11
|
-
export interface AuditLine {
|
|
12
|
-
id: number;
|
|
13
|
-
creation: Date;
|
|
14
|
-
user: string;
|
|
15
|
-
action: string;
|
|
16
|
-
changes?: AuditLineUpdateData;
|
|
17
|
-
}
|
|
7
|
+
import { ShowDataComparison } from './ShowDataComparison';
|
|
18
8
|
|
|
19
9
|
/**
|
|
20
10
|
* Audit display props
|
|
21
11
|
*/
|
|
22
12
|
export interface AuditDisplayProps
|
|
23
|
-
extends Omit<ListMoreDisplayProps<
|
|
13
|
+
extends Omit<ListMoreDisplayProps<AuditLineDto>, 'children'> {
|
|
24
14
|
/**
|
|
25
15
|
* Get list item style callback
|
|
26
16
|
*/
|
|
27
17
|
getItemStyle?: (index: number, theme: Theme) => CSSProperties;
|
|
28
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Get column label
|
|
21
|
+
*/
|
|
22
|
+
getColumnLabel?: (field: string) => string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Equal check
|
|
26
|
+
*/
|
|
27
|
+
equalCheck?: boolean;
|
|
28
|
+
|
|
29
29
|
/**
|
|
30
30
|
* Item/line renderer
|
|
31
31
|
*/
|
|
32
|
-
itemRenderer?: (data:
|
|
32
|
+
itemRenderer?: (data: AuditLineDto, index: number) => React.ReactNode;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// Get label
|
|
@@ -64,15 +64,28 @@ export function AuditDisplay(props: AuditDisplayProps) {
|
|
|
64
64
|
? theme.palette.grey[100]
|
|
65
65
|
: theme.palette.grey[50]
|
|
66
66
|
}),
|
|
67
|
+
getColumnLabel,
|
|
68
|
+
equalCheck,
|
|
67
69
|
itemRenderer = (data) => {
|
|
68
|
-
const
|
|
70
|
+
const {
|
|
71
|
+
newData,
|
|
72
|
+
oldData,
|
|
73
|
+
changes = { newData: newData ?? {}, oldData: oldData ?? {} }
|
|
74
|
+
} = data;
|
|
69
75
|
return (
|
|
70
76
|
<React.Fragment>
|
|
71
77
|
{changes != null && (
|
|
72
78
|
<Button
|
|
73
79
|
variant="outlined"
|
|
74
80
|
size="small"
|
|
75
|
-
onClick={() =>
|
|
81
|
+
onClick={() =>
|
|
82
|
+
ShowDataComparison(
|
|
83
|
+
changes,
|
|
84
|
+
title,
|
|
85
|
+
getColumnLabel,
|
|
86
|
+
equalCheck
|
|
87
|
+
)
|
|
88
|
+
}
|
|
76
89
|
sx={{
|
|
77
90
|
marginLeft: theme.spacing(1),
|
|
78
91
|
marginTop: theme.spacing(-0.5),
|
|
@@ -103,7 +116,7 @@ export function AuditDisplay(props: AuditDisplayProps) {
|
|
|
103
116
|
|
|
104
117
|
// Layout
|
|
105
118
|
return (
|
|
106
|
-
<ListMoreDisplay<
|
|
119
|
+
<ListMoreDisplay<AuditLineDto> headerTitle={headerTitle} {...rest}>
|
|
107
120
|
{(data, index) => (
|
|
108
121
|
<div key={data.id} style={getItemStyle(index, theme)}>
|
|
109
122
|
{itemRenderer(data, index)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IApp } from '@etsoo/appscript
|
|
1
|
+
import { AuditLineChangesDto, IApp } from '@etsoo/appscript';
|
|
2
2
|
import { NotificationMessageType } from '@etsoo/notificationbase';
|
|
3
3
|
import { Utils } from '@etsoo/shared';
|
|
4
4
|
import {
|
|
@@ -12,19 +12,11 @@ import React from 'react';
|
|
|
12
12
|
import { globalApp } from './app/ReactApp';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export interface AuditLineUpdateData {
|
|
18
|
-
oldData: Record<string, unknown>;
|
|
19
|
-
newData: Record<string, unknown>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Check obj is instance of AuditLineUpdateData
|
|
15
|
+
* Check obj is instance of AuditLineChangesDto
|
|
24
16
|
* @param obj Input
|
|
25
17
|
* @returns Result
|
|
26
18
|
*/
|
|
27
|
-
export function IsAuditLineUpdateData(obj: any): obj is
|
|
19
|
+
export function IsAuditLineUpdateData(obj: any): obj is AuditLineChangesDto {
|
|
28
20
|
return (
|
|
29
21
|
typeof obj === 'object' &&
|
|
30
22
|
'oldData' in obj &&
|
|
@@ -46,11 +38,13 @@ const formatValue = (value: unknown, app: IApp) => {
|
|
|
46
38
|
* @param data Data
|
|
47
39
|
* @param modelTitle Model window title
|
|
48
40
|
* @param getLabel Get label callback
|
|
41
|
+
* @param equalCheck Equal check for properties
|
|
49
42
|
*/
|
|
50
43
|
export const ShowDataComparison = (
|
|
51
|
-
data:
|
|
44
|
+
data: AuditLineChangesDto,
|
|
52
45
|
modelTitle?: string,
|
|
53
|
-
getLabel?: (field: string) => string
|
|
46
|
+
getLabel?: (field: string) => string,
|
|
47
|
+
equalCheck: boolean = true
|
|
54
48
|
) => {
|
|
55
49
|
modelTitle ??= globalApp.get<string>('dataComparison');
|
|
56
50
|
getLabel ??= (key) => {
|
|
@@ -62,12 +56,17 @@ export const ShowDataComparison = (
|
|
|
62
56
|
...Object.keys(data.newData)
|
|
63
57
|
]);
|
|
64
58
|
|
|
65
|
-
|
|
59
|
+
let rows = Array.from(keys).map((field) => ({
|
|
66
60
|
field,
|
|
67
61
|
oldValue: data.oldData[field],
|
|
68
62
|
newValue: data.newData[field]
|
|
69
63
|
}));
|
|
70
64
|
|
|
65
|
+
if (equalCheck)
|
|
66
|
+
rows = rows.filter(
|
|
67
|
+
(item) => !Utils.equals(item.oldValue, item.newValue)
|
|
68
|
+
);
|
|
69
|
+
|
|
71
70
|
const inputs = (
|
|
72
71
|
<Table>
|
|
73
72
|
<TableHead>
|
package/src/TwoFieldInput.tsx
CHANGED
|
@@ -83,8 +83,8 @@ export function TwoFieldInput(props: TwoFieldInputProps) {
|
|
|
83
83
|
const formatValue = (v: ValueType, type?: string) => {
|
|
84
84
|
if (v == null) return '';
|
|
85
85
|
if (typeof v === 'number') return v;
|
|
86
|
-
if (type === 'date'
|
|
87
|
-
|
|
86
|
+
if (type === 'date' || type === 'datetime-local')
|
|
87
|
+
return DateUtils.formatForInput(v, type);
|
|
88
88
|
return v;
|
|
89
89
|
};
|
|
90
90
|
|