import { Component , Input } from '@angular/core' ; import { HsCompositionsDeleteDialogComponent } from './dialogs/delete-dialog.component' ; import { HsCompositionsInfoDialogComponent } from './dialogs/info-dialog.component' ; import { HsCompositionsService } from './compositions.service' ; import { HsCompositionsShareDialogComponent } from './dialogs/share-dialog.component' ; import { HsConfig } from '../../config.service' ; import { HsDialogContainerService } from '../layout/dialogs/dialog-container.service' ; import { HsLanguageService } from '../language/language.service' ; import { HsLayoutService } from '../layout/layout.service' ; import { HsToastService } from '../layout/toast/toast.service' ; @ Component ( { selector : 'hs-compositions-list-item' , templateUrl : 'compositions-list-item.html' , } ) export class HsCompositionsListItemComponent { @ Input ( ) composition ; @ Input ( ) selectedCompId ; constructor ( public hsCompositionsService , public hsLayoutService , public hsToastService , public hsDialogContainerService , public hsConfig , public hsLanguageService ) { } param composition openComposition ( composition ) { this . hsCompositionsService . loadCompositionParser ( composition ) . then ( ( ) => { this . hsLayoutService . setMainPanel ( 'layermanager' ) ; } ) . catch ( ( ) => { } ) ; } param record async detailComposition ( record ) { const info = await this . hsCompositionsService . getCompositionInfo ( record ) ; if ( info !== undefined ) { this . infoDialogBootstrap ( info ) ; } } param record async shareComposition ( record ) { let url ; try { await this . hsCompositionsService . shareComposition ( record ) . then ( async ( ) => { url = await this . hsCompositionsService . getShareUrl ( ) ; if ( url !== undefined ) { this . shareDialogBootstrap ( record , url ) ; } else { throw new Error ( 'COMPOSITIONS.sharingUrlIsNotAvailable' ) ; } } ) ; } catch ( e ) { this . hsToastService . createToastPopupMessage ( this . hsLanguageService . getTranslation ( 'COMPOSITIONS.errorWhileSharingOnSocialNetwork' ) , this . hsLanguageService . getTranslationIgnoreNonExisting ( 'ERRORMESSAGES' , e . message , { url : url } ) , { disableLocalization : true } ) ; } } param composition description confirmDelete ( composition ) { if ( ! composition . editable ) { return ; } this . deleteDialogBootstrap ( composition ) ; } param composition deleteDialogBootstrap ( composition ) { this . hsDialogContainerService . create ( HsCompositionsDeleteDialogComponent , { compositionToDelete : composition , } ) ; } param record param url shareDialogBootstrap ( record , url ) { this . hsDialogContainerService . create ( HsCompositionsShareDialogComponent , { url , title : this . hsConfig . social_hashtag && ! record . title . includes ( this . hsConfig . social_hashtag ) ? record . title + ' ' + this . hsConfig . social_hashtag : record . title , abstract : record . abstract , } ) ; } infoDialogBootstrap ( info ) { this . hsDialogContainerService . create ( HsCompositionsInfoDialogComponent , { info , } ) ; } }