mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
NEW Open first tab with validation errors
This commit is contained in:
parent
3156e75548
commit
09067cc8dd
@ -88,6 +88,11 @@
|
||||
if(this.hasClass('validationerror')) {
|
||||
// TODO validation shouldnt need a special case
|
||||
statusMessage(ss.i18n._t('ModelAdmin.VALIDATIONERROR', 'Validation Error'), 'bad');
|
||||
|
||||
// Ensure the first validation error is visible
|
||||
var firstTabWithErrors = this.find('.message.validation:first').closest('.tab');
|
||||
$('.cms-container').clearCurrentTabState(); // clear state to avoid override later on
|
||||
firstTabWithErrors.closest('.tabset').tabs('select', firstTabWithErrors.attr('id'));
|
||||
}
|
||||
|
||||
// Move navigator to preview if one is available.
|
||||
|
@ -473,6 +473,30 @@ jQuery.noConflict();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove any previously saved state.
|
||||
*
|
||||
* Parameters:
|
||||
* (String) url Optional (sanitized) URL to clear a specific state.
|
||||
*/
|
||||
clearTabState: function(url) {
|
||||
if(typeof(window.sessionStorage)=="undefined") return;
|
||||
|
||||
var s = window.sessionStorage;
|
||||
if(url) {
|
||||
s.removeItem('tabs-' + url);
|
||||
} else {
|
||||
for(var i=0;i<s.length;i++) s.removeItem(s.key(i));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove tab state for the current URL.
|
||||
*/
|
||||
clearCurrentTabState: function() {
|
||||
this.clearTabState(this._tabStateUrl());
|
||||
},
|
||||
|
||||
_tabStateUrl: function() {
|
||||
return History.getState().url
|
||||
.replace(/\?.*/, '')
|
||||
|
Loading…
Reference in New Issue
Block a user