generated from maximegris/angular-electron
-
-
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.
- Loading branch information
Showing
6 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/app/shared/components/input-quest/input-quest.component.html
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,25 @@ | ||
<div class="relative"> | ||
<ng-select class="form-control" [items]="values()" [(ngModel)]="quest" placeholder="Select quest..." | ||
(change)="change.emit($event?.value)" [compareWith]="itemCompare" [searchFn]="search"> | ||
|
||
<ng-template ng-label-tmp let-item="item"> | ||
<div class="relative"> | ||
<div class="text-white"> | ||
{{ item.value }} | ||
</div> | ||
</div> | ||
</ng-template> | ||
|
||
<ng-template ng-option-tmp let-item="item"> | ||
<div class="relative"> | ||
<div class="text-white"> | ||
{{ item.value }} | ||
</div> | ||
|
||
<p class="text-white text-sm italic whitespace-break-spaces">{{ item.desc }}</p> | ||
</div> | ||
</ng-template> | ||
</ng-select> | ||
|
||
<app-input-floating-label>{{ label() }}</app-input-floating-label> | ||
</div> |
Empty file.
55 changes: 55 additions & 0 deletions
55
src/app/shared/components/input-quest/input-quest.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,55 @@ | ||
import { | ||
Component, | ||
computed, | ||
inject, | ||
input, | ||
model, | ||
OnInit, | ||
output, | ||
} from '@angular/core'; | ||
import { IQuest } from '../../../../interfaces'; | ||
import { ModService } from '../../../services/mod.service'; | ||
|
||
@Component({ | ||
selector: 'app-input-quest', | ||
templateUrl: './input-quest.component.html', | ||
styleUrl: './input-quest.component.scss', | ||
}) | ||
export class InputQuestComponent implements OnInit { | ||
private modService = inject(ModService); | ||
|
||
public quest = model<IQuest | undefined>(); | ||
public defaultValue = input<string>(); | ||
public label = input<string>('Quest'); | ||
public change = output<string>(); | ||
|
||
public values = computed(() => { | ||
const mod = this.modService.mod(); | ||
|
||
return [ | ||
...mod.quests.map((q) => ({ | ||
value: q.name, | ||
desc: `[${q.giver}] ${q.desc}`, | ||
})), | ||
]; | ||
}); | ||
|
||
ngOnInit() { | ||
const defaultItem = this.defaultValue(); | ||
if (defaultItem) { | ||
const foundItem = this.values().find((i) => i.value === defaultItem); | ||
this.quest.set(foundItem as unknown as IQuest); | ||
} | ||
} | ||
|
||
public itemCompare( | ||
itemA: { value: string; desc: string }, | ||
itemB: { value: string; desc: string } | ||
): boolean { | ||
return itemA.value === itemB.value; | ||
} | ||
|
||
public search(term: string, item: { value: string }) { | ||
return item.value.toLowerCase().includes(term.toLowerCase()); | ||
} | ||
} |
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
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