mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Better error message when attempting to enter a blank URL Segment (fixes silverstripe/silverstripe-cms#1570)
This commit is contained in:
parent
6457ab2433
commit
ea446f2ade
@ -43,7 +43,11 @@ class SiteTreeURLSegmentField extends TextField {
|
||||
}
|
||||
|
||||
public function suggest($request) {
|
||||
if(!$request->getVar('value')) return $this->httpError(405);
|
||||
if(!$request->getVar('value')) {
|
||||
return $this->httpError(405,
|
||||
_t('SiteTreeURLSegmentField.EMPTY', 'Please enter a URL Segment or click cancel')
|
||||
);
|
||||
}
|
||||
$page = $this->getPage();
|
||||
|
||||
// Same logic as SiteTree->onBeforeWrite
|
||||
|
@ -92,12 +92,24 @@
|
||||
* @param (Function)
|
||||
*/
|
||||
suggest: function(val, callback) {
|
||||
var field = this.find(':text'),
|
||||
urlParts = $.path.parseUrl(this.closest('form').attr('action')),
|
||||
var self = this,
|
||||
field = self.find(':text'),
|
||||
urlParts = $.path.parseUrl(self.closest('form').attr('action')),
|
||||
url = urlParts.hrefNoSearch + '/field/' + field.attr('name') + '/suggest/?value=' + encodeURIComponent(val);
|
||||
if(urlParts.search) url += '&' + urlParts.search.replace(/^\?/, '');
|
||||
|
||||
$.get(url, function(data) {callback.apply(this, arguments);});
|
||||
$.ajax({
|
||||
url: url,
|
||||
success: function(data) {
|
||||
callback.apply(this, arguments);
|
||||
},
|
||||
error: function(xhr, status) {
|
||||
xhr.statusText = xhr.responseText;
|
||||
},
|
||||
complete: function() {
|
||||
self.removeClass('loading');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user