[ALOY-1092] Allow more query options / scope in .tss
GitHub Issue | n/a |
Type | Improvement |
Priority | Medium |
Status | Resolved |
Resolution | Fixed |
Resolution Date | 2014-10-07T04:17:24.000+0000 |
Affected Version/s | Alloy 1.5.0, Alloy 1.4.1 |
Fix Version/s | Alloy 1.7.0 |
Components | Styling |
Labels | n/a |
Reporter | Rick Blalock |
Assignee | Tim Poulsen |
Created | 2014-07-21T01:24:29.000+0000 |
Updated | 2014-10-23T19:47:52.000+0000 |
Description
The docs state that you have to use Alloy.Globals.* in a .tss query. You can actually use a local function in a controller too, i.e. "#window[if=myFunc()]"
and that will work too.
What won't work however is basing a query off of params passed to the controller instance. It would work, but the Alloy compiler doesn't allow it - "#window[if=arguments[0].someProp]"
This would be a very powerful addition to the new queries available. It technically already works in the runtime code (I hardcoded it and tried it)...but it just won't compile right now because we're not allowed to put those characters in the tss query.
Attachments
[~rblalock] Which characters is it complaining about? The brackets? Could you escape them?
See the attached screen. Even if the
arguments\[0\]
syntax worked, it would be pointing to the wrong arguments object. Your components are defined inside self-calling functions soarguments
correspond to that function's args. My couple of attempts to work around this by using a local function didn't work either.And of course this wouldn't work either, as again it refers to the wrong arguments object
I wouldn't focus on my "arguments[0]" as what should be the solution - the goal of this ticket is not to try to tell you how to provide the solution. The ticket is a request for more query options for TSS...the use case isn't "arguments[0]" but rather providing a scope from which the styles can be dynamic. As an idea for the problem you point out above.., instead of arguments[0] ... what if there was a
var __arguments = arguments[0];
put as the first line in the function? That would be assessable inside the closure then. Whatever the implementation is...the request is to allow arguments passed in a controller to determine tss styles.Reopening. I might be able to satisfy both this and ALOY-1037 with the same additions to the Controller() definition.
PR https://github.com/appcelerator/alloy/pull/584 Functional test: run the included ALOY\-1092 test app. Click the "Tap for new window" label. In the resulting window should be two labels, one saying the passed property was truthy and the other is present. Edit index.js and change the someProperty argument value to false and rebuild. This time, the child window will have just the first label saying the parameter was falsey.
PR merged.