2018-02-10 23:31:26 +00:00
|
|
|
<div class="accounts-page">
|
|
|
|
{{#if loading}}
|
|
|
|
<LoadingPage />
|
|
|
|
{{elseif accounts && accounts.length}}
|
|
|
|
<ul class="accounts-results">
|
|
|
|
{{#each accounts as account}}
|
2018-04-28 21:19:39 +00:00
|
|
|
<AccountSearchResult
|
|
|
|
:account
|
|
|
|
actions={{accountActions}}
|
|
|
|
on:click="onClickAction(event)"
|
|
|
|
/>
|
2018-02-10 23:31:26 +00:00
|
|
|
{{/each}}
|
|
|
|
</ul>
|
|
|
|
{{/if}}
|
|
|
|
</div>
|
|
|
|
<style>
|
|
|
|
.accounts-page {
|
|
|
|
padding: 20px 20px;
|
2018-02-11 00:03:28 +00:00
|
|
|
position: relative;
|
2018-02-10 23:31:26 +00:00
|
|
|
}
|
|
|
|
.accounts-results {
|
|
|
|
list-style: none;
|
|
|
|
box-sizing: border-box;
|
|
|
|
border: 1px solid var(--main-border);
|
|
|
|
border-radius: 2px;
|
|
|
|
}
|
|
|
|
@media (max-width: 767px) {
|
|
|
|
.accounts-page {
|
|
|
|
padding: 20px 10px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<script>
|
|
|
|
import { store } from '../_store/store'
|
|
|
|
import LoadingPage from '../_components/LoadingPage.html'
|
|
|
|
import AccountSearchResult from '../_components/search/AccountSearchResult.html'
|
|
|
|
import { toast } from '../_utils/toast'
|
2018-04-28 21:19:39 +00:00
|
|
|
import { on } from '../_utils/eventBus'
|
2018-02-10 23:31:26 +00:00
|
|
|
|
2018-04-28 21:19:39 +00:00
|
|
|
// TODO: paginate
|
2018-02-10 23:31:26 +00:00
|
|
|
export default {
|
2018-04-20 04:38:01 +00:00
|
|
|
async oncreate () {
|
2018-02-10 23:31:26 +00:00
|
|
|
try {
|
2018-04-28 21:19:39 +00:00
|
|
|
await this.refreshAccounts()
|
2018-02-10 23:31:26 +00:00
|
|
|
} catch (e) {
|
|
|
|
toast.say('Error: ' + (e.name || '') + ' ' + (e.message || ''))
|
|
|
|
} finally {
|
|
|
|
this.set({loading: false})
|
|
|
|
}
|
2018-04-28 21:19:39 +00:00
|
|
|
on('refreshAccountsList', this, () => this.refreshAccounts())
|
2018-02-10 23:31:26 +00:00
|
|
|
},
|
|
|
|
data: () => ({
|
|
|
|
loading: true,
|
|
|
|
accounts: []
|
|
|
|
}),
|
|
|
|
store: () => store,
|
|
|
|
components: {
|
|
|
|
LoadingPage,
|
|
|
|
AccountSearchResult
|
2018-04-28 21:19:39 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onClickAction (event) {
|
|
|
|
let { action, accountId } = event
|
|
|
|
action.onclick(accountId)
|
|
|
|
},
|
|
|
|
async refreshAccounts () {
|
|
|
|
let { accountsFetcher } = this.get()
|
|
|
|
let accounts = await accountsFetcher()
|
|
|
|
this.set({ accounts: accounts })
|
|
|
|
}
|
2018-02-10 23:31:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|