feat(frontend): Erweiterung der Benutzeroberfläche zur Lagerverwaltung
- 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.
This commit is contained in:
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -67,11 +67,14 @@
|
||||
<div v-else class="no-stocks">
|
||||
{{ $t('admin.falukant.edituser.branches.noStocks') }}
|
||||
</div>
|
||||
<div class="add-stock-section">
|
||||
<div v-if="canAddStock(branch)" class="add-stock-section">
|
||||
<button @click="openAddStockDialog(branch.id)" class="add-stock-btn">
|
||||
{{ $t('admin.falukant.edituser.branches.addStock') }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-else-if="branch.stocks && branch.stocks.length > 0" class="all-stocks-added">
|
||||
{{ $t('admin.falukant.edituser.branches.allStocksAdded') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!userBranches.length" class="no-branches">
|
||||
@@ -91,7 +94,7 @@
|
||||
<label>{{ $t('admin.falukant.edituser.branches.stockType') }}:</label>
|
||||
<select v-model="newStock.stockTypeId" class="form-select">
|
||||
<option value="">{{ $t('admin.falukant.edituser.branches.selectStockType') }}</option>
|
||||
<option v-for="stockType in stockTypes" :key="stockType.id" :value="stockType.id">
|
||||
<option v-for="stockType in availableStockTypes" :key="stockType.id" :value="stockType.id">
|
||||
{{ $t(`falukant.branch.stocktype.${stockType.labelTr}`) }}
|
||||
</option>
|
||||
</select>
|
||||
@@ -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;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user