Skip to content

Commit 106a7d0

Browse files
committed
#817 - Changing to input instead of navparams to avoid deprecation
1 parent 3621971 commit 106a7d0

File tree

31 files changed

+372
-377
lines changed

31 files changed

+372
-377
lines changed

src/app/beans/bean-filter/bean-filter.component.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, Input, OnInit } from '@angular/core';
22
import { Settings } from '../../../classes/settings/settings';
33
import { Preparation } from '../../../classes/preparation/preparation';
44
import { Bean } from '../../../classes/bean/bean';
55
import { Mill } from '../../../classes/mill/mill';
6-
import { ModalController, NavParams } from '@ionic/angular';
6+
import { ModalController } from '@ionic/angular';
77
import { UIHelper } from '../../../services/uiHelper';
88
import { UISettingsStorage } from '../../../services/uiSettingsStorage';
99
import { UIPreparationStorage } from '../../../services/uiPreparationStorage';
@@ -25,15 +25,16 @@ export class BeanFilterComponent implements OnInit {
2525
public method_of_preparations: Array<Preparation> = [];
2626
public beans: Array<Bean> = [];
2727
public mills: Array<Mill> = [];
28-
public segment: string = 'open';
28+
@Input('segment') public segment: string = 'open';
29+
30+
@Input('bean_filter') public bean_filter: any;
2931

3032
public beanRoastingTypeEnum = BEAN_ROASTING_TYPE_ENUM;
3133

3234
public roasteries: Array<string> = undefined;
3335

3436
constructor(
3537
private readonly modalController: ModalController,
36-
private readonly navParams: NavParams,
3738
public readonly uiHelper: UIHelper,
3839
private readonly uiSettingsStorage: UISettingsStorage,
3940
private readonly uiPreparationStorage: UIPreparationStorage,
@@ -62,8 +63,7 @@ export class BeanFilterComponent implements OnInit {
6263
}
6364

6465
public ngOnInit() {
65-
this.segment = this.navParams.get('segment');
66-
this.filter = this.uiHelper.copyData(this.navParams.get('bean_filter'));
66+
this.filter = this.uiHelper.copyData(this.bean_filter);
6767
this.__reloadFilterSettings();
6868
}
6969

src/app/beans/bean-popover-actions/bean-popover-actions.component.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Component, OnInit } from '@angular/core';
2-
import { ModalController, NavParams } from '@ionic/angular';
1+
import { Component, Input, OnInit } from '@angular/core';
2+
import { ModalController } from '@ionic/angular';
33
import { UIHelper } from '../../../services/uiHelper';
44
import { IBean } from '../../../interfaces/bean/iBean';
55
import { Bean } from '../../../classes/bean/bean';
@@ -18,25 +18,25 @@ export class BeanPopoverActionsComponent implements OnInit {
1818
public static COMPONENT_ID = 'bean-popover-actions';
1919
public data: Bean = new Bean();
2020

21+
@Input('bean') public bean: IBean;
22+
2123
public settings: Settings;
2224
constructor(
2325
private readonly modalController: ModalController,
24-
private readonly navParams: NavParams,
2526
private readonly uiHelper: UIHelper,
2627
private readonly uiBeanHelper: UIBeanHelper,
2728
private readonly uiSettingsStorage: UISettingsStorage
2829
) {
2930
// Moved from ionViewDidEnter, because of Ionic issues with ion-range
30-
const bean: IBean = this.uiHelper.copyData(this.navParams.get('bean'));
31-
32-
this.data.initializeByObject(bean);
33-
34-
this.settings = this.uiSettingsStorage.getSettings();
3531
}
3632

3733
public ionViewDidEnter(): void {}
3834

39-
public ngOnInit() {}
35+
public ngOnInit() {
36+
const bean: IBean = this.uiHelper.copyData(this.bean);
37+
this.data.initializeByObject(bean);
38+
this.settings = this.uiSettingsStorage.getSettings();
39+
}
4040

4141
public hasPhotos(): boolean {
4242
return this.data.attachments.length > 0;
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { Component, OnInit } from '@angular/core';
22

3-
import {ModalController, NavParams} from '@ionic/angular';
3+
import { ModalController } from '@ionic/angular';
44

5-
6-
import {BEAN_POPOVER_ADD_ACTION} from '../../../enums/beans/beanPopoverAddAction';
5+
import { BEAN_POPOVER_ADD_ACTION } from '../../../enums/beans/beanPopoverAddAction';
76

87
@Component({
98
selector: 'app-bean-popover-add',
@@ -13,27 +12,28 @@ import {BEAN_POPOVER_ADD_ACTION} from '../../../enums/beans/beanPopoverAddAction
1312
export class BeanPopoverAddComponent implements OnInit {
1413
public static COMPONENT_ID = 'bean-popover-add';
1514

16-
constructor(private readonly modalController: ModalController) {
17-
18-
}
19-
20-
public ionViewDidEnter(): void {
21-
}
22-
23-
public ngOnInit() {
15+
constructor(private readonly modalController: ModalController) {}
2416

25-
}
17+
public ionViewDidEnter(): void {}
2618

19+
public ngOnInit() {}
2720

2821
public getStaticActions(): any {
2922
return BEAN_POPOVER_ADD_ACTION;
3023
}
3124

3225
public async choose(_type: string): Promise<void> {
33-
this.modalController.dismiss(undefined, _type, BeanPopoverAddComponent.COMPONENT_ID);
26+
this.modalController.dismiss(
27+
undefined,
28+
_type,
29+
BeanPopoverAddComponent.COMPONENT_ID
30+
);
3431
}
3532
public async dismiss() {
36-
this.modalController.dismiss(undefined, undefined,BeanPopoverAddComponent.COMPONENT_ID);
33+
this.modalController.dismiss(
34+
undefined,
35+
undefined,
36+
BeanPopoverAddComponent.COMPONENT_ID
37+
);
3738
}
38-
3939
}

src/app/beans/bean-sort/bean-sort.component.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Component, OnInit } from '@angular/core';
2-
import { ModalController, NavParams } from '@ionic/angular';
1+
import { Component, Input, OnInit } from '@angular/core';
2+
import { ModalController } from '@ionic/angular';
33
import { UIHelper } from '../../../services/uiHelper';
44
import { IBeanPageSort } from '../../../interfaces/bean/iBeanPageSort';
55
import { BEAN_SORT_AFTER } from '../../../enums/beans/beanSortAfter';
@@ -19,14 +19,15 @@ export class BeanSortComponent implements OnInit {
1919
sort_after: BEAN_SORT_AFTER.UNKOWN,
2020
};
2121

22+
@Input('bean_sort') public bean_sort: any;
23+
2224
constructor(
2325
private readonly modalController: ModalController,
24-
private readonly navParams: NavParams,
2526
private readonly uiHelper: UIHelper
2627
) {}
2728

2829
public ngOnInit() {
29-
this.filter = this.uiHelper.copyData(this.navParams.get('bean_sort'));
30+
this.filter = this.uiHelper.copyData(this.bean_sort);
3031
this.__reloadFilterSettings();
3132
}
3233

src/app/beans/beans-detail/beans-detail.component.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Component, OnInit, ViewChild } from '@angular/core';
1+
import { Component, Input, OnInit, ViewChild } from '@angular/core';
22

3-
import { ModalController, NavParams } from '@ionic/angular';
3+
import { ModalController } from '@ionic/angular';
44
import { UIHelper } from '../../../services/uiHelper';
55
import { IBean } from '../../../interfaces/bean/iBean';
66
import { Bean } from '../../../classes/bean/bean';
@@ -25,7 +25,6 @@ export class BeansDetailComponent implements OnInit {
2525
public roast_enum = ROASTS_ENUM;
2626
public mixEnum = BEAN_MIX_ENUM;
2727
public beanRoastingTypeEnum = BEAN_ROASTING_TYPE_ENUM;
28-
public bean: IBean;
2928
public data: Bean = new Bean();
3029
public visibleIndex: any = {};
3130
@ViewChild('beanStars', { read: NgxStarsComponent, static: false })
@@ -36,9 +35,11 @@ export class BeansDetailComponent implements OnInit {
3635
public settings: Settings = undefined;
3736
public bean_segment = 'general';
3837
public maxBeanRating: number = 5;
38+
39+
@Input('bean') public bean: IBean;
40+
3941
constructor(
4042
private readonly modalController: ModalController,
41-
private readonly navParams: NavParams,
4243
public uiHelper: UIHelper,
4344
private readonly uiAnalytics: UIAnalytics,
4445
public readonly uiBeanHelper: UIBeanHelper,
@@ -50,7 +51,6 @@ export class BeansDetailComponent implements OnInit {
5051
BEAN_TRACKING.TITLE,
5152
BEAN_TRACKING.ACTIONS.DETAIL
5253
);
53-
this.bean = this.navParams.get('bean');
5454

5555
if (this.bean) {
5656
const copy: IBean = this.uiHelper.copyData(this.bean);

src/app/brew/brew-add/brew-add.component.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Geolocation } from '@capacitor/geolocation';
1111
import { UIBeanStorage } from '../../../services/uiBeanStorage';
1212
import { UIBrewStorage } from '../../../services/uiBrewStorage';
1313
import { UISettingsStorage } from '../../../services/uiSettingsStorage';
14-
import { ModalController, NavParams, Platform } from '@ionic/angular';
14+
import { ModalController, Platform } from '@ionic/angular';
1515
import { UIMillStorage } from '../../../services/uiMillStorage';
1616
import { UIPreparationStorage } from '../../../services/uiPreparationStorage';
1717
import { Brew } from '../../../classes/brew/brew';
@@ -58,13 +58,14 @@ declare var Plotly;
5858
})
5959
export class BrewAddComponent implements OnInit, OnDestroy {
6060
public static readonly COMPONENT_ID: string = 'brew-add';
61-
public brew_template: Brew;
61+
@Input('brew_template') public brew_template: Brew;
6262
public data: Brew = new Brew();
6363
public settings: Settings;
6464

6565
@Input() public brew_flow_preset: BrewFlow;
6666
@Input() public bean_preset: Bean;
6767

68+
@Input('loadSpecificLastPreparation')
6869
public loadSpecificLastPreparation: Preparation;
6970

7071
@ViewChild('brewBrewing', { read: BrewBrewingComponent, static: false })
@@ -77,9 +78,10 @@ export class BrewAddComponent implements OnInit, OnDestroy {
7778
private disableHardwareBack;
7879
public bluetoothSubscription: Subscription = undefined;
7980
public readonly PreparationDeviceType = PreparationDeviceType;
81+
8082
constructor(
8183
private readonly modalController: ModalController,
82-
private readonly navParams: NavParams,
84+
8385
private readonly uiBeanStorage: UIBeanStorage,
8486
private readonly uiPreparationStorage: UIPreparationStorage,
8587
private readonly uiBrewStorage: UIBrewStorage,
@@ -100,12 +102,7 @@ export class BrewAddComponent implements OnInit, OnDestroy {
100102
private readonly uiHelper: UIHelper
101103
) {
102104
// Initialize to standard in drop down
103-
104105
this.settings = this.uiSettingsStorage.getSettings();
105-
this.brew_template = this.navParams.get('brew_template');
106-
this.loadSpecificLastPreparation = this.navParams.get(
107-
'loadSpecificLastPreparation'
108-
);
109106

110107
// Get first entry
111108
this.data.bean = this.uiBeanStorage

src/app/brew/brew-cupping/brew-cupping.component.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Component, ViewChild } from '@angular/core';
2-
import { ModalController, NavParams } from '@ionic/angular';
1+
import { Component, Input, ViewChild } from '@angular/core';
2+
import { ModalController } from '@ionic/angular';
33
import { Brew } from '../../../classes/brew/brew';
44
import { Settings } from '../../../classes/settings/settings';
55
import { IBrew } from '../../../interfaces/brew/iBrew';
@@ -31,12 +31,11 @@ export class BrewCuppingComponent {
3131
public settings: Settings;
3232

3333
@ViewChild('radar', { static: false }) public radar: CuppingRadarComponent;
34-
private brew: IBrew;
35-
private bean: IBean;
34+
@Input('brew') public brew: IBrew;
35+
@Input('bean') public bean: IBean;
3636

3737
constructor(
3838
private readonly modalController: ModalController,
39-
private readonly navParams: NavParams,
4039
public uiHelper: UIHelper,
4140
private readonly uiSettingsStorage: UISettingsStorage,
4241
private readonly uiBrewStorage: UIBrewStorage,
@@ -87,7 +86,6 @@ export class BrewCuppingComponent {
8786
}
8887

8988
public ionViewWillEnter() {
90-
this.brew = this.navParams.get('brew');
9189
if (this.brew) {
9290
this.uiAnalytics.trackEvent(
9391
BREW_TRACKING.TITLE,
@@ -103,7 +101,6 @@ export class BrewCuppingComponent {
103101
BEAN_TRACKING.TITLE,
104102
BEAN_TRACKING.ACTIONS.CUPPING
105103
);
106-
this.bean = this.navParams.get('bean');
107104
this.data = new Bean();
108105
const copyBean: IBean = this.uiHelper.cloneData(
109106
this.uiBeanStorage.getByUUID(this.bean.config.uuid)

src/app/brew/brew-detail/brew-detail.component.ts

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import { Component, ViewChild } from '@angular/core';
1+
import { Component, Input, ViewChild } from '@angular/core';
22
import { UISettingsStorage } from '../../../services/uiSettingsStorage';
3-
import {
4-
AlertController,
5-
ModalController,
6-
NavParams,
7-
Platform,
8-
} from '@ionic/angular';
3+
import { AlertController, ModalController, Platform } from '@ionic/angular';
94
import { UIHelper } from '../../../services/uiHelper';
105
import { Brew } from '../../../classes/brew/brew';
116
import { IBrew } from '../../../interfaces/brew/iBrew';
@@ -47,7 +42,7 @@ export class BrewDetailComponent {
4742
public settings: Settings;
4843

4944
@ViewChild('cuppingChart', { static: false }) public cuppingChart;
50-
private brew: IBrew;
45+
@Input('brew') public brew: IBrew;
5146
public loaded: boolean = false;
5247

5348
private maximizeFlowGraphIsShown: boolean = false;
@@ -58,7 +53,6 @@ export class BrewDetailComponent {
5853

5954
constructor(
6055
private readonly modalController: ModalController,
61-
private readonly navParams: NavParams,
6256
public uiHelper: UIHelper,
6357
private readonly uiSettingsStorage: UISettingsStorage,
6458
public readonly uiBrewHelper: UIBrewHelper,
@@ -83,7 +77,6 @@ export class BrewDetailComponent {
8377
BREW_TRACKING.TITLE,
8478
BREW_TRACKING.ACTIONS.DETAIL
8579
);
86-
this.brew = this.navParams.get('brew');
8780
if (this.brew) {
8881
const copy: IBrew = this.uiHelper.copyData(this.brew);
8982
this.data.initializeByObject(copy);

src/app/brew/brew-edit/brew-edit.component.ts

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
import { Component, HostListener, OnInit, ViewChild } from '@angular/core';
1+
import {
2+
Component,
3+
HostListener,
4+
Input,
5+
OnInit,
6+
ViewChild,
7+
} from '@angular/core';
28
import { UIHelper } from '../../../services/uiHelper';
39
import { UIBrewStorage } from '../../../services/uiBrewStorage';
410
import { IBrew } from '../../../interfaces/brew/iBrew';
5-
import { ModalController, NavParams, Platform } from '@ionic/angular';
11+
import { ModalController, Platform } from '@ionic/angular';
612
import { Brew } from '../../../classes/brew/brew';
713
import moment from 'moment';
814
import { UIToast } from '../../../services/uiToast';
@@ -41,9 +47,9 @@ export class BrewEditComponent implements OnInit {
4147
private initialBeanData: string = '';
4248
private disableHardwareBack;
4349
public readonly PreparationDeviceType = PreparationDeviceType;
50+
@Input('brew') public brew: IBrew;
4451
constructor(
4552
private readonly modalController: ModalController,
46-
private readonly navParams: NavParams,
4753
private readonly uiBrewStorage: UIBrewStorage,
4854
private readonly uiHelper: UIHelper,
4955
private readonly uiToast: UIToast,
@@ -59,11 +65,6 @@ export class BrewEditComponent implements OnInit {
5965
) {
6066
this.settings = this.uiSettingsStorage.getSettings();
6167
// Moved from ionViewDidEnter, because of Ionic issues with ion-range
62-
const brew: IBrew = this.uiHelper.copyData(this.navParams.get('brew'));
63-
64-
if (brew !== undefined) {
65-
this.data.initializeByObject(brew);
66-
}
6768
}
6869

6970
@HostListener('window:keyboardWillShow')
@@ -76,6 +77,7 @@ export class BrewEditComponent implements OnInit {
7677
// Describe your logic which will be run each time when keyboard is about to be closed.
7778
this.showFooter = true;
7879
}
80+
7981
public ionViewDidEnter(): void {
8082
if (this.settings.wake_lock) {
8183
this.uiHelper.deviceKeepAwake();
@@ -228,6 +230,9 @@ export class BrewEditComponent implements OnInit {
228230
}
229231

230232
public ngOnInit() {
233+
if (this.brew !== undefined) {
234+
this.data.initializeByObject(this.brew);
235+
}
231236
this.uiAnalytics.trackEvent(
232237
BREW_TRACKING.TITLE,
233238
BREW_TRACKING.ACTIONS.EDIT

0 commit comments

Comments
 (0)