forked from Neovici/cosmoz-omnitable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcosmoz-omnitable-column-date.html
94 lines (85 loc) · 2.7 KB
/
cosmoz-omnitable-column-date.html
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
<link rel="import" href="cosmoz-omnitable-column-behavior.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../cosmoz-i18next/cosmoz-i18next.html">
<link rel="import" href="ui-helpers/cosmoz-clear-button.html">
<link rel="import" href="cosmoz-omnitable-column-date-behavior.html">
<dom-module id="cosmoz-omnitable-column-date">
<template>
<template class="cell">
[[ getString(item, valuePath, formatter) ]]
</template>
<template class="edit-cell">
<paper-input no-label-float type="date" on-change="_dateValueChanged"
value="[[ getInputString(item, valuePath) ]]">
</paper-input>
</template>
<template class="header">
<cosmoz-clear-button on-click="resetFilter" visible="[[ hasFilter(filter.*) ]]"></cosmoz-clear-button>
<paper-dropdown-menu label="[[ title ]]" placeholder="[[ _filterText ]]" title="[[ _tooltip ]]"
horizontal-align="[[ preferredDropdownHorizontalAlign ]]" opened="{{ headerFocused }}">
<div class="dropdown-content" slot="dropdown-content" style="padding: 15px; min-width: 100px;">
<h3 style="margin: 0;">[[ title ]]</h3>
<paper-input type="date" label="[[ _('From date', t) ]]"
min="[[ _toInputString(_limit.fromMin) ]]" max="[[ _toInputString(_limit.fromMax) ]]"
value="{{ _filterInput.min }}">
</paper-input>
<paper-input type="date" label="[[ _('Until date', t) ]]"
min="[[ _toInputString(_limit.toMin) ]]" max="[[ _toInputString(_limit.toMax) ]]"
value="{{ _filterInput.max }}">
</paper-input>
</div>
</paper-dropdown-menu>
</template>
</template>
<script>
/*global Cosmoz */
Polymer({
is: 'cosmoz-omnitable-column-date',
properties: {
headerCellClass: {
type: String,
value: 'date-header-cell'
},
minWidth: {
type: String,
value: '82px'
},
editMinWidth: {
type: String,
value: '82px'
}
},
behaviors: [
Cosmoz.OmnitableColumnBehavior,
Cosmoz.TranslatableBehavior,
Cosmoz.DateColumnBehavior
],
_fromInputString(value, property) {
const date = this.toDate(value);
if (date == null) {
return;
}
if (property === 'min') {
date.setHours(0, 0, 0, 0);
}
if (property === 'max') {
date.setHours(23, 59, 59);
}
return date;
},
toXlsxValue: function (item, valuePath = this.valuePath) {
if (!valuePath) {
return '';
}
const date = this.toValue(this.get(valuePath, item));
if (!date) {
return '';
}
const localDate = this.toValue(this._toLocalISOString(date));
localDate.setHours(0, 0, 0, 0);
return localDate;
}
});
</script>
</dom-module>