Skip to content

Commit

Permalink
(js) Fix uploading same attachment after removal
Browse files Browse the repository at this point in the history
Fixes #3876
  • Loading branch information
cgx committed Nov 10, 2016
1 parent a78621a commit 5961117
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions UI/Templates/MailerUI/UIxMailEditor.wox
Expand Up @@ -237,14 +237,14 @@
</span>
<a ng-href="{{$chip.inlineUrl}}" target="_new">{{$chip.file.name}}</a>
<md-icon ng-class="{ 'md-warn': $chip.isUploading }"
ng-click="editor.removeAttachment($chip)">close</md-icon>
ng-click="editor.removeAttachment($chip, 'fileInput')">close</md-icon>
</md-chip-template>
</md-chips>
<label class="md-button md-icon-button" for="file-input">
<label class="md-button md-icon-button" for="fileInput">
<md-icon>attach_file</md-icon>
<!-- <span><var:string label:value="Attach"/></span> -->
</label>
<input id="file-input" name="file-input" type="file" class="ng-hide"
<input id="fileInput" name="fileInput" type="file" class="ng-hide"
nv-file-select="nv-file-select"
uploader="editor.uploader"/>
<!--
Expand Down
7 changes: 6 additions & 1 deletion UI/WebServerResources/js/Mailer/MessageEditorController.js
Expand Up @@ -134,13 +134,18 @@
}
}

function removeAttachment(item) {
function removeAttachment(item, id) {
if (item.isUploading)
vm.uploader.cancelItem(item);
else {
vm.message.$deleteAttachment(item.file.name);
item.remove();
}
// Hack to allow adding the same file again
// See https://github.com/nervgh/angular-file-upload/issues/671
var element = $window.document.getElementById(id);
if (element)
angular.element(element).prop('value', null);
}

function cancel() {
Expand Down

0 comments on commit 5961117

Please sign in to comment.