Fix agenda item number

This commit is contained in:
FinnStutzenstein 2019-11-13 14:00:53 +01:00
parent e3e50c1730
commit a3c97a2ccd
13 changed files with 45 additions and 23 deletions

View File

@ -143,7 +143,7 @@ export class ItemRepositoryService extends BaseHasContentObjectRepository<
/**
* TODO: Copied from BaseRepository and added the cloned model to write back the
* item_number correctly. This must be reversed with #4738 (indroduced with #4639)
* item_number correctly. This must be reverted with #4738 (indroduced with #4639)
*
* Saves the (full) update to an existing model. So called "update"-function
* Provides a default procedure, but can be overwritten if required
@ -152,6 +152,7 @@ export class ItemRepositoryService extends BaseHasContentObjectRepository<
* @param viewModel the view model that the update is based on
*/
public async update(update: Partial<Item>, viewModel: ViewItem): Promise<void> {
(<any>update)._itemNumber = update.item_number;
const sendUpdate = viewModel.getUpdatedModel(update);
const clone = JSON.parse(JSON.stringify(sendUpdate));
clone.item_number = clone._itemNumber;

View File

@ -125,7 +125,7 @@ export class ListOfSpeakersRepositoryService extends BaseHasContentObjectReposit
// TODO: This can be resolved with #4738
const item = this.itemRepo.findByContentObject(titleInformation.contentObjectData);
if (item) {
(<any>titleInformation.title_information).agenda_item_number = item.item_number;
(<any>titleInformation.title_information).agenda_item_number = () => item.item_number;
}
return repo.getListOfSpeakersTitle(titleInformation.title_information);

View File

@ -54,7 +54,7 @@ export abstract class BaseIsAgendaItemAndListOfSpeakersContentObjectRepository<
public getAgendaListTitle(titleInformation: T): string {
// Return the agenda title with the model's verbose name appended
const numberPrefix = titleInformation.agenda_item_number ? `${titleInformation.agenda_item_number} · ` : '';
const numberPrefix = titleInformation.agenda_item_number() ? `${titleInformation.agenda_item_number()} · ` : '';
return numberPrefix + this.getTitle(titleInformation) + ' (' + this.getVerboseName() + ')';
}
@ -63,7 +63,7 @@ export abstract class BaseIsAgendaItemAndListOfSpeakersContentObjectRepository<
}
public getAgendaSlideTitle(titleInformation: T): string {
const numberPrefix = titleInformation.agenda_item_number ? `${titleInformation.agenda_item_number} · ` : '';
const numberPrefix = titleInformation.agenda_item_number() ? `${titleInformation.agenda_item_number()} · ` : '';
return numberPrefix + this.getTitle(titleInformation);
}

View File

@ -79,7 +79,7 @@ export abstract class BaseIsAgendaItemContentObjectRepository<
*/
public getAgendaListTitle(titleInformation: T): string {
// Return the agenda title with the model's verbose name appended
const numberPrefix = titleInformation.agenda_item_number ? `${titleInformation.agenda_item_number} · ` : '';
const numberPrefix = titleInformation.agenda_item_number() ? `${titleInformation.agenda_item_number()} · ` : '';
return numberPrefix + this.getTitle(titleInformation) + ' (' + this.getVerboseName() + ')';
}

View File

@ -252,7 +252,7 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo
};
public getAgendaSlideTitle = (titleInformation: MotionTitleInformation) => {
const numberPrefix = titleInformation.agenda_item_number ? `${titleInformation.agenda_item_number} · ` : '';
const numberPrefix = titleInformation.agenda_item_number() ? `${titleInformation.agenda_item_number()} · ` : '';
// if the identifier is set, the title will be 'Motion <identifier>'.
if (titleInformation.identifier) {
return numberPrefix + this.translate.instant('Motion') + ' ' + titleInformation.identifier;
@ -262,7 +262,7 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo
};
public getAgendaListTitle = (titleInformation: MotionTitleInformation) => {
const numberPrefix = titleInformation.agenda_item_number ? `${titleInformation.agenda_item_number} · ` : '';
const numberPrefix = titleInformation.agenda_item_number() ? `${titleInformation.agenda_item_number()} · ` : '';
// Append the verbose name only, if not the special format 'Motion <identifier>' is used.
if (titleInformation.identifier) {
return `${numberPrefix}${this.translate.instant('Motion')} ${titleInformation.identifier} · ${

View File

@ -52,8 +52,8 @@ export class TopicRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCon
}
public getTitle = (titleInformation: TopicTitleInformation) => {
if (titleInformation.agenda_item_number) {
return titleInformation.agenda_item_number + ' · ' + titleInformation.title;
if (titleInformation.agenda_item_number()) {
return titleInformation.agenda_item_number() + ' · ' + titleInformation.title;
} else {
return titleInformation.title;
}

View File

@ -30,7 +30,7 @@ export class Item extends BaseModelWithContentObject<Item> {
public set item_number(val: string) {
this._itemNumber = val;
if (this._titleInformation) {
this._titleInformation.agenda_item_number = this.item_number;
this._titleInformation.agenda_item_number = () => this.item_number;
}
}
public get title_information(): object {
@ -38,7 +38,7 @@ export class Item extends BaseModelWithContentObject<Item> {
}
public set title_information(val: object) {
this._titleInformation = val;
this._titleInformation.agenda_item_number = this.item_number;
this._titleInformation.agenda_item_number = () => this.item_number;
}
public comment: string;
public closed: boolean;

View File

@ -22,7 +22,7 @@ export function isBaseViewModelWithAgendaItem(obj: any): obj is BaseViewModelWit
}
export interface TitleInformationWithAgendaItem extends TitleInformation {
agenda_item_number?: string;
agenda_item_number?: () => string;
}
/**
@ -58,7 +58,7 @@ export interface BaseViewModelWithAgendaItem<M extends BaseModelWithAgendaItem =
export abstract class BaseViewModelWithAgendaItem<
M extends BaseModelWithAgendaItem = any
> extends BaseProjectableViewModel<M> {
public get agenda_item_number(): string | null {
public agenda_item_number(): string | null {
return this.item && this.item.item_number ? this.item.item_number : null;
}

View File

@ -7,7 +7,7 @@ import { ViewMediafile } from 'app/site/mediafiles/models/view-mediafile';
export interface TopicTitleInformation extends TitleInformationWithAgendaItem {
title: string;
agenda_item_number?: string;
agenda_item_number?: () => string;
}
/**

View File

@ -1,5 +1,10 @@
export interface SlideItem {
title_information: object;
title_information: {
collection: string;
depth: number;
_agenda_item_number: string;
agenda_item_number: () => string;
};
collection: string;
depth: number;
}

View File

@ -1,7 +1,9 @@
import { Component } from '@angular/core';
import { Component, Input } from '@angular/core';
import { CollectionStringMapperService } from 'app/core/core-services/collection-string-mapper.service';
import { SlideData } from 'app/core/core-services/projector-data.service';
import { isBaseIsAgendaItemContentObjectRepository } from 'app/core/repositories/base-is-agenda-item-content-object-repository';
import { ProjectorElement } from 'app/shared/models/core/projector';
import { BaseSlideComponent } from 'app/slides/base-slide-component';
import { ItemListSlideData, SlideItem } from './item-list-slide-data';
@ -11,6 +13,20 @@ import { ItemListSlideData, SlideItem } from './item-list-slide-data';
styleUrls: ['./item-list-slide.component.scss']
})
export class ItemListSlideComponent extends BaseSlideComponent<ItemListSlideData> {
@Input()
public set data(value: SlideData<ItemListSlideData, ProjectorElement>) {
value.data.items.forEach(
item => (item.title_information.agenda_item_number = () => item.title_information._agenda_item_number)
);
this._data = value;
}
public get data(): SlideData<ItemListSlideData, ProjectorElement> {
return this._data;
}
private _data: SlideData<ItemListSlideData, ProjectorElement>;
public constructor(private collectionStringMapperService: CollectionStringMapperService) {
super();
}

View File

@ -49,7 +49,7 @@ async def get_flat_tree(all_data: AllData, parent_id: int = 0) -> List[Dict[str,
for item_id in item_ids:
item = all_data["agenda/item"][item_id]
title_information = item["title_information"]
title_information["agenda_item_number"] = item["item_number"]
title_information["_agenda_item_number"] = item["item_number"]
tree.append(
{
"title_information": title_information,
@ -78,7 +78,7 @@ async def item_list_slide(
for item in await get_sorted_agenda_items(all_data):
if item["parent_id"] is None and item["type"] == 1:
title_information = item["title_information"]
title_information["agenda_item_number"] = item["item_number"]
title_information["_agenda_item_number"] = item["item_number"]
agenda_items.append(
{
"title_information": title_information,

View File

@ -95,11 +95,11 @@ async def test_main_items(all_data):
"items": [
{
"collection": "topics/topic",
"title_information": {"title": "item1", "agenda_item_number": ""},
"title_information": {"title": "item1", "_agenda_item_number": ""},
},
{
"collection": "topics/topic",
"title_information": {"title": "item2", "agenda_item_number": ""},
"title_information": {"title": "item2", "_agenda_item_number": ""},
},
]
}
@ -116,17 +116,17 @@ async def test_all_items(all_data):
{
"collection": "topics/topic",
"depth": 0,
"title_information": {"title": "item1", "agenda_item_number": ""},
"title_information": {"title": "item1", "_agenda_item_number": ""},
},
{
"collection": "topics/topic",
"depth": 1,
"title_information": {"title": "item4", "agenda_item_number": ""},
"title_information": {"title": "item4", "_agenda_item_number": ""},
},
{
"collection": "topics/topic",
"depth": 0,
"title_information": {"title": "item2", "agenda_item_number": ""},
"title_information": {"title": "item2", "_agenda_item_number": ""},
},
]
}