-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3447 from ita-social-projects/search-eco-places
feat: Show places results in search popup
- Loading branch information
Showing
16 changed files
with
142 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
export interface EventsSearchModel { | ||
id: number; | ||
title: string; | ||
creationDate: string; | ||
tags: Array<string>; | ||
tags: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
export interface NewsSearchModel { | ||
id: number; | ||
title: string; | ||
author: { | ||
id: number; | ||
name: string; | ||
}; | ||
creationDate: string; | ||
tags: Array<string>; | ||
tags: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface PlacesSearchModel { | ||
id: number; | ||
name: string; | ||
category: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,6 @@ | ||
import { NewsSearchModel } from './newsSearch.model'; | ||
import { TipsSearchModel } from './tipsSearch.model'; | ||
import { EventsSearchModel } from './eventsSearch.model'; | ||
|
||
export interface SearchModel { | ||
countOfResults: number; | ||
ecoNews: Array<NewsSearchModel>; | ||
events: Array<EventsSearchModel>; | ||
tipsAndTricks: Array<TipsSearchModel>; | ||
} | ||
|
||
export interface SearchDataModel { | ||
export interface SearchDataModel<T = any> { | ||
currentPage: number; | ||
page: Array<TipsSearchModel>; | ||
page: Array<T>; | ||
totalElements: number; | ||
totalPages: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
<div class="search_item-wrp"> | ||
<div class="search_item-tag" *ngFor="let tag of searchModel.tags"> | ||
{{ tag }} | ||
<div class="search_item-tag" *ngFor="let item of commonModel.tagsOrCategory"> | ||
{{ item }} | ||
</div> | ||
<div class="search_item-title"> | ||
<a [routerLink]="['/' + type, searchModel.id]"> | ||
<p> | ||
{{ searchModel.title | slice: 0 : 130 }} | ||
</p> | ||
<a [routerLink]="itemLink"> | ||
<p>{{ commonModel.title | slice: 0 : 130 }}</p> | ||
</a> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,45 @@ | ||
import { userAssignedCardsIcons } from '../../main/image-pathes/profile-icons'; | ||
import { NewsSearchModel } from '@global-models/search/newsSearch.model'; | ||
import { EventsSearchModel } from '@global-models/search/eventsSearch.model'; | ||
import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; | ||
import { PlacesSearchModel } from '@global-models/search/placesSearch.model'; | ||
import { CommonSearchModel } from './search-item.model'; | ||
|
||
@Component({ | ||
selector: 'app-search-item', | ||
templateUrl: './search-item.component.html', | ||
styleUrls: ['./search-item.component.scss'] | ||
}) | ||
export class SearchItemComponent { | ||
@Input() searchModel: NewsSearchModel | EventsSearchModel; | ||
export class SearchItemComponent implements OnInit { | ||
@Input() searchModel: NewsSearchModel | EventsSearchModel | PlacesSearchModel; | ||
@Input() type: string; | ||
@Output() closeSearch: EventEmitter<boolean> = new EventEmitter(); | ||
profileIcons = userAssignedCardsIcons; | ||
|
||
commonModel: CommonSearchModel; | ||
itemLink: (string | number)[]; | ||
|
||
ngOnInit(): void { | ||
this.commonModel = this.convertToCommonModel(this.searchModel); | ||
this.itemLink = ['/' + this.type]; | ||
if (this.type !== 'places') { | ||
this.itemLink.push(this.searchModel.id); | ||
} | ||
} | ||
|
||
private convertToCommonModel(model: NewsSearchModel | EventsSearchModel | PlacesSearchModel): CommonSearchModel { | ||
if ('tags' in model) { | ||
return { | ||
id: model.id, | ||
title: model.title, | ||
tagsOrCategory: model.tags | ||
}; | ||
} else { | ||
return { | ||
id: model.id, | ||
title: model.name, | ||
tagsOrCategory: [model.category] | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface CommonSearchModel { | ||
id: number; | ||
title: string; | ||
tagsOrCategory: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export enum SearchCategory { | ||
NEWS = 'econews', | ||
EVENTS = 'events' | ||
NEWS = 'eco-news', | ||
EVENTS = 'events', | ||
PLACES = 'places' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { EventsSearchModel } from '@global-models/search/eventsSearch.model'; | ||
import { NewsSearchModel } from '@global-models/search/newsSearch.model'; | ||
import { PlacesSearchModel } from '@global-models/search/placesSearch.model'; | ||
import { SearchDataModel } from '@global-models/search/search.model'; | ||
|
||
export interface PopupSearchResults { | ||
news: SearchDataModel<NewsSearchModel>; | ||
events: SearchDataModel<EventsSearchModel>; | ||
places: SearchDataModel<PlacesSearchModel>; | ||
} |
Oops, something went wrong.