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:
@@ -56,10 +56,6 @@ class FalukantController {
|
||||
if (!page) page = 1;
|
||||
return this.service.moneyHistory(userId, page, filter);
|
||||
});
|
||||
this.moneyHistoryGraph = this._wrapWithUser((userId, req) => {
|
||||
const { range } = req.body || {};
|
||||
return this.service.moneyHistoryGraph(userId, range || '24h');
|
||||
});
|
||||
this.getStorage = this._wrapWithUser((userId, req) => this.service.getStorage(userId, req.params.branchId));
|
||||
this.buyStorage = this._wrapWithUser((userId, req) => {
|
||||
const { branchId, amount, stockTypeId } = req.body;
|
||||
@@ -125,9 +121,6 @@ class FalukantController {
|
||||
});
|
||||
|
||||
this.getTitlesOfNobility = this._wrapWithUser((userId) => this.service.getTitlesOfNobility(userId));
|
||||
this.getReputationActions = this._wrapWithUser((userId) => this.service.getReputationActions(userId));
|
||||
this.executeReputationAction = this._wrapWithUser((userId, req) =>
|
||||
this.service.executeReputationAction(userId, req.body?.actionTypeId), { successStatus: 201 });
|
||||
this.getHouseTypes = this._wrapWithUser((userId) => this.service.getHouseTypes(userId));
|
||||
this.getMoodAffect = this._wrapWithUser((userId) => this.service.getMoodAffect(userId));
|
||||
this.getCharacterAffect = this._wrapWithUser((userId) => this.service.getCharacterAffect(userId));
|
||||
@@ -147,17 +140,6 @@ class FalukantController {
|
||||
const { characterId: childId, firstName } = req.body;
|
||||
return this.service.baptise(userId, childId, firstName);
|
||||
});
|
||||
this.getChurchOverview = this._wrapWithUser((userId) => this.service.getChurchOverview(userId));
|
||||
this.getAvailableChurchPositions = this._wrapWithUser((userId) => this.service.getAvailableChurchPositions(userId));
|
||||
this.getSupervisedApplications = this._wrapWithUser((userId) => this.service.getSupervisedApplications(userId));
|
||||
this.applyForChurchPosition = this._wrapWithUser((userId, req) => {
|
||||
const { officeTypeId, regionId } = req.body;
|
||||
return this.service.applyForChurchPosition(userId, officeTypeId, regionId);
|
||||
});
|
||||
this.decideOnChurchApplication = this._wrapWithUser((userId, req) => {
|
||||
const { applicationId, decision } = req.body;
|
||||
return this.service.decideOnChurchApplication(userId, applicationId, decision);
|
||||
});
|
||||
|
||||
this.getEducation = this._wrapWithUser((userId) => this.service.getEducation(userId));
|
||||
this.sendToSchool = this._wrapWithUser((userId, req) => {
|
||||
@@ -170,20 +152,25 @@ class FalukantController {
|
||||
this.takeBankCredits = this._wrapWithUser((userId, req) => this.service.takeBankCredits(userId, req.body.height));
|
||||
|
||||
this.getNobility = this._wrapWithUser((userId) => this.service.getNobility(userId));
|
||||
this.advanceNobility = this._wrapWithUser((userId) => this.service.advanceNobility(userId));
|
||||
|
||||
this.getHealth = this._wrapWithUser((userId) => this.service.getHealth(userId));
|
||||
this.healthActivity = this._wrapWithUser(async (userId, req) => {
|
||||
this.advanceNobility = this._wrapWithUser(async (userId) => {
|
||||
try {
|
||||
return await this.service.healthActivity(userId, req.body.measureTr);
|
||||
return await this.service.advanceNobility(userId);
|
||||
} catch (e) {
|
||||
if (e && e.name === 'PreconditionError' && e.message === 'tooClose') {
|
||||
throw { status: 412, message: 'tooClose', retryAt: e.meta?.retryAt };
|
||||
if (e && e.name === 'PreconditionError') {
|
||||
if (e.message === 'nobilityTooSoon') {
|
||||
throw { status: 412, message: 'nobilityTooSoon', retryAt: e.meta?.retryAt };
|
||||
}
|
||||
if (e.message === 'nobilityRequirements') {
|
||||
throw { status: 412, message: 'nobilityRequirements', unmet: e.meta?.unmet || [] };
|
||||
}
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
this.getHealth = this._wrapWithUser((userId) => this.service.getHealth(userId));
|
||||
this.healthActivity = this._wrapWithUser((userId, req) => this.service.healthActivity(userId, req.body.measureTr));
|
||||
|
||||
this.getPoliticsOverview = this._wrapWithUser((userId) => this.service.getPoliticsOverview(userId));
|
||||
this.getOpenPolitics = this._wrapWithUser((userId) => this.service.getOpenPolitics(userId));
|
||||
this.getElections = this._wrapWithUser((userId) => this.service.getElections(userId));
|
||||
@@ -200,13 +187,6 @@ class FalukantController {
|
||||
}
|
||||
return this.service.getProductPriceInRegion(userId, productId, regionId);
|
||||
});
|
||||
this.getAllProductPricesInRegion = this._wrapWithUser((userId, req) => {
|
||||
const regionId = parseInt(req.query.regionId, 10);
|
||||
if (Number.isNaN(regionId)) {
|
||||
throw new Error('regionId is required');
|
||||
}
|
||||
return this.service.getAllProductPricesInRegion(userId, regionId);
|
||||
});
|
||||
this.getProductPricesInCities = this._wrapWithUser((userId, req) => {
|
||||
const productId = parseInt(req.query.productId, 10);
|
||||
const currentPrice = parseFloat(req.query.currentPrice);
|
||||
@@ -216,16 +196,6 @@ class FalukantController {
|
||||
}
|
||||
return this.service.getProductPricesInCities(userId, productId, currentPrice, currentRegionId);
|
||||
});
|
||||
this.getProductPricesInCitiesBatch = this._wrapWithUser((userId, req) => {
|
||||
const body = req.body || {};
|
||||
const items = Array.isArray(body.items) ? body.items : [];
|
||||
const currentRegionId = body.currentRegionId != null ? parseInt(body.currentRegionId, 10) : null;
|
||||
const valid = items.map(i => ({
|
||||
productId: parseInt(i.productId, 10),
|
||||
currentPrice: parseFloat(i.currentPrice)
|
||||
})).filter(i => !Number.isNaN(i.productId) && !Number.isNaN(i.currentPrice));
|
||||
return this.service.getProductPricesInCitiesBatch(userId, valid, Number.isNaN(currentRegionId) ? null : currentRegionId);
|
||||
});
|
||||
this.renovate = this._wrapWithUser((userId, req) => this.service.renovate(userId, req.body.element));
|
||||
this.renovateAll = this._wrapWithUser((userId) => this.service.renovateAll(userId));
|
||||
|
||||
@@ -233,7 +203,6 @@ class FalukantController {
|
||||
this.getNotifications = this._wrapWithUser((userId) => this.service.getNotifications(userId));
|
||||
this.getAllNotifications = this._wrapWithUser((userId, req) => this.service.getAllNotifications(userId, req.query.page, req.query.size));
|
||||
this.markNotificationsShown = this._wrapWithUser((userId) => this.service.markNotificationsShown(userId), { successStatus: 202 });
|
||||
this.getDashboardWidget = this._wrapWithUser((userId) => this.service.getDashboardWidget(userId));
|
||||
this.getUndergroundTargets = this._wrapWithUser((userId) => this.service.getPoliticalOfficeHolders(userId));
|
||||
|
||||
this.searchUsers = this._wrapWithUser((userId, req) => {
|
||||
@@ -308,13 +277,7 @@ class FalukantController {
|
||||
} catch (error) {
|
||||
console.error('Controller error:', error);
|
||||
const status = error.status && typeof error.status === 'number' ? error.status : 500;
|
||||
// Wenn error ein Objekt mit status ist, alle Felder außer status übernehmen
|
||||
if (error && typeof error === 'object' && error.status && typeof error.status === 'number') {
|
||||
const { status: errorStatus, ...errorData } = error;
|
||||
res.status(errorStatus).json({ error: error.message || errorData.message || 'Internal error', ...errorData });
|
||||
} else {
|
||||
res.status(status).json({ error: error.message || 'Internal error' });
|
||||
}
|
||||
res.status(status).json({ error: error.message || 'Internal error' });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,7 +15,17 @@ ProductType.init({
|
||||
allowNull: false},
|
||||
sellCost: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false
|
||||
allowNull: false}
|
||||
,
|
||||
sellCostMinNeutral: {
|
||||
type: DataTypes.DECIMAL,
|
||||
allowNull: true,
|
||||
field: 'sell_cost_min_neutral'
|
||||
},
|
||||
sellCostMaxNeutral: {
|
||||
type: DataTypes.DECIMAL,
|
||||
allowNull: true,
|
||||
field: 'sell_cost_max_neutral'
|
||||
}
|
||||
}, {
|
||||
sequelize,
|
||||
|
||||
@@ -11,7 +11,6 @@ router.get('/character/affect', falukantController.getCharacterAffect);
|
||||
router.get('/name/randomfirstname/:gender', falukantController.randomFirstName);
|
||||
router.get('/name/randomlastname', falukantController.randomLastName);
|
||||
router.get('/info', falukantController.getInfo);
|
||||
router.get('/dashboard-widget', falukantController.getDashboardWidget);
|
||||
router.get('/branches/types', falukantController.getBranchTypes);
|
||||
router.get('/branches/:branch', falukantController.getBranch);
|
||||
router.get('/branches', falukantController.getBranches);
|
||||
@@ -29,7 +28,6 @@ router.get('/inventory/?:branchId', falukantController.getInventory);
|
||||
router.post('/sell/all', falukantController.sellAllProducts);
|
||||
router.post('/sell', falukantController.sellProduct);
|
||||
router.post('/moneyhistory', falukantController.moneyHistory);
|
||||
router.post('/moneyhistory/graph', falukantController.moneyHistoryGraph);
|
||||
router.get('/storage/:branchId', falukantController.getStorage);
|
||||
router.post('/storage', falukantController.buyStorage);
|
||||
router.delete('/storage', falukantController.sellStorage);
|
||||
@@ -47,8 +45,6 @@ router.get('/family/children', falukantController.getChildren);
|
||||
router.post('/family/gift', falukantController.sendGift);
|
||||
router.get('/family', falukantController.getFamily);
|
||||
router.get('/nobility/titels', falukantController.getTitlesOfNobility);
|
||||
router.get('/reputation/actions', falukantController.getReputationActions);
|
||||
router.post('/reputation/actions', falukantController.executeReputationAction);
|
||||
router.get('/houses/types', falukantController.getHouseTypes);
|
||||
router.get('/houses/buyable', falukantController.getBuyableHouses);
|
||||
router.get('/houses', falukantController.getUserHouse);
|
||||
@@ -60,11 +56,6 @@ router.post('/party', falukantController.createParty);
|
||||
router.get('/party', falukantController.getParties);
|
||||
router.get('/family/notbaptised', falukantController.getNotBaptisedChildren);
|
||||
router.post('/church/baptise', falukantController.baptise);
|
||||
router.get('/church/overview', falukantController.getChurchOverview);
|
||||
router.get('/church/positions/available', falukantController.getAvailableChurchPositions);
|
||||
router.get('/church/applications/supervised', falukantController.getSupervisedApplications);
|
||||
router.post('/church/positions/apply', falukantController.applyForChurchPosition);
|
||||
router.post('/church/applications/decide', falukantController.decideOnChurchApplication);
|
||||
router.get('/education', falukantController.getEducation);
|
||||
router.post('/education', falukantController.sendToSchool);
|
||||
router.get('/bank/overview', falukantController.getBankOverview);
|
||||
@@ -76,14 +67,13 @@ router.get('/health', falukantController.getHealth);
|
||||
router.post('/health', falukantController.healthActivity);
|
||||
router.get('/politics/overview', falukantController.getPoliticsOverview);
|
||||
router.get('/politics/open', falukantController.getOpenPolitics);
|
||||
router.post('/politics/open', falukantController.applyForElections);
|
||||
router.get('/politics/elections', falukantController.getElections);
|
||||
router.post('/politics/elections', falukantController.vote);
|
||||
router.get('/politics/open', falukantController.getOpenPolitics);
|
||||
router.post('/politics/open', falukantController.applyForElections);
|
||||
router.get('/cities', falukantController.getRegions);
|
||||
router.get('/products/price-in-region', falukantController.getProductPriceInRegion);
|
||||
router.get('/products/prices-in-region', falukantController.getAllProductPricesInRegion);
|
||||
router.get('/products/prices-in-cities', falukantController.getProductPricesInCities);
|
||||
router.post('/products/prices-in-cities-batch', falukantController.getProductPricesInCitiesBatch);
|
||||
router.get('/branches/:branchId/taxes', falukantController.getBranchTaxes);
|
||||
router.get('/vehicles/types', falukantController.getVehicleTypes);
|
||||
router.post('/vehicles', falukantController.buyVehicles);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user