From 784bec95fd502e8988276137d7ad915623cc33f4 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 13 Jun 2012 18:17:12 +0200 Subject: [PATCH] [ADD] Recovered delete icon for the attachments bzr revid: fme@openerp.com-20120613161712-91h2yvg0rykwun2j --- addons/web/static/src/css/base.css | 53 +++++++++++++++++++++++------ addons/web/static/src/css/base.sass | 31 +++++++++++++++-- addons/web/static/src/js/views.js | 20 +++++------ addons/web/static/src/xml/base.xml | 4 +-- 4 files changed, 82 insertions(+), 26 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index b65f4da557a..32f520d1a30 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1066,11 +1066,24 @@ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); } .openerp .oe_dropdown_menu li { + position: relative; list-style-type: none; float: none; display: block; background-color: none; } +.openerp .oe_dropdown_menu li:hover { + background-color: #f0f0fa; + background-image: -webkit-gradient(linear, left top, left bottom, from(#f0f0fa), to(#eeeef6)); + background-image: -webkit-linear-gradient(top, #f0f0fa, #eeeef6); + background-image: -moz-linear-gradient(top, #f0f0fa, #eeeef6); + background-image: -ms-linear-gradient(top, #f0f0fa, #eeeef6); + background-image: -o-linear-gradient(top, #f0f0fa, #eeeef6); + background-image: linear-gradient(to bottom, #f0f0fa, #eeeef6); + -moz-box-shadow: none; + -webkit-box-shadow: none; + box-shadow: none; +} .openerp .oe_dropdown_menu li a { display: block; padding: 3px 6px; @@ -1083,20 +1096,40 @@ } .openerp .oe_dropdown_menu li a:hover { text-decoration: none; - background-color: #f0f0fa; - background-image: -webkit-gradient(linear, left top, left bottom, from(#f0f0fa), to(#eeeef6)); - background-image: -webkit-linear-gradient(top, #f0f0fa, #eeeef6); - background-image: -moz-linear-gradient(top, #f0f0fa, #eeeef6); - background-image: -ms-linear-gradient(top, #f0f0fa, #eeeef6); - background-image: -o-linear-gradient(top, #f0f0fa, #eeeef6); - background-image: linear-gradient(to bottom, #f0f0fa, #eeeef6); - -moz-box-shadow: none; - -webkit-box-shadow: none; - box-shadow: none; +} +.openerp .oe_dropdown_menu li .oe_sidebar_delete_item { + position: absolute; + bottom: 1px; + right: 4px; + display: none; + width: 12px; + height: 12px; + line-height: 12px; + padding: 1px; + color: #8786b7; + line-height: 8px; + text-align: center; + font-weight: bold; + text-shadow: 0 1px 1px white; +} +.openerp .oe_dropdown_menu li .oe_sidebar_delete_item:hover { + text-decoration: none; + color: white; + background: #8786b7; + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + border-radius: 2px; +} +.openerp .oe_dropdown_menu li:hover .oe_sidebar_delete_item { + display: inline-block; } .openerp .oe_sidebar { white-space: nowrap; } +.openerp .oe_sidebar .oe_dropdown_menu li { + padding-right: 16px; +} .openerp .oe_sidebar .oe_sidebar_add_attachment { cursor: pointer; padding-left: 6px; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 7208834a887..d933550db23 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -858,6 +858,10 @@ $colour4: #8a89ba @include radius(3px) @include box-shadow(0 1px 4px rgba(0,0,0,0.3)) li + &:hover + @include vertical-gradient(#f0f0fa, #eeeef6) + @include box-shadow(none) + position: relative list-style-type: none float: none display: block @@ -873,10 +877,33 @@ $colour4: #8a89ba cursor: pointer &:hover text-decoration: none - @include vertical-gradient(#f0f0fa, #eeeef6) - @include box-shadow(none) + .oe_sidebar_delete_item + position: absolute + bottom: 1px + right: 4px + display: none + width: 12px + height: 12px + line-height: 12px + padding: 1px + color: #8786b7 + line-height: 8px + text-align: center + font-weight: bold + text-shadow: 0 1px 1px white + &:hover + text-decoration: none + color: white + background: #8786b7 + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4) + @include radius(2px) + &:hover + .oe_sidebar_delete_item + display: inline-block .oe_sidebar white-space: nowrap + .oe_dropdown_menu li + padding-right: 16px .oe_sidebar_add_attachment cursor: pointer padding-left: 6px diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 5be69760f80..4d677364e41 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -857,7 +857,7 @@ instance.web.Sidebar = instance.web.Widget.extend({ self.items['files'] = attachments; self.redraw(); this.$('.oe_sidebar_add_attachment .oe-binary-file').change(this.on_attachment_changed); - //this.$element.find('.oe-sidebar-attachment-delete').click(this.on_attachment_delete); + this.$element.find('.oe_sidebar_delete_item').click(this.on_attachment_delete); }, on_attachment_changed: function(e) { var $e = $(e.target); @@ -870,16 +870,14 @@ instance.web.Sidebar = instance.web.Widget.extend({ } }, on_attachment_delete: function(e) { - return; - var self = this, $e = $(e.currentTarget); - var name = _.str.trim($e.parent().find('a.oe-sidebar-attachments-link').text()); - if (confirm(_.str.sprintf(_t("Do you really want to delete the attachment %s?"), name))) { - this.rpc('/web/dataset/unlink', { - model: 'ir.attachment', - ids: [parseInt($e.attr('data-id'))] - }, function(r) { - $e.parent().remove(); - self.do_notify("Delete an attachment", "The attachment '" + name + "' has been deleted"); + var self = this; + e.preventDefault(); + e.stopPropagation(); + var self = this; + var $e = $(e.currentTarget); + if (confirm(_t("Do you really want to delete this attachment ?"))) { + (new instance.web.DataSet(this, 'ir.attachment')).unlink([parseInt($e.attr('data-id'), 10)]).then(function() { + self.do_attachement_update(self.dataset, self.model_id); }); } } diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index d0f3a235323..b90addb0a2c 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -517,9 +517,7 @@ - + x