robobyte-front-builder 1.0.17 → 1.0.19

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.
@@ -0,0 +1,151 @@
1
+ import React, {useState, useEffect} from 'react'
2
+ import {
3
+ Dialog,
4
+ DialogTitle,
5
+ DialogContent,
6
+ DialogActions,
7
+ Button,
8
+ Box,
9
+ Typography,
10
+ TextField,
11
+ IconButton,
12
+ List,
13
+ ListItem,
14
+ Paper,
15
+ Chip,
16
+ Alert
17
+ } from '@mui/material'
18
+ import {Add, Delete, Close} from '@mui/icons-material'
19
+
20
+ const ReportSettingsDialog = ({open, onClose, settings, onSave}) => {
21
+ const [localSettings, setLocalSettings] = useState({
22
+ rowUniqueId: []
23
+ })
24
+ const [newUniqueIdField, setNewUniqueIdField] = useState('')
25
+
26
+ useEffect(() => {
27
+ if (settings) {
28
+ setLocalSettings({
29
+ rowUniqueId: settings.rowUniqueId || []
30
+ })
31
+ }
32
+ }, [settings, open])
33
+
34
+ const handleAddUniqueIdField = () => {
35
+ if (!newUniqueIdField.trim()) return
36
+
37
+ setLocalSettings(prev => ({
38
+ ...prev,
39
+ rowUniqueId: [...prev.rowUniqueId, newUniqueIdField.trim()]
40
+ }))
41
+ setNewUniqueIdField('')
42
+ }
43
+
44
+ const handleRemoveUniqueIdField = (index) => {
45
+ setLocalSettings(prev => ({
46
+ ...prev,
47
+ rowUniqueId: prev.rowUniqueId.filter((_, i) => i !== index)
48
+ }))
49
+ }
50
+
51
+ const handleSave = () => {
52
+ onSave(localSettings)
53
+ onClose()
54
+ }
55
+
56
+ return (
57
+ <Dialog open={open} onClose={onClose} maxWidth="md" fullWidth>
58
+ <DialogTitle>
59
+ <Box display="flex" justifyContent="space-between" alignItems="center">
60
+ <Typography variant="h6">Report Settings</Typography>
61
+ <IconButton onClick={onClose} size="small">
62
+ <Close/>
63
+ </IconButton>
64
+ </Box>
65
+ </DialogTitle>
66
+ <DialogContent>
67
+ <Box sx={{display: 'flex', flexDirection: 'column', gap: 3, mt: 2}}>
68
+ {/* Row Unique ID Section */}
69
+ <Paper sx={{p: 2, bgcolor: 'background.default'}}>
70
+ <Typography variant="subtitle1" sx={{mb: 2, fontWeight: 'bold'}}>
71
+ Row Unique ID
72
+ </Typography>
73
+ <Alert severity="info" sx={{mb: 2, fontSize: '0.875rem'}}>
74
+ Define field(s) that uniquely identify each row. Can be a single field (e.g., "Id"),
75
+ nested field (e.g., "User.Id"), or multiple fields for composite keys.
76
+ Use dot notation for nested fields.
77
+ </Alert>
78
+
79
+ <Box sx={{display: 'flex', gap: 2, mb: 2}}>
80
+ <TextField
81
+ size="small"
82
+ fullWidth
83
+ label="Field Path"
84
+ placeholder="Id or Product.Id or User.Email"
85
+ value={newUniqueIdField}
86
+ onChange={(e) => setNewUniqueIdField(e.target.value)}
87
+ onKeyPress={(e) => {
88
+ if (e.key === 'Enter') {
89
+ handleAddUniqueIdField()
90
+ }
91
+ }}
92
+ />
93
+ <Button
94
+ variant="contained"
95
+ startIcon={<Add/>}
96
+ onClick={handleAddUniqueIdField}
97
+ disabled={!newUniqueIdField.trim()}
98
+ >
99
+ Add
100
+ </Button>
101
+ </Box>
102
+
103
+ {localSettings.rowUniqueId.length > 0 ? (
104
+ <Box sx={{display: 'flex', flexWrap: 'wrap', gap: 1}}>
105
+ {localSettings.rowUniqueId.map((field, index) => (
106
+ <Chip
107
+ key={index}
108
+ label={field}
109
+ onDelete={() => handleRemoveUniqueIdField(index)}
110
+ color="primary"
111
+ variant="outlined"
112
+ />
113
+ ))}
114
+ </Box>
115
+ ) : (
116
+ <Typography variant="body2" color="text.secondary">
117
+ No unique ID fields defined. Add at least one field to uniquely identify rows.
118
+ </Typography>
119
+ )}
120
+ </Paper>
121
+
122
+ {/* Preview */}
123
+ <Paper sx={{p: 2, bgcolor: 'background.default'}}>
124
+ <Typography variant="subtitle2" sx={{mb: 1}}>Preview</Typography>
125
+ <Box
126
+ component="pre"
127
+ sx={{
128
+ p: 2,
129
+ bgcolor: 'grey.900',
130
+ color: 'grey.100',
131
+ borderRadius: 1,
132
+ overflow: 'auto',
133
+ fontSize: '0.875rem'
134
+ }}
135
+ >
136
+ {JSON.stringify(localSettings, null, 2)}
137
+ </Box>
138
+ </Paper>
139
+ </Box>
140
+ </DialogContent>
141
+ <DialogActions>
142
+ <Button onClick={onClose}>Cancel</Button>
143
+ <Button variant="contained" onClick={handleSave}>
144
+ Save Settings
145
+ </Button>
146
+ </DialogActions>
147
+ </Dialog>
148
+ )
149
+ }
150
+
151
+ export default ReportSettingsDialog