Added presence view

This commit is contained in:
FinnStutzenstein 2017-11-21 10:32:31 +01:00
parent 4f9b1e178f
commit 3f0f98dc24
5 changed files with 100 additions and 4 deletions

View File

@ -66,6 +66,7 @@ Users:
- Added option to enable updating the last_login field in the database. The
default is now disabled [#3400].
- Hide password in change password view [#3417].
- Added a change presence view [#3496].
Core:
- No reload on logoff. OpenSlides is now a full single page

View File

@ -21,6 +21,15 @@ def get_config_variables():
group='Participants',
subgroup='General')
yield ConfigVariable(
name='users_enable_presence_view',
default_value=False,
input_type='boolean',
label='Enable participant presence view',
weight=511,
group='Participants',
subgroup='General')
# PDF
yield ConfigVariable(

View File

@ -76,6 +76,10 @@ angular.module('OpenSlidesApp.users.site', [
url: '/import',
controller: 'UserImportCtrl',
})
.state('users.user.presence', {
url: '/presence',
controller: 'UserPresenceCtrl',
})
// groups
.state('users.group', {
url: '/groups',
@ -432,7 +436,7 @@ angular.module('OpenSlidesApp.users.site', [
function (gettextCatalog, Editor, Mediafile) {
return {
// ngDialog for user form
getDialog: function (user) {
getDialog: function () {
return {
template: 'static/templates/users/profile-password-form.html',
controller: 'UserProfileCtrl',
@ -474,7 +478,7 @@ angular.module('OpenSlidesApp.users.site', [
function (gettextCatalog) {
return {
// ngDialog for user form
getDialog: function (user) {
getDialog: function () {
return {
template: 'static/templates/users/profile-password-form.html',
controller: 'UserPasswordCtrl',
@ -536,8 +540,9 @@ angular.module('OpenSlidesApp.users.site', [
'gettext',
'UserPdfExport',
'ErrorMessage',
function($scope, $state, $http, $q, ngDialog, UserForm, User, Group, PasswordGenerator, Projector, ProjectionDefault,
Config, gettextCatalog, UserCsvExport, osTableFilter, osTableSort, gettext, UserPdfExport, ErrorMessage) {
function($scope, $state, $http, $q, ngDialog, UserForm, User, Group, PasswordGenerator,
Projector, ProjectionDefault, Config, gettextCatalog, UserCsvExport, osTableFilter,
osTableSort, gettext, UserPdfExport, ErrorMessage) {
$scope.$watch(function () {
return User.lastModified();
}, function () {
@ -962,6 +967,49 @@ angular.module('OpenSlidesApp.users.site', [
}
])
.controller('UserPresenceCtrl', [
'$scope',
'User',
'gettextCatalog',
'ErrorMessage',
function ($scope, User, gettextCatalog, ErrorMessage) {
$scope.alert = {};
$('#userNumber').focus();
$scope.changeState = function () {
if (!$scope.number) {
return;
}
var enteredNumber = $scope.number.trim();
var user = _.find(User.getAll(), function (user) {
return user.number === enteredNumber;
});
if (user) {
user.is_present = !user.is_present;
User.save(user).then(function (success) {
var messageText = user.full_name + ' ' + gettextCatalog.getString('is now') + ' ';
messageText += gettextCatalog.getString(user.is_present ? 'present' : 'not present') + '.';
$scope.alert = {
msg: messageText,
show: true,
type: 'success',
};
$scope.number = '';
}, function (error) {
$scope.alert = ErrorMessage.forAlert(error);
});
} else {
$scope.alert = {
msg: gettextCatalog.getString('Cannot find the participant with the participant number') + ' "' + enteredNumber + '".',
show: true,
type: 'danger',
};
}
$('#userNumber').focus();
};
}
])
.controller('UserImportCtrl', [
'$scope',
'$http',
@ -1653,6 +1701,7 @@ angular.module('OpenSlidesApp.users.site', [
// config strings in users/config_variables.py
gettext('General');
gettext('Sort name of participants by');
gettext('Enable participant presence view');
gettext('Participants');
gettext('Given name');
gettext('Surname');

View File

@ -5,6 +5,12 @@
<i class="fa fa-plus fa-lg"></i>
<translate>New</translate>
</a>
<span ng-if="config('users_enable_presence_view')">
<a ui-sref="users.user.presence" os-perms="users.can_manage" class="btn btn-default btn-sm">
<i class="fa fa-barcode fa-lg"></i>
<translate>Presence</translate>
</a>
</span>
<a ui-sref="users.group.list" os-perms="users.can_manage" class="btn btn-default btn-sm">
<i class="fa fa-group fa-lg"></i>
<translate>Groups</translate>

View File

@ -0,0 +1,31 @@
<div class="header">
<div class="title">
<div class="submenu">
<a ui-sref="users.user.list" class="btn btn-sm btn-default">
<i class="fa fa-angle-double-left fa-lg"></i>
<translate>Back to overview</translate>
</a>
</div>
<h1 translate>Presence</h1>
</div>
</div>
<div class="details">
<div uib-alert ng-show="alert.show" ng-class="'alert-' + (alert.type || 'warning')" close="alert={}">
{{ alert.msg }}
</div>
<form ng-submit="changeState()" class="row">
<div class="col-md-6">
<div class="form-group">
<label for="userNumber" translate>Enter participant number</label>
<input type="text" class="form-control" id="userNumber"
ng-model="number" ng-change="updateSuggestions()">
</div>
<button type="submit" class="btn btn-sm btn-primary" translate>
Change presence
</button>
</div>
</form>
</div>