-
Notifications
You must be signed in to change notification settings - Fork 11
Conversation
event.preventDefault(); | ||
component.sendUpdateSnapshotRequest( { status: 'draft' } ); | ||
if ( $( this ).html() === component.data.i18n.scheduleButton && ! _.isEmpty( component.snapshotScheduleBox ) && component.getDateFromInputs() && component.isScheduleDateFuture() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$( this ).html()
seems dirty. Can't you look at snapshotStatus
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
snapshotStatus
can be draft
or future
we can remove that check as we are checking for the future date on the same condition. And will also add isSnapshotHasUnsavedChanges
check.
ESLint errors:
And phpunit failure:
|
return false; | ||
} | ||
|
||
remainingTime = component.dateValueOf( date ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat of a problem here. date
is a Date
object. However, the component.dateValueOf()
function takes a string
as its param. It looks like dateValueOf
needs to take a Date
as its argument as well?
diff --git a/js/customize-snapshots.js b/js/customize-snapshots.js
index 40cf91e..6ecd668 100644
--- a/js/customize-snapshots.js
+++ b/js/customize-snapshots.js
@@ -774,19 +774,21 @@
/**
* Get the primitive value of a Date object.
*
- * @param {string} dateString The post status for the snapshot.
+ * @param {Date|string} [date] The post status for the snapshot. Defaults to current date.
* @returns {object|string} The primitive value or date object.
*/
- component.dateValueOf = function( dateString ) {
- var date;
+ component.dateValueOf = function( date ) {
+ var dateObj;
- if ( _.isUndefined( dateString ) ) {
- date = new Date();
+ if ( _.isUndefined( date ) ) {
+ dateObj = new Date();
+ } else if ( 'string' === typeof date ) {
+ dateObj = new Date( date );
} else {
- date = new Date( dateString );
+ dateObj = date;
}
- return date.valueOf();
+ return dateObj.valueOf();
};
component.init();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed dateValueOf
function.
@PatelUtkarsh something is wrong with the time being entered. I change a date and then click Reset and it always is showing for me as 16:25, no matter what the current time is: |
@westonruter Maybe that is the time when snapshot was saved in DB, reset only reset time to snapshot's publish date if publish date is empty it resets to current date/time, Should we tweak it like this: if snapshot date is future reset to that date or else reset to current date/time? |
@PatelUtkarsh ah, thanks for that info. OK, it does make sense to me now I think. The reset link is initially hidden because it behaves differently than it does in Customize Posts. Instead of resetting it to NOW it resets it to the original value. I was expecting Reset to undo the scheduling, by setting the date back to |
How in the world did the coverage go DOWN when I added MORE tests?! |
…stomize-snapshots into feature/schedule-ui-customizer
No description provided.