Add searchForm input in all search pages

This commit is contained in:
Konstantinos Triantafyllou 2022-04-15 15:38:41 +03:00
parent 73b6704124
commit d17f9b4d5c
7 changed files with 165 additions and 130 deletions

View File

@ -59,7 +59,7 @@ import {properties} from "../../../environments/environment";
</form> </form>
</div> </div>
<search-dataproviders [simpleView]="true" type="deposit" simpleSearchLink="/participate/deposit/search" [includeOnlyResultsAndFilter]="true" > <search-dataproviders [simpleView]="true" [searchForm]="{class: null, dark: false}" type="deposit" simpleSearchLink="/participate/deposit/search" [includeOnlyResultsAndFilter]="true" >
</search-dataproviders> </search-dataproviders>
</div> </div>
` `

View File

@ -8,7 +8,7 @@ import {SearchFields} from '../utils/properties/searchFields';
import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class'; import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class';
import {EnvProperties} from '../utils/properties/env-properties'; import {EnvProperties} from '../utils/properties/env-properties';
import {NewSearchPageComponent} from "./searchUtils/newSearchPage.component"; import {NewSearchPageComponent, SearchForm} from "./searchUtils/newSearchPage.component";
import {DatasourcesHelperClass} from "./searchUtils/datasourcesHelper.class"; import {DatasourcesHelperClass} from "./searchUtils/datasourcesHelper.class";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
@ -34,7 +34,7 @@ import {properties} from "../../../environments/environment";
[openaireLink]=openaireLink [openaireLink]=openaireLink
[includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter" [includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter"
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix" [piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
[searchForm]="{class: '', dark: false}" [searchForm]="searchForm"
[entitiesSelection]="type=='all'" [showSwitchSearchLink]="showSwitchSearchLink" [entitiesSelection]="type=='all'" [showSwitchSearchLink]="showSwitchSearchLink"
[filters]="filters" [filters]="filters"
[simpleView]="simpleView" formPlaceholderText="Search by name, description, subject..." [simpleView]="simpleView" formPlaceholderText="Search by name, description, subject..."
@ -53,6 +53,7 @@ export class SearchDataProvidersComponent {
@Input() piwikSiteId = null; @Input() piwikSiteId = null;
@Input() customFilter:SearchCustomFilter= null; @Input() customFilter:SearchCustomFilter= null;
@Input() tableViewLink; @Input() tableViewLink;
@Input() searchForm: SearchForm = {class: 'search-form', dark: true};
public results =[]; public results =[];
public filters =[]; public filters =[];
public searchUtils:SearchUtilsClass = new SearchUtilsClass(); public searchUtils:SearchUtilsClass = new SearchUtilsClass();

View File

@ -7,7 +7,7 @@ import {ErrorMessagesComponent} from '../utils/errorMessages.component';
import {SearchFields} from '../utils/properties/searchFields'; import {SearchFields} from '../utils/properties/searchFields';
import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class'; import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class';
import {EnvProperties} from '../utils/properties/env-properties'; import {EnvProperties} from '../utils/properties/env-properties';
import {NewSearchPageComponent} from "./searchUtils/newSearchPage.component"; import {NewSearchPageComponent, SearchForm} from "./searchUtils/newSearchPage.component";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
@ -31,6 +31,7 @@ import {properties} from "../../../environments/environment";
[openaireLink]=openaireLink [openaireLink]=openaireLink
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix" [piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
[includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter" [includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter"
[searchForm]="searchForm"
[sort]="false" [sort]="false"
[filters]="filters" [filters]="filters"
[simpleView]="simpleView" formPlaceholderText="Search by organization name..." [simpleView]="simpleView" formPlaceholderText="Search by organization name..."
@ -46,6 +47,7 @@ export class SearchOrganizationsComponent {
private errorMessages: ErrorMessagesComponent; private errorMessages: ErrorMessagesComponent;
properties:EnvProperties; properties:EnvProperties;
@Input() piwikSiteId = null; @Input() piwikSiteId = null;
@Input() searchForm: SearchForm = {class: 'search-form', dark: true};
public results =[]; public results =[];
public filters =[]; public filters =[];
public searchUtils:SearchUtilsClass = new SearchUtilsClass(); public searchUtils:SearchUtilsClass = new SearchUtilsClass();

View File

@ -7,7 +7,7 @@ import {ErrorMessagesComponent} from '../utils/errorMessages.component';
import {SearchFields} from '../utils/properties/searchFields'; import {SearchFields} from '../utils/properties/searchFields';
import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class'; import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class';
import {EnvProperties} from '../utils/properties/env-properties'; import {EnvProperties} from '../utils/properties/env-properties';
import {NewSearchPageComponent} from "./searchUtils/newSearchPage.component"; import {NewSearchPageComponent, SearchForm} from "./searchUtils/newSearchPage.component";
import {RangeFilter} from "../utils/rangeFilter/rangeFilterHelperClasses.class"; import {RangeFilter} from "../utils/rangeFilter/rangeFilterHelperClasses.class";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
@ -30,6 +30,7 @@ import {properties} from "../../../environments/environment";
[oldTotalResults]="oldTotalResults" [oldTotalResults]="oldTotalResults"
[openaireLink]=openaireLink [openaireLink]=openaireLink
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix" [piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
[searchForm]="searchForm"
[includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter" [includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter"
[filters]="filters" [filters]="filters"
[rangeFilters]="rangeFilters" [rangeFields]="rangeFields" [rangeFilters]="rangeFilters" [rangeFields]="rangeFields"
@ -47,6 +48,7 @@ export class SearchProjectsComponent {
private errorMessages: ErrorMessagesComponent; private errorMessages: ErrorMessagesComponent;
@Input() piwikSiteId = null; @Input() piwikSiteId = null;
@Input() customFilter: SearchCustomFilter = null; @Input() customFilter: SearchCustomFilter = null;
@Input() searchForm: SearchForm = {class: 'search-form', dark: true};
public results = []; public results = [];
public filters = []; public filters = [];
public rangeFilters: RangeFilter[] = []; public rangeFilters: RangeFilter[] = [];
@ -138,6 +140,7 @@ export class SearchProjectsComponent {
firstLoad = false; firstLoad = false;
})); }));
} }
ngOnDestroy() { ngOnDestroy() {
if (this.searchResultsSub) { if (this.searchResultsSub) {
this.searchResultsSub.unsubscribe(); this.searchResultsSub.unsubscribe();
@ -154,7 +157,11 @@ export class SearchProjectsComponent {
if (page <= this.pagingLimit || this.searchUtils.refineStatus == this.errorCodes.LOADING) { if (page <= this.pagingLimit || this.searchUtils.refineStatus == this.errorCodes.LOADING) {
this.searchUtils.refineStatus = this.errorCodes.LOADING; this.searchUtils.refineStatus = this.errorCodes.LOADING;
this.disableRefineForms = true; this.disableRefineForms = true;
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils}); this.searchPageUpdates.emit({
disableForms: this.disableForms,
disableRefineForms: this.disableRefineForms,
searchUtils: this.searchUtils
});
this.searchFiltersSub = this._searchProjectsService.advancedSearchProjects(parameters, page, size, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery) this.searchFiltersSub = this._searchProjectsService.advancedSearchProjects(parameters, page, size, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery)
//.switchMap( //.switchMap(
.subscribe( .subscribe(
@ -172,7 +179,11 @@ export class SearchProjectsComponent {
this.searchUtils.refineStatus = this.errorMessages.getErrorCode(err.status); this.searchUtils.refineStatus = this.errorMessages.getErrorCode(err.status);
this.disableRefineForms = false; this.disableRefineForms = false;
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils}) this.searchPageUpdates.emit({
disableForms: this.disableForms,
disableRefineForms: this.disableRefineForms,
searchUtils: this.searchUtils
})
} }
); );
} }
@ -209,7 +220,11 @@ export class SearchProjectsComponent {
} }
this.disableRefineForms = false; this.disableRefineForms = false;
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils}) this.searchPageUpdates.emit({
disableForms: this.disableForms,
disableRefineForms: this.disableRefineForms,
searchUtils: this.searchUtils
})
} }
public getResults(parameters: string, page: number, size: number, refine: boolean, refineFieldsFilterQuery = null) { public getResults(parameters: string, page: number, size: number, refine: boolean, refineFieldsFilterQuery = null) {
@ -232,7 +247,11 @@ export class SearchProjectsComponent {
this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.status = this.errorCodes.LOADING;
//this.searchPage.openLoading(); //this.searchPage.openLoading();
this.disableForms = true; this.disableForms = true;
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils}); this.searchPageUpdates.emit({
disableForms: this.disableForms,
disableRefineForms: this.disableRefineForms,
searchUtils: this.searchUtils
});
this.results = []; this.results = [];
this.searchUtils.totalResults = 0; this.searchUtils.totalResults = 0;
@ -265,7 +284,11 @@ export class SearchProjectsComponent {
//this.searchPage.closeLoading(); //this.searchPage.closeLoading();
this.disableForms = false; this.disableForms = false;
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils}) this.searchPageUpdates.emit({
disableForms: this.disableForms,
disableRefineForms: this.disableRefineForms,
searchUtils: this.searchUtils
})
this.searchPage.hideFilters = false; this.searchPage.hideFilters = false;
} }
); );
@ -306,7 +329,11 @@ export class SearchProjectsComponent {
} }
this.disableForms = false; this.disableForms = false;
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils}) this.searchPageUpdates.emit({
disableForms: this.disableForms,
disableRefineForms: this.disableRefineForms,
searchUtils: this.searchUtils
})
} }
private handleError(message: string, error) { private handleError(message: string, error) {

View File

@ -7,7 +7,7 @@ import {ErrorMessagesComponent} from '../utils/errorMessages.component';
import {SearchFields} from '../utils/properties/searchFields'; import {SearchFields} from '../utils/properties/searchFields';
import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class'; import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class';
import {EnvProperties} from '../utils/properties/env-properties'; import {EnvProperties} from '../utils/properties/env-properties';
import {NewSearchPageComponent} from "./searchUtils/newSearchPage.component"; import {NewSearchPageComponent, SearchForm} from "./searchUtils/newSearchPage.component";
import {RangeFilter} from "../utils/rangeFilter/rangeFilterHelperClasses.class"; import {RangeFilter} from "../utils/rangeFilter/rangeFilterHelperClasses.class";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {ContextsService} from "../claims/claim-utils/service/contexts.service"; import {ContextsService} from "../claims/claim-utils/service/contexts.service";
@ -31,6 +31,7 @@ import {ContextsService} from "../claims/claim-utils/service/contexts.service";
[oldTotalResults]="oldTotalResults" [oldTotalResults]="oldTotalResults"
[openaireLink]=openaireLink [openaireLink]=openaireLink
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix" [piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
[searchForm]="searchForm"
[filters]="filters" [quickFilter]="quickFilter" [filters]="filters" [quickFilter]="quickFilter"
[rangeFilters]="rangeFilters" [rangeFields]="rangeFields" [rangeFilters]="rangeFilters" [rangeFields]="rangeFields"
[simpleView]="simpleView" formPlaceholderText="Search by title, author, abstract, DOI, orcid..." [simpleView]="simpleView" formPlaceholderText="Search by title, author, abstract, DOI, orcid..."
@ -39,7 +40,6 @@ import {ContextsService} from "../claims/claim-utils/service/contexts.service";
[stickyForm]="stickyForm" [stickyForm]="stickyForm"
> >
</new-search-page> </new-search-page>
` `
}) })
@ -53,6 +53,7 @@ export class SearchResearchResultsComponent {
private errorMessages: ErrorMessagesComponent; private errorMessages: ErrorMessagesComponent;
@Input() piwikSiteId = properties.piwikSiteId; @Input() piwikSiteId = properties.piwikSiteId;
@Input() hasPrefix: boolean = true; @Input() hasPrefix: boolean = true;
@Input() searchForm: SearchForm = {class: 'search-form', dark: true};
public results = []; public results = [];
public filters = []; public filters = [];
public rangeFilters: RangeFilter[] = []; public rangeFilters: RangeFilter[] = [];

View File

@ -26,6 +26,11 @@ import {Subscriber} from "rxjs";
import {IndexInfoService} from "../../utils/indexInfo.service"; import {IndexInfoService} from "../../utils/indexInfo.service";
import { Option } from '../../sharedComponents/input/input.component'; import { Option } from '../../sharedComponents/input/input.component';
export interface SearchForm {
class: string,
dark: boolean
}
declare var UIkit: any; declare var UIkit: any;
@Component({ @Component({
@ -59,10 +64,7 @@ export class NewSearchPageComponent {
@Input() customFilter: SearchCustomFilter; @Input() customFilter: SearchCustomFilter;
@Input() sort: boolean = true; @Input() sort: boolean = true;
@Input() sortedByChanged: string = ""; @Input() sortedByChanged: string = "";
@Input() searchForm = { @Input() searchForm: SearchForm = {class: 'search-form', dark: true};
class: 'search-form',
dark: true
};
//From simple: //From simple:
@Input() rangeFilters: RangeFilter[] = []; @Input() rangeFilters: RangeFilter[] = [];
@Input() rangeFields: string[][] = []; @Input() rangeFields: string[][] = [];

View File

@ -17,7 +17,7 @@ import {ClickEvent} from "../../utils/click/click-outside-or-esc.directive";
@Component({ @Component({
selector: '[search-input]', selector: '[search-input]',
template: ` template: `
<div class="uk-flex uk-flex-right uk-width-1-1"> <div *ngIf="initialized" class="uk-flex uk-flex-right uk-width-1-1">
<div #searchInput click-outside-or-esc (clickOutside)="click($event)" class="search-input" [class.collapsed]="hidden" [ngClass]="searchInputClass"> <div #searchInput click-outside-or-esc (clickOutside)="click($event)" class="search-input" [class.collapsed]="hidden" [ngClass]="searchInputClass">
<div class="uk-flex uk-flex-middle"> <div class="uk-flex uk-flex-middle">
<div class="uk-width-expand"> <div class="uk-width-expand">
@ -53,6 +53,7 @@ export class SearchInputComponent implements OnInit {
@ViewChild('searchInput') searchInput: ElementRef; @ViewChild('searchInput') searchInput: ElementRef;
@ViewChild('input') input: InputComponent; @ViewChild('input') input: InputComponent;
public expanded: boolean = true; public expanded: boolean = true;
public initialized: boolean = false;
constructor(private cdr: ChangeDetectorRef) { constructor(private cdr: ChangeDetectorRef) {
} }
@ -75,6 +76,7 @@ export class SearchInputComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.expanded = !this.expandable; this.expanded = !this.expandable;
this.initialized = true;
} }
expand(value: boolean) { expand(value: boolean) {