Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Fix behavior of update button #83

Merged
merged 2 commits into from Aug 27, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions js/customize-snapshots.js
Expand Up @@ -765,9 +765,11 @@

// Change update button to schedule.
if ( component.isFutureDate() ) {
save.html( component.data.i18n.scheduleButton );
save.text( component.data.i18n.scheduleButton );
} else if ( api.state( 'snapshot-exists' ).get() ) {
save.text( component.data.i18n.updateButton );
} else {
save.html( component.data.i18n.updateButton );
save.text( component.data.i18n.saveButton );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all of this logic related to the buttons should be moved to addButton.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could move this logic to addButton but we also want to tie this logic on date input change so I kept it separate. But yes I see the advantage of keeping all button logic in addButton.
Maybe we should create a event for schedule and bind this button logic in addButton with that event? (using wp.customize.state.create)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, creating more states would be good and then listening for changes to those states in a centralized location I think is the best architecture.

}

if ( scheduled || component.data.dirty ) {
Expand Down