1
0
Fork 0

[DEV-6730] Post whether or not a save step will conclude the process

master
Austin Schaffer 2020-01-14 12:59:00 -05:00
parent d918d56a7e
commit 103c06da39
5 changed files with 57 additions and 22 deletions

View File

@ -1563,7 +1563,11 @@ module.exports = Class( 'Client' )
// transport used to transfer the bucket data to the server, prohibiting // transport used to transfer the bucket data to the server, prohibiting
// callback aborts (to ensure that we can handle failures ourselves) // callback aborts (to ensure that we can handle failures ourselves)
var transport = this._createBucketTransport( step_id, true ); var transport = this._createBucketTransport(
step_id,
true,
event.concluding_save
);
var finish, timeout; var finish, timeout;
function dosave() function dosave()
@ -1712,11 +1716,16 @@ module.exports = Class( 'Client' )
}, },
'private _createBucketTransport': function( step_id, prohibit_abort ) 'private _createBucketTransport': function(
{ step_id,
prohibit_abort,
concluding_save
){
return this._factory.createDataBucketTransport( return this._factory.createDataBucketTransport(
this._quote.getId(), step_id, this._quote.getId(),
this._createDataProxy( jQuery, prohibit_abort ) step_id,
this._createDataProxy( jQuery, prohibit_abort ),
concluding_save
); );
}, },

View File

@ -162,11 +162,17 @@ module.exports = Class( 'ClientDependencyFactory',
createStagingBucketDiscard: StagingBucketAutoDiscard, createStagingBucketDiscard: StagingBucketAutoDiscard,
createDataBucketTransport: function ( quote_id, step_id, proxy ) createDataBucketTransport: function (
quote_id,
step_id,
proxy,
concluding_save
)
{ {
return XhttpQuoteTransport( return XhttpQuoteTransport(
( quote_id + '/step/' + step_id + '/post' ), ( quote_id + '/step/' + step_id + '/post' ),
proxy proxy,
concluding_save
); );
}, },

View File

@ -42,19 +42,27 @@ module.exports = Class( 'XhttpQuoteTransport' )
*/ */
'private _url': '', 'private _url': '',
/**
* Indicates a concluding save
* @type {boolean}
*/
'private _concluding_save': false,
/** /**
* Constructs a new quote transport with the destination URL and proxy * Constructs a new quote transport with the destination URL and proxy
* *
* @param {string} url destination URL * @param {string} url destination URL
* @param {HttpDataProxy} proxy proxy to use for transfer * @param {HttpDataProxy} proxy proxy to use for transfer
* @param {boolean} concluding_save concluding save
* *
* @return {undefined} * @return {undefined}
*/ */
'public __construct': function( url, proxy ) 'public __construct': function( url, proxy, concluding_save )
{ {
this._url = ''+( url ); this._url = ''+( url );
this._proxy = proxy; this._proxy = proxy;
this._concluding_save = concluding_save;
}, },
@ -80,7 +88,9 @@ module.exports = Class( 'XhttpQuoteTransport' )
var data = _self.getBucketDataJson( bucket ); var data = _self.getBucketDataJson( bucket );
// post the data // post the data
_self._proxy.post( _self._url, { data: data }, _self._proxy.post(
_self._url,
{ data: data, concluding_save: _self._concluding_save },
function( data, error ) function( data, error )
{ {
if ( typeof callback === 'function' ) if ( typeof callback === 'function' )

View File

@ -934,7 +934,8 @@ module.exports = Class( 'Ui' ).extend( EventEmitter,
}, },
// no UI update (IE will display a security warning // no UI update (IE will display a security warning
// otherwise) // otherwise)
( ( last_step ) ? true : false ) last_step,
last_step
); );
}); });
@ -1128,20 +1129,24 @@ module.exports = Class( 'Ui' ).extend( EventEmitter,
return this; return this;
} }
var len = this.saveStepHooks.length, var len = this.saveStepHooks.length,
step = arguments[0] || this.getCurrentStep(), step = arguments[0] || this.getCurrentStep(),
callback = arguments[1] || function() {}, callback = arguments[1] || function() {},
fail_callback = arguments[2] || function() {}, fail_callback = arguments[2] || function() {},
immediate = ( ( arguments[3] !== undefined ) immediately_save = ( ( arguments[3] !== undefined )
? arguments[3] ? arguments[3]
: false : false
), ),
concluding_save = ( ( arguments[4] !== undefined )
? !!arguments[4]
: false
),
abort = false; abort = false;
var event = { var event = {
forceCallback: false, forceCallback: false,
errors: [], errors: [],
concluding_save: concluding_save,
aborted: false, aborted: false,
abort: function() abort: function()
{ {
@ -1285,7 +1290,7 @@ module.exports = Class( 'Ui' ).extend( EventEmitter,
} }
}; };
if ( immediate ) if ( immediately_save )
{ {
doSave(); doSave();
} }

View File

@ -58,6 +58,8 @@ describe( "XhttpQuoteTransport", () =>
bs: [ null ], bs: [ null ],
}; };
const concluding_save = true;
const stub_quote = { visitData: c => c( bucket ) }; const stub_quote = { visitData: c => c( bucket ) };
const mock_proxy = { const mock_proxy = {
@ -66,10 +68,13 @@ describe( "XhttpQuoteTransport", () =>
expect( JSON.parse( data.data ) ) expect( JSON.parse( data.data ) )
.to.deep.equal( expected_data ); .to.deep.equal( expected_data );
expect( JSON.parse( data.concluding_save ) )
.to.deep.equal( concluding_save );
done(); done();
}, },
}; };
Sut( '', mock_proxy ).send( stub_quote ); Sut( '', mock_proxy, concluding_save ).send( stub_quote );
} ); } );
} ); } );