Browse Source

Merge pull request #783 from anandpdoshi/anand-august-19

[fix] Remove button in Attach field
version-14
Nabin Hait 11 years ago
parent
commit
1c977fb824
2 changed files with 21 additions and 4 deletions
  1. +17
    -2
      frappe/public/js/frappe/form/attachments.js
  2. +4
    -2
      frappe/public/js/frappe/form/control.js

+ 17
- 2
frappe/public/js/frappe/form/attachments.js View File

@@ -109,10 +109,25 @@ frappe.ui.form.Attachments = Class.extend({
// hash is not escaped, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI
return encodeURI(file_url).replace(/#/g, '%23');
},
get_file_id_from_file_url: function(file_url) {
var fid;
$.each(this.get_attachments(), function(i, attachment) {
if (attachment.file_url === file_url) {
fid = attachment.name;
return false;
}
});
return fid;
},
remove_attachment_by_filename: function(filename, callback) {
this.remove_attachment(this.get_attachments()[filename], callback);
this.remove_attachment(this.get_file_id_from_file_url(filename), callback);
},
remove_attachment: function(fileid, callback) {
if (!fileid) {
if (callback) callback();
return;
}

var me = this;
return frappe.call({
method: 'frappe.widgets.form.utils.remove_attach',
@@ -131,7 +146,7 @@ frappe.ui.form.Attachments = Class.extend({
me.frm.toolbar.show_infobar();
me.frm.get_docinfo().comments.push(r.message);
me.frm.comments.refresh();
if(callback) callback();
if (callback) callback();
}
});
},


+ 4
- 2
frappe/public/js/frappe/form/control.js View File

@@ -559,8 +559,10 @@ frappe.ui.form.ControlAttach = frappe.ui.form.ControlData.extend({
me.onclick();
});
this.$value = $('<div style="margin-top: 5px;">\
<i class="icon-paper-clip" style="overflow: hidden; display: inline-block"></i> \
<a class="attached-file text-ellipsis" style="width: 80%" target="_blank"></a>\
<div class="text-ellipsis" style="display: inline-block; width: 90%;">\
<i class="icon-paper-clip"></i> \
<a class="attached-file" target="_blank"></a>\
</div>\
<a class="close">&times;</a></div>')
.prependTo(me.input_area)
.toggle(false);


Loading…
Cancel
Save