Enhance NPC creation functionality and validation in Admin module
- Updated AdminController to validate the count parameter, ensuring it is between 1 and 500. - Refactored NPC creation logic in AdminService to create NPCs for each city-title combination, improving efficiency. - Enhanced frontend localization files to reflect changes in count descriptions and validation messages. - Updated CreateNPCView to provide user guidance on count input and display detailed creation results.
This commit is contained in:
@@ -47,7 +47,8 @@
|
||||
|
||||
<div class="form-group">
|
||||
<label>{{ $t('admin.falukant.createNPC.count') }}:</label>
|
||||
<input type="number" v-model.number="count" min="1" max="100" class="form-input" />
|
||||
<input type="number" v-model.number="count" min="1" max="500" class="form-input" />
|
||||
<div class="help-text">{{ $t('admin.falukant.createNPC.countHelp') }}</div>
|
||||
</div>
|
||||
|
||||
<div class="action-buttons">
|
||||
@@ -61,6 +62,13 @@
|
||||
<div v-if="result" class="result-section">
|
||||
<h2>{{ $t('admin.falukant.createNPC.result') }}</h2>
|
||||
<p>{{ $t('admin.falukant.createNPC.createdCount', { count: result.count }) }}</p>
|
||||
<p v-if="result.totalCombinations" class="info-text">
|
||||
{{ $t('admin.falukant.createNPC.combinationInfo', {
|
||||
perCombination: result.countPerCombination,
|
||||
combinations: result.totalCombinations,
|
||||
total: result.count
|
||||
}) }}
|
||||
</p>
|
||||
<div v-if="result.npcs && result.npcs.length > 0" class="npcs-list">
|
||||
<div v-for="npc in result.npcs" :key="npc.id" class="npc-item">
|
||||
{{ $t(`falukant.titles.${npc.gender}.${npc.title}`) }} {{ npc.firstName }} {{ npc.lastName }}
|
||||
@@ -142,7 +150,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.count < 1 || this.count > 100) {
|
||||
if (this.count < 1 || this.count > 500) {
|
||||
this.error = this.$t('admin.falukant.createNPC.invalidCount');
|
||||
return;
|
||||
}
|
||||
@@ -286,4 +294,17 @@ export default {
|
||||
border-radius: 4px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.help-text {
|
||||
font-size: 0.9em;
|
||||
color: #666;
|
||||
margin-top: 5px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.info-text {
|
||||
font-size: 0.9em;
|
||||
color: #155724;
|
||||
margin-top: 5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user