Modify calendar to display the date layout in sync with the current year

This commit is contained in:
James Ketrenos 2018-10-16 08:31:49 -07:00
parent 2c28dde0bf
commit 7978aa3db9

View File

@ -333,9 +333,9 @@
<calendar-element <calendar-element
id="calendar" id="calendar"
tabindex tabindex
min="2016-01-01" min$="[[year]]-01-01"
max="2016-12-31" max$="[[year]]-12-31"
date="{{date}}"></calendar-element> date$="{{date}}"></calendar-element>
<div>Pick a date on the calendar to look back in time and see photos from that day.</div> <div>Pick a date on the calendar to look back in time and see photos from that day.</div>
<div hidden$="[[!thumbnails.length]]"> <div hidden$="[[!thumbnails.length]]">
<div>On <b>[[memoryDate]]</b>, there have been <b>[[add(thumbnails.length,pendingPhotos.length)]]</b> photos taken over <b>[[years.length]]</b> year(s).</div> <div>On <b>[[memoryDate]]</b>, there have been <b>[[add(thumbnails.length,pendingPhotos.length)]]</b> photos taken over <b>[[years.length]]</b> year(s).</div>
@ -469,6 +469,10 @@
Polymer({ Polymer({
is: "ketr-photos", is: "ketr-photos",
properties: { properties: {
year: {
type: String,
value: window.moment().format("YYYY")
},
actions: { actions: {
type: Array, type: Array,
value: [] value: []
@ -529,7 +533,7 @@
}, },
date: { date: {
type: String, type: String,
value: "2016-" + window.moment().format("MM-DD") value: window.moment().format("YYYY-MM-DD")
} }
}, },
@ -585,15 +589,16 @@
}, },
isToday: function(date) { isToday: function(date) {
return this.date == "2016-" + window.moment().format("MM-DD"); return this.date == window.moment().format("YYYY-MM-DD");
}, },
gotoToday: function() { gotoToday: function() {
this.date = "2016-" + window.moment().format("MM-DD"); this.date = window.moment().format("YYYY-MM-DD");
console.log(this.date);
}, },
gotoRandomDay: function() { gotoRandomDay: function() {
this.date = "2016-" + window.moment(Math.ceil(Math.random() * 365), "DDD").format("MM-DD"); this.date = window.moment().format("YYYY-") + window.moment(Math.ceil(Math.random() * 365), "DDD").format("MM-DD");
}, },
login: function(event) { login: function(event) {
@ -1470,7 +1475,7 @@
if (mode == "time") { if (mode == "time") {
path = ""; path = "";
} else if (mode == "memories") { } else if (mode == "memories") {
path = "memories/" + (this.date.replace(/2016-/, "") || ""); path = "memories/" + (this.date.replace(this.year + "-", "") || "");
} }
} }
var username = this.user ? this.user.username : ""; var username = this.user ? this.user.username : "";
@ -1485,7 +1490,7 @@
if ((username != (this.user ? this.user.username : "")) || if ((username != (this.user ? this.user.username : "")) ||
(mode != this.mode) || (mode != this.mode) ||
((mode == "albums") && (path != (this.path || ""))) || ((mode == "albums") && (path != (this.path || ""))) ||
((mode == "memories") && (path != ("memories/" + (this.date.replace(/2016-/, "") || ""))))) { ((mode == "memories") && (path != ("memories/" + (this.date.replace(this.year + "-", "") || ""))))) {
console.log("Skipping results for old query. Triggering re-fetch of photos for new path or mode."); console.log("Skipping results for old query. Triggering re-fetch of photos for new path or mode.");
this._loadPhotos(); this._loadPhotos();
return; return;