Refactor DirectorInfo and SaleSection components to unify speedLabel logic and remove unnecessary watch properties
- Simplified speedLabel method in DirectorInfo.vue and SaleSection.vue to handle null values and translations more efficiently. - Removed the watch property for branchId in DirectorInfo.vue as it was not needed. - Cleaned up the code by eliminating redundant checks and improving readability. Update translations in falukant.json files - Removed unused keys and cleaned up the structure in both German and English translation files. - Ensured that all necessary translations are still present while removing obsolete entries. Refactor BranchView and PoliticsView components for improved performance and clarity - Removed caching logic for product prices in BranchView.vue to simplify the loading process. - Streamlined the loadCurrentPositions method in PoliticsView.vue by eliminating unnecessary character ID checks and logging. - Enhanced the user experience by ensuring that the application submission process is clearer and more efficient. Clean up MoneyHistoryView and FamilyView components - Removed the graph section from MoneyHistoryView.vue to simplify the UI. - Adjusted the mood display logic in FamilyView.vue to ensure proper translation handling.
This commit is contained in:
@@ -210,14 +210,6 @@ export default {
|
||||
},
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
branchId: {
|
||||
immediate: false,
|
||||
handler() {
|
||||
this.loadDirector();
|
||||
},
|
||||
},
|
||||
},
|
||||
async mounted() {
|
||||
await this.loadDirector();
|
||||
},
|
||||
@@ -264,17 +256,11 @@ export default {
|
||||
},
|
||||
|
||||
speedLabel(value) {
|
||||
if (value == null) return this.$t('falukant.branch.transport.speed.unknown') || '—';
|
||||
if (typeof value === 'object') {
|
||||
const k = value.tr ?? value.id ?? 'unknown';
|
||||
const tKey = `falukant.branch.transport.speed.${k}`;
|
||||
const t = this.$t(tKey);
|
||||
return (t && t !== tKey) ? t : String(k);
|
||||
}
|
||||
const key = String(value);
|
||||
const key = value == null ? 'unknown' : String(value);
|
||||
const tKey = `falukant.branch.transport.speed.${key}`;
|
||||
const translated = this.$t(tKey);
|
||||
return (!translated || translated === tKey) ? key : translated;
|
||||
if (!translated || translated === tKey) return value;
|
||||
return translated;
|
||||
},
|
||||
|
||||
openNewDirectorDialog() {
|
||||
|
||||
@@ -251,6 +251,13 @@
|
||||
return new Date(a.eta).getTime() - new Date(b.eta).getTime();
|
||||
});
|
||||
},
|
||||
speedLabel(value) {
|
||||
const key = value == null ? 'unknown' : String(value);
|
||||
const tKey = `falukant.branch.transport.speed.${key}`;
|
||||
const translated = this.$t(tKey);
|
||||
if (!translated || translated === tKey) return value;
|
||||
return translated;
|
||||
},
|
||||
},
|
||||
async mounted() {
|
||||
await this.loadInventory();
|
||||
@@ -267,19 +274,6 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
speedLabel(value) {
|
||||
if (value == null) return this.$t('falukant.branch.transport.speed.unknown') || '—';
|
||||
if (typeof value === 'object') {
|
||||
const k = value.tr ?? value.id ?? 'unknown';
|
||||
const tKey = `falukant.branch.transport.speed.${k}`;
|
||||
const t = this.$t(tKey);
|
||||
return (t && t !== tKey) ? t : String(k);
|
||||
}
|
||||
const key = String(value);
|
||||
const tKey = `falukant.branch.transport.speed.${key}`;
|
||||
const translated = this.$t(tKey);
|
||||
return (!translated || translated === tKey) ? key : translated;
|
||||
},
|
||||
async loadInventory() {
|
||||
try {
|
||||
const response = await apiClient.get(`/api/falukant/inventory/${this.branchId}`);
|
||||
@@ -293,24 +287,25 @@
|
||||
}
|
||||
},
|
||||
async loadPricesForInventory() {
|
||||
if (this.inventory.length === 0) return;
|
||||
const currentRegionId = this.inventory[0]?.region?.id ?? null;
|
||||
const items = this.inventory.map(item => ({
|
||||
productId: item.product.id,
|
||||
currentPrice: item.product.sellCost || 0
|
||||
}));
|
||||
try {
|
||||
const { data } = await apiClient.post('/api/falukant/products/prices-in-cities-batch', {
|
||||
currentRegionId,
|
||||
items
|
||||
});
|
||||
for (const item of this.inventory) {
|
||||
item.betterPrices = data && data[item.product.id] ? data[item.product.id] : [];
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading prices for inventory:', error);
|
||||
for (const item of this.inventory) {
|
||||
item.betterPrices = [];
|
||||
for (const item of this.inventory) {
|
||||
const itemKey = `${item.region.id}-${item.product.id}-${item.quality}`;
|
||||
if (this.loadingPrices.has(itemKey)) continue;
|
||||
this.loadingPrices.add(itemKey);
|
||||
try {
|
||||
// Aktueller Preis basierend auf sellCost
|
||||
const currentPrice = item.product.sellCost || 0;
|
||||
const { data } = await apiClient.get('/api/falukant/products/prices-in-cities', {
|
||||
params: {
|
||||
productId: item.product.id,
|
||||
currentPrice: currentPrice
|
||||
}
|
||||
});
|
||||
this.$set(item, 'betterPrices', data || []);
|
||||
} catch (error) {
|
||||
console.error(`Error loading prices for item ${itemKey}:`, error);
|
||||
this.$set(item, 'betterPrices', []);
|
||||
} finally {
|
||||
this.loadingPrices.delete(itemKey);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user