This repository was archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheditable-table-filter.html
More file actions
119 lines (109 loc) · 3.07 KB
/
editable-table-filter.html
File metadata and controls
119 lines (109 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-tooltip/paper-tooltip.html">
<link rel="import" href="../iron-icons/iron-icons.html">
<link rel="import" href="editable-table-iconset.html">
<!--
`editable-table-filter`
Displays a cell in the editable-table-display mode
(editable-table-display.html) as a filter button.
@demo demo/index.html
@microcopy - the mental model for this element
<editable-table-filter
column-number="1" //The index of the cell's column
text=""> //The text of the cell, which will become the filter value when button is toggled.
</editable-table-filter>
-->
<dom-module id="editable-table-filter">
<template>
<style is="custom-style">
:host paper-button {
padding: 0;
margin: 0;
width: 100%;
min-width: unset;
display: inline-flex;
justify-content: space-between;
align-items:center;
align-content: stretch;
text-transform: unset;
}
:host paper-button > div {
flex-grow: 1;
}
:host .sr-only {
position: absolute;
left: -9999px;
font-size: 0;
height: 0;
width: 0;
overflow: hidden;
}
:host #filter-off {
opacity: 0.25;
}
:host:not([filtered]) .filtered,
:host:not([filtered]):not(:focus):not(:hover) #filter,
:host:not([filtered]):focus #filter-off,
:host:not([filtered]):hover #filter-off,
:host[filtered]:not(:focus):not(:hover) #filter-off,
:host[filtered]:focus #filter,
:host[filtered]:hover #filter {
display: none;
}
</style>
<paper-button id="button" class="container">
<span>[[text]]</span>
<span class="sr-only" hidden$="[[!filtered]]"> (filtered)</span>
<span class="sr-only"> Toggle filter.</span>
<iron-icon id="filter" icon="editable-table:filter"></iron-icon>
<iron-icon id="filter-off" icon="editable-table:filter-off"></iron-icon>
</paper-button>
<paper-tooltip for="button">Toggle filter for "[[text]]"</paper-tooltip>
</template>
<script>
Polymer({
is: 'editable-table-filter',
listeners: {
"tap": "_onFilterTapped"
},
properties: {
/**
* the column for the filter
*/
columnNumber: {
type: Number,
value: null
},
/**
* is the data filtered
*/
filtered: {
type: Boolean,
value: false,
reflectToAttribute: true
},
/**
* the column header text
*/
text: {
type: String,
value: ""
},
},
/**
* listen for button tap
*/
_getPressed: function(filtered){
return filtered ? 'true' : 'false';
},
/**
* listen for button tap
*/
_onFilterTapped: function(){
let root = this;
root.fire('toggle-filter',root);
}
});
</script>
</dom-module>