u
This commit is contained in:
@@ -69,6 +69,7 @@ const initialState = {
|
||||
filter: '',
|
||||
onlyUnpaid: false,
|
||||
onlyUndelivered: false,
|
||||
entityId: null,
|
||||
seekMonths: 0,
|
||||
seekYears: 0,
|
||||
negativeSeekMonths: 0,
|
||||
@@ -117,25 +118,27 @@ export function getFilterParams(state = automat?.state || initialState) {
|
||||
const filter = String(state.filter ?? '').trim();
|
||||
const onlyUnpaid = Boolean(state.onlyUnpaid);
|
||||
const onlyUndelivered = Boolean(state.onlyUndelivered);
|
||||
const entityId = state.entityId != null && state.entityId !== '' ? Number(state.entityId) : null;
|
||||
const negativeSeekMonths = (state.negativeSeekMonths != null && Number(state.negativeSeekMonths) < 0)
|
||||
? Number(state.negativeSeekMonths)
|
||||
: 0;
|
||||
return { filter, onlyUnpaid, onlyUndelivered, negativeSeekMonths };
|
||||
return { filter, onlyUnpaid, onlyUndelivered, entityId, negativeSeekMonths };
|
||||
}
|
||||
|
||||
export function getFilterKey(state = automat?.state || initialState) {
|
||||
const { filter, onlyUnpaid, onlyUndelivered, negativeSeekMonths } = getFilterParams(state);
|
||||
return JSON.stringify({ f: filter, u: onlyUnpaid, d: onlyUndelivered, s: negativeSeekMonths });
|
||||
const { filter, onlyUnpaid, onlyUndelivered, entityId, negativeSeekMonths } = getFilterParams(state);
|
||||
return JSON.stringify({ f: filter, u: onlyUnpaid, d: onlyUndelivered, e: entityId, s: negativeSeekMonths });
|
||||
}
|
||||
|
||||
export function formatFilterLabel(filterKeyOrState) {
|
||||
let f, u, d, s;
|
||||
let f, u, d, e, s;
|
||||
if (typeof filterKeyOrState === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(filterKeyOrState);
|
||||
f = parsed.f;
|
||||
u = parsed.u;
|
||||
d = parsed.d;
|
||||
e = parsed.e;
|
||||
s = parsed.s;
|
||||
} catch {
|
||||
return filterKeyOrState;
|
||||
@@ -145,18 +148,21 @@ export function formatFilterLabel(filterKeyOrState) {
|
||||
f = filterKeyOrState.f;
|
||||
u = filterKeyOrState.u;
|
||||
d = filterKeyOrState.d;
|
||||
e = filterKeyOrState.e;
|
||||
s = filterKeyOrState.s;
|
||||
} else {
|
||||
const params = getFilterParams(filterKeyOrState);
|
||||
f = params.filter;
|
||||
u = params.onlyUnpaid;
|
||||
d = params.onlyUndelivered;
|
||||
e = params.entityId;
|
||||
s = params.negativeSeekMonths;
|
||||
}
|
||||
}
|
||||
|
||||
const parts = [];
|
||||
if (f) parts.push(`Suche: „${f}“`);
|
||||
if (e != null) parts.push(`Kunde: #${e}`);
|
||||
if (u) parts.push('Nur unbezahlt');
|
||||
if (d) parts.push('Nur ungeliefert');
|
||||
if (s < 0) parts.push(`Seek: ${formatNegativeSeek(s)}`);
|
||||
@@ -498,6 +504,7 @@ function buildQueryParamsFor(filterParams, offset = 0, limit = CHUNK_SIZE) {
|
||||
if (trimmed) params.search = trimmed;
|
||||
if (filterParams.onlyUnpaid) params.onlyUnpaid = true;
|
||||
if (filterParams.onlyUndelivered) params.onlyUndelivered = true;
|
||||
if (filterParams.entityId != null) params.entityId = filterParams.entityId;
|
||||
if (filterParams.negativeSeekMonths != null && Number(filterParams.negativeSeekMonths) < 0) {
|
||||
params.seekMonths = Number(filterParams.negativeSeekMonths);
|
||||
}
|
||||
@@ -859,6 +866,12 @@ const actions = {
|
||||
onFilterChange(true);
|
||||
},
|
||||
|
||||
setEntityId(entityId) {
|
||||
const parsed = entityId != null && entityId !== '' ? Number(entityId) : null;
|
||||
automat.setState({ entityId: parsed });
|
||||
onFilterChange(true);
|
||||
},
|
||||
|
||||
addSeekMonth() {
|
||||
const seekMonths = (automat.state.seekMonths ?? 0) + 1;
|
||||
const seekYears = automat.state.seekYears ?? 0;
|
||||
|
||||
@@ -70,6 +70,7 @@ const initialState = {
|
||||
total: 0,
|
||||
unfilteredTotal: 0,
|
||||
filter: '',
|
||||
entityId: null,
|
||||
seekMonths: 0,
|
||||
seekYears: 0,
|
||||
negativeSeekMonths: 0,
|
||||
@@ -112,23 +113,25 @@ export function parseLruKey(key) {
|
||||
// MARK: pure filter helpers
|
||||
export function getFilterParams(state = automat?.state || initialState) {
|
||||
const filter = String(state.filter ?? '').trim();
|
||||
const entityId = state.entityId != null && state.entityId !== '' ? Number(state.entityId) : null;
|
||||
const negativeSeekMonths = (state.negativeSeekMonths != null && Number(state.negativeSeekMonths) < 0)
|
||||
? Number(state.negativeSeekMonths)
|
||||
: 0;
|
||||
return { filter, negativeSeekMonths };
|
||||
return { filter, entityId, negativeSeekMonths };
|
||||
}
|
||||
|
||||
export function getFilterKey(state = automat?.state || initialState) {
|
||||
const { filter, negativeSeekMonths } = getFilterParams(state);
|
||||
return JSON.stringify({ f: filter, s: negativeSeekMonths });
|
||||
const { filter, entityId, negativeSeekMonths } = getFilterParams(state);
|
||||
return JSON.stringify({ f: filter, e: entityId, s: negativeSeekMonths });
|
||||
}
|
||||
|
||||
export function formatFilterLabel(filterKeyOrState) {
|
||||
let f, s;
|
||||
let f, e, s;
|
||||
if (typeof filterKeyOrState === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(filterKeyOrState);
|
||||
f = parsed.f;
|
||||
e = parsed.e;
|
||||
s = parsed.s;
|
||||
} catch {
|
||||
return filterKeyOrState;
|
||||
@@ -136,16 +139,19 @@ export function formatFilterLabel(filterKeyOrState) {
|
||||
} else if (filterKeyOrState && typeof filterKeyOrState === 'object') {
|
||||
if ('f' in filterKeyOrState) {
|
||||
f = filterKeyOrState.f;
|
||||
e = filterKeyOrState.e;
|
||||
s = filterKeyOrState.s;
|
||||
} else {
|
||||
const params = getFilterParams(filterKeyOrState);
|
||||
f = params.filter;
|
||||
e = params.entityId;
|
||||
s = params.negativeSeekMonths;
|
||||
}
|
||||
}
|
||||
|
||||
const parts = [];
|
||||
if (f) parts.push(`Suche: „${f}“`);
|
||||
if (e != null) parts.push(`Kunde: #${e}`);
|
||||
if (s < 0) parts.push(`Seek: ${formatNegativeSeek(s)}`);
|
||||
if (parts.length === 0) return 'Standard (Alle Angebote)';
|
||||
return parts.join(' · ');
|
||||
@@ -439,6 +445,7 @@ function buildQueryParamsFor(filterParams, offset = 0, limit = CHUNK_SIZE) {
|
||||
const params = { offset, limit };
|
||||
const trimmed = String(filterParams.filter ?? '').trim();
|
||||
if (trimmed) params.search = trimmed;
|
||||
if (filterParams.entityId != null) params.entityId = filterParams.entityId;
|
||||
if (filterParams.negativeSeekMonths != null && Number(filterParams.negativeSeekMonths) < 0) {
|
||||
params.seekMonths = Number(filterParams.negativeSeekMonths);
|
||||
}
|
||||
@@ -777,6 +784,12 @@ const actions = {
|
||||
onFilterChange(false);
|
||||
},
|
||||
|
||||
setEntityId(entityId) {
|
||||
const parsed = entityId != null && entityId !== '' ? Number(entityId) : null;
|
||||
automat.setState({ entityId: parsed });
|
||||
onFilterChange(true);
|
||||
},
|
||||
|
||||
addSeekMonth() {
|
||||
const seekMonths = (automat.state.seekMonths ?? 0) + 1;
|
||||
const seekYears = automat.state.seekYears ?? 0;
|
||||
|
||||
@@ -64,6 +64,7 @@ const initialState = {
|
||||
unfilteredTotal: 0,
|
||||
filter: '',
|
||||
stateFilter: '',
|
||||
entityId: null,
|
||||
seekMonths: 0,
|
||||
seekYears: 0,
|
||||
negativeSeekMonths: 0,
|
||||
@@ -107,15 +108,16 @@ export function parseLruKey(key) {
|
||||
export function getFilterParams(state = automat?.state || initialState) {
|
||||
const filter = String(state.filter ?? '').trim();
|
||||
const stateFilter = String(state.stateFilter ?? '').trim();
|
||||
const entityId = state.entityId != null && state.entityId !== '' ? Number(state.entityId) : null;
|
||||
const negativeSeekMonths = (state.negativeSeekMonths != null && Number(state.negativeSeekMonths) < 0)
|
||||
? Number(state.negativeSeekMonths)
|
||||
: 0;
|
||||
return { filter, stateFilter, negativeSeekMonths };
|
||||
return { filter, stateFilter, entityId, negativeSeekMonths };
|
||||
}
|
||||
|
||||
export function getFilterKey(state = automat?.state || initialState) {
|
||||
const { filter, stateFilter, negativeSeekMonths } = getFilterParams(state);
|
||||
return JSON.stringify({ f: filter, st: stateFilter, s: negativeSeekMonths });
|
||||
const { filter, stateFilter, entityId, negativeSeekMonths } = getFilterParams(state);
|
||||
return JSON.stringify({ f: filter, st: stateFilter, e: entityId, s: negativeSeekMonths });
|
||||
}
|
||||
|
||||
export function formatNegativeSeek(months) {
|
||||
@@ -134,12 +136,13 @@ export function formatNegativeSeek(months) {
|
||||
}
|
||||
|
||||
export function formatFilterLabel(filterKeyOrState) {
|
||||
let f, st, s;
|
||||
let f, st, e, s;
|
||||
if (typeof filterKeyOrState === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(filterKeyOrState);
|
||||
f = parsed.f;
|
||||
st = parsed.st;
|
||||
e = parsed.e;
|
||||
s = parsed.s;
|
||||
} catch {
|
||||
return filterKeyOrState;
|
||||
@@ -148,17 +151,20 @@ export function formatFilterLabel(filterKeyOrState) {
|
||||
if ('f' in filterKeyOrState) {
|
||||
f = filterKeyOrState.f;
|
||||
st = filterKeyOrState.st;
|
||||
e = filterKeyOrState.e;
|
||||
s = filterKeyOrState.s;
|
||||
} else {
|
||||
const params = getFilterParams(filterKeyOrState);
|
||||
f = params.filter;
|
||||
st = params.stateFilter;
|
||||
e = params.entityId;
|
||||
s = params.negativeSeekMonths;
|
||||
}
|
||||
}
|
||||
|
||||
const parts = [];
|
||||
if (f) parts.push(`Suche: „${f}“`);
|
||||
if (e != null) parts.push(`Kunde: #${e}`);
|
||||
if (st) parts.push(`Status: ${st}`);
|
||||
if (s < 0) parts.push(`Seek: ${formatNegativeSeek(s)}`);
|
||||
if (parts.length === 0) return 'Standard (Alle Lieferscheine)';
|
||||
@@ -436,6 +442,7 @@ function buildQueryParamsFor(filterParams, offset = 0, limit = CHUNK_SIZE) {
|
||||
const trimmed = String(filterParams.filter ?? '').trim();
|
||||
if (trimmed) params.search = trimmed;
|
||||
if (filterParams.stateFilter) params.state = filterParams.stateFilter;
|
||||
if (filterParams.entityId != null) params.entityId = filterParams.entityId;
|
||||
if (filterParams.negativeSeekMonths != null && Number(filterParams.negativeSeekMonths) < 0) {
|
||||
params.seekMonths = Number(filterParams.negativeSeekMonths);
|
||||
}
|
||||
@@ -784,6 +791,12 @@ const actions = {
|
||||
onFilterChange(true);
|
||||
},
|
||||
|
||||
setEntityId(entityId) {
|
||||
const parsed = entityId != null && entityId !== '' ? Number(entityId) : null;
|
||||
automat.setState({ entityId: parsed });
|
||||
onFilterChange(true);
|
||||
},
|
||||
|
||||
setSeekMonths(months) {
|
||||
actions.addNegativeSeek(-months);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user