Merge pull request #4313 from FinnStutzenstein/fixCalllist
Fixed calllist by removing the attached data from the tree (fixes #4296)
This commit is contained in:
commit
f7966df3ea
@ -234,7 +234,7 @@ export class ItemRepositoryService extends BaseRepository<ViewItem, Item> {
|
|||||||
*/
|
*/
|
||||||
public async delete(item: ViewItem): Promise<void> {
|
public async delete(item: ViewItem): Promise<void> {
|
||||||
const restUrl = `/rest/${item.contentObject.collectionString}/${item.contentObject.id}/`;
|
const restUrl = `/rest/${item.contentObject.collectionString}/${item.contentObject.id}/`;
|
||||||
return await this.httpService.delete(restUrl);
|
await this.httpService.delete(restUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -260,7 +260,7 @@ export class ItemRepositoryService extends BaseRepository<ViewItem, Item> {
|
|||||||
*
|
*
|
||||||
* @param data The reordered data from the sorting
|
* @param data The reordered data from the sorting
|
||||||
*/
|
*/
|
||||||
public async sortItems(data: OSTreeSortEvent<ViewItem>): Promise<void> {
|
public async sortItems(data: OSTreeSortEvent): Promise<void> {
|
||||||
const url = '/rest/agenda/item/sort/';
|
const url = '/rest/agenda/item/sort/';
|
||||||
await this.httpService.post(url, data);
|
await this.httpService.post(url, data);
|
||||||
}
|
}
|
||||||
|
@ -314,7 +314,7 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
|
|||||||
*
|
*
|
||||||
* @param data The reordered data from the sorting
|
* @param data The reordered data from the sorting
|
||||||
*/
|
*/
|
||||||
public async sortMotions(data: OSTreeSortEvent<ViewMotion>): Promise<void> {
|
public async sortMotions(data: OSTreeSortEvent): Promise<void> {
|
||||||
const url = '/rest/motions/motion/sort/';
|
const url = '/rest/motions/motion/sort/';
|
||||||
await this.httpService.post(url, data);
|
await this.httpService.post(url, data);
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,18 @@ import { Displayable } from 'app/site/base/displayable';
|
|||||||
import { Identifiable } from 'app/shared/models/base/identifiable';
|
import { Identifiable } from 'app/shared/models/base/identifiable';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A representation of nodes in our tree. Saves the displayed name, the id, the element and children to build a full tree.
|
* A basic representation of a tree node. This node does not stores any data.
|
||||||
*/
|
*/
|
||||||
export interface OSTreeNode<T> {
|
export interface OSTreeNodeWithoutItem {
|
||||||
name: string;
|
name: string;
|
||||||
id: number;
|
id: number;
|
||||||
|
children?: OSTreeNodeWithoutItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A representation of nodes with the item atached.
|
||||||
|
*/
|
||||||
|
export interface OSTreeNode<T> extends OSTreeNodeWithoutItem {
|
||||||
item: T;
|
item: T;
|
||||||
children?: OSTreeNode<T>[];
|
children?: OSTreeNode<T>[];
|
||||||
}
|
}
|
||||||
@ -113,6 +120,25 @@ export class TreeService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes `item` from the tree.
|
||||||
|
*
|
||||||
|
* @param tree The tree with items
|
||||||
|
* @returns The tree without items
|
||||||
|
*/
|
||||||
|
public stripTree<T>(tree: OSTreeNode<T>[]): OSTreeNodeWithoutItem[] {
|
||||||
|
return tree.map(node => {
|
||||||
|
const nodeWithoutItem: OSTreeNodeWithoutItem = {
|
||||||
|
name: node.name,
|
||||||
|
id: node.id
|
||||||
|
};
|
||||||
|
if (node.children) {
|
||||||
|
nodeWithoutItem.children = this.stripTree(node.children);
|
||||||
|
}
|
||||||
|
return nodeWithoutItem;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Traverses items in pre-order givem (implicit) by the weight and parentId.
|
* Traverses items in pre-order givem (implicit) by the weight and parentId.
|
||||||
*
|
*
|
||||||
|
@ -7,16 +7,16 @@ import { Subscription, Observable } from 'rxjs';
|
|||||||
|
|
||||||
import { Identifiable } from 'app/shared/models/base/identifiable';
|
import { Identifiable } from 'app/shared/models/base/identifiable';
|
||||||
import { Displayable } from 'app/site/base/displayable';
|
import { Displayable } from 'app/site/base/displayable';
|
||||||
import { OSTreeNode, TreeService } from 'app/core/ui-services/tree.service';
|
import { OSTreeNode, TreeService, OSTreeNodeWithoutItem } from 'app/core/ui-services/tree.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The data representation for the sort event.
|
* The data representation for the sort event.
|
||||||
*/
|
*/
|
||||||
export interface OSTreeSortEvent<T> {
|
export interface OSTreeSortEvent {
|
||||||
/**
|
/**
|
||||||
* Gives all nodes to be inserted below the parent_id.
|
* Gives all nodes to be inserted below the parent_id.
|
||||||
*/
|
*/
|
||||||
nodes: OSTreeNode<T>[];
|
nodes: OSTreeNodeWithoutItem[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the parent id for the nodes array. Do not provide it, if it's the
|
* Provides the parent id for the nodes array. Do not provide it, if it's the
|
||||||
@ -85,7 +85,7 @@ export class SortingTreeComponent<T extends Identifiable & Displayable> implemen
|
|||||||
* sorted part of the tree.
|
* sorted part of the tree.
|
||||||
*/
|
*/
|
||||||
@Output()
|
@Output()
|
||||||
public readonly sort = new EventEmitter<OSTreeSortEvent<T>>();
|
public readonly sort = new EventEmitter<OSTreeSortEvent>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options for the tree. As a default drag and drop is allowed.
|
* Options for the tree. As a default drag and drop is allowed.
|
||||||
@ -159,6 +159,7 @@ export class SortingTreeComponent<T extends Identifiable & Displayable> implemen
|
|||||||
to.parent.data.children = [];
|
to.parent.data.children = [];
|
||||||
}
|
}
|
||||||
transferArrayItem(fromArray, to.parent.data.children, from.index, to.index);
|
transferArrayItem(fromArray, to.parent.data.children, from.index, to.index);
|
||||||
this.sort.emit({ nodes: to.parent.data.children, parent_id: parentId });
|
const strippedNodes = this.treeService.stripTree(to.parent.data.children);
|
||||||
|
this.sort.emit({ nodes: strippedNodes, parent_id: parentId });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ export class AgendaSortComponent extends BaseViewComponent {
|
|||||||
* @param data The event data. The representation fits the servers requirements, so it can directly
|
* @param data The event data. The representation fits the servers requirements, so it can directly
|
||||||
* be send to the server via the repository.
|
* be send to the server via the repository.
|
||||||
*/
|
*/
|
||||||
public sort(data: OSTreeSortEvent<ViewItem>): void {
|
public sort(data: OSTreeSortEvent): void {
|
||||||
this.agendaRepo.sortItems(data).then(null, this.raiseError);
|
this.agendaRepo.sortItems(data).then(null, this.raiseError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import { BaseViewComponent } from '../../../base/base-view';
|
|||||||
import { MotionRepositoryService } from 'app/core/repositories/motions/motion-repository.service';
|
import { MotionRepositoryService } from 'app/core/repositories/motions/motion-repository.service';
|
||||||
import { MotionCsvExportService } from '../../services/motion-csv-export.service';
|
import { MotionCsvExportService } from '../../services/motion-csv-export.service';
|
||||||
import { MotionPdfExportService } from '../../services/motion-pdf-export.service';
|
import { MotionPdfExportService } from '../../services/motion-pdf-export.service';
|
||||||
|
|
||||||
import { ViewMotion } from '../../models/view-motion';
|
import { ViewMotion } from '../../models/view-motion';
|
||||||
import { OSTreeSortEvent } from 'app/shared/components/sorting-tree/sorting-tree.component';
|
import { OSTreeSortEvent } from 'app/shared/components/sorting-tree/sorting-tree.component';
|
||||||
|
|
||||||
@ -67,7 +66,7 @@ export class CallListComponent extends BaseViewComponent {
|
|||||||
* @param data The event data. The representation fits the servers requirements, so it can directly
|
* @param data The event data. The representation fits the servers requirements, so it can directly
|
||||||
* be send to the server via the repository.
|
* be send to the server via the repository.
|
||||||
*/
|
*/
|
||||||
public sort(data: OSTreeSortEvent<ViewMotion>): void {
|
public sort(data: OSTreeSortEvent): void {
|
||||||
this.motionRepo.sortMotions(data).then(null, this.raiseError);
|
this.motionRepo.sortMotions(data).then(null, this.raiseError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user