Skip to content

Commit

Permalink
Code reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
almothafar committed Sep 16, 2024
1 parent 9d5df45 commit 027e70a
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 89 deletions.
3 changes: 2 additions & 1 deletion projects/auto-complete/src/lib/auto-complete.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ import { NguiAutoCompleteService } from './auto-complete.service';
NguiAutoCompleteDirective
]
})
export class NguiAutoCompleteModule { }
export class NguiAutoCompleteModule {
}
9 changes: 3 additions & 6 deletions projects/auto-complete/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
import 'zone.js';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';

// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(), {
teardown: { destroyAfterEach: false }
}
teardown: {destroyAfterEach: false}
}
);
5 changes: 3 additions & 2 deletions projects/demo/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { RouterModule, Routes } from '@angular/router';
import { DirectiveTestComponent } from './directive-test/directive-test.component';
import { ComponentTestComponent } from './component-test/component-test.component';

Expand All @@ -15,4 +15,5 @@ const routes: Routes = [
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
export class AppRoutingModule {
}
2 changes: 1 addition & 1 deletion projects/demo/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Router } from '@angular/router';
styleUrls: ['./app.component.scss']
})
export class AppComponent {
public links = [{name: 'Directive', url: '/directive-test'}, {name: 'Component', url: '/component-test'}]
public links = [{name: 'Directive', url: '/directive-test'}, {name: 'Component', url: '/component-test'}];
public activeLink: string = '/directive-test';

constructor(public router: Router) {
Expand Down
38 changes: 20 additions & 18 deletions projects/demo/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,25 @@ import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatIconModule } from '@angular/material/icon';

@NgModule({ declarations: [
AppComponent,
ComponentTestComponent,
DirectiveTestComponent
],
bootstrap: [AppComponent], imports: [BrowserModule,
BrowserAnimationsModule,
FormsModule,
NguiAutoCompleteModule,
MatFormFieldModule,
MatInputModule,
AppRoutingModule,
MatTabsModule,
MatFormFieldModule,
MatIconModule], providers: [
AppService,
provideHttpClient(withInterceptorsFromDi())
] })
@NgModule({
declarations: [
AppComponent,
ComponentTestComponent,
DirectiveTestComponent
],
bootstrap: [AppComponent], imports: [BrowserModule,
BrowserAnimationsModule,
FormsModule,
NguiAutoCompleteModule,
MatFormFieldModule,
MatInputModule,
AppRoutingModule,
MatTabsModule,
MatFormFieldModule,
MatIconModule], providers: [
AppService,
provideHttpClient(withInterceptorsFromDi())
]
})
export class AppModule {
}
4 changes: 2 additions & 2 deletions projects/demo/src/app/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ export class AppService {
};

public getMapsUrl = () => {
return `https://maps.googleapis.com/maps/api/geocode/json?address=:my_own_keyword&key=${this.googleMapsPublicKey}`
}
return `https://maps.googleapis.com/maps/api/geocode/json?address=:my_own_keyword&key=${this.googleMapsPublicKey}`;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ fieldset {
margin: 10px;
padding: 20px
}

.demo-1 {
ngui-auto-complete {
display: inline-block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ describe('ComponentTestComponent', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ ComponentTestComponent ]
declarations: [ComponentTestComponent]
})
.compileComponents();
.compileComponents();
}));

beforeEach(() => {
Expand Down
107 changes: 59 additions & 48 deletions projects/demo/src/app/directive-test/directive-test.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<h1> Autocomplete Directive Test - Local Source </h1>

<fieldset class="demo-1"><legend><h2>Source as Array of Strings</h2></legend>
<fieldset class="demo-1">
<legend><h2>Source as Array of Strings</h2></legend>
<div ngui-auto-complete
[source]="arrayOfStrings"
[accept-user-input]="true"
Expand All @@ -9,14 +10,15 @@ <h1> Autocomplete Directive Test - Local Source </h1>
(ngModelChange)="myCallback1($event)"
(customSelected)="customCallback($event)"
placeholder="enter text">
<input id="model1" [ngModel]="model1" autofocus />
<input id="model1" [ngModel]="model1" autofocus/>
</div>
<br/>selected model1: {{json(model1)}}<br/><br/>
<pre>{{template1}}</pre>
<pre> arrayOfStrings: {{json(arrayOfStrings)}}</pre>
<br/>selected model1: {{ json(model1) }}<br/><br/>
<pre>{{ template1 }}</pre>
<pre> arrayOfStrings: {{ json(arrayOfStrings) }}</pre>
</fieldset>

<fieldset class="demo-1"><legend><h2>Source as Array of Strings. Drop-down on focus disable</h2></legend>
<fieldset class="demo-1">
<legend><h2>Source as Array of Strings. Drop-down on focus disable</h2></legend>
<div ngui-auto-complete
[source]="arrayOfStrings"
[accept-user-input]="true"
Expand All @@ -26,14 +28,15 @@ <h1> Autocomplete Directive Test - Local Source </h1>
(ngModelChange)="myCallback1($event)"
(customSelected)="customCallback($event)"
placeholder="enter text">
<input id="model1-1" [ngModel]="model1" autofocus />
<input id="model1-1" [ngModel]="model1" autofocus/>
</div>
<br/>selected model1: {{json(model1)}}<br/><br/>
<pre>{{template2}}</pre>
<pre> arrayOfStrings: {{json(arrayOfStrings)}}</pre>
<br/>selected model1: {{ json(model1) }}<br/><br/>
<pre>{{ template2 }}</pre>
<pre> arrayOfStrings: {{ json(arrayOfStrings) }}</pre>
</fieldset>

<fieldset class="demo-1"><legend><h2>Source as Array of id/value</h2></legend>
<fieldset class="demo-1">
<legend><h2>Source as Array of id/value</h2></legend>
<input
id="model2"
ngui-auto-complete
Expand All @@ -43,25 +46,27 @@ <h1> Autocomplete Directive Test - Local Source </h1>
placeholder="enter text"
z-index="4"/>
<a href="javascript:void(0)" (click)="model2={id:100, value: 'it'}">Change It</a>
<br/>selected model2: {{model2 | json}}<br/><br/>
<pre>{{template3}}</pre>
<pre>arrayOfKeyValues: {{json(arrayOfKeyValues)}}</pre>
<br/>selected model2: {{ model2 | json }}<br/><br/>
<pre>{{ template3 }}</pre>
<pre>arrayOfKeyValues: {{ json(arrayOfKeyValues) }}</pre>
</fieldset>

<fieldset><legend><h2>Source as Array of Key/Name</h2></legend>
<fieldset>
<legend><h2>Source as Array of Key/Name</h2></legend>
<input ngui-auto-complete [source]="arrayOfKeyValues2"
id="model3"
[(ngModel)]="model3"
placeholder="enter text"
value-formatter="(key) name"
list-formatter="(key) name"
[match-formatted]="true" />
<br/>selected model3: {{model3 | json}}<br/><br/>
<pre>{{template4}}</pre>
<pre>arrayOfKeyValues2: {{json(arrayOfKeyValues2)}}</pre>
[match-formatted]="true"/>
<br/>selected model3: {{ model3 | json }}<br/><br/>
<pre>{{ template4 }}</pre>
<pre>arrayOfKeyValues2: {{ json(arrayOfKeyValues2) }}</pre>
</fieldset>

<fieldset><legend><h2>Source as HTTP URI String</h2></legend>
<fieldset>
<legend><h2>Source as HTTP URI String</h2></legend>
<input ngui-auto-complete
id="model4"
[(ngModel)]="model4"
Expand All @@ -73,13 +78,14 @@ <h1> Autocomplete Directive Test - Local Source </h1>
loading-text="Google Is Thinking..."
[loading-template]="loadingTemplate"
max-num-list="5"
min-chars="2" />
<br/>selected model4: {{model4 | json}}<br/><br/>
<pre>{{template5}}</pre>
min-chars="2"/>
<br/>selected model4: {{ model4 | json }}<br/><br/>
<pre>{{ template5 }}</pre>
<pre> source: https://maps.googleapis.com/maps/api/geocode/json?address=:my_own_keyword</pre>
</fieldset>

<fieldset><legend><h2>Source as Observable "Marvel API"</h2></legend>
<fieldset>
<legend><h2>Source as Observable "Marvel API"</h2></legend>
<input ngui-auto-complete
id="model5"
placeholder="Start typing a hero name (min. 2 chars) ... for example: Hulk"
Expand All @@ -89,11 +95,12 @@ <h1> Autocomplete Directive Test - Local Source </h1>
[list-formatter]="renderHero"
min-chars="2"
/>
<br/>selected model5: {{model5 | json}}<br/><br/>
<pre>{{template6}}</pre>
<br/>selected model5: {{ model5 | json }}<br/><br/>
<pre>{{ template6 }}</pre>
</fieldset>

<fieldset><legend><h2>With Material Design</h2></legend>
<fieldset>
<legend><h2>With Material Design</h2></legend>
<mat-form-field appearance="outline">
<mat-icon fontIcon="attach_money" matPrefix></mat-icon>
<input matInput ngui-auto-complete
Expand All @@ -104,37 +111,40 @@ <h1> Autocomplete Directive Test - Local Source </h1>
placeholder="amount"/>
<span matSuffix>.00</span>
</mat-form-field>
<pre>{{template7}}</pre>
<pre>arrayOfNumbers: {{json(arrayOfNumbers)}}</pre>
<pre>{{ template7 }}</pre>
<pre>arrayOfNumbers: {{ json(arrayOfNumbers) }}</pre>
</fieldset>

<fieldset><legend><h2>Source as Array of Strings (with auto-select-first-item)</h2></legend>
<fieldset>
<legend><h2>Source as Array of Strings (with auto-select-first-item)</h2></legend>
<div ngui-auto-complete
[source]="arrayOfStrings"
(ngModelChange)="myCallback7($event)"
placeholder="enter text">
<input id="model7" [ngModel]="model7"/>
</div>
<br/>selected model7: {{json(model7)}}<br/><br/>
<pre>{{template8}}</pre>
<pre> arrayOfStrings: {{json(arrayOfStrings)}}</pre>
<br/>selected model7: {{ json(model7) }}<br/><br/>
<pre>{{ template8 }}</pre>
<pre> arrayOfStrings: {{ json(arrayOfStrings) }}</pre>
</fieldset>

<fieldset style="direction:rtl;text-align:right"><legend><h2>RTL support</h2></legend>
<fieldset style="direction:rtl;text-align:right">
<legend><h2>RTL support</h2></legend>
<div ngui-auto-complete
[source]="arrayOfStrings"
[accept-user-input]="false"
(ngModelChange)="myCallback8($event)"
[is-rtl]="true"
placeholder="enter text">
<input id="model8" [ngModel]="model8" autofocus />
<input id="model8" [ngModel]="model8" autofocus/>
</div>
<br/>selected model8: {{json(model8)}}<br/><br/>
<pre>{{template9}}</pre>
<pre> arrayOfStrings: {{json(arrayOfStrings)}}</pre>
<br/>selected model8: {{ json(model8) }}<br/><br/>
<pre>{{ template9 }}</pre>
<pre> arrayOfStrings: {{ json(arrayOfStrings) }}</pre>
</fieldset>

<fieldset><legend><h2>Grid-Style Results with Header Row</h2></legend>
<fieldset>
<legend><h2>Grid-Style Results with Header Row</h2></legend>
<input ngui-auto-complete
style="width: 650px"
[(ngModel)]="model9"
Expand All @@ -145,24 +155,25 @@ <h1> Autocomplete Directive Test - Local Source </h1>
display-property-name="city"
[header-item-template]="cityHeaderTemplate"
/>
<br />selected model9: {{json(model9)}}<br /><br />
<pre>{{template10}}</pre>
<pre> arrayOfCities: {{json(arrayOfCities)}}</pre>
<br/>selected model9: {{ json(model9) }}<br/><br/>
<pre>{{ template10 }}</pre>
<pre> arrayOfCities: {{ json(arrayOfCities) }}</pre>
</fieldset>

<fieldset><legend><h2>Exact Match Including Accents</h2></legend>
<fieldset>
<legend><h2>Exact Match Including Accents</h2></legend>
<div ngui-auto-complete
[ignore-accents] = "false"
[ignore-accents]="false"
[source]="arrayOfAccentedStrings"
[accept-user-input]="true"
[auto-select-first-item]="false"
[select-on-blur]="true"
(ngModelChange)="myCallback10($event)"
(customSelected)="customCallback($event)"
placeholder="enter text">
<input id="model10" [ngModel]="model10" autofocus />
<input id="model10" [ngModel]="model10" autofocus/>
</div>
<br/>selected model10: {{json(model10)}}<br/><br/>
<pre>{{template11}}</pre>
<pre> arrayOfStrings: {{json(arrayOfAccentedStrings)}}</pre>
<br/>selected model10: {{ json(model10) }}<br/><br/>
<pre>{{ template11 }}</pre>
<pre> arrayOfStrings: {{ json(arrayOfAccentedStrings) }}</pre>
</fieldset>
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@ ngui-auto-complete, input {
color: #ffffff;
margin: -2px -5px;
}

.data-row {
margin: -2px -5px;
}

.col-1 {
border-left: 1px solid #ccc;
padding-left: 5px;
display: inline-block;
width: 100px;
}

.col-2 {
border-left: 1px solid #ccc;
padding-left: 5px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ describe('DirectiveTestComponent', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ DirectiveTestComponent ]
declarations: [DirectiveTestComponent]
})
.compileComponents();
.compileComponents();
}));

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion projects/demo/src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js'; // Included with Angular CLI.
import 'zone.js'; // Included with Angular CLI.


/***************************************************************************************************
Expand Down
9 changes: 3 additions & 6 deletions projects/demo/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';

// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(), {
teardown: { destroyAfterEach: false }
}
teardown: {destroyAfterEach: false}
}
);

0 comments on commit 027e70a

Please sign in to comment.