Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify file input in import datasource component #5021

Merged
merged 1 commit into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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