Last active
June 7, 2019 08:54
-
-
Save sukima/25bad17ed582a4b7e2479c79a1f60f6f to your computer and use it in GitHub Desktop.
ember-observer-causing-an-issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Component from '@ember/component'; | |
import { computed } from '@ember/object'; | |
export default Component.extend({ | |
time: computed('datetime', function() { | |
let date = new Date(this.datetime); | |
return `${date.getHours()}:${date.getMinutes()}`; | |
}), | |
date: computed('datetime', function() { | |
let date = new Date(this.datetime); | |
return `${date.getMonth() + 1}/${date.getDay()}`; | |
}), | |
actions: { | |
updateTime(newTime) { | |
let [hour, minute] = newTime.split(':').map(v => parseInt(v)); | |
if (!(hour && minute)) { return; } | |
let date = new Date(this.datetime); | |
date.setHours(hour); | |
date.setMinutes(minute); | |
this.update(date.toISOString()); | |
}, | |
updateDate(newDate) { | |
let [month, day] = newDate.split('/').map(v => parseInt(v)); | |
if (!(month && day)) { return; } | |
let date = new Date(this.datetime); | |
date.setMonth(month - 1); | |
date.setDate(day); | |
this.update(date.toISOString()); | |
}, | |
updateToNow() { | |
let now = new Date(); | |
this.update(now.toISOString()); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
queryParams: ['exampleTime'], | |
exampleTime: new Date().toISOString() | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment