From 842ed055211d3d2519a522688b27040ed693e3b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sat, 20 Aug 2022 22:30:46 +0100 Subject: [PATCH] CustomCategory: buttons 'Apply & keep editing', 'Apply & close' --- lang/en.json | 3 ++- src/customCategory.js | 25 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lang/en.json b/lang/en.json index 48726d38..5012e210 100644 --- a/lang/en.json +++ b/lang/en.json @@ -10,7 +10,8 @@ "closed": "closed", "default": "default", "download": "Download", - "apply": "Apply", + "apply-keep": "Apply & keep editing", + "apply-close": "Apply & close", "tip-tutorial": "Check out the [Tutorial]", "customCategory:header": "Custom categories", "customCategory:clone": "Clone as custom category", diff --git a/src/customCategory.js b/src/customCategory.js index 8c99699c..d6bb6f43 100644 --- a/src/customCategory.js +++ b/src/customCategory.js @@ -114,13 +114,16 @@ class CustomCategoryEditor { const input = document.createElement('input') input.type = 'submit' - input.value = lang('apply') + input.value = lang('apply-keep') controls.appendChild(input) const inputClose = document.createElement('input') inputClose.type = 'button' - inputClose.value = lang('close') - inputClose.onclick = () => this.window.close() + inputClose.value = lang('apply-close') + inputClose.onclick = () => { + this.submit() + this.window.close() + } controls.appendChild(inputClose) const icons = document.createElement('div') @@ -143,18 +146,22 @@ class CustomCategoryEditor { controls.appendChild(tutorial) input.onclick = (e) => { - const err = customCategoryTest(this.textarea.value) - if (err) { - return global.alert(err) - } - - this.applyContent(this.textarea.value) + this.submit() e.preventDefault() } this.window.show() } + submit () { + const err = customCategoryTest(this.textarea.value) + if (err) { + return global.alert(err) + } + + this.applyContent(this.textarea.value) + } + applyContent (content) { this.content = content this.repository.saveCategory(this.content, {}, () => {})