mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
ENHANCEMENT: Files and images section warns if you are deleting a file that is linked to (from r96778)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@105678 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
8cea5136d2
commit
1e510684a3
@ -111,4 +111,60 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
}(jQuery));
|
||||
}(jQuery));
|
||||
|
||||
// TODO Implementation in Behaviour instead of entwine is necessary to overload TableListField
|
||||
var AssetTableField = Class.create();
|
||||
AssetTableField.applyTo('#Form_EditForm_Files');
|
||||
AssetTableField.prototype = {
|
||||
initialize: function() {
|
||||
var rules = {};
|
||||
rules['#'+this.id+' table.data a.deletelink'] = {onclick: this.deleteRecord.bind(this)};
|
||||
Behaviour.register('ComplexTableField_'+this.id,rules);
|
||||
},
|
||||
|
||||
deleteRecord: function(e) {
|
||||
var img = Event.element(e);
|
||||
var link = Event.findElement(e,"a");
|
||||
var row = Event.findElement(e,"tr");
|
||||
|
||||
var linkCount = row.getElementsByClassName('linkCount')[0];
|
||||
if(linkCount) linkCount = linkCount.innerHTML;
|
||||
|
||||
var confirmMessage = ss.i18n._t('TABLEFIELD.DELETECONFIRMMESSAGE', 'Are you sure you want to delete this record?');
|
||||
if(linkCount && linkCount > 0) confirmMessage += '\nThere are ' + linkCount + ' page(s) that use this file, please review the list of pages on the Links tab of the file before continuing.';
|
||||
|
||||
// TODO ajaxErrorHandler and loading-image are dependent on cms, but formfield is in sapphire
|
||||
var confirmed = confirm(confirmMessage);
|
||||
if(confirmed)
|
||||
{
|
||||
img.setAttribute("src",'cms/images/network-save.gif'); // TODO doesn't work
|
||||
new Ajax.Request(
|
||||
link.getAttribute("href"),
|
||||
{
|
||||
method: 'post',
|
||||
postBody: 'forceajax=1' + ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : ''),
|
||||
onComplete: function(){
|
||||
Effect.Fade(
|
||||
row,
|
||||
{
|
||||
afterFinish: function(obj) {
|
||||
// remove row from DOM
|
||||
obj.element.parentNode.removeChild(obj.element);
|
||||
// recalculate summary if needed (assumes that TableListField.js is present)
|
||||
// TODO Proper inheritance
|
||||
if(this._summarise) this._summarise();
|
||||
// custom callback
|
||||
if(this.callback_deleteRecord) this.callback_deleteRecord(e);
|
||||
}.bind(this)
|
||||
}
|
||||
);
|
||||
}.bind(this),
|
||||
onFailure: this.ajaxErrorHandler
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Event.stop(e);
|
||||
}
|
||||
};
|
@ -1,6 +1,7 @@
|
||||
<tr id="record-$Parent.id-$ID"<% if HighlightClasses %> class="$HighlightClasses"<% end_if %>>
|
||||
<td class="dragfile" id="drag-$Parent.Name-$ID">
|
||||
<img id="drag-img-$Parent.Name-$ID" alt="Drag" title="<% _t('DRAGTOFOLDER','Drag to folder on left to move file') %>" src="sapphire/images/drag.gif" />
|
||||
<span class="linkCount" style="display: none;">$BackLinkTrackingCount</span>
|
||||
</div>
|
||||
<% if Markable %><td class="markingcheckbox">$MarkingCheckbox</td><% end_if %>
|
||||
<% control Fields %>
|
||||
|
Loading…
Reference in New Issue
Block a user