Add file metadata sidebar entry
Signed-off-by: trivernis <trivernis@protonmail.com>pull/4/head
parent
7501e65d5c
commit
e233c1e59c
@ -0,0 +1,13 @@
|
||||
<div class="metadata-inner">
|
||||
<app-metadata-entry *ngIf="mode === 'read'" [value]="value" [attributeName]="attributeName"></app-metadata-entry>
|
||||
<mat-form-field *ngIf="mode === 'write'">
|
||||
<mat-label>{{attributeName}}</mat-label>
|
||||
<input [formControl]="formControl" type="text" matInput [value]="value">
|
||||
</mat-form-field>
|
||||
<button *ngIf="mode === 'write'" mat-button (click)="this.onSave()">
|
||||
<ng-icon name="mat-save"></ng-icon>
|
||||
</button>
|
||||
<button *ngIf="mode === 'read'" mat-button (click)="mode = 'write'">
|
||||
<ng-icon name="mat-edit"></ng-icon>
|
||||
</button>
|
||||
</div>
|
@ -0,0 +1,17 @@
|
||||
.metadata-inner {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
button {
|
||||
float: right;
|
||||
}
|
||||
|
||||
app-metadata-entry {
|
||||
width: calc(100% - 4em);
|
||||
display: block;
|
||||
}
|
||||
|
||||
mat-form-field {
|
||||
width: calc(100% - 4em);
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { EditableMetadataEntryComponent } from './editable-metadata-entry.component';
|
||||
|
||||
describe('EditableMetadataEntryComponent', () => {
|
||||
let component: EditableMetadataEntryComponent;
|
||||
let fixture: ComponentFixture<EditableMetadataEntryComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ EditableMetadataEntryComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(EditableMetadataEntryComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,36 @@
|
||||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
Input,
|
||||
OnChanges,
|
||||
OnInit,
|
||||
Output
|
||||
} from "@angular/core";
|
||||
import {FormControl} from "@angular/forms";
|
||||
|
||||
@Component({
|
||||
selector: "app-editable-metadata-entry",
|
||||
templateUrl: "./editable-metadata-entry.component.html",
|
||||
styleUrls: ["./editable-metadata-entry.component.scss"]
|
||||
})
|
||||
export class EditableMetadataEntryComponent implements OnInit{
|
||||
|
||||
@Input() attributeName!: string;
|
||||
@Input() value!: string;
|
||||
@Input() mode: "read" | "write" = "read";
|
||||
@Output() valueChangeEvent = new EventEmitter<string>();
|
||||
|
||||
public formControl = new FormControl();
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.formControl.setValue(this.value);
|
||||
}
|
||||
|
||||
public onSave(): void {
|
||||
this.valueChangeEvent.emit(this.formControl.value);
|
||||
this.mode = "read";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue