Add in a notification for unsaved changes.

This commit is contained in:
George Stephanis 2015-08-10 18:49:06 -04:00
parent 843fef6e26
commit 56218b0824
2 changed files with 5 additions and 0 deletions

View File

@ -16,6 +16,7 @@
paginationTemplate = wp.template( 'wc-tax-table-pagination' ), paginationTemplate = wp.template( 'wc-tax-table-pagination' ),
$table = $( '.wc_tax_rates' ), $table = $( '.wc_tax_rates' ),
$tbody = $( '#rates' ), $tbody = $( '#rates' ),
$p_unsaved_msg = $( '#unsaved-changes' ),
$pagination = $( '#rates-pagination' ), $pagination = $( '#rates-pagination' ),
WCTaxTableModelConstructor = Backbone.Model.extend({ WCTaxTableModelConstructor = Backbone.Model.extend({
setRateAttribute : function( rateID, attribute, value ) { setRateAttribute : function( rateID, attribute, value ) {
@ -85,9 +86,11 @@
}, },
setUnloadConfirmation : function() { setUnloadConfirmation : function() {
this.needsUnloadConfirm = true; this.needsUnloadConfirm = true;
$p_unsaved_msg.show();
}, },
clearUnloadConfirmation : function() { clearUnloadConfirmation : function() {
this.needsUnloadConfirm = false; this.needsUnloadConfirm = false;
$p_unsaved_msg.hide();
}, },
unloadConfirmation : function(event) { unloadConfirmation : function(event) {
if ( event.data.view.needsUnloadConfirm ) { if ( event.data.view.needsUnloadConfirm ) {

View File

@ -45,6 +45,8 @@ if ( ! defined( 'ABSPATH' ) ) {
</tbody> </tbody>
</table> </table>
<p id="unsaved-changes" style="display:none;"><?php _e( 'There are unsaved changes.', 'woocommerce' ); ?></p>
<script type="text/html" id="tmpl-wc-tax-table-row"> <script type="text/html" id="tmpl-wc-tax-table-row">
<tr class="tips" data-tip="<?php echo esc_attr( sprintf( __( 'Tax rate ID: %s', 'woocommerce' ), '{{ data.tax_rate_id }}' ) ); ?>" data-id="{{ data.tax_rate_id }}"> <tr class="tips" data-tip="<?php echo esc_attr( sprintf( __( 'Tax rate ID: %s', 'woocommerce' ), '{{ data.tax_rate_id }}' ) ); ?>" data-id="{{ data.tax_rate_id }}">
<td class="sort"> <td class="sort">