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:
@@ -360,7 +360,6 @@ export default {
|
||||
vehicles: [],
|
||||
activeTab: 'production',
|
||||
productPricesCache: {}, // Cache für regionale Preise: { productId: price }
|
||||
productPricesCacheRegionId: null, // regionId, für die der Cache gültig ist
|
||||
tabs: [
|
||||
{ value: 'production', label: 'falukant.branch.tabs.production' },
|
||||
{ value: 'inventory', label: 'falukant.branch.tabs.inventory' },
|
||||
@@ -570,46 +569,30 @@ export default {
|
||||
async loadProductPricesForCurrentBranch() {
|
||||
if (!this.selectedBranch || !this.selectedBranch.regionId) {
|
||||
this.productPricesCache = {};
|
||||
this.productPricesCacheRegionId = null;
|
||||
return;
|
||||
}
|
||||
if (this.productPricesCacheRegionId === this.selectedBranch.regionId && Object.keys(this.productPricesCache).length > 0) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { data } = await apiClient.get('/api/falukant/products/prices-in-region', {
|
||||
params: {
|
||||
regionId: this.selectedBranch.regionId
|
||||
}
|
||||
});
|
||||
this.productPricesCache = data.prices || {};
|
||||
this.productPricesCacheRegionId = this.selectedBranch.regionId;
|
||||
} catch (error) {
|
||||
console.error(`Error loading product prices for region ${this.selectedBranch.regionId}:`, error);
|
||||
// Fallback: Lade Preise einzeln (alte Methode)
|
||||
console.warn('[BranchView] Falling back to individual product price requests');
|
||||
const prices = {};
|
||||
for (const product of this.products) {
|
||||
try {
|
||||
const { data } = await apiClient.get('/api/falukant/products/price-in-region', {
|
||||
params: {
|
||||
productId: product.id,
|
||||
regionId: this.selectedBranch.regionId
|
||||
}
|
||||
});
|
||||
prices[product.id] = data.price;
|
||||
} catch (err) {
|
||||
console.error(`Error loading price for product ${product.id}:`, err);
|
||||
// Fallback auf Standard-Berechnung
|
||||
const knowledgeFactor = product.knowledges?.[0]?.knowledge || 0;
|
||||
const maxPrice = product.sellCost;
|
||||
const minPrice = maxPrice * 0.6;
|
||||
prices[product.id] = minPrice + (maxPrice - minPrice) * (knowledgeFactor / 100);
|
||||
}
|
||||
|
||||
// Lade Preise für alle Produkte in der aktuellen Region
|
||||
const prices = {};
|
||||
for (const product of this.products) {
|
||||
try {
|
||||
const { data } = await apiClient.get('/api/falukant/products/price-in-region', {
|
||||
params: {
|
||||
productId: product.id,
|
||||
regionId: this.selectedBranch.regionId
|
||||
}
|
||||
});
|
||||
prices[product.id] = data.price;
|
||||
} catch (error) {
|
||||
console.error(`Error loading price for product ${product.id}:`, error);
|
||||
// Fallback auf Standard-Berechnung
|
||||
const knowledgeFactor = product.knowledges?.[0]?.knowledge || 0;
|
||||
const maxPrice = product.sellCost;
|
||||
const minPrice = maxPrice * 0.6;
|
||||
prices[product.id] = minPrice + (maxPrice - minPrice) * (knowledgeFactor / 100);
|
||||
}
|
||||
this.productPricesCache = prices;
|
||||
this.productPricesCacheRegionId = this.selectedBranch?.regionId ?? null;
|
||||
}
|
||||
this.productPricesCache = prices;
|
||||
},
|
||||
|
||||
formatPercent(value) {
|
||||
@@ -721,17 +704,13 @@ 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);
|
||||
// Expect numeric speeds 1..4; provide localized labels as fallback to raw 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 translation returns the key (no translation found), fall back to the numeric value
|
||||
if (!translated || translated === tKey) return value;
|
||||
return translated;
|
||||
},
|
||||
|
||||
transportModeLabel(mode) {
|
||||
|
||||
Reference in New Issue
Block a user