Editing change recommendations

This commit is contained in:
Tobias Hößl 2016-11-19 14:07:46 +01:00
parent 14d00cc404
commit fd82ae348e
4 changed files with 60 additions and 1 deletions

View File

@ -605,9 +605,12 @@ img {
opacity: 1;
}
.diff-box .action-row .btn-delete {
margin-left: 10px;
margin-left: 5px;
color: red;
}
.diff-box .action-row .btn-edit {
margin-left: 5px;
}
.diff-box .status-row {
font-style: italic;
color: gray;

View File

@ -304,6 +304,10 @@ angular.module('OpenSlidesApp.motions.motionservices', ['OpenSlidesApp.motions',
version = _version;
};
obj.editDialog = function(change_recommendation) {
ngDialog.open(ChangeRecommendationForm.getEditDialog(change_recommendation));
};
obj.init = function (_scope, _motion) {
$scope = _scope;
motion = _motion;

View File

@ -311,6 +311,20 @@ angular.module('OpenSlidesApp.motions.site', [
}
};
},
getEditDialog: function(change) {
return {
template: 'static/templates/motions/change-recommendation-form.html',
controller: 'ChangeRecommendationUpdateCtrl',
className: 'ngdialog-theme-default wide-form',
closeByEscape: false,
closeByDocument: false,
resolve: {
change: function() {
return change;
}
}
};
},
// angular-formly fields for motion form
getFormFields: function (line_from, line_to) {
return [
@ -1231,6 +1245,39 @@ angular.module('OpenSlidesApp.motions.site', [
}
])
.controller('ChangeRecommendationUpdateCtrl', [
'$scope',
'MotionChangeRecommendation',
'ChangeRecommendationForm',
'change',
function ($scope, MotionChangeRecommendation, ChangeRecommendationForm, change) {
$scope.alert = {};
$scope.model = angular.copy(change);
// get all form fields
$scope.formFields = ChangeRecommendationForm.getFormFields(change.line_from, change.line_to);
// save motion
$scope.save = function (change) {
// inject the changed change recommendation (copy) object back into DS store
MotionChangeRecommendation.inject(change);
// save changed change recommendation object on server
MotionChangeRecommendation.save(change, { method: 'PATCH' }).then(
function(success) {
$scope.closeThisDialog();
},
function (error) {
MotionChangeRecommendation.refresh(change);
var message = '';
for (var e in error.data) {
message += e + ': ' + error.data[e] + ' ';
}
$scope.alert = {type: 'danger', msg: message, show: true};
}
);
};
}
])
.controller('ChangeRecommendationCreateCtrl', [
'$scope',
'Motion',

View File

@ -30,6 +30,11 @@
title="{{ 'Delete' | translate }}">
<i class="fa fa-trash"></i>
</button>
<button class="btn btn-default btn-sm pull-right btn-edit" ng-click="createChangeRecommendation.editDialog(change)"
title="{{ 'Edit' | translate }}">
<i class="fa fa-pencil"></i>
</button>
</div>
<div class="status-row" ng-if="!motion.isAllowed('can_manage') && change.rejected">
<translate>Rejected</translate>