Skip to content

Commit

Permalink
Merge pull request #3808 from NoelDeMartin/MOBILE-3371
Browse files Browse the repository at this point in the history
MOBILE-3371: Global Search fixes
  • Loading branch information
dpalou authored Oct 6, 2023
2 parents 42aa917 + 0474d69 commit 3ae3c30
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 24 deletions.
1 change: 0 additions & 1 deletion scripts/langindex.json
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,6 @@
"addon.mod_forum.removefromfavourites": "forum",
"addon.mod_forum.reply": "forum",
"addon.mod_forum.replyplaceholder": "forum",
"addon.mod_forum.searchresults": "course",
"addon.mod_forum.subject": "forum",
"addon.mod_forum.tagarea_forum_posts": "forum",
"addon.mod_forum.thisforumhasduedate": "forum",
Expand Down
1 change: 0 additions & 1 deletion src/addons/mod/forum/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"removefromfavourites": "Unstar this discussion",
"reply": "Reply",
"replyplaceholder": "Write your reply...",
"searchresults": "Search results: {{$a}}",
"subject": "Subject",
"tagarea_forum_posts": "Forum posts",
"thisforumhasduedate": "The due date for posting to this forum is {{$a}}.",
Expand Down
4 changes: 0 additions & 4 deletions src/addons/mod/forum/pages/search/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ <h1 *ngIf="!forum">{{ 'addon.block_searchforums.pluginname' | translate }}</h1>
<core-search-box (onSubmit)="search($event)" (onClear)="clearSearch()" [placeholder]="'core.search' | translate"
[searchLabel]="'core.search' | translate" [autoFocus]="true" [searchArea]="searchAreaId"></core-search-box>

<div *ngIf="!resultsSource.isEmpty()" class="results-count">
{{ 'addon.mod_forum.searchresults' | translate: { $a: resultsSource.getTotalResults() } }}
</div>

<ion-list *ngIf="resultsSource.isLoaded()">
<core-search-global-search-result *ngFor="let result of resultsSource.getItems()" [result]="result" [showCourse]="false"
(onClick)="visitResult(result)">
Expand Down
3 changes: 1 addition & 2 deletions src/addons/mod/forum/tests/behat/search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@ Feature: Test Forum Search

When I set the field "Search" to "message" in the app
And I press "Search" "button" in the app
Then I should find "Search results: 2" in the app
And I should find "Test forum 1" in the app
Then I should find "Test forum 1" in the app
And I should find "Test forum 2" in the app
6 changes: 6 additions & 0 deletions src/core/components/mod-icon/mod-icon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
}
}

&.other {
img {
filter: var(--filter);
}
}

}

img {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h3 *ngIf="result.title">
<core-format-text [text]="result.title"></core-format-text>
</h3>
<core-format-text *ngIf="result.content && !result.course && !result.user" [text]="result.content"></core-format-text>
<div *ngIf="renderedContext" class="flex-row">
<div *ngIf="renderedContext" class="result-context-wrapper">
<div *ngIf="renderedContext.courseName" class="result-context">
<ion-icon name="fas-graduation-cap" aria-hidden="true"></ion-icon>
<core-format-text [text]="renderedContext.courseName"></core-format-text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
margin-bottom: 0px;
--padding: 0px;
background: transparent;
flex-shrink: 0;
}

ion-icon, .result-icon {
width: var(--core-global-search-result-icon-size);
height: var(--core-global-search-result-icon-size);

margin-inline-end: var(--spacing-2);
flex-shrink: 0;
}

}
Expand Down Expand Up @@ -61,20 +63,33 @@

}

.result-context {
.result-context-wrapper {
display: flex;
justify-items: center;
align-items: center;
color: var(--core-global-search-result-context-color);
margin-top: var(--spacing-2);
font-size: 12px;

ion-icon {
margin-inline-end: var(--spacing-1);
}
flex-wrap: wrap;
flex-direction: row;

.result-context {
display: flex;
justify-items: center;
align-items: center;
color: var(--core-global-search-result-context-color);
margin-top: var(--spacing-2);
margin-inline-end: var(--spacing-4);
font-size: 12px;

ion-icon {
margin-inline-end: var(--spacing-1);
flex-shrink: 0;
}

core-format-text {
color: var(--core-global-search-result-context-color);
}

span {
white-space: normal;
}

+ .result-context {
margin-inline-start: var(--spacing-4);
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/core/features/search/services/global-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class CoreSearchGlobalSearchService {
? await CoreSites.getSite(siteId)
: CoreSites.getRequiredCurrentSite();

return !site?.isFeatureDisabled('CoreNoDelegate_GlobalSearch')
return !site?.isFeatureDisabled('NoDelegate_GlobalSearch')
&& site?.wsAvailable('core_search_get_results') // @since 4.3
&& site?.canUseAdvancedFeature('enableglobalsearch');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ import { CommonModule } from '@angular/common';
import {
CoreSearchGlobalSearchResultsPageComponent,
} from '@features/search/stories/components/global-search-results-page/global-search-results-page';
import { CoreSearchGlobalSearchResultComponent } from '@features/search/components/global-search-result/global-search-result';
import { CoreSharedModule } from '@/core/shared.module';

@NgModule({
declarations: [
CoreSearchGlobalSearchResultsPageComponent,
CoreSearchGlobalSearchResultComponent,
],
imports: [
CoreSharedModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,26 @@ export class CoreSearchGlobalSearchResultsPageComponent {
iconurl: 'https://master.mm.moodledemo.net/theme/image.php?theme=boost&component=core&image=i%2Fsection',
},
},
{
id: 8,
url: '',
title: 'This item has long text everywhere, so make sure that it looks good anyways. ' +
'Even if the screen you\'re using is also big, this should still be a problem because this text is *really* long.',
content: 'You would normally see lorem ipsum here, but we decided to just write some gibberish here to make it more ' +
'real. We all know that lorem ipsum is fabricated text, and even though it serves its purpose, it isn\'t as ' +
'engaging as some real, hand-crafted text (not sure why this should be engaging, anyways).',
context: {
courseName: 'And it\'s not just the title, either. Other things like the Course title also take more than ' +
'you would expect in a normal site (or even not so normal).',
userName: 'To top it off, it has a user name as well! What is this madness? Well, at some point you just have to ' +
'get creative. Honestly, I\'m surprised if you\'re even reading this. Kudos to you for being thorough.',
},
module: {
name: 'book',
iconurl: 'assets/img/mod/book.svg',
area: '',
},
},
];

/**
Expand Down

0 comments on commit 3ae3c30

Please sign in to comment.