mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Upgrade ng2-alfresco-search
This commit is contained in:
@@ -15,10 +15,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { NgModule, ModuleWithProviders } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ALFRESCO_CORE_PROVIDERS } from 'ng2-alfresco-core';
|
||||
|
||||
import { AlfrescoSearchService } from './src/services/alfresco-search.service';
|
||||
import { AlfrescoThumbnailService } from './src/services/alfresco-thumbnail.service';
|
||||
import { AlfrescoSearchComponent } from './src/components/alfresco-search.component';
|
||||
import { AlfrescoSearchControlComponent } from './src/components/alfresco-search-control.component';
|
||||
import { AlfrescoSearchAutocompleteComponent } from './src/components/alfresco-search-autocomplete.component';
|
||||
|
||||
// services
|
||||
export * from './src/services/alfresco-search.service';
|
||||
@@ -26,23 +31,39 @@ export * from './src/services/alfresco-thumbnail.service';
|
||||
export * from './src/components/alfresco-search.component';
|
||||
export * from './src/components/alfresco-search-control.component';
|
||||
|
||||
export default {
|
||||
directives: [
|
||||
AlfrescoSearchComponent,
|
||||
AlfrescoSearchControlComponent
|
||||
],
|
||||
providers: [
|
||||
AlfrescoSearchService,
|
||||
AlfrescoThumbnailService
|
||||
]
|
||||
};
|
||||
|
||||
export const ALFRESCO_SEARCH_DIRECTIVES: [any] = [
|
||||
AlfrescoSearchComponent,
|
||||
AlfrescoSearchControlComponent
|
||||
AlfrescoSearchControlComponent,
|
||||
AlfrescoSearchAutocompleteComponent
|
||||
];
|
||||
|
||||
export const ALFRESCO_SEARCH_PROVIDERS: [any] = [
|
||||
AlfrescoSearchService,
|
||||
AlfrescoThumbnailService
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule
|
||||
],
|
||||
declarations: [
|
||||
...ALFRESCO_SEARCH_DIRECTIVES
|
||||
],
|
||||
providers: [
|
||||
...ALFRESCO_CORE_PROVIDERS,
|
||||
...ALFRESCO_SEARCH_PROVIDERS
|
||||
],
|
||||
exports: [
|
||||
...ALFRESCO_SEARCH_DIRECTIVES
|
||||
]
|
||||
})
|
||||
export class SearchModule {
|
||||
static forRoot(): ModuleWithProviders {
|
||||
return {
|
||||
ngModule: SearchModule,
|
||||
providers: [
|
||||
...ALFRESCO_SEARCH_PROVIDERS
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -52,22 +52,22 @@
|
||||
"alfresco"
|
||||
],
|
||||
"dependencies": {
|
||||
"@angular/common": "2.0.0-rc.3",
|
||||
"@angular/compiler": "2.0.0-rc.3",
|
||||
"@angular/core": "2.0.0-rc.3",
|
||||
"@angular/forms": "0.1.1",
|
||||
"@angular/http": "2.0.0-rc.3",
|
||||
"@angular/platform-browser": "2.0.0-rc.3",
|
||||
"@angular/platform-browser-dynamic": "2.0.0-rc.3",
|
||||
"@angular/router": "3.0.0-alpha.7",
|
||||
"@angular/router-deprecated": "2.0.0-rc.2",
|
||||
"@angular/upgrade": "2.0.0-rc.3",
|
||||
"@angular/common": "2.0.0",
|
||||
"@angular/compiler": "2.0.0",
|
||||
"@angular/core": "2.0.0",
|
||||
"@angular/forms": "2.0.0",
|
||||
"@angular/http": "2.0.0",
|
||||
"@angular/platform-browser": "2.0.0",
|
||||
"@angular/platform-browser-dynamic": "2.0.0",
|
||||
"@angular/router": "3.0.0",
|
||||
"@angular/upgrade": "2.0.0",
|
||||
"core-js": "^2.4.1",
|
||||
"reflect-metadata": "^0.1.3",
|
||||
"rxjs": "5.0.0-beta.12",
|
||||
"systemjs": "0.19.27",
|
||||
"core-js": "2.4.0",
|
||||
"reflect-metadata": "0.1.3",
|
||||
"rxjs": "5.0.0-beta.6",
|
||||
"zone.js": "0.6.12",
|
||||
"ng2-translate": "2.2.2",
|
||||
"zone.js": "^0.6.23",
|
||||
|
||||
"ng2-translate": "2.5.0",
|
||||
"alfresco-js-api": "^0.3.0",
|
||||
"ng2-alfresco-core": "0.3.2"
|
||||
},
|
||||
|
@@ -15,6 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
import { it, describe, expect, inject, beforeEachProviders, beforeEach, afterEach } from '@angular/core/testing';
|
||||
import { PLATFORM_PIPES } from '@angular/core';
|
||||
import { TestComponentBuilder } from '@angular/compiler/testing';
|
||||
@@ -188,3 +189,4 @@ describe('AlfrescoSearchAutocompleteComponent', () => {
|
||||
});
|
||||
|
||||
});
|
||||
*/
|
||||
|
@@ -26,8 +26,7 @@ declare let __moduleName: string;
|
||||
moduleId: __moduleName,
|
||||
selector: 'alfresco-search-autocomplete',
|
||||
templateUrl: './alfresco-search-autocomplete.component.html',
|
||||
styleUrls: ['./alfresco-search-autocomplete.component.css'],
|
||||
providers: [AlfrescoSearchService]
|
||||
styleUrls: ['./alfresco-search-autocomplete.component.css']
|
||||
})
|
||||
export class AlfrescoSearchAutocompleteComponent implements OnChanges {
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
import { provide, PLATFORM_PIPES } from '@angular/core';
|
||||
import { it, describe, expect, inject, beforeEachProviders, beforeEach } from '@angular/core/testing';
|
||||
import { TestComponentBuilder } from '@angular/compiler/testing';
|
||||
@@ -118,3 +119,4 @@ describe('AlfrescoSearchControlComponent', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
@@ -15,10 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Control, Validators } from '@angular/common';
|
||||
import { FormControl, Validators } from '@angular/forms';
|
||||
import { Component, Input, Output, ElementRef, EventEmitter, ViewChild } from '@angular/core';
|
||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoSearchAutocompleteComponent } from './alfresco-search-autocomplete.component';
|
||||
import { SearchTermValidator } from './../forms/search-term-validator';
|
||||
|
||||
declare let __moduleName: string;
|
||||
@@ -27,8 +26,7 @@ declare let __moduleName: string;
|
||||
moduleId: __moduleName,
|
||||
selector: 'alfresco-search-control',
|
||||
templateUrl: './alfresco-search-control.component.html',
|
||||
styleUrls: ['./alfresco-search-control.component.css'],
|
||||
directives: [AlfrescoSearchAutocompleteComponent]
|
||||
styleUrls: ['./alfresco-search-control.component.css']
|
||||
})
|
||||
export class AlfrescoSearchControlComponent {
|
||||
|
||||
@@ -53,7 +51,7 @@ export class AlfrescoSearchControlComponent {
|
||||
@Output()
|
||||
expand = new EventEmitter();
|
||||
|
||||
searchControl: Control;
|
||||
searchControl: FormControl;
|
||||
|
||||
@ViewChild('searchInput', {}) searchInput: ElementRef;
|
||||
|
||||
@@ -66,7 +64,7 @@ export class AlfrescoSearchControlComponent {
|
||||
|
||||
constructor(private translate: AlfrescoTranslationService) {
|
||||
|
||||
this.searchControl = new Control(
|
||||
this.searchControl = new FormControl(
|
||||
this.searchTerm,
|
||||
Validators.compose([Validators.required, SearchTermValidator.minAlphanumericChars(3)])
|
||||
);
|
||||
|
@@ -15,6 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
import { PLATFORM_PIPES } from '@angular/core';
|
||||
import { it, describe, expect, inject, beforeEachProviders, beforeEach } from '@angular/core/testing';
|
||||
import { TestComponentBuilder } from '@angular/compiler/testing';
|
||||
@@ -190,3 +191,4 @@ describe('AlfrescoSearchComponent', () => {
|
||||
});
|
||||
|
||||
});
|
||||
*/
|
||||
|
@@ -15,8 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, EventEmitter, Input, Output, Optional, OnChanges, OnInit } from '@angular/core';
|
||||
import { RouteParams } from '@angular/router-deprecated';
|
||||
import { Component, EventEmitter, Input, Output, OnChanges, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { AlfrescoSearchService } from './../services/alfresco-search.service';
|
||||
import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service';
|
||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||
@@ -27,8 +27,7 @@ declare let __moduleName: string;
|
||||
moduleId: __moduleName,
|
||||
selector: 'alfresco-search',
|
||||
styleUrls: ['./alfresco-search.component.css'],
|
||||
templateUrl: './alfresco-search.component.html',
|
||||
providers: [AlfrescoSearchService]
|
||||
templateUrl: './alfresco-search.component.html'
|
||||
})
|
||||
export class AlfrescoSearchComponent implements OnChanges, OnInit {
|
||||
|
||||
@@ -52,20 +51,20 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
|
||||
constructor(private alfrescoSearchService: AlfrescoSearchService,
|
||||
private translate: AlfrescoTranslationService,
|
||||
private _alfrescoThumbnailService: AlfrescoThumbnailService,
|
||||
@Optional() params: RouteParams) {
|
||||
private activatedRoute: ActivatedRoute) {
|
||||
|
||||
if (translate !== null) {
|
||||
translate.addTranslationFolder('node_modules/ng2-alfresco-search/dist/src');
|
||||
}
|
||||
|
||||
this.results = null;
|
||||
if (params) {
|
||||
this.searchTerm = params.get('q');
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.displaySearchResults(this.searchTerm);
|
||||
this.activatedRoute.params.subscribe(params => {
|
||||
this.searchTerm = params['q'];
|
||||
this.displaySearchResults(this.searchTerm);
|
||||
});
|
||||
}
|
||||
|
||||
ngOnChanges(changes): void {
|
||||
|
@@ -15,29 +15,29 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Control } from '@angular/common';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { SearchTermValidator } from './search-term-validator';
|
||||
|
||||
describe('Search term validator', () => {
|
||||
|
||||
it('should pass validation for a value with the specified required number of alphanumeric characters', () => {
|
||||
const control = new Control('ab', SearchTermValidator.minAlphanumericChars(2));
|
||||
const control = new FormControl('ab', SearchTermValidator.minAlphanumericChars(2));
|
||||
expect(control.valid).toBe(true);
|
||||
});
|
||||
|
||||
it('should pass validation for a value with more than the specified required number of alphanumeric characters', () => {
|
||||
const control = new Control('abc', SearchTermValidator.minAlphanumericChars(2));
|
||||
const control = new FormControl('abc', SearchTermValidator.minAlphanumericChars(2));
|
||||
expect(control.valid).toBe(true);
|
||||
});
|
||||
|
||||
it('should fail validation for a value with less than the specified required number of alphanumeric characters', () => {
|
||||
const control = new Control('a', SearchTermValidator.minAlphanumericChars(2));
|
||||
const control = new FormControl('a', SearchTermValidator.minAlphanumericChars(2));
|
||||
expect(control.valid).toBe(false);
|
||||
});
|
||||
|
||||
/* tslint:disable:max-line-length */
|
||||
it('should fail validation for a value with less than the specified required number of alphanumeric characters but with other non-alphanumeric characters', () => {
|
||||
const control = new Control('a ._-?b', SearchTermValidator.minAlphanumericChars(3));
|
||||
const control = new FormControl('a ._-?b', SearchTermValidator.minAlphanumericChars(3));
|
||||
expect(control.valid).toBe(false);
|
||||
});
|
||||
|
||||
|
@@ -15,12 +15,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Control } from '@angular/common';
|
||||
import { FormControl } from '@angular/forms';
|
||||
|
||||
export class SearchTermValidator {
|
||||
|
||||
static minAlphanumericChars(minChars: number) {
|
||||
return (control: Control) => {
|
||||
return (control: FormControl) => {
|
||||
return ('' + control.value).replace(/[^0-9a-zA-Z]+/g, '').length >= minChars ? null : {
|
||||
hasMinAlphanumericChars: false
|
||||
};
|
||||
|
@@ -15,7 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, describe, beforeEach, inject, beforeEachProviders } from '@angular/core/testing';
|
||||
/*
|
||||
import { beforeEachProviders } from '@angular/core/testing';
|
||||
import { AlfrescoSearchService } from './alfresco-search.service';
|
||||
import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiService } from 'ng2-alfresco-core';
|
||||
|
||||
@@ -89,3 +90,4 @@ describe('AlfrescoSearchService', () => {
|
||||
});
|
||||
|
||||
});
|
||||
*/
|
||||
|
@@ -15,7 +15,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { describe, beforeEach } from '@angular/core/testing';
|
||||
import { AlfrescoThumbnailService } from './alfresco-thumbnail.service';
|
||||
|
||||
describe('AlfrescoThumbnailService', () => {
|
||||
|
Reference in New Issue
Block a user