Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ENHANCEMENT Using built-in TableListField javascript deletion for Ass…

…etTableField

ENHANCEMENT Less template overloading in AssetTableField.ss

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92820 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
commit 343044e89c952e098a621b7e142d0410d5e3cfaf 1 parent f15e2d8
@chillu chillu authored
View
26 code/AssetAdmin.php
@@ -45,7 +45,6 @@ class AssetAdmin extends LeftAndMain {
'getfile',
'getsubtree',
'movemarked',
- 'removefile',
'save',
'savefile',
'uploadiframe',
@@ -110,7 +109,7 @@ function init() {
CMSBatchActionHandler::register('delete', 'AssetAdmin_DeleteBatchAction', 'Folder');
}
-
+
/**
* Show the content of the upload iframe. The form is specified by a template.
*/
@@ -609,29 +608,6 @@ function BatchActionsForm() {
return $form;
}
- public function removefile(){
- if($fileID = $this->urlParams['ID']) {
- $file = DataObject::get_by_id('File', $fileID);
- // Delete the temp verions of this file in assets/_resampled
- if($file instanceof Image) {
- $file->deleteFormattedImages();
- }
- $file->delete();
- $file->destroy();
-
- if(Director::is_ajax()) {
- echo <<<JS
- $('Form_EditForm_Files').removeFile($fileID);
- statusMessage('removed file', 'good');
-JS;
- } else {
- Director::redirectBack();
- }
- } else {
- user_error("AssetAdmin::removefile: Bad parameters: File=$fileID", E_USER_ERROR);
- }
- }
-
/**
* @return Form
*/
View
2  code/CMSMain.php
@@ -323,7 +323,7 @@ function EditForm($request = null) {
public function getEditForm($id = null) {
// Include JavaScript to ensure HtmlEditorField works.
HtmlEditorField::include_js();
-
+
if(!$id) $id = $this->currentPageID();
$record = ($id) ? $this->getRecord($id) : null;
View
36 javascript/AssetTableField.js
@@ -14,7 +14,8 @@ AssetTableField.prototype = {
'ctf[ID]' : true,
'FileFilterButton' : true,
'FileFieldName' : true,
- 'FileSearch' : true
+ 'FileSearch' : true,
+ 'Files[]' : true
}
}
});
@@ -135,35 +136,4 @@ MarkingPropertiesButton.prototype = {
}
return false;
}
-}
-
-Behaviour.register({
- '#Form_EditForm_Files': {
- removeFile : function(fileID) {
- var record;
- if(record = $('record-' + fileID)) {
- record.parentNode.removeChild(record);
- }
- }
- },
-
- '#Form_EditForm_Files a.deletelink' : {
- onclick : function(event) {
- // Send request
- new Ajax.Request(this.href + (this.href.indexOf("?") == -1 ? "?" : "&") + "ajax=1", {
- method : 'get',
- onSuccess : Ajax.Evaluator,
- onFailure : function(response) {errorMessage('Server Error', response);}
- });
- Event.stop(event);
- return false;
- }
- },
-
-
- '#Form_EditForm' : {
- changeDetection_fieldsToIgnore : {
- 'Files[]' : true
- }
- }
-});
+}
View
39 templates/Includes/AssetTableField.ss
@@ -18,40 +18,15 @@
<tbody>
<% if Items %>
<% control Items %>
- <tr id="record-$Parent.Name-$ID">
- <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" />
- </div>
- <% if Markable %><td class="markingcheckbox">$MarkingCheckbox</td><% end_if %>
- <% control Fields %>
- <td>$Value</td>
- <% end_control %>
- <% if Can(show) %>
- <td width="18" class="action">
- <a class="popuplink showlink" href="$ShowLink" target="_blank" title="<% _t('SHOW', 'Show asset') %>"><img src="cms/images/show.png" alt="<% _t('SHOW', 'Show asset') %>" /></a>
- </td>
- <% end_if %>
- <% if Can(edit) %>
- <td width="18" class="action">
- <a class="popuplink editlink" href="$EditLink" target="_blank" title="<% _t('EDIT', 'Edit asset') %>"><img src="cms/images/edit.gif" alt="<% _t('EDIT', 'Edit asset') %>" /></a>
- </td>
- <% end_if %>
- <% if Can(delete) %>
- <td width="18" class="action">
- <a class="deletelink" href="admin/assets/removefile/$ID" title="<% _t('DELFILE', 'Delete this file') %>"><img src="cms/images/delete.gif" alt="<% _t('DELFILE', 'Delete this file') %>" title="<% _t('DELFILE','Delete this file') %>" /></a>
- </td>
- <% end_if %>
- </tr>
+ <% include AssetTableField_Item %>
<% end_control %>
<% else %>
- <tr class="notfound">
- <td>&nbsp;</td>
- <% if Markable %><td width="18">&nbsp;</td><% end_if %>
- <td colspan="$Headings.Count"><i>No $NamePlural found</i></td>
- <% if Can(show) %><td width="18">&nbsp;</td><% end_if %>
- <% if Can(edit) %><td width="18">&nbsp;</td><% end_if %>
- <% if Can(delete) %><td width="18">&nbsp;</td><% end_if %>
- </tr>
+ <tr class="notfound">
+ <td></td>
+ <% if Markable %><th width="18">&nbsp;</th><% end_if %>
+ <td colspan="$Headings.Count"><i><% _t('NOITEMSFOUND','No items found') %></i></td>
+ <% if Can(delete) %><td width="18">&nbsp;</td><% end_if %>
+ </tr>
<% end_if %>
</tbody>
</table>
View
22 templates/Includes/AssetTableField_Item.ss
@@ -0,0 +1,22 @@
+<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" />
+ </div>
+ <% if Markable %><td class="markingcheckbox">$MarkingCheckbox</td><% end_if %>
+ <% control Fields %>
+ <td class="field-$Title.HTMLATT $FirstLast $Name">$Value</td>
+ <% end_control %>
+ <% control Actions %>
+ <td width="16">
+ <% if IsAllowed %>
+ <a class="$Class" href="$Link">
+ <% if Icon %><img src="$Icon" alt="$Label" /><% else %>$Label<% end_if %>
+ </a>
+ <% else %>
+ <span class="disabled">
+ <% if IconDisabled %><img src="$IconDisabled" alt="$Label" /><% else %>$Label<% end_if %>
+ </span>
+ <% end_if %>
+ </td>
+ <% end_control %>
+</tr>
Please sign in to comment.
Something went wrong with that request. Please try again.