Skip to content

Commit

Permalink
fix(build): fix provider search exports
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbeau committed May 11, 2017
1 parent 77ac9e7 commit 9a3703a
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 65 deletions.
9 changes: 1 addition & 8 deletions src/lib/search/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,11 @@ import { IgoSharedModule } from '../shared';

import { SearchService,
provideSearchSourceService } from './shared';
import { provideSearchSourceOptions, SearchSourceOptions,
provideNominatimSearchSource } from './search-sources';
import { provideSearchSourceOptions } from './search-sources';

import { SearchBarComponent, SearchUrlParamDirective } from './search-bar';


export function provideDefaultSearchSources(options?: SearchSourceOptions) {
return [
provideNominatimSearchSource()
];
}

@NgModule({
imports: [
JsonpModule,
Expand Down
20 changes: 4 additions & 16 deletions src/lib/search/search-sources/datasource-search-source.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
import { Inject } from '@angular/core';
import { Inject, Injectable } from '@angular/core';
import { Jsonp, Response, URLSearchParams } from '@angular/http';
import { Observable } from 'rxjs/Observable';

import { Message } from '../../core/message';
import { Feature, FeatureType } from '../../feature';

import { SEARCH_SOURCE_OPTIONS, SearchSource } from './search-source';
import { SearchSource } from './search-source';
import { SEARCH_SOURCE_OPTIONS } from './search-source.provider';
import { SearchSourceOptions } from './search-source.interface';


export function dataSourceSearchSourcesFactory(jsonp: Jsonp, options: any) {
return new DataSourceSearchSource(jsonp, options);
}

export function provideDataSourceSearchSource() {
return {
provide: SearchSource,
useFactory: dataSourceSearchSourcesFactory,
multi: true,
deps: [Jsonp, SEARCH_SOURCE_OPTIONS]
};
}


@Injectable()
export class DataSourceSearchSource extends SearchSource {

static _name: string = 'Data Sources';
Expand Down
19 changes: 4 additions & 15 deletions src/lib/search/search-sources/icherche-search-source.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
import { Inject } from '@angular/core';
import { Inject, Injectable } from '@angular/core';
import { Jsonp, Response, URLSearchParams } from '@angular/http';
import { Observable } from 'rxjs/Observable';

import { Message } from '../../core/message';
import { Feature, FeatureType, FeatureFormat} from '../../feature';

import { SEARCH_SOURCE_OPTIONS, SearchSource } from './search-source';
import { SearchSource } from './search-source';
import { SEARCH_SOURCE_OPTIONS } from './search-source.provider';
import { SearchSourceOptions } from './search-source.interface';


export function ichercheSearchSourcesFactory(jsonp: Jsonp, options: any) {
return new IChercheSearchSource(jsonp, options);
}

export function provideIChercheSearchSource() {
return {
provide: SearchSource,
useFactory: ichercheSearchSourcesFactory,
multi: true,
deps: [Jsonp, SEARCH_SOURCE_OPTIONS]
};
}

@Injectable()
export class IChercheSearchSource extends SearchSource {

static _name: string = 'ICherche Québec';
Expand Down
1 change: 1 addition & 0 deletions src/lib/search/search-sources/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './search-source';
export * from './search-source.provider';
export * from './search-source.interface';
export * from './nominatim-search-source';
export * from './icherche-search-source';
Expand Down
19 changes: 4 additions & 15 deletions src/lib/search/search-sources/nominatim-search-source.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
import { Inject } from '@angular/core';
import { Inject, Injectable } from '@angular/core';
import { Http, Response, URLSearchParams } from '@angular/http';
import { Observable } from 'rxjs/Observable';

import { Message } from '../../core/message';
import { Feature, FeatureType, FeatureFormat} from '../../feature';

import { SEARCH_SOURCE_OPTIONS, SearchSource } from './search-source';
import { SearchSource } from './search-source';
import { SEARCH_SOURCE_OPTIONS } from './search-source.provider';
import { SearchSourceOptions } from './search-source.interface';


export function nominatimSearchSourcesFactory(http: Http, options: any) {
return new NominatimSearchSource(http, options);
}

export function provideNominatimSearchSource() {
return {
provide: SearchSource,
useFactory: nominatimSearchSourcesFactory,
multi: true,
deps: [Http, SEARCH_SOURCE_OPTIONS]
};
}

@Injectable()
export class NominatimSearchSource extends SearchSource {

static _name: string = 'Nominatim (OSM)';
Expand Down
61 changes: 61 additions & 0 deletions src/lib/search/search-sources/search-source.provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { InjectionToken } from '@angular/core';
import { Http, Jsonp } from '@angular/http';

import { SearchSource } from './search-source';
import { SearchSourceOptions } from './search-source.interface';
import { NominatimSearchSource } from './nominatim-search-source';
import { IChercheSearchSource } from './icherche-search-source';
import { DataSourceSearchSource } from './datasource-search-source';


export let SEARCH_SOURCE_OPTIONS =
new InjectionToken<SearchSourceOptions>('searchSourceOptions');

export function provideSearchSourceOptions(options: SearchSourceOptions) {
return {
provide: SEARCH_SOURCE_OPTIONS,
useValue: options
};
}


export function nominatimSearchSourcesFactory(http: Http, options: any) {
return new NominatimSearchSource(http, options);
}

export function provideNominatimSearchSource() {
return {
provide: SearchSource,
useFactory: (nominatimSearchSourcesFactory),
multi: true,
deps: [Http, SEARCH_SOURCE_OPTIONS]
};
}


export function ichercheSearchSourcesFactory(jsonp: Jsonp, options: any) {
return new IChercheSearchSource(jsonp, options);
}

export function provideIChercheSearchSource() {
return {
provide: SearchSource,
useFactory: (ichercheSearchSourcesFactory),
multi: true,
deps: [Jsonp, SEARCH_SOURCE_OPTIONS]
};
}


export function dataSourceSearchSourcesFactory(jsonp: Jsonp, options: any) {
return new DataSourceSearchSource(jsonp, options);
}

export function provideDataSourceSearchSource() {
return {
provide: SearchSource,
useFactory: (dataSourceSearchSourcesFactory),
multi: true,
deps: [Jsonp, SEARCH_SOURCE_OPTIONS]
};
}
11 changes: 0 additions & 11 deletions src/lib/search/search-sources/search-source.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
import { InjectionToken } from '@angular/core';
import { Observable } from 'rxjs/Observable';

import { Message } from '../../core/message';
import { Feature } from '../../feature';

import { SearchSourceOptions } from './search-source.interface';

export let SEARCH_SOURCE_OPTIONS =
new InjectionToken<SearchSourceOptions>('searchSourceOptions');

export function provideSearchSourceOptions(options: SearchSourceOptions) {
return {
provide: SEARCH_SOURCE_OPTIONS,
useValue: options
};
}

export abstract class SearchSource {

Expand Down

0 comments on commit 9a3703a

Please sign in to comment.