mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Add expandable input field to search control
This commit is contained in:
@@ -144,6 +144,7 @@ bootstrap(SearchDemo, [
|
||||
|
||||
**searchTerm**: {string} (optional) default "". Search term to pre-populate the field with<br />
|
||||
**inputType**: {string} (optional) default "text". Type of the input field to render, e.g. "search" or "text" (default)<br />
|
||||
**expandable** {boolean} (optional) default true. Whether to use an expanding search control, if false then a regular input is used.
|
||||
|
||||
### Search results
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
<form (submit)="onSearch($event)">
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--expandable">
|
||||
<label class="mdl-button mdl-js-button mdl-button--icon" for="searchTerm">
|
||||
<div [class]="getTextFieldClassName()">
|
||||
<label *ngIf="expandable" class="mdl-button mdl-js-button mdl-button--icon" for="searchTerm">
|
||||
<i class="material-icons">search</i>
|
||||
</label>
|
||||
<div class="mdl-textfield__expandable-holder">
|
||||
<div [class]="getTextFieldHolderClassName()">
|
||||
<input class="mdl-textfield__input" [type]="inputType" id="searchTerm" [ngFormControl]="searchControl" [(ngModel)]="searchTerm">
|
||||
<label class="mdl-textfield__label" for="searchTerm">Search content</label>
|
||||
</div>
|
||||
|
@@ -38,6 +38,9 @@ export class AlfrescoSearchControlComponent {
|
||||
@Input()
|
||||
inputType = 'text';
|
||||
|
||||
@Input()
|
||||
expandable: boolean = true;
|
||||
|
||||
@Output()
|
||||
searchChange = new EventEmitter();
|
||||
|
||||
@@ -56,6 +59,14 @@ export class AlfrescoSearchControlComponent {
|
||||
componentHandler.upgradeAllRegistered();
|
||||
}
|
||||
|
||||
getTextFieldClassName(): string {
|
||||
return 'mdl-textfield mdl-js-textfield' + (this.expandable ? ' mdl-textfield--expandable' : '');
|
||||
}
|
||||
|
||||
getTextFieldHolderClassName(): string {
|
||||
return this.expandable ? ' mdl-textfield__expandable-holder' : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called on form submit, i.e. when the user has hit enter
|
||||
*
|
||||
|
Reference in New Issue
Block a user