mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 09:05:53 +00: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) {
|
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();
|
$page = $this->getPage();
|
||||||
|
|
||||||
// Same logic as SiteTree->onBeforeWrite
|
// Same logic as SiteTree->onBeforeWrite
|
||||||
|
@ -92,12 +92,24 @@
|
|||||||
* @param (Function)
|
* @param (Function)
|
||||||
*/
|
*/
|
||||||
suggest: function(val, callback) {
|
suggest: function(val, callback) {
|
||||||
var field = this.find(':text'),
|
var self = this,
|
||||||
urlParts = $.path.parseUrl(this.closest('form').attr('action')),
|
field = self.find(':text'),
|
||||||
|
urlParts = $.path.parseUrl(self.closest('form').attr('action')),
|
||||||
url = urlParts.hrefNoSearch + '/field/' + field.attr('name') + '/suggest/?value=' + encodeURIComponent(val);
|
url = urlParts.hrefNoSearch + '/field/' + field.attr('name') + '/suggest/?value=' + encodeURIComponent(val);
|
||||||
if(urlParts.search) url += '&' + urlParts.search.replace(/^\?/, '');
|
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…
x
Reference in New Issue
Block a user