TextComponent.editable

This commit is contained in:
Patrick Haßel 2024-10-29 12:03:57 +01:00
parent 7dc4c3ca7c
commit 65617c1538
4 changed files with 15 additions and 8 deletions

View File

@ -60,7 +60,8 @@ export class UserService {
return this.subject.subscribe(next);
}
owns(group: Group): boolean {
iOwn(group: Group): boolean {
return this.user?.publicUuid === group.owner.publicUuid;
}
}

View File

@ -8,15 +8,15 @@
<tr>
<th>Titel</th>
<td>
<app-text *ngIf="userService.owns(group)" [initial]="group.title" (onChange)="changeTitle(group, $event)"></app-text>
<ng-container *ngIf="!userService.owns(group)"></ng-container>
<app-text [initial]="group.title" [editable]="userService.iOwn(group)" (onChange)="changeTitle(group, $event)"></app-text>
<ng-container *ngIf="!userService.iOwn(group)"></ng-container>
</td>
</tr>
<tr>
<th>Passwort</th>
<td>
<app-text *ngIf="userService.owns(group)" [initial]="group.password" (onChange)="changePassword(group, $event)"></app-text>
<ng-container *ngIf="!userService.owns(group)"></ng-container>
<app-text [initial]="group.password" [editable]="userService.iOwn(group)" (onChange)="changePassword(group, $event)"></app-text>
<ng-container *ngIf="!userService.iOwn(group)"></ng-container>
</td>
</tr>
<tr>

View File

@ -1 +1,2 @@
<input [(ngModel)]="model" (focus)="begin()" (blur)="apply()" (keydown.enter)="apply()" (keydown.escape)="abort()">
<input *ngIf="editable" [(ngModel)]="model" (focus)="begin()" (blur)="apply()" (keydown.enter)="apply()" (keydown.escape)="abort()">
<div *ngIf="!editable">{{ _initial }}</div>

View File

@ -1,18 +1,20 @@
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {FormsModule} from "@angular/forms";
import {NgIf} from "@angular/common";
@Component({
selector: 'app-text',
standalone: true,
imports: [
FormsModule
FormsModule,
NgIf
],
templateUrl: './text.component.html',
styleUrl: './text.component.less'
})
export class TextComponent implements OnInit {
private _initial: string = "";
protected _initial: string = "";
protected model: string = this._initial;
@ -29,6 +31,9 @@ export class TextComponent implements OnInit {
}
}
@Input()
editable: boolean = false;
ngOnInit(): void {
this.model = this._initial;
}