import { ChangeDetectionStrategy , Component , Input , OnChanges , OnInit } from '@angular/core' ; import { ContentTutorialsEntry } from '../../../../../main/src/app/content/meta' ; import { DataService } from '../../data.service' ; import { VersionComponent } from '../../version/version/version.component' ; @ Component ( { selector : 'app-tutorials-entry' , templateUrl : './tutorials-entry.component.html' , styleUrls : [ './tutorials-entry.component.scss' ] , changeDetection : ChangeDetectionStrategy . OnPush , } ) export class TutorialsEntryComponent implements OnInit , OnChanges { @ Input ( ) entry : ContentTutorialsEntry ; constructor ( private versionComponent , private data ) { } ngOnInit ( ) { } ngOnChanges ( ) { if ( ! this . entry . links ) { this . entry . links = [ ] ; } } create ( ) { this . entry . links . push ( { } ) ; } delete ( index ) { if ( confirm ( 'Delete link?' ) ) { this . data . delete ( this . entry . links , index ) ; } } moveUp ( index ) { this . data . move ( this . entry . links , index , index - 1 ) ; } moveDown ( index ) { this . data . move ( this . entry . links , index , index + 1 ) ; } }