Fixed quickEdit mode in agenda, motion, assignment.

Refresh motion object after cancel.
This commit is contained in:
Emanuel Schuetze 2016-02-08 21:19:13 +01:00
parent 6ba47a64d3
commit 82f2c4f003
6 changed files with 52 additions and 36 deletions

View File

@ -126,6 +126,12 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
$state.go(item.content_object.collection.replace('/','.')+'.detail',
{id: item.content_object.id});
};
// cancel QuickEdit mode
$scope.cancelQuickEdit = function (item) {
// revert all changes by restore (refresh) original item object from server
Agenda.refresh(item);
item.quickEdit = false;
};
// save changed item
$scope.save = function (item) {
Agenda.save(item).then(

View File

@ -168,42 +168,40 @@
<input os-perms="agenda.can_manage" type="checkbox" ng-model="item.closed" ng-change="save(item.id);">
<!-- quickEdit columns -->
<td ng-show="item.quickEdit" os-perms="agenda.can_manage" colspan="3">
<form ng-submit="save(item)">
<h4>{{ item.getTitle() }} <span class="text-muted">&ndash; QuickEdit</span></h4>
<uib-alert ng-show="alert.show" type="{{ alert.type }}" ng-click="alert={}" close="alert={}">
{{ alert.msg }}
</uib-alert>
<div class="row">
<div class="col-xs-6">
<label for="inputItemNumber" translate>Item number</label>
<input type="text" ng-model="item.item_number" class="form-control input-sm" id="inputItemNumber">
</div>
<div class="col-xs-6">
<label for="inputComment" translate>Comment</label>
<input type="text" ng-model="item.comment" class="form-control input-sm" id="inputComment">
</div>
<uib-alert ng-show="alert.show" type="{{ alert.type }}" ng-click="alert={}" close="alert={}">
{{ alert.msg }}
</uib-alert>
<div class="row">
<div class="col-xs-6">
<label for="inputItemNumber" translate>Item number</label>
<input type="text" ng-model="item.item_number" class="form-control input-sm" id="inputItemNumber">
</div>
<div class="row">
<div class="col-xs-6">
<!-- item type: AGENDA_ITEM = 1, HIDDEN_ITEM = 2 -->
<input type="checkbox" ng-model="item.type" ng-true-value="1" ng-false-value="2">
<translate>Show as agenda item</translate>
</div>
<div class="col-xs-6">
<label for="inputDuration" translate>Duration</label>
<input type="text" ng-model="item.duration" class="form-control input-sm" id="inputDuration">
</div>
<div class="col-xs-6">
<label for="inputComment" translate>Comment</label>
<input type="text" ng-model="item.comment" class="form-control input-sm" id="inputComment">
</div>
<div class="spacer">
<button ng-click="item.quickEdit=false" class="btn btn-default pull-left" translate>
Cancel
</button> &nbsp;
<button type="submit" class="btn btn-primary" translate>
Update
</button>
<a href="" ng-click="editDialog(item)" class="pull-right"><translate>Edit ...</translate></a>
</div>
<div class="row">
<div class="col-xs-6">
<!-- item type: AGENDA_ITEM = 1, HIDDEN_ITEM = 2 -->
<input type="checkbox" ng-model="item.type" ng-true-value="1" ng-false-value="2">
<translate>Show as agenda item</translate>
</div>
</form>
<div class="col-xs-6">
<label for="inputDuration" translate>Duration</label>
<input type="text" ng-model="item.duration" class="form-control input-sm" id="inputDuration">
</div>
</div>
<div class="spacer">
<button ng-click="cancelQuickEdit(item)" class="btn btn-default pull-left" translate>
Cancel
</button> &nbsp;
<button ng-click="save(item)" class="btn btn-primary" translate>
Update
</button>
<a href="" ng-click="editDialog(item)" class="pull-right"><translate>Edit ...</translate></a>
</div>
</table>
<uib-pagination total-items="itemsFiltered.length" items-per-page="itemsPerPage" ng-model="currentPage" ng-change="pageChanged()"></uib-pagination>
</div>

View File

@ -203,6 +203,12 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
$scope.openDialog = function (assignment) {
ngDialog.open(AssignmentForm.getDialog(assignment));
};
// cancel QuickEdit mode
$scope.cancelQuickEdit = function (assignment) {
// revert all changes by restore (refresh) original assignment object from server
Assignment.refresh(assignment);
assignment.quickEdit = false;
};
// save changed assignment
$scope.save = function (assignment) {
Assignment.save(assignment).then(

View File

@ -162,7 +162,7 @@
</span>
<!-- quickEdit columns -->
<td ng-if="assignment.quickEdit" colspan="3">
<td ng-if="assignment.quickEdit" colspan="4">
<h4>{{ assignment.title }} <span class="text-muted">&ndash; Quick Edit</span></h4>
<uib-alert ng-show="alert.show" type="{{ alert.type }}" ng-click="alert={}" close="alert={}">
{{ alert.msg }}
@ -187,7 +187,7 @@
<div class="col-xs-6"></div>
</div>
<div class="spacer">
<button ng-click="assignment.quickEdit=false" class="btn btn-default pull-left" translate>
<button ng-click="cancelQuickEdit(assignment)" class="btn btn-default pull-left" translate>
Cancel
</button> &nbsp;
<button ng-click="save(assignment)" class="btn btn-primary" translate>

View File

@ -467,6 +467,12 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
$scope.openDialog = function (motion) {
ngDialog.open(MotionForm.getDialog(motion));
};
// cancel QuickEdit mode
$scope.cancelQuickEdit = function (motion) {
// revert all changes by restore (refresh) original motion object from server
Motion.refresh(motion);
motion.quickEdit = false;
};
// save changed motion
$scope.save = function (motion) {
// get (unchanged) values from latest version for update method

View File

@ -197,7 +197,7 @@
</span>
<!-- quickEdit columns -->
<td ng-if="motion.quickEdit && motion.isAllowed('quickedit')" colspan="5">
<td ng-if="motion.quickEdit && motion.isAllowed('quickedit')" colspan="6">
<h4>{{ motion.getTitle() }} <span class="text-muted">&ndash; <translate>QuickEdit</translate></span></h4>
<uib-alert ng-show="alert.show" type="{{ alert.type }}" ng-click="alert={}" close="alert={}">
{{ alert.msg }}
@ -255,7 +255,7 @@
</div>
</div>
<div class="spacer">
<button ng-click="motion.quickEdit=false" class="btn btn-default pull-left" translate>
<button ng-click="cancelQuickEdit(motion)" class="btn btn-default pull-left" translate>
Cancel
</button> &nbsp;
<button ng-if="motion.isAllowed('update')" ng-click="save(motion)" class="btn btn-primary" translate>