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

Dialog for hidden filters [issue-78] #90

Closed
wants to merge 49 commits into from

Conversation

JaySunSyn
Copy link
Contributor

@JaySunSyn JaySunSyn commented Nov 17, 2017

See #78

Please merge #117 first

@@ -52,7 +54,15 @@
<paper-checkbox checked$="{{ _allSelected }}" on-change="_onAllCheckboxChange" hidden$="[[ !_dataIsValid ]]">
</paper-checkbox>
</div>
<cosmoz-omnitable-header-row columns="[[ visibleColumns ]]" group-on-column="[[ groupOnColumn ]]"></cosmoz-omnitable-header-row>
<cosmoz-omnitable-header-row columns="[[ visibleColumns ]]" group-on-column="[[ groupOnColumn ]]">
<div slot="suffix" class="align-right" hidden$="[[allVisible]]">
Copy link
Contributor

Choose a reason for hiding this comment

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

This breaks _adjustHeadersWidth.
In _adjustHeadersWidth, we reference individual header cell by their index in header row children (see https://github.com/Neovici/cosmoz-omnitable/blob/master/cosmoz-omnitable.js#L786)
But now, the suffix div is the first children in header row, so we don't size the right element anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, pls let me know if the changes work for you.

is: 'cosmoz-omnitable-filter-dialog',

behaviors: [
Polymer.PaperDialogBehavior,
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't use paper-dialog, because it has stacking context issues (the dialog can appear below another element).
cosmoz-dialog solves stacking context issues, but works differently.
Instead, you should use

<cosmoz-dialog>
   <template>
      dialog content
   <template>

Regarding the dialog content, you should investigate using cosmoz-omnitable-repeater-behavior, as this behavior already handles columns changes and instances creation/release.
See for example https://github.com/Neovici/cosmoz-omnitable/blob/master/cosmoz-omnitable-header-row.html

@@ -195,7 +205,13 @@ <h3 class="groupRow-label">
<div id="columns">
<slot></slot>
</div>


<cosmoz-omnitable-filter-dialog
Copy link
Contributor

Choose a reason for hiding this comment

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

So this should rather looks like (relating to other comments):

<cosmoz-dialog with-backdrop>
   <template>
       <cosmoz-omnitable-filters-dialog columns="[[disabledColumns]]">
   <template>

Copy link
Contributor

@plequang plequang left a comment

Choose a reason for hiding this comment

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

See code comments

@@ -297,6 +304,14 @@
return dataIsValid && hasActions;
},

_computeColumnsAllVisible(visibleColumnsChange, columns) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not work for the groupOn column.
When grouping on a column, it is not removed from the visibleColumn property, but the cells for the groupOn colunm are hidden.
The _computeColumnsAllVisible function could also observe changes to the groupOnColumn property, and If this is not null, then it should return false

@@ -196,6 +206,16 @@ <h3 class="groupRow-label">
<slot></slot>
</div>

<cosmoz-dialog with-backdrop id="filterDialog">
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the dialog needs at least a "Close" button.
It's not always clear to the user that clicking somewhere outside the dialog will close it.

return;
}

headers.innerHTML = '';
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not the right way to clear the content of the dialog.
cosmoz-omnitable-templatizer keeps a reference to the instances it creates, so when an instance is not used anymore it needs to be "released", otherwise it will stay in memory.
This is also not very efficient, as we recreate new instances for all headers in the dialog when disabledColumns is changing.

You should really try to use cosmoz-omnitable-repeater-behavior, as it takes care of correctly releasing unused instances as well as creating only instances when needed.
cosmoz-omnitable-headers-dialog could be implemented the same way as cosmoz-omnitable-header-row.

@JaySunSyn
Copy link
Contributor Author

Please check again.

*/
allColumnsVisible: {
type: Boolean,
computed: '_computeColumnsAllVisible(visibleColumns.*, groupOnColumn.*, columns)'
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't work correctly when groupOnColumn is undefined because complex observers are called only when all properties are defined.
So when groupOn is not defined, groupOnColumn is undefined and the computed function is not called.

Currently, the open filters dialog icon is always visible.

}
},

observers: [
'_dataChanged(data.*)',
'_debounceSortItems(sortOn, descending, filteredGroupedItems)',
'_routeHashParamsChanged(_routeHashParams.*, hashParam, columns)',
' _selectedItemsChanged(selectedItems.*)'
'_selectedItemsChanged(selectedItems.*)',
'_setFilterDialogColumns(disabledColumns.*, groupOnColumn.*)'
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as for _computeColumnsAllVisible.
_setFilterDialogColumns will never be called as long as there is no group on column

}
</style>

<paper-icon-button class="close-btn" icon="close" on-tap="_close"></paper-icon-button>
Copy link
Contributor

Choose a reason for hiding this comment

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

It does not feel natural to have to click top right.
I think a button inside the dialog, bottom right, would be better. Like in paper-dialog demos.
Not sure about the label though.
Let's use "Close" for now.
So the close button should move the cosmoz-dialog template in omnitable.html, a <div class="buttons> to use paper-dialog default styling.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, took the facebook approach here.. But I thinks you are right..

-->
<dom-module id="cosmoz-omnitable-headers-dialog">
<template>
<style>
Copy link
Contributor

Choose a reason for hiding this comment

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

Styling of the dialog looks strange.
host might require a display block.
container should use a vertical flexbox.

<paper-icon-button class="close-btn" icon="close" on-tap="_close"></paper-icon-button>

<div class="container">
<div class="title">[[title]]</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the title from here, and use <h2>...</h2> in the dialog template in omnitable.html
That way, it will use paper-dialog default styling.

@@ -196,6 +208,17 @@ <h3 class="groupRow-label">
<slot></slot>
</div>

<cosmoz-dialog with-backdrop id="filterDialog">
<template>
Copy link
Contributor

Choose a reason for hiding this comment

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

<h2>[[_('Filter', t)]]</h2>

columns="[[_filterDialogColumns]]"
on-close-tapped="_closeFilterDialog"
with-backdrop>
</cosmoz-omnitable-headers-dialog>
Copy link
Contributor

Choose a reason for hiding this comment

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

<div class="buttons>
<paper-button>[[_("Close")]]</paper-button>
</div>

Copy link
Contributor

@plequang plequang left a comment

Choose a reason for hiding this comment

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

  1. _close() function in headers-dialog not needed anymore ?
  2. Thanks to this PR, we don't have to reset filters when groupon column changes (this was some sort of hack). See https://github.com/Neovici/cosmoz-omnitable/blob/master/cosmoz-omnitable.js#L536-L538

Code looks good, and the dialog works as expected.

Some UI/UX issues have to be fixed, though I'm not sure how:

  1. If the dialog contains only an autocomplete header, interaction with the dropdown is not possible (try grouping on "Group" column).
  2. The "filter' icon to open the dialog is overlaying the last header (not always. Try to group on Amount in the demo).

this._forwardPropertiesFlush(instance);
},

_close() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the close button is now in omnitable.html, is this function still needed ?

@plequang
Copy link
Contributor

plequang commented Dec 3, 2017

Some screenshot to illustrate the UI/UX issues:

Single filter with paper-autocomplete-chips:

image

Icon overlaying header:

image

Even more overlaying icon, when there is no scrollbar in the omnitable

image

@JaySunSyn
Copy link
Contributor Author

The not-overlapping suggestions of autocomplete-chips is fixed with this PR Neovici/paper-autocomplete-chips#6

@JaySunSyn
Copy link
Contributor Author

JaySunSyn commented Dec 19, 2017

Hmm :( sorry for that - I cannot reproduce.. May you check again if you have integrated the PR Neovici/paper-autocomplete-chips#6 and pull also this PR again please. Thanks

@plequang
Copy link
Contributor

OK my bad. I was using bower link paper-autocomplete-chips, which links to bower_components directory, and not the bower_components-1.x directory.

@plequang
Copy link
Contributor

Found an issue. To reproduce, follow these steps in the full demo:

  1. Reduce the width of the screen to let the filter icon appear
  2. open the filter dialog, the close it
  3. reduce more the width, so that new filters are added to the dialog.
  4. open the dialog

=> the paper-autocomplete will have a width of 0
When the dialog is opened for the first time, _onNodesChange is called while the dialog is visible, so offsetWidth returns something different than 0
When you reduce the width at step 3, the dialog is not visible, so in _onNodesChange, offsetWidth will return 0.

@plequang
Copy link
Contributor

Found another issue, not related to paper-autocomplete:

  1. reduce the width of the screen to let the filter icon appear
  2. open the filter dialog
  3. maximize the window

=> the dialog is displayed without any filter

},

_onResize() {
this.scopeSubtree(this.$.container);
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the purpose of this ?

Actually, this seems to break styling of the suggestion wrapper, which does not overlap anymore (but it works if I remove the scopeSubtree call)

Copy link
Contributor Author

@JaySunSyn JaySunSyn Dec 23, 2017

Choose a reason for hiding this comment

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

Hmm :/ yes, I see this too now..
It's to apply the styles of .header-clear-filter to some intputs

Without:
image

But it seems that we should not use scopeSubtree for polymer elements. Only for external libs..

Looking into it. Trying to find a way without putting the style into the template

@JaySunSyn
Copy link
Contributor Author

Added a clear button in PR #117 to apply styles correctly.

plequang pushed a commit that referenced this pull request Jan 10, 2018
* Added clear button element
* Use clear button instead of iron-icon
Currently needed to display the clear button in the filters-dialog (PR #90) without having to include the styles into the template.
Copy link
Contributor

@plequang plequang left a comment

Choose a reason for hiding this comment

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

Found another issue, with autocomplete columns.
To reproduce in full-demo.html, update x-page to set priority="-1" to the group column.
Then reduce the window width so that the group column is hidden. Open the filter dialog, and click in the group filter. The dropdown should open with possible group values.
Close the filter dialog.
Increase window size so that the group column is visible again.
Click in the Group filter => the available values dropdown does not show.

Solved issue, with autocomplete columns.
To reproduce in full-demo.html, update x-page to set priority="-1" to the group column.
Then reduce the window width so that the group column is hidden. Open the filter dialog, and click in the group filter. The dropdown should open with possible group values.
Close the filter dialog.
Increase window size so that the group column is visible again.
Click in the Group filter => the available values dropdown does not show.
@JaySunSyn
Copy link
Contributor Author

Please merge #135 first so building succeeds again.

Copy link
Contributor

@plequang plequang left a comment

Choose a reason for hiding this comment

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

Found another issue.

To reproduce in full-demo, group the table on the last column (Amount). The dialog filter icon does not appear, because we don't want to filter on the group on column.
Then reduce the window width to make the icon appear.
Open the dialog => Amount filter is visible, but it shouldn't.

Copy link
Contributor

@plequang plequang left a comment

Choose a reason for hiding this comment

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

Found an issue when using cosmoz-omnitable-treenode-column : for this column type, the header is using paper-autocomplete, and the dropdown causing the dialog to scroll.
Actually, same issue as before with paper-autocomplete.
You can try it in treenode column repository, and using bower link cosmoz-omnitable.
Don't know if this can be solved in omnitable or in treenode-column.

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

Successfully merging this pull request may close these issues.

4 participants