mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
Merge pull request #648 from Alfresco/dev-eromano-565
Cannot click on a item in search result
This commit is contained in:
commit
21486c110a
@ -16,13 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, EventEmitter, Output } from '@angular/core';
|
import { Component, EventEmitter, Output } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { ALFRESCO_SEARCH_DIRECTIVES } from 'ng2-alfresco-search';
|
import { ALFRESCO_SEARCH_DIRECTIVES } from 'ng2-alfresco-search';
|
||||||
import { VIEWERCOMPONENT } from 'ng2-alfresco-viewer';
|
import { VIEWERCOMPONENT } from 'ng2-alfresco-viewer';
|
||||||
import {
|
import { AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||||
AlfrescoAuthenticationService,
|
|
||||||
AlfrescoContentService
|
|
||||||
} from 'ng2-alfresco-core';
|
|
||||||
|
|
||||||
declare let __moduleName: string;
|
declare let __moduleName: string;
|
||||||
|
|
||||||
@ -30,48 +26,26 @@ declare let __moduleName: string;
|
|||||||
moduleId: __moduleName,
|
moduleId: __moduleName,
|
||||||
selector: 'search-bar',
|
selector: 'search-bar',
|
||||||
templateUrl: './search-bar.component.html',
|
templateUrl: './search-bar.component.html',
|
||||||
styles: [`
|
directives: [ALFRESCO_SEARCH_DIRECTIVES, VIEWERCOMPONENT]
|
||||||
`],
|
|
||||||
directives: [ ALFRESCO_SEARCH_DIRECTIVES, VIEWERCOMPONENT ]
|
|
||||||
})
|
})
|
||||||
export class SearchBarComponent {
|
export class SearchBarComponent {
|
||||||
|
|
||||||
urlFile: string;
|
fileNodeId: string;
|
||||||
fileName: string;
|
|
||||||
mimeType: string;
|
|
||||||
fileShowed: boolean = false;
|
fileShowed: boolean = false;
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
expand = new EventEmitter();
|
expand = new EventEmitter();
|
||||||
|
|
||||||
constructor(
|
constructor(public auth: AlfrescoAuthenticationService) {
|
||||||
public router: Router,
|
|
||||||
public auth: AlfrescoAuthenticationService,
|
|
||||||
public contentService: AlfrescoContentService
|
|
||||||
|
|
||||||
) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isLoggedIn(): boolean {
|
isLoggedIn(): boolean {
|
||||||
return this.auth.isLoggedIn();
|
return this.auth.isLoggedIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a new search term is submitted
|
|
||||||
*
|
|
||||||
* @param params Parameters relating to the search
|
|
||||||
*/
|
|
||||||
searchTermChange(params) {
|
|
||||||
this.router.navigate(['Search', {
|
|
||||||
q: params.value
|
|
||||||
}]);
|
|
||||||
}
|
|
||||||
|
|
||||||
onFileClicked(event) {
|
onFileClicked(event) {
|
||||||
if (event.value.entry.isFile) {
|
if (event.value.entry.isFile) {
|
||||||
this.fileName = event.value.entry.name;
|
this.fileNodeId = event.value.entry.id;
|
||||||
this.mimeType = event.value.entry.content.mimeType;
|
|
||||||
this.urlFile = this.contentService.getContentUrl(event.value);
|
|
||||||
this.fileShowed = true;
|
this.fileShowed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
<alfresco-search (preview)="onFileClicked($event)"></alfresco-search>
|
<alfresco-search (preview)="onFileClicked($event)"></alfresco-search>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<alfresco-viewer [(showViewer)]="previewActive" [urlFile]="previewContentUrl" [fileName]="previewName" [mimeType]="previewMimeType" [overlayMode]="true">
|
<alfresco-viewer [(showViewer)]="fileShowed" [fileNodeId]="fileNodeId" [overlayMode]="true">
|
||||||
<div class="mdl-spinner mdl-js-spinner is-active"></div>
|
<div class="mdl-spinner mdl-js-spinner is-active"></div>
|
||||||
</alfresco-viewer>
|
</alfresco-viewer>
|
||||||
|
@ -52,10 +52,7 @@ declare let __moduleName: string;
|
|||||||
})
|
})
|
||||||
export class SearchComponent {
|
export class SearchComponent {
|
||||||
|
|
||||||
previewContentUrl: string;
|
fileShowed: boolean = false;
|
||||||
previewName: string;
|
|
||||||
previewMimeType: string;
|
|
||||||
previewActive: boolean = false;
|
|
||||||
fileNodeId: string;
|
fileNodeId: string;
|
||||||
|
|
||||||
constructor(public contentService: AlfrescoContentService) {
|
constructor(public contentService: AlfrescoContentService) {
|
||||||
@ -64,7 +61,7 @@ export class SearchComponent {
|
|||||||
onFileClicked(event) {
|
onFileClicked(event) {
|
||||||
if (event.value.entry.isFile) {
|
if (event.value.entry.isFile) {
|
||||||
this.fileNodeId = event.value.entry.id;
|
this.fileNodeId = event.value.entry.id;
|
||||||
this.previewActive = true;
|
this.fileShowed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {it, describe, inject, beforeEach, beforeEachProviders} from '@angular/core/testing';
|
import { it, describe, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
||||||
import {ActivitiTaskListService} from './activiti-tasklist.service';
|
import { ActivitiTaskListService } from './activiti-tasklist.service';
|
||||||
import {AlfrescoSettingsService, AlfrescoAuthenticationService} from 'ng2-alfresco-core';
|
import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||||
import {TaskDetailsModel} from '../models/task-details.model';
|
import { TaskDetailsModel } from '../models/task-details.model';
|
||||||
import {Comment} from '../models/comment.model';
|
import { Comment } from '../models/comment.model';
|
||||||
|
|
||||||
declare let AlfrescoApi: any;
|
declare let AlfrescoApi: any;
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
@ -33,7 +33,7 @@ import {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'alfresco-search-demo',
|
selector: 'alfresco-search-demo',
|
||||||
template: `<label for="ticket"><b>Insert a valid access ticket / ticket:</b></label><br>
|
template: `<label for="ticket"><b>Insert a valid access ticket / ticket:</b></label><br>
|
||||||
<input id="ticket" type="text" size="48" (change)="updateticket()" [(ngModel)]="ticket"><br>
|
<input id="ticket" type="text" size="48" (change)="updateTicket()" [(ngModel)]="ticket"><br>
|
||||||
<label for="host"><b>Insert the ip of your Alfresco instance:</b></label><br>
|
<label for="host"><b>Insert the ip of your Alfresco instance:</b></label><br>
|
||||||
<input id="host" type="text" size="48" (change)="updateHost()" [(ngModel)]="ecmHost"><br><br>
|
<input id="host" type="text" size="48" (change)="updateHost()" [(ngModel)]="ecmHost"><br><br>
|
||||||
<div *ngIf="!authenticated" style="color:#FF2323">
|
<div *ngIf="!authenticated" style="color:#FF2323">
|
||||||
|
@ -4,7 +4,7 @@ module.exports = function (config) {
|
|||||||
var configuration = {
|
var configuration = {
|
||||||
basePath: '.',
|
basePath: '.',
|
||||||
|
|
||||||
frameworks: ['jasmine'],
|
frameworks: ['jasmine-ajax', 'jasmine'],
|
||||||
|
|
||||||
files: [
|
files: [
|
||||||
// paths loaded by Karma
|
// paths loaded by Karma
|
||||||
@ -67,6 +67,7 @@ module.exports = function (config) {
|
|||||||
plugins: [
|
plugins: [
|
||||||
'karma-jasmine',
|
'karma-jasmine',
|
||||||
'karma-coverage',
|
'karma-coverage',
|
||||||
|
'karma-jasmine-ajax',
|
||||||
'karma-chrome-launcher',
|
'karma-chrome-launcher',
|
||||||
'karma-mocha-reporter',
|
'karma-mocha-reporter',
|
||||||
'karma-jasmine-html-reporter'
|
'karma-jasmine-html-reporter'
|
||||||
|
@ -70,9 +70,8 @@
|
|||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.6",
|
||||||
"zone.js": "0.6.12",
|
"zone.js": "0.6.12",
|
||||||
"ng2-translate": "2.2.2",
|
"ng2-translate": "2.2.2",
|
||||||
"material-design-lite": "1.1.3",
|
|
||||||
"alfresco-js-api": "^0.3.0",
|
"alfresco-js-api": "^0.3.0",
|
||||||
"ng2-alfresco-core": "0.3.0"
|
"ng2-alfresco-core": "^0.3.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"material-design-icons": "^2.2.3",
|
"material-design-icons": "^2.2.3",
|
||||||
@ -88,6 +87,7 @@
|
|||||||
"karma-coverage": "1.0.0",
|
"karma-coverage": "1.0.0",
|
||||||
"karma-coveralls": "1.1.2",
|
"karma-coveralls": "1.1.2",
|
||||||
"karma-jasmine": "1.0.2",
|
"karma-jasmine": "1.0.2",
|
||||||
|
"karma-jasmine-ajax": "^0.1.13",
|
||||||
"karma-mocha-reporter": "2.0.3",
|
"karma-mocha-reporter": "2.0.3",
|
||||||
"karma-jasmine-html-reporter": "0.2.0",
|
"karma-jasmine-html-reporter": "0.2.0",
|
||||||
"license-check": "1.1.5",
|
"license-check": "1.1.5",
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<form (submit)="onSearch($event)">
|
<form (submit)="onSearch($event)">
|
||||||
<div [class]="getTextFieldClassName()">
|
<div [class]="getTextFieldClassName()">
|
||||||
<label *ngIf="expandable" class="mdl-button mdl-js-button mdl-button--icon" for="searchControl">
|
<label *ngIf="expandable" class="mdl-button mdl-js-button mdl-button--icon" for="searchControl">
|
||||||
<i class="material-icons">search</i>
|
<i mdl-upgrade class="material-icons">search</i>
|
||||||
</label>
|
</label>
|
||||||
<div [class]="getTextFieldHolderClassName()">
|
<div [class]="getTextFieldHolderClassName()">
|
||||||
<input class="mdl-textfield__input" [type]="inputType" [autocomplete]="getAutoComplete()" data-automation-id="search_input"
|
<input mdl-upgrade class="mdl-textfield__input" [type]="inputType" [autocomplete]="getAutoComplete()" data-automation-id="search_input"
|
||||||
#searchInput id="searchControl" [ngFormControl]="searchControl" [(ngModel)]="searchTerm" (focus)="onFocus($event)"
|
#searchInput id="searchControl" [ngFormControl]="searchControl" [(ngModel)]="searchTerm" (focus)="onFocus($event)"
|
||||||
(blur)="onBlur($event)" aria-labelledby="searchLabel">
|
(blur)="onBlur($event)" aria-labelledby="searchLabel">
|
||||||
<label id="searchLabel" class="mdl-textfield__label" for="searchControl">{{'SEARCH.CONTROL.LABEL' | translate}}</label>
|
<label id="searchLabel" class="mdl-textfield__label" for="searchControl">{{'SEARCH.CONTROL.LABEL' | translate}}</label>
|
||||||
|
@ -16,25 +16,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Control, Validators } from '@angular/common';
|
import { Control, Validators } from '@angular/common';
|
||||||
import { Component, Input, Output, ElementRef, EventEmitter, AfterViewInit, ViewChild } from '@angular/core';
|
import { Component, Input, Output, ElementRef, EventEmitter, ViewChild } from '@angular/core';
|
||||||
import { AlfrescoPipeTranslate, AlfrescoTranslationService } from 'ng2-alfresco-core';
|
import { AlfrescoPipeTranslate, AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||||
import { AlfrescoSearchAutocompleteComponent } from './alfresco-search-autocomplete.component';
|
import { AlfrescoSearchAutocompleteComponent } from './alfresco-search-autocomplete.component';
|
||||||
import { SearchTermValidator } from './../forms/search-term-validator';
|
import { SearchTermValidator } from './../forms/search-term-validator';
|
||||||
|
|
||||||
declare let __moduleName: string;
|
declare let __moduleName: string;
|
||||||
declare var componentHandler: any;
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
moduleId: __moduleName,
|
moduleId: __moduleName,
|
||||||
selector: 'alfresco-search-control',
|
selector: 'alfresco-search-control',
|
||||||
styles: [
|
|
||||||
],
|
|
||||||
templateUrl: './alfresco-search-control.component.html',
|
templateUrl: './alfresco-search-control.component.html',
|
||||||
styleUrls: ['./alfresco-search-control.component.css'],
|
styleUrls: ['./alfresco-search-control.component.css'],
|
||||||
directives: [AlfrescoSearchAutocompleteComponent],
|
directives: [AlfrescoSearchAutocompleteComponent],
|
||||||
pipes: [AlfrescoPipeTranslate]
|
pipes: [AlfrescoPipeTranslate]
|
||||||
})
|
})
|
||||||
export class AlfrescoSearchControlComponent implements AfterViewInit {
|
export class AlfrescoSearchControlComponent {
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
searchTerm = '';
|
searchTerm = '';
|
||||||
@ -77,21 +74,15 @@ export class AlfrescoSearchControlComponent implements AfterViewInit {
|
|||||||
|
|
||||||
this.searchControl.valueChanges.map(value => this.searchControl.valid ? value : '')
|
this.searchControl.valueChanges.map(value => this.searchControl.valid ? value : '')
|
||||||
.debounceTime(400).distinctUntilChanged().subscribe(
|
.debounceTime(400).distinctUntilChanged().subscribe(
|
||||||
(value: string) => {
|
(value: string) => {
|
||||||
this.autocompleteSearchTerm = value;
|
this.autocompleteSearchTerm = value;
|
||||||
this.searchValid = this.searchControl.valid;
|
this.searchValid = this.searchControl.valid;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
translate.addTranslationFolder('node_modules/ng2-alfresco-search/dist/src');
|
translate.addTranslationFolder('node_modules/ng2-alfresco-search/dist/src');
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
|
||||||
if (componentHandler) {
|
|
||||||
componentHandler.upgradeAllRegistered();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getTextFieldClassName(): string {
|
getTextFieldClassName(): string {
|
||||||
return 'mdl-textfield mdl-js-textfield' + (this.expandable ? ' mdl-textfield--expandable' : '');
|
return 'mdl-textfield mdl-js-textfield' + (this.expandable ? ' mdl-textfield--expandable' : '');
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
|
|||||||
|
|
||||||
route: any[] = [];
|
route: any[] = [];
|
||||||
|
|
||||||
constructor(private _alfrescoSearchService: AlfrescoSearchService,
|
constructor(private alfrescoSearchService: AlfrescoSearchService,
|
||||||
private translate: AlfrescoTranslationService,
|
private translate: AlfrescoTranslationService,
|
||||||
private _alfrescoThumbnailService: AlfrescoThumbnailService,
|
private _alfrescoThumbnailService: AlfrescoThumbnailService,
|
||||||
@Optional() params: RouteParams) {
|
@Optional() params: RouteParams) {
|
||||||
@ -118,7 +118,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
|
|||||||
*/
|
*/
|
||||||
public displaySearchResults(searchTerm): void {
|
public displaySearchResults(searchTerm): void {
|
||||||
if (searchTerm !== null) {
|
if (searchTerm !== null) {
|
||||||
this._alfrescoSearchService
|
this.alfrescoSearchService
|
||||||
.getLiveSearchResults(searchTerm)
|
.getLiveSearchResults(searchTerm)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
results => {
|
results => {
|
||||||
|
@ -15,17 +15,76 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { it, describe, beforeEach, inject, beforeEachProviders } from '@angular/core/testing';
|
||||||
describe,
|
import { AlfrescoSearchService } from './alfresco-search.service';
|
||||||
beforeEach
|
import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
|
||||||
} from '@angular/core/testing';
|
|
||||||
import {AlfrescoSearchService} from './alfresco-search.service';
|
declare let jasmine: any;
|
||||||
|
|
||||||
describe('AlfrescoSearchService', () => {
|
describe('AlfrescoSearchService', () => {
|
||||||
|
|
||||||
let service: AlfrescoSearchService;
|
let service: any;
|
||||||
|
|
||||||
beforeEach(() => {
|
let fakeSearch = {
|
||||||
service = new AlfrescoSearchService(null);
|
list: {
|
||||||
|
pagination: {
|
||||||
|
count: 1,
|
||||||
|
hasMoreItems: false,
|
||||||
|
totalItems: 1,
|
||||||
|
skipCount: 0,
|
||||||
|
maxItems: 100
|
||||||
|
},
|
||||||
|
entries: [
|
||||||
|
{
|
||||||
|
entry: {
|
||||||
|
id: '123',
|
||||||
|
name: 'MyDoc',
|
||||||
|
content: {
|
||||||
|
mimetype: 'text/plain'
|
||||||
|
},
|
||||||
|
createdByUser: {
|
||||||
|
displayName: 'John Doe'
|
||||||
|
},
|
||||||
|
modifiedByUser: {
|
||||||
|
displayName: 'John Doe'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeEachProviders(() => {
|
||||||
|
return [
|
||||||
|
AlfrescoSearchService,
|
||||||
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoAuthenticationService
|
||||||
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
beforeEach(inject([AlfrescoSearchService], (alfrescoSearchService: AlfrescoSearchService) => {
|
||||||
|
jasmine.Ajax.install();
|
||||||
|
service = alfrescoSearchService;
|
||||||
|
}));
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jasmine.Ajax.uninstall();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return search list', (done) => {
|
||||||
|
service.getSearchNodesPromise('MyDoc').then(
|
||||||
|
(res) => {
|
||||||
|
expect(res).toBeDefined();
|
||||||
|
expect(res.list.entries[0].entry.name).toEqual('MyDoc');
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
'status': 200,
|
||||||
|
contentType: 'application/json',
|
||||||
|
responseText: JSON.stringify(fakeSearch)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -17,12 +17,7 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
|
import { AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||||
import {
|
|
||||||
AlfrescoAuthenticationService
|
|
||||||
} from 'ng2-alfresco-core';
|
|
||||||
|
|
||||||
declare let AlfrescoApi: any;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal service used by Document List component.
|
* Internal service used by Document List component.
|
||||||
@ -33,14 +28,14 @@ export class AlfrescoSearchService {
|
|||||||
constructor(private authService: AlfrescoAuthenticationService) {
|
constructor(private authService: AlfrescoAuthenticationService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getSearchNodesPromise(term: string) {
|
public getSearchNodesPromise(term: string) {
|
||||||
let nodeId = '-root-';
|
let nodeId = '-root-';
|
||||||
let opts = {
|
let opts = {
|
||||||
include: ['path'],
|
include: ['path'],
|
||||||
rootNodeId: nodeId,
|
rootNodeId: nodeId,
|
||||||
nodeType: 'cm:content'
|
nodeType: 'cm:content'
|
||||||
};
|
};
|
||||||
return this.authService.getAlfrescoApi().search.liveSearchNodes(term, opts);
|
return this.authService.getAlfrescoApi().core.searchApi.liveSearchNodes(term, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,11 +15,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { describe, beforeEach } from '@angular/core/testing';
|
||||||
describe,
|
import { AlfrescoThumbnailService } from './alfresco-thumbnail.service';
|
||||||
beforeEach
|
|
||||||
} from '@angular/core/testing';
|
|
||||||
import {AlfrescoThumbnailService} from './alfresco-thumbnail.service';
|
|
||||||
|
|
||||||
describe('AlfrescoThumbnailService', () => {
|
describe('AlfrescoThumbnailService', () => {
|
||||||
|
|
||||||
|
@ -16,9 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import {
|
import { AlfrescoContentService } from 'ng2-alfresco-core';
|
||||||
AlfrescoContentService
|
|
||||||
} from 'ng2-alfresco-core';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlfrescoThumbnailService {
|
export class AlfrescoThumbnailService {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user