Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then( record => {
if ( !data.instanceStr && record && record.xml ) {
records.setActive( records.getAutoSavedKey() );
data.instanceStr = record.xml;
}
if ( data.instanceAttachments ) {
fileManager.setInstanceAttachments( data.instanceAttachments );
}
form = new Form( formSelector, data, formOptions );
loadErrors = form.init();
// Remove loader. This will make the form visible.
// In order to aggregate regular loadErrors and GoTo loaderrors,
// this is placed in between form.init() and form.goTo().
$( '.main-loader' ).remove();
if ( settings.goTo && location.hash ) {
console.log( 'going to ', location.hash.substring( 1 ) );
loadErrors = loadErrors.concat( form.goTo( location.hash.substring( 1 ) ) );
}
if ( form.encryptionKey && !encryptor.isSupported() ) {
loadErrors.unshift( t( 'error.encryptionnotsupported' ) );
}
function _resetForm( confirmed ) {
let message;
if ( !confirmed && form.editStatus ) {
message = t( 'confirm.save.msg' );
gui.confirm( message )
.then( confirmed => {
if ( confirmed ) {
_resetForm( true );
}
} );
} else {
_setDraftStatus( false );
form.resetView();
form = new Form( formSelector, {
modelStr: formData.modelStr,
external: formData.external
}, formOptions );
const loadErrors = form.init();
// formreset event will update the form media:
form.view.$.trigger( 'formreset' );
if ( records ) {
records.setActive( null );
}
if ( loadErrors.length > 0 ) {
gui.alertLoadErrors( loadErrors );
}
}
}