Merge pull request #2651 from CatoTH/editing-change-recommendations

Editing change recommendations
This commit is contained in:
Emanuel Schütze 2016-11-28 21:31:22 +01:00 committed by GitHub
commit 5312d44235
4 changed files with 60 additions and 1 deletions

View File

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

View File

@ -307,6 +307,10 @@ angular.module('OpenSlidesApp.motions.motionservices', ['OpenSlidesApp.motions',
version = _version; version = _version;
}; };
obj.editDialog = function(change_recommendation) {
ngDialog.open(ChangeRecommendationForm.getEditDialog(change_recommendation));
};
obj.init = function (_scope, _motion) { obj.init = function (_scope, _motion) {
$scope = _scope; $scope = _scope;
motion = _motion; 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 // angular-formly fields for motion form
getFormFields: function (line_from, line_to) { getFormFields: function (line_from, line_to) {
return [ return [
@ -1279,6 +1293,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', [ .controller('ChangeRecommendationCreateCtrl', [
'$scope', '$scope',
'Motion', 'Motion',

View File

@ -30,6 +30,11 @@
title="{{ 'Delete' | translate }}"> title="{{ 'Delete' | translate }}">
<i class="fa fa-trash"></i> <i class="fa fa-trash"></i>
</button> </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>
<div class="status-row" ng-if="!motion.isAllowed('can_manage') && change.rejected"> <div class="status-row" ng-if="!motion.isAllowed('can_manage') && change.rejected">
<translate>Rejected</translate> <translate>Rejected</translate>