[ALOY-1132] 'testing/ALOY-1058' sample code is using quoted type value
GitHub Issue | n/a |
Type | Bug |
Priority | Medium |
Status | Resolved |
Resolution | Fixed |
Resolution Date | 2014-09-17T03:57:57.000+0000 |
Affected Version/s | Alloy 1.5.0, Alloy 1.4.1 |
Fix Version/s | Alloy 1.7.0 |
Components | Samples & Templates |
Labels | qe-3.4.0 |
Reporter | Federico Casali |
Assignee | Tim Poulsen |
Created | 2014-09-08T18:32:40.000+0000 |
Updated | 2014-10-23T19:47:55.000+0000 |
Description
Problem description
Sample code for ALOY-1058 is using a value for the type property with quotes, while, setting the type from the TSS, it should be used with no quotes.
Not a regression.
From the sample code "index.tss", type is defined in this way:
"#picker":{
type:"Ti.UI.PICKER_TYPE_DATE"
}
while type should be:
type: Ti.UI.PICKER_TYPE_DATE
Steps to reproduce
1. Run the sample code
Result: Running the sample, the picker is actually showing DATE as a type when run, but the constant values should be used with no quotes in the TSS.
Here is the compiled code from Resources/iphone/alloy/controller/index.js:
$.__views.picker = Ti.UI.createPicker({
type: "Ti.UI.PICKER_TYPE_DATE",
id: "picker",
minDate: new Date("Tue Apr 01 2014 00:00:00 GMT-0700 (PDT)"),
maxDate: new Date("Thu May 01 2014 12:00:00 GMT-0700 (PDT)"),
value: new Date("Tue Apr 15 2014 12:00:00 GMT-0700 (PDT)")
});
2. Change index.tss picker stile to:
"#picker":{
type:Ti.UI.PICKER_TYPE_DATE_AND_TIME
}
Result: compiled code is:
$.__views.picker = Ti.UI.createPicker({
type: "Ti.UI.PICKER_TYPE_DATE_AND_TIME",
id: "picker",
minDate: new Date("Tue Apr 01 2014 00:00:00 GMT-0700 (PDT)"),
maxDate: new Date("Thu May 01 2014 12:00:00 GMT-0700 (PDT)"),
value: new Date("Tue Apr 15 2014 12:00:00 GMT-0700 (PDT)")
});
However, DATE type picker is still shown (not DATE_AND_TIME).
Considering the generated code, this could be a behavior issue relative to how SDK is handling the Picker type property, not Alloy. Investigating and creating a Classic Titanium sample.
3. Change the picker style to:
"#picker":{
type:Ti.UI.PICKER_TYPE_DATE_AND_TIME
}
Result: Picker DATE_AND_STYLE is shown. Compiled code also looks good:
$.__views.picker = Ti.UI.createPicker({
type: Ti.UI.PICKER_TYPE_DATE_AND_TIME,
id: "picker",
minDate: new Date("Tue Apr 01 2014 00:00:00 GMT-0700 (PDT)"),
maxDate: new Date("Thu May 01 2014 12:00:00 GMT-0700 (PDT)"),
value: new Date("Tue Apr 15 2014 12:00:00 GMT-0700 (PDT)")
});
Note
My suggestion for the sample is to use the DATE_AND_TIME picker as type in case of iOS.
i.e.
"#picker":{
type:Ti.UI.PICKER_TYPE_DATE
}
"#picker[platform=ios]":{
type:Ti.UI.PICKER_TYPE_DATE_AND_TIME
}
Comments
- Tim Poulsen 2014-09-15
PR: https://github.com/appcelerator/alloy/pull/563
Functional test: run the ALOY-1058 sample on ios and android simulators, no errors, and you get the date-time or date pickers respectively. Examine the generated code to see that the constant is supplied to the picker constructor without quotes.
- Feon Sua Xin Miao 2014-09-17
PR merged.
JSON Source