auto-assign filter priority (max+10) on create
New filter rules no longer default to priority 100. Server picks max(priority)+10 per account when client sends priority=None (or 10 if the account has no rules yet), and the UI pre-fills the input with the next value instead of a fixed 100. Avoids ambiguous ordering when multiple rules end up with the same priority. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -29,8 +29,8 @@
|
||||
</label>
|
||||
<div class="grid">
|
||||
<label>
|
||||
Priorität
|
||||
<input type="number" id="filter-priority" value="100">
|
||||
Priorität <small style="opacity:0.7;">(niedriger = früher)</small>
|
||||
<input type="number" id="filter-priority" placeholder="auto">
|
||||
</label>
|
||||
<label>
|
||||
Quellordner
|
||||
@@ -179,6 +179,8 @@ const ACTION_TYPES = [
|
||||
{value: 'mark_read', label: 'Als gelesen markieren', needsParam: false, needsFolder: false},
|
||||
];
|
||||
|
||||
let currentFilters = [];
|
||||
|
||||
async function loadFilters() {
|
||||
const accountId = document.getElementById('account-select').value;
|
||||
const container = document.getElementById('filters-container');
|
||||
@@ -188,6 +190,7 @@ async function loadFilters() {
|
||||
}
|
||||
const resp = await fetch(`/api/filters/account/${accountId}`);
|
||||
const filters = await resp.json();
|
||||
currentFilters = filters;
|
||||
if (filters.length === 0) {
|
||||
container.innerHTML = `
|
||||
<p>Keine Filterregeln für dieses Konto.</p>
|
||||
@@ -369,7 +372,8 @@ function openNewFilter() {
|
||||
document.getElementById('dialog-title').textContent = 'Neue Filterregel';
|
||||
document.getElementById('filter-id').value = '';
|
||||
document.getElementById('filter-name').value = '';
|
||||
document.getElementById('filter-priority').value = '100';
|
||||
const maxPrio = currentFilters.reduce((m, f) => Math.max(m, f.priority), -Infinity);
|
||||
document.getElementById('filter-priority').value = isFinite(maxPrio) ? (maxPrio + 10) : 10;
|
||||
document.getElementById('filter-source-folder').value = 'INBOX';
|
||||
document.getElementById('filter-stop-processing').checked = false;
|
||||
document.getElementById('conditions-list').innerHTML = '';
|
||||
@@ -432,10 +436,12 @@ function collectFormData() {
|
||||
parameter: input ? (input.value || null) : null,
|
||||
});
|
||||
}
|
||||
const prioRaw = document.getElementById('filter-priority').value.trim();
|
||||
const prio = prioRaw === '' ? null : parseInt(prioRaw);
|
||||
return {
|
||||
account_id: parseInt(accountId),
|
||||
name: document.getElementById('filter-name').value,
|
||||
priority: parseInt(document.getElementById('filter-priority').value),
|
||||
priority: prio,
|
||||
source_folder: document.getElementById('filter-source-folder').value,
|
||||
stop_processing: document.getElementById('filter-stop-processing').checked,
|
||||
enabled: true,
|
||||
|
||||
Reference in New Issue
Block a user