Merge pull request #5295 from GabrielInTheWorld/duplicate-topics
Duplicates single and multiple items in the agenda
This commit is contained in:
commit
ddfe7d0c5a
@ -10,6 +10,7 @@ import { ViewModelStoreService } from 'app/core/core-services/view-model-store.s
|
|||||||
import { RelationDefinition } from 'app/core/definitions/relations';
|
import { RelationDefinition } from 'app/core/definitions/relations';
|
||||||
import { Topic } from 'app/shared/models/topics/topic';
|
import { Topic } from 'app/shared/models/topics/topic';
|
||||||
import { ViewMediafile } from 'app/site/mediafiles/models/view-mediafile';
|
import { ViewMediafile } from 'app/site/mediafiles/models/view-mediafile';
|
||||||
|
import { CreateTopic } from 'app/site/topics/models/create-topic';
|
||||||
import { TopicTitleInformation, ViewTopic } from 'app/site/topics/models/view-topic';
|
import { TopicTitleInformation, ViewTopic } from 'app/site/topics/models/view-topic';
|
||||||
import { BaseIsAgendaItemAndListOfSpeakersContentObjectRepository } from '../base-is-agenda-item-and-list-of-speakers-content-object-repository';
|
import { BaseIsAgendaItemAndListOfSpeakersContentObjectRepository } from '../base-is-agenda-item-and-list-of-speakers-content-object-repository';
|
||||||
|
|
||||||
@ -72,4 +73,15 @@ export class TopicRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCon
|
|||||||
public getVerboseName = (plural: boolean = false) => {
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
return this.translate.instant(plural ? 'Topics' : 'Topic');
|
return this.translate.instant(plural ? 'Topics' : 'Topic');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public duplicateTopic(topic: ViewTopic): void {
|
||||||
|
this.create(
|
||||||
|
new CreateTopic({
|
||||||
|
...topic.topic,
|
||||||
|
agenda_type: topic.item.type,
|
||||||
|
agenda_parent_id: topic.item.parent_id,
|
||||||
|
agenda_weight: topic.item.weight
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,6 +180,12 @@
|
|||||||
</button>
|
</button>
|
||||||
<mat-divider></mat-divider>
|
<mat-divider></mat-divider>
|
||||||
|
|
||||||
|
<!-- Duplicate items -->
|
||||||
|
<button mat-menu-item [disabled]="!selectedRows.length" (click)="duplicateMultipleTopics(selectedRows)">
|
||||||
|
<mat-icon>file_copy</mat-icon>
|
||||||
|
<span>{{ 'Create copy of selected topics' | translate }}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
<!-- Delete selected -->
|
<!-- Delete selected -->
|
||||||
<button mat-menu-item [disabled]="!selectedRows.length" (click)="removeSelected()">
|
<button mat-menu-item [disabled]="!selectedRows.length" (click)="removeSelected()">
|
||||||
<mat-icon>remove</mat-icon>
|
<mat-icon>remove</mat-icon>
|
||||||
@ -211,22 +217,19 @@
|
|||||||
<span>{{ 'Edit details' | translate }}</span>
|
<span>{{ 'Edit details' | translate }}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<!-- Duplicate button -->
|
||||||
|
<button mat-menu-item (click)="duplicateTopic(item.contentObject)" *ngIf="isTopic(item.contentObject)">
|
||||||
|
<mat-icon>file_copy</mat-icon>
|
||||||
|
<span>{{ 'Create copy' | translate }}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
<!-- Delete Button -->
|
<!-- Delete Button -->
|
||||||
<button
|
<button mat-menu-item (click)="removeFromAgenda(item)" *ngIf="!isTopic(item.contentObject)">
|
||||||
mat-menu-item
|
|
||||||
(click)="removeFromAgenda(item)"
|
|
||||||
*ngIf="item.contentObjectData.collection !== 'topics/topic'"
|
|
||||||
>
|
|
||||||
<mat-icon>remove</mat-icon>
|
<mat-icon>remove</mat-icon>
|
||||||
<span>{{ 'Remove from agenda' | translate }}</span>
|
<span>{{ 'Remove from agenda' | translate }}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button mat-menu-item class="red-warning-text" (click)="deleteTopic(item)" *ngIf="isTopic(item.contentObject)">
|
||||||
mat-menu-item
|
|
||||||
class="red-warning-text"
|
|
||||||
(click)="deleteTopic(item)"
|
|
||||||
*ngIf="item.contentObjectData.collection === 'topics/topic'"
|
|
||||||
>
|
|
||||||
<mat-icon>delete</mat-icon>
|
<mat-icon>delete</mat-icon>
|
||||||
<span>{{ 'Delete' | translate }}</span>
|
<span>{{ 'Delete' | translate }}</span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -350,4 +350,43 @@ export class AgendaListComponent extends BaseListViewComponent<ViewItem> impleme
|
|||||||
this.listOfSpeakersRepo.deleteAllSpeakersOfAllListsOfSpeakers().catch(this.raiseError);
|
this.listOfSpeakersRepo.deleteAllSpeakersOfAllListsOfSpeakers().catch(this.raiseError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicates a single selected item.
|
||||||
|
*
|
||||||
|
* @param item The item to duplicte.
|
||||||
|
*/
|
||||||
|
public duplicateTopic(topic: ViewTopic): void {
|
||||||
|
this.topicRepo.duplicateTopic(topic);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicates all selected items, that are topics.
|
||||||
|
*
|
||||||
|
* @param selectedItems All selected items.
|
||||||
|
*/
|
||||||
|
public duplicateMultipleTopics(selectedItems: ViewItem[]): void {
|
||||||
|
for (const item of selectedItems) {
|
||||||
|
if (this.isTopic(item.contentObject)) {
|
||||||
|
this.duplicateTopic(item.contentObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to determine, if the given item is a `Topic`.
|
||||||
|
*
|
||||||
|
* @param item The selected item.
|
||||||
|
*
|
||||||
|
* @returns `true` if the given item's collection is equal to the `Topic.COLLECTIONSTRING`.
|
||||||
|
*/
|
||||||
|
public isTopic(obj: any): obj is ViewTopic {
|
||||||
|
const topic = obj as ViewTopic;
|
||||||
|
return (
|
||||||
|
!!topic &&
|
||||||
|
topic.collectionString !== undefined &&
|
||||||
|
topic.collectionString === ViewTopic.COLLECTIONSTRING &&
|
||||||
|
!!topic.topic
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,10 @@ export interface TopicTitleInformation extends TitleInformationWithAgendaItem {
|
|||||||
export class ViewTopic extends BaseViewModelWithAgendaItemAndListOfSpeakers<Topic> implements TopicTitleInformation {
|
export class ViewTopic extends BaseViewModelWithAgendaItemAndListOfSpeakers<Topic> implements TopicTitleInformation {
|
||||||
public static COLLECTIONSTRING = Topic.COLLECTIONSTRING;
|
public static COLLECTIONSTRING = Topic.COLLECTIONSTRING;
|
||||||
|
|
||||||
|
public get topic(): Topic {
|
||||||
|
return this._model;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats the category for search
|
* Formats the category for search
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user