Clear History button will look disabled when there is no history

This commit is contained in:
Andrew Bastin
2019-08-23 10:49:17 +05:30
parent b8f9f23684
commit e6f6c17c80
2 changed files with 6 additions and 1 deletions

View File

@@ -108,7 +108,7 @@
<legend v-on:click="collapse">History ↕</legend>
<div class="collapsible">
<ul>
<li><button v-on:click="clearHistory">Clear History</button></li>
<li><button v-bind:class="{ disabled: noHistoryToClear }" v-on:click="clearHistory">Clear History</button></li>
</ul>
<ul v-for="entry in history">
<li>

View File

@@ -29,6 +29,11 @@ const app = new Vue({
history: window.localStorage.getItem('history') ? JSON.parse(window.localStorage.getItem('history')) : []
},
computed: {
noHistoryToClear() {
return this.history.length === 0;
},
urlNotValid() {
const pattern = new RegExp('^(https?:\\/\\/)?' +
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' +