diff --git a/front/core/components/input-number/index.js b/front/core/components/input-number/index.js
index 458c6d61f..7117ada9a 100644
--- a/front/core/components/input-number/index.js
+++ b/front/core/components/input-number/index.js
@@ -82,8 +82,7 @@ export default class InputNumber extends Input {
* @param {Number} value - Value
*/
set min(value) {
- if (!value) value = 0;
- this.input.min = value;
+ if (value) this.input.min = value;
}
/**
@@ -99,7 +98,7 @@ export default class InputNumber extends Input {
* @param {Number} value - Value
*/
set step(value) {
- this.input.step = value;
+ if (value) this.input.step = value;
}
/**
diff --git a/front/core/components/input-time/index.html b/front/core/components/input-time/index.html
index c189168d3..8d885ba47 100644
--- a/front/core/components/input-time/index.html
+++ b/front/core/components/input-time/index.html
@@ -18,14 +18,6 @@
-
- clear
-
diff --git a/front/core/components/input-time/index.js b/front/core/components/input-time/index.js
index 535d6004f..00e7c9118 100644
--- a/front/core/components/input-time/index.js
+++ b/front/core/components/input-time/index.js
@@ -3,32 +3,113 @@ import Input from '../../lib/input';
import './style.scss';
export default class InputTime extends Input {
+ constructor($element, $scope) {
+ super($element, $scope);
+
+ this.registerEvents();
+ }
+
+ /**
+ * Registers all event emitters
+ */
+ registerEvents() {
+ this.input.addEventListener('change', event => {
+ this.emit('change', {event});
+ });
+
+ this.input.addEventListener('focus', event => {
+ this.emit('focus', {event});
+ });
+ }
+
+ /**
+ * Gets current value
+ */
get value() {
return this._value;
}
+ /**
+ * Sets input value
+ *
+ * @param {Number} value - Value
+ */
set value(value) {
- if (!value) return;
+ if (this._value === undefined && value || typeof value === 'string')
+ value = this.formatTime(value);
- let newDate = new Date(value);
- newDate.setSeconds(0);
- newDate.setMilliseconds(0);
+ this._value = value;
+ this.hasValue = !(value === null || value === undefined);
- this._value = newDate;
- this.hasValue = this._value !== null;
- this.input.value = this._value;
-
- if (this.hasValue) this.element.classList.add('not-empty');
-
- this.element.querySelector('.infix').classList.remove('invalid', 'validated');
+ if (this.hasValue)
+ this.element.classList.add('not-empty');
+ else
+ this.element.classList.remove('not-empty');
}
+ /**
+ * Gets max value
+ */
+ get max() {
+ return this.input.max;
+ }
+
+ /**
+ * Sets max allowed value
+ *
+ * @param {Number} value - Value
+ */
+ set max(value) {
+ if (value) this.input.max = value;
+ }
+
+ /**
+ * Gets min value
+ */
+ get min() {
+ return this.input.min;
+ }
+
+ /**
+ * Sets min allowed value
+ *
+ * @param {Number} value - Value
+ */
+ set min(value) {
+ if (value) this.input.min = value;
+ }
+
+ /**
+ * Gets min step value
+ */
get step() {
- return parseInt(this.input.step);
+ return this.input.step;
}
+ /**
+ * Sets min step value
+ *
+ * @param {Number} value - Value
+ */
set step(value) {
- this.input.step = value;
+ if (value) this.input.step = value;
+ }
+
+ /**
+ * Returns a formatted hour
+ * @param {Date} date -a
+ * @return {String} Formatted hour
+ */
+ formatTime(date) {
+ if (typeof date === 'string') {
+ date = new Date(date);
+ date.setTime(date.getTime() + (date.getTimezoneOffset() * 60000));
+ }
+
+ date.setSeconds(null);
+ date.setMilliseconds(null);
+
+ return date;
}
}
@@ -46,6 +127,8 @@ ngModule.component('vnInputTime', {
disabled: '',
readonly: '',
step: '',
+ min: '',
+ max: '',
rule: '@?',
value: '=model',
vnTabIndex: '@?',
diff --git a/front/core/filters/dateTime.js b/front/core/filters/dateTime.js
index fdda69870..a4a527160 100644
--- a/front/core/filters/dateTime.js
+++ b/front/core/filters/dateTime.js
@@ -9,14 +9,13 @@ dateTime.$inject = ['$filter'];
export default function dateTime($filter) {
return function(input, format) {
- let value;
- if (input) {
- value = new Date(input);
- let offset = value.getTimezoneOffset() * 60000;
- value.setTime(value.getTime() + offset);
+ if (typeof input === 'string' && input) {
+ input = new Date(input);
+ let offset = input.getTimezoneOffset() * 60000;
+ input.setTime(input.getTime() + offset);
}
- return $filter('date')(value, format);
+ return $filter('date')(input, format);
};
}
ngModule.filter('dateTime', dateTime);
diff --git a/modules/agency/front/basic-data/index.html b/modules/agency/front/basic-data/index.html
index 1dfeaa1c6..ac37e8c07 100644
--- a/modules/agency/front/basic-data/index.html
+++ b/modules/agency/front/basic-data/index.html
@@ -39,8 +39,7 @@
label="Traveling days"
field="$ctrl.zone.travelingDays">
-
diff --git a/modules/agency/front/create/index.html b/modules/agency/front/create/index.html
index eef4be8ba..d25c91219 100644
--- a/modules/agency/front/create/index.html
+++ b/modules/agency/front/create/index.html
@@ -15,16 +15,14 @@
-
-
-
+ model="$ctrl.zone.travelingDays"
+ min="0" step="1">
-
+ model="$ctrl.zone.hour"
+ rule="zone.hour">
+ model="$ctrl.zone.price"
+ min="0" step="0.01">
+ model="$ctrl.zone.bonus"
+ min="0" step="0.01">