Projekt

Obecné

Profil

« Předchozí | Další » 

Revize fbb0d123

Přidáno uživatelem Vít Mazín před více než 5 roky(ů)

Getting min and max date for date slider (refs #7465)

Zobrazit rozdíly:

sources/imiger-core/src/main/webapp/css/components/modal-window.css
11 11

  
12 12
.modal-content {
13 13
	position: relative;
14
	max-width: 440px;
14
	max-width: 540px;
15 15
	min-height: 40px;
16 16
	max-height: 100%;
17 17
	margin-left: auto;
sources/imiger-core/src/main/webapp/js/components/filterModalWindow.js
5 5
	constructor() {
6 6
		super();
7 7

  
8
		this._sliderString = "$(\"#slider\").dateRangeSlider({valueLabels:\"change\", step:{days:1}});";
8 9
		this._baseFilterOptions = {
9 10
			nodeType: 'Node type',
10 11
			vertexArchetype: 'Vertex archetype',
......
76 77
				type: 'hidden',
77 78
				name: 'dataType',
78 79
			}),
79
			DOM.h('table', {}, [
80
			DOM.h('table', {
81
				style: "width:100%;"
82
			}, [
80 83
				DOM.h('tr', {}, [
81 84
					DOM.h('td', {}, [
82 85
						DOM.h('label', {
......
135 138
					]),
136 139
				]),
137 140
			]),
138
			DOM.h('script', {}, [
139
				DOM.t("$(\"#slider\").dateRangeSlider();")
140
			]),
141 141
		]);
142 142
		this._bodyElement.appendChild(this._form);
143 143

  
......
180 180

  
181 181
		this._dateRangeField = DOM.h('div', {
182 182
			id: "slider"
183
		}, []);
183
		}, [/*
184
			DOM.h('input', {
185
				type: 'date',
186
				name: 'value-from',
187
			}),
188
			DOM.t(' - '),
189
			DOM.h('input', {
190
				type: 'date',
191
				name: 'value-to',
192
			}),*/
193
		]);
194

  
195
		this._showSlider = DOM.h('script', {
196
			id: "sliderScript",
197
		}, [
198
				DOM.t(this._sliderString)
199
			]),
184 200

  
185 201
		// number
186 202
		this._numberField = DOM.h('input', {
......
302 318
			case FilterDataType.DATE:
303 319
				if (value === DateFilterOperation.RANGE) {
304 320
					this._valueCell.appendChild(this._dateRangeField);
321
					this._valueCell.appendChild(this._showSlider);
305 322
				} else {
306 323
					this._valueCell.appendChild(this._dateField);
307 324
				}
......
421 438
			node.isFound = true;
422 439
		});
423 440
	}
441

  
442
	setDateBounds(minDate, maxDate) {
443
		if(minDate !== null && maxDate !== null) {
444
			this._sliderString = "$(\"#slider\").dateRangeSlider({valueLabels:\"change\", step:{days:1}, bounds:{min: new Date(" + minDate.toString() + "), max: new Date(" + maxDate.toString() + ")}});";
445
			var element = document.getElementById("sliderScript");
446
		}
447
	}
424 448
}
sources/imiger-core/src/main/webapp/js/showGraphApp.js
257 257

  
258 258
			this.spinLoaderComponent.disable();
259 259

  
260
			// find date in graph data
261
			this.checkDate();
260 262
		} catch (error) {
261 263
			if (error instanceof HttpError) {
262 264
				switch (error.response.status) {
......
284 286
			window.location.replace('./');
285 287
		}
286 288
	}
289

  
290
	/**
291
	 * Checks for date bounds and set them to filter
292
	 */
293
	checkDate() {
294
		var dateAttributes = [];
295
		var minDate = null;
296
		var maxDate = null;
297
		this.attributeTypeList.forEach(function (attribute) {
298
			if(attribute.dataType === "DATE") {
299
				dateAttributes.push(attribute.name);
300
			}
301
		});
302
		if(dateAttributes.length > 0) {
303
			this.vertexList.forEach(function (vertex) {
304
				vertex.attributes.forEach(function (a) {
305
					var index = dateAttributes.indexOf(a[0]);
306
					if(index > -1) {
307
						var date = Date.parse(a[1]);
308
						if(isNaN(date)) {
309
							date = new Date(Number(a[1]));
310
						}
311

  
312
						if(date !== 'Invalid Date') {
313
							if(minDate === null || date < minDate) {
314
								minDate = date;
315
							}
316
							if(maxDate === null || date > maxDate) {
317
								maxDate = date;
318
							}
319
						}
320
					}
321
				});
322
			});
323
		}
324
		this.filterModalWindowComponent.setDateBounds(minDate, maxDate);
325
	}
287 326
}
288 327

  
289 328
export default ShowGraphApp;

Také k dispozici: Unified diff