-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #458 from IgniteUI/bpenkov/autocomplete-samples
Add IgxAutocomplete templates
- Loading branch information
Showing
16 changed files
with
1,243 additions
and
2 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
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
20 changes: 20 additions & 0 deletions
20
...ar/igx-ts/autocomplete/autocomplete-custom/files/src/app/__path__/__name__.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,20 @@ | ||
<p>The <b>igx-autocomplete</b> directive provides a way to enhance a text input by showing a panel of suggested options provided by the developer.</p> | ||
<p>You can read more about configuring the <b>igx-autocomplete</b> in the | ||
<a href="https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/directives/autocomplete/README.md" target="_blank">README</a> or the | ||
<a href="https://www.infragistics.com/products/ignite-ui-angular/angular/components/autocomplete.html" target="_blank">official documentation</a>.</p> | ||
|
||
<section class="sample-content"> | ||
<article class="sample-column"> | ||
<form class="input-group-form"> | ||
<igx-input-group> | ||
<label igxLabel for="town">Town</label> | ||
<input igxInput name="town" type="text" [igxAutocomplete]="townsPanel" [(ngModel)]="townSelected" /> | ||
</igx-input-group> | ||
<igx-drop-down #townsPanel maxHeight="300px"> | ||
<igx-drop-down-item *ngFor="let town of towns | $(camelCaseName)StartsWith:townSelected" [value]="town"> | ||
{{town}} | ||
</igx-drop-down-item> | ||
</igx-drop-down> | ||
</form> | ||
</article> | ||
</section> |
7 changes: 7 additions & 0 deletions
7
...ar/igx-ts/autocomplete/autocomplete-custom/files/src/app/__path__/__name__.component.scss
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,7 @@ | ||
.sample-content { | ||
padding-top: 100px; | ||
} | ||
|
||
.input-group-form { | ||
width: 300px; | ||
} |
28 changes: 28 additions & 0 deletions
28
...igx-ts/autocomplete/autocomplete-custom/files/src/app/__path__/__name__.component.spec.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,28 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { $(ClassName)Component, $(ClassName)PipeStartsWith } from './$(filePrefix).component'; | ||
import { IgxDropDownModule, IgxAutocompleteModule, IgxInputGroupModule } from 'igniteui-angular'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
describe('$(ClassName)Component', () => { | ||
let component: $(ClassName)Component; | ||
let fixture: ComponentFixture<$(ClassName)Component>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [$(ClassName)Component, $(ClassName)PipeStartsWith], | ||
imports: [FormsModule, IgxDropDownModule, IgxAutocompleteModule, NoopAnimationsModule, IgxInputGroupModule] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent($(ClassName)Component); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
...ular/igx-ts/autocomplete/autocomplete-custom/files/src/app/__path__/__name__.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,23 @@ | ||
import { Component, Pipe, PipeTransform } from '@angular/core'; | ||
import { Towns } from './towns-data'; | ||
|
||
@Component({ | ||
selector: 'app-$(filePrefix)', | ||
templateUrl: './$(filePrefix).component.html', | ||
styleUrls: ['./$(filePrefix).component.scss'] | ||
}) | ||
export class $(ClassName)Component { | ||
public towns: any; | ||
public townSelected; | ||
|
||
constructor() { | ||
this.towns = Towns; | ||
} | ||
} | ||
|
||
@Pipe({ name: '$(camelCaseName)StartsWith' }) | ||
export class $(ClassName)PipeStartsWith implements PipeTransform { | ||
public transform(collection: any[], term = '') { | ||
return collection.filter((item) => item.toString().toLowerCase().startsWith(term.trim().toLowerCase())); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...ates/angular/igx-ts/autocomplete/autocomplete-custom/files/src/app/__path__/towns-data.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,27 @@ | ||
export const Towns = [ | ||
'Sofia', 'Plovdiv', 'Varna', 'Burgas', 'Ruse', 'Stara Zagora', 'Pleven', 'Dobrich', 'Sliven', 'Shumen', | ||
'Pernik', 'Haskovo', 'Yambol', 'Pazardzhik', 'Blagoevgrad', 'Veliko Tarnovo', 'Vratsa', 'Gabrovo', 'Asenovgrad', | ||
'Vidin', 'Kazanlak', 'Kyustendil', 'Kardzhali', 'Montana', 'Dimitrovgrad', 'Targovishte', 'Lovech', 'Silistra', 'Dupnitsa', | ||
'Svishtov', 'Razgrad', 'Gorna Oryahovitsa', 'Smolyan', 'Petrich', 'Sandanski', 'Samokov', 'Sevlievo', 'Lom', | ||
'Karlovo', 'Velingrad', 'Nova Zagora', 'Troyan', 'Aytos', 'Botevgrad', 'Gotse Delchev', 'Peshtera', 'Harmanli', 'Karnobat', | ||
'Svilengrad', 'Panagyurishte', 'Chirpan', 'Popovo', 'Rakovski', 'Radomir', 'Novi Iskar', 'Kozloduy', 'Parvomay', 'Berkovitsa', | ||
'Cherven Bryag', 'Pomorie', 'Ihtiman', 'Radnevo', 'Provadiya', 'Novi Pazar', 'Razlog', 'Byala Slatina', 'Nesebar', 'Balchik', | ||
'Kostinbrod', 'Stamboliyski', 'Kavarna', 'Knezha', 'Pavlikeni', 'Mezdra', 'Etropole', 'Levski', 'Teteven', 'Elhovo', 'Bankya', | ||
'Tryavna', 'Lukovit', 'Tutrakan', 'Sredets', 'Sopot', 'Byala', 'Veliki Preslav', 'Isperih', 'Belene', 'Omurtag', 'Bansko', 'Krichim', | ||
'Galabovo', 'Devnya', 'Septemvri', 'Rakitovo', 'Lyaskovets', 'Svoge', 'Aksakovo', 'Kubrat', 'Dryanovo', 'Beloslav', 'Pirdop', | ||
'Lyubimets', 'Momchilgrad', 'Slivnitsa', 'Hisarya', 'Zlatograd', 'Kostenets', 'Devin', 'General Toshevo', 'Simeonovgrad', 'Simitli', | ||
'Elin Pelin', 'Dolni Chiflik', 'Tervel', 'Dulovo', 'Varshets', 'Kotel', 'Madan', 'Straldzha', 'Saedinenie', 'Bobov Dol', 'Tsarevo', | ||
'Kuklen', 'Tvarditsa', 'Yakoruda', 'Elena', 'Topolovgrad', 'Bozhurishte', 'Chepelare', 'Oryahovo', 'Sozopol', 'Belogradchik', | ||
'Perushtitsa', 'Zlatitsa', 'Strazhitsa', 'Krumovgrad', 'Kameno', 'Dalgopol', 'Vetovo', 'Suvorovo', 'Dolni Dabnik', 'Dolna Banya', | ||
'Pravets', 'Nedelino', 'Polski Trambesh', 'Trastenik', 'Bratsigovo', 'Koynare', 'Godech', 'Slavyanovo', 'Dve Mogili', 'Kostandovo', | ||
'Debelets', 'Strelcha', 'Sapareva Banya', 'Ignatievo', 'Smyadovo', 'Breznik', 'Sveti Vlas', 'Nikopol', 'Shivachevo', 'Belovo', | ||
'Tsar Kaloyan', 'Ivaylovgrad', 'Valchedram', 'Marten', 'Glodzhevo', 'Sarnitsa', 'Letnitsa', 'Varbitsa', 'Iskar', 'Ardino', 'Shabla', | ||
'Rudozem', 'Vetren', 'Kresna', 'Banya', 'Batak', 'Maglizh', 'Valchi Dol', 'Gulyantsi', 'Dragoman', 'Zavet', 'Kran', 'Miziya', | ||
'Primorsko', 'Sungurlare', 'Dolna Mitropoliya', 'Krivodol', 'Kula', 'Kalofer', 'Slivo Pole', 'Kaspichan', 'Apriltsi', 'Belitsa', | ||
'Roman', 'Dzhebel', 'Dolna Oryahovitsa', 'Buhovo', 'Gurkovo', 'Pavel Banya', 'Nikolaevo', 'Yablanitsa', 'Kableshkovo', 'Opaka', | ||
'Rila', 'Ugarchin', 'Dunavtsi', 'Dobrinishte', 'Hadzhidimovo', 'Bregovo', 'Byala Cherkva', 'Zlataritsa', 'Kocherinovo', 'Dospat', | ||
'Tran', 'Sadovo', 'Laki', 'Koprivshtitsa', 'Malko Tarnovo', 'Loznitsa', 'Obzor', 'Kilifarevo', 'Borovo', | ||
'Batanovtsi', 'Chernomorets', 'Aheloy', 'Byala', 'Pordim', 'Suhindol', 'Merichleri', 'Glavinitsa', 'Chiprovtsi', 'Kermen', 'Brezovo', | ||
'Plachkovtsi', 'Zemen', 'Balgarovo', 'Alfatar', 'Boychinovtsi', 'Gramada', 'Senovo', 'Momin Prohod', 'Kaolinovo', 'Shipka', | ||
'Antonovo', 'Ahtopol', 'Boboshevo', 'Bolyarovo', 'Brusartsi', 'Klisura', 'Dimovo', 'Kiten', 'Pliska', 'Madzharovo', 'Melnik' | ||
]; |
22 changes: 22 additions & 0 deletions
22
templates/angular/igx-ts/autocomplete/autocomplete-custom/index.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,22 @@ | ||
import { IgniteUIForAngularTemplate } from "../../../../../lib/templates/IgniteUIForAngularTemplate"; | ||
|
||
class IgxAutocompleteTemplate extends IgniteUIForAngularTemplate { | ||
constructor() { | ||
super(__dirname); | ||
this.components = ["Autocomplete"]; | ||
this.controlGroup = "Data Entry & Display"; | ||
this.listInComponentTemplates = true; | ||
this.id = "autocomplete"; | ||
this.projectType = "igx-ts"; | ||
this.name = "Simple Autocomplete"; | ||
this.description = "Simple IgxAutocomplete"; | ||
this.dependencies = [{ | ||
import: ["IgxAutocompleteModule", "IgxDropDownModule", "IgxInputGroupModule"], | ||
from: "igniteui-angular" | ||
}, { | ||
declare: ["$(ClassName)PipeStartsWith"], | ||
from: "./src/app/__path__/__name__.component.ts" | ||
}]; | ||
} | ||
} | ||
module.exports = new IgxAutocompleteTemplate(); |
37 changes: 37 additions & 0 deletions
37
.../igx-ts/autocomplete/autocomplete-extended/files/src/app/__path__/__name__.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,37 @@ | ||
<div class="content-wrapper"> | ||
<p>The <b>igx-autocomplete</b> directive provides a way to enhance a text input by showing a panel of suggested options provided by the developer.<br /> | ||
Using the <b>igx-drop-down</b> as a provider, allows using its functionalities like grouping, templating, etc.</p> | ||
<p>You can read more about configuring those components, using the following links:</p> | ||
<ul> | ||
<li> | ||
<b>igx-autocomplete</b> - | ||
<a href="https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/directives/autocomplete/README.md" target="_blank">README</a> or the | ||
<a href="https://www.infragistics.com/products/ignite-ui-angular/angular/components/autocomplete.html" target="_blank">official documentation</a>. | ||
</li> | ||
<li> | ||
<b>igx-drop-down</b> - | ||
<a href="https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/drop-down/README.md" target="_blank">README</a> or the | ||
<a href="https://www.infragistics.com/products/ignite-ui-angular/angular/components/drop_down.html" target="_blank">official documentation</a>. | ||
</li> | ||
</ul> | ||
<p>The following sample demonstrates igx-drop-down with defined groups:</p> | ||
<div class="enhanced-groups"> | ||
<igx-input-group> | ||
<label igxLabel for="townEhanced">Town</label> | ||
<input igxInput name="townEhanced" type="text" [igxAutocomplete]="townsEnhancedPanel" | ||
[(ngModel)]="townSelected"/> | ||
</igx-input-group> | ||
<igx-drop-down #townsEnhancedPanel maxHeight="300px" (onSelection)="getPostalCode($event)"> | ||
<igx-drop-down-item-group | ||
*ngFor="let eRegion of extendedTowns.regions | $(camelCaseName)RegionContains:townSelected" | ||
[label]="eRegion.name"> | ||
<igx-drop-down-item *ngFor="let town of eRegion.towns | $(camelCaseName)StartsWith:townSelected" | ||
[value]="town.name"> | ||
{{town.name}} | ||
</igx-drop-down-item> | ||
</igx-drop-down-item-group> | ||
</igx-drop-down> | ||
|
||
<igx-toast #message message="Postal Code: {{postalCode}}" [position]="messagePosition"></igx-toast> | ||
</div> | ||
</div> |
9 changes: 9 additions & 0 deletions
9
.../igx-ts/autocomplete/autocomplete-extended/files/src/app/__path__/__name__.component.scss
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,9 @@ | ||
.enhanced-groups { | ||
width: 300px; | ||
padding-top: 100px; | ||
} | ||
|
||
.content-wrapper { | ||
display: flex; | ||
flex-flow: column; | ||
} |
29 changes: 29 additions & 0 deletions
29
...x-ts/autocomplete/autocomplete-extended/files/src/app/__path__/__name__.component.spec.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,29 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { $(ClassName)Component, $(ClassName)PipeStartsWith, | ||
$(ClassName)RegionContains } from './$(filePrefix).component'; | ||
import { IgxDropDownModule, IgxAutocompleteModule, IgxInputGroupModule, IgxToastModule } from 'igniteui-angular'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
describe('$(ClassName)Component', () => { | ||
let component: $(ClassName)Component; | ||
let fixture: ComponentFixture<$(ClassName)Component>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [$(ClassName)Component, $(ClassName)PipeStartsWith, $(ClassName)RegionContains], | ||
imports: [FormsModule, IgxDropDownModule, IgxAutocompleteModule, NoopAnimationsModule, IgxInputGroupModule, IgxToastModule] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent($(ClassName)Component); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
50 changes: 50 additions & 0 deletions
50
...ar/igx-ts/autocomplete/autocomplete-extended/files/src/app/__path__/__name__.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,50 @@ | ||
import { Component, Pipe, PipeTransform, ViewChild } from '@angular/core'; | ||
import { townsExtended } from './towns-data-extended'; | ||
import { IgxToastComponent, IgxToastPosition } from 'igniteui-angular'; | ||
|
||
@Component({ | ||
selector: 'app-$(filePrefix)', | ||
templateUrl: './$(filePrefix).component.html', | ||
styleUrls: ['./$(filePrefix).component.scss'] | ||
}) | ||
export class $(ClassName)Component { | ||
public extendedTowns: any; | ||
public townSelected: string; | ||
public postalCode: string; | ||
public messagePosition = IgxToastPosition.Middle; | ||
|
||
@ViewChild(IgxToastComponent) | ||
public toast: IgxToastComponent; | ||
|
||
constructor() { | ||
this.extendedTowns = townsExtended; | ||
} | ||
|
||
public getPostalCode(event) { | ||
const targetRegion = this.extendedTowns.regions.filter((r) => r.name === event.newSelection.group.label)[0]; | ||
this.postalCode = targetRegion.towns.filter(t => t.name === event.newSelection.value)[0].postalCode; | ||
this.toast.show(); | ||
} | ||
} | ||
|
||
@Pipe({ name: '$(camelCaseName)StartsWith' }) | ||
export class $(ClassName)PipeStartsWith implements PipeTransform { | ||
public transform(collection: any[], term = '') { | ||
return collection.filter((item) => item.name.toString().toLowerCase().startsWith(term.trim().toLowerCase())); | ||
} | ||
} | ||
|
||
@Pipe({ name: '$(camelCaseName)RegionContains' }) | ||
export class $(ClassName)RegionContains implements PipeTransform { | ||
transform(regions: any[], term = '') { | ||
return this.filterRegions(regions, term); | ||
} | ||
|
||
private filterRegions(regions: any[], term: string) { | ||
return regions.filter((region: any) => this.filterTowns(region.towns, term.toLowerCase()).length > 0); | ||
} | ||
|
||
private filterTowns(towns: any[], term: string) { | ||
return towns.filter((town: any) => town.name.toLowerCase().startsWith(term)); | ||
} | ||
} |
Oops, something went wrong.