[ALOY-787] A <Widget> in a widget view should default to the current src
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-07-01T15:01:20.000+0000 |
Affected Version/s | Alloy 1.2.0 |
Fix Version/s | Alloy 1.5.0 |
Components | n/a |
Labels | alloy, qe-manualtest, view, widget |
Reporter | Fokke Zandbergen |
Assignee | Feon Sua Xin Miao |
Created | 2013-08-12T06:47:19.000+0000 |
Updated | 2015-12-04T08:47:23.000+0000 |
Description
Considering this view of a widget:
<Alloy>
<Window>
<Widget name="secondView" />
</Window>
</Alloy>
I would like the src
attribute to automatically default to the widget it is used in. It's clean, better for my keyboard and one less statement to check if I decide to change my widget's name.
[~fokke] Is this ticket still valid? I'm not sure I understand what you're asking for and why you need it. Can you provide a better description? Maybe even a mocked up project showing how you'd like it to work?
[~skypanther], yes it's still valid. Imagine a widget with these 2 views: *widgets/my.widget/views/widget.xml*
*widgets/my.widget/views/other.xml*
I'd like to be able to leave out the
src
attribute in the first view. Why? Because I hate to repeat the id of the widget since a) I'm lazy b) It allows me to easily rename the widget.[~fokke] Widget tags are processed essentially as Require tags. In the case of widgets, the src attribute specifies the folder name from which to get the file specified with the name attribute. There are no properties available at runtime that give me this info automatically. The developer must supply it.
Closing as Won't Fix because we don't have a Can't Fix option.
Thanks for trying anyway :)
Re-opening as this could be implemented by injecting the widget name at compile time, then using it at runtime as a default if no explicit widget src is specified.
PR: https://github.com/appcelerator/alloy/pull/465 Test app: https://github.com/feons/alloy/tree/ALOY-787/test/apps/testing/ALOY-787 Functional Test: 1. Run the test app on iOS, it should compile with no error Noted that in *widgets/my.widget/views/widget.xml*, src attribute for Widget tag is omitted.
Thx [~fmiao]!
Tested on iOS Simulator with provided test app and works fine.
PR tested and merged
Verified working as expected on iPhone 5 iOS 7.1.2 - Android Nexus Galaxy 4.3 - MobileWeb TiSDK 3.4.0.v20140815142514 Appcelerator Studio 3.3.1.201408140648 CLI 3.4.0-dev Alloy 1.5.0-dev
It not work in Alloy 1.7.24
Inside
mywidget/views/widget.xml
widgets/mywidget/views/templates/showlistOne.xml
Android
[~falko] Could you simplify the test case by not using templates, but instead simple views? The first view is missing the Alloy root element as well. Does the following fail as well for you? *mywidget/views/widget.xml*
*mywidget/views/foo.xml*
I can't edit my comments for this issue to add
alloy
tag. My example is quite simple.[~falko],
Widget
is currently not supported inTemplates
, a related ticket is here ALOY-1220.That ticket has not relation to this. Please read carefully. In my case Widget works as Require and not inside ItemTemplate.
[~falko] I'm afraid what you see *is* variation of ALOY-1220 and ALOY-787: *This does NOT work:*
As does
<Require type="widget" name="bar" />
which both fail with:*This DOES work:*
As does
<Require type="widget" src="foo" name="bar" />
. [~fmiao] I guess the implementation of ALOY-787 is missing a case for when it's used in templates?Fokke Zandbergen your simple example also not work.
{noformat} [ERROR] : widget "foo" view "widget" does not exist. [ERROR] : The following paths were inspected: [ERROR] : /Users/falko/Documents/Appcelerator_Studio_Workspace/test123123/app/widgets/foo/views/android/widget [ERROR] : /Users/falko/Documents/Appcelerator_Studio_Workspace/test123123/app/widgets/foo/views/widget [ERROR] : /Users/falko/.appcelerator/install/5.2.0-55/package/node_modules/appc-cli-titanium/node_modules/alloy/widgets/foo/views/android/widget [ERROR] : /Users/falko/.appcelerator/install/5.2.0-55/package/node_modules/appc-cli-titanium/node_modules/alloy/widgets/foo/views/widget [ERROR] : Alloy compiler failed {noformat}
In the *widget.xml* you should have
name="foo"
and notsrc="foo"
@Fokke Zandbergen yes you right. But it does not work inside
Templates
.