Skip to content

Commit 3d90a54

Browse files
committed
Remove Save button for period setting
1 parent 311cd5a commit 3d90a54

File tree

5 files changed

+17
-34
lines changed

5 files changed

+17
-34
lines changed

feature-locales/explore-filter/en.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"author": "Author",
55
"period": "Period",
66
"reset": "Reset",
7-
"save": "Save",
87
"sharedDate": "Shared Date",
98
"updateDate": "Update Date",
109
"startDate": "Start date",

feature-locales/explore-filter/es.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"author": "Autor",
55
"period": "Período",
66
"reset": "Restablecer",
7-
"save": "Guardar",
87
"sharedDate": "Fecha compartida",
98
"updateDate": "Fecha de actualización",
109
"startDate": "Fecha de inicio",

feature-locales/explore-filter/ja.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"author": "作者",
55
"period": "期間",
66
"reset": "リセット",
7-
"save": "保存",
87
"sharedDate": "共有日",
98
"updateDate": "更新日",
109
"startDate": "開始日",

feature-locales/explore-filter/tr.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"author": "Yazar",
55
"period": "Dönem",
66
"reset": "Sıfırla",
7-
"save": "Kaydet",
87
"sharedDate": "Paylaşım Tarihi",
98
"updateDate": "Güncelleme Tarihi",
109
"startDate": "Başlangıç tarihi",

features/explore-filter/script.js

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,24 @@ export default async function ({ feature, console }) {
287287
input.type = "date";
288288
input.style.margin = "0 10px";
289289
if (filterData.period[id]) input.value = filterData.period[id];
290-
const button = document.createElement("button");
291-
button.textContent = feature.msg("reset");
292-
button.addEventListener("click", function () {
290+
input.addEventListener("change", function () {
291+
if (input.value) {
292+
filterData["period"][id] = input.value;
293+
button.classList.add('active');
294+
}
295+
else if (filterData.period[id]) delete filterData.period[id];
296+
filter()
297+
});
298+
const resetButton = document.createElement("button");
299+
resetButton.textContent = feature.msg("reset");
300+
resetButton.addEventListener("click", function () {
293301
input.value = ''
302+
if (filterData.period[id]) delete filterData.period[id];
303+
filter()
304+
if (Object.keys(filterData["period"]).length == 0) { if (button.classList.contains('active')) button.classList.remove('active') }
294305
});
295306
content.appendChild(input);
296-
content.appendChild(button);
307+
content.appendChild(resetButton);
297308
return content;
298309
}
299310

@@ -310,11 +321,7 @@ export default async function ({ feature, console }) {
310321
updateDetails.appendChild(updateStart);
311322
updateDetails.appendChild(updateEnd);
312323

313-
const saveButton = document.createElement("button");
314-
saveButton.textContent = feature.msg("save");
315-
saveButton.style.marginRight = "100%";
316-
317-
let modal = ScratchTools.modals.create({
324+
ScratchTools.modals.create({
318325
title: `${feature.msg("period")}`,
319326
components: [
320327
{
@@ -324,29 +331,9 @@ export default async function ({ feature, console }) {
324331
{
325332
type: "html",
326333
content: updateDetails,
327-
},
328-
{
329-
type: "html",
330-
content: saveButton,
331334
}
332335
]
333336
});
334-
saveButton.addEventListener("click", function () {
335-
function checkInput(id, element) {
336-
const input = element.querySelector("input");
337-
if (input.value) filterData["period"][id] = input.value;
338-
else if (filterData.period[id]) delete filterData.period[id];
339-
}
340-
checkInput("shareStart", shareStart);
341-
checkInput("shareEnd", shareEnd);
342-
checkInput("updateStart", updateStart);
343-
checkInput("updateEnd", updateEnd);
344-
modal.close();
345-
346-
filter()
347-
if (Object.keys(filterData[id]).length == 0) { if (button.classList.contains('active')) button.classList.remove('active') }
348-
else button.classList.add('active');
349-
})
350337
break;
351338
}
352339

@@ -361,7 +348,7 @@ export default async function ({ feature, console }) {
361348
else filterButton.classList.add('active');
362349
const filterSettings = document.createElement("div");
363350
filterSettings.classList.add('ste-filter-settings');
364-
options.map((option) => {
351+
options.forEach(option => {
365352
const icon = document.createElement("img");
366353
icon.src = feature.self.getResource(option.icon);
367354

0 commit comments

Comments
 (0)