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: {
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,
}
}
);

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
.controller('ProjectorSidebarCtrl', [
'$scope',