-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(seeds): fix state reset on add seeds dialog re-open, fix componen…
…ts naming
- Loading branch information
1 parent
39a3822
commit 57ea0b8
Showing
6 changed files
with
88 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/app/seeds/add-seeds-button/add-seeds-button.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; | ||
|
||
import { DialogComponent } from '../../ui/dialog/dialog.component'; | ||
import { IconComponent } from '../../ui/icon/icon'; | ||
import { AddSeedsComponent } from '../add-seeds/add-seeds.component'; | ||
|
||
@Component({ | ||
selector: 'app-add-seeds-button', | ||
template: ` | ||
<button | ||
class="fixed bottom-16 right-6 flex items-center justify-center rounded-full bg-action-primary shadow-md" | ||
title="Add" | ||
(click)="showAddSeedsDialog.set(true)" | ||
> | ||
<app-icon class="size-10 text-primary" name="plusInCircle" /> | ||
</button> | ||
<app-dialog [open]="showAddSeedsDialog()" (close)="showAddSeedsDialog.set(false)"> | ||
<ng-template> | ||
<app-add-seeds (close)="showAddSeedsDialog.set(false)" /> | ||
</ng-template> | ||
</app-dialog> | ||
`, | ||
imports: [IconComponent, AddSeedsComponent, DialogComponent], | ||
standalone: true, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class AddSeedsButtonComponent { | ||
showAddSeedsDialog = signal(false); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { ChangeDetectionStrategy, Component, inject, output, signal } from '@angular/core'; | ||
|
||
import { BarnService } from '../../barn/barn.service'; | ||
import { ButtonDirective } from '../../ui/button/button'; | ||
import { InputDirective } from '../../ui/input/input'; | ||
|
||
@Component({ | ||
selector: 'app-add-seeds', | ||
template: ` | ||
<div class="flex h-full flex-col gap-8"> | ||
<textarea | ||
class="grow" | ||
appInput | ||
placeholder="One seed a line" | ||
[value]="newSeed()" | ||
(input)="updateSeed($event)" | ||
></textarea> | ||
<div class="mt-auto flex shrink-0 justify-end gap-4"> | ||
<button appButton (click)="close.emit()">Cancel</button> | ||
<button appButton appButtonType="primary" (click)="add()">Add</button> | ||
</div> | ||
</div> | ||
`, | ||
imports: [ButtonDirective, InputDirective], | ||
standalone: true, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class AddSeedsComponent { | ||
private barnService = inject(BarnService); | ||
|
||
close = output(); | ||
|
||
newSeed = signal(''); | ||
|
||
updateSeed(event: Event) { | ||
this.newSeed.set((event.target as HTMLTextAreaElement).value); | ||
} | ||
|
||
add() { | ||
const newSeeds = this.newSeed() | ||
.split('\n') | ||
.map(seed => seed.trim()) | ||
.filter(seed => !!seed); | ||
|
||
if (newSeeds.length !== 0) { | ||
this.barnService.addSeeds(newSeeds); | ||
} | ||
|
||
this.close.emit(); | ||
} | ||
} |
25 changes: 0 additions & 25 deletions
25
src/app/seeds/add-terms-button/add-terms-button.component.ts
This file was deleted.
Oops, something went wrong.
58 changes: 0 additions & 58 deletions
58
src/app/seeds/add-terms-dialog/add-terms-dialog.component.ts
This file was deleted.
Oops, something went wrong.