Closed JacquesSchalkwyk closed 5 years ago
I sent the way to do this in another email, basically you create a variable to 'remember' the index of the previous item, then on subsequent calls to the selector, use that index:
... selectedIndex: number = 0; ... defaultItems: [ { index: 0, value: this.jsonData.products[*this*.selectedIndex].description } ]
Keeps the native plugin code clean, and allows for maximum flexibility for the app developer.
Thanks, Jason
On Mon, Nov 5, 2018 at 8:51 PM Jacques Schalkwyk notifications@github.com wrote:
Thank you so much for this plugin. To make it even better the following is required!
The ability for the wheel picker to remember the last option selected. This will make life a lot easy for people who do data capture where there a number of variants for the same item like in my industry I have a lot of Transmission Poles with different length and classes.
The ability to set a parent to filter list down to data that is only applicable to the relevant parent.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jasonmamy/cordova-wheel-selector-plugin/issues/41, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ9UxhiWVHi1yYYLo4ElRgUSixkHHAgGks5usRVcgaJpZM4YPwLT .
Hi Jason
Thank you for your prompt reply. I appreciate it.
Here is my modified code.
import { Component, OnInit } from '@angular/core'; import { ModalController, NavParams } from '@ionic/angular'; import { FormBuilder, FormGroup, FormArray } from '@angular/forms'; import { WheelSelector } from '@ionic-native/wheel-selector/ngx'; import { DataService } from '../services/data.service';
@Component({ selector: 'app-addload', templateUrl: './addload.page.html', styleUrls: ['./addload.page.scss'], })
export class AddloadPage implements OnInit {
worksOrder; productForm: FormGroup; selectedProduct; products: any; productLengths: any; productIndex = 0; productClass: any;
constructor( public modalController: ModalController, public navParams: NavParams, private selector: WheelSelector, private ds: DataService ) {
// this.ds.currentProducts.subscribe(Response => { // this.products = Response; // console.log(this.products); // });
this.ds.currentProductLength.subscribe(Response => { this.productLengths = Response; this.productLengths = JSON.parse(JSON.stringify(this.productLengths).split( '"length":').join('"description":')); // console.log(this.productLengths); });
this.ds.currentProductClass.subscribe(Response => { this.productClass = Response; // console.log(Response); });
}
ngOnInit() { this.worksOrder = this.navParams.get('data'); }
dismiss() { this.modalController.dismiss(); }
// basic number selection, index is always returned in the result selectProduct() {
this.ds.currentProducts.subscribe(Response => { this.products = Response; // console.log(this.products); // console.log(this.productIndex); this.selector.show({ title: 'Select product', items: [ this.products, this.productLengths, this.productClass ], theme: 'dark', wrapWheelText: true, defaultItems: [ { index: 0, value: this.products[this.productIndex].description } ]
}).then( result => { console.log(result); console.log(result[0].description + ' at index: ' + result[0].index); this.productIndex = result[0].index; console.log(this.productIndex); this.selectedProduct = result[0].description
});
}
}
I have included a screen cast so that you can see what I am seeing. As per the screen cast the selector starts at index 0 which is correct. I then pick another product 'Tx Poles' at index 2 and it gets set correctly. However when I return to the selector it is back at the 0 position. Am I missing something here.
-- Best regards,
Jacques Schalkwyk The 'Coding' Grandpa
I can't see the screencast, but everything looks ok to me, one thing you can do is (if it's android), a logcat, something like this:
logcat | grep SelectorCordovaPlugin
and look for the default items index that you sent in, to verify it got sent in as the correct index.
When you say "return to the selector", you mean that you select something and click 'ok', then start up the selector again?
On Tue, Nov 6, 2018 at 10:05 PM Jacques Schalkwyk notifications@github.com wrote:
Hi Jason
Thank you for your prompt reply. I appreciate it.
Here is my modified code.
import { Component, OnInit } from '@angular/core'; import { ModalController, NavParams } from '@ionic/angular'; import { FormBuilder, FormGroup, FormArray } from '@angular/forms'; import { WheelSelector } from '@ionic-native/wheel-selector/ngx'; import { DataService } from '../services/data.service';
@Component({ selector: 'app-addload', templateUrl: './addload.page.html', styleUrls: ['./addload.page.scss'], })
export class AddloadPage implements OnInit {
worksOrder; productForm: FormGroup; selectedProduct; products: any; productLengths: any; productIndex = 0; productClass: any;
constructor( public modalController: ModalController, public navParams: NavParams, private selector: WheelSelector, private ds: DataService ) {
// this.ds.currentProducts.subscribe(Response => { // this.products = Response; // console.log(this.products); // });
this.ds.currentProductLength.subscribe(Response => { this.productLengths = Response; this.productLengths = JSON.parse(JSON.stringify(this.productLengths).split( '"length":').join('"description":')); // console.log(this.productLengths); });
this.ds.currentProductClass.subscribe(Response => { this.productClass = Response; // console.log(Response); });
}
ngOnInit() { this.worksOrder = this.navParams.get('data'); }
dismiss() { this.modalController.dismiss(); }
// basic number selection, index is always returned in the result selectProduct() {
this.ds.currentProducts.subscribe(Response => { this.products = Response; // console.log(this.products); // console.log(this.productIndex); this.selector.show({ title: 'Select product', items: [ this.products, this.productLengths, this.productClass ], theme: 'dark', wrapWheelText: true, defaultItems: [ { index: 0, value: this.products[this.productIndex].description } ]
}).then( result => { console.log(result); console.log(result[0].description + ' at index: ' + result[0].index); this.productIndex = result[0].index; console.log(this.productIndex); this.selectedProduct = result[0].description
- ' - '
- result[1].description
- 'm'
- ' '
- result[2].description; }, err => console.log('Error: ', err) );
});
}
}
I have included a screen cast so that you can see what I am seeing. As per the screen cast the selector starts at index 0 which is correct. I then pick another product 'Tx Poles' at index 2 and it gets set correctly. However when I return to the selector it is back at the 0 position. Am I missing something here.
-- Best regards,
Jacques Schalkwyk The 'Coding' Grandpa
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jasonmamy/cordova-wheel-selector-plugin/issues/41#issuecomment-436514694, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ9UxmNZgm4jU1pSPJp9LlqqEyGldYqeks5usnhCgaJpZM4YPwLT .
Hi Jason
Let's assume I am going to capture sawlogs. I activate the selector and pick sawlogs and all other params and press done.. This is what I see!
[image: Shot1.png] Now I want to pic a different size saw log. The default item index is set to 1. I am expecting the selector to be at that position but it is not. it reverts to index 0 even though I have hard coded it to 1. This is what is returned to me.
[image: Shot2.png]
As can be seen below. I have hard coded the index to 1. I am using ionic 4.
this.ds.currentProducts.subscribe(Response => { this.products = Response; // console.log(this.products); // console.log(this.productIndex); this.selector.show({ title: 'Select product', items: [ this.products, this.productLengths, this.productClass ], theme: 'dark', wrapWheelText: true, defaultItems: [ /{ index: 0, value: this.products[this.productIndex].description } / { index: 0, value: this.products[1].description } ]
On Wed, 7 Nov 2018 at 19:38, jasonmamy notifications@github.com wrote:
I can't see the screencast, but everything looks ok to me, one thing you can do is (if it's android), a logcat, something like this:
logcat | grep SelectorCordovaPlugin
and look for the default items index that you sent in, to verify it got sent in as the correct index.
When you say "return to the selector", you mean that you select something and click 'ok', then start up the selector again?
On Tue, Nov 6, 2018 at 10:05 PM Jacques Schalkwyk < notifications@github.com> wrote:
Hi Jason
Thank you for your prompt reply. I appreciate it.
Here is my modified code.
import { Component, OnInit } from '@angular/core'; import { ModalController, NavParams } from '@ionic/angular'; import { FormBuilder, FormGroup, FormArray } from '@angular/forms'; import { WheelSelector } from '@ionic-native/wheel-selector/ngx'; import { DataService } from '../services/data.service';
@Component({ selector: 'app-addload', templateUrl: './addload.page.html', styleUrls: ['./addload.page.scss'], })
export class AddloadPage implements OnInit {
worksOrder; productForm: FormGroup; selectedProduct; products: any; productLengths: any; productIndex = 0; productClass: any;
constructor( public modalController: ModalController, public navParams: NavParams, private selector: WheelSelector, private ds: DataService ) {
// this.ds.currentProducts.subscribe(Response => { // this.products = Response; // console.log(this.products); // });
this.ds.currentProductLength.subscribe(Response => { this.productLengths = Response; this.productLengths = JSON.parse(JSON.stringify(this.productLengths).split( '"length":').join('"description":')); // console.log(this.productLengths); });
this.ds.currentProductClass.subscribe(Response => { this.productClass = Response; // console.log(Response); });
}
ngOnInit() { this.worksOrder = this.navParams.get('data'); }
dismiss() { this.modalController.dismiss(); }
// basic number selection, index is always returned in the result selectProduct() {
this.ds.currentProducts.subscribe(Response => { this.products = Response; // console.log(this.products); // console.log(this.productIndex); this.selector.show({ title: 'Select product', items: [ this.products, this.productLengths, this.productClass ], theme: 'dark', wrapWheelText: true, defaultItems: [ { index: 0, value: this.products[this.productIndex].description } ]
}).then( result => { console.log(result); console.log(result[0].description + ' at index: ' + result[0].index); this.productIndex = result[0].index; console.log(this.productIndex); this.selectedProduct = result[0].description
- ' - '
- result[1].description
- 'm'
- ' '
- result[2].description; }, err => console.log('Error: ', err) );
});
}
}
I have included a screen cast so that you can see what I am seeing. As per the screen cast the selector starts at index 0 which is correct. I then pick another product 'Tx Poles' at index 2 and it gets set correctly. However when I return to the selector it is back at the 0 position. Am I missing something here.
-- Best regards,
Jacques Schalkwyk The 'Coding' Grandpa
— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/jasonmamy/cordova-wheel-selector-plugin/issues/41#issuecomment-436514694 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AJ9UxmNZgm4jU1pSPJp9LlqqEyGldYqeks5usnhCgaJpZM4YPwLT
.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jasonmamy/cordova-wheel-selector-plugin/issues/41#issuecomment-436711238, or mute the thread https://github.com/notifications/unsubscribe-auth/Aawhy2Vh7OW2WeFqm9qaf9sNTbJbgiB1ks5usxqlgaJpZM4YPwLT .
-- Best regards,
Jacques Schalkwyk The 'Coding' Grandpa
That looks right to me and very similar to the working code I posted a few days ago, it's entirely possible that since Ionic 4 is still in beta, there might be an issue with their native layer? If it's easy could you create a quick Ionic 3 project and try the code (just hard-coded)?
On Fri, Nov 9, 2018 at 12:11 AM Jacques Schalkwyk notifications@github.com wrote:
Hi Jason
Let's assume I am going to capture sawlogs. I activate the selector and pick sawlogs and all other params and press done.. This is what I see!
[image: Shot1.png] Now I want to pic a different size saw log. The default item index is set to 1. I am expecting the selector to be at that position but it is not. it reverts to index 0 even though I have hard coded it to 1. This is what is returned to me.
[image: Shot2.png]
As can be seen below. I have hard coded the index to 1. I am using ionic 4.
this.ds.currentProducts.subscribe(Response => { this.products = Response; // console.log(this.products); // console.log(this.productIndex); this.selector.show({ title: 'Select product', items: [ this.products, this.productLengths, this.productClass ], theme: 'dark', wrapWheelText: true, defaultItems: [ /{ index: 0, value: this.products[this.productIndex].description } / { index: 0, value: this.products[1].description } ]
On Wed, 7 Nov 2018 at 19:38, jasonmamy notifications@github.com wrote:
I can't see the screencast, but everything looks ok to me, one thing you can do is (if it's android), a logcat, something like this:
logcat | grep SelectorCordovaPlugin
and look for the default items index that you sent in, to verify it got sent in as the correct index.
When you say "return to the selector", you mean that you select something and click 'ok', then start up the selector again?
On Tue, Nov 6, 2018 at 10:05 PM Jacques Schalkwyk < notifications@github.com> wrote:
Hi Jason
Thank you for your prompt reply. I appreciate it.
Here is my modified code.
import { Component, OnInit } from '@angular/core'; import { ModalController, NavParams } from '@ionic/angular'; import { FormBuilder, FormGroup, FormArray } from '@angular/forms'; import { WheelSelector } from '@ionic-native/wheel-selector/ngx'; import { DataService } from '../services/data.service';
@Component({ selector: 'app-addload', templateUrl: './addload.page.html', styleUrls: ['./addload.page.scss'], })
export class AddloadPage implements OnInit {
worksOrder; productForm: FormGroup; selectedProduct; products: any; productLengths: any; productIndex = 0; productClass: any;
constructor( public modalController: ModalController, public navParams: NavParams, private selector: WheelSelector, private ds: DataService ) {
// this.ds.currentProducts.subscribe(Response => { // this.products = Response; // console.log(this.products); // });
this.ds.currentProductLength.subscribe(Response => { this.productLengths = Response; this.productLengths = JSON.parse(JSON.stringify(this.productLengths).split( '"length":').join('"description":')); // console.log(this.productLengths); });
this.ds.currentProductClass.subscribe(Response => { this.productClass = Response; // console.log(Response); });
}
ngOnInit() { this.worksOrder = this.navParams.get('data'); }
dismiss() { this.modalController.dismiss(); }
// basic number selection, index is always returned in the result selectProduct() {
this.ds.currentProducts.subscribe(Response => { this.products = Response; // console.log(this.products); // console.log(this.productIndex); this.selector.show({ title: 'Select product', items: [ this.products, this.productLengths, this.productClass ], theme: 'dark', wrapWheelText: true, defaultItems: [ { index: 0, value: this.products[this.productIndex].description } ]
}).then( result => { console.log(result); console.log(result[0].description + ' at index: ' + result[0].index); this.productIndex = result[0].index; console.log(this.productIndex); this.selectedProduct = result[0].description
- ' - '
- result[1].description
- 'm'
- ' '
- result[2].description; }, err => console.log('Error: ', err) );
});
}
}
I have included a screen cast so that you can see what I am seeing. As per the screen cast the selector starts at index 0 which is correct. I then pick another product 'Tx Poles' at index 2 and it gets set correctly. However when I return to the selector it is back at the 0 position. Am I missing something here.
-- Best regards,
Jacques Schalkwyk The 'Coding' Grandpa
— You are receiving this because you commented. Reply to this email directly, view it on GitHub <
https://github.com/jasonmamy/cordova-wheel-selector-plugin/issues/41#issuecomment-436514694
, or mute the thread <
.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/jasonmamy/cordova-wheel-selector-plugin/issues/41#issuecomment-436711238 , or mute the thread < https://github.com/notifications/unsubscribe-auth/Aawhy2Vh7OW2WeFqm9qaf9sNTbJbgiB1ks5usxqlgaJpZM4YPwLT
.
-- Best regards,
Jacques Schalkwyk The 'Coding' Grandpa
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jasonmamy/cordova-wheel-selector-plugin/issues/41#issuecomment-437282542, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ9UxidSy2TWv8DJ47dgSutQfb7uQUSoks5utTitgaJpZM4YPwLT .
Thank you so much for this plugin. To make it even better the following is required!
The ability for the wheel picker to remember the last option selected. This will make life a lot easy for people who do data capture where there a number of variants for the same item like in my industry I have a lot of Transmission Poles with different length and classes.
The ability to set a parent to filter list down to data that is only applicable to the relevant parent.