nx-primeng-sakai-v17/src/app/components/input/input.component.ts

129 lines
3.0 KiB
TypeScript
Raw Normal View History

2021-12-09 14:24:42 +00:00
import {Component, OnInit} from '@angular/core';
2021-12-28 10:29:25 +00:00
import {CountryService} from '../../service/countryservice';
import {NodeService} from '../../service/nodeservice';
2021-12-09 14:24:42 +00:00
import {SelectItem} from 'primeng/api';
@Component({
2021-12-28 10:29:25 +00:00
templateUrl: './input.component.html',
2021-12-09 14:24:42 +00:00
styles: [`:host ::ng-deep .p-multiselect {
min-width: 15rem;
}
:host ::ng-deep .multiselect-custom-virtual-scroll .p-multiselect {
min-width: 20rem;
}
2021-12-22 13:06:49 +00:00
:host ::ng-deep .multiselect-custom .p-multiselect-label, {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
2021-12-09 14:24:42 +00:00
}
:host ::ng-deep .multiselect-custom .country-item.country-item-value {
padding: .25rem .5rem;
border-radius: 3px;
display: inline-flex;
margin-right: .5rem;
background-color: var(--primary-color);
color: var(--primary-color-text);
}
:host ::ng-deep .multiselect-custom .country-item.country-item-value img.flag {
width: 17px;
}
:host ::ng-deep .multiselect-custom .country-item {
display: flex;
align-items: center;
}
:host ::ng-deep .multiselect-custom .country-item img.flag {
width: 18px;
margin-right: .5rem;
}
:host ::ng-deep .multiselect-custom .country-placeholder {
padding: 0.25rem;
}
`]
})
2021-12-28 10:29:25 +00:00
export class InputComponent implements OnInit{
2021-12-09 14:24:42 +00:00
countries: any[];
filteredCountries: any[];
selectedCountryAdvanced: any[];
2021-12-22 13:06:49 +00:00
valSlider = 50;
2021-12-09 14:24:42 +00:00
valColor = '#424242';
valRadio: string;
valCheck: string[] = [];
valSwitch: boolean;
cities: SelectItem[];
selectedList: SelectItem;
selectedDrop: SelectItem;
selectedMulti: string[] = [];
2021-12-22 13:06:49 +00:00
treeSelectNodes: any[];
selectedNode: SelectItem;
2021-12-09 14:24:42 +00:00
valToggle = false;
paymentOptions: any[];
valSelect1: string;
valSelect2: string;
valueKnob = 20;
selectedDate:any;
2021-12-22 13:06:49 +00:00
constructor(private countryService: CountryService, private nodeService: NodeService) {}
2021-12-09 14:24:42 +00:00
ngOnInit() {
this.countryService.getCountries().then(countries => {
this.countries = countries;
});
this.cities = [
{label: 'New York', value: {id: 1, name: 'New York', code: 'NY'}},
{label: 'Rome', value: {id: 2, name: 'Rome', code: 'RM'}},
{label: 'London', value: {id: 3, name: 'London', code: 'LDN'}},
{label: 'Istanbul', value: {id: 4, name: 'Istanbul', code: 'IST'}},
{label: 'Paris', value: {id: 5, name: 'Paris', code: 'PRS'}}
];
this.paymentOptions = [
{name: 'Option 1', value: 1},
{name: 'Option 2', value: 2},
{name: 'Option 3', value: 3}
];
2021-12-22 13:06:49 +00:00
2021-12-22 13:15:15 +00:00
this.nodeService.getFiles().then(files => this.treeSelectNodes = files)
2021-12-09 14:24:42 +00:00
}
filterCountry(event) {
const filtered: any[] = [];
const query = event.query;
for (let i = 0; i < this.countries.length; i++) {
const country = this.countries[i];
if (country.name.toLowerCase().indexOf(query.toLowerCase()) == 0) {
filtered.push(country);
}
}
this.filteredCountries = filtered;
}
}