This commit is contained in:
Angelina Filippova 2020-02-03 17:21:00 +03:00
parent 4566725a4e
commit 6ecfbb8892
3 changed files with 28 additions and 5 deletions

View file

@ -121,6 +121,11 @@ import moment from 'moment'
export default { export default {
name: 'Status', name: 'Status',
props: { props: {
fetchStatusesByInstance: {
type: Boolean,
required: false,
default: false
},
showCheckbox: { showCheckbox: {
type: Boolean, type: Boolean,
required: true, required: true,
@ -156,7 +161,15 @@ export default {
return str.charAt(0).toUpperCase() + str.slice(1) return str.charAt(0).toUpperCase() + str.slice(1)
}, },
changeStatus(statusId, isSensitive, visibility) { changeStatus(statusId, isSensitive, visibility) {
this.$store.dispatch('ChangeStatusScope', { statusId, isSensitive, visibility, reportCurrentPage: this.page, userId: this.userId, godmode: this.godmode }) this.$store.dispatch('ChangeStatusScope', {
statusId,
isSensitive,
visibility,
reportCurrentPage: this.page,
userId: this.userId,
godmode: this.godmode,
fetchStatusesByInstance: this.fetchStatusesByInstance
})
}, },
deleteStatus(statusId) { deleteStatus(statusId) {
this.$confirm('Are you sure you want to delete this status?', 'Warning', { this.$confirm('Are you sure you want to delete this status?', 'Warning', {
@ -164,7 +177,13 @@ export default {
cancelButtonText: 'Cancel', cancelButtonText: 'Cancel',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$store.dispatch('DeleteStatus', { statusId, reportCurrentPage: this.page, userId: this.userId, godmode: this.godmode }) this.$store.dispatch('DeleteStatus', {
statusId,
reportCurrentPage: this.page,
userId: this.userId,
godmode: this.godmode,
fetchStatusesByInstance: this.fetchStatusesByInstance
})
this.$message({ this.$message({
type: 'success', type: 'success',
message: 'Delete completed' message: 'Delete completed'

View file

@ -28,22 +28,26 @@ const status = {
} }
}, },
actions: { actions: {
async ChangeStatusScope({ dispatch, getters }, { statusId, isSensitive, visibility, reportCurrentPage, userId, godmode }) { async ChangeStatusScope({ dispatch, getters }, { statusId, isSensitive, visibility, reportCurrentPage, userId, godmode, fetchStatusesByInstance }) {
await changeStatusScope(statusId, isSensitive, visibility, getters.authHost, getters.token) await changeStatusScope(statusId, isSensitive, visibility, getters.authHost, getters.token)
if (reportCurrentPage !== 0) { // called from Reports if (reportCurrentPage !== 0) { // called from Reports
dispatch('FetchReports', reportCurrentPage) dispatch('FetchReports', reportCurrentPage)
} else if (userId.length > 0) { // called from User profile } else if (userId.length > 0) { // called from User profile
dispatch('FetchUserStatuses', { userId, godmode }) dispatch('FetchUserStatuses', { userId, godmode })
} else if (fetchStatusesByInstance) { // called from Statuses by Instance
dispatch('FetchStatusesByInstance')
} else { // called from GroupedReports } else { // called from GroupedReports
dispatch('FetchGroupedReports') dispatch('FetchGroupedReports')
} }
}, },
async DeleteStatus({ dispatch, getters }, { statusId, reportCurrentPage, userId, godmode }) { async DeleteStatus({ dispatch, getters }, { statusId, reportCurrentPage, userId, godmode, fetchStatusesByInstance }) {
await deleteStatus(statusId, getters.authHost, getters.token) await deleteStatus(statusId, getters.authHost, getters.token)
if (reportCurrentPage !== 0) { // called from Reports if (reportCurrentPage !== 0) { // called from Reports
dispatch('FetchReports', reportCurrentPage) dispatch('FetchReports', reportCurrentPage)
} else if (userId.length > 0) { // called from User profile } else if (userId.length > 0) { // called from User profile
dispatch('FetchUserStatuses', { userId, godmode }) dispatch('FetchUserStatuses', { userId, godmode })
} else if (fetchStatusesByInstance) { // called from Statuses by Instance
dispatch('FetchStatusesByInstance')
} else { // called from GroupedReports } else { // called from GroupedReports
dispatch('FetchGroupedReports') dispatch('FetchGroupedReports')
} }

View file

@ -25,7 +25,7 @@
<status <status
:status="status" :status="status"
:show-checkbox="isDesktop" :show-checkbox="isDesktop"
:statuses-args="{ instance: selectedInstance, page, pageSize }" :fetch-statuses-by-instance="true"
@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">