Files
Assetmanager/app/templates/assets_bulk_edit.html
T
RolandandClaude Opus 5.5 40cd88871f Version 0.5.5.94: field type conversion, exclusion filters and value lists
- Change the data type of custom fields with stored values via a preview:
  values that cannot be converted need an explicit decision, the
  conversion runs in one transaction with row locks and a stale-preview
  check, old values are saved to data/backups and recorded in history.
- Table filters: "!value" excludes rows, "=value" compares exactly;
  Excel-like value list (▾) per column in all tables. The software job
  list computes its value list on the server over the full job history.
- Bulk edit offers custom fields with type-specific input and validation.
- MeshCentral mappings: optional "value if empty" with a guard path;
  fallbacks are skipped when only basic data was delivered.
- Deleting a field removes its translations (same name can be reused);
  one confirmation with the value count replaces the checkbox.
- Job list filters recognize the "reinstall" action and the
  "software deployment" job type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 21:14:21 +01:00

73 lines
4.7 KiB
HTML
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends 'base.html' %}
{% block content %}
<div class="toolbar"><div><h1>{{ t('assets.bulk_edit.title') }}</h1><p class="muted">{{ t('assets.bulk_edit.applies_to', count=assets|length) }}</p></div><a class="button button-secondary" href="/assets{% if category_id %}?category_id={{ category_id }}{% endif %}">{{ t('common.cancel') }}</a></div>
<section class="panel bulk-edit-panel">
<form method="post" action="/assets/bulk-edit/apply" id="bulk-edit-apply-form">
{% for id in asset_ids %}<input type="hidden" name="asset_ids" value="{{ id }}">{% endfor %}
{% if category_id %}<input type="hidden" name="category_id" value="{{ category_id }}">{% endif %}
<div class="form-grid">
<label>{{ t('common.field') }}
<select name="field_name" id="bulk-field" required>
<option value="">{{ t('common.please_select') }}</option>
{% for field in fields %}<option value="{{ field.field_name }}" data-type="{{ field.data_type or '' }}" data-custom="{{ '1' if field.custom else '0' }}">{{ field.label }}</option>{% endfor %}
</select>
</label>
<label>{{ t('history.new_value') }}
<input name="new_value" id="bulk-value" autocomplete="off">
<select id="bulk-status-value" class="hidden-control">
<option value="">{{ t('assets.bulk_edit.empty_value') }}</option>
{% for status in status_options %}<option value="{{ status.name }}">{{ status.name }}</option>{% endfor %}
</select>
<select id="bulk-parent-value" class="hidden-control">
<option value="">{{ t('assets.bulk_edit.no_parent') }}</option>
{% for parent in parent_candidates %}<option value="{{ parent.id }}">{{ parent.name }}{% if parent.asset_tag %} – {{ parent.asset_tag }}{% endif %} ({{ parent.category.name }})</option>{% endfor %}
</select>
<select id="bulk-boolean-value" class="hidden-control">
<option value="">{{ t('assets.bulk_edit.empty_value') }}</option>
<option value="true">{{ t('common.yes') }}</option>
<option value="false">{{ t('common.no') }}</option>
</select>
<select id="bulk-category-value" class="hidden-control">
<option value="">{{ t('assets.bulk_edit.select_category') }}</option>
{% for category in categories %}<option value="{{ category.id }}">{{ category.name }}</option>{% endfor %}
</select>
</label>
</div>
<p class="muted">{{ t('assets.bulk_edit.help') }}</p>
<details><summary>{{ t('assets.bulk_edit.show_selected') }}</summary><ul class="compact-list">{% for asset in assets %}<li>{{ asset.name }} <span class="muted">({{ asset.category.name }})</span></li>{% endfor %}</ul></details>
<div class="form-actions"><a class="button button-secondary" href="/assets{% if category_id %}?category_id={{ category_id }}{% endif %}">{{ t('common.cancel') }}</a><button type="submit">💾 {{ t('assets.bulk_edit.save_for', count=assets|length) }}</button></div>
</form>
</section>
<script>
(() => {
const field = document.getElementById('bulk-field');
const input = document.getElementById('bulk-value');
const status = document.getElementById('bulk-status-value');
const parent = document.getElementById('bulk-parent-value');
const category = document.getElementById('bulk-category-value');
const bool = document.getElementById('bulk-boolean-value');
const controls = [input, status, parent, category, bool];
field.addEventListener('change', () => {
const selected = field.value;
const option = field.selectedOptions[0];
const isCustom = option && option.dataset.custom === '1';
const dataType = option ? option.dataset.type : '';
const active = selected === 'status' ? status : selected === 'parent_asset_id' ? parent : selected === 'category_id' ? category : (isCustom && dataType === 'boolean') ? bool : input;
controls.forEach(control => {
control.classList.toggle('hidden-control', control !== active);
if (control === active) control.name = 'new_value'; else control.removeAttribute('name');
});
const dateFields = ['assigned_on','purchase_date','warranty_until'];
input.removeAttribute('step');
if (dateFields.includes(selected) || (isCustom && dataType === 'date')) input.type = 'date';
else if (isCustom && dataType === 'datetime') input.type = 'datetime-local';
else if (isCustom && dataType === 'integer') { input.type = 'number'; input.step = '1'; }
else if (isCustom && dataType === 'decimal') { input.type = 'number'; input.step = 'any'; }
else if (isCustom && dataType === 'email') input.type = 'email';
else if (isCustom && dataType === 'url') input.type = 'url';
else input.type = 'text';
});
})();
</script>
{% endblock %}