(js) Fix uploading same attachment after removal

Fixes #3876
This commit is contained in:
Francis Lachapelle
2016-11-10 10:21:33 -05:00
parent a78621add4
commit 5961117208
2 changed files with 9 additions and 4 deletions
+3 -3
View File
@@ -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"/>
<!--
@@ -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() {