Skip to content

Commit 0bb037f

Browse files
committed
Bug 1374165: Unable to upload the same file the second time after clear in ace editor
1 parent ac45a1b commit 0bb037f

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

app/scripts/directives/oscFileInput.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ angular.module('openshiftConsole')
2424
dropZoneName = scope.dropZoneId + "-drag-and-drop-zone",
2525
dropZoneSelectorName = "#" + dropZoneName,
2626
highlightDropZone = false,
27-
showDropZone = false;
27+
showDropZone = false,
28+
inputFileField = element.find('input[type=file]')[0];
2829

2930
// Add/Remove dropZone based on if the directive element is disabled
3031
scope.$watch('disabled', function() {
@@ -68,8 +69,14 @@ angular.module('openshiftConsole')
6869
});
6970
}
7071

72+
scope.cleanInputValues = function() {
73+
scope.model = '';
74+
scope.fileName = '';
75+
inputFileField.value = "";
76+
};
77+
7178
element.change(function() {
72-
addFile($('input[type=file]', this)[0].files[0]);
79+
addFile(inputFileField.files[0]);
7380
});
7481

7582
// Add listeners for the dropZone element

app/views/directives/osc-file-input.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@
3232
<div ng-if="model && showValues && supportsFileUpload">
3333
<pre ng-if="model && showValues && supportsFileUpload" class="clipped scroll">{{model}}</pre>
3434
</div>
35-
<a href="" ng-show="model || fileName" ng-click="model = ''; fileName = ''">Clear value</a>
35+
<a href="" ng-show="model || fileName" class="clear-btn" ng-click="cleanInputValues()">Clear value</a>

dist/scripts/scripts.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -7067,7 +7067,7 @@ function h() {
70677067
$(k).remove();
70687068
}
70697069
b.helpID = _.uniqueId("help-"), b.supportsFileUpload = window.File && window.FileReader && window.FileList && window.Blob, b.uploadError = !1;
7070-
var i = b.dropZoneId ? $("#" + b.dropZoneId) :c, j = b.dropZoneId + "-drag-and-drop-zone", k = "#" + j, l = !1, m = !1;
7070+
var i = b.dropZoneId ? $("#" + b.dropZoneId) :c, j = b.dropZoneId + "-drag-and-drop-zone", k = "#" + j, l = !1, m = !1, n = c.find("input[type=file]")[0];
70717071
b.$watch("disabled", function() {
70727072
b.disabled ? h() :(e(), d());
70737073
}, !0), (_.isUndefined($._data($(document)[0], "events")) || _.isUndefined($._data($(document)[0], "events").drop)) && ($(document).on("drop.oscFileInput", function() {
@@ -7080,8 +7080,10 @@ return m = !0, $(".drag-and-drop-zone").addClass("show-drag-and-drop-zone"), !1;
70807080
return m = !1, _.delay(function() {
70817081
m || $(".drag-and-drop-zone").removeClass("show-drag-and-drop-zone");
70827082
}, 200), !1;
7083-
})), c.change(function() {
7084-
f($("input[type=file]", this)[0].files[0]);
7083+
})), b.cleanInputValues = function() {
7084+
b.model = "", b.fileName = "", n.value = "";
7085+
}, c.change(function() {
7086+
f(n.files[0]);
70857087
}), b.$on("$destroy", function() {
70867088
$(k).off(), $(document).off("drop.oscFileInput").off("dragenter.oscFileInput").off("dragover.oscFileInput").off("dragleave.oscFileInput");
70877089
});

dist/scripts/templates.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5881,7 +5881,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
58815881
"<div ng-if=\"model && showValues && supportsFileUpload\">\n" +
58825882
"<pre ng-if=\"model && showValues && supportsFileUpload\" class=\"clipped scroll\">{{model}}</pre>\n" +
58835883
"</div>\n" +
5884-
"<a href=\"\" ng-show=\"model || fileName\" ng-click=\"model = ''; fileName = ''\">Clear value</a>"
5884+
"<a href=\"\" ng-show=\"model || fileName\" class=\"clear-btn\" ng-click=\"cleanInputValues()\">Clear value</a>"
58855885
);
58865886

58875887

0 commit comments

Comments
 (0)