Set Pull to Refresh feature on Accounts list

This commit is contained in:
Bubka 2020-02-09 23:04:46 +01:00
parent 0db83e9908
commit 94d57aff4f
2 changed files with 45 additions and 28 deletions

View File

@ -27,6 +27,12 @@
</div> </div>
<!-- accounts --> <!-- accounts -->
<div class="accounts columns is-multiline is-centered"> <div class="accounts columns is-multiline is-centered">
<vue-pull-refresh :on-refresh="onRefresh" :config="{
errorLabel: 'error',
startLabel: '',
readyLabel: '',
loadingLabel: 'refreshing'
}">
<div class="tfa column is-narrow has-text-white" v-for="account in filteredAccounts"> <div class="tfa column is-narrow has-text-white" v-for="account in filteredAccounts">
<div class="tfa-container"> <div class="tfa-container">
<div class="tfa-checkbox" v-if="editMode"> <div class="tfa-checkbox" v-if="editMode">
@ -49,6 +55,7 @@
</div> </div>
</div> </div>
</div> </div>
</vue-pull-refresh>
</div> </div>
</div> </div>
<!-- No account --> <!-- No account -->
@ -131,6 +138,7 @@
import Modal from '../components/Modal' import Modal from '../components/Modal'
import TwofaccountShow from '../components/TwofaccountShow' import TwofaccountShow from '../components/TwofaccountShow'
import Form from './../components/Form' import Form from './../components/Form'
import vuePullRefresh from 'vue-pull-refresh';
export default { export default {
data(){ data(){
@ -141,11 +149,10 @@
search: '', search: '',
username : null, username : null,
editMode: this.InitialEditMode, editMode: this.InitialEditMode,
QuickFormIsVisible: false, showQuickForm: false,
form: new Form({ form: new Form({
qrcode: null qrcode: null
}), }),
axiosIsComplete: null,
} }
}, },
@ -159,14 +166,8 @@
}, },
showAccounts() { showAccounts() {
return this.accounts.length > 0 && !this.QuickFormIsVisible ? true : false return this.accounts.length > 0 && !this.showQuickForm ? true : false
}, },
showQuickForm: {
get: function() { return (this.QuickFormIsVisible || this.accounts.length === 0) && this.axiosIsComplete },
set: function(value) { this.QuickFormIsVisible = value }
},
}, },
props: ['InitialEditMode'], props: ['InitialEditMode'],
@ -187,10 +188,22 @@
components: { components: {
Modal, Modal,
TwofaccountShow, TwofaccountShow,
'vue-pull-refresh': vuePullRefresh
}, },
methods: { methods: {
onRefresh() {
var that = this
return new Promise(function (resolve, reject) {
setTimeout(function () {
that.fetchAccounts()
resolve();
}, 1000);
});
},
async uploadQrcode(event) { async uploadQrcode(event) {
let imgdata = new FormData(); let imgdata = new FormData();
@ -216,7 +229,7 @@
}) })
}) })
this.axiosIsComplete = true this.showQuickForm = response.data.length === 0 ? true: false
}) })
}, },

View File

@ -52,6 +52,10 @@ a:hover {
background-color: hsl(0, 0%, 14%) !important; background-color: hsl(0, 0%, 14%) !important;
} }
.pull-down-header {
background-color: hsl(0, 0%, 21%) !important;
}
.tfa { .tfa {
border-radius: 6px; border-radius: 6px;
text-align: center; text-align: center;