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
// 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;
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(
this._quote.getId(), step_id,
this._createDataProxy( jQuery, prohibit_abort )
this._quote.getId(),
step_id,
this._createDataProxy( jQuery, prohibit_abort ),
concluding_save
);
},

View File

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

View File

@ -42,19 +42,27 @@ module.exports = Class( 'XhttpQuoteTransport' )
*/
'private _url': '',
/**
* Indicates a concluding save
* @type {boolean}
*/
'private _concluding_save': false,
/**
* Constructs a new quote transport with the destination URL and proxy
*
* @param {string} url destination URL
* @param {HttpDataProxy} proxy proxy to use for transfer
* @param {string} url destination URL
* @param {HttpDataProxy} proxy proxy to use for transfer
* @param {boolean} concluding_save concluding save
*
* @return {undefined}
*/
'public __construct': function( url, proxy )
'public __construct': function( url, proxy, concluding_save )
{
this._url = ''+( url );
this._proxy = proxy;
this._url = ''+( url );
this._proxy = proxy;
this._concluding_save = concluding_save;
},
@ -80,7 +88,9 @@ module.exports = Class( 'XhttpQuoteTransport' )
var data = _self.getBucketDataJson( bucket );
// 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 )
{
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
// otherwise)
( ( last_step ) ? true : false )
last_step,
last_step
);
});
@ -1128,20 +1129,24 @@ module.exports = Class( 'Ui' ).extend( EventEmitter,
return this;
}
var len = this.saveStepHooks.length,
step = arguments[0] || this.getCurrentStep(),
callback = arguments[1] || function() {},
fail_callback = arguments[2] || function() {},
immediate = ( ( arguments[3] !== undefined )
var len = this.saveStepHooks.length,
step = arguments[0] || this.getCurrentStep(),
callback = arguments[1] || function() {},
fail_callback = arguments[2] || function() {},
immediately_save = ( ( arguments[3] !== undefined )
? arguments[3]
: false
),
concluding_save = ( ( arguments[4] !== undefined )
? !!arguments[4]
: false
),
abort = false;
var event = {
forceCallback: false,
errors: [],
concluding_save: concluding_save,
aborted: false,
abort: function()
{
@ -1285,7 +1290,7 @@ module.exports = Class( 'Ui' ).extend( EventEmitter,
}
};
if ( immediate )
if ( immediately_save )
{
doSave();
}

View File

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