translate models
This commit is contained in:
parent
76210e807f
commit
424e7945be
@ -19,6 +19,7 @@ import { BaseAgendaViewModel } from 'app/site/base/base-agenda-view-model';
|
|||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
import { BaseViewModel } from 'app/site/base/base-view-model';
|
import { BaseViewModel } from 'app/site/base/base-view-model';
|
||||||
import { ViewUser } from 'app/site/users/models/view-user';
|
import { ViewUser } from 'app/site/users/models/view-user';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository service for users
|
* Repository service for users
|
||||||
@ -46,11 +47,39 @@ export class ItemRepositoryService extends BaseRepository<ViewItem, Item> {
|
|||||||
private httpService: HttpService,
|
private httpService: HttpService,
|
||||||
private config: ConfigService,
|
private config: ConfigService,
|
||||||
private dataSend: DataSendService,
|
private dataSend: DataSendService,
|
||||||
private treeService: TreeService
|
private treeService: TreeService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, Item);
|
super(DS, mapperService, viewModelStoreService, Item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected setupDependencyObservation(): void {
|
||||||
|
this.DS.secondaryModelChangeSubject.subscribe(model => {
|
||||||
|
const viewModel = this.viewModelStoreService.get(model.collectionString, model.id);
|
||||||
|
const somethingChanged = this.getViewModelList().some(ownViewModel => {
|
||||||
|
return ownViewModel.updateDependencies(viewModel);
|
||||||
|
});
|
||||||
|
if (somethingChanged) {
|
||||||
|
this.updateAllObservables(model.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the viewItem out of a given item
|
||||||
|
*
|
||||||
|
* @param item the item that should be converted to view item
|
||||||
|
* @returns a new view item
|
||||||
|
*/
|
||||||
|
public createViewModel(item: Item): ViewItem {
|
||||||
|
const contentObject = this.getContentObject(item);
|
||||||
|
const viewItem = new ViewItem(item, contentObject);
|
||||||
|
viewItem.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Items' : 'Item');
|
||||||
|
};
|
||||||
|
return viewItem;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the corresponding content object to a given {@link Item} as an {@link AgendaBaseViewModel}
|
* Returns the corresponding content object to a given {@link Item} as an {@link AgendaBaseViewModel}
|
||||||
* Used dynamically because of heavy race conditions
|
* Used dynamically because of heavy race conditions
|
||||||
@ -216,17 +245,6 @@ export class ItemRepositoryService extends BaseRepository<ViewItem, Item> {
|
|||||||
throw new Error('Method not implemented.');
|
throw new Error('Method not implemented.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the viewItem out of a given item
|
|
||||||
*
|
|
||||||
* @param item the item that should be converted to view item
|
|
||||||
* @returns a new view item
|
|
||||||
*/
|
|
||||||
public createViewModel(item: Item): ViewItem {
|
|
||||||
const contentObject = this.getContentObject(item);
|
|
||||||
return new ViewItem(item, contentObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get agenda visibility from the config
|
* Get agenda visibility from the config
|
||||||
*
|
*
|
||||||
|
@ -13,6 +13,7 @@ import { CreateTopic } from 'app/site/agenda/models/create-topic';
|
|||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
import { ViewMediafile } from 'app/site/mediafiles/models/view-mediafile';
|
import { ViewMediafile } from 'app/site/mediafiles/models/view-mediafile';
|
||||||
import { ViewItem } from 'app/site/agenda/models/view-item';
|
import { ViewItem } from 'app/site/agenda/models/view-item';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository for topics
|
* Repository for topics
|
||||||
@ -32,7 +33,8 @@ export class TopicRepositoryService extends BaseRepository<ViewTopic, Topic> {
|
|||||||
DS: DataStoreService,
|
DS: DataStoreService,
|
||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
viewModelStoreService: ViewModelStoreService,
|
viewModelStoreService: ViewModelStoreService,
|
||||||
private dataSend: DataSendService
|
private dataSend: DataSendService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, Topic, [Mediafile, Item]);
|
super(DS, mapperService, viewModelStoreService, Topic, [Mediafile, Item]);
|
||||||
}
|
}
|
||||||
@ -46,7 +48,11 @@ export class TopicRepositoryService extends BaseRepository<ViewTopic, Topic> {
|
|||||||
public createViewModel(topic: Topic): ViewTopic {
|
public createViewModel(topic: Topic): ViewTopic {
|
||||||
const attachments = this.viewModelStoreService.getMany(ViewMediafile, topic.attachments_id);
|
const attachments = this.viewModelStoreService.getMany(ViewMediafile, topic.attachments_id);
|
||||||
const item = this.viewModelStoreService.get(ViewItem, topic.agenda_item_id);
|
const item = this.viewModelStoreService.get(ViewItem, topic.agenda_item_id);
|
||||||
return new ViewTopic(topic, attachments, item);
|
const viewTopic = new ViewTopic(topic, attachments, item);
|
||||||
|
viewTopic.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Topics' : 'Topic');
|
||||||
|
};
|
||||||
|
return viewTopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,6 +12,7 @@ import { ViewModelStoreService } from 'app/core/core-services/view-model-store.s
|
|||||||
import { ViewItem } from 'app/site/agenda/models/view-item';
|
import { ViewItem } from 'app/site/agenda/models/view-item';
|
||||||
import { ViewUser } from 'app/site/users/models/view-user';
|
import { ViewUser } from 'app/site/users/models/view-user';
|
||||||
import { ViewTag } from 'app/site/tags/models/view-tag';
|
import { ViewTag } from 'app/site/tags/models/view-tag';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository Service for Assignments.
|
* Repository Service for Assignments.
|
||||||
@ -31,11 +32,24 @@ export class AssignmentRepositoryService extends BaseRepository<ViewAssignment,
|
|||||||
public constructor(
|
public constructor(
|
||||||
DS: DataStoreService,
|
DS: DataStoreService,
|
||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
viewModelStoreService: ViewModelStoreService
|
viewModelStoreService: ViewModelStoreService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, Assignment, [User, Item, Tag]);
|
super(DS, mapperService, viewModelStoreService, Assignment, [User, Item, Tag]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public createViewModel(assignment: Assignment): ViewAssignment {
|
||||||
|
const relatedUser = this.viewModelStoreService.getMany(ViewUser, assignment.candidateIds);
|
||||||
|
const agendaItem = this.viewModelStoreService.get(ViewItem, assignment.agenda_item_id);
|
||||||
|
const tags = this.viewModelStoreService.getMany(ViewTag, assignment.tags_id);
|
||||||
|
|
||||||
|
const viewAssignment = new ViewAssignment(assignment, relatedUser, agendaItem, tags);
|
||||||
|
viewAssignment.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Elections' : 'Election');
|
||||||
|
};
|
||||||
|
return viewAssignment;
|
||||||
|
}
|
||||||
|
|
||||||
public async update(assignment: Partial<Assignment>, viewAssignment: ViewAssignment): Promise<void> {
|
public async update(assignment: Partial<Assignment>, viewAssignment: ViewAssignment): Promise<void> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -47,12 +61,4 @@ export class AssignmentRepositoryService extends BaseRepository<ViewAssignment,
|
|||||||
public async create(assignment: Assignment): Promise<Identifiable> {
|
public async create(assignment: Assignment): Promise<Identifiable> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public createViewModel(assignment: Assignment): ViewAssignment {
|
|
||||||
const relatedUser = this.viewModelStoreService.getMany(ViewUser, assignment.candidateIds);
|
|
||||||
const agendaItem = this.viewModelStoreService.get(ViewItem, assignment.agenda_item_id);
|
|
||||||
const tags = this.viewModelStoreService.getMany(ViewTag, assignment.tags_id);
|
|
||||||
|
|
||||||
return new ViewAssignment(assignment, relatedUser, agendaItem, tags);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,24 @@ export abstract class BaseRepository<V extends BaseViewModel, M extends BaseMode
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.setupDependencyObservation();
|
||||||
|
|
||||||
|
// Watch the Observables for deleting
|
||||||
|
// TODO: What happens, if some related object was deleted?
|
||||||
|
// My quess: This must trigger an autoupdate also for this model, because some IDs changed, so the
|
||||||
|
// affected models will be newly created by the primaryModelChangeSubject.
|
||||||
|
this.DS.deletedObservable.subscribe(model => {
|
||||||
|
if (
|
||||||
|
model.collection ===
|
||||||
|
this.collectionStringMapperService.getCollectionStringFromModelConstructor(this.baseModelCtor)
|
||||||
|
) {
|
||||||
|
delete this.viewModelStore[model.id];
|
||||||
|
this.updateAllObservables(model.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected setupDependencyObservation(): void {
|
||||||
if (this.depsModelCtors) {
|
if (this.depsModelCtors) {
|
||||||
this.DS.secondaryModelChangeSubject.subscribe(model => {
|
this.DS.secondaryModelChangeSubject.subscribe(model => {
|
||||||
const dependencyChanged: boolean = this.depsModelCtors.some(ctor => {
|
const dependencyChanged: boolean = this.depsModelCtors.some(ctor => {
|
||||||
@ -94,20 +112,6 @@ export abstract class BaseRepository<V extends BaseViewModel, M extends BaseMode
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watch the Observables for deleting
|
|
||||||
// TODO: What happens, if some related object was deleted?
|
|
||||||
// My quess: This must trigger an autoupdate also for this model, because some IDs changed, so the
|
|
||||||
// affected models will be newly created by the primaryModelChangeSubject.
|
|
||||||
this.DS.deletedObservable.subscribe(model => {
|
|
||||||
if (
|
|
||||||
model.collection ===
|
|
||||||
this.collectionStringMapperService.getCollectionStringFromModelConstructor(this.baseModelCtor)
|
|
||||||
) {
|
|
||||||
delete this.viewModelStore[model.id];
|
|
||||||
this.updateAllObservables(model.id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,6 +6,7 @@ import { CollectionStringMapperService } from '../../core-services/collectionStr
|
|||||||
import { ChatMessage } from 'app/shared/models/core/chat-message';
|
import { ChatMessage } from 'app/shared/models/core/chat-message';
|
||||||
import { ViewChatMessage } from 'app/site/common/models/view-chatmessage';
|
import { ViewChatMessage } from 'app/site/common/models/view-chatmessage';
|
||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -14,13 +15,18 @@ export class ChatMessageRepositoryService extends BaseRepository<ViewChatMessage
|
|||||||
public constructor(
|
public constructor(
|
||||||
DS: DataStoreService,
|
DS: DataStoreService,
|
||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
viewModelStoreService: ViewModelStoreService
|
viewModelStoreService: ViewModelStoreService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, ChatMessage);
|
super(DS, mapperService, viewModelStoreService, ChatMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createViewModel(message: ChatMessage): ViewChatMessage {
|
protected createViewModel(message: ChatMessage): ViewChatMessage {
|
||||||
return new ViewChatMessage(message);
|
const viewChatMessage = new ViewChatMessage(message);
|
||||||
|
viewChatMessage.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Chatmessages' : 'Chatmessage');
|
||||||
|
};
|
||||||
|
return viewChatMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async create(message: ChatMessage): Promise<Identifiable> {
|
public async create(message: ChatMessage): Promise<Identifiable> {
|
||||||
|
@ -11,6 +11,7 @@ import { Identifiable } from 'app/shared/models/base/identifiable';
|
|||||||
import { CollectionStringMapperService } from 'app/core/core-services/collectionStringMapper.service';
|
import { CollectionStringMapperService } from 'app/core/core-services/collectionStringMapper.service';
|
||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
import { ViewConfig } from 'app/site/config/models/view-config';
|
import { ViewConfig } from 'app/site/config/models/view-config';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds a single config item.
|
* Holds a single config item.
|
||||||
@ -99,7 +100,8 @@ export class ConfigRepositoryService extends BaseRepository<ViewConfig, Config>
|
|||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
viewModelStoreService: ViewModelStoreService,
|
viewModelStoreService: ViewModelStoreService,
|
||||||
private constantsService: ConstantsService,
|
private constantsService: ConstantsService,
|
||||||
private http: HttpService
|
private http: HttpService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, Config);
|
super(DS, mapperService, viewModelStoreService, Config);
|
||||||
|
|
||||||
@ -110,6 +112,18 @@ export class ConfigRepositoryService extends BaseRepository<ViewConfig, Config>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ViewConfig of a given Config object
|
||||||
|
* @param config
|
||||||
|
*/
|
||||||
|
public createViewModel(config: Config): ViewConfig {
|
||||||
|
const viewConfig = new ViewConfig(config);
|
||||||
|
viewConfig.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Configs' : 'Config');
|
||||||
|
};
|
||||||
|
return viewConfig;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overwritten setup. Does only care about the custom list observable and inserts changed configs into the
|
* Overwritten setup. Does only care about the custom list observable and inserts changed configs into the
|
||||||
* config group structure.
|
* config group structure.
|
||||||
@ -223,14 +237,6 @@ export class ConfigRepositoryService extends BaseRepository<ViewConfig, Config>
|
|||||||
throw new Error('Config variables cannot be created');
|
throw new Error('Config variables cannot be created');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new ViewConfig of a given Config object
|
|
||||||
* @param config
|
|
||||||
*/
|
|
||||||
public createViewModel(config: Config): ViewConfig {
|
|
||||||
return new ViewConfig(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initially create the config structure from the given constant.
|
* initially create the config structure from the given constant.
|
||||||
* @param constant
|
* @param constant
|
||||||
|
@ -11,6 +11,7 @@ import { ViewHistory } from 'app/site/history/models/view-history';
|
|||||||
import { TimeTravelService } from 'app/core/core-services/time-travel.service';
|
import { TimeTravelService } from 'app/core/core-services/time-travel.service';
|
||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
import { ViewUser } from 'app/site/users/models/view-user';
|
import { ViewUser } from 'app/site/users/models/view-user';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository for the history.
|
* Repository for the history.
|
||||||
@ -34,11 +35,27 @@ export class HistoryRepositoryService extends BaseRepository<ViewHistory, Histor
|
|||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
viewModelStoreService: ViewModelStoreService,
|
viewModelStoreService: ViewModelStoreService,
|
||||||
private httpService: HttpService,
|
private httpService: HttpService,
|
||||||
private timeTravel: TimeTravelService
|
private timeTravel: TimeTravelService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, History, [User]);
|
super(DS, mapperService, viewModelStoreService, History, [User]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ViewHistory objects out of a historyObject
|
||||||
|
*
|
||||||
|
* @param history the source history object
|
||||||
|
* @return a new ViewHistory object
|
||||||
|
*/
|
||||||
|
public createViewModel(history: History): ViewHistory {
|
||||||
|
const user = this.viewModelStoreService.get(ViewUser, history.user_id);
|
||||||
|
const viewHistory = new ViewHistory(history, user);
|
||||||
|
viewHistory.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Histories' : 'History'); // Whats about the plural case??
|
||||||
|
};
|
||||||
|
return viewHistory;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clients usually do not need to create a history object themselves
|
* Clients usually do not need to create a history object themselves
|
||||||
* @ignore
|
* @ignore
|
||||||
@ -79,17 +96,6 @@ export class HistoryRepositoryService extends BaseRepository<ViewHistory, Histor
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new ViewHistory objects out of a historyObject
|
|
||||||
*
|
|
||||||
* @param history the source history object
|
|
||||||
* @return a new ViewHistory object
|
|
||||||
*/
|
|
||||||
public createViewModel(history: History): ViewHistory {
|
|
||||||
const user = this.viewModelStoreService.get(ViewUser, history.user_id);
|
|
||||||
return new ViewHistory(history, user);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the full data on the given date and use the
|
* Get the full data on the given date and use the
|
||||||
* TimeTravelService to browse the history on the
|
* TimeTravelService to browse the history on the
|
||||||
|
@ -12,6 +12,7 @@ import { HttpService } from 'app/core/core-services/http.service';
|
|||||||
import { HttpHeaders } from '@angular/common/http';
|
import { HttpHeaders } from '@angular/common/http';
|
||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
import { ViewUser } from 'app/site/users/models/view-user';
|
import { ViewUser } from 'app/site/users/models/view-user';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository for MediaFiles
|
* Repository for MediaFiles
|
||||||
@ -32,11 +33,27 @@ export class MediafileRepositoryService extends BaseRepository<ViewMediafile, Me
|
|||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
viewModelStoreService: ViewModelStoreService,
|
viewModelStoreService: ViewModelStoreService,
|
||||||
private dataSend: DataSendService,
|
private dataSend: DataSendService,
|
||||||
private httpService: HttpService
|
private httpService: HttpService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, Mediafile, [User]);
|
super(DS, mapperService, viewModelStoreService, Mediafile, [User]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates mediafile ViewModels out of given mediafile objects
|
||||||
|
*
|
||||||
|
* @param file mediafile to convert
|
||||||
|
* @returns a new mediafile ViewModel
|
||||||
|
*/
|
||||||
|
public createViewModel(file: Mediafile): ViewMediafile {
|
||||||
|
const uploader = this.viewModelStoreService.get(ViewUser, file.uploader_id);
|
||||||
|
const viewMediafile = new ViewMediafile(file, uploader);
|
||||||
|
viewMediafile.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Files' : 'File');
|
||||||
|
};
|
||||||
|
return viewMediafile;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alter a given mediaFile
|
* Alter a given mediaFile
|
||||||
* Usually just i.e change the name and the hidden flag.
|
* Usually just i.e change the name and the hidden flag.
|
||||||
@ -83,15 +100,4 @@ export class MediafileRepositoryService extends BaseRepository<ViewMediafile, Me
|
|||||||
const emptyHeader = new HttpHeaders();
|
const emptyHeader = new HttpHeaders();
|
||||||
return this.httpService.post<Identifiable>(restPath, file, {}, emptyHeader);
|
return this.httpService.post<Identifiable>(restPath, file, {}, emptyHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates mediafile ViewModels out of given mediafile objects
|
|
||||||
*
|
|
||||||
* @param file mediafile to convert
|
|
||||||
* @returns a new mediafile ViewModel
|
|
||||||
*/
|
|
||||||
public createViewModel(file: Mediafile): ViewMediafile {
|
|
||||||
const uploader = this.viewModelStoreService.get(ViewUser, file.uploader_id);
|
|
||||||
return new ViewMediafile(file, uploader);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { BehaviorSubject, Observable } from 'rxjs';
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
@ -53,7 +54,11 @@ export class CategoryRepositoryService extends BaseRepository<ViewCategory, Cate
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected createViewModel(category: Category): ViewCategory {
|
protected createViewModel(category: Category): ViewCategory {
|
||||||
return new ViewCategory(category);
|
const viewCategory = new ViewCategory(category);
|
||||||
|
viewCategory.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Categories' : 'Category');
|
||||||
|
};
|
||||||
|
return viewCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async create(newCategory: Category): Promise<Identifiable> {
|
public async create(newCategory: Category): Promise<Identifiable> {
|
||||||
|
@ -14,6 +14,7 @@ import { ViewMotionChangeRecommendation } from 'app/site/motions/models/view-cha
|
|||||||
import { Identifiable } from 'app/shared/models/base/identifiable';
|
import { Identifiable } from 'app/shared/models/base/identifiable';
|
||||||
import { CollectionStringMapperService } from 'app/core/core-services/collectionStringMapper.service';
|
import { CollectionStringMapperService } from 'app/core/core-services/collectionStringMapper.service';
|
||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository Services for change recommendations
|
* Repository Services for change recommendations
|
||||||
@ -46,11 +47,25 @@ export class ChangeRecommendationRepositoryService extends BaseRepository<
|
|||||||
DS: DataStoreService,
|
DS: DataStoreService,
|
||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
viewModelStoreService: ViewModelStoreService,
|
viewModelStoreService: ViewModelStoreService,
|
||||||
private dataSend: DataSendService
|
private dataSend: DataSendService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, MotionChangeRecommendation, [Category, User, Workflow]);
|
super(DS, mapperService, viewModelStoreService, MotionChangeRecommendation, [Category, User, Workflow]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates this view wrapper based on an actual Change Recommendation model
|
||||||
|
*
|
||||||
|
* @param {MotionChangeRecommendation} model
|
||||||
|
*/
|
||||||
|
protected createViewModel(model: MotionChangeRecommendation): ViewMotionChangeRecommendation {
|
||||||
|
const viewMotionChangeRecommendation = new ViewMotionChangeRecommendation(model);
|
||||||
|
viewMotionChangeRecommendation.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Change recommendations' : 'Change recommendation');
|
||||||
|
};
|
||||||
|
return viewMotionChangeRecommendation;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a change recommendation
|
* Creates a change recommendation
|
||||||
* Creates a (real) change recommendation and delegates it to the {@link DataSendService}
|
* Creates a (real) change recommendation and delegates it to the {@link DataSendService}
|
||||||
@ -70,15 +85,6 @@ export class ChangeRecommendationRepositoryService extends BaseRepository<
|
|||||||
return await this.dataSend.createModel(view.changeRecommendation);
|
return await this.dataSend.createModel(view.changeRecommendation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates this view wrapper based on an actual Change Recommendation model
|
|
||||||
*
|
|
||||||
* @param {MotionChangeRecommendation} model
|
|
||||||
*/
|
|
||||||
protected createViewModel(model: MotionChangeRecommendation): ViewMotionChangeRecommendation {
|
|
||||||
return new ViewMotionChangeRecommendation(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deleting a change recommendation.
|
* Deleting a change recommendation.
|
||||||
*
|
*
|
||||||
|
@ -17,6 +17,7 @@ import { ViewMotionBlock } from 'app/site/motions/models/view-motion-block';
|
|||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
import { Item } from 'app/shared/models/agenda/item';
|
import { Item } from 'app/shared/models/agenda/item';
|
||||||
import { ViewItem } from 'app/site/agenda/models/view-item';
|
import { ViewItem } from 'app/site/agenda/models/view-item';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository service for motion blocks
|
* Repository service for motion blocks
|
||||||
@ -40,11 +41,27 @@ export class MotionBlockRepositoryService extends BaseRepository<ViewMotionBlock
|
|||||||
viewModelStoreService: ViewModelStoreService,
|
viewModelStoreService: ViewModelStoreService,
|
||||||
private dataSend: DataSendService,
|
private dataSend: DataSendService,
|
||||||
private motionRepo: MotionRepositoryService,
|
private motionRepo: MotionRepositoryService,
|
||||||
private httpService: HttpService
|
private httpService: HttpService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, MotionBlock, [Item]);
|
super(DS, mapperService, viewModelStoreService, MotionBlock, [Item]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a given motion block into a ViewModel
|
||||||
|
*
|
||||||
|
* @param block a motion block
|
||||||
|
* @returns a new ViewMotionBlock
|
||||||
|
*/
|
||||||
|
protected createViewModel(block: MotionBlock): ViewMotionBlock {
|
||||||
|
const item = this.viewModelStoreService.get(ViewItem, block.agenda_item_id);
|
||||||
|
const viewMotionBlock = new ViewMotionBlock(block, item);
|
||||||
|
viewMotionBlock.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Motion blocks' : 'Motion block');
|
||||||
|
};
|
||||||
|
return viewMotionBlock;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a given motion block
|
* Updates a given motion block
|
||||||
*
|
*
|
||||||
@ -77,17 +94,6 @@ export class MotionBlockRepositoryService extends BaseRepository<ViewMotionBlock
|
|||||||
return await this.dataSend.createModel(newBlock);
|
return await this.dataSend.createModel(newBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a given motion block into a ViewModel
|
|
||||||
*
|
|
||||||
* @param block a motion block
|
|
||||||
* @returns a new ViewMotionBlock
|
|
||||||
*/
|
|
||||||
protected createViewModel(block: MotionBlock): ViewMotionBlock {
|
|
||||||
const item = this.viewModelStoreService.get(ViewItem, block.agenda_item_id);
|
|
||||||
return new ViewMotionBlock(block, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the motion block id from the given motion
|
* Removes the motion block id from the given motion
|
||||||
*
|
*
|
||||||
|
@ -11,6 +11,7 @@ import { CollectionStringMapperService } from '../../core-services/collectionStr
|
|||||||
import { HttpService } from 'app/core/core-services/http.service';
|
import { HttpService } from 'app/core/core-services/http.service';
|
||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
import { ViewGroup } from 'app/site/users/models/view-group';
|
import { ViewGroup } from 'app/site/users/models/view-group';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository Services for Categories
|
* Repository Services for Categories
|
||||||
@ -44,7 +45,8 @@ export class MotionCommentSectionRepositoryService extends BaseRepository<
|
|||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
viewModelStoreService: ViewModelStoreService,
|
viewModelStoreService: ViewModelStoreService,
|
||||||
private dataSend: DataSendService,
|
private dataSend: DataSendService,
|
||||||
private http: HttpService
|
private http: HttpService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, MotionCommentSection, [Group]);
|
super(DS, mapperService, viewModelStoreService, MotionCommentSection, [Group]);
|
||||||
}
|
}
|
||||||
@ -58,7 +60,11 @@ export class MotionCommentSectionRepositoryService extends BaseRepository<
|
|||||||
protected createViewModel(section: MotionCommentSection): ViewMotionCommentSection {
|
protected createViewModel(section: MotionCommentSection): ViewMotionCommentSection {
|
||||||
const readGroups = this.viewModelStoreService.getMany(ViewGroup, section.read_groups_id);
|
const readGroups = this.viewModelStoreService.getMany(ViewGroup, section.read_groups_id);
|
||||||
const writeGroups = this.viewModelStoreService.getMany(ViewGroup, section.write_groups_id);
|
const writeGroups = this.viewModelStoreService.getMany(ViewGroup, section.write_groups_id);
|
||||||
return new ViewMotionCommentSection(section, readGroups, writeGroups);
|
const viewMotionCommentSection = new ViewMotionCommentSection(section, readGroups, writeGroups);
|
||||||
|
viewMotionCommentSection.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Comment sections' : 'Comment section');
|
||||||
|
};
|
||||||
|
return viewMotionCommentSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,7 +114,7 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
|
|||||||
if (workflow) {
|
if (workflow) {
|
||||||
state = workflow.getStateById(motion.state_id);
|
state = workflow.getStateById(motion.state_id);
|
||||||
}
|
}
|
||||||
return new ViewMotion(
|
const viewMotion = new ViewMotion(
|
||||||
motion,
|
motion,
|
||||||
category,
|
category,
|
||||||
submitters,
|
submitters,
|
||||||
@ -127,6 +127,26 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
|
|||||||
tags,
|
tags,
|
||||||
parent
|
parent
|
||||||
);
|
);
|
||||||
|
viewMotion.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Motions' : 'Motion');
|
||||||
|
};
|
||||||
|
viewMotion.getAgendaTitle = () => {
|
||||||
|
// if the identifier is set, the title will be 'Motion <identifier>'.
|
||||||
|
if (viewMotion.identifier) {
|
||||||
|
return this.translate.instant('Motion') + ' ' + viewMotion.identifier;
|
||||||
|
} else {
|
||||||
|
return viewMotion.getTitle();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
viewMotion.getAgendaTitleWithType = () => {
|
||||||
|
// Append the verbose name only, if not the special format 'Motion <identifier>' is used.
|
||||||
|
if (viewMotion.identifier) {
|
||||||
|
return this.translate.instant('Motion') + ' ' + viewMotion.identifier;
|
||||||
|
} else {
|
||||||
|
return viewMotion.getTitle() + ' (' + viewMotion.getVerboseName() + ')';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return viewMotion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,6 +8,7 @@ import { StatuteParagraph } from 'app/shared/models/motions/statute-paragraph';
|
|||||||
import { Identifiable } from 'app/shared/models/base/identifiable';
|
import { Identifiable } from 'app/shared/models/base/identifiable';
|
||||||
import { CollectionStringMapperService } from '../../core-services/collectionStringMapper.service';
|
import { CollectionStringMapperService } from '../../core-services/collectionStringMapper.service';
|
||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository Services for statute paragraphs
|
* Repository Services for statute paragraphs
|
||||||
@ -33,13 +34,18 @@ export class StatuteParagraphRepositoryService extends BaseRepository<ViewStatut
|
|||||||
DS: DataStoreService,
|
DS: DataStoreService,
|
||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
viewModelStoreService: ViewModelStoreService,
|
viewModelStoreService: ViewModelStoreService,
|
||||||
private dataSend: DataSendService
|
private dataSend: DataSendService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, StatuteParagraph);
|
super(DS, mapperService, viewModelStoreService, StatuteParagraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createViewModel(statuteParagraph: StatuteParagraph): ViewStatuteParagraph {
|
protected createViewModel(statuteParagraph: StatuteParagraph): ViewStatuteParagraph {
|
||||||
return new ViewStatuteParagraph(statuteParagraph);
|
const viewStatuteParagraph = new ViewStatuteParagraph(statuteParagraph);
|
||||||
|
viewStatuteParagraph.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Statute paragraphs' : 'Statute paragraph');
|
||||||
|
};
|
||||||
|
return viewStatuteParagraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async create(statuteParagraph: StatuteParagraph): Promise<Identifiable> {
|
public async create(statuteParagraph: StatuteParagraph): Promise<Identifiable> {
|
||||||
|
@ -11,6 +11,7 @@ import { WorkflowState } from 'app/shared/models/motions/workflow-state';
|
|||||||
import { ViewMotion } from 'app/site/motions/models/view-motion';
|
import { ViewMotion } from 'app/site/motions/models/view-motion';
|
||||||
import { HttpService } from 'app/core/core-services/http.service';
|
import { HttpService } from 'app/core/core-services/http.service';
|
||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository Services for Categories
|
* Repository Services for Categories
|
||||||
@ -45,7 +46,8 @@ export class WorkflowRepositoryService extends BaseRepository<ViewWorkflow, Work
|
|||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
private httpService: HttpService,
|
private httpService: HttpService,
|
||||||
viewModelStoreService: ViewModelStoreService,
|
viewModelStoreService: ViewModelStoreService,
|
||||||
private dataSend: DataSendService
|
private dataSend: DataSendService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, Workflow);
|
super(DS, mapperService, viewModelStoreService, Workflow);
|
||||||
}
|
}
|
||||||
@ -56,7 +58,11 @@ export class WorkflowRepositoryService extends BaseRepository<ViewWorkflow, Work
|
|||||||
* @param workflow the Workflow to convert
|
* @param workflow the Workflow to convert
|
||||||
*/
|
*/
|
||||||
protected createViewModel(workflow: Workflow): ViewWorkflow {
|
protected createViewModel(workflow: Workflow): ViewWorkflow {
|
||||||
return new ViewWorkflow(workflow);
|
const viewWorkflow = new ViewWorkflow(workflow);
|
||||||
|
viewWorkflow.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Workflows' : 'Workflow');
|
||||||
|
};
|
||||||
|
return viewWorkflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,6 +7,7 @@ import { CollectionStringMapperService } from '../../core-services/collectionStr
|
|||||||
import { ViewCountdown } from 'app/site/projector/models/view-countdown';
|
import { ViewCountdown } from 'app/site/projector/models/view-countdown';
|
||||||
import { Countdown } from 'app/shared/models/core/countdown';
|
import { Countdown } from 'app/shared/models/core/countdown';
|
||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -16,13 +17,18 @@ export class CountdownRepositoryService extends BaseRepository<ViewCountdown, Co
|
|||||||
DS: DataStoreService,
|
DS: DataStoreService,
|
||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
viewModelStoreService: ViewModelStoreService,
|
viewModelStoreService: ViewModelStoreService,
|
||||||
private dataSend: DataSendService
|
private dataSend: DataSendService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, Countdown);
|
super(DS, mapperService, viewModelStoreService, Countdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createViewModel(countdown: Countdown): ViewCountdown {
|
protected createViewModel(countdown: Countdown): ViewCountdown {
|
||||||
return new ViewCountdown(countdown);
|
const viewCountdown = new ViewCountdown(countdown);
|
||||||
|
viewCountdown.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Countdowns' : 'Countdown');
|
||||||
|
};
|
||||||
|
return viewCountdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async create(countdown: Countdown): Promise<Identifiable> {
|
public async create(countdown: Countdown): Promise<Identifiable> {
|
||||||
|
@ -9,6 +9,7 @@ import { ViewProjector } from 'app/site/projector/models/view-projector';
|
|||||||
import { Projector } from 'app/shared/models/core/projector';
|
import { Projector } from 'app/shared/models/core/projector';
|
||||||
import { HttpService } from 'app/core/core-services/http.service';
|
import { HttpService } from 'app/core/core-services/http.service';
|
||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directions for scale and scroll requests.
|
* Directions for scale and scroll requests.
|
||||||
@ -39,11 +40,20 @@ export class ProjectorRepositoryService extends BaseRepository<ViewProjector, Pr
|
|||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
viewModelStoreService: ViewModelStoreService,
|
viewModelStoreService: ViewModelStoreService,
|
||||||
private dataSend: DataSendService,
|
private dataSend: DataSendService,
|
||||||
private http: HttpService
|
private http: HttpService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, Projector);
|
super(DS, mapperService, viewModelStoreService, Projector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public createViewModel(projector: Projector): ViewProjector {
|
||||||
|
const viewProjector = new ViewProjector(projector);
|
||||||
|
viewProjector.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Projectors' : 'Projector');
|
||||||
|
};
|
||||||
|
return viewProjector;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new projector. Adds the clock as default, stable element
|
* Creates a new projector. Adds the clock as default, stable element
|
||||||
*/
|
*/
|
||||||
@ -73,10 +83,6 @@ export class ProjectorRepositoryService extends BaseRepository<ViewProjector, Pr
|
|||||||
await this.dataSend.deleteModel(projector.projector);
|
await this.dataSend.deleteModel(projector.projector);
|
||||||
}
|
}
|
||||||
|
|
||||||
public createViewModel(projector: Projector): ViewProjector {
|
|
||||||
return new ViewProjector(projector);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scroll the given projector.
|
* Scroll the given projector.
|
||||||
*
|
*
|
||||||
|
@ -6,6 +6,7 @@ import { CollectionStringMapperService } from '../../core-services/collectionStr
|
|||||||
import { ProjectorMessage } from 'app/shared/models/core/projector-message';
|
import { ProjectorMessage } from 'app/shared/models/core/projector-message';
|
||||||
import { ViewProjectorMessage } from 'app/site/projector/models/view-projectormessage';
|
import { ViewProjectorMessage } from 'app/site/projector/models/view-projectormessage';
|
||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -14,13 +15,18 @@ export class ProjectorMessageRepositoryService extends BaseRepository<ViewProjec
|
|||||||
public constructor(
|
public constructor(
|
||||||
DS: DataStoreService,
|
DS: DataStoreService,
|
||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
viewModelStoreService: ViewModelStoreService
|
viewModelStoreService: ViewModelStoreService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, ProjectorMessage);
|
super(DS, mapperService, viewModelStoreService, ProjectorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createViewModel(message: ProjectorMessage): ViewProjectorMessage {
|
protected createViewModel(message: ProjectorMessage): ViewProjectorMessage {
|
||||||
return new ViewProjectorMessage(message);
|
const viewProjectorMessage = new ViewProjectorMessage(message);
|
||||||
|
viewProjectorMessage.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Messages' : 'Message');
|
||||||
|
};
|
||||||
|
return viewProjectorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async create(message: ProjectorMessage): Promise<Identifiable> {
|
public async create(message: ProjectorMessage): Promise<Identifiable> {
|
||||||
|
@ -8,6 +8,7 @@ import { BaseRepository } from '../base-repository';
|
|||||||
import { Identifiable } from 'app/shared/models/base/identifiable';
|
import { Identifiable } from 'app/shared/models/base/identifiable';
|
||||||
import { CollectionStringMapperService } from '../../core-services/collectionStringMapper.service';
|
import { CollectionStringMapperService } from '../../core-services/collectionStringMapper.service';
|
||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository Services for Tags
|
* Repository Services for Tags
|
||||||
@ -36,13 +37,18 @@ export class TagRepositoryService extends BaseRepository<ViewTag, Tag> {
|
|||||||
protected DS: DataStoreService,
|
protected DS: DataStoreService,
|
||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
viewModelStoreService: ViewModelStoreService,
|
viewModelStoreService: ViewModelStoreService,
|
||||||
private dataSend: DataSendService
|
private dataSend: DataSendService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, Tag);
|
super(DS, mapperService, viewModelStoreService, Tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createViewModel(tag: Tag): ViewTag {
|
protected createViewModel(tag: Tag): ViewTag {
|
||||||
return new ViewTag(tag);
|
const viewTag = new ViewTag(tag);
|
||||||
|
viewTag.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Tags' : 'Tag');
|
||||||
|
};
|
||||||
|
return viewTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async create(update: Tag): Promise<Identifiable> {
|
public async create(update: Tag): Promise<Identifiable> {
|
||||||
|
@ -9,6 +9,7 @@ import { Group } from 'app/shared/models/users/group';
|
|||||||
import { Identifiable } from 'app/shared/models/base/identifiable';
|
import { Identifiable } from 'app/shared/models/base/identifiable';
|
||||||
import { ViewGroup } from 'app/site/users/models/view-group';
|
import { ViewGroup } from 'app/site/users/models/view-group';
|
||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shape of a permission
|
* Shape of a permission
|
||||||
@ -52,12 +53,21 @@ export class GroupRepositoryService extends BaseRepository<ViewGroup, Group> {
|
|||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
viewModelStoreService: ViewModelStoreService,
|
viewModelStoreService: ViewModelStoreService,
|
||||||
private dataSend: DataSendService,
|
private dataSend: DataSendService,
|
||||||
private constants: ConstantsService
|
private constants: ConstantsService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, Group);
|
super(DS, mapperService, viewModelStoreService, Group);
|
||||||
this.sortPermsPerApp();
|
this.sortPermsPerApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public createViewModel(group: Group): ViewGroup {
|
||||||
|
const viewGroup = new ViewGroup(group);
|
||||||
|
viewGroup.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Groups' : 'Group');
|
||||||
|
};
|
||||||
|
return viewGroup;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an entry to appPermissions
|
* Add an entry to appPermissions
|
||||||
*
|
*
|
||||||
@ -180,8 +190,4 @@ export class GroupRepositoryService extends BaseRepository<ViewGroup, Group> {
|
|||||||
public async delete(viewGroup: ViewGroup): Promise<void> {
|
public async delete(viewGroup: ViewGroup): Promise<void> {
|
||||||
await this.dataSend.deleteModel(viewGroup.group);
|
await this.dataSend.deleteModel(viewGroup.group);
|
||||||
}
|
}
|
||||||
|
|
||||||
public createViewModel(group: Group): ViewGroup {
|
|
||||||
return new ViewGroup(group);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import { PersonalNote } from 'app/shared/models/users/personal-note';
|
|||||||
import { Identifiable } from 'app/shared/models/base/identifiable';
|
import { Identifiable } from 'app/shared/models/base/identifiable';
|
||||||
import { ViewPersonalNote } from 'app/site/users/models/view-personal-note';
|
import { ViewPersonalNote } from 'app/site/users/models/view-personal-note';
|
||||||
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@ -21,13 +22,18 @@ export class PersonalNoteRepositoryService extends BaseRepository<ViewPersonalNo
|
|||||||
public constructor(
|
public constructor(
|
||||||
DS: DataStoreService,
|
DS: DataStoreService,
|
||||||
mapperService: CollectionStringMapperService,
|
mapperService: CollectionStringMapperService,
|
||||||
viewModelStoreService: ViewModelStoreService
|
viewModelStoreService: ViewModelStoreService,
|
||||||
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(DS, mapperService, viewModelStoreService, PersonalNote);
|
super(DS, mapperService, viewModelStoreService, PersonalNote);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createViewModel(personalNote: PersonalNote): ViewPersonalNote {
|
protected createViewModel(personalNote: PersonalNote): ViewPersonalNote {
|
||||||
return new ViewPersonalNote();
|
const viewPersonalNote = new ViewPersonalNote();
|
||||||
|
viewPersonalNote.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Personal notes' : 'Personal note');
|
||||||
|
};
|
||||||
|
return viewPersonalNote;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async create(personalNote: PersonalNote): Promise<Identifiable> {
|
public async create(personalNote: PersonalNote): Promise<Identifiable> {
|
||||||
|
@ -49,6 +49,15 @@ export class UserRepositoryService extends BaseRepository<ViewUser, User> {
|
|||||||
super(DS, mapperService, viewModelStoreService, User, [Group]);
|
super(DS, mapperService, viewModelStoreService, User, [Group]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public createViewModel(user: User): ViewUser {
|
||||||
|
const groups = this.viewModelStoreService.getMany(ViewGroup, user.groups_id);
|
||||||
|
const viewUser = new ViewUser(user, groups);
|
||||||
|
viewUser.getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Users' : 'User');
|
||||||
|
};
|
||||||
|
return viewUser;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a the selected user with the form values.
|
* Updates a the selected user with the form values.
|
||||||
*
|
*
|
||||||
@ -106,11 +115,6 @@ export class UserRepositoryService extends BaseRepository<ViewUser, User> {
|
|||||||
return await this.dataSend.createModel(newUser);
|
return await this.dataSend.createModel(newUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public createViewModel(user: User): ViewUser {
|
|
||||||
const groups = this.viewModelStoreService.getMany(ViewGroup, user.groups_id);
|
|
||||||
return new ViewUser(user, groups);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a random password
|
* Generates a random password
|
||||||
*
|
*
|
||||||
|
@ -82,11 +82,11 @@ export class SearchService {
|
|||||||
ctor: new (...args: any[]) => Searchable & BaseViewModel,
|
ctor: new (...args: any[]) => Searchable & BaseViewModel,
|
||||||
displayOrder: number
|
displayOrder: number
|
||||||
): void {
|
): void {
|
||||||
const instance = new ctor();
|
// const instance = new ctor();
|
||||||
this.searchModels.push({
|
this.searchModels.push({
|
||||||
collectionString: collectionString,
|
collectionString: collectionString,
|
||||||
verboseNameSingular: instance.getVerboseName(),
|
verboseNameSingular: 'TODO', // instance.getVerboseName(),
|
||||||
verboseNamePlural: instance.getVerboseName(true),
|
verboseNamePlural: 'TODO', // instance.getVerboseName(true),
|
||||||
displayOrder: displayOrder
|
displayOrder: displayOrder
|
||||||
});
|
});
|
||||||
this.searchModels.sort((a, b) => a.displayOrder - b.displayOrder);
|
this.searchModels.sort((a, b) => a.displayOrder - b.displayOrder);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Selectable } from './selectable';
|
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
|
import { Selectable } from './selectable';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to display an "empty" Selectable
|
* Class to display an "empty" Selectable
|
||||||
*/
|
*/
|
||||||
@ -19,20 +20,10 @@ export class EmptySelectable implements Selectable {
|
|||||||
/**
|
/**
|
||||||
* gets the title
|
* gets the title
|
||||||
*/
|
*/
|
||||||
public getTitle(): string {
|
public getTitle = () => (this.translate ? this.translate.instant('None') : 'None');
|
||||||
if (this.translate) {
|
|
||||||
return this.translate.instant('None');
|
|
||||||
}
|
|
||||||
return 'None';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets the list title
|
* gets the list title
|
||||||
*/
|
*/
|
||||||
public getListTitle(): string {
|
public getListTitle = () => this.getTitle();
|
||||||
if (this.translate) {
|
|
||||||
return this.translate.instant('None');
|
|
||||||
}
|
|
||||||
return 'None';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,9 @@ class TestModel implements Identifiable, Displayable {
|
|||||||
public parent_id: number | null
|
public parent_id: number | null
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => this.name;
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getListTitle(): string {
|
public getListTitle = () => this.getTitle();
|
||||||
return this.getTitle();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('SortingTreeComponent', () => {
|
describe('SortingTreeComponent', () => {
|
||||||
|
@ -25,6 +25,8 @@ export const itemVisibilityChoices = [
|
|||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
export class Item extends BaseModel<Item> {
|
export class Item extends BaseModel<Item> {
|
||||||
|
public static COLLECTIONSTRING = 'agenda/item';
|
||||||
|
|
||||||
public id: number;
|
public id: number;
|
||||||
public item_number: string;
|
public item_number: string;
|
||||||
public title: string;
|
public title: string;
|
||||||
@ -41,7 +43,7 @@ export class Item extends BaseModel<Item> {
|
|||||||
public parent_id: number;
|
public parent_id: number;
|
||||||
|
|
||||||
public constructor(input?: any) {
|
public constructor(input?: any) {
|
||||||
super('agenda/item', input);
|
super(Item.COLLECTIONSTRING, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public deserialize(input: any): void {
|
public deserialize(input: any): void {
|
||||||
|
@ -13,6 +13,7 @@ export const assignmentPhase = [
|
|||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
export class Assignment extends BaseModel<Assignment> {
|
export class Assignment extends BaseModel<Assignment> {
|
||||||
|
public static COLLECTIONSTRING = 'assignments/assignment';
|
||||||
public id: number;
|
public id: number;
|
||||||
public title: string;
|
public title: string;
|
||||||
public description: string;
|
public description: string;
|
||||||
@ -25,7 +26,7 @@ export class Assignment extends BaseModel<Assignment> {
|
|||||||
public tags_id: number[];
|
public tags_id: number[];
|
||||||
|
|
||||||
public constructor(input?: any) {
|
public constructor(input?: any) {
|
||||||
super('assignments/assignment', input);
|
super(Assignment.COLLECTIONSTRING, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get candidateIds(): number[] {
|
public get candidateIds(): number[] {
|
||||||
|
@ -6,6 +6,7 @@ import { BaseModel } from '../base/base-model';
|
|||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
export class Mediafile extends BaseModel<Mediafile> {
|
export class Mediafile extends BaseModel<Mediafile> {
|
||||||
|
public static COLLECTIONSTRING = 'mediafiles/mediafile';
|
||||||
public id: number;
|
public id: number;
|
||||||
public title: string;
|
public title: string;
|
||||||
public mediafile: File;
|
public mediafile: File;
|
||||||
@ -16,7 +17,7 @@ export class Mediafile extends BaseModel<Mediafile> {
|
|||||||
public timestamp: string;
|
public timestamp: string;
|
||||||
|
|
||||||
public constructor(input?: any) {
|
public constructor(input?: any) {
|
||||||
super('mediafiles/mediafile', input);
|
super(Mediafile.COLLECTIONSTRING, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public deserialize(input: any): void {
|
public deserialize(input: any): void {
|
||||||
|
@ -6,6 +6,7 @@ import { BaseModel } from '../base/base-model';
|
|||||||
*/
|
*/
|
||||||
export class Group extends BaseModel<Group> {
|
export class Group extends BaseModel<Group> {
|
||||||
public static COLLECTIONSTRING = 'users/group';
|
public static COLLECTIONSTRING = 'users/group';
|
||||||
|
|
||||||
public id: number;
|
public id: number;
|
||||||
public name: string;
|
public name: string;
|
||||||
public permissions: string[];
|
public permissions: string[];
|
||||||
@ -17,8 +18,4 @@ export class Group extends BaseModel<Group> {
|
|||||||
this.permissions = [];
|
this.permissions = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -58,8 +58,4 @@ export class PersonalNote extends BaseModel<PersonalNote> implements PersonalNot
|
|||||||
public constructor(input: any) {
|
public constructor(input: any) {
|
||||||
super(PersonalNote.COLLECTIONSTRING, input);
|
super(PersonalNote.COLLECTIONSTRING, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
|
||||||
return 'Personal note';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -107,4 +107,8 @@ export class ViewCreateTopic extends ViewTopic {
|
|||||||
public constructor(topic: CreateTopic) {
|
public constructor(topic: CreateTopic) {
|
||||||
super(topic);
|
super(topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getVerboseName = () => {
|
||||||
|
throw new Error('This should not be used');
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { BaseViewModel } from '../../base/base-view-model';
|
import { BaseViewModel } from '../../base/base-view-model';
|
||||||
import { Item } from 'app/shared/models/agenda/item';
|
import { Item } from 'app/shared/models/agenda/item';
|
||||||
import { Speaker } from 'app/shared/models/agenda/speaker';
|
import { Speaker } from 'app/shared/models/agenda/speaker';
|
||||||
import { BaseAgendaViewModel } from 'app/site/base/base-agenda-view-model';
|
import { BaseAgendaViewModel, isAgendaBaseModel } from 'app/site/base/base-agenda-view-model';
|
||||||
|
|
||||||
export class ViewItem extends BaseViewModel {
|
export class ViewItem extends BaseViewModel {
|
||||||
private _item: Item;
|
private _item: Item;
|
||||||
@ -29,52 +29,46 @@ export class ViewItem extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get id(): number {
|
public get id(): number {
|
||||||
return this.item ? this.item.id : null;
|
return this.item.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get itemNumber(): string {
|
public get itemNumber(): string {
|
||||||
return this.item ? this.item.item_number : null;
|
return this.item.item_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get duration(): number {
|
public get duration(): number {
|
||||||
return this.item ? this.item.duration : null;
|
return this.item.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get waitingSpeakerAmount(): number {
|
public get waitingSpeakerAmount(): number {
|
||||||
return this.item ? this.item.waitingSpeakerAmount : null;
|
return this.item.waitingSpeakerAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get type(): number {
|
public get type(): number {
|
||||||
return this.item ? this.item.type : null;
|
return this.item.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get closed(): boolean {
|
public get closed(): boolean {
|
||||||
return this.item ? this.item.closed : null;
|
return this.item.closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get comment(): string {
|
public get comment(): string {
|
||||||
if (this.item && this.item.comment) {
|
|
||||||
return this.item.comment;
|
return this.item.comment;
|
||||||
}
|
}
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public get verboseType(): string {
|
public get verboseType(): string {
|
||||||
if (this.item && this.item.verboseType) {
|
|
||||||
return this.item.verboseType;
|
return this.item.verboseType;
|
||||||
}
|
}
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public get verboseCsvType(): string {
|
public get verboseCsvType(): string {
|
||||||
return this.item ? this.item.verboseCsvType : '';
|
return this.item.verboseCsvType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: make the repository set the ViewSpeakers here.
|
* TODO: make the repository set the ViewSpeakers here.
|
||||||
*/
|
*/
|
||||||
public get speakers(): Speaker[] {
|
public get speakers(): Speaker[] {
|
||||||
return this.item ? this.item.speakers : [];
|
return this.item.speakers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,29 +76,34 @@ export class ViewItem extends BaseViewModel {
|
|||||||
* it's own hierarchy level (items sharing a parent)
|
* it's own hierarchy level (items sharing a parent)
|
||||||
*/
|
*/
|
||||||
public get weight(): number {
|
public get weight(): number {
|
||||||
return this.item ? this.item.weight : null;
|
return this.item.weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns the parent's id of that item (0 if no parent is set).
|
* @returns the parent's id of that item (0 if no parent is set).
|
||||||
*/
|
*/
|
||||||
public get parent_id(): number {
|
public get parent_id(): number {
|
||||||
return this.item ? this.item.parent_id : null;
|
return this.item.parent_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(item: Item, contentObject: BaseAgendaViewModel) {
|
public constructor(item: Item, contentObject: BaseAgendaViewModel) {
|
||||||
super('Item');
|
super(Item.COLLECTIONSTRING);
|
||||||
this._item = item;
|
this._item = item;
|
||||||
this._contentObject = contentObject;
|
this._contentObject = contentObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
if (this.contentObject) {
|
if (this.contentObject) {
|
||||||
return this.contentObject.getAgendaTitle();
|
return this.contentObject.getAgendaTitle();
|
||||||
} else {
|
} else {
|
||||||
return this.item ? this.item.title : null;
|
return this.item ? this.item.title : null;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the list view title.
|
* Create the list view title.
|
||||||
@ -112,16 +111,27 @@ export class ViewItem extends BaseViewModel {
|
|||||||
*
|
*
|
||||||
* @returns the agenda list title as string
|
* @returns the agenda list title as string
|
||||||
*/
|
*/
|
||||||
public getListTitle(): string {
|
public getListTitle = () => {
|
||||||
const contentObject: BaseAgendaViewModel = this.contentObject;
|
|
||||||
const numberPrefix = this.itemNumber ? `${this.itemNumber} · ` : '';
|
const numberPrefix = this.itemNumber ? `${this.itemNumber} · ` : '';
|
||||||
|
|
||||||
if (contentObject) {
|
if (this.contentObject) {
|
||||||
return numberPrefix + contentObject.getAgendaTitleWithType();
|
return numberPrefix + this.contentObject.getAgendaTitleWithType();
|
||||||
} else {
|
} else {
|
||||||
return this.item ? numberPrefix + this.item.title_with_type : null;
|
return numberPrefix + this.item.title_with_type;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public updateDependencies(update: BaseViewModel): void {}
|
public updateDependencies(update: BaseViewModel): boolean {
|
||||||
|
if (
|
||||||
|
update.collectionString === this.item.content_object.collection &&
|
||||||
|
update.id === this.item.content_object.id
|
||||||
|
) {
|
||||||
|
if (!isAgendaBaseModel(update)) {
|
||||||
|
throw new Error('The item is not an BaseAgendaViewModel:' + update);
|
||||||
|
}
|
||||||
|
this._contentObject = update as BaseAgendaViewModel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,15 +55,20 @@ export class ViewSpeaker extends BaseViewModel {
|
|||||||
return this.user ? this.user.gender : '';
|
return this.user ? this.user.gender : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(speaker: Speaker, user?: ViewUser) {
|
public constructor(speaker: Speaker, user?: ViewUser) {
|
||||||
super('Speaker');
|
super('TODO');
|
||||||
this._speaker = speaker;
|
this._speaker = speaker;
|
||||||
this._user = user;
|
this._user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Speaker is not a base model,
|
* Speaker is not a base model,
|
||||||
|
@ -47,25 +47,30 @@ export class ViewTopic extends BaseAgendaViewModel {
|
|||||||
return this.topic.text;
|
return this.topic.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(topic: Topic, attachments?: ViewMediafile[], item?: ViewItem) {
|
public constructor(topic: Topic, attachments?: ViewMediafile[], item?: ViewItem) {
|
||||||
super('Topic');
|
super(Topic.COLLECTIONSTRING);
|
||||||
this._topic = topic;
|
this._topic = topic;
|
||||||
this._attachments = attachments;
|
this._attachments = attachments;
|
||||||
this._agendaItem = item;
|
this._agendaItem = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.title;
|
return this.title;
|
||||||
}
|
};
|
||||||
|
|
||||||
public getAgendaItem(): ViewItem {
|
public getAgendaItem(): ViewItem {
|
||||||
return this.agendaItem;
|
return this.agendaItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getAgendaTitleWithType(): string {
|
public getAgendaTitleWithType = () => {
|
||||||
// Do not append ' (Topic)' to the title.
|
// Do not append ' (Topic)' to the title.
|
||||||
return this.getAgendaTitle();
|
return this.getAgendaTitle();
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats the category for search
|
* Formats the category for search
|
||||||
|
@ -44,8 +44,13 @@ export class ViewAssignment extends BaseAgendaViewModel {
|
|||||||
return this.candidates ? this.candidates.length : 0;
|
return this.candidates ? this.candidates.length : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(assignment: Assignment, relatedUser?: ViewUser[], agendaItem?: ViewItem, tags?: ViewTag[]) {
|
public constructor(assignment: Assignment, relatedUser?: ViewUser[], agendaItem?: ViewItem, tags?: ViewTag[]) {
|
||||||
super('Election');
|
super(Assignment.COLLECTIONSTRING);
|
||||||
this._assignment = assignment;
|
this._assignment = assignment;
|
||||||
this._relatedUser = relatedUser;
|
this._relatedUser = relatedUser;
|
||||||
this._agendaItem = agendaItem;
|
this._agendaItem = agendaItem;
|
||||||
@ -60,9 +65,9 @@ export class ViewAssignment extends BaseAgendaViewModel {
|
|||||||
return this.agendaItem;
|
return this.agendaItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.assignment.title;
|
return this.assignment.title;
|
||||||
}
|
};
|
||||||
|
|
||||||
public formatForSearch(): SearchRepresentation {
|
public formatForSearch(): SearchRepresentation {
|
||||||
throw new Error('TODO');
|
throw new Error('TODO');
|
||||||
|
@ -8,12 +8,12 @@ export interface AgendaInformation extends DetailNavigable {
|
|||||||
/**
|
/**
|
||||||
* Should return the title for the agenda list view.
|
* Should return the title for the agenda list view.
|
||||||
*/
|
*/
|
||||||
getAgendaTitle(): string;
|
getAgendaTitle: () => string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should return the title for the list of speakers view.
|
* Should return the title for the list of speakers view.
|
||||||
*/
|
*/
|
||||||
getAgendaTitleWithType(): string;
|
getAgendaTitleWithType: () => string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An (optional) descriptive text to be exported in the CSV.
|
* An (optional) descriptive text to be exported in the CSV.
|
||||||
|
@ -3,26 +3,40 @@ import { BaseProjectableViewModel } from './base-projectable-view-model';
|
|||||||
import { SearchRepresentation } from 'app/core/ui-services/search.service';
|
import { SearchRepresentation } from 'app/core/ui-services/search.service';
|
||||||
import { ViewItem } from '../agenda/models/view-item';
|
import { ViewItem } from '../agenda/models/view-item';
|
||||||
|
|
||||||
|
export function isAgendaBaseModel(obj: object): obj is BaseAgendaViewModel {
|
||||||
|
const agendaViewModel = <BaseAgendaViewModel>obj;
|
||||||
|
return (
|
||||||
|
agendaViewModel.getAgendaTitle !== undefined &&
|
||||||
|
agendaViewModel.getAgendaTitleWithType !== undefined &&
|
||||||
|
agendaViewModel.getCSVExportText !== undefined &&
|
||||||
|
agendaViewModel.getAgendaItem !== undefined &&
|
||||||
|
agendaViewModel.getDetailStateURL !== undefined
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base view class for projectable models.
|
* Base view class for projectable models.
|
||||||
*/
|
*/
|
||||||
export abstract class BaseAgendaViewModel extends BaseProjectableViewModel implements AgendaInformation {
|
export abstract class BaseAgendaViewModel extends BaseProjectableViewModel implements AgendaInformation {
|
||||||
|
/**
|
||||||
|
* @returns the contained agenda item
|
||||||
|
*/
|
||||||
public abstract getAgendaItem(): ViewItem;
|
public abstract getAgendaItem(): ViewItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns the agenda title
|
* @returns the agenda title
|
||||||
*/
|
*/
|
||||||
public getAgendaTitle(): string {
|
public getAgendaTitle = () => {
|
||||||
return this.getTitle();
|
return this.getTitle();
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the agenda title with the verbose name of the content object
|
* @return the agenda title with the verbose name of the content object
|
||||||
*/
|
*/
|
||||||
public getAgendaTitleWithType(): string {
|
public getAgendaTitleWithType = () => {
|
||||||
// Return the agenda title with the model's verbose name appended
|
// Return the agenda title with the model's verbose name appended
|
||||||
return this.getAgendaTitle() + ' (' + this.getVerboseName() + ')';
|
return this.getAgendaTitle() + ' (' + this.getVerboseName() + ')';
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns the (optional) descriptive text to be exported in the CSV.
|
* @returns the (optional) descriptive text to be exported in the CSV.
|
||||||
|
@ -5,9 +5,5 @@ import { BaseViewModel } from './base-view-model';
|
|||||||
* Base view class for projectable models.
|
* Base view class for projectable models.
|
||||||
*/
|
*/
|
||||||
export abstract class BaseProjectableViewModel extends BaseViewModel implements Projectable {
|
export abstract class BaseProjectableViewModel extends BaseViewModel implements Projectable {
|
||||||
public constructor(verboseName: string) {
|
|
||||||
super(verboseName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract getSlide(): ProjectorElementBuildDeskriptor;
|
public abstract getSlide(): ProjectorElementBuildDeskriptor;
|
||||||
}
|
}
|
||||||
|
@ -1,50 +1,60 @@
|
|||||||
import { Displayable } from './displayable';
|
import { Displayable } from './displayable';
|
||||||
import { Identifiable } from '../../shared/models/base/identifiable';
|
import { Identifiable } from '../../shared/models/base/identifiable';
|
||||||
|
import { Collection } from 'app/shared/models/base/collection';
|
||||||
|
|
||||||
export type ViewModelConstructor<T extends BaseViewModel> = new (...args: any[]) => T;
|
export type ViewModelConstructor<T extends BaseViewModel> = new (...args: any[]) => T;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for view models. alls view models should have titles.
|
* Base class for view models. alls view models should have titles.
|
||||||
*/
|
*/
|
||||||
export abstract class BaseViewModel implements Displayable, Identifiable {
|
export abstract class BaseViewModel implements Displayable, Identifiable, Collection {
|
||||||
/**
|
/**
|
||||||
* Force children to have an id.
|
* Force children to have an id.
|
||||||
*/
|
*/
|
||||||
public abstract id: number;
|
public abstract id: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Children should also have a verbose name for generic display purposes
|
* force children of BaseModel to have a collectionString.
|
||||||
|
*
|
||||||
|
* Has a getter but no setter.
|
||||||
*/
|
*/
|
||||||
protected _verboseName: string;
|
protected _collectionString: string;
|
||||||
|
|
||||||
public constructor(verboseName: string) {
|
|
||||||
this._verboseName = verboseName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the verbose name. Makes it plural by adding a 's'.
|
* returns the collectionString.
|
||||||
|
*
|
||||||
|
* The server and the dataStore use it to identify the collection.
|
||||||
|
*/
|
||||||
|
public get collectionString(): string {
|
||||||
|
return this._collectionString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract getTitle: () => string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the verbose name.
|
||||||
*
|
*
|
||||||
* @param plural If the name should be plural
|
* @param plural If the name should be plural
|
||||||
* @returns the verbose name of the model
|
* @returns the verbose name of the model
|
||||||
*/
|
*/
|
||||||
public getVerboseName(plural: boolean = false): string {
|
public abstract getVerboseName: (plural?: boolean) => string;
|
||||||
if (plural) {
|
|
||||||
return this._verboseName + 's'; // I love english. This works for all our models (participantS, electionS,
|
/**
|
||||||
// topicS, motionS, (media)fileS, motion blockS, commentS, personal noteS, projectorS, messageS, countdownS, ...)
|
* TODO: Remove verboseName, this must be overwritten by repos..
|
||||||
// Just categorIES need to overwrite this...
|
*
|
||||||
} else {
|
* @param verboseName
|
||||||
return this._verboseName;
|
* @param collectionString
|
||||||
}
|
*/
|
||||||
|
public constructor(collectionString: string) {
|
||||||
|
this._collectionString = collectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getListTitle: () => string = () => {
|
||||||
|
return this.getTitle();
|
||||||
|
};
|
||||||
|
|
||||||
public abstract updateDependencies(update: BaseViewModel): void;
|
public abstract updateDependencies(update: BaseViewModel): void;
|
||||||
|
|
||||||
public abstract getTitle(): string;
|
|
||||||
|
|
||||||
public getListTitle(): string {
|
|
||||||
return this.getTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
public toString(): string {
|
public toString(): string {
|
||||||
return this.getTitle();
|
return this.getTitle();
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
*/
|
*/
|
||||||
export interface Displayable {
|
export interface Displayable {
|
||||||
/**
|
/**
|
||||||
* Should return the title. Alway used except for list view, the agenda and in the projector.
|
* Should return the title. Always used except for list view, the agenda and in the projector.
|
||||||
*/
|
*/
|
||||||
getTitle(): string;
|
getTitle: () => string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should return the title for the list view.
|
* Should return the title for the list view.
|
||||||
*/
|
*/
|
||||||
getListTitle(): string;
|
getListTitle: () => string;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,11 @@ import { BaseViewModel } from 'app/site/base/base-view-model';
|
|||||||
export class ViewChatMessage extends BaseViewModel {
|
export class ViewChatMessage extends BaseViewModel {
|
||||||
private _chatMessage: ChatMessage;
|
private _chatMessage: ChatMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public get chatmessage(): ChatMessage {
|
public get chatmessage(): ChatMessage {
|
||||||
return this._chatMessage;
|
return this._chatMessage;
|
||||||
}
|
}
|
||||||
@ -17,13 +22,13 @@ export class ViewChatMessage extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public constructor(message?: ChatMessage) {
|
public constructor(message?: ChatMessage) {
|
||||||
super('Chatmessage');
|
super(ChatMessage.COLLECTIONSTRING);
|
||||||
this._chatMessage = message;
|
this._chatMessage = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return 'Chatmessage';
|
return 'Chatmessage';
|
||||||
}
|
};
|
||||||
|
|
||||||
public updateDependencies(message: BaseViewModel): void {}
|
public updateDependencies(message: BaseViewModel): void {}
|
||||||
}
|
}
|
||||||
|
@ -93,14 +93,19 @@ export class ViewConfig extends BaseViewModel {
|
|||||||
return this._defaultValue;
|
return this._defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(config: Config) {
|
public constructor(config: Config) {
|
||||||
super('Config');
|
super(Config.COLLECTIONSTRING);
|
||||||
this._config = config;
|
this._config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.label;
|
return this.label;
|
||||||
}
|
};
|
||||||
|
|
||||||
public updateDependencies(update: BaseViewModel): void {}
|
public updateDependencies(update: BaseViewModel): void {}
|
||||||
|
|
||||||
|
@ -68,6 +68,11 @@ export class ViewHistory extends BaseViewModel {
|
|||||||
return this.history.now;
|
return this.history.now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construction of a ViewHistory
|
* Construction of a ViewHistory
|
||||||
*
|
*
|
||||||
@ -75,7 +80,7 @@ export class ViewHistory extends BaseViewModel {
|
|||||||
* @param user the real user BaseModel
|
* @param user the real user BaseModel
|
||||||
*/
|
*/
|
||||||
public constructor(history: History, user?: ViewUser) {
|
public constructor(history: History, user?: ViewUser) {
|
||||||
super('History');
|
super(History.COLLECTIONSTRING);
|
||||||
this._history = history;
|
this._history = history;
|
||||||
this._user = user;
|
this._user = user;
|
||||||
}
|
}
|
||||||
@ -112,9 +117,9 @@ export class ViewHistory extends BaseViewModel {
|
|||||||
*
|
*
|
||||||
* @returns history.getTitle which returns the element_id
|
* @returns history.getTitle which returns the element_id
|
||||||
*/
|
*/
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.element_id;
|
return this.element_id;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the history object with new values
|
* Updates the history object with new values
|
||||||
|
@ -61,15 +61,20 @@ export class ViewMediafile extends BaseViewModel implements Searchable {
|
|||||||
return this.mediafile.hidden;
|
return this.mediafile.hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(mediafile: Mediafile, uploader?: ViewUser) {
|
public constructor(mediafile: Mediafile, uploader?: ViewUser) {
|
||||||
super('Mediafile');
|
super(Mediafile.COLLECTIONSTRING);
|
||||||
this._mediafile = mediafile;
|
this._mediafile = mediafile;
|
||||||
this._uploader = uploader;
|
this._uploader = uploader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.title;
|
return this.title;
|
||||||
}
|
};
|
||||||
|
|
||||||
public formatForSearch(): SearchRepresentation {
|
public formatForSearch(): SearchRepresentation {
|
||||||
return [this.title];
|
return [this.title];
|
||||||
|
@ -41,29 +41,19 @@ export class ViewCategory extends BaseViewModel implements Searchable {
|
|||||||
return this.prefix ? this.prefix + ' - ' + this.name : this.name;
|
return this.prefix ? this.prefix + ' - ' + this.name : this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(category: Category) {
|
public constructor(category: Category) {
|
||||||
super('Category');
|
super(Category.COLLECTIONSTRING);
|
||||||
this._category = category;
|
this._category = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public getTitle = () => {
|
||||||
* Returns the verbose name of this model.
|
|
||||||
*
|
|
||||||
* @override
|
|
||||||
* @param plural If the name should be plural
|
|
||||||
* @param The verbose name
|
|
||||||
*/
|
|
||||||
public getVerboseName(plural: boolean = false): string {
|
|
||||||
if (plural) {
|
|
||||||
return 'Categories';
|
|
||||||
} else {
|
|
||||||
return this._verboseName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public getTitle(): string {
|
|
||||||
return this.prefixedName;
|
return this.prefixedName;
|
||||||
}
|
};
|
||||||
|
|
||||||
public formatForSearch(): SearchRepresentation {
|
public formatForSearch(): SearchRepresentation {
|
||||||
return [this.name, this.prefix];
|
return [this.name, this.prefix];
|
||||||
|
@ -21,14 +21,19 @@ export class ViewMotionChangeRecommendation extends BaseViewModel implements Vie
|
|||||||
return this._changeRecommendation;
|
return this._changeRecommendation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(changeReco: MotionChangeRecommendation) {
|
public constructor(changeReco: MotionChangeRecommendation) {
|
||||||
super('Change recommendation');
|
super(MotionChangeRecommendation.COLLECTIONSTRING);
|
||||||
this._changeRecommendation = changeReco;
|
this._changeRecommendation = changeReco;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return 'Changerecommendation';
|
return 'Changerecommendation';
|
||||||
}
|
};
|
||||||
|
|
||||||
public updateDependencies(update: BaseViewModel): void {}
|
public updateDependencies(update: BaseViewModel): void {}
|
||||||
|
|
||||||
|
@ -46,6 +46,10 @@ export class ViewCreateMotion extends ViewMotion {
|
|||||||
super(motion, category, submitters, supporters, workflow, state, item, block, null);
|
super(motion, category, submitters, supporters, workflow, state, item, block, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getVerboseName = () => {
|
||||||
|
throw new Error('This should not be used');
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicate this motion into a copy of itself
|
* Duplicate this motion into a copy of itself
|
||||||
*/
|
*/
|
||||||
|
@ -34,8 +34,13 @@ export class ViewMotionBlock extends BaseAgendaViewModel implements Searchable {
|
|||||||
return this.motionBlock.agenda_item_id;
|
return this.motionBlock.agenda_item_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(motionBlock: MotionBlock, agendaItem?: ViewItem) {
|
public constructor(motionBlock: MotionBlock, agendaItem?: ViewItem) {
|
||||||
super('Motion block');
|
super(MotionBlock.COLLECTIONSTRING);
|
||||||
this._motionBlock = motionBlock;
|
this._motionBlock = motionBlock;
|
||||||
this._agendaItem = agendaItem;
|
this._agendaItem = agendaItem;
|
||||||
}
|
}
|
||||||
@ -68,9 +73,9 @@ export class ViewMotionBlock extends BaseAgendaViewModel implements Searchable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.title;
|
return this.title;
|
||||||
}
|
};
|
||||||
|
|
||||||
public getSlide(): ProjectorElementBuildDeskriptor {
|
public getSlide(): ProjectorElementBuildDeskriptor {
|
||||||
throw new Error('todo');
|
throw new Error('todo');
|
||||||
|
@ -47,16 +47,21 @@ export class ViewMotionCommentSection extends BaseViewModel {
|
|||||||
this._section.name = name;
|
this._section.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(section: MotionCommentSection, readGroups: ViewGroup[], writeGroups: ViewGroup[]) {
|
public constructor(section: MotionCommentSection, readGroups: ViewGroup[], writeGroups: ViewGroup[]) {
|
||||||
super('Comment section');
|
super(MotionCommentSection.COLLECTIONSTRING);
|
||||||
this._section = section;
|
this._section = section;
|
||||||
this._readGroups = readGroups;
|
this._readGroups = readGroups;
|
||||||
this._writeGroups = writeGroups;
|
this._writeGroups = writeGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the local objects if required
|
* Updates the local objects if required
|
||||||
|
@ -318,6 +318,21 @@ export class ViewMotion extends BaseAgendaViewModel implements Searchable {
|
|||||||
return this.personalNote && this.personalNote.note ? true : false;
|
return this.personalNote && this.personalNote.note ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getAgendaTitle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getAgendaTitleWithType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
motion: Motion,
|
motion: Motion,
|
||||||
category?: ViewCategory,
|
category?: ViewCategory,
|
||||||
@ -331,7 +346,7 @@ export class ViewMotion extends BaseAgendaViewModel implements Searchable {
|
|||||||
tags?: ViewTag[],
|
tags?: ViewTag[],
|
||||||
parent?: ViewMotion
|
parent?: ViewMotion
|
||||||
) {
|
) {
|
||||||
super('Motion');
|
super(Motion.COLLECTIONSTRING);
|
||||||
this._motion = motion;
|
this._motion = motion;
|
||||||
this._category = category;
|
this._category = category;
|
||||||
this._submitters = submitters;
|
this._submitters = submitters;
|
||||||
@ -345,36 +360,18 @@ export class ViewMotion extends BaseAgendaViewModel implements Searchable {
|
|||||||
this._parent = parent;
|
this._parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
if (this.identifier) {
|
if (this.identifier) {
|
||||||
return this.identifier + ': ' + this.title;
|
return this.identifier + ': ' + this.title;
|
||||||
} else {
|
} else {
|
||||||
return this.title;
|
return this.title;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
public getAgendaItem(): ViewItem {
|
public getAgendaItem(): ViewItem {
|
||||||
return this.item;
|
return this.item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getAgendaTitle(): string {
|
|
||||||
// if the identifier is set, the title will be 'Motion <identifier>'.
|
|
||||||
if (this.identifier) {
|
|
||||||
return 'Motion ' + this.identifier;
|
|
||||||
} else {
|
|
||||||
return this.getTitle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public getAgendaTitleWithType(): string {
|
|
||||||
// Append the verbose name only, if not the special format 'Motion <identifier>' is used.
|
|
||||||
if (this.identifier) {
|
|
||||||
return 'Motion ' + this.identifier;
|
|
||||||
} else {
|
|
||||||
return this.getTitle() + ' (' + this.getVerboseName() + ')';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats the category for search
|
* Formats the category for search
|
||||||
*
|
*
|
||||||
|
@ -33,14 +33,19 @@ export class ViewStatuteParagraph extends BaseViewModel implements Searchable {
|
|||||||
return this.statuteParagraph.weight;
|
return this.statuteParagraph.weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(paragraph: StatuteParagraph) {
|
public constructor(paragraph: StatuteParagraph) {
|
||||||
super('Statute paragraph');
|
super(StatuteParagraph.COLLECTIONSTRING);
|
||||||
this._paragraph = paragraph;
|
this._paragraph = paragraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.title;
|
return this.title;
|
||||||
}
|
};
|
||||||
|
|
||||||
public formatForSearch(): SearchRepresentation {
|
public formatForSearch(): SearchRepresentation {
|
||||||
throw new Error('TODO');
|
throw new Error('TODO');
|
||||||
|
@ -33,14 +33,19 @@ export class ViewWorkflow extends BaseViewModel {
|
|||||||
return this.getStateById(this.first_state_id);
|
return this.getStateById(this.first_state_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(workflow: Workflow) {
|
public constructor(workflow: Workflow) {
|
||||||
super('Workflow');
|
super(Workflow.COLLECTIONSTRING);
|
||||||
this._workflow = workflow;
|
this._workflow = workflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicate this motion into a copy of itself
|
* Duplicate this motion into a copy of itself
|
||||||
|
@ -18,14 +18,19 @@ export class ViewCountdown extends BaseProjectableViewModel {
|
|||||||
return this.countdown.description;
|
return this.countdown.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(countdown: Countdown) {
|
public constructor(countdown: Countdown) {
|
||||||
super('Countdown');
|
super(Countdown.COLLECTIONSTRING);
|
||||||
this._countdown = countdown;
|
this._countdown = countdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.description;
|
return this.description;
|
||||||
}
|
};
|
||||||
|
|
||||||
public updateDependencies(update: BaseViewModel): void {}
|
public updateDependencies(update: BaseViewModel): void {}
|
||||||
|
|
||||||
|
@ -52,14 +52,19 @@ export class ViewProjector extends BaseViewModel {
|
|||||||
return this.projector.reference_projector_id;
|
return this.projector.reference_projector_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(projector?: Projector) {
|
public constructor(projector?: Projector) {
|
||||||
super('Projector');
|
super(Projector.COLLECTIONSTRING);
|
||||||
this._projector = projector;
|
this._projector = projector;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
};
|
||||||
|
|
||||||
public updateDependencies(update: BaseViewModel): void {}
|
public updateDependencies(update: BaseViewModel): void {}
|
||||||
}
|
}
|
||||||
|
@ -18,14 +18,19 @@ export class ViewProjectorMessage extends BaseProjectableViewModel {
|
|||||||
return this.projctormessage.message;
|
return this.projctormessage.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(message: ProjectorMessage) {
|
public constructor(message: ProjectorMessage) {
|
||||||
super('Message');
|
super(ProjectorMessage.COLLECTIONSTRING);
|
||||||
this._message = message;
|
this._message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return 'Message';
|
return 'Message';
|
||||||
}
|
};
|
||||||
|
|
||||||
public updateDependencies(update: BaseViewModel): void {}
|
public updateDependencies(update: BaseViewModel): void {}
|
||||||
|
|
||||||
|
@ -25,14 +25,19 @@ export class ViewTag extends BaseViewModel implements Searchable {
|
|||||||
return this.tag.name;
|
return this.tag.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(tag: Tag) {
|
public constructor(tag: Tag) {
|
||||||
super('Tag');
|
super(Tag.COLLECTIONSTRING);
|
||||||
this._tag = tag;
|
this._tag = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
};
|
||||||
|
|
||||||
public formatForSearch(): SearchRepresentation {
|
public formatForSearch(): SearchRepresentation {
|
||||||
return [this.name];
|
return [this.name];
|
||||||
|
@ -29,8 +29,13 @@ export class ViewGroup extends BaseViewModel {
|
|||||||
return this.group.permissions;
|
return this.group.permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(group?: Group) {
|
public constructor(group?: Group) {
|
||||||
super('Group');
|
super(Group.COLLECTIONSTRING);
|
||||||
this._group = group;
|
this._group = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,9 +70,9 @@ export class ViewGroup extends BaseViewModel {
|
|||||||
return this.permissions.includes(perm);
|
return this.permissions.includes(perm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
};
|
||||||
|
|
||||||
public updateDependencies(update: BaseViewModel): void {
|
public updateDependencies(update: BaseViewModel): void {
|
||||||
console.log('ViewGroups wants to update Values with : ', update);
|
console.log('ViewGroups wants to update Values with : ', update);
|
||||||
|
@ -12,14 +12,19 @@ export class ViewPersonalNote extends BaseViewModel {
|
|||||||
return this.personalNote ? this.personalNote.id : null;
|
return this.personalNote ? this.personalNote.id : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(personalNote?: PersonalNote) {
|
public constructor(personalNote?: PersonalNote) {
|
||||||
super('Personal note');
|
super(PersonalNote.COLLECTIONSTRING);
|
||||||
this._personalNote = personalNote;
|
this._personalNote = personalNote;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.personalNote ? this.personalNote.toString() : null;
|
return this.personalNote ? this.personalNote.toString() : null;
|
||||||
}
|
};
|
||||||
|
|
||||||
public updateDependencies(update: BaseViewModel): void {
|
public updateDependencies(update: BaseViewModel): void {
|
||||||
throw new Error('Todo');
|
throw new Error('Todo');
|
||||||
|
@ -160,8 +160,13 @@ export class ViewUser extends BaseProjectableViewModel implements Searchable {
|
|||||||
return name.trim();
|
return name.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is set by the repository
|
||||||
|
*/
|
||||||
|
public getVerboseName;
|
||||||
|
|
||||||
public constructor(user: User, groups?: ViewGroup[]) {
|
public constructor(user: User, groups?: ViewGroup[]) {
|
||||||
super('Participant');
|
super(User.COLLECTIONSTRING);
|
||||||
this._user = user;
|
this._user = user;
|
||||||
this._groups = groups;
|
this._groups = groups;
|
||||||
}
|
}
|
||||||
@ -195,9 +200,9 @@ export class ViewUser extends BaseProjectableViewModel implements Searchable {
|
|||||||
/**
|
/**
|
||||||
* required by BaseViewModel. Don't confuse with the users title.
|
* required by BaseViewModel. Don't confuse with the users title.
|
||||||
*/
|
*/
|
||||||
public getTitle(): string {
|
public getTitle = () => {
|
||||||
return this.full_name;
|
return this.full_name;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Implement
|
* TODO: Implement
|
||||||
|
Loading…
Reference in New Issue
Block a user