You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.8 KiB
61 lines
1.8 KiB
import {Component, OnInit} from '@angular/core';
|
|
import {RouterLink, ActivatedRoute} from '@angular/router';
|
|
import {ThemeService} from '../../services/theme.service';
|
|
import {NgClass, NgIf} from '@angular/common';
|
|
import {TranslateModule} from '@ngx-translate/core';
|
|
import {Work} from '../../models/work.model';
|
|
import {WorkService} from '../../services/work.service';
|
|
import {NgForOf} from '@angular/common';
|
|
import {FormsModule, NgForm} from '@angular/forms';
|
|
import {EditorComponent} from '../editor/editor.component';
|
|
import {WorkListDetailComponent} from '../work-list-detail/work-list-detail.component';
|
|
|
|
@Component({
|
|
selector: 'app-work',
|
|
templateUrl: './work.component.html',
|
|
styleUrl: './work.component.scss',
|
|
standalone: true,
|
|
imports: [
|
|
NgClass,
|
|
TranslateModule,
|
|
RouterLink,
|
|
NgForOf,
|
|
FormsModule,
|
|
EditorComponent,
|
|
WorkListDetailComponent,
|
|
NgIf,
|
|
],
|
|
})
|
|
export class WorkComponent implements OnInit {
|
|
// à retirer quand les boutons seront dans editor.component
|
|
isLoaded: boolean = false; // Pour vérifier si le chargement est terminé
|
|
|
|
themeClass!: string;
|
|
work!: Work;
|
|
|
|
constructor(
|
|
private route: ActivatedRoute,
|
|
private themeService: ThemeService,
|
|
protected workService: WorkService
|
|
) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.themeService.isDarkTheme.subscribe((value) => {
|
|
value
|
|
? (this.themeClass = 'dark-theme')
|
|
: (this.themeClass = 'light-theme');
|
|
});
|
|
|
|
const work_id = String(this.route.snapshot.paramMap.get('id'));
|
|
|
|
this.workService.getWorkById(work_id).subscribe((response: Work) => {
|
|
this.work = response as Work;
|
|
});
|
|
}
|
|
|
|
onSubmit(form: NgForm) {
|
|
this.workService.postWork(form);
|
|
}
|
|
}
|