updated tag tab
This commit is contained in:
parent
3d0d63b1d4
commit
410c84b3e5
4 changed files with 56 additions and 32 deletions
|
|
@ -1,17 +1,24 @@
|
||||||
<div class="tags-container">
|
<div class="tags-container">
|
||||||
<div class="tag-list-header">
|
<mat-card appearance="outlined">
|
||||||
<p>Tags</p>
|
<mat-card-header>
|
||||||
<app-divider />
|
<mat-card-title>Tags</mat-card-title>
|
||||||
</div>
|
</mat-card-header>
|
||||||
|
|
||||||
<div class="tag-list">
|
<mat-card-content>
|
||||||
@for (tag of tags(); track tag.id) {
|
<div class="new-tag">
|
||||||
<div>{{ tag.name }}</div>
|
<app-metadata-form (newMetaData)="createTag($event.name)" [editing]="true" [label]="'New Tag'"/>
|
||||||
}
|
|
||||||
@if (!tags().length) {
|
|
||||||
<div class="tag-list-empty">
|
|
||||||
No tags to display
|
|
||||||
</div>
|
</div>
|
||||||
}
|
|
||||||
</div>
|
<div class="tag-list">
|
||||||
|
@for (tag of tags(); track tag.id) {
|
||||||
|
<app-metadata-form [metadata]="tag" (newMetaData)="updateTag($event)" />
|
||||||
|
}
|
||||||
|
@if (!tags().length) {
|
||||||
|
<div>
|
||||||
|
No tags to display
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,21 @@
|
||||||
.tags-container {
|
@use "variables";
|
||||||
display: grid;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag-list-header {
|
.tags-container {
|
||||||
padding-top: 1rem;
|
padding-top: 0.5rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
p {
|
mat-card {
|
||||||
font-size: 1.8rem;
|
max-width: variables.$wide-screen;
|
||||||
line-height: 100%;
|
|
||||||
font-weight: 400;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
app-divider {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.new-tag {
|
||||||
|
padding-top: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.tag-list {
|
.tag-list {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 1rem;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
import { Component, computed } from '@angular/core';
|
import { Component, computed } from '@angular/core';
|
||||||
import { TagService } from '../../../services/tag.service';
|
import { Tag, TagService } from '../../../services/tag.service';
|
||||||
import { DividerComponent } from '../../divider/divider.component';
|
import { MatCardModule } from '@angular/material/card';
|
||||||
|
import { MetadataFormComponent } from '../metadata-form/metadata-form.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-tags',
|
selector: 'app-tags',
|
||||||
imports: [
|
imports: [
|
||||||
DividerComponent
|
MatCardModule,
|
||||||
|
MetadataFormComponent
|
||||||
],
|
],
|
||||||
templateUrl: './tags.component.html',
|
templateUrl: './tags.component.html',
|
||||||
styleUrl: './tags.component.scss'
|
styleUrl: './tags.component.scss'
|
||||||
|
|
@ -14,4 +16,14 @@ export class TagsComponent {
|
||||||
protected tags = computed(() => this.tagService.tags());
|
protected tags = computed(() => this.tagService.tags());
|
||||||
|
|
||||||
public constructor(private readonly tagService: TagService) { }
|
public constructor(private readonly tagService: TagService) { }
|
||||||
|
|
||||||
|
public async createTag(name: string): Promise<void> {
|
||||||
|
await this.tagService.create({ name });
|
||||||
|
await this.tagService.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async updateTag(tag: Tag): Promise<void> {
|
||||||
|
await this.tagService.update(tag);
|
||||||
|
await this.tagService.fetch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,21 @@ export class TagService {
|
||||||
public async fetch(): Promise<void> {
|
public async fetch(): Promise<void> {
|
||||||
this.internalTags.set(await this.http.get<Tag[]>(this.tagPath));
|
this.internalTags.set(await this.http.get<Tag[]>(this.tagPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async create(tag: CreateTag): Promise<Tag> {
|
||||||
|
return await this.http.post<Tag>(this.tagPath, tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async update(tag: Tag): Promise<Tag> {
|
||||||
|
return await this.http.put<Tag>(this.tagPath, tag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Tag {
|
export interface Tag {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CreateTag {
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue