Setting to show only available items. On by default.

This commit is contained in:
Mario Zechner 2023-06-21 21:39:33 +02:00
parent 97b4b25933
commit c8a1e41abb
3 changed files with 13 additions and 7 deletions

View File

@ -10,6 +10,7 @@ class Settings extends Model {
STORE_KEYS.forEach((store) => {
this[store] = stores[store].defaultChecked;
});
this.onlyAvailable = true;
let settings = localStorage.getItem("settings");
if (settings) {

View File

@ -21,22 +21,23 @@ class SettingsView extends View {
></custom-checkbox>`
).join("")}
</div>
<label
>Start-Datum für Diagramme
<div class="flex flex-row gap-2">
Start-Datum für Diagramme
<input
x-id="startDate"
x-change
x-state
type="date"
class="cursor-pointer inline-flex items-center gap-x-1 rounded-full bg-white border border-gray-400 px-2 py-1 text-xs font-medium text-gray-600"
/></label>
<label>
class="flex-grow cursor-pointer inline-flex items-center gap-x-1 rounded-full bg-white border border-gray-400 px-2 py-1 text-xs font-medium text-gray-600">
</div>
<div class="flex flex-row gap-2">
Diagramm Typ
<select x-id="chartType" x-change x-state>
<select x-id="chartType" x-change x-state class="flex-grow">
<option value="stepped">Stufen</option>
<option value="lines">Linien</option>
</select>
</label>
</div>
<custom-checkbox x-id="onlyAvailable" x-state x-change label="Nur verfügbare Produkte anzeigen" checked></custom-checkbox>
</div>
`;
this.setupEventHandlers();

View File

@ -180,6 +180,10 @@ class ItemsFilter extends View {
return;
}
if (settings.onlyAvailable) {
filteredItems = filteredItems.filter((item) => !item.unavailable);
}
this.model.lastDate = null;
if (this._filterByPriceChanges) {
if (elements.priceChangesToday.checked) {