Removed agenda related options from assignment client code

This commit is contained in:
FinnStutzenstein 2017-08-18 07:44:58 +02:00 committed by Norman Jäckel
parent 4a78298f94
commit f7de741e10

View File

@ -155,8 +155,11 @@ angular.module('OpenSlidesApp.assignments.site', [
templateOptions: { templateOptions: {
label: gettextCatalog.getString('Default comment on the ballot paper') label: gettextCatalog.getString('Default comment on the ballot paper')
} }
}, }];
{
// parent item
if (isCreateForm) {
formFields.push({
key: 'showAsAgendaItem', key: 'showAsAgendaItem',
type: 'checkbox', type: 'checkbox',
templateOptions: { templateOptions: {
@ -164,12 +167,9 @@ angular.module('OpenSlidesApp.assignments.site', [
description: gettextCatalog.getString('If deactivated the election appears as internal item on agenda.') description: gettextCatalog.getString('If deactivated the election appears as internal item on agenda.')
}, },
hide: !(operator.hasPerms('assignments.can_manage') && operator.hasPerms('agenda.can_manage')) hide: !(operator.hasPerms('assignments.can_manage') && operator.hasPerms('agenda.can_manage'))
}]; });
// parent item
if (isCreateForm) {
formFields.push({ formFields.push({
key: 'agenda_parent_item_id', key: 'agenda_parent_id',
type: 'select-single', type: 'select-single',
templateOptions: { templateOptions: {
label: gettextCatalog.getString('Parent item'), label: gettextCatalog.getString('Parent item'),
@ -627,9 +627,9 @@ angular.module('OpenSlidesApp.assignments.site', [
'Assignment', 'Assignment',
'AssignmentForm', 'AssignmentForm',
'Agenda', 'Agenda',
'AgendaUpdate', //'AgendaUpdate',
'ErrorMessage', 'ErrorMessage',
function($scope, $state, Assignment, AssignmentForm, Agenda, AgendaUpdate, ErrorMessage) { function($scope, $state, Assignment, AssignmentForm, Agenda,/* AgendaUpdate,*/ ErrorMessage) {
$scope.model = {}; $scope.model = {};
// set default value for open posts form field // set default value for open posts form field
$scope.model.open_posts = 1; $scope.model.open_posts = 1;
@ -637,13 +637,14 @@ angular.module('OpenSlidesApp.assignments.site', [
$scope.formFields = AssignmentForm.getFormFields(true); $scope.formFields = AssignmentForm.getFormFields(true);
// save assignment // save assignment
$scope.save = function(assignment, gotoDetailView) { $scope.save = function(assignment, gotoDetailView) {
assignment.agenda_type = assignment.showAsAgendaItem ? 1 : 2;
Assignment.create(assignment).then( Assignment.create(assignment).then(
function (success) { function (success) {
// type: Value 1 means a non hidden agenda item, value 2 means a hidden agenda item, // type: Value 1 means a non hidden agenda item, value 2 means a hidden agenda item,
// see openslides.agenda.models.Item.ITEM_TYPE. // see openslides.agenda.models.Item.ITEM_TYPE.
var changes = [{key: 'type', value: (assignment.showAsAgendaItem ? 1 : 2)}, /*var changes = [{key: 'type', value: (assignment.showAsAgendaItem ? 1 : 2)},
{key: 'parent_id', value: assignment.agenda_parent_item_id}]; {key: 'parent_id', value: assignment.agenda_parent_item_id}];
AgendaUpdate.saveChanges(success.agenda_item_id,changes); AgendaUpdate.saveChanges(success.agenda_item_id,changes);*/
if (gotoDetailView) { if (gotoDetailView) {
$state.go('assignments.assignment.detail', {id: success.id}); $state.go('assignments.assignment.detail', {id: success.id});
} }
@ -663,10 +664,9 @@ angular.module('OpenSlidesApp.assignments.site', [
'Assignment', 'Assignment',
'AssignmentForm', 'AssignmentForm',
'Agenda', 'Agenda',
'AgendaUpdate',
'assignmentId', 'assignmentId',
'ErrorMessage', 'ErrorMessage',
function($scope, $state, Assignment, AssignmentForm, Agenda, AgendaUpdate, assignmentId, ErrorMessage) { function($scope, $state, Assignment, AssignmentForm, Agenda, assignmentId, ErrorMessage) {
var assignment = Assignment.get(assignmentId); var assignment = Assignment.get(assignmentId);
$scope.alert = {}; $scope.alert = {};
// set initial values for form model by create deep copy of assignment object // set initial values for form model by create deep copy of assignment object
@ -679,21 +679,17 @@ angular.module('OpenSlidesApp.assignments.site', [
if ($scope.formFields[i].key == "showAsAgendaItem") { if ($scope.formFields[i].key == "showAsAgendaItem") {
// get state from agenda item (hidden/internal or agenda item) // get state from agenda item (hidden/internal or agenda item)
$scope.formFields[i].defaultValue = !assignment.agenda_item.is_hidden; $scope.formFields[i].defaultValue = !assignment.agenda_item.is_hidden;
} else if($scope.formFields[i].key == 'agenda_parent_item_id') {
$scope.formFields[i].defaultValue = agenda_item.parent_id;
} }
} }
// save assignment // save assignment
$scope.save = function (assignment, gotoDetailView) { $scope.save = function (assignment, gotoDetailView) {
assignment.agenda_type = assignment.showAsAgendaItem ? 1 : 2;
// inject the changed assignment (copy) object back into DS store // inject the changed assignment (copy) object back into DS store
Assignment.inject(assignment); Assignment.inject(assignment);
// save change assignment object on server // save change assignment object on server
Assignment.save(assignment).then( Assignment.save(assignment).then(
function(success) { function(success) {
var changes = [{key: 'type', value: (assignment.showAsAgendaItem ? 1 : 2)},
{key: 'parent_id', value: assignment.agenda_parent_item_id}];
AgendaUpdate.saveChanges(success.agenda_item_id,changes);
if (gotoDetailView) { if (gotoDetailView) {
$state.go('assignments.assignment.detail', {id: success.id}); $state.go('assignments.assignment.detail', {id: success.id});
} }