From fa5ba6beb88be44c64c9db9bdede4e2e7da65d3d Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 30 Mar 2020 19:34:53 +0200 Subject: [PATCH] FIX: ensures mini-tag-chooser display min tags req if no selection (#9303) --- .../select-kit/components/mini-tag-chooser.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/assets/javascripts/select-kit/components/mini-tag-chooser.js b/app/assets/javascripts/select-kit/components/mini-tag-chooser.js index 4f89e380b88..d8c63c9ae5d 100644 --- a/app/assets/javascripts/select-kit/components/mini-tag-chooser.js +++ b/app/assets/javascripts/select-kit/components/mini-tag-chooser.js @@ -77,6 +77,20 @@ export default ComboBox.extend(TagsMixin, { ); }), + modifyNoSelection() { + if (this.selectKit.options.minimum) { + const minimum = parseInt(this.selectKit.options.minimum, 10); + if (minimum > 0) { + return this.defaultItem( + null, + I18n.t("select_kit.min_content_not_reached", { count: minimum }) + ); + } + } + + return this._super(...arguments); + }, + init() { this._super(...arguments);