u
This commit is contained in:
@@ -84,7 +84,7 @@ flow:
|
||||
| **Build & Dev** | Vite 8 (`type: module`) | Dev server on `4209`, HTTPS on `4308`, proxies `/api` → `http://localhost:4208` |
|
||||
| **Framework** | React 19 (`react`, `react-dom`) | Uses `PureComponent` (with Automats & dashgui) and modern function components |
|
||||
| **Routing** | `react-router-dom` v7 | Configured in [src/appRouter.jsx](file:///home/seb/src/dashfront/src/appRouter.jsx) with HMR router preservation |
|
||||
| **UI & Theming** | MUI 9 (`@mui/material`, Emotion) | Custom theme in `src/theme/`, base background `#c5ddd8` in `src/colors.js` |
|
||||
| **UI & Theming** | MUI 9 (`@mui/material`, Emotion) | Custom theme in `src/theme/`, base background `#85b7ad` in `src/colors.js` |
|
||||
| **Shared GUI** | `dashgui` (`file:../dashgui`) | `PanelTile`, `RecordList`, `Tile`, `SingleLineTextEdit`, `ElevatedPill` |
|
||||
| **State Management** | `react-automat` | Single state layer for all domain & configuration data (articles, categories, company, brands, units, POS terminals, session) |
|
||||
| **Notifications** | `notistack` | `useSnackbar()` / `<SnackbarProvider>` in [src/main.jsx](file:///home/seb/src/dashfront/src/main.jsx) |
|
||||
|
||||
103
index.html
103
index.html
@@ -1,56 +1,59 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="apple-touch-icon" href="/icons/icon-192.png" />
|
||||
<meta name="theme-color" content="#3b5bdb" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
<title>Dashfront</title>
|
||||
<style>
|
||||
html,
|
||||
body,
|
||||
#root {
|
||||
min-height: 100%;
|
||||
background-color: #c5ddd8;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
overscroll-behavior-y: none;
|
||||
touch-action: manipulation;
|
||||
}
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="apple-touch-icon" href="/icons/icon-192.png" />
|
||||
<meta name="theme-color" content="#3b5bdb" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
<title>Dashfront</title>
|
||||
<style>
|
||||
html,
|
||||
body,
|
||||
#root {
|
||||
min-height: 100%;
|
||||
background-color: #85b7ad;
|
||||
}
|
||||
|
||||
html {
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script>
|
||||
(function () {
|
||||
var host = location.hostname;
|
||||
if (host !== 'localhost' && host !== '127.0.0.1') return;
|
||||
if (!navigator.serviceWorker) return;
|
||||
var hadSw = false;
|
||||
navigator.serviceWorker.getRegistrations().then(function (regs) {
|
||||
hadSw = regs.length > 0;
|
||||
return Promise.all(regs.map(function (r) { return r.unregister(); }));
|
||||
}).then(function () {
|
||||
if (!window.caches) return hadSw;
|
||||
return caches.keys().then(function (keys) {
|
||||
return Promise.all(keys.map(function (k) { return caches.delete(k); }))
|
||||
.then(function () { return hadSw; });
|
||||
});
|
||||
}).then(function (reload) {
|
||||
if (reload && !sessionStorage.getItem('dashfront-sw-cleared')) {
|
||||
sessionStorage.setItem('dashfront-sw-cleared', '1');
|
||||
location.reload();
|
||||
}
|
||||
html,
|
||||
body {
|
||||
overscroll-behavior-y: none;
|
||||
touch-action: manipulation;
|
||||
}
|
||||
|
||||
html {
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script>
|
||||
(function () {
|
||||
var host = location.hostname;
|
||||
if (host !== 'localhost' && host !== '127.0.0.1') return;
|
||||
if (!navigator.serviceWorker) return;
|
||||
var hadSw = false;
|
||||
navigator.serviceWorker.getRegistrations().then(function (regs) {
|
||||
hadSw = regs.length > 0;
|
||||
return Promise.all(regs.map(function (r) { return r.unregister(); }));
|
||||
}).then(function () {
|
||||
if (!window.caches) return hadSw;
|
||||
return caches.keys().then(function (keys) {
|
||||
return Promise.all(keys.map(function (k) { return caches.delete(k); }))
|
||||
.then(function () { return hadSw; });
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
}).then(function (reload) {
|
||||
if (reload && !sessionStorage.getItem('dashfront-sw-cleared')) {
|
||||
sessionStorage.setItem('dashfront-sw-cleared', '1');
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,2 +1,2 @@
|
||||
// Mirrored in index.html and index.css for paint before JS loads.
|
||||
export const MAIN_BACKGROUND = '#c5ddd8';
|
||||
export const MAIN_BACKGROUND = '#85b7ad';
|
||||
|
||||
@@ -112,6 +112,7 @@ export default class TextInput extends Component {
|
||||
|
||||
const mergedSlotProps = {
|
||||
...restSlotProps,
|
||||
...(resolvedInputProps ? { input: resolvedInputProps } : {}),
|
||||
inputLabel: {
|
||||
...(label ? { shrink: true } : {}),
|
||||
...InputLabelProps,
|
||||
@@ -128,7 +129,6 @@ export default class TextInput extends Component {
|
||||
autoComplete="one-time-code"
|
||||
onFocus={this.handleFocus}
|
||||
onMouseDown={this.handleMouseDown}
|
||||
InputProps={resolvedInputProps}
|
||||
slotProps={mergedSlotProps}
|
||||
sx={resolveSx(sx)}
|
||||
{...rest}
|
||||
|
||||
@@ -246,20 +246,19 @@ export default class ArticleAttributesTab extends PureComponent {
|
||||
const isExclusive = Boolean(targetAttr.exclusive);
|
||||
const targetValId = Number(effectiveItemId);
|
||||
const isAlreadyAssigned = assignedAttributes.some((a) => a.attributeValueId === targetValId);
|
||||
const isMerkmalAlreadyAssigned = assignedAttributes.some((a) => a.attributeId === targetAttr.id);
|
||||
|
||||
if (isExclusive && isMerkmalAlreadyAssigned) {
|
||||
enqueueSnackbar('Eindeutiges Merkmal ist bereits zugeordnet.', { variant: 'info' });
|
||||
return;
|
||||
}
|
||||
|
||||
if (isAlreadyAssigned) {
|
||||
enqueueSnackbar('Bereits zugeordnet.', { variant: 'info' });
|
||||
return;
|
||||
}
|
||||
|
||||
const nextValues = isExclusive
|
||||
? [
|
||||
...assignedAttributes
|
||||
.filter((a) => a.attributeId !== targetAttr.id)
|
||||
.map((a) => a.attributeValueId),
|
||||
targetValId,
|
||||
]
|
||||
: [...assignedAttributes.map((a) => a.attributeValueId), targetValId];
|
||||
const nextValues = [...assignedAttributes.map((a) => a.attributeValueId), targetValId];
|
||||
|
||||
this.setState({ saving: true });
|
||||
try {
|
||||
@@ -282,6 +281,13 @@ export default class ArticleAttributesTab extends PureComponent {
|
||||
if (!targetProp || !val) return;
|
||||
|
||||
const isExclusive = Boolean(targetProp.exclusive);
|
||||
const isMerkmalAlreadyAssigned = assignedProperties.some((p) => p.propertyId === propId);
|
||||
|
||||
if (isExclusive && isMerkmalAlreadyAssigned) {
|
||||
enqueueSnackbar('Eindeutiges Merkmal ist bereits zugeordnet.', { variant: 'info' });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isExclusive) {
|
||||
const isAlreadyAssigned = assignedProperties.some(
|
||||
(p) => p.propertyId === propId && p.value.trim().toLowerCase() === val.toLowerCase()
|
||||
@@ -291,11 +297,8 @@ export default class ArticleAttributesTab extends PureComponent {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const sourceProps = isExclusive
|
||||
? assignedProperties.filter((p) => p.propertyId !== propId)
|
||||
: assignedProperties;
|
||||
const nextProps = [
|
||||
...sourceProps.map((p) => ({ propertyId: p.propertyId, value: p.value, sort: p.sort })),
|
||||
...assignedProperties.map((p) => ({ propertyId: p.propertyId, value: p.value, sort: p.sort })),
|
||||
{ propertyId: propId, value: val },
|
||||
];
|
||||
|
||||
@@ -470,6 +473,36 @@ export default class ArticleAttributesTab extends PureComponent {
|
||||
|
||||
assignedGroups.sort((a, b) => a.sort - b.sort || a.name.localeCompare(b.name));
|
||||
|
||||
const isExclusive = Boolean(selectedOption?.exclusive);
|
||||
const isMerkmalAlreadyAssigned = isAttr
|
||||
? assignedAttributes.some((a) => a.attributeId === selectedOption?.id)
|
||||
: assignedProperties.some((p) => p.propertyId === selectedOption?.id);
|
||||
|
||||
const isValueAlreadyAssigned = isAttr
|
||||
? assignedAttributes.some((a) => a.attributeValueId === Number(currentItemId))
|
||||
: (Boolean(customValueText.trim()) && assignedProperties.some(
|
||||
(p) => p.propertyId === selectedOption?.id && p.value.trim().toLowerCase() === customValueText.trim().toLowerCase()
|
||||
));
|
||||
|
||||
const isUniqueAlreadyAdded = isExclusive && isMerkmalAlreadyAssigned;
|
||||
|
||||
const isAddDisabled =
|
||||
saving ||
|
||||
isVariantBlocked ||
|
||||
!selectedMerkmalKey ||
|
||||
(isAttr ? !currentItemId || availableItems.length === 0 : !customValueText.trim()) ||
|
||||
isUniqueAlreadyAdded ||
|
||||
isValueAlreadyAssigned;
|
||||
|
||||
let addTooltipTitle = 'Hinzufügen';
|
||||
if (isUniqueAlreadyAdded) {
|
||||
addTooltipTitle = 'Eindeutiges Merkmal ist bereits zugeordnet';
|
||||
} else if (isValueAlreadyAssigned) {
|
||||
addTooltipTitle = 'Bereits zugeordnet';
|
||||
} else if (isVariantBlocked) {
|
||||
addTooltipTitle = 'Varianten-Merkmal kann nicht zugeordnet werden';
|
||||
}
|
||||
|
||||
return (
|
||||
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
|
||||
{/* Unified Add Bar: [Merkmal ▼] [Wert ▼ / Input] [+] */}
|
||||
@@ -531,16 +564,11 @@ export default class ArticleAttributesTab extends PureComponent {
|
||||
/>
|
||||
)}
|
||||
|
||||
<Tooltip title="Hinzufügen">
|
||||
<Tooltip title={addTooltipTitle}>
|
||||
<span>
|
||||
<IconButton
|
||||
color="primary"
|
||||
disabled={
|
||||
saving ||
|
||||
isVariantBlocked ||
|
||||
!selectedMerkmalKey ||
|
||||
(isAttr ? !selectedItemId || availableItems.length === 0 : !customValueText.trim())
|
||||
}
|
||||
disabled={isAddDisabled}
|
||||
onClick={() => void this.handleAddItem()}
|
||||
sx={{
|
||||
bgcolor: 'primary.main',
|
||||
|
||||
@@ -5,7 +5,7 @@ html,
|
||||
body,
|
||||
#root {
|
||||
min-height: 100%;
|
||||
background-color: #c5ddd8;
|
||||
background-color: #85b7ad;
|
||||
}
|
||||
|
||||
html,
|
||||
|
||||
@@ -288,45 +288,45 @@ export default defineConfig(({ command }) => ({
|
||||
nginxHeadersPreviewPlugin(),
|
||||
...(command === 'build'
|
||||
? [
|
||||
VitePWA({
|
||||
registerType: 'autoUpdate',
|
||||
injectRegister: 'auto',
|
||||
manifest: {
|
||||
id: '/',
|
||||
name: 'Dashfront',
|
||||
short_name: 'Dashfront',
|
||||
start_url: '/',
|
||||
scope: '/',
|
||||
display: 'standalone',
|
||||
background_color: '#c5ddd8',
|
||||
theme_color: '#3b5bdb',
|
||||
icons: [
|
||||
{
|
||||
src: '/icons/icon-192.png',
|
||||
sizes: '192x192',
|
||||
type: 'image/png',
|
||||
},
|
||||
{
|
||||
src: '/icons/icon-512.png',
|
||||
sizes: '512x512',
|
||||
type: 'image/png',
|
||||
},
|
||||
{
|
||||
src: '/icons/icon-512.png',
|
||||
sizes: '512x512',
|
||||
type: 'image/png',
|
||||
purpose: 'maskable',
|
||||
},
|
||||
],
|
||||
},
|
||||
workbox: {
|
||||
globPatterns: ['**/*.{js,css,html,ico,png,svg,webmanifest,woff2}'],
|
||||
globIgnores: ['**/*.wasm'],
|
||||
navigateFallback: 'index.html',
|
||||
navigateFallbackDenylist: [/^\/api/],
|
||||
},
|
||||
}),
|
||||
]
|
||||
VitePWA({
|
||||
registerType: 'autoUpdate',
|
||||
injectRegister: 'auto',
|
||||
manifest: {
|
||||
id: '/',
|
||||
name: 'Dashfront',
|
||||
short_name: 'Dashfront',
|
||||
start_url: '/',
|
||||
scope: '/',
|
||||
display: 'standalone',
|
||||
background_color: '#85b7ad',
|
||||
theme_color: '#3b5bdb',
|
||||
icons: [
|
||||
{
|
||||
src: '/icons/icon-192.png',
|
||||
sizes: '192x192',
|
||||
type: 'image/png',
|
||||
},
|
||||
{
|
||||
src: '/icons/icon-512.png',
|
||||
sizes: '512x512',
|
||||
type: 'image/png',
|
||||
},
|
||||
{
|
||||
src: '/icons/icon-512.png',
|
||||
sizes: '512x512',
|
||||
type: 'image/png',
|
||||
purpose: 'maskable',
|
||||
},
|
||||
],
|
||||
},
|
||||
workbox: {
|
||||
globPatterns: ['**/*.{js,css,html,ico,png,svg,webmanifest,woff2}'],
|
||||
globIgnores: ['**/*.wasm'],
|
||||
navigateFallback: 'index.html',
|
||||
navigateFallbackDenylist: [/^\/api/],
|
||||
},
|
||||
}),
|
||||
]
|
||||
: []),
|
||||
],
|
||||
server: sharedServer,
|
||||
|
||||
Reference in New Issue
Block a user