making metadata form component
This commit is contained in:
parent
2c6d0c1d0c
commit
5f3dabb8b7
6 changed files with 47 additions and 17 deletions
|
|
@ -7,12 +7,7 @@
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<div class="category-list">
|
<div class="category-list">
|
||||||
@for (category of categories(); track category.id) {
|
@for (category of categories(); track category.id) {
|
||||||
<!-- TODO: Convert to form...-->
|
<app-metadata-form [metadata]="category" (newMetaData)="updateCategory($event)" />
|
||||||
<div class="category-item">
|
|
||||||
<div>{{ category.name }}</div>
|
|
||||||
|
|
||||||
<button matIconButton><mat-icon>edit</mat-icon></button>
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
@if (!categories().length) {
|
@if (!categories().length) {
|
||||||
<div>
|
<div>
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,3 @@
|
||||||
padding-top: 1rem;
|
padding-top: 1rem;
|
||||||
display: grid;
|
display: grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
.category-item {
|
|
||||||
display: flex;
|
|
||||||
gap: 0.5rem;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,13 @@
|
||||||
import { Component, computed } from '@angular/core';
|
import { Component, computed } from '@angular/core';
|
||||||
import { CategoryService } from '../../../services/category.service';
|
import { Category, CategoryService } from '../../../services/category.service';
|
||||||
import { MatCardModule } from '@angular/material/card';
|
import { MatCardModule } from '@angular/material/card';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MetadataFormComponent } from '../metadata-form/metadata-form.component';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-categories',
|
selector: 'app-categories',
|
||||||
imports: [
|
imports: [
|
||||||
MatCardModule,
|
MatCardModule,
|
||||||
MatIconModule,
|
MetadataFormComponent
|
||||||
MatButtonModule
|
|
||||||
],
|
],
|
||||||
templateUrl: './categories.component.html',
|
templateUrl: './categories.component.html',
|
||||||
styleUrl: './categories.component.scss'
|
styleUrl: './categories.component.scss'
|
||||||
|
|
@ -18,4 +16,8 @@ export class CategoriesComponent {
|
||||||
protected categories = computed(() => this.categoryService.categories());
|
protected categories = computed(() => this.categoryService.categories());
|
||||||
|
|
||||||
public constructor(private readonly categoryService: CategoryService) { }
|
public constructor(private readonly categoryService: CategoryService) { }
|
||||||
|
|
||||||
|
public async updateCategory(category: Category): Promise<void> {
|
||||||
|
console.log('updated category', category); // TODO: Remove
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
<div class="metadata-form-container">
|
||||||
|
<div>{{ metadata().name }}</div>
|
||||||
|
|
||||||
|
<button matIconButton>
|
||||||
|
<mat-icon>edit</mat-icon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
.metadata-form-container {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.5rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
import {Component, input, output, signal} from '@angular/core';
|
||||||
|
import { MatCardModule } from '@angular/material/card';
|
||||||
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
|
||||||
|
interface MetaData {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-metadata-form',
|
||||||
|
imports: [
|
||||||
|
MatCardModule,
|
||||||
|
MatIconModule,
|
||||||
|
MatButtonModule
|
||||||
|
],
|
||||||
|
templateUrl: './metadata-form.component.html',
|
||||||
|
styleUrl: './metadata-form.component.scss'
|
||||||
|
})
|
||||||
|
export class MetadataFormComponent {
|
||||||
|
public metadata = input.required<MetaData>();
|
||||||
|
|
||||||
|
public newMetaData = output<MetaData>();
|
||||||
|
|
||||||
|
public editing = signal(false);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue