Implement job hierarchy and region depth calculations in FalukantService; enhance PoliticsView with own position highlighting
- Added a job hierarchy mapping to determine positions based on their rank. - Introduced asynchronous region depth calculations to determine the hierarchy of regions. - Updated the mapping of office data to include job hierarchy levels and region depths. - Enhanced the PoliticsView to highlight the user's own positions with a distinct style. - Implemented a method to load the user's character ID for position comparison.
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="pos in currentPositions" :key="pos.id">
|
||||
<tr v-for="pos in currentPositions" :key="pos.id" :class="{ 'own-position': isOwnPosition(pos) }">
|
||||
<td>{{ $t(`falukant.politics.offices.${pos.officeType.name}`) }}</td>
|
||||
<td>{{ pos.region.name }}</td>
|
||||
<td>
|
||||
@@ -193,6 +193,7 @@ export default {
|
||||
elections: [],
|
||||
selectedCandidates: {},
|
||||
selectedApplications: [],
|
||||
ownCharacterId: null,
|
||||
loading: {
|
||||
current: false,
|
||||
openPolitics: false,
|
||||
@@ -209,7 +210,8 @@ export default {
|
||||
return this.elections.some(e => !e.voted);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
async mounted() {
|
||||
await this.loadOwnCharacterId();
|
||||
this.loadCurrentPositions();
|
||||
},
|
||||
methods: {
|
||||
@@ -330,6 +332,24 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
async loadOwnCharacterId() {
|
||||
try {
|
||||
const { data } = await apiClient.get('/api/falukant/info');
|
||||
if (data.character && data.character.id) {
|
||||
this.ownCharacterId = data.character.id;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error loading own character ID', err);
|
||||
}
|
||||
},
|
||||
|
||||
isOwnPosition(pos) {
|
||||
if (!this.ownCharacterId || !pos.character) {
|
||||
return false;
|
||||
}
|
||||
return pos.character.id === this.ownCharacterId;
|
||||
},
|
||||
|
||||
async submitApplications() {
|
||||
try {
|
||||
const response = await apiClient.post(
|
||||
@@ -411,6 +431,11 @@ h2 {
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.politics-table tbody tr.own-position {
|
||||
background-color: #e0e0e0;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
font-style: italic;
|
||||
|
||||
Reference in New Issue
Block a user