From e4735b943755126e121cf43f1721c543b029fc22 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Tue, 22 May 2018 14:30:25 +0200 Subject: [PATCH] no negative votes and better scrolling in forms with number inputs (closes #3739) --- .../assignments/static/js/assignments/site.js | 34 +++++++++++-------- openslides/core/static/js/core/site.js | 11 ++++++ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/openslides/assignments/static/js/assignments/site.js b/openslides/assignments/static/js/assignments/site.js index 94aa3a815..31320853d 100644 --- a/openslides/assignments/static/js/assignments/site.js +++ b/openslides/assignments/static/js/assignments/site.js @@ -727,6 +727,7 @@ angular.module('OpenSlidesApp.assignments.site', [ templateOptions: { label: gettextCatalog.getString('Yes'), type: 'number', + min: -2, required: true }, defaultValue: defaultValue.yes @@ -737,6 +738,7 @@ angular.module('OpenSlidesApp.assignments.site', [ templateOptions: { label: gettextCatalog.getString('No'), type: 'number', + min: -2, required: true }, defaultValue: defaultValue.no @@ -750,6 +752,7 @@ angular.module('OpenSlidesApp.assignments.site', [ templateOptions: { label: gettextCatalog.getString('Abstain'), type: 'number', + min: -2, required: true }, defaultValue: defaultValue.abstain @@ -759,17 +762,17 @@ angular.module('OpenSlidesApp.assignments.site', [ if (option.votes.length) { defaultValue = option.votes[0].weight; } - $scope.formFields.push( - { - key: 'vote_' + option.candidate_id, - type: 'input', - templateOptions: { - label: option.candidate.get_full_name(), - type: 'number', - required: true - }, - defaultValue: defaultValue - }); + $scope.formFields.push({ + key: 'vote_' + option.candidate_id, + type: 'input', + templateOptions: { + label: option.candidate.get_full_name(), + type: 'number', + min: -2, + required: true, + }, + defaultValue: defaultValue + }); } }); // add general form fields @@ -779,7 +782,8 @@ angular.module('OpenSlidesApp.assignments.site', [ type: 'input', templateOptions: { label: gettextCatalog.getString('Valid ballots'), - type: 'number' + type: 'number', + min: -2, } }, { @@ -787,7 +791,8 @@ angular.module('OpenSlidesApp.assignments.site', [ type: 'input', templateOptions: { label: gettextCatalog.getString('Invalid ballots'), - type: 'number' + type: 'number', + min: -2, } }, { @@ -795,7 +800,8 @@ angular.module('OpenSlidesApp.assignments.site', [ type: 'input', templateOptions: { label: gettextCatalog.getString('Casted ballots'), - type: 'number' + type: 'number', + min: -2, } } ); diff --git a/openslides/core/static/js/core/site.js b/openslides/core/static/js/core/site.js index 04aa5167d..9b54ee3a7 100644 --- a/openslides/core/static/js/core/site.js +++ b/openslides/core/static/js/core/site.js @@ -1112,6 +1112,17 @@ angular.module('OpenSlidesApp.core.site', [ } ]) +// Prevent scrolling in number inputs. Instead of changing the number, the input +// is blurred and the window is scrolled. This is very important for our dialog +// forms, so a user didn't change a value, when he wants to scroll the form. +.run(function () { + $('body').on('mousewheel', function (e) { + if (e.target.nodeName === 'INPUT' && e.target.type === 'number') { + $(e.target).blur(); + } + }); +}) + // Projector Sidebar Controller .controller('ProjectorSidebarCtrl', [ '$scope',