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 #1329 - Makes the actions menu a deltemplate #1356

Merged
merged 1 commit 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
9 changes: 9 additions & 0 deletions packages/clay-table/src/ClayTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ class ClayTable extends Component {
* @type {!Object}
*/
ClayTable.STATE = {
/**
* Variant name to render the actions menu
* @default undefined
* @instance
* @memberof ClayTable
* @type {?(string|undefined)}
*/
actionsMenuVariant: Config.string(),

/**
* CSS classes to be applied to the element.
* @default undefined
Expand Down
65 changes: 43 additions & 22 deletions packages/clay-table/src/ClayTable.soy
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{@param? _handleCellContentClick: any}
{@param? _handleItemToggled: any}
{@param? _handleSortingClick: any}
{@param? actionsMenuVariant: string}
{@param? elementClasses: string}
{@param? id: string}
{@param? items: list<?>}
Expand Down Expand Up @@ -62,6 +63,7 @@
{call .body}
{param _handleCellContentClick: $_handleCellContentClick /}
{param _handleItemToggled: $_handleItemToggled /}
{param actionsMenuVariant: $actionsMenuVariant /}
{param id: $id /}
{param items: $items /}
{param schema: $schema /}
Expand Down Expand Up @@ -121,6 +123,7 @@
]}
{@param? _handleCellContentClick: any}
{@param? _handleItemToggled: any}
{@param? actionsMenuVariant: string}
{@param? id: string}
{@param? items: list<?>}
{@param? selectable: bool}
Expand All @@ -132,6 +135,7 @@
{call .rows}
{param _handleCellContentClick: $_handleCellContentClick /}
{param _handleItemToggled: $_handleItemToggled /}
{param actionsMenuVariant: $actionsMenuVariant /}
{param groupName: $id /}
{param items: $items /}
{param schema: $schema /}
Expand Down Expand Up @@ -227,6 +231,7 @@
]}
{@param? _handleCellContentClick: any}
{@param? _handleItemToggled: any}
{@param? actionsMenuVariant: string}
{@param? groupName: string}
{@param? selectable: bool}
{@param? showActionsMenu: bool}
Expand Down Expand Up @@ -299,28 +304,10 @@
{/if}

{if $showActionsMenu and $item.actionItems and $spritemap}
<td>
<div class="quick-action-menu">
{foreach $actionItem in $item.actionItems}
{if $actionItem.quickAction and $actionItem.icon}
{call ClayLink.render}
{param ariaLabel: $actionItem.label /}
{param elementClasses: 'component-action quick-action-item' /}
{param href: $actionItem.href /}
{param icon: $actionItem.icon /}
{param spritemap: $spritemap /}
{param title: $actionItem.lable /}
{/call}
{/if}
{/foreach}
</div>

{call ClayActionsDropdown.render}
{param items: $item.actionItems /}
{param spritemap: $spritemap /}
{param triggerClasses: 'component-action' /}
{/call}
</td>
{delcall ClayTable.ActionsMenu variant="$actionsMenuVariant"}
{param actionItems: $item.actionItems /}
{param spritemap: $spritemap /}
{/delcall}
{/if}
</tr>
{/template}
Expand Down Expand Up @@ -348,6 +335,7 @@
]}
{@param? _handleCellContentClick: any}
{@param? _handleItemToggled: any}
{@param? actionsMenuVariant: string}
{@param? groupName: string}
{@param? selectable: bool}
{@param? showActionsMenu: bool}
Expand Down Expand Up @@ -379,6 +367,7 @@
{call .rows}
{param _handleCellContentClick: $_handleCellContentClick /}
{param _handleItemToggled: $_handleItemToggled /}
{param actionsMenuVariant: $actionsMenuVariant /}
{param groupName: $currentgroupName /}
{param items: $item.items /}
{param schema: $schema /}
Expand All @@ -390,6 +379,7 @@
{call .row}
{param _handleCellContentClick: $_handleCellContentClick /}
{param _handleItemToggled: $_handleItemToggled /}
{param actionsMenuVariant: $actionsMenuVariant /}
{param groupName: $groupName /}
{param item: $item /}
{param schema: $schema /}
Expand All @@ -401,6 +391,37 @@
{/foreach}
{/template}

/**
* This renders the default variant of the actions menu
*/
{deltemplate ClayTable.ActionsMenu}
{@param actionItems: list<?>}
{@param spritemap: string}

<td>
<div class="quick-action-menu">
{foreach $actionItem in $actionItems}
{if $actionItem.quickAction and $actionItem.icon}
{call ClayLink.render}
{param ariaLabel: $actionItem.label /}
{param elementClasses: 'component-action quick-action-item' /}
{param href: $actionItem.href /}
{param icon: $actionItem.icon /}
{param spritemap: $spritemap /}
{param title: $actionItem.lable /}
{/call}
{/if}
{/foreach}
</div>

{call ClayActionsDropdown.render}
{param items: $actionItems /}
{param spritemap: $spritemap /}
{param triggerClasses: 'component-action' /}
{/call}
</td>
{/deltemplate}

/**
* This renders the default variant of a cell
*/
Expand Down