Added version history (Fixes #1676)

This commit is contained in:
Emanuel Schuetze 2016-01-18 00:15:28 +01:00
parent 7967da0b4e
commit 59a7a02cfe
2 changed files with 63 additions and 5 deletions

View File

@ -504,7 +504,7 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
User.bindAll({}, $scope, 'users');
Workflow.bindAll({}, $scope, 'workflows');
Motion.loadRelations(motion, 'agenda_item');
$scope.version = motion.active_version;
$scope.isCollapsed = true;
// open edit dialog
@ -553,6 +553,27 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
$scope.delete_poll = function (poll) {
poll.DSDestroy();
}
// show specific version
$scope.showVersion = function (version) {
$scope.version = version.id;
}
// permit specific version
$scope.permitVersion = function (version) {
$http.put('/rest/motions/motion/' + motion.id + '/manage_version/',
{'version_number': version.version_number})
.then(function(success) {
$scope.version = version.id;
});
}
// delete specific version
$scope.deleteVersion = function (version) {
$http.delete('/rest/motions/motion/' + motion.id + '/manage_version/',
{headers: {'Content-Type': 'application/json'},
data: JSON.stringify({version_number: version.version_number})})
.then(function(success) {
$scope.version = motion.active_version;
});
}
}
])

View File

@ -28,10 +28,14 @@
<i class="fa fa-pencil"></i>
</a>
</div>
<h1>{{ motion.getTitle() }}</h1>
<h1>{{ motion.getTitle(version) }}</h1>
<h2>
<translate>Motion</translate> {{ motion.identifier }}
<span ng-if="motion.versions.length > 1" >| Version {{ motion.getVersion().version_number }}</span>
<span ng-if="motion.versions.length > 1" >| Version {{ motion.getVersion(version).version_number }}</span>
<span ng-if="motion.active_version != version" class="label label-warning">
<i class="fa fa-exclamation-triangle"></i>
<translate>This version is not permitted.</translate>
</span>
<span ng-if="motion.agenda_item.item_number">
&ndash;
<translate>Agenda</translate>: {{ motion.agenda_item.item_number }}
@ -193,10 +197,10 @@
<div class="row">
<div class="col-sm-8">
<h3 translate>Text</h3>
<div class="white-space-pre-line" ng-bind-html="motion.getText()"></div>
<div class="white-space-pre-line" ng-bind-html="motion.getText(version)"></div>
<!-- reason -->
<div ng-if="motion.getReason() != ''">
<div ng-if="motion.getReason(version) != ''">
<h3 translate>Reason</h3>
<div class="white-space-pre-line" ng-bind-html="motion.getReason()"></div>
</div>
@ -208,6 +212,39 @@
<a href="{{ attachment.mediafileUrl }}" target="_blank">{{ attachment.title_or_filename }}</a>
</ul>
<!-- version history -->
<div ng-if="motion.versions.length > 1">
<h3 translate>Version history</h3>
<ul>
<li ng-repeat="version in motion.versions">
<span ng-if="$parent.version == version.id">
<strong><translate>Version</translate> {{ version.version_number }}</strong>
</span>
<a ng-if="$parent.version != version.id" ng-click="showVersion(version)">
<translate>Version</translate> {{ version.version_number }}
</a>
<!-- active version -->
<i ng-if="motion.active_version == version.id" class="fa fa-star"
title="{{ 'This is the last active version.' | translate }}"></i>
<!-- permit version -->
<button os-perms="motions.can_manage" ng-show="motion.active_version != version.id"
ng-click="permitVersion(version)"
class="btn btn-default btn-xs" title="{{ 'Permit and activate' | translate }}">
<i class="fa fa-check"></i>
</button>
<!-- delete version -->
<button os-perms="motions.can_manage" ng-show="motion.active_version != version.id"
class="btn btn-default btn-xs"
ng-bootbox-confirm="{{ 'Are you sure you want to delete this version?' | translate }}<br>
<strong><translate>Version</translate> {{ version.version_number }}</strong>"
ng-bootbox-confirm-action="deleteVersion(version)"
title="{{ 'Delete' | translate }}">
<i class="fa fa-times"></i>
</button>
<br><translate>Last modified</translate>: {{ version.creation_time | date:'yyyy-MM-dd HH:mm:ss' }}
</ul>
</div>
<!-- log -->
<button type="button" class="btn btn-default spacer" ng-click="isCollapsed = !isCollapsed" translate>
Show history