Skip to content

Commit ba74188

Browse files
fix any number of models (#486)
1 parent 5e1531b commit ba74188

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

transforms/angle-brackets/transform.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,10 @@ function transformLinkToAttrs(params) {
261261
if (models.length < 3) {
262262
_modelsParam = b.attr('@model', transformModelParams(models[0]));
263263
} else {
264-
_modelsParam = b.attr('@models', b.mustache(b.path('array'), models.slice().splice(0, 2)));
264+
_modelsParam = b.attr(
265+
'@models',
266+
b.mustache(b.path('array'), models.slice(0, models.length - 1))
267+
);
265268
}
266269
_qpParam = b.attr('@query', b.mustache(b.path('hash'), [], models[models.length - 1].hash));
267270
} else {

transforms/angle-brackets/transform.test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,31 @@ test('link-to-query-param', () => {
615615
'all-users'
616616
(query-params searchTerm=searchTerm)
617617
}}
618+
{{#link-to (concat parentName ".index")
619+
model.project.id
620+
model.projectVersion.compactVersion
621+
model.name
622+
(query-params anchor=undefined)
623+
class="tabbed-layout__menu__item"
624+
activeClass="tabbed-layout__menu__item_selected"
625+
current-when=(concat parentName ".index")
626+
data-test-tab="index"
627+
}}
628+
<span>Events</span>
629+
{{/link-to}}
630+
{{#link-to (concat parentName ".index")
631+
model.project.id
632+
model.projectVersion.compactVersion
633+
model.name
634+
model.description
635+
(query-params anchor=undefined)
636+
class="tabbed-layout__menu__item"
637+
activeClass="tabbed-layout__menu__item_selected"
638+
current-when=(concat parentName ".index")
639+
data-test-tab="index"
640+
}}
641+
<span>Events</span>
642+
{{/link-to}}
618643
`;
619644
/**
620645
* NOTE: An issue has been opened in `ember-template-recast` (https://github.com/ember-template-lint/ember-template-recast/issues/82)
@@ -639,6 +664,12 @@ test('link-to-query-param', () => {
639664
Recent Posts
640665
</LinkTo>
641666
<LinkTo @route=\\"apps.app.users.segments.segment\\" @model=\\"all-users\\" @query={{hash searchTerm=searchTerm}}>Users</LinkTo>
667+
<LinkTo @route={{concat parentName \\".index\\"}} @models={{array model.project.id model.projectVersion.compactVersion model.name}} @query={{hash anchor=undefined}} class=\\"tabbed-layout__menu__item\\" @activeClass=\\"tabbed-layout__menu__item_selected\\" @current-when={{concat parentName \\".index\\"}} data-test-tab=\\"index\\">
668+
<span>Events</span>
669+
</LinkTo>
670+
<LinkTo @route={{concat parentName \\".index\\"}} @models={{array model.project.id model.projectVersion.compactVersion model.name model.description}} @query={{hash anchor=undefined}} class=\\"tabbed-layout__menu__item\\" @activeClass=\\"tabbed-layout__menu__item_selected\\" @current-when={{concat parentName \\".index\\"}} data-test-tab=\\"index\\">
671+
<span>Events</span>
672+
</LinkTo>
642673
"
643674
`);
644675
});

0 commit comments

Comments
 (0)