Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Sep 5, 2024
1 parent 6195723 commit ae3b386
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/app/shared/components/input-stem/input-stem.component.html
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)]="stem" placeholder="Select STEM..."
(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.
59 changes: 59 additions & 0 deletions src/app/shared/components/input-stem/input-stem.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import {
Component,
computed,
inject,
input,
model,
OnInit,
output,
} from '@angular/core';
import { sortBy } from 'lodash';
import { ISTEM } from '../../../../interfaces';
import { ModService } from '../../../services/mod.service';

@Component({
selector: 'app-input-stem',
templateUrl: './input-stem.component.html',
styleUrl: './input-stem.component.scss',
})
export class InputStemComponent implements OnInit {
private modService = inject(ModService);

public stem = model<ISTEM | undefined>();
public defaultValue = input<string>();
public label = input<string>('STEM');
public change = output<string>();

public values = computed(() => {
const mod = this.modService.mod();

return [
...sortBy(
mod.stems.map((q) => ({
value: q._gameId,
desc: q.all.desc,
})),
'value'
),
];
});

ngOnInit() {
const defaultItem = this.defaultValue();
if (defaultItem) {
const foundItem = this.values().find((i) => i.value === defaultItem);
this.stem.set(foundItem as unknown as ISTEM);
}
}

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());
}
}

0 comments on commit ae3b386

Please sign in to comment.