Post by d77 » Sat Sep 15, 2007 12:12 am

there are tons of little "delete" icons throughout the admin tool, for removing entries in a list. i have coded a few small admin pages like this and usually on every delete button click, i pop up a javascript confirm: "Are you sure you want to delete ? OK/Cancel".

earlier this week i screwed myself over by accidentally clicking the "delete" button beside the "paypal" pament type. i meant to click the configuration button, but i deleted paypal instead! :o this completely blew a way a number of database records and i had to rebuild it by picking pieces out of the install script.

a confirmation would have saved me :) has anyone else not done this  ??? 8)

User avatar
d77
Active Member

Posts

Joined
Sat Apr 14, 2007 8:04 am

Post by ginghamgirl » Wed Sep 19, 2007 3:33 am

i agree that a comfirmation would be helpful! i expected to see one when deleting some default information pages, and was surprised when i was not presented with one.

Newbie

Posts

Joined
Tue Sep 18, 2007 2:00 am

Post by lev » Sat May 03, 2008 3:57 am

I did this, but its not clean so maybe it will inspire someone to do it the clean way.

  I figured that since we can have delete in a different language spell something different, but we only confirm on delete, i used the icon to differentiate between the buttons. I modified the 'admin/template/default/content/list.tpl'  file:
  added some javscript to the top
       

Code: Select all

<script type="text/javascript">
	function confirmDelete(href){
		if (confirm("Are you sure you would like to delete this item?")) {
			window.location.href = href;
		}
	}
</script>
and changed the button link (at the very bottom of the file)
  from:
 

Code: Select all

<a href="<?php echo $action['href']; ?>">
  to this:

 

Code: Select all

<a <?php if(strpos(strtolower($action['icon']),'elete') > 0) { echo "onclick=\"confirmDelete('".$action['href']."')\" "; } else { echo "href=\"" . $action['href'] . "\""; } ?>>

I'm fairly new to php so im sure you guys can do better  :)
Last edited by lev on Sat May 03, 2008 4:20 am, edited 1 time in total.

lev
New member

Posts

Joined
Wed Apr 30, 2008 10:47 pm

Post by bruce » Thu May 29, 2008 6:15 pm

The whole notion of quick delete is flawed. What I suggest is to comment out or simply delete the following code

Code: Select all

    $action[] = array(
        'icon' => 'delete.png',
        'text' => $language->get('button_delete'),
        'href' => $url->ssl('product', 'delete', array('product_id' => $result['product_id']))
    );
from each of the following files where it occurs:

"'icon' => 'delete.png',", "category.php (242:22)"
"'icon' => 'delete.png',", "country.php (203:22)"
"'icon' => 'delete.png',", "coupon.php (273:22)"
"'icon' => 'delete.png',", "currency.php (215:22)"
"'icon' => 'delete.png',", "customer.php (211:22)"
"'icon' => 'delete.png',", "download.php (225:22)"
"'icon' => 'delete.png',", "extension.php (217:22)"
"'icon' => 'delete.png',", "geo_zone.php (199:22)"
"'icon' => 'delete.png',", "image.php (232:22)"
"'icon' => 'delete.png',", "information.php (205:22)"
"'icon' => 'delete.png',", "language.php (201:22)"
"'icon' => 'delete.png',", "manufacturer.php (190:22)"
"'icon' => 'delete.png',", "newsletter.php (237:22)"
"'icon' => 'delete.png',", "option.php (183:22)"
"'icon' => 'delete.png',", "option_value.php (179:22)"
"'icon' => 'delete.png',", "order.php (226:22)"
"'icon' => 'delete.png',", "order_status.php (183:22)"
"'icon' => 'delete.png',", "product.php (296:22)"
"'icon' => 'delete.png',", "product_option.php (235:22)"
"'icon' => 'delete.png',", "review.php (205:22)"
"'icon' => 'delete.png',", "tax_class.php (183:22)"
"'icon' => 'delete.png',", "tax_rate.php (198:22)"
"'icon' => 'delete.png',", "url_alias.php (190:22)"
"'icon' => 'delete.png',", "user.php (186:22)"
"'icon' => 'delete.png',", "user_group.php (175:22)"
"'icon' => 'delete.png',", "weight_class.php (212:22)"
"'icon' => 'delete.png',", "zone.php (203:22)"
"'icon' => 'delete.png',", "zone_to_geo_zone.php (191:22)"

Now, to delete anything from the admin, you must first click on the notepad icon to edit the item and then you can click the big red delete button at the top of the page. I also suggest adding a javascript confirmation to that as well by replacing every occurrence of

Code: Select all

  <div class="enabled" onmouseover="className='hover'" onmouseout="className='enabled'" onclick="location='<?php echo $delete; ?>';"><img src="template/default/image/delete_enabled.png" alt="<?php echo $button_delete; ?>" class="png" /><?php echo $button_delete; ?></div>
with

Code: Select all

  <div class="enabled" onmouseover="className='hover'" onmouseout="className='enabled'" onclick="if(confirm('Do you really want to DELETE this order?')) location='<?php echo $delete; ?>'; else return false;"><img src="template/default/image/delete_enabled.png" alt="<?php echo $button_delete; ?>" class="png" /><?php echo $button_delete; ?></div>
in each of the respective template files. Note that the above example is from admin\template\default\content\order.tpl and contains the word Order in the dialog message.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by hm2k » Mon Jun 02, 2008 6:25 pm


UK Web Hosting


User avatar
Global Moderator

Posts

Joined
Tue Mar 11, 2008 9:06 am
Location - UK
Who is online

Users browsing this forum: No registered users and 4 guests