mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Merge pull request #290 from Alfresco/dev-wabson-228
Search component responsiveness
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
@media only screen and (max-width: 640px) {
|
||||||
|
.mdl-layout__header.header-search-expanded .mdl-layout-title {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
<div class="mdl-layout-spacer"></div>
|
<div class="mdl-layout-spacer"></div>
|
||||||
|
|
||||||
<!-- Search bar -->
|
<!-- Search bar -->
|
||||||
<search-bar></search-bar>
|
<search-bar (expand)="onToggleSearch($event)"></search-bar>
|
||||||
|
|
||||||
<!-- Navigation. We hide it in small screens. -->
|
<!-- Navigation. We hide it in small screens. -->
|
||||||
<nav class="mdl-navigation mdl-layout--large-screen-only">
|
<nav class="mdl-navigation mdl-layout--large-screen-only">
|
||||||
|
@@ -82,6 +82,16 @@ export class AppComponent {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onToggleSearch(event) {
|
||||||
|
let expandedHeaderClass = 'header-search-expanded',
|
||||||
|
header = document.querySelector('header');
|
||||||
|
if (event.expanded) {
|
||||||
|
header.classList.add(expandedHeaderClass);
|
||||||
|
} else {
|
||||||
|
header.classList.remove(expandedHeaderClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
changeLanguage(lang: string) {
|
changeLanguage(lang: string) {
|
||||||
this.translate.use(lang);
|
this.translate.use(lang);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<alfresco-search-control *ngIf="isLoggedIn()" [searchTerm]="searchTerm" [autocomplete]="false"
|
<alfresco-search-control *ngIf="isLoggedIn()" [searchTerm]="searchTerm" [autocomplete]="false"
|
||||||
(searchChange)="searchTermChange($event);"(preview)="onFileClicked($event)"></alfresco-search-control>
|
(searchChange)="searchTermChange($event);" (expand)="onExpandToggle($event);" (preview)="onFileClicked($event)"></alfresco-search-control>
|
||||||
|
|
||||||
<alfresco-viewer [(showViewer)]="fileShowed" [urlFile]="urlFile" [fileName]="fileName" [mimeType]="mimeType" [overlayMode]="true">
|
<alfresco-viewer [(showViewer)]="fileShowed" [urlFile]="urlFile" [fileName]="fileName" [mimeType]="mimeType" [overlayMode]="true">
|
||||||
<div class="mdl-spinner mdl-js-spinner is-active"></div>
|
<div class="mdl-spinner mdl-js-spinner is-active"></div>
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component, EventEmitter, Output } from '@angular/core';
|
||||||
import { Router } from '@angular/router-deprecated';
|
import { Router } from '@angular/router-deprecated';
|
||||||
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';
|
||||||
@@ -41,6 +41,9 @@ export class SearchBarComponent {
|
|||||||
mimeType: string;
|
mimeType: string;
|
||||||
fileShowed: boolean = false;
|
fileShowed: boolean = false;
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
expand = new EventEmitter();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public router: Router,
|
public router: Router,
|
||||||
public auth: AlfrescoAuthenticationService,
|
public auth: AlfrescoAuthenticationService,
|
||||||
@@ -72,4 +75,8 @@ export class SearchBarComponent {
|
|||||||
this.fileShowed = true;
|
this.fileShowed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onExpandToggle(event) {
|
||||||
|
this.expand.emit(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -36,6 +36,17 @@ declare let __moduleName: string;
|
|||||||
:host tbody tr {
|
:host tbody tr {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
@media screen and (max-width: 600px) {
|
||||||
|
:host .col-display-name {
|
||||||
|
min-width: 100px;
|
||||||
|
}
|
||||||
|
:host .col-modified-at, :host .col-modified-by {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
:host div.search-results-container table {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
`],
|
`],
|
||||||
directives: [ ALFRESCO_SEARCH_DIRECTIVES, VIEWERCOMPONENT ]
|
directives: [ ALFRESCO_SEARCH_DIRECTIVES, VIEWERCOMPONENT ]
|
||||||
})
|
})
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
"NONE": "No results found for {{searchTerm}}",
|
"NONE": "No results found for {{searchTerm}}",
|
||||||
"ERROR": "An error occurred while running the search",
|
"ERROR": "An error occurred while running the search",
|
||||||
"COLUMNS": {
|
"COLUMNS": {
|
||||||
"NAME": "Name",
|
"NAME": "Display name",
|
||||||
"MODIFIED_BY": "Modified by",
|
"MODIFIED_BY": "Modified by",
|
||||||
"MODIFIED_AT": "Modified at"
|
"MODIFIED_AT": "Modified at"
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
:host {
|
:host {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 1;
|
z-index: 5;
|
||||||
display: none;
|
display: none;
|
||||||
color: #555;
|
color: #555;
|
||||||
margin: -21px 0px 0px 0px;
|
margin: -21px 0px 0px 0px;
|
||||||
@@ -36,3 +36,12 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 400px) {
|
||||||
|
:host {
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
.truncate{
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -1,3 +1,13 @@
|
|||||||
.search-field{
|
.search-field {
|
||||||
width: 267px;
|
width: 267px;
|
||||||
}
|
}
|
||||||
|
@media only screen and (max-width: 400px) {
|
||||||
|
.search-field {
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 320px) {
|
||||||
|
.search-field {
|
||||||
|
width: 160px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
</label>
|
</label>
|
||||||
<div [class]="getTextFieldHolderClassName()">
|
<div [class]="getTextFieldHolderClassName()">
|
||||||
<input class="mdl-textfield__input" [type]="inputType" [autocomplete]="getAutoComplete()" data-automation-id="search_input"
|
<input class="mdl-textfield__input" [type]="inputType" [autocomplete]="getAutoComplete()" data-automation-id="search_input"
|
||||||
id="searchControl" [ngFormControl]="searchControl" [(ngModel)]="searchTerm" (focus)="onFocus($event)"
|
#searchInput id="searchControl" [ngFormControl]="searchControl" [(ngModel)]="searchTerm" (focus)="onFocus($event)"
|
||||||
(blur)="onBlur($event)">
|
(blur)="onBlur($event)">
|
||||||
<label class="mdl-textfield__label" for="searchControl">{{'SEARCH.CONTROL.LABEL' | translate}}</label>
|
<label class="mdl-textfield__label" for="searchControl">{{'SEARCH.CONTROL.LABEL' | translate}}</label>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Control, Validators } from '@angular/common';
|
import { Control, Validators } from '@angular/common';
|
||||||
import { Component, Input, Output, EventEmitter, AfterViewInit } from '@angular/core';
|
import { Component, Input, Output, ElementRef, EventEmitter, AfterViewInit, 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';
|
||||||
|
|
||||||
@@ -53,8 +53,13 @@ export class AlfrescoSearchControlComponent implements AfterViewInit {
|
|||||||
@Output()
|
@Output()
|
||||||
preview = new EventEmitter();
|
preview = new EventEmitter();
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
expand = new EventEmitter();
|
||||||
|
|
||||||
searchControl: Control;
|
searchControl: Control;
|
||||||
|
|
||||||
|
@ViewChild('searchInput', {}) searchInput: ElementRef;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
autocompleteSearchTerm = '';
|
autocompleteSearchTerm = '';
|
||||||
|
|
||||||
@@ -111,7 +116,7 @@ export class AlfrescoSearchControlComponent implements AfterViewInit {
|
|||||||
this.searchChange.emit({
|
this.searchChange.emit({
|
||||||
value: this.searchTerm
|
value: this.searchTerm
|
||||||
});
|
});
|
||||||
// this.router.navigate(['Search', term]);
|
this.searchInput.nativeElement.blur();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,12 +128,22 @@ export class AlfrescoSearchControlComponent implements AfterViewInit {
|
|||||||
|
|
||||||
onFocus(): void {
|
onFocus(): void {
|
||||||
this.searchActive = true;
|
this.searchActive = true;
|
||||||
|
if (this.expandable) {
|
||||||
|
this.expand.emit({
|
||||||
|
expanded: true
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onBlur(): void {
|
onBlur(): void {
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
this.searchActive = false;
|
this.searchActive = false;
|
||||||
}, 200);
|
}, 200);
|
||||||
|
if (this.expandable && (this.searchControl.value === '' || this.searchControl.value === undefined)) {
|
||||||
|
this.expand.emit({
|
||||||
|
expanded: false
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -3,28 +3,28 @@
|
|||||||
<table data-automation-id="search_result_table" *ngIf="results && results.length && searchTerm" class="mdl-data-table mdl-js-data-table mdl-shadow--2dp full-width">
|
<table data-automation-id="search_result_table" *ngIf="results && results.length && searchTerm" class="mdl-data-table mdl-js-data-table mdl-shadow--2dp full-width">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th class="mdl-data-table__cell--non-numeric col-mimetype-icon"></th>
|
||||||
<span class="mdl-data-table__cell--non-numeric"></span>
|
<th class="mdl-data-table__cell--non-numeric col-display-name">
|
||||||
|
{{'SEARCH.RESULTS.COLUMNS.NAME' | translate}}
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th class="mdl-data-table__cell--non-numeric col-modified-by">
|
||||||
<span class="mdl-data-table__cell--non-numeric">{{'SEARCH.RESULTS.COLUMNS.NAME' | translate}}</span>
|
{{'SEARCH.RESULTS.COLUMNS.MODIFIED_BY' | translate}}
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th class="mdl-data-table__cell--non-numeric col-modified-at">
|
||||||
<span class="mdl-data-table__cell--non-numeric">{{'SEARCH.RESULTS.COLUMNS.MODIFIED_BY' | translate}}</span>
|
{{'SEARCH.RESULTS.COLUMNS.MODIFIED_AT' | translate}}
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<span class="mdl-data-table__cell--non-numeric">{{'SEARCH.RESULTS.COLUMNS.MODIFIED_AT' | translate}}</span>
|
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<tr *ngFor="let result of results; let idx = index" (click)="onItemClick(result, $event)">
|
<tr *ngFor="let result of results; let idx = index" (click)="onItemClick(result, $event)">
|
||||||
<td><img src="{{getMimeTypeIcon(result)}}" /></td>
|
<td class="col-mimetype-icon"><img src="{{getMimeTypeIcon(result)}}" /></td>
|
||||||
<td attr.data-automation-id=file_{{result.entry.name}} >{{result.entry.name}}</td>
|
<td class="mdl-data-table__cell--non-numeric col-display-name"
|
||||||
<td attr.data-automation-id=file_{{result.entry.name}}_{{result.entry.modifiedByUser.displayName}}>
|
attr.data-automation-id=file_{{result.entry.name}} >{{result.entry.name}}</td>
|
||||||
|
<td class="mdl-data-table__cell--non-numeric col-modified-by"
|
||||||
|
attr.data-automation-id=file_{{result.entry.name}}_{{result.entry.modifiedByUser.displayName}}>
|
||||||
{{result.entry.modifiedByUser.displayName}}</td>
|
{{result.entry.modifiedByUser.displayName}}</td>
|
||||||
<td>{{result.entry.modifiedAt | date}}</td>
|
<td class="col-modified-at">{{result.entry.modifiedAt | date}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@@ -26,7 +26,20 @@ declare let __moduleName: string;
|
|||||||
@Component({
|
@Component({
|
||||||
moduleId: __moduleName,
|
moduleId: __moduleName,
|
||||||
selector: 'alfresco-search',
|
selector: 'alfresco-search',
|
||||||
styles: [],
|
styles: [`
|
||||||
|
:host .mdl-data-table td {
|
||||||
|
max-width: 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
:host .mdl-data-table td.col-mimetype-icon {
|
||||||
|
width: 24px;
|
||||||
|
}
|
||||||
|
:host .col-display-name {
|
||||||
|
min-width: 250px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
`],
|
||||||
templateUrl: './alfresco-search.component.html',
|
templateUrl: './alfresco-search.component.html',
|
||||||
providers: [AlfrescoSearchService],
|
providers: [AlfrescoSearchService],
|
||||||
pipes: [AlfrescoPipeTranslate]
|
pipes: [AlfrescoPipeTranslate]
|
||||||
|
Reference in New Issue
Block a user