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
Closed
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
7870516
proof of concept
JaySunSyn Nov 17, 2017
dd4974b
Implemented with paper-dialog-behavior
JaySunSyn Nov 17, 2017
f6e3b4f
Reverted changes column-amount
JaySunSyn Nov 17, 2017
36f3e4f
Integrated with cosmoz-dialog
JaySunSyn Nov 21, 2017
0a48825
Fixed _adjustHeadersWidth
JaySunSyn Nov 21, 2017
3a743ab
Cleanup & docs
JaySunSyn Nov 21, 2017
c075188
new line fix
JaySunSyn Nov 21, 2017
f1aedc3
small _adjustHeadersWidth enhancment
JaySunSyn Nov 21, 2017
5d268db
Added close button
JaySunSyn Nov 28, 2017
6196ebc
remove children
JaySunSyn Nov 28, 2017
8c099a7
Replaced with OmnitableRepeaterBehavior
JaySunSyn Nov 28, 2017
c76ee43
Removed suffix slot of header-row
JaySunSyn Nov 29, 2017
90f3fe2
Sorted header columns
JaySunSyn Nov 29, 2017
d6c3018
fixed codeclimate issue
JaySunSyn Nov 29, 2017
02018f4
fixed hide if all colums are visible
JaySunSyn Nov 29, 2017
fc7fda6
PR comments
JaySunSyn Nov 30, 2017
98680ed
minor fix
JaySunSyn Nov 30, 2017
3a0810b
Merge branch 'master' into issue-78
JaySunSyn Nov 30, 2017
a7c9fd9
whitespace fix
JaySunSyn Nov 30, 2017
7c26f3e
Minor style improvments
JaySunSyn Nov 30, 2017
4d8e263
Fixed filter btn position
JaySunSyn Dec 8, 2017
ea93d18
PR comment
JaySunSyn Dec 8, 2017
27cb2d4
PR comment
JaySunSyn Dec 8, 2017
cb00b5b
Fixed bower issue
JaySunSyn Dec 8, 2017
2a72752
Revert filtering on the group on column
JaySunSyn Dec 14, 2017
486fe1d
Merge remote-tracking branch 'upstream/master' into issue-78
JaySunSyn Dec 14, 2017
11738d8
Style autocompletes
JaySunSyn Dec 18, 2017
e25f6f0
removed column sorting
JaySunSyn Dec 18, 2017
c4743b3
added min-width for autocomplete
JaySunSyn Dec 19, 2017
0e110b0
PR comment updateStyles()
JaySunSyn Dec 19, 2017
cfa3852
whitespace fix
JaySunSyn Dec 19, 2017
f9d26ce
Merge remote-tracking branch 'upstream/master' into issue-78
JaySunSyn Dec 19, 2017
0ddec4a
Set width of paper-autocomplete-suggestions _onResize instead _onNode…
JaySunSyn Dec 20, 2017
bf02f2d
close filterdialog if no _filterDialogColumns
JaySunSyn Dec 20, 2017
59d92d3
scopeSubtree to apply existing header styles
JaySunSyn Dec 20, 2017
1267167
added debouncer
JaySunSyn Dec 29, 2017
58a450b
minor style update
JaySunSyn Jan 10, 2018
707fa8c
PR comment
JaySunSyn Jan 11, 2018
49d6f6f
Merge remote-tracking branch 'upstream/master' into issue-78
JaySunSyn Jan 11, 2018
369e202
Merge remote-tracking branch 'upstream/master' into issue-78
JaySunSyn Jan 12, 2018
e2a8e7c
Merge branch 'master' into issue-78
nomego Jan 12, 2018
6dc1d6f
Merge branch 'issue-78' of https://github.com/JaySunSyn/cosmoz-omnita…
JaySunSyn Jan 16, 2018
5406848
Merge remote-tracking branch 'upstream/master' into issue-78
JaySunSyn Jan 16, 2018
4b827f2
fixed filterDialogColumns
JaySunSyn Jan 16, 2018
a3485ff
Merge remote-tracking branch 'upstream/master' into issue-78
JaySunSyn Jan 16, 2018
9cd4c92
Merge remote-tracking branch 'upstream/master' into issue-78
JaySunSyn Jan 17, 2018
17adf74
fixed tests
JaySunSyn Jan 17, 2018
8d6c20f
Handle paper-autocomplete headers
JaySunSyn Jan 19, 2018
e1d5bfa
Ensure wrapper sizing after resize
JaySunSyn Jan 19, 2018
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
7 changes: 5 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@
"cosmoz-bottom-bar": "neovici/cosmoz-bottom-bar#master",
"cosmoz-behaviors": "neovici/cosmoz-behaviors#master",
"cosmoz-page-router": "Neovici/cosmoz-page-router#master",
"cosmoz-dialog": "Neovici/cosmoz-dialog#master",
"paper-autocomplete-chips": "Neovici/paper-autocomplete-chips#master",
"import-filesaver": "JaySunSyn/import-filesaver",
"datetime-local": "JaySunSyn/datetime-local#polymer-1",
"nullxlsx": "Neovici/nullxlsx#master"
"nullxlsx": "Neovici/nullxlsx#master",
"paper-dialog-scrollable": "^2.1.0"
},
"devDependencies": {
"paper-button": "PolymerElements/paper-button#1 - 2",
Expand Down Expand Up @@ -81,7 +83,8 @@
"paper-autocomplete-chips": "Neovici/paper-autocomplete-chips#master",
"import-filesaver": "JaySunSyn/import-filesaver",
"datetime-local": "JaySunSyn/datetime-local#polymer-1",
"nullxlsx": "Neovici/nullxlsx#master"
"nullxlsx": "Neovici/nullxlsx#master",
"paper-dialog-scrollable": "^2.1.0"
},
"devDependencies": {
"paper-button": "PolymerElements/paper-button#^2.0.0",
Expand Down
90 changes: 90 additions & 0 deletions cosmoz-omnitable-headers-dialog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<link rel="import" href="../polymer/polymer.html">

<link rel="import" href="../iron-flex-layout/iron-flex-layout-classes.html"/>
<link rel="import" href="../iron-resizable-behavior/iron-resizable-behavior.html">

<link rel="import" href="cosmoz-omnitable-repeater-behavior.html">
<!--
`cosmoz-omnitable-headers-dialog` is an element for displaying omnitable column headers in a separate dialog.

<cosmoz-dialog>
<template>
<cosmoz-omnitable-headers-dialog
columns="[[disabledColumns]]">
</cosmoz-omnitable-headers-dialog>
</template>
</cosmoz-dialog>

In the above example, the `<cosmoz-omnitable-headers-dialog>` element is wrapped
with a `cosmoz-dialog` element which enables it to be displayed as a dialog.

@group Cosmoz Elements
@element cosmoz-omnitable-headers-dialog
@demo demo/index.html
-->
<dom-module id="cosmoz-omnitable-headers-dialog">
<template>
<style include="cosmoz-omnitable-styles iron-flex">
:host {
display: block;
}
#container {
padding: 12px;
max-height: calc(100vh - 200px);
}
</style>

<div id="container" class="layout vertical">
<slot name="header-cell"></slot>
</div>
</template>
<script>
(() => {
'use strict';
Polymer({
is: 'cosmoz-omnitable-headers-dialog',

behaviors: [
Cosmoz.OmnitableRepeaterBehavior,
Polymer.IronResizableBehavior
],

_elementType: 'div',

_slotName: 'header-cell',

listeners: {
'iron-resize': '_onResize'
},

_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


const accs = Polymer.dom(this).querySelectorAll('paper-autocomplete-chips');

setTimeout(() => {
accs.forEach(acc => {
acc.updateStyles({
'--paper-autocomplete-chips-suggestions-position': 'fixed',
'--paper-autocomplete-chips-suggestions-width': `${acc.offsetWidth}px`,
'--paper-autocomplete-chips-suggestions-min-width': '0'
});
});
});
},

_getTemplateInstance(column) {
return column.headerTemplatizer.getInstance();
},

_detachTemplateInstance(instance, column, element) {
column.headerTemplatizer.detachInstance(instance, element);
},

_configureTemplateInstance(instance) {
this._forwardPropertiesFlush(instance);
}
});
})();
</script>
</dom-module>
7 changes: 7 additions & 0 deletions cosmoz-omnitable-styles.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
@apply --layout-relative;
@apply --layout-horizontal;
@apply --layout-end;
width: 100%;
}

.header > cosmoz-omnitable-header-row {
Expand Down Expand Up @@ -279,6 +280,12 @@
text-align: right;
}

.filter-btn-wrapper {
position: absolute;
right: 0;
margin-right: 8px;
}

cosmoz-bottom-bar {
background-color: var(--cosmoz-omnitable-bottom-bar-color, #5f5a92);
color: white;
Expand Down
41 changes: 34 additions & 7 deletions cosmoz-omnitable.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<link rel="import" href="../iron-flex-layout/iron-flex-layout.html"/>
<link rel="import" href="../iron-flex-layout/iron-flex-layout-classes.html"/>
<link rel="import" href="../iron-resizable-behavior/iron-resizable-behavior.html">
<link rel="import" href="../iron-icons/iron-icons.html"/>
<link rel="import" href="../iron-icon/iron-icon.html"/>
<link rel="import" href="../iron-label/iron-label.html"/>
Expand All @@ -13,11 +14,13 @@
<link rel="import" href="../paper-item/paper-item.html"/>
<link rel="import" href="../paper-listbox/paper-listbox.html"/>
<link rel="import" href="../paper-spinner/paper-spinner-lite.html">
<link rel="import" href="../paper-dialog-scrollable/paper-dialog-scrollable.html">

<link rel="import" href="../cosmoz-grouped-list/cosmoz-grouped-list.html"/>
<link rel="import" href="../cosmoz-i18next/cosmoz-i18next.html">
<link rel="import" href="../cosmoz-bottom-bar/cosmoz-bottom-bar.html"/>
<link rel="import" href="../cosmoz-page-router/cosmoz-page-location.html">
<link rel="import" href="../cosmoz-dialog/cosmoz-dialog.html">

<link rel="import" href="../import-filesaver/import-filesaver.html"/>
<link rel="import" href="../nullxlsx/dist/import-nullxlsx.html"/>
Expand All @@ -31,8 +34,7 @@
<link rel="import" href="cosmoz-omnitable-styles.html">
<link rel="import" href="cosmoz-omnitable-item.html">
<link rel="import" href="cosmoz-omnitable-columns.html">


<link rel="import" href="cosmoz-omnitable-headers-dialog.html">
<!--
`<cosmoz-omnitable>`

Expand All @@ -47,12 +49,22 @@
<cosmoz-page-location id="location" route-hash="{{ _routeHash }}"></cosmoz-page-location>

<div class="mainContainer">
<div class="header" id="header">
<div class="selectAllCheckbox" hidden$="[[ !_showCheckboxes ]]">
<paper-checkbox checked$="{{ _allSelected }}" on-change="_onAllCheckboxChange" hidden$="[[ !_dataIsValid ]]">
</paper-checkbox>
<div class="layout horizontal center">
<div class="header" id="header">
<div class="selectAllCheckbox" hidden$="[[ !_showCheckboxes ]]">
<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>
<div class="filter-btn-wrapper">
<paper-icon-button
hidden$="[[allColumnsVisible]]"
icon="icons:filter-list"
on-click="_openFilterDialog">
</paper-icon-button>
</div>
</div>
<cosmoz-omnitable-header-row columns="[[ visibleColumns ]]" group-on-column="[[ groupOnColumn ]]"></cosmoz-omnitable-header-row>
</div>
<div class="tableContent" id="tableContent">
<template is="dom-if" if="[[ !_dataIsValid ]]">
Expand Down Expand Up @@ -196,6 +208,21 @@ <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.

<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>

<h2>[[_('Filter', t)]]</h2>
<paper-dialog-scrollable>
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want to use paper-dialog-scrollable, you have to let it manage scroll, meaning cosmoz-omnitable-headers-dialog should overflow.

<cosmoz-omnitable-headers-dialog
columns="[[_filterDialogColumns]]"
with-backdrop>
</cosmoz-omnitable-headers-dialog>
</paper-dialog-scrollable>
<div class="buttons">
<paper-button dialog-dismiss>[[_("Close")]]</paper-button>
</div>
</template>
</cosmoz-dialog>

</template>
<script type="text/javascript" src="cosmoz-omnitable.js"></script>
</dom-module>
43 changes: 42 additions & 1 deletion cosmoz-omnitable.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,26 @@
*/
_allSelected: {
type: Boolean
},

_filterDialogColumns: {
type: Array,
notify: true
},
/**
* True if all columns are visible.
*/
allColumnsVisible: {
type: Boolean,
computed: '_computeColumnsAllVisible(visibleColumns.*, columns)'
}
},

observers: [
'_dataChanged(data.*)',
'_debounceSortItems(sortOn, descending, filteredGroupedItems)',
' _selectedItemsChanged(selectedItems.*)'
'_selectedItemsChanged(selectedItems.*)',
'_setFilterDialogColumns(disabledColumns.*)'
],

behaviors: [
Expand Down Expand Up @@ -290,6 +303,21 @@
_disabledColumnsIndexes: null,

_scalingUp: false,

_setFilterDialogColumns(disabledColumnsChange) {
const disabledColumns = disabledColumnsChange.base;

// Otherwise change doesn't notify `cosmoz-omnitable-repeater-behavior`
// Todo: figure out a nicer way.
this._filterDialogColumns = [];

this.set('_filterDialogColumns', disabledColumns);

if (!disabledColumns || disabledColumns.length < 1) {
this.$.filterDialog.close();
}
},

_computeDataValidity(data) {
return data && Array.isArray(data) && data.length > 0;
},
Expand All @@ -307,6 +335,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

const visibleColumns = visibleColumnsChange.base;
if (!visibleColumns || !columns) {
return;
}
return visibleColumns.length === columns.length;
},

_visibleColumnsChanged() {
this.disabledColumns = [];
this._disabledColumnsIndexes = [];
Expand Down Expand Up @@ -545,6 +581,7 @@
} else {
this.debounce('groupItems', this._groupItems);
}
this.debounce('groupItems', this._groupItems);
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 is not necessary (resetFilter should in the end trigger a call to groupItems)

},

_debounceGroupItems: function () {
Expand Down Expand Up @@ -1207,6 +1244,10 @@
}

this.set(path, serialized === undefined ? null : serialized);
},

_openFilterDialog() {
this.$$('#filterDialog').open();
}
});
}());