fix: simplify resource input format
This commit is contained in:
1 parent
dde7957068
commit
b1b1c6bcf0
1 file changed
+6
-5
+6
-5
@@ -115,9 +115,9 @@
|
||||
<div class="wide identity-tools"><button type="button" id="resolveIdentity">Найти связку имени и ID</button><span class="muted" id="identityStatus"></span></div>
|
||||
<label>Место<select name="place"><option>дупло</option><option>расщелина</option></select></label>
|
||||
<label>Количество осмотров<input name="inspections" type="number" min="0" value="0"></label>
|
||||
<label class="wide">Ресурсы, по одному на строку: название; количество<br>
|
||||
<label class="wide">Ресурсы, по одному на строку: +количество название<br>
|
||||
<div class="quick-actions"><button type="button" id="noResourcesBtn" class="quick-btn">Без ресурсов</button></div>
|
||||
<textarea name="resources" placeholder="вьюнок; 2 паук; 1"></textarea></label>
|
||||
<textarea name="resources" placeholder="+2 вьюнок +1 паук"></textarea></label>
|
||||
</div>
|
||||
|
||||
<label class="wide">Скриншоты отчёта<input id="screenshots" type="file" accept="image/*" multiple><span class="muted">Можно выбрать несколько фотографий. Они будут загружены на img.nyan404.ru.</span></label>
|
||||
@@ -264,7 +264,7 @@
|
||||
if (['mode', 'raw', 'resources'].includes(key)) return;
|
||||
setField(target, key, value);
|
||||
});
|
||||
if (fields.resources) setField(target, 'resources', fields.resources.map(item => `${item[0]}; ${item[1]}`).join('\n'));
|
||||
if (fields.resources) setField(target, 'resources', fields.resources.map(item => `+${item[1]} ${item[0]}`).join('\n'));
|
||||
(fields.extra_kittens || []).forEach(item => addExtraKitten({name: item[0], id: item[1], independence: item[2]}));
|
||||
updateStatusRules();
|
||||
bulkStatus.textContent = data.status === 'complete'
|
||||
@@ -315,8 +315,9 @@
|
||||
['escort_id', 'kitten_id', 'character_id', 'inspections'].forEach(key => { if (data[key] !== undefined && data[key] !== '') data[key] = Number(data[key]); });
|
||||
if (mode === 'inspection') {
|
||||
data.resources = (data.resources || '').split('\n').map(line => line.trim()).filter(Boolean).map(line => {
|
||||
const [name, amount] = line.split(';').map(item => item.trim());
|
||||
return [name, Number(amount)];
|
||||
const match = line.match(/^\+\s*(\d+)\s+(.+)$/);
|
||||
if (!match) throw new Error('Ресурс укажите так: +2 вьюнок.');
|
||||
return [match[2].trim(), Number(match[1])];
|
||||
});
|
||||
}
|
||||
if (mode === 'coaching') {
|
||||
|
||||
Reference in new issue
Block a user