mirror of
https://github.com/beestat/app.git
synced 2025-05-24 02:14:03 -04:00
Fixed temperature profile start date not saving
This commit is contained in:
parent
97c65a95b9
commit
0742b65e72
@ -135,25 +135,26 @@ beestat.component.card.settings.prototype.decorate_contents_ = function(parent)
|
||||
|
||||
var temperature_profiles_range_begin = new beestat.component.input.text()
|
||||
.set_maxlength(10)
|
||||
.set_requirements({
|
||||
'type': 'date'
|
||||
})
|
||||
.set_icon('calendar');
|
||||
|
||||
var temperature_profiles_range_begin_m =
|
||||
moment(beestat.setting(temperature_profiles_range_begin_key));
|
||||
|
||||
if (temperature_profiles_range_begin_m.isValid() === true) {
|
||||
if (
|
||||
beestat.setting(temperature_profiles_range_begin_key) !== undefined &&
|
||||
beestat.setting(temperature_profiles_range_begin_key) !== null
|
||||
) {
|
||||
temperature_profiles_range_begin.set_value(
|
||||
temperature_profiles_range_begin_m.format('M/D/YYYY')
|
||||
beestat.setting(temperature_profiles_range_begin_key)
|
||||
);
|
||||
}
|
||||
|
||||
temperature_profiles_range_begin.addEventListener('change', function() {
|
||||
var m = moment(this.get_value());
|
||||
var temperature_profiles_range_begin_value;
|
||||
if (m.isValid() === true) {
|
||||
this.set_value(m.format('M/D/YYYY'));
|
||||
temperature_profiles_range_begin_value = m.format('YYYY-MM-DD');
|
||||
if (temperature_profiles_range_begin.meets_requirements() === true) {
|
||||
temperature_profiles_range_begin_value = this.get_value();
|
||||
} else {
|
||||
this.set_value('');
|
||||
this.set_value('', false);
|
||||
temperature_profiles_range_begin_value = null;
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,14 @@ beestat.component.input.prototype.meets_requirements = function() {
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
this.get_value() !== undefined &&
|
||||
this.requirements_.type === 'date' &&
|
||||
moment(this.get_value()).isValid() === false
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -86,13 +86,18 @@ beestat.component.input.text.prototype.decorate_ = function(parent) {
|
||||
* Set the value in the input field. Do not rerender; it's unnecessary.
|
||||
*
|
||||
* @param {string} value
|
||||
* @param {boolean} dispatch_event Whether or not to dispatch the change
|
||||
* event. Useful in situations where you need to change the value *inside* the
|
||||
* chagne event.
|
||||
*
|
||||
* @return {beestat.component.input.text} This.
|
||||
*/
|
||||
beestat.component.input.text.prototype.set_value = function(value) {
|
||||
beestat.component.input.text.prototype.set_value = function(value, dispatch_event = true) {
|
||||
this.input_.value = value;
|
||||
|
||||
this.dispatchEvent('change');
|
||||
if (dispatch_event === true) {
|
||||
this.dispatchEvent('change');
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user