Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 28x 28x 28x 28x 28x 28x 24x 24x 24x 2x 1x 1x 1x 1x 1x 1x 1x | import { AfterContentInit, Component, ContentChild, ElementRef, EventEmitter, Input, Output } from '@angular/core';
import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms';
import { MatButton } from '@angular/material/button';
import { MatIcon } from '@angular/material/icon';
import { MatTooltip } from '@angular/material/tooltip';
import { Job } from '@app/core/model/job.interface';
import { CommentInputComponent } from '../forms/inputs/comment-input.component';
import { JobService } from '@app/core/services/job.service';
import { DescriptionInputComponent } from "../forms/inputs/description-input.component";
import { ProfileInputComponent } from '../forms/inputs/profile-input.component';
import { TitleInputComponent } from '../forms/inputs/title-input.component';
import { CompanyInputComponent } from "../forms/inputs/company-input.component";
import { UpdateJobFieldRequest } from '@app/core/model/update-job-request.interface';
import { NotificationService } from '@app/core/services/notification.service';
import { SalaryInputComponent } from "../forms/inputs/salary-input.component";
import { UrlInputComponent } from "../forms/inputs/url-input.component";
@Component({
selector: 'app-job-editable-field',
imports: [MatIcon, MatButton, MatTooltip, ReactiveFormsModule, CommentInputComponent, DescriptionInputComponent, ProfileInputComponent, TitleInputComponent, CompanyInputComponent, SalaryInputComponent, UrlInputComponent],
templateUrl: './job-editable-field.component.html',
styleUrl: './job-editable-field.component.scss'
})
export class JobEditableFieldComponent implements AfterContentInit {
@Input({ required: true }) job!: Job;
@Input({required: true}) field!: keyof Pick<Job, 'url' | 'title' | 'description' | 'profile' | 'comment' | 'company' | 'salary'>;
@Input() actionLabel: string = "Edit";
@Output() fieldEdited = new EventEmitter<Job>();
@ContentChild('fieldDisplayContent', { static: false }) content: ElementRef | undefined;
hasContent = false;
formVisible = false;
loading = false;
form!: FormGroup;
constructor(private readonly fb: FormBuilder, private readonly jobService: JobService, private readonly notificationService: NotificationService) {}
ngAfterContentInit() {
this.hasContent = !!this.content;
}
ngOnInit(): void {
this.initForm();
}
displayForm(): void {
this.formVisible = true;
}
private initForm(): void {
this.form = this.fb.group({});
}
submit(): void {
if (this.form.valid) {
this.loading = true;
this.jobService.updateJobField(this.job.id, this.form.value as UpdateJobFieldRequest).subscribe((job) => {
this.loading = false;
this.formVisible = false;
const term = $localize `:@@info.job.updated:updated`;
this.notificationService.confirmation($localize `:@@job.created_or_saved:Job ${term} successfully`);
this.fieldEdited.emit(job);
});
}
}
cancel(): void {
this.formVisible = false;
}
}
|