From 3c07e0b5dee040896397ecfcaa869bd68c550540 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Sun, 31 Aug 2025 22:25:19 +0200 Subject: [PATCH] =?UTF-8?q?feat(frontend):=20Erweiterung=20der=20Benutzero?= =?UTF-8?q?berfl=C3=A4che=20zur=20Lagerverwaltung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Hinzufügen einer neuen Anzeige für den Fall, dass alle verfügbaren Lagertypen bereits vorhanden sind. - Anpassung der Logik zur Überprüfung, ob neue Lagertypen hinzugefügt werden können. - Aktualisierung der Übersetzungen in den Sprachdateien für die neuen Meldungen zur Lagerverwaltung. --- frontend/src/i18n/locales/de/admin.json | 3 +- frontend/src/i18n/locales/en/admin.json | 3 +- .../src/views/admin/falukant/EditUserView.vue | 55 ++++++++++++++++++- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/frontend/src/i18n/locales/de/admin.json b/frontend/src/i18n/locales/de/admin.json index d020f17..6aa84b5 100644 --- a/frontend/src/i18n/locales/de/admin.json +++ b/frontend/src/i18n/locales/de/admin.json @@ -66,7 +66,8 @@ "addStock": "Lager hinzufügen", "stockType": "Lagertyp", "selectStockType": "Lagertyp auswählen", - "quantity": "Menge" + "quantity": "Menge", + "allStocksAdded": "Alle verfügbaren Lagertypen sind bereits vorhanden" }, "errorLoadingStockTypes": "Fehler beim Laden der Lagertypen.", "errorAddingStock": "Fehler beim Hinzufügen des Lagers.", diff --git a/frontend/src/i18n/locales/en/admin.json b/frontend/src/i18n/locales/en/admin.json index ee1cfcf..dcaf06d 100644 --- a/frontend/src/i18n/locales/en/admin.json +++ b/frontend/src/i18n/locales/en/admin.json @@ -78,7 +78,8 @@ "addStock": "Add Warehouse", "stockType": "Warehouse Type", "selectStockType": "Select warehouse type", - "quantity": "Quantity" + "quantity": "Quantity", + "allStocksAdded": "All available warehouse types are already present" }, "errorLoadingStockTypes": "Error loading warehouse types.", "errorAddingStock": "Error adding warehouse.", diff --git a/frontend/src/views/admin/falukant/EditUserView.vue b/frontend/src/views/admin/falukant/EditUserView.vue index 8bf1691..3a93a3c 100644 --- a/frontend/src/views/admin/falukant/EditUserView.vue +++ b/frontend/src/views/admin/falukant/EditUserView.vue @@ -67,11 +67,14 @@
{{ $t('admin.falukant.edituser.branches.noStocks') }}
-
+
+
+ {{ $t('admin.falukant.edituser.branches.allStocksAdded') }} +
@@ -91,7 +94,7 @@ @@ -158,7 +161,26 @@ export default { } }, computed: { - ...mapState('falukant', ['user']) + ...mapState('falukant', ['user']), + availableStockTypes() { + if (!this.newStock.branchId || !this.stockTypes.length) { + return this.stockTypes; + } + + // Finde den aktuellen Branch + const currentBranch = this.userBranches.find(branch => branch.id === this.newStock.branchId); + if (!currentBranch || !currentBranch.stocks) { + return this.stockTypes; + } + + // Erstelle eine Liste der bereits vorhandenen Stock-Type-IDs für diesen Branch + const existingStockTypeIds = currentBranch.stocks.map(stock => stock.stockTypeId); + + // Filtere die Stock-Types, die noch nicht in diesem Branch vorhanden sind + return this.stockTypes.filter(stockType => + !existingStockTypeIds.includes(stockType.id) + ); + } }, async mounted() { const titlesResult = await apiClient.get('/api/falukant/nobility/titels'); @@ -287,6 +309,22 @@ export default { console.error('Error adding stock:', error); this.$root.$refs.errorDialog.open('tr:admin.falukant.edituser.errorAddingStock'); } + }, + canAddStock(branch) { + // Prüfe ob noch Stock-Types verfügbar sind, die für diesen Branch noch nicht existieren + if (!branch.stocks || !this.stockTypes.length) { + return true; // Wenn keine Stocks vorhanden sind, kann immer hinzugefügt werden + } + + // Erstelle eine Liste der bereits vorhandenen Stock-Type-IDs für diesen Branch + const existingStockTypeIds = branch.stocks.map(stock => stock.stockTypeId); + + // Prüfe ob es noch Stock-Types gibt, die nicht in diesem Branch vorhanden sind + const availableStockTypes = this.stockTypes.filter(stockType => + !existingStockTypeIds.includes(stockType.id) + ); + + return availableStockTypes.length > 0; } } } @@ -612,4 +650,15 @@ export default { .add-stock-btn:hover { background: #218838; } + +.all-stocks-added { + margin-top: 15px; + padding: 10px; + background: #e8f5e8; + border: 1px solid #c3e6c3; + border-radius: 4px; + color: #2d5a2d; + font-size: 14px; + text-align: center; +} \ No newline at end of file