Skip to content

Commit 17448fe

Browse files
committed
MOBILE-3281 search: Add history to search boxes
1 parent 67da1cd commit 17448fe

File tree

16 files changed

+514
-100
lines changed

16 files changed

+514
-100
lines changed

src/addon/messages/components/components.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { TranslateModule } from '@ngx-translate/core';
1919
import { CoreComponentsModule } from '@components/components.module';
2020
import { CoreDirectivesModule } from '@directives/directives.module';
2121
import { CorePipesModule } from '@pipes/pipes.module';
22+
import { CoreSearchComponentsModule } from '@core/search/components/components.module';
2223
import { AddonMessagesDiscussionsComponent } from '../components/discussions/discussions';
2324
import { AddonMessagesConfirmedContactsComponent } from '../components/confirmed-contacts/confirmed-contacts';
2425
import { AddonMessagesContactRequestsComponent } from '../components/contact-requests/contact-requests';
@@ -37,7 +38,8 @@ import { AddonMessagesContactsComponent } from '../components/contacts/contacts'
3738
TranslateModule.forChild(),
3839
CoreComponentsModule,
3940
CoreDirectivesModule,
40-
CorePipesModule
41+
CorePipesModule,
42+
CoreSearchComponentsModule,
4143
],
4244
providers: [
4345
],

src/addon/messages/pages/search/search.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { AddonMessagesSearchPage } from './search';
1919
import { CoreComponentsModule } from '@components/components.module';
2020
import { CoreDirectivesModule } from '@directives/directives.module';
2121
import { CorePipesModule } from '@pipes/pipes.module';
22+
import { CoreSearchComponentsModule } from '@core/search/components/components.module';
2223
import { AddonMessagesComponentsModule } from '../../components/components.module';
2324

2425
@NgModule({
@@ -29,9 +30,10 @@ import { AddonMessagesComponentsModule } from '../../components/components.modul
2930
CoreComponentsModule,
3031
CoreDirectivesModule,
3132
CorePipesModule,
33+
CoreSearchComponentsModule,
3234
AddonMessagesComponentsModule,
3335
IonicPageModule.forChild(AddonMessagesSearchPage),
34-
TranslateModule.forChild()
36+
TranslateModule.forChild(),
3537
],
3638
})
3739
export class AddonMessagesSearchPageModule {}

src/addon/mod/glossary/components/components.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { CoreComponentsModule } from '@components/components.module';
2020
import { CoreDirectivesModule } from '@directives/directives.module';
2121
import { CorePipesModule } from '@pipes/pipes.module';
2222
import { CoreCourseComponentsModule } from '@core/course/components/components.module';
23+
import { CoreSearchComponentsModule } from '@core/search/components/components.module';
2324
import { AddonModGlossaryIndexComponent } from './index/index';
2425
import { AddonModGlossaryModePickerPopoverComponent } from './mode-picker/mode-picker';
2526

@@ -35,7 +36,8 @@ import { AddonModGlossaryModePickerPopoverComponent } from './mode-picker/mode-p
3536
CoreComponentsModule,
3637
CoreDirectivesModule,
3738
CorePipesModule,
38-
CoreCourseComponentsModule
39+
CoreCourseComponentsModule,
40+
CoreSearchComponentsModule,
3941
],
4042
providers: [
4143
],

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ import { CoreRatingModule } from '@core/rating/rating.module';
8787
import { CoreTagModule } from '@core/tag/tag.module';
8888
import { CoreFilterModule } from '@core/filter/filter.module';
8989
import { CoreH5PModule } from '@core/h5p/h5p.module';
90+
import { CoreSearchModule } from '@core/search/search.module';
9091

9192
// Addon modules.
9293
import { AddonBadgesModule } from '@addon/badges/badges.module';
@@ -235,6 +236,7 @@ export const WP_PROVIDER: any = null;
235236
CoreTagModule,
236237
CoreFilterModule,
237238
CoreH5PModule,
239+
CoreSearchModule,
238240
AddonBadgesModule,
239241
AddonBlogModule,
240242
AddonCalendarModule,

src/app/app.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,15 @@ ion-app.app-root {
112112
@include core-selected-item($core-splitview-selected);
113113
}
114114

115-
// Recover borders on items inside cards.
115+
// Recover borders on items inside cards and lists.
116116
.card.with-borders .core-as-item,
117+
.list.with-borders .core-as-item,
117118
.core-as-item {
118119
@include core-as-items();
119120
}
120121

121-
.card.with-borders .item {
122+
.card.with-borders .item,
123+
.list.with-borders .item {
122124
@include core-items();
123125
}
124126

src/components/components.module.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { CoreSplitViewComponent } from './split-view/split-view';
2525
import { CoreIframeComponent } from './iframe/iframe';
2626
import { CoreProgressBarComponent } from './progress-bar/progress-bar';
2727
import { CoreEmptyBoxComponent } from './empty-box/empty-box';
28-
import { CoreSearchBoxComponent } from './search-box/search-box';
2928
import { CoreFileComponent } from './file/file';
3029
import { CoreFilesComponent } from './files/files';
3130
import { CoreIconComponent } from './icon/icon';
@@ -66,7 +65,6 @@ import { CoreBSTooltipComponent } from './bs-tooltip/bs-tooltip';
6665
CoreIframeComponent,
6766
CoreProgressBarComponent,
6867
CoreEmptyBoxComponent,
69-
CoreSearchBoxComponent,
7068
CoreFileComponent,
7169
CoreFilesComponent,
7270
CoreIconComponent,
@@ -118,7 +116,6 @@ import { CoreBSTooltipComponent } from './bs-tooltip/bs-tooltip';
118116
CoreIframeComponent,
119117
CoreProgressBarComponent,
120118
CoreEmptyBoxComponent,
121-
CoreSearchBoxComponent,
122119
CoreFileComponent,
123120
CoreFilesComponent,
124121
CoreIconComponent,

src/components/search-box/search-box.ts

Lines changed: 0 additions & 88 deletions
This file was deleted.

src/core/courses/pages/search/search.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { TranslateModule } from '@ngx-translate/core';
1818
import { CoreCoursesSearchPage } from './search';
1919
import { CoreComponentsModule } from '@components/components.module';
2020
import { CoreDirectivesModule } from '@directives/directives.module';
21+
import { CoreSearchComponentsModule } from '@core/search/components/components.module';
2122
import { CoreCoursesComponentsModule } from '../../components/components.module';
2223

2324
@NgModule({
@@ -28,8 +29,9 @@ import { CoreCoursesComponentsModule } from '../../components/components.module'
2829
CoreComponentsModule,
2930
CoreDirectivesModule,
3031
CoreCoursesComponentsModule,
32+
CoreSearchComponentsModule,
3133
IonicPageModule.forChild(CoreCoursesSearchPage),
32-
TranslateModule.forChild()
34+
TranslateModule.forChild(),
3335
],
3436
})
3537
export class CoreCoursesSearchPageModule {}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// (C) Copyright 2015 Moodle Pty Ltd.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import { NgModule } from '@angular/core';
16+
import { CommonModule } from '@angular/common';
17+
import { IonicModule } from 'ionic-angular';
18+
import { TranslateModule } from '@ngx-translate/core';
19+
import { CoreSearchBoxComponent } from './search-box/search-box';
20+
import { CoreDirectivesModule } from '@directives/directives.module';
21+
import { CoreComponentsModule } from '@components/components.module';
22+
23+
@NgModule({
24+
declarations: [
25+
CoreSearchBoxComponent,
26+
],
27+
imports: [
28+
CommonModule,
29+
IonicModule,
30+
TranslateModule.forChild(),
31+
CoreDirectivesModule,
32+
CoreComponentsModule,
33+
],
34+
providers: [
35+
],
36+
exports: [
37+
CoreSearchBoxComponent,
38+
],
39+
entryComponents: [
40+
CoreSearchBoxComponent,
41+
]
42+
})
43+
export class CoreSearchComponentsModule {}
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
<ion-card>
22
<form #f="ngForm" (ngSubmit)="submitForm($event)" role="search">
33
<ion-item>
4-
<ion-input type="search" name="search" [(ngModel)]="searchText" [placeholder]="placeholder" [autocorrect]="autocorrect" [spellcheck]="spellcheck" [core-auto-focus]="autoFocus" [disabled]="disabled" role="searchbox"></ion-input>
4+
<ion-input type="search" name="search" [(ngModel)]="searchText" [placeholder]="placeholder" [autocorrect]="autocorrect" [spellcheck]="spellcheck" [core-auto-focus]="autoFocus" [disabled]="disabled" role="searchbox" (focus)="showHistory()" (blur)="hideHistory()"></ion-input>
55
<button item-end ion-button clear icon-only type="submit" class="button-small" [attr.aria-label]="searchLabel" [disabled]="disabled || !searchText || (searchText.length < lengthCheck)">
66
<ion-icon name="search"></ion-icon>
77
</button>
8-
<button *ngIf="showClear" item-end ion-button clear icon-only class="button-small" [attr.aria-label]="'core.clearsearch' | translate" [disabled]="!searched || disabled" (click)="clearForm()">
8+
<button *ngIf="showClear" item-end ion-button clear icon-only class="button-small" [attr.aria-label]="'core.clearsearch' | translate" [disabled]="searched == '' || disabled" (click)="clearForm()">
99
<ion-icon name="close"></ion-icon>
1010
</button>
1111
</ion-item>
12+
<div class="core-search-history" *ngIf="historyShown && history.length">
13+
<ion-list class="with-borders">
14+
<ion-item text-wrap *ngFor="let item of history" (mousedown)="itemMouseDown($event, item.searchedtext)" (mouseup)="itemMouseUp($event, item.searchedtext)" class="core-clickable">
15+
<core-icon name="fa-history" item-start></core-icon>
16+
{{item.searchedtext}}
17+
</ion-item>
18+
</ion-list>
19+
</div>
1220
</form>
1321
</ion-card>

0 commit comments

Comments
 (0)