move to agenda

This commit is contained in:
FinnStutzenstein 2018-11-30 10:09:49 +01:00
parent 212bce1c08
commit 428e58db9b
3 changed files with 22 additions and 2 deletions

View File

@ -133,7 +133,7 @@
</button>
<div *osPerms="'motions.can_manage'">
<mat-divider></mat-divider>
<button mat-menu-item>
<button mat-menu-item (click)="multiselectWrapper(multiselectService.moveToItem(selectedRows))">
<!-- TODO: Not implemented yet -->
<mat-icon>sort</mat-icon>
<span translate>Move to agenda item</span>

View File

@ -179,6 +179,6 @@ export class MotionListComponent extends ListViewBaseComponent<ViewMotion> imple
* @param multiselectPromise The promise returned by multiselect actions.
*/
public multiselectWrapper(multiselectPromise: Promise<void>): void {
multiselectPromise.then(() => this.toggleMultiSelect());
multiselectPromise.then(() => this.toggleMultiSelect(), this.raiseError);
}
}

View File

@ -11,6 +11,9 @@ import { WorkflowRepositoryService } from './workflow-repository.service';
import { CategoryRepositoryService } from './category-repository.service';
import { TagRepositoryService } from 'app/site/tags/services/tag-repository.service';
import { HttpService } from 'app/core/services/http.service';
import { AgendaRepositoryService } from 'app/site/agenda/services/agenda-repository.service';
import { Displayable } from 'app/shared/models/base/displayable';
import { Identifiable } from 'app/shared/models/base/identifiable';
/**
* Contains all multiselect actions for the motion list view.
@ -40,6 +43,7 @@ export class MotionMultiselectService {
private workflowRepo: WorkflowRepositoryService,
private categoryRepo: CategoryRepositoryService,
private tagRepo: TagRepositoryService,
private agendaRepo: AgendaRepositoryService,
private httpService: HttpService
) {}
@ -57,6 +61,22 @@ export class MotionMultiselectService {
}
}
/**
* Moves the related agenda items from the motions as childs under a selected (parent) agenda item.
*/
public async moveToItem(motions: ViewMotion[]): Promise<void> {
const title = this.translate.instant('This will move all selected motions as childs to:');
const choices: (Displayable & Identifiable)[] = this.agendaRepo.getViewModelList();
const selectedChoice = await this.choiceService.open(title, choices);
if (selectedChoice) {
const requestData = {
items: motions.map(motion => motion.agenda_item_id),
parent_id: selectedChoice as number
};
await this.httpService.post('/rest/agenda/item/assign', requestData);
}
}
/**
* Opens a dialog and then sets the status for all motions.
*