Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-24817] Support Widgets in ListView templates #892

Merged
merged 6 commits into from
Apr 30, 2018

Conversation

garymathews
Copy link
Contributor

@garymathews garymathews commented Mar 30, 2018

REQUIRES tidev/titanium-sdk#9955
  • Support defining Alloy widgets in ListView templates
TEST CASE
<Alloy>
	<Window class="container" backgroundColor="white">
		
        <ListView id="listView" defaultItemTemplate="template">
            <Templates>
                <ItemTemplate name="template">
                    <Widget src="test.widget" bindId="testWidget" id="testWidget"/>
                </ItemTemplate>
            </Templates>

            <ListSection headerTitle="WIDGETS">
                <ListItem testWidget:backgroundColor="red" />
                <ListItem testWidget:backgroundColor="blue" />
                <ListItem testWidget:backgroundColor="orange" />
            </ListSection>
        </ListView>

	</Window>
</Alloy>

JIRA Ticket

@feons
Copy link
Contributor

feons commented Apr 3, 2018

@garymathews, what's the structure of test.widget?

@garymathews
Copy link
Contributor Author

// to generate a valid template
if (child.nodeName === 'Widget') {
let src = child.getAttribute('src'),
ns = src.split('.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ,
Also, widget ids are not necessarily be in the form of a.b.c. This won't work if the id is not . separated.

@feons
Copy link
Contributor

feons commented Apr 4, 2018

@garymathews, what's the expected output here? I see the text TEST1 against a white background.

@guiled
Copy link

guiled commented Apr 5, 2018

Will it be possible to bind a widget (using bindId property) ?

@garymathews
Copy link
Contributor Author

garymathews commented Apr 5, 2018

@feons updated both PRs and test case 👍

You should see three squares of red, blue and orange

@feons
Copy link
Contributor

feons commented Apr 30, 2018

@garymathews, looks good. Please update the package version!

@feons
Copy link
Contributor

feons commented Apr 30, 2018

Approved.

@feons feons merged commit 385ded2 into tidev:master Apr 30, 2018
@hansemannn
Copy link
Contributor

Was this tested before? Just tried with SDK 7.4.0 and Alloy 1.13.0 and it throws a build error:

<Alloy>
		<Window>
			<ListView id="listView" defaultItemTemplate="Cell">
				<Templates>
					<ItemTemplate name="Cell">
						<View height="250">
						        <Widget src="my.widget" bindId="testWidget" id="testWidget"/>
						</View>
					</ItemTemplate>
				</Templates>
				<ListSection>
					<ListItem></ListItem>
				</ListSection>
			</ListView>
		</Window>
</Alloy>

Error:

[DEBUG] /usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/default.js:98
[DEBUG]         					return childTemplates + '.push(' + state.item.symbol + ');';
[DEBUG]         					                                              ^
[DEBUG] TypeError: Cannot read property 'symbol' of undefined
[DEBUG]     at Object.post (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/default.js:98:53)
[DEBUG]     at Object.exports.parse (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/base.js:14:17)
[DEBUG]     at Object.exports.parse (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/Alloy.Require.js:12:27)

@jamieastley
Copy link

This issue was initially brought up on JIRA over 5 years ago, supposedly "fixed" last year according to this PR and yet is still broken and unresolved, i'm still getting the same crashes as above ^.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants