From e93eb6ffa278c1316aba285e01033733dd2944af Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 31 Aug 2016 11:43:17 +0200 Subject: [PATCH] Fixed poll error handling --- .../templates/__messageFormPollInline.tpl | 4 +++- wcfsetup/install/files/js/WCF.Poll.js | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/com.woltlab.wcf/templates/__messageFormPollInline.tpl b/com.woltlab.wcf/templates/__messageFormPollInline.tpl index b3465b05dc..01f778c226 100644 --- a/com.woltlab.wcf/templates/__messageFormPollInline.tpl +++ b/com.woltlab.wcf/templates/__messageFormPollInline.tpl @@ -4,7 +4,9 @@ $(function() { WCF.Language.addObject({ 'wcf.poll.button.addOption': '{lang}wcf.poll.button.addOption{/lang}', - 'wcf.poll.button.removeOption': '{lang}wcf.poll.button.removeOption{/lang}' + 'wcf.poll.button.removeOption': '{lang}wcf.poll.button.removeOption{/lang}', + 'wcf.poll.endTime.error.notValid': '{lang}wcf.poll.endTime.error.notValid{/lang}', + 'wcf.poll.maxVotes.error.notValid': '{lang}wcf.poll.maxVotes.error.notValid{/lang}' }); new WCF.Poll.Management( diff --git a/wcfsetup/install/files/js/WCF.Poll.js b/wcfsetup/install/files/js/WCF.Poll.js index 33667ce790..a8bfc328d0 100644 --- a/wcfsetup/install/files/js/WCF.Poll.js +++ b/wcfsetup/install/files/js/WCF.Poll.js @@ -276,17 +276,25 @@ WCF.Poll.Management = Class.extend({ } // get options - var hasOptions = false; + var count = 0; elBySelAll('li input[type="text"]', this._container[0], function(input) { if (input.value.trim() !== '') { - hasOptions = true; + count++; } }); - if (hasOptions === false) { + if (count === 0) { data.api.throwError(this._container[0], WCF.Language.get('wcf.global.form.error.empty')); data.valid = false; } + else { + var pollMaxVotes = elById('pollMaxVotes_' + this._editorId); + var num = ~~pollMaxVotes.value; + if (num && num > count) { + data.api.throwError(pollMaxVotes, WCF.Language.get('wcf.poll.maxVotes.error.notValid')); + data.valid = false; + } + } } }); -- 2.20.1