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

Fixes #1228 - Add the .filterLabel template to a file soy separate #1361

Merged
merged 5 commits into from
Dec 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay and change view o
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -1064,7 +1065,8 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay and change view o
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -2107,7 +2109,8 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay and change view o
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -2887,7 +2890,8 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with grouped item
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -3240,7 +3244,8 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with grouped item
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -3476,7 +3481,8 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with items and de
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -3869,7 +3875,8 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with items and li
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -4802,7 +4809,8 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with items and li
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -5845,7 +5853,8 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with items and li
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -6580,7 +6589,8 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with items and se
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -6768,7 +6778,8 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with selected gro
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -7496,7 +7507,8 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with selected ite
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -8007,7 +8019,8 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with ungrouped it
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -8682,7 +8695,8 @@ exports[`ClayDatasetDisplay should select and unselect all items 1`] = `
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -9572,7 +9586,8 @@ exports[`ClayDatasetDisplay should select and unselect all items 2`] = `
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -10343,7 +10358,8 @@ exports[`ClayDatasetDisplay should select and unselect all items 3`] = `
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<li class="tbar-item"><div class="tbar-section"><span class="label label-dismissible component-label tbar-label"><span class="label-item label-item-expand"><div class="label-section">Category: Label 3</div></span><span class="label-item label-item-after"><button class="btn close"aria-label="close"type="button"><svg class="lexicon-icon lexicon-icon-times"focusable="false"role="presentation"><use xlink:href="icons.svg#times" /></svg></button></span></span></div></li>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"spritemap": "icons.svg",
"closeable": true,
"label": "Category: Label 3",
"_handleFilterLabelCloseClicked": "(any|null)"
}
2 changes: 1 addition & 1 deletion packages/clay-management-toolbar/demos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ <h2>With filter labels</h2>
label: 'Filter 2',
},
{
label: 'Category: Label 3',
label: 'Category: <strong>Label 3</strong>',
}
]

Expand Down
36 changes: 36 additions & 0 deletions packages/clay-management-toolbar/src/ClayFilterLabel.soy
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{namespace ClayFilterLabel}

/**
* This render the filter label.
*/
{template .render}
{@param label: html|string}
{@param spritemap: string}
{@param? _handleFilterLabelCloseClicked: any}
{@param? closeable: bool}
{@param? expand: bool}

{let $elementClasses kind="text"}
tbar-item
{if $expand}
{sp}tbar-item-expand
{/if}
{/let}

<li class="{$elementClasses}">
<div class="tbar-section">
{call ClayLabel.render}
{param closeable: $closeable /}
{param elementClasses: 'component-label tbar-label' /}
{param events: ['close': $_handleFilterLabelCloseClicked] /}
{param label kind="html"}
<div class="label-section">{$label}</div>
{/param}

{param ref: 'label' /}
{param spritemap: $spritemap /}
{param style: false /}
{/call}
</div>
</li>
{/template}
1 change: 1 addition & 0 deletions packages/clay-management-toolbar/src/ClayResultsBar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'clay-button';
import 'clay-label';
import 'clay-link';
import './ClayFilterLabel.soy.js';
import {Config} from 'metal-state';
import ClayComponent from 'clay-component';
import defineWebComponent from 'metal-web-component';
Expand Down
40 changes: 2 additions & 38 deletions packages/clay-management-toolbar/src/ClayResultsBar.soy
Original file line number Diff line number Diff line change
Expand Up @@ -80,42 +80,6 @@
</li>
{/template}

/**
*
*/
{template .filterLabel}
{@param index: number}
{@param label: html|string}
{@param spritemap: string}
{@param? _handleFilterLabelCloseClicked: any}
{@param? closeable: bool}
{@param? expand: bool}

{let $elementClasses kind="text"}
tbar-item
{if $expand}
{sp}tbar-item-expand
{/if}
{/let}

<li class="{$elementClasses}">
<div class="tbar-section">
{call ClayLabel.render}
{param closeable: $closeable /}
{param elementClasses: 'component-label tbar-label' /}
{param events: ['close': $_handleFilterLabelCloseClicked] /}
{param label kind="html"}
<div class="label-section">{$label}</div>
{/param}

{param ref: 'label' + $index /}
{param spritemap: $spritemap /}
{param style: false /}
{/call}
</div>
</li>
{/template}

/**
* This renders the list of filter labels
*/
Expand All @@ -125,12 +89,12 @@
{@param? _handleFilterLabelCloseClicked: any}

{foreach $filterLabel in $filterLabels}
{call .filterLabel}
{call ClayFilterLabel.render}
{param _handleFilterLabelCloseClicked: $_handleFilterLabelCloseClicked /}
{param closeable: $filterLabel.closeable ?: true /}
{param expand: isLast($filterLabel) /}
{param index: index($filterLabel) /}
{param label: $filterLabel.label /}
{param ref: 'label' + index($filterLabel) /}
{param spritemap: $spritemap /}
{/call}
{/foreach}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ describe('ClayManagementToolbar', function() {
const spy = jest.spyOn(managementToolbar, 'emit');

// eslint-disable-next-line
managementToolbar.refs.resultsBar.refs.label1.refs.closeButton.element.click();
managementToolbar.refs.resultsBar.refs.label1.refs.label.refs.closeButton.element.click();

expect(spy).toHaveBeenCalled();
expect(spy).toHaveBeenCalledWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('ClayResultsBar', function() {

const spy = jest.spyOn(resultsBar, 'emit');

resultsBar.refs.label1.refs.closeButton.element.click();
resultsBar.refs.label1.refs.label.refs.closeButton.element.click();

expect(spy).toHaveBeenCalled();
expect(spy).toHaveBeenCalledWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2093,7 +2093,8 @@ exports[`ClayManagementToolbar should render a management toolbar with search re
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ exports[`ClayResultsBar should render a results bar with filter labels 1`] = `
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down Expand Up @@ -102,7 +103,8 @@ exports[`ClayResultsBar should render a results bar with filter labels and searc
<div class="tbar-section">
<span class="label label-dismissible component-label tbar-label">
<span class="label-item label-item-expand">
<div class="label-section">&lt;strong&gt;Category:&lt;/strong&gt;Label 3</div>
<div class="label-section">
<strong>Category:</strong>Label 3</div>
</span>
<span class="label-item label-item-after">
<button class="btn close" aria-label="close" type="button">
Expand Down