-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFilters.js
153 lines (140 loc) · 5.41 KB
/
Filters.js
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import React from 'react';
import pluralize from 'pluralize';
import { connect } from 'react-redux';
import { Control, Form, actions } from 'react-redux-form';
import { getCruLabel, getNatureLabel, getDeadlineStatusLabel } from '../../Global/MhpDrupal';
import Checkboxes from '../../Global/Forms/CheckboxesFilter';
import DatePicker from 'react-datepicker';
/**
* DatePicker widget.
*/
export class DatePickerWidget extends React.Component {
render() {
return <div>
<div className="date">
<input className="datepicker" type="text" value={this.props.value} onClick={this.props.onClick}/>
<span className="ico edit-date" onClick={this.props.onClick}>
<svg className="svg-ico">
<use xmlnsXlink="http://www.w3.org/1999/xlink" xlinkHref="#ico-edit" />
</svg>
</span>
</div>
</div>
}
}
@connect(store => ({ filters: store.Deadlines.filters, count: store.Deadlines.count, form: store.DeadlineForms.filters }))
export default class Filters extends React.Component {
/**
* Change date handler
*
* @param date
*/
dateHandleChange = (date) => {
this.props.dispatch(actions.change('DeadlineForms.filters.created', date && date.isValid() ? date : null));
};
/**
* {@inheritDoc}
*/
render() {
const { count, submitFilters, form, filters } = this.props;
const deadlineCount = pluralize('demande', count, true);
return (
<div className="filters-block">
<Form model="DeadlineForms.filters" onSubmit={ submitFilters }>
<div className="row">
<strong className="ttl">Date</strong>
<ul>
<li>
<DatePicker
selected={form.created}
onChange={this.dateHandleChange}
customInput={<DatePickerWidget />}
isClearable={true}
locale="fr"
/>
</li>
</ul>
</div>
<Checkboxes
itemsLabel={ getNatureLabel }
items={ filters.field_mhp_deadline_contract }
model=".field_mhp_deadline_contract"
name="field_mhp_deadline_contract"
label="Type de contrat"
/>
<Checkboxes
itemsLabel={ getCruLabel }
items={ filters.field_mhp_deadline_cru }
model=".field_mhp_deadline_cru"
name="field_mhp_deadline_cru"
label="Cru"
/>
<div className="row">
<strong className="ttl">
Année de Récolte
<div className="info">
<span className="ico"><svg className="svg-ico"><use xmlnsXlink="http://www.w3.org/1999/xlink" xlinkHref="#ico-info" /></svg></span>
<div className="drop">
<p>Merci de sélectioner une deuxième année supérieure ou égale à la première</p>
</div>
</div>
</strong>
<ul>
<li>
<label className="hidden">harvest year</label>
<Control.select className="custom-select" model=".field_mhp_deadline_harvest:from" updateOn="change">
<option value="null" />
{filters.field_mhp_deadline_harvest && filters.field_mhp_deadline_harvest.map((item, key) => {
return <option key={key} value={item}>{item}</option>
})}
</Control.select>
</li>
<li>
<label className="hidden">harvest year</label>
<Control.select className="custom-select" model=".field_mhp_deadline_harvest:to" updateOn="change">
<option value="null" />
{filters.field_mhp_deadline_harvest && filters.field_mhp_deadline_harvest.map((item, key) => {
return <option key={key} value={item}>{item}</option>
})}
</Control.select>
</li>
</ul>
</div>
<div className="row">
<strong className="ttl">Numéro</strong>
<ul>
<li>
<label className="hidden">Contract number</label>
<Control.text model=".field_mhp_deadline_contract_num" updateOn="change" placeholder="Contract number"/>
</li>
</ul>
</div>
<div className="row">
<strong className="ttl">Raison Sociale</strong>
<ul>
<li>
<label className="hidden">Raison Sociale</label>
<Control.text model=".field_mhp_deadline_corp_name" updateOn="change" placeholder="Raison Sociale"/>
</li>
</ul>
</div>
<Checkboxes
itemsLabel={ getDeadlineStatusLabel }
items={ filters.field_mhp_deadline_status }
model=".field_mhp_deadline_status"
name="field_mhp_deadline_status"
label="Statut"
/>
<div className="controls form-actions">
<div className="holder">
<span className="result-txt">{ deadlineCount }</span>
<button className="btn-filter active">
<center>VALIDER</center>
</button>
</div>
</div>
</Form>
</div>
);
}
}