Merge pull request #3750 from FinnStutzenstein/assignmentPollInputs

no negative votes and better scrolling in forms with number inputs (c…
This commit is contained in:
Emanuel Schütze 2018-05-23 15:58:01 +02:00 committed by GitHub
commit 1b321fb680
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 14 deletions

View File

@ -727,6 +727,7 @@ angular.module('OpenSlidesApp.assignments.site', [
templateOptions: { templateOptions: {
label: gettextCatalog.getString('Yes'), label: gettextCatalog.getString('Yes'),
type: 'number', type: 'number',
min: -2,
required: true required: true
}, },
defaultValue: defaultValue.yes defaultValue: defaultValue.yes
@ -737,6 +738,7 @@ angular.module('OpenSlidesApp.assignments.site', [
templateOptions: { templateOptions: {
label: gettextCatalog.getString('No'), label: gettextCatalog.getString('No'),
type: 'number', type: 'number',
min: -2,
required: true required: true
}, },
defaultValue: defaultValue.no defaultValue: defaultValue.no
@ -750,6 +752,7 @@ angular.module('OpenSlidesApp.assignments.site', [
templateOptions: { templateOptions: {
label: gettextCatalog.getString('Abstain'), label: gettextCatalog.getString('Abstain'),
type: 'number', type: 'number',
min: -2,
required: true required: true
}, },
defaultValue: defaultValue.abstain defaultValue: defaultValue.abstain
@ -759,14 +762,14 @@ angular.module('OpenSlidesApp.assignments.site', [
if (option.votes.length) { if (option.votes.length) {
defaultValue = option.votes[0].weight; defaultValue = option.votes[0].weight;
} }
$scope.formFields.push( $scope.formFields.push({
{
key: 'vote_' + option.candidate_id, key: 'vote_' + option.candidate_id,
type: 'input', type: 'input',
templateOptions: { templateOptions: {
label: option.candidate.get_full_name(), label: option.candidate.get_full_name(),
type: 'number', type: 'number',
required: true min: -2,
required: true,
}, },
defaultValue: defaultValue defaultValue: defaultValue
}); });
@ -779,7 +782,8 @@ angular.module('OpenSlidesApp.assignments.site', [
type: 'input', type: 'input',
templateOptions: { templateOptions: {
label: gettextCatalog.getString('Valid ballots'), label: gettextCatalog.getString('Valid ballots'),
type: 'number' type: 'number',
min: -2,
} }
}, },
{ {
@ -787,7 +791,8 @@ angular.module('OpenSlidesApp.assignments.site', [
type: 'input', type: 'input',
templateOptions: { templateOptions: {
label: gettextCatalog.getString('Invalid ballots'), label: gettextCatalog.getString('Invalid ballots'),
type: 'number' type: 'number',
min: -2,
} }
}, },
{ {
@ -795,7 +800,8 @@ angular.module('OpenSlidesApp.assignments.site', [
type: 'input', type: 'input',
templateOptions: { templateOptions: {
label: gettextCatalog.getString('Casted ballots'), label: gettextCatalog.getString('Casted ballots'),
type: 'number' type: 'number',
min: -2,
} }
} }
); );

View File

@ -1121,6 +1121,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 // Projector Sidebar Controller
.controller('ProjectorSidebarCtrl', [ .controller('ProjectorSidebarCtrl', [
'$scope', '$scope',