From 810afdaf5a429468d31b09ae5a7f995dd11568f8 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 21 Feb 2021 12:28:25 +0300 Subject: prevent creation of filter rules matching no feeds --- js/form/ValidationMultiSelect.js | 20 ++++++++++++++++++++ js/prefs.js | 1 + js/tt-rss.js | 1 + 3 files changed, 22 insertions(+) create mode 100644 js/form/ValidationMultiSelect.js (limited to 'js') diff --git a/js/form/ValidationMultiSelect.js b/js/form/ValidationMultiSelect.js new file mode 100644 index 000000000..4e7263c61 --- /dev/null +++ b/js/form/ValidationMultiSelect.js @@ -0,0 +1,20 @@ +/* global define */ + +// only supports required for the time being +// TODO: maybe show dojo native error message? i dunno +define(["dojo/_base/declare", "dojo/_base/lang", "dijit/form/MultiSelect", ], + function(declare, lang, MultiSelect) { + + return declare('fox.form.ValidationMultiSelect', [MultiSelect], { + constructor: function(params){ + this.constraints = {}; + this.baseClass += ' dijitValidationMultiSelect'; + }, + validate: function(/*Boolean*/ isFocused){ + if (this.required && this.attr('value').length == 0) + return false; + + return true; + }, + }) + }); diff --git a/js/prefs.js b/js/prefs.js index a23a74856..8f4f45700 100755 --- a/js/prefs.js +++ b/js/prefs.js @@ -53,6 +53,7 @@ require(["dojo/_base/kernel", "fox/PrefLabelTree", "fox/Toolbar", "fox/SingleUseDialog", + "fox/form/ValidationMultiSelect", "fox/form/ValidationTextArea", "fox/form/Select", "fox/form/ComboButton", diff --git a/js/tt-rss.js b/js/tt-rss.js index 8d7dd00a6..4a7f2e643 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -51,6 +51,7 @@ require(["dojo/_base/kernel", "fox/FeedTree", "fox/Toolbar", "fox/SingleUseDialog", + "fox/form/ValidationMultiSelect", "fox/form/ValidationTextArea", "fox/form/Select", "fox/form/ComboButton", -- cgit v1.2.3