Front/Back: add entry settings modal
This commit is contained in:
1 parent
8724a96b81
commit
625ec3367e
15 files changed
+334
-57
No files matched your search
Whitespace-only changes.
+40
@@ -0,0 +1,40 @@
|
||||
<div class="card border-top border-3 border-primary rounded-0 media-dialog-main mb-0">
|
||||
<div class="modal-header card-header py-3 px-4">
|
||||
<h5 class="mb-0 text-primary">Entry Settings</h5>
|
||||
<button type="button" class="btn-close" aria-label="Close" (click)="onClose()"></button>
|
||||
</div>
|
||||
<div class="card-body p-4 pt-0">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-12">
|
||||
<form class="row g-3" [formGroup]="entryForm">
|
||||
<div class="col-md-12">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" id="favorit" formControlName="favorit" class="form-check-input">
|
||||
<label for="favorit" class="form-check-label">Favorit</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" id="hidden" formControlName="hidden" class="form-check-input">
|
||||
<label for="hidden" class="form-check-label">Hidden</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" id="showInCalendar" formControlName="showInCalendar" class="form-check-input">
|
||||
<label for="showInCalendar" class="form-check-label">Show in Calendar</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" id="watchlist" formControlName="watchlist" class="form-check-input">
|
||||
<label for="watchlist" class="form-check-label">Watchlist</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" id="autoSync" formControlName="autoSync" class="form-check-input">
|
||||
<label for="autoSync" class="form-check-label">Auto Sync</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-12 mt-3 d-flex justify-content-end gap-3">
|
||||
<button type="button" class="btn btn-primary px-4 rounded-0" (click)="onSubmit()">Confirm</button>
|
||||
<button type="button" class="btn btn-secondary px-4 rounded-0" (click)="onClose()">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/* tslint:disable:no-unused-variable */
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { DebugElement } from '@angular/core';
|
||||
|
||||
import { EntrySettingsModalComponent } from './entry-settings-modal.component';
|
||||
|
||||
describe('EntrySettingsModalComponent', () => {
|
||||
let component: EntrySettingsModalComponent;
|
||||
let fixture: ComponentFixture<EntrySettingsModalComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ EntrySettingsModalComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(EntrySettingsModalComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import {
|
||||
MatDialogRef,
|
||||
MAT_DIALOG_DATA,
|
||||
MatDialog,
|
||||
} from '@angular/material/dialog';
|
||||
import { EntryService } from '../../../core/services/entry.service';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-entry-settings-modal',
|
||||
templateUrl: './entry-settings-modal.component.html',
|
||||
styleUrls: ['./entry-settings-modal.component.css'],
|
||||
})
|
||||
export class EntrySettingsModalComponent implements OnInit {
|
||||
entryId!: number;
|
||||
entryForm: FormGroup;
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<EntrySettingsModalComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
private formBuilder: FormBuilder,
|
||||
private entryService: EntryService
|
||||
) {
|
||||
this.entryForm = this.formBuilder.group({
|
||||
watchlist: [null],
|
||||
favorit: [null],
|
||||
hidden: [null],
|
||||
showInCalendar: [null],
|
||||
autoSync: [null],
|
||||
});
|
||||
|
||||
if (this.data && this.data.entry) {
|
||||
this.entryForm.patchValue(this.data.entry);
|
||||
this.entryId = this.data.entry.id;
|
||||
} else {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
onSubmit() {
|
||||
const entryData = this.entryForm.value;
|
||||
|
||||
this.entryService.updateEntry(this.entryId, entryData).subscribe({
|
||||
next: (result) => {
|
||||
this.dialogRef.close({ entry: result });
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
onClose() {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user