-
Notifications
You must be signed in to change notification settings - Fork 5
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
Changes from 35 commits
7870516
dd4974b
f6e3b4f
36f3e4f
0a48825
3a743ab
c075188
f1aedc3
5d268db
6196ebc
8c099a7
c76ee43
90f3fe2
d6c3018
02018f4
fc7fda6
98680ed
3a0810b
a7c9fd9
7c26f3e
4d8e263
ea93d18
27cb2d4
cb00b5b
2a72752
486fe1d
11738d8
e25f6f0
c4743b3
0e110b0
cfa3852
f9d26ce
0ddec4a
bf02f2d
59d92d3
1267167
58a450b
707fa8c
49d6f6f
369e202
e2a8e7c
6dc1d6f
5406848
4b827f2
a3485ff
9cd4c92
17adf74
8d6c20f
e1d5bfa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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); | ||
|
||
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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"/> | ||
|
@@ -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"/> | ||
|
@@ -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>` | ||
|
||
|
@@ -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 ]]"> | ||
|
@@ -196,6 +208,21 @@ <h3 class="groupRow-label"> | |
<slot></slot> | ||
</div> | ||
|
||
<cosmoz-dialog with-backdrop id="filterDialog"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the dialog needs at least a "Close" button. |
||
<template> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
<h2>[[_('Filter', t)]]</h2> | ||
<paper-dialog-scrollable> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to use |
||
<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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: [ | ||
|
@@ -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; | ||
}, | ||
|
@@ -307,6 +335,14 @@ | |
return dataIsValid && hasActions; | ||
}, | ||
|
||
_computeColumnsAllVisible(visibleColumnsChange, columns) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not work for the groupOn column. |
||
const visibleColumns = visibleColumnsChange.base; | ||
if (!visibleColumns || !columns) { | ||
return; | ||
} | ||
return visibleColumns.length === columns.length; | ||
}, | ||
|
||
_visibleColumnsChanged() { | ||
this.disabledColumns = []; | ||
this._disabledColumnsIndexes = []; | ||
|
@@ -545,6 +581,7 @@ | |
} else { | ||
this.debounce('groupItems', this._groupItems); | ||
} | ||
this.debounce('groupItems', this._groupItems); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is is not necessary ( |
||
}, | ||
|
||
_debounceGroupItems: function () { | ||
|
@@ -1207,6 +1244,10 @@ | |
} | ||
|
||
this.set(path, serialized === undefined ? null : serialized); | ||
}, | ||
|
||
_openFilterDialog() { | ||
this.$$('#filterDialog').open(); | ||
} | ||
}); | ||
}()); |
There was a problem hiding this comment.
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)There was a problem hiding this comment.
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 intputsWithout:
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