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
id="calendar"
tabindex
min="2016-01-01"
max="2016-12-31"
date="{{date}}"></calendar-element>
min$="[[year]]-01-01"
max$="[[year]]-12-31"
date$="{{date}}"></calendar-element>
<div>Pick a date on the calendar to look back in time and see photos from that day.</div>
<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>
@ -469,6 +469,10 @@
Polymer({
is: "ketr-photos",
properties: {
year: {
type: String,
value: window.moment().format("YYYY")
},
actions: {
type: Array,
value: []
@ -529,7 +533,7 @@
},
date: {
type: String,
value: "2016-" + window.moment().format("MM-DD")
value: window.moment().format("YYYY-MM-DD")
}
},
@ -585,15 +589,16 @@
},
isToday: function(date) {
return this.date == "2016-" + window.moment().format("MM-DD");
return this.date == window.moment().format("YYYY-MM-DD");
},
gotoToday: function() {
this.date = "2016-" + window.moment().format("MM-DD");
this.date = window.moment().format("YYYY-MM-DD");
console.log(this.date);
},
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) {
@ -1470,7 +1475,7 @@
if (mode == "time") {
path = "";
} else if (mode == "memories") {
path = "memories/" + (this.date.replace(/2016-/, "") || "");
path = "memories/" + (this.date.replace(this.year + "-", "") || "");
}
}
var username = this.user ? this.user.username : "";
@ -1485,7 +1490,7 @@
if ((username != (this.user ? this.user.username : "")) ||
(mode != this.mode) ||
((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.");
this._loadPhotos();
return;