Skip to content

Commit

Permalink
Disable button if no values set
Browse files Browse the repository at this point in the history
  • Loading branch information
erjanmx committed Nov 30, 2023
1 parent f8c7a71 commit 448056f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h3>Preview of the first {{ firstThreeRows.length }} rows</h3>
</div>
</div>
<br />
<button class="button" @click="handleDownloadButton">Download</button>
<button :disabled="canDownload" class="button" @click="handleDownloadButton">Download</button>
</div>
</div>
</section>
Expand Down
7 changes: 5 additions & 2 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ new Vue({
return this.data.slice(-1)[0];
}
},
canDownload() {
return !this.fields.some(item => item.values.length);
}
},
methods: {
readFile() {
Expand Down Expand Up @@ -82,9 +85,9 @@ new Vue({
result += `VERSION:3.0\r\n`;

for (const item of self.fields) {
if (item.value) {
if (item.values) {
let value = "";
for (const v of item.value) {
for (const v of item.values) {
value += " " + contact[v];
}
result += `${item.code}:${value.trim()}\r\n`;
Expand Down

0 comments on commit 448056f

Please sign in to comment.