Some falukant fixes, added undeground ui - no save right now, changed menu (and verification)

This commit is contained in:
Torsten Schulz
2025-07-17 14:28:52 +02:00
parent fceea5b7fb
commit 89cf12a7a8
33 changed files with 1010 additions and 423 deletions

View File

@@ -88,6 +88,8 @@ import PoliticalOfficeRequirement from './falukant/predefine/political_office_pr
import PoliticalOfficePrerequisite from './falukant/predefine/political_office_prerequisite.js';
import PoliticalOfficeHistory from './falukant/log/political_office_history.js';
import ElectionHistory from './falukant/log/election_history.js';
import Underground from './falukant/data/underground.js';
import UndergroundType from './falukant/type/underground.js';
export default function setupAssociations() {
// UserParam related associations
@@ -675,7 +677,7 @@ export default function setupAssociations() {
PoliticalOfficeType.hasMany(PoliticalOfficeHistory, {
foreignKey: 'officeTypeId',
as: 'history',
as: 'history',
});
FalukantCharacter.hasMany(PoliticalOfficeHistory, {
@@ -686,7 +688,7 @@ export default function setupAssociations() {
foreignKey: 'characterId',
as: 'character',
});
ElectionHistory.belongsTo(PoliticalOfficeType, {
foreignKey: 'officeTypeId',
as: 'officeTypeHistory',
@@ -696,5 +698,34 @@ export default function setupAssociations() {
foreignKey: 'officeTypeId',
as: 'electionHistory',
}
)
);
Underground.belongsTo(UndergroundType, {
foreignKey: 'undergroundTypeId',
as: 'undergroundType'
});
UndergroundType.hasMany(Underground, {
foreignKey: 'undergroundTypeId',
as: 'undergrounds'
});
// 2) Täter (performer)
Underground.belongsTo(FalukantCharacter, {
foreignKey: 'performerId',
as: 'performer'
});
FalukantCharacter.hasMany(Underground, {
foreignKey: 'performerId',
as: 'performedUndergrounds'
});
// 3) Opfer (victim)
Underground.belongsTo(FalukantCharacter, {
foreignKey: 'victimId',
as: 'victim'
});
FalukantCharacter.hasMany(Underground, {
foreignKey: 'victimId',
as: 'victimUndergrounds'
});
}

View File

@@ -0,0 +1,36 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class Underground extends Model { }
Underground.init({
undergroundTypeId: {
type: DataTypes.STRING,
allowNull: false,
},
performerId: {
type: DataTypes.INTEGER,
allowNull: false,
},
victimId: {
type: DataTypes.INTEGER,
allowNull: false,
},
parameters: {
type: DataTypes.JSON,
allowNull: true,
},
result: {
type: DataTypes.JSON,
allowNull: true,
}
}, {
sequelize,
modelName: 'Underground',
tableName: 'underground',
schema: 'falukant_data',
timestamps: true,
underscored: true,
});
export default Underground;

View File

@@ -0,0 +1,25 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class UndergroundType extends Model { }
UndergroundType.init({
tr: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
},
cost: {
type: DataTypes.INTEGER,
allowNull: false,
}
}, {
sequelize,
modelName: 'UndergroundType',
tableName: 'underground',
schema: 'falukant_type',
timestamps: false,
underscored: true,
});
export default UndergroundType;

View File

@@ -96,6 +96,8 @@ import Vote from './falukant/data/vote.js';
import ElectionResult from './falukant/data/election_result.js';
import PoliticalOfficeHistory from './falukant/log/political_office_history.js';
import ElectionHistory from './falukant/log/election_history.js';
import UndergroundType from './falukant/type/underground.js';
import Underground from './falukant/data/underground.js';
const models = {
SettingsType,
@@ -182,8 +184,6 @@ const models = {
Credit,
DebtorsPrism,
HealthActivity,
// Politics
PoliticalOfficeType,
PoliticalOfficeRequirement,
PoliticalOfficeBenefitType,
@@ -195,6 +195,8 @@ const models = {
ElectionResult,
PoliticalOfficeHistory,
ElectionHistory,
UndergroundType,
Underground,
};
export default models;