mirror of
https://github.com/block-core/blockcore-notes.git
synced 2024-09-29 06:20:42 +00:00
Display labels on the saved note
This commit is contained in:
parent
a8adc08378
commit
ba95ec322a
@ -123,6 +123,8 @@ import { ScrollingModule } from '@angular/cdk/scrolling';
|
||||
import { EditorComponent } from './editor/editor';
|
||||
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
||||
import { ArticleComponent } from './article/article';
|
||||
import { LabelPipe } from './shared/label.pipe';
|
||||
import { LabelComponent } from './shared/label/label';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
@ -199,6 +201,8 @@ import { ArticleComponent } from './article/article';
|
||||
UsernamePipe,
|
||||
EditorComponent,
|
||||
ArticleComponent,
|
||||
LabelComponent,
|
||||
LabelPipe,
|
||||
],
|
||||
imports: [
|
||||
AboutModule,
|
||||
|
@ -8,6 +8,7 @@
|
||||
</div>
|
||||
|
||||
<app-content [event]="note"></app-content>
|
||||
<app-label [labels]="note.labels"></app-label>
|
||||
<!-- <div class="content">
|
||||
{{ note.content }}<span *ngIf="note.contentCut">... (message was truncated)</span>
|
||||
<div *ngIf="details">
|
||||
|
@ -22,6 +22,16 @@ export class LabelService {
|
||||
|
||||
constructor(private storage: StorageService) {}
|
||||
|
||||
getName(id: string) {
|
||||
const label = this.labels.find((l) => l.id == id);
|
||||
|
||||
if (!label) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return label.name;
|
||||
}
|
||||
|
||||
async initialize() {
|
||||
this.labels = await this.storage.storage.getLabels();
|
||||
|
||||
|
15
src/app/shared/label.pipe.ts
Normal file
15
src/app/shared/label.pipe.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { LabelService } from '../services/label';
|
||||
|
||||
@Pipe({ name: 'label' })
|
||||
export class LabelPipe implements PipeTransform {
|
||||
constructor(private labelService: LabelService) {}
|
||||
|
||||
transform(value?: string): string {
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return this.labelService.getName(value);
|
||||
}
|
||||
}
|
1
src/app/shared/label/label.html
Normal file
1
src/app/shared/label/label.html
Normal file
@ -0,0 +1 @@
|
||||
Labels: <span *ngFor="let label of labels; let i=index; let isLast=last"> <strong>{{ label | label }}</strong><span *ngIf="!isLast">, </span> </span>
|
12
src/app/shared/label/label.ts
Normal file
12
src/app/shared/label/label.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { LabelService } from 'src/app/services/label';
|
||||
|
||||
@Component({
|
||||
selector: 'app-label',
|
||||
templateUrl: 'label.html',
|
||||
})
|
||||
export class LabelComponent {
|
||||
@Input() labels: string[] = [];
|
||||
|
||||
constructor(private labelService: LabelService) {}
|
||||
}
|
0
src/app/shared/labels/labels.css
Normal file
0
src/app/shared/labels/labels.css
Normal file
@ -6,6 +6,7 @@ import { v4 as uuidv4 } from 'uuid';
|
||||
@Component({
|
||||
selector: 'app-labels',
|
||||
templateUrl: 'labels.html',
|
||||
styleUrls: ['labels.css'],
|
||||
})
|
||||
export class LabelsComponent {
|
||||
showNewLabel?: boolean;
|
||||
|
@ -9,8 +9,8 @@ export interface ReplyEntry {
|
||||
|
||||
@Component({
|
||||
selector: 'app-reply-list',
|
||||
templateUrl: './reply-list.html',
|
||||
styleUrls: ['./reply-list.css'],
|
||||
templateUrl: 'reply-list.html',
|
||||
styleUrls: ['reply-list.css'],
|
||||
})
|
||||
export class ReplyListComponent {
|
||||
@Input() keys: string[] = [];
|
||||
|
Loading…
Reference in New Issue
Block a user