Bladeren bron

Added "Delate all displayed rules" button

Gildas 7 jaren geleden
bovenliggende
commit
75f1edc087

+ 8 - 0
_locales/en/messages.json

@@ -223,6 +223,14 @@
         "message": "Auto-settings rules",
         "description": "Options sub-title: 'Auto-settings rules'"
     },
+    "optionsDeleteDisplayedRulesConfirm": {
+        "message": "Confirm deletion of all displayed rules",
+        "description": "Popup text 'Confirm deletion of all displayed rules'"
+    },
+    "optionsDeleteRulesTooltip": {
+        "message": "Delete all displayed rules",
+        "description": "Popup text 'Delete all displayed rules'"
+    },
     "optionsAutoSettingsUrl": {
         "message": "URL",
         "description": "Options label in the Auto-settings rules: 'URL'"

+ 8 - 0
_locales/fr/messages.json

@@ -223,6 +223,14 @@
         "message": "Règles d'auto-configuration",
         "description": "Options sub-title: 'Auto-settings rules'"
     },
+    "optionsDeleteDisplayedRulesConfirm": {
+        "message": "Confirmez la suppression de toutes les règles affichées",
+        "description": "Popup text 'Confirm deletion of all displayed rules'"
+    },
+    "optionsDeleteRulesTooltip": {
+        "message": "Supprimer toutes les règles affichées",
+        "description": "Popup text 'Delete all displayed rules'"
+    },
     "optionsAutoSettingsUrl": {
         "message": "URL",
         "description": "Options label in the auto-settings rules: 'URL'"

+ 8 - 0
_locales/ja/messages.json

@@ -223,6 +223,14 @@
         "message": "自動設定のルール",
         "description": "Options sub-title: 'Auto-settings rules'"
     },
+    "optionsDeleteDisplayedRulesConfirm": {
+        "message": "Confirm deletion of all displayed rules",
+        "description": "Popup text 'Confirm deletion of all displayed rules'"
+    },
+    "optionsDeleteRulesTooltip": {
+        "message": "Delete all displayed rules",
+        "description": "Popup text 'Delete all displayed rules'"
+    },
     "optionsAutoSettingsUrl": {
         "message": "URL",
         "description": "Options label in the auto-settings rules: 'URL'"

+ 8 - 0
_locales/pl/messages.json

@@ -223,6 +223,14 @@
         "message": "Reguły automatycznej konfiguracji",
         "description": "Options sub-title: 'Auto-settings rules'"
     },
+    "optionsDeleteDisplayedRulesConfirm": {
+        "message": "Confirm deletion of all displayed rules",
+        "description": "Popup text 'Confirm deletion of all displayed rules'"
+    },
+    "optionsDeleteRulesTooltip": {
+        "message": "Delete all displayed rules",
+        "description": "Popup text 'Delete all displayed rules'"
+    },
     "optionsAutoSettingsUrl": {
         "message": "Adres URL",
         "description": "Options label in the Auto-settings rules: 'URL'"

+ 9 - 1
_locales/ru/messages.json

@@ -223,6 +223,14 @@
         "message": "Правила автонастройки",
         "description": "Options sub-title: 'Auto-settings rules'"
     },
+    "optionsDeleteDisplayedRulesConfirm": {
+        "message": "Confirm deletion of all displayed rules",
+        "description": "Popup text 'Confirm deletion of all displayed rules'"
+    },
+    "optionsDeleteRulesTooltip": {
+        "message": "Delete all displayed rules",
+        "description": "Popup text 'Delete all displayed rules'"
+    },
     "optionsAutoSettingsUrl": {
         "message": "URL",
         "description": "Options label in the auto-settings rules: 'URL'"
@@ -379,4 +387,4 @@
         "message": "Введите новое имя для выбранного профиля",
         "description": "Popup text 'Enter a new name for the selected profile' in the options page"
     }
-}
+}

+ 8 - 0
_locales/zh_CN/messages.json

@@ -219,6 +219,14 @@
         "message": "自动保存",
         "description": "选项页副标题: '自动保存'"
     },
+    "optionsDeleteDisplayedRulesConfirm": {
+        "message": "Confirm deletion of all displayed rules",
+        "description": "Popup text 'Confirm deletion of all displayed rules'"
+    },
+    "optionsDeleteRulesTooltip": {
+        "message": "Delete all displayed rules",
+        "description": "Popup text 'Delete all displayed rules'"
+    },
     "optionsAutoSettingsSubTitle": {
         "message": "自动设置",
         "description": "Options sub-title: 'Auto-settings rules'"

+ 11 - 0
extension/ui/bg/ui-options.js

@@ -120,6 +120,7 @@
 	const infobarTemplateInput = document.getElementById("infobarTemplateInput");
 	const confirmInfobarInput = document.getElementById("confirmInfobarInput");
 	const expandAllButton = document.getElementById("expandAllButton");
+	const rulesDeleteAllButton = document.getElementById("rulesDeleteAllButton");
 	const ruleUrlInput = document.getElementById("ruleUrlInput");
 	const ruleProfileInput = document.getElementById("ruleProfileInput");
 	const ruleAutoSaveProfileInput = document.getElementById("ruleAutoSaveProfileInput");
@@ -143,6 +144,12 @@
 	ruleAutoSaveProfileInput.onchange = () => {
 		autoSaveProfileChanged = true;
 	};
+	rulesDeleteAllButton.addEventListener("click", async () => {
+		if (confirm(browser.i18n.getMessage("optionsDeleteDisplayedRulesConfirm"))) {
+			await singlefile.config.deleteRules(!showAllProfilesInput.checked && profileNamesInput.value);
+			await refresh();
+		}
+	}, false);
 	createURLElement.onsubmit = async event => {
 		event.preventDefault();
 		try {
@@ -327,6 +334,7 @@
 	autoSettingsAutoSaveProfileLabel.textContent = browser.i18n.getMessage("optionsAutoSettingsAutoSaveProfile");
 	ruleAddButton.title = browser.i18n.getMessage("optionsAddRuleTooltip");
 	ruleEditButton.title = browser.i18n.getMessage("optionsValidateChangesTooltip");
+	rulesDeleteAllButton.title = browser.i18n.getMessage("optionsDeleteRulesTooltip");
 	showAllProfilesLabel.textContent = browser.i18n.getMessage("optionsAutoSettingsShowAllProfiles");
 	showAutoSaveProfileLabel.textContent = browser.i18n.getMessage("optionsAutoSettingsShowAutoSaveProfile");
 	ruleUrlInput.placeholder = ruleEditUrlInput.placeholder = browser.i18n.getMessage("optionsAutoSettingsUrlPlaceholder");
@@ -373,8 +381,10 @@
 		createURLElement.hidden = false;
 		editURLElement.hidden = true;
 		ruleProfileInput.value = ruleAutoSaveProfileInput.value = selectedProfileName;
+		let rulesDisplayed;
 		rules.forEach(rule => {
 			if (showAllProfilesInput.checked || selectedProfileName == rule.profile || selectedProfileName == rule.autoSaveProfile) {
+				rulesDisplayed = true;
 				const ruleElement = rulesElement.querySelector(".rule-view").cloneNode(true);
 				const ruleUrlElement = ruleElement.querySelector(".rule-url");
 				const ruleProfileElement = ruleElement.querySelector(".rule-profile");
@@ -415,6 +425,7 @@
 				}, false);
 			}
 		});
+		rulesDeleteAllButton.disabled = !rulesDisplayed;
 		rulesElement.appendChild(createURLElement);
 		profileNamesInput.value = selectedProfileName;
 		renameProfileButton.disabled = deleteProfileButton.disabled = profileNamesInput.value == singlefile.config.DEFAULT_PROFILE_NAME;

+ 21 - 8
extension/ui/pages/options.css

@@ -131,23 +131,36 @@ h3 {
 }
 
 .profiles button,
-.rules-table button {
+.rules-table-container button {
     padding: 0;
     margin: 0;
     width: 22px;
     text-align: center;
 }
 
+.rules-table-container .thead .tr {
+    min-height: 32px;
+}
+
+.rules-table-container .thead .th:last-of-type {
+    text-align: right;
+    padding-right: 4px;
+}
+
+.rules-table-container .thead .th {
+    min-height: 22px;
+}
+
 .profiles button,
 .profiles select,
-.rules-table button,
-.rules-table select,
-.rules-table input {
+.rules-table-container button,
+.rules-table-container select,
+.rules-table-container input {
     height: 22px;
     vertical-align: top;
 }
 
-.rules-table input {
+.rules-table-container input {
     width: 100%;
     height: 20px;
     margin: 0;
@@ -156,7 +169,7 @@ h3 {
     padding-right: 2px;
 }
 
-.rules-table .rule-create {
+.rules-table-container .rule-create {
     margin-top: 8px;
     margin-bottom: 3px;
 }
@@ -165,7 +178,7 @@ h3 {
     max-width: calc(100% - 78px);
 }
 
-.rules-table select {
+.rules-table-container select {
     max-width: 100%;
 }
 
@@ -175,7 +188,7 @@ h3 {
 }
 
 .profiles button>img,
-.rules-table button>img {
+.rules-table-container button>img {
     width: 14px;
     height: auto;
     vertical-align: middle;

+ 1 - 1
extension/ui/pages/options.html

@@ -182,7 +182,7 @@
 					<span class="th" id="autoSettingsUrlLabel"></span>
 					<span class="th" id="autoSettingsProfileLabel"></span>
 					<span class="th rule-autosave-profile" id="autoSettingsAutoSaveProfileLabel"></span>
-					<span class="th">&nbsp;</span>
+					<span class="th"><button id="rulesDeleteAllButton"><img src="../resources/button_delete_all.png"></button></span>
 				</div>
 			</div>
 			<div class="rules-table">

BIN
extension/ui/resources/button_delete_all.png