mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR Changed GridField.js edit click behaviour from event-based to an (subclassable) method class, which means it works outside of the CMS by default. Making the whole row active in case an edit link is present
This commit is contained in:
parent
1b600a0b09
commit
a415034d0a
@ -381,6 +381,16 @@ jQuery.noConflict();
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Overload the default GridField behaviour (open a new URL in the browser)
|
||||
* with the CMS-specific ajax loading.
|
||||
*/
|
||||
$('.cms .ss-gridfield').entwine({
|
||||
showDetailView: function(url) {
|
||||
$('.cms-container').entwine('ss').loadPanel(url);
|
||||
}
|
||||
});
|
||||
|
||||
$('.cms-filter-form').entwine({
|
||||
|
||||
GridField: null,
|
||||
|
@ -34,6 +34,9 @@
|
||||
}
|
||||
}, ajaxOpts));
|
||||
},
|
||||
showDetailView: function(url) {
|
||||
window.location.href = url;
|
||||
},
|
||||
getItems: function() {
|
||||
return this.find('.ss-gridfield-item');
|
||||
},
|
||||
@ -59,6 +62,24 @@
|
||||
return this.closest('.ss-gridfield');
|
||||
}
|
||||
});
|
||||
|
||||
$('.ss-gridfield .ss-gridfield-item').entwine({
|
||||
onclick: function(e) {
|
||||
if($(e.target).is('.action')) {
|
||||
this._super(e);
|
||||
return;
|
||||
}
|
||||
|
||||
var editLink = this.find('.edit-link');
|
||||
if(editLink.length) this.getGridField().showDetailView(editLink.prop('href'));
|
||||
},
|
||||
onmouseover: function() {
|
||||
if(this.find('.edit-link').length) this.css('cursor', 'pointer');
|
||||
},
|
||||
onmouseout: function() {
|
||||
this.css('cursor', 'default');
|
||||
}
|
||||
});
|
||||
|
||||
$('.ss-gridfield .action').entwine({
|
||||
onclick: function(e){
|
||||
@ -67,7 +88,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
$('.ss-gridfield .action-deleterecord').entwine({
|
||||
$('.ss-gridfield .gridfield-button-delete').entwine({
|
||||
onclick: function(e){
|
||||
if(!confirm(ss.i18n._t('TABLEFIELD.DELETECONFIRMMESSAGE'))) return false;
|
||||
else this._super(e);
|
||||
@ -76,14 +97,14 @@
|
||||
|
||||
$('fieldset.ss-gridfield .new-link').entwine({
|
||||
onclick: function(e) {
|
||||
$(this).trigger('opennewview', $(this).prop('href'));
|
||||
this.getGridField().showDetailView($(this).prop('href'));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('fieldset.ss-gridfield .edit-link').entwine({
|
||||
onclick: function(e) {
|
||||
$(this).trigger('openeditview', $(this).prop('href'));
|
||||
this.getGridField().showDetailView($(this).prop('href'));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user