mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-26 17:24:45 +00:00
[ACA-1449][ACA-1448] Show searched term on the extended search input (#411)
* [ACA-1449][ACA-1448] Show searched term on the extended search input * [ACA-1449][ACA-1448] fix test
This commit is contained in:
parent
f8fe664f1f
commit
981b59095c
@ -1,8 +1,17 @@
|
|||||||
<adf-search-control
|
<div class="adf-search-control-wrapper">
|
||||||
[highlight]="true"
|
<button mat-icon-button
|
||||||
(optionClicked)="onItemClicked($event)"
|
*ngIf="onSearchResults"
|
||||||
[expandable]="!onSearchResults"
|
id="adf-search-button"
|
||||||
[liveSearchEnabled]="!onSearchResults"
|
class="adf-search-button"
|
||||||
(submit)="onSearchSubmit($event)"
|
[title]="'SEARCH.BUTTON.TOOLTIP' | translate">
|
||||||
(searchChange)="onSearchChange($event)">
|
<mat-icon [attr.aria-label]="'SEARCH.BUTTON.ARIA-LABEL' | translate">search</mat-icon>
|
||||||
</adf-search-control>
|
</button>
|
||||||
|
<adf-search-control #searchControl
|
||||||
|
[highlight]="true"
|
||||||
|
(optionClicked)="onItemClicked($event)"
|
||||||
|
[expandable]="!onSearchResults"
|
||||||
|
[liveSearchEnabled]="!onSearchResults"
|
||||||
|
(submit)="onSearchSubmit($event)"
|
||||||
|
(searchChange)="onSearchChange($event)">
|
||||||
|
</adf-search-control>
|
||||||
|
</div>
|
||||||
|
@ -8,3 +8,21 @@
|
|||||||
adf-search-control {
|
adf-search-control {
|
||||||
color: $alfresco-white;
|
color: $alfresco-white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.adf-search-control-wrapper {
|
||||||
|
display: flex;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
.adf-search-button {
|
||||||
|
left: -15px;
|
||||||
|
margin-left: 13px;
|
||||||
|
align-items: flex-start;
|
||||||
|
font: 400 11px system-ui;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -29,6 +29,7 @@ import { Router } from '@angular/router';
|
|||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
|
||||||
import { SearchInputComponent } from './search-input.component';
|
import { SearchInputComponent } from './search-input.component';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
|
||||||
describe('SearchInputComponent', () => {
|
describe('SearchInputComponent', () => {
|
||||||
let fixture;
|
let fixture;
|
||||||
@ -38,7 +39,8 @@ describe('SearchInputComponent', () => {
|
|||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [
|
||||||
RouterTestingModule
|
RouterTestingModule,
|
||||||
|
TranslateModule.forRoot()
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
SearchInputComponent
|
SearchInputComponent
|
||||||
|
@ -23,23 +23,62 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import {
|
||||||
|
NavigationEnd, PRIMARY_OUTLET, Router, RouterEvent, UrlSegment, UrlSegmentGroup,
|
||||||
|
UrlTree
|
||||||
|
} from '@angular/router';
|
||||||
import { MinimalNodeEntity } from 'alfresco-js-api';
|
import { MinimalNodeEntity } from 'alfresco-js-api';
|
||||||
|
import { SearchControlComponent } from '@alfresco/adf-content-services';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-search-input',
|
selector: 'app-search-input',
|
||||||
templateUrl: 'search-input.component.html',
|
templateUrl: 'search-input.component.html',
|
||||||
styleUrls: ['search-input.component.scss']
|
styleUrls: ['search-input.component.scss']
|
||||||
})
|
})
|
||||||
export class SearchInputComponent {
|
export class SearchInputComponent implements OnInit {
|
||||||
|
|
||||||
hasOneChange = false;
|
hasOneChange = false;
|
||||||
hasNewChange = false;
|
hasNewChange = false;
|
||||||
navigationTimer: any;
|
navigationTimer: any;
|
||||||
|
|
||||||
constructor(
|
@ViewChild('searchControl')
|
||||||
private router: Router) {
|
searchControl: SearchControlComponent;
|
||||||
|
|
||||||
|
constructor(private router: Router) {
|
||||||
|
this.router.events.filter(e => e instanceof RouterEvent).subscribe(event => {
|
||||||
|
if (event instanceof NavigationEnd) {
|
||||||
|
this.showInputValue();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.showInputValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
showInputValue() {
|
||||||
|
if (this.onSearchResults) {
|
||||||
|
|
||||||
|
let searchedWord = null;
|
||||||
|
const urlTree: UrlTree = this.router.parseUrl(this.router.url);
|
||||||
|
const urlSegmentGroup: UrlSegmentGroup = urlTree.root.children[PRIMARY_OUTLET];
|
||||||
|
|
||||||
|
if (urlSegmentGroup) {
|
||||||
|
const urlSegments: UrlSegment[] = urlSegmentGroup.segments;
|
||||||
|
searchedWord = urlSegments[0].parameters['q'];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.searchControl.searchTerm = searchedWord;
|
||||||
|
this.searchControl.subscriptAnimationState = 'no-animation';
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (this.searchControl.subscriptAnimationState === 'no-animation') {
|
||||||
|
this.searchControl.subscriptAnimationState = 'active';
|
||||||
|
this.searchControl.searchTerm = '';
|
||||||
|
this.searchControl.toggleSearchBar();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onItemClicked(node: MinimalNodeEntity) {
|
onItemClicked(node: MinimalNodeEntity) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user