Merge pull request #2820 from FinnStutzenstein/Issue2667

Change user import table
This commit is contained in:
Emanuel Schütze 2017-01-10 21:22:39 +01:00 committed by GitHub
commit 962c06c85f
3 changed files with 110 additions and 102 deletions

View File

@ -1249,6 +1249,10 @@ img {
padding-right: 0 !important;
}
.scroll-x-container {
overflow-x: auto;
}
/* user details */
.user_details fieldset {
margin-bottom: 10px;

View File

@ -963,6 +963,7 @@ angular.module('OpenSlidesApp.users.site', [
$scope.duplicates = 0;
var quotionRe = /^"(.*)"$/;
angular.forEach($scope.csv.result, function (user) {
user.selected = true;
// title
if (user.title) {
user.title = user.title.replace(quotionRe, '$1');
@ -1098,7 +1099,7 @@ angular.module('OpenSlidesApp.users.site', [
$scope.usersWillBeImported = 0;
$scope.users.forEach(function(user) {
if (user.importerror || (user.duplicate && user.duplicateAction == $scope.duplicateActions[0])) {
if (!user.selected || user.importerror || (user.duplicate && user.duplicateAction == $scope.duplicateActions[0])) {
$scope.usersWillNotBeImported++;
} else {
$scope.usersWillBeImported++;
@ -1121,7 +1122,7 @@ angular.module('OpenSlidesApp.users.site', [
// collect all needed groups and create non existing groups
var groupsToCreate = [];
_.forEach($scope.users, function (user) {
if (!user.importerror && user.groups.length) {
if (user.selected && !user.importerror && user.groups.length) {
_.forEach(user.groupsToCreate, function (group) { // Just append groups, that are not listed yet.
if (_.indexOf(groupsToCreate, group) == -1) {
groupsToCreate.push(group);
@ -1147,7 +1148,7 @@ angular.module('OpenSlidesApp.users.site', [
var existingUsers = User.getAll();
_.forEach($scope.users, function (user) {
if (!user.importerror) {
if (user.selected && !user.importerror) {
// Assign all groups
_.forEach(user.groups, function(csvGroup) {
allGroups.forEach(function (allGroup) {

View File

@ -77,108 +77,111 @@
<div ng-show="csv.result">
<h3 translate>Preview</h3>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>
<th>#
<th translate>Title
<th translate>Given name
<th translate>Surname
<th translate>Structure level
<th translate>Participant number
<th translate>Groups
<th translate>Comment
<th translate>Is active
<th translate>Is present
<th translate>Is committee</th>
<th ng-if="duplicates > 0">
<i class="fa fa-exclamation-triangle text-danger"></i>
<strong class="text-danger" ng-if="duplicates == 1">1 <translate>duplicate</translate></strong>
<strong class="text-danger" ng-if="duplicates > 1">{{ duplicates }} <translate>duplicates</translate></strong>
<div class="scroll-x-container">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>
<th>#
<th translate>Title
<th translate>Given name
<th translate>Surname
<th translate>Structure level
<th translate>Participant number
<th translate>Groups
<th translate>Comment
<th translate>Is active
<th translate>Is present
<th translate>Is committee</th>
<th ng-if="duplicates > 0">
<i class="fa fa-exclamation-triangle text-danger"></i>
<strong class="text-danger" ng-if="duplicates == 1">1 <translate>duplicate</translate></strong>
<strong class="text-danger" ng-if="duplicates > 1">{{ duplicates }} <translate>duplicates</translate></strong>
<div uib-dropdown>
<button id="GlobalAction" type="button" class="btn btn-default btn-danger btn-sm" uib-dropdown-toggle>
<translate>Set global action</translate>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="GlobalAction">
<li ng-repeat="action in duplicateActions">
<a href ng-click="setGlobalAction(action)">
{{ action | translate }}
</a>
</li>
</ul>
</div>
</th>
<tbody>
<tr ng-repeat="user in users | limitTo : itemsPerPage : limitBegin">
<td class="minimum"
ng-class="{ 'text-danger': (user.importerror || user.duplicateAction == duplicateActions[0]), 'text-success': user.imported }">
<span ng-if="user.importerror || user.duplicateAction == duplicateActions[0]">
<i class="fa fa-exclamation-triangle fa-lg"></i>
</span>
<span ng-if="!user.importerror && !user.imported && user.duplicateAction != duplicateActions[0]">
<i class="fa fa-check-circle-o fa-lg"></i>
</span>
<span ng-if="user.imported">
<i class="fa fa-check-circle fa-lg"></i>
</span>
<td>
{{ (currentPage - 1) * itemsPerPage + $index + 1 }}
<td>
{{ user.title }}
<td ng-class="{ 'text-danger': user.name_error }">
<span ng-if="!user.first_name && user.name_error" title="{{ user.name_error | translate }}">
<i class="fa fa-exclamation-triangle"></i>
</span>
{{ user.first_name }}
<td ng-class="{ 'text-danger': user.name_error }">
<span ng-if="!user.last_name && user.name_error" title="{{ user.name_error | translate }}">
<i class="fa fa-exclamation-triangle"></i>
</span>
{{ user.last_name }}
<td>
{{ user.structure_level }}
<td>
{{ user.number }}
<td>
<div ng-repeat="groupname in user.groupsNotToCreate">
{{ groupname | translate }}
</div>
<div ng-repeat="groupname in user.groupsToCreate" class="text-warning">
<i class="fa fa-plus-circle"></i>
{{ groupname | translate }}
</div>
<td style="max-width: 130px;">
<span uib-tooltip="{{ user.comment }}">
{{ user.comment | limitTo: 30 }}{{ user.comment.length > 30 ? '...' : '' }}
</span>
<td>
<i class="fa pointer" ng-class="user.is_active ? 'fa-check-square-o' : 'fa-square-o'"
ng-click="user.is_active = !user.is_active"></i>
<td>
<i class="fa pointer" ng-class="user.is_present ? 'fa-check-square-o' : 'fa-square-o'"
ng-click="user.is_present = !user.is_present"></i>
<td>
<i class="fa pointer" ng-class="user.is_committee ? 'fa-check-square-o' : 'fa-square-o'"
ng-click="user.is_committee = !user.is_committee"></i>
<td ng-if="duplicates > 0">
<div ng-if="user.duplicate" uib-tooltip="{{ user.duplicate_info }}" uib-dropdown>
<button id="UserAction{{ $index }}" type="button" class="btn btn-default btn-sm"
uib-dropdown-toggle ng-class="user.duplicateAction == duplicateActions[0] ? 'btn-warning' : (user.duplicateAction == duplicateActions[1] ? 'btn-danger' : 'btn-success')">
{{ user.duplicateAction | translate }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="UserAction{{ $index }}">
<li ng-repeat="action in duplicateActions">
<a href ng-click="user.duplicateAction = action; calcStats()">
<i class="fa fa-check" ng-if="user.duplicateAction == action"></i>
<div uib-dropdown>
<button id="GlobalAction" type="button" class="btn btn-default btn-danger btn-sm" uib-dropdown-toggle>
<translate>Set global action</translate>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="GlobalAction">
<li ng-repeat="action in duplicateActions">
<a href ng-click="setGlobalAction(action)">
{{ action | translate }}
</a>
</li>
</ul>
</table>
</li>
</ul>
</div>
</th>
<tbody>
<tr ng-repeat="user in users | limitTo : itemsPerPage : limitBegin">
<td class="minimum"
ng-class="{ 'text-danger': (user.importerror || user.duplicateAction == duplicateActions[0]), 'text-success': user.imported }">
<span ng-if="user.importerror || user.duplicateAction == duplicateActions[0]">
<i class="fa fa-exclamation-triangle fa-lg"></i>
</span>
<span ng-if="!user.importerror && !user.imported && user.duplicateAction != duplicateActions[0]" class="pointer">
<i class="fa fa-check-circle-o fa-lg" ng-if="user.selected" ng-click="user.selected=false; calcStats();"></i>
<i class="fa fa-circle-o fa-lg" ng-if="!user.selected" ng-click="user.selected=true; calcStats();"></i>
</span>
<span ng-if="user.imported">
<i class="fa fa-check-circle fa-lg"></i>
</span>
<td class="nobr">
{{ (currentPage - 1) * itemsPerPage + $index + 1 }}
<td>
{{ user.title }}
<td ng-class="{ 'text-danger': user.name_error }">
<span ng-if="!user.first_name && user.name_error" title="{{ user.name_error | translate }}">
<i class="fa fa-exclamation-triangle"></i>
</span>
{{ user.first_name }}
<td ng-class="{ 'text-danger': user.name_error }">
<span ng-if="!user.last_name && user.name_error" title="{{ user.name_error | translate }}">
<i class="fa fa-exclamation-triangle"></i>
</span>
{{ user.last_name }}
<td>
{{ user.structure_level }}
<td>
{{ user.number }}
<td>
<div ng-repeat="groupname in user.groupsNotToCreate">
{{ groupname | translate }}
</div>
<div ng-repeat="groupname in user.groupsToCreate" class="text-warning">
<i class="fa fa-plus-circle"></i>
{{ groupname | translate }}
</div>
<td style="max-width: 130px;">
<span uib-tooltip="{{ user.comment }}">
{{ user.comment | limitTo: 30 }}{{ user.comment.length > 30 ? '...' : '' }}
</span>
<td>
<i class="fa pointer" ng-class="user.is_active ? 'fa-check-square-o' : 'fa-square-o'"
ng-click="user.is_active = !user.is_active"></i>
<td>
<i class="fa pointer" ng-class="user.is_present ? 'fa-check-square-o' : 'fa-square-o'"
ng-click="user.is_present = !user.is_present"></i>
<td>
<i class="fa pointer" ng-class="user.is_committee ? 'fa-check-square-o' : 'fa-square-o'"
ng-click="user.is_committee = !user.is_committee"></i>
<td ng-if="duplicates > 0">
<div ng-if="user.duplicate" uib-tooltip="{{ user.duplicate_info }}" uib-dropdown>
<button id="UserAction{{ $index }}" type="button" class="btn btn-default btn-sm"
uib-dropdown-toggle ng-class="user.duplicateAction == duplicateActions[0] ? 'btn-warning' : (user.duplicateAction == duplicateActions[1] ? 'btn-danger' : 'btn-success')">
{{ user.duplicateAction | translate }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="UserAction{{ $index }}">
<li ng-repeat="action in duplicateActions">
<a href ng-click="user.duplicateAction = action; calcStats()">
<i class="fa fa-check" ng-if="user.duplicateAction == action"></i>
{{ action | translate }}
</a>
</li>
</ul>
</table>
</div>
<ul uib-pagination
ng-show="users.length > itemsPerPage"
total-items="users.length"