See #890: added feedback when updating user quota, permissions and report category
This commit is contained in:
parent
43dfab9a82
commit
24093a12f1
|
@ -0,0 +1,45 @@
|
||||||
|
<template>
|
||||||
|
<span class="feedback" v-if="isLoading || isDone">
|
||||||
|
<span v-if="isLoading" :class="['ui', 'active', size, 'inline', 'loader']"></span>
|
||||||
|
<i v-if="isDone" :class="['green', size, 'check', 'icon']"></i>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {hashCode, intToRGB} from '@/utils/color'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
isLoading: {type: Boolean, required: true},
|
||||||
|
size: {type: String, default: 'small'},
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
timer: null,
|
||||||
|
isDone: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
destroyed () {
|
||||||
|
if (this.timer) {
|
||||||
|
clearTimeout(this.timer)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isLoading (v) {
|
||||||
|
let self = this
|
||||||
|
if (v && this.timer) {
|
||||||
|
clearTimeout(this.timer)
|
||||||
|
}
|
||||||
|
if (v) {
|
||||||
|
this.isDone = false
|
||||||
|
} else {
|
||||||
|
this.isDone = true
|
||||||
|
this.timer = setTimeout(() => {
|
||||||
|
self.isDone = false
|
||||||
|
}, (2000));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -56,4 +56,8 @@ import CollapseLink from '@/components/common/CollapseLink'
|
||||||
|
|
||||||
Vue.component('collapse-link', CollapseLink)
|
Vue.component('collapse-link', CollapseLink)
|
||||||
|
|
||||||
|
import ActionFeedback from '@/components/common/ActionFeedback'
|
||||||
|
|
||||||
|
Vue.component('action-feedback', ActionFeedback)
|
||||||
|
|
||||||
export default {}
|
export default {}
|
||||||
|
|
|
@ -32,9 +32,11 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<report-category-dropdown
|
<report-category-dropdown
|
||||||
class="field"
|
|
||||||
:value="obj.type"
|
:value="obj.type"
|
||||||
@input="update({type: $event})"></report-category-dropdown>
|
@input="update({type: $event})">
|
||||||
|
 
|
||||||
|
<action-feedback :is-loading="updating.type"></action-feedback>
|
||||||
|
</report-category-dropdown>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -225,6 +227,7 @@ import NoteForm from '@/components/manage/moderation/NoteForm'
|
||||||
import NotesThread from '@/components/manage/moderation/NotesThread'
|
import NotesThread from '@/components/manage/moderation/NotesThread'
|
||||||
import ReportCategoryDropdown from '@/components/moderation/ReportCategoryDropdown'
|
import ReportCategoryDropdown from '@/components/moderation/ReportCategoryDropdown'
|
||||||
import entities from '@/entities'
|
import entities from '@/entities'
|
||||||
|
import {setUpdate} from '@/utils'
|
||||||
import showdown from 'showdown'
|
import showdown from 'showdown'
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,6 +253,9 @@ export default {
|
||||||
markdown: new showdown.Converter(),
|
markdown: new showdown.Converter(),
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isCollapsed: false,
|
isCollapsed: false,
|
||||||
|
updating: {
|
||||||
|
type: false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -343,11 +349,15 @@ export default {
|
||||||
let url = `manage/moderation/reports/${this.obj.uuid}/`
|
let url = `manage/moderation/reports/${this.obj.uuid}/`
|
||||||
let self = this
|
let self = this
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
|
setUpdate(payload, this.updating, true)
|
||||||
axios.patch(url, payload).then((response) => {
|
axios.patch(url, payload).then((response) => {
|
||||||
self.$emit('updated', payload)
|
self.$emit('updated', payload)
|
||||||
|
Object.assign(self.obj, payload)
|
||||||
self.isLoading = false
|
self.isLoading = false
|
||||||
|
setUpdate(payload, self.updating, false)
|
||||||
}, error => {
|
}, error => {
|
||||||
self.isLoading = false
|
self.isLoading = false
|
||||||
|
setUpdate(payload, self.updating, false)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
resolve (v) {
|
resolve (v) {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<select class="ui dropdown" :value="value" @change="$emit('input', $event.target.value)">
|
<select class="ui dropdown" :value="value" @change="$emit('input', $event.target.value)">
|
||||||
<option :value="option.value" v-for="option in allCategories">{{ option.label }}</option>
|
<option :value="option.value" v-for="option in allCategories">{{ option.label }}</option>
|
||||||
</select>
|
</select>
|
||||||
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
import lodash from '@/lodash'
|
||||||
|
|
||||||
|
export function setUpdate(obj, statuses, value) {
|
||||||
|
let updatedKeys = lodash.keys(obj)
|
||||||
|
updatedKeys.forEach((k) => {
|
||||||
|
statuses[k] = value
|
||||||
|
})
|
||||||
|
}
|
|
@ -174,6 +174,7 @@
|
||||||
class="ui search selection dropdown">
|
class="ui search selection dropdown">
|
||||||
<option v-for="p in allPermissions" :value="p.code">{{ p.label }}</option>
|
<option v-for="p in allPermissions" :value="p.code">{{ p.label }}</option>
|
||||||
</select>
|
</select>
|
||||||
|
<action-feedback :is-loading="updating.permissions"></action-feedback>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -308,8 +309,9 @@
|
||||||
name="quota"
|
name="quota"
|
||||||
type="number" />
|
type="number" />
|
||||||
<div class="ui basic label">
|
<div class="ui basic label">
|
||||||
<translate translate-context="Content/*/*/Unit">MB</translate>
|
<translate translate-context="Content/*/*/Unit">MB</translate> 
|
||||||
</div>
|
</div>
|
||||||
|
<action-feedback class="ui basic label" size="tiny" :is-loading="updating.upload_quota"></action-feedback>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -403,6 +405,10 @@ export default {
|
||||||
stats: null,
|
stats: null,
|
||||||
showPolicyForm: false,
|
showPolicyForm: false,
|
||||||
permissions: [],
|
permissions: [],
|
||||||
|
updating: {
|
||||||
|
permissions: false,
|
||||||
|
upload_quota: false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -457,6 +463,8 @@ export default {
|
||||||
if (toNull && !newValue) {
|
if (toNull && !newValue) {
|
||||||
newValue = null
|
newValue = null
|
||||||
}
|
}
|
||||||
|
let self = this
|
||||||
|
this.updating[attr] = true
|
||||||
let params = {}
|
let params = {}
|
||||||
if (attr === "permissions") {
|
if (attr === "permissions") {
|
||||||
params["permissions"] = {}
|
params["permissions"] = {}
|
||||||
|
@ -471,12 +479,14 @@ export default {
|
||||||
logger.default.info(
|
logger.default.info(
|
||||||
`${attr} was updated succcessfully to ${newValue}`
|
`${attr} was updated succcessfully to ${newValue}`
|
||||||
)
|
)
|
||||||
|
self.updating[attr] = false
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
logger.default.error(
|
logger.default.error(
|
||||||
`Error while setting ${attr} to ${newValue}`,
|
`Error while setting ${attr} to ${newValue}`,
|
||||||
error
|
error
|
||||||
)
|
)
|
||||||
|
self.updating[attr] = false
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue