Add loading button

This commit is contained in:
Angelina Filippova 2020-03-02 22:01:08 +03:00
parent 48d9e1a48a
commit c8f07c85fa
2 changed files with 11 additions and 2 deletions

View file

@ -9,7 +9,8 @@ const status = {
showLocal: false, showLocal: false,
showPrivate: false, showPrivate: false,
page: 1, page: 1,
pageSize: 30 pageSize: 30,
buttonLoading: false
} }
}, },
mutations: { mutations: {
@ -31,6 +32,9 @@ const status = {
PUSH_STATUSES: (state, statuses) => { PUSH_STATUSES: (state, statuses) => {
state.fetchedStatuses = [...state.fetchedStatuses, ...statuses] state.fetchedStatuses = [...state.fetchedStatuses, ...statuses]
}, },
SET_BUTTON_LOADING: (state, status) => {
state.statusesByInstance.buttonLoading = status
},
SET_LOADING: (state, status) => { SET_LOADING: (state, status) => {
state.loading = status state.loading = status
} }
@ -82,6 +86,7 @@ const status = {
commit('SET_LOADING', false) commit('SET_LOADING', false)
}, },
async FetchStatusesPageByInstance({ commit, getters, state }) { async FetchStatusesPageByInstance({ commit, getters, state }) {
commit('SET_BUTTON_LOADING', true)
const statuses = await fetchStatusesByInstance( const statuses = await fetchStatusesByInstance(
{ {
instance: state.statusesByInstance.selectedInstance, instance: state.statusesByInstance.selectedInstance,
@ -92,6 +97,7 @@ const status = {
}) })
commit('PUSH_STATUSES', statuses.data) commit('PUSH_STATUSES', statuses.data)
commit('SET_BUTTON_LOADING', false)
}, },
HandleGodmodeCheckboxChange({ commit, dispatch }, value) { HandleGodmodeCheckboxChange({ commit, dispatch }, value) {
commit('CHANGE_GODMODE_CHECKBOX_VALUE', value) commit('CHANGE_GODMODE_CHECKBOX_VALUE', value)

View file

@ -39,7 +39,7 @@
@status-selection="handleStatusSelection" /> @status-selection="handleStatusSelection" />
</div> </div>
<div v-if="statuses.length > 0" class="statuses-pagination"> <div v-if="statuses.length > 0" class="statuses-pagination">
<el-button @click="handleLoadMore">{{ $t('statuses.loadMore') }}</el-button> <el-button :loading="buttonLoading" @click="handleLoadMore">{{ $t('statuses.loadMore') }}</el-button>
</div> </div>
</div> </div>
</template> </template>
@ -60,6 +60,9 @@ export default {
} }
}, },
computed: { computed: {
buttonLoading() {
return this.$store.state.status.statusesByInstance.buttonLoading
},
currentInstance() { currentInstance() {
return this.selectedInstance === this.$store.state.user.authHost return this.selectedInstance === this.$store.state.user.authHost
}, },