Skip to content

Commit

Permalink
Simplify file input in import datasource component
Browse files Browse the repository at this point in the history
  • Loading branch information
fredj committed Jul 16, 2019
1 parent c0c38ef commit 2109939
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 33 deletions.
3 changes: 0 additions & 3 deletions contribs/gmf/src/import/import.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
@import "~gmf/sass/typeahead.scss";

gmf-importdatasource {
input[type=file] {
display: none;
}

.gmf-importdatasource-url-form-group {
background-color: #fff;
Expand Down
24 changes: 4 additions & 20 deletions contribs/gmf/src/import/importdatasourceComponent.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,10 @@
ng-show="$ctrl.mode === 'Local'">
<div class="form-group">
<div class="input-group">
<input
name="file"
type="file"
required
/>
<input
class="form-control"
placeholder="{{'No file' | translate}}"
readonly
type="text"
value="{{$ctrl.fileNameAndSize}}"
ng-click="$ctrl.browse()"
/>
<span class="input-group-btn">
<button
class="btn btn-default"
type="button"
ng-click="$ctrl.browse()"
translate>Browse</button>
</span>
<div class="custom-file">
<input type="file" class="custom-file-input" required>
<label class="custom-file-label" translate>No file</label>
</div>
</div>
</div>
<div class="form-group">
Expand Down
15 changes: 7 additions & 8 deletions contribs/gmf/src/import/importdatasourceComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ class Controller {
const fileInput = /** @type {HTMLInputElement} */(this.fileInput_[0]);
const files = fileInput.files;
this.file = files && files[0] ? files[0] : null;

if (this.file) {
this.hasError = false;
// update the label
$(fileInput).next('.custom-file-label').html(this.fileNameAndSize);
}

this.scope_.$apply();
});
}
Expand Down Expand Up @@ -316,14 +323,6 @@ class Controller {
}
}

/**
* Triggers a 'click' on the "Browse" button.
*/
browse() {
this.hasError = false;
this.element_.find('input[type=file][name=file]').click();
}

/**
* Connect to given online resource URL.
*/
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/src/map/mousepositionComponent.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="btn-group dropup">
<a class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="gmf-mouseposition-control-target"></span>
</a>
</button>
<ul class="dropdown-menu dropdown-menu-right" role="menu">
<li class="dropdown-header" translate>Coordinate systems</li>
<li ng-repeat="projitem in ::ctrl.projections">
Expand Down

0 comments on commit 2109939

Please sign in to comment.