2018-02-10 23:31:26 +00:00
|
|
|
<div class="accounts-page">
|
2018-05-02 00:05:36 +00:00
|
|
|
{#if loading}
|
2018-02-10 23:31:26 +00:00
|
|
|
<LoadingPage />
|
2018-05-02 00:05:36 +00:00
|
|
|
{:elseif accounts && accounts.length}
|
2018-02-10 23:31:26 +00:00
|
|
|
<ul class="accounts-results">
|
2018-05-02 00:05:36 +00:00
|
|
|
{#each accounts as account}
|
2018-04-28 21:19:39 +00:00
|
|
|
<AccountSearchResult
|
2018-05-02 00:05:36 +00:00
|
|
|
{account}
|
|
|
|
actions={accountActions}
|
2018-04-28 21:19:39 +00:00
|
|
|
on:click="onClickAction(event)"
|
|
|
|
/>
|
2018-05-02 00:05:36 +00:00
|
|
|
{/each}
|
2018-02-10 23:31:26 +00:00
|
|
|
</ul>
|
2018-05-02 00:05:36 +00:00
|
|
|
{/if}
|
2018-02-10 23:31:26 +00:00
|
|
|
</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'
|
2018-12-11 15:31:48 +00:00
|
|
|
import LoadingPage from './LoadingPage.html'
|
|
|
|
import AccountSearchResult from './search/AccountSearchResult.html'
|
2018-12-22 23:37:51 +00:00
|
|
|
import { toast } from './toast/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 {
|
2018-08-30 04:42:57 +00:00
|
|
|
this.set({ loading: false })
|
2018-02-10 23:31:26 +00:00
|
|
|
}
|
2018-04-28 21:19:39 +00:00
|
|
|
on('refreshAccountsList', this, () => this.refreshAccounts())
|
2018-02-10 23:31:26 +00:00
|
|
|
},
|
|
|
|
data: () => ({
|
|
|
|
loading: true,
|
2018-05-01 02:06:08 +00:00
|
|
|
accounts: [],
|
2019-08-20 02:08:59 +00:00
|
|
|
accountActions: undefined
|
2018-02-10 23:31:26 +00:00
|
|
|
}),
|
|
|
|
store: () => store,
|
|
|
|
components: {
|
|
|
|
LoadingPage,
|
|
|
|
AccountSearchResult
|
2018-04-28 21:19:39 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onClickAction (event) {
|
2019-08-03 20:49:37 +00:00
|
|
|
const { action, accountId } = event
|
2018-04-28 21:19:39 +00:00
|
|
|
action.onclick(accountId)
|
|
|
|
},
|
|
|
|
async refreshAccounts () {
|
2019-08-03 20:49:37 +00:00
|
|
|
const { accountsFetcher } = this.get()
|
|
|
|
const accounts = await accountsFetcher()
|
2018-04-28 21:19:39 +00:00
|
|
|
this.set({ accounts: accounts })
|
|
|
|
}
|
2018-02-10 23:31:26 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-11 15:31:48 +00:00
|
|
|
</script>
|