Skip to content

Commit

Permalink
Merge pull request #24 from unicef-polymer/ability-to-hide-change
Browse files Browse the repository at this point in the history
Ability to hide Change btn and allow filename display on multiline
  • Loading branch information
acory authored Dec 7, 2018
2 parents b18fdf8 + 756f8a9 commit 149be48
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "etools-upload",
"description": "Use to upload files",
"version": "1.0.1",
"version": "1.0.2",
"main": "etools-upload.html",
"dependencies": {
"polymer": "Polymer/polymer#^2.0.0",
Expand Down
23 changes: 18 additions & 5 deletions etools-upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<dom-module id="etools-upload">
<template>
<style include="common-styles">

#input-main-content {
@apply --layout-horizontal;
@apply --layout-center;
Expand Down Expand Up @@ -67,7 +68,7 @@
@apply --layout-wrap;
}

.file-name {
.file-name:not([allow-multiline-filename]) {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
Expand Down Expand Up @@ -95,7 +96,7 @@
<!-- File name container an upload status -->
<div class="filename-container" hidden$="[[!_thereIsAFileSelectedOrSaved(_filename)]]">
<iron-icon class="file-icon" icon="attachment"></iron-icon>
<span class="file-name" title="[[_filename]]">[[_filename]]</span>
<span class="file-name" allow-multiline-filename$="[[allowMultilineFilename]]" title="[[_filename]]">[[_filename]]</span>
</div>
<div class="upload-status">
<paper-spinner id="uploadingSpinner" hidden$="[[!uploadInProgress]]"
Expand All @@ -118,8 +119,8 @@

<paper-button class="change-button"
on-tap="_openFileChooser"
disabled$="[[!_showChange(readonly, _filename, uploadInProgress)]]"
hidden$="[[!_showChange(readonly, _filename, uploadInProgress)]]">
disabled$="[[!_showChange(readonly, _filename, uploadInProgress, showChange)]]"
hidden$="[[!_showChange(readonly, _filename, uploadInProgress, showChange)]]">
Change
</paper-button>

Expand Down Expand Up @@ -216,6 +217,15 @@
fail: {
type: Boolean,
value: false
},
showChange: {
type: Boolean,
value: true
},
allowMultilineFilename: {
type: Boolean,
value: false,
reflectToAttribute: true
}
};
}
Expand Down Expand Up @@ -319,7 +329,10 @@
return !!fileUrl && isNaN(fileUrl);
}

_showChange(readonly, _filename, uploadInProgress) {
_showChange(readonly, _filename, uploadInProgress, showChange) {
if (!showChange) {
return false;
}
return uploadInProgress ? false : (!readonly && !!_filename);
}

Expand Down

0 comments on commit 149be48

Please sign in to comment.