cleaning message/confirm usage

This commit is contained in:
les 2020-10-07 11:12:13 +02:00
parent a67751928c
commit 3616eeefe5
20 changed files with 53 additions and 287 deletions

View file

@ -61,10 +61,10 @@ export default {
this.$root.$confirm = this.open
},
methods: {
open (title, message, options) {
open (message, options) {
this.dialog = true
this.title = title
this.message = message
this.title = option.title || 'Confirm'
this.message = this.$t(message, options)
this.options = Object.assign(this.options, options)
return new Promise((resolve, reject) => {
this.resolve = resolve

View file

@ -98,14 +98,10 @@ export default {
},
methods: {
copyLink () {
this.$root.$message({
message: this.$t('common.feed_url_copied')
})
this.$root.$message('common.feed_url_copied')
},
logout () {
this.$root.$message({
message: this.$t('common.logout_ok')
})
this.$root.$message('common.logout_ok')
this.$auth.logout()
},
async createTrustedInstance () {
@ -123,11 +119,7 @@ export default {
}
this.setSetting({ key: 'trusted_instances', value: this.settings.trusted_instances.concat(trusted_instance) })
} catch (e) {
console.error(e)
this.$root.$message({
type: 'error',
message: e
})
this.$root.$message(e, { color: 'error' })
}
}
}

View file

@ -29,10 +29,11 @@ export default {
}
},
created () {
this.$root.$message = snackbar => {
this.$root.$message = (message, opts) => {
this.active = true
this.message = snackbar.message
this.color = snackbar.color || 'primary'
this.message = this.$t(message, opts)
this.color = opts.color || 'primary'
this.icon = opts.icon || 'md-alert'
}
}
}

View file

@ -2,7 +2,7 @@
v-container
v-card-title {{$t('common.announcements')}}
v-card-subtitle(v-html="$t('admin.announcement_description')")
v-dialog(v-model='dialog' width='800')
v-dialog(v-model='dialog' width='800px')
v-card
v-card-title {{$t('admin.new_announcement')}}
v-card-text
@ -72,18 +72,12 @@ export default {
this.setAnnouncements(cloneDeep(this.announcements.filter(a => a.visible)))
} catch (e) {}
},
remove (announcement) {
this.$root.$confirm(this.$t('admin.delete_announcement_confirm'),
this.$t('common.confirm'), {
confirmButtonText: this.$t('common.ok'),
cancelButtonText: this.$t('common.cancel'),
type: 'error'
})
.then(() => this.$axios.delete(`/announcements/${announcement.id}`))
async remove (announcement) {
const ret = await this.$root.$confirm('admin.delete_announcement_confirm')
if (!ret) return
this.$axios.delete(`/announcements/${announcement.id}`)
.then(() => {
this.$root.$message({
message: this.$t('admin.announcement_remove_ok')
})
this.$root.$message('admin.announcement_remove_ok')
this.announcements = this.announcements.filter(a => a.id !== announcement.id)
})
},

View file

@ -45,13 +45,10 @@ export default {
} catch (e) {}
},
async remove (event) {
const ret = await this.$root.$confirm(this.$t('common.confirm'),
this.$t('event.remove_confirmation'))
const ret = await this.$root.$confirm('event.remove_confirmation')
if (!ret) { return }
await this.$axios.delete(`/event/${event.id}`)
this.$root.$message({
message: this.$t('admin.event_remove_ok')
})
this.$root.$message('admin.event_remove_ok')
}
}
}

View file

@ -124,15 +124,11 @@ export default {
})
this.instance_url = ''
} catch (e) {
this.$root.$message({
type: 'error',
message: e
})
this.$root.$message(e, { color: 'error' })
}
},
async deleteInstance (instance) {
const ret = await this.$root.$confirm(this.$t('common.confirm'),
this.$t('admin.delete_trusted_instance_confirm'))
const ret = await this.$root.$confirm('admin.delete_trusted_instance_confirm')
if (!ret) { return }
this.setSetting({
key: 'trusted_instances',

View file

@ -67,10 +67,10 @@ export default {
computed: mapState(['settings']),
methods: {
async deleteUser (user) {
const ret = await this.$root.$confirm(this.$t('common.confirm'), this.$t('admin.delete_user_confirm'))
const ret = await this.$root.$confirm('admin.delete_user_confirm')
if (!ret) { return }
await this.$axios.delete(`/user/${user.id}`)
this.$root.$message({ message: this.$t('admin.user_remove_ok') })
this.$root.$message('admin.user_remove_ok')
this.users_ = this.users_.filter(u => u.id !== user.id)
},
toggle (user) {
@ -90,16 +90,10 @@ export default {
const user = await this.$axios.$post('/user', this.new_user)
this.new_user = { email: '', is_admin: false }
this.$root.$message({
type: 'success',
message: this.$t('admin.user_create_ok')
})
this.$root.$message('admin.user_create_ok', { color: 'success'})
this.users_.push(user)
} catch (e) {
this.$root.$message({
type: 'error',
message: this.$t(e)
})
this.$root.$message(e, { color: 'error' })
}
}
}

View file

@ -32,7 +32,6 @@ export default {
</script>
<style lang="less">
.v-dialog {
width: unset !important;
max-width: 600px;
max-width: 800px;
}
</style>

View file

@ -205,7 +205,8 @@
"add_link": "Add link",
"footer_links": "Footer links",
"delete_footer_link_confirm": "Sure to remove this link?",
"edit_place": "Edit place"
"edit_place": "Edit place",
"new_announcement": "New announcement"
},
"auth": {
"not_confirmed": "Not confirmed yet...",

View file

@ -88,17 +88,11 @@ export default {
this.$router.push(`/event/${id}`)
},
async confirm (id) {
try {
this.loading = true
await this.$axios.$get(`/event/confirm/${id}`)
this.loading = false
this.$root.$message({
message: this.$t('event.confirmed'),
type: 'success'
})
this.$root.$message('event.confirmed', { color: 'succes' })
this.unconfirmedEvents = this.unconfirmedEvents.filter(e => e.id !== id)
} catch (e) {
}
}
},
head () {

View file

@ -65,7 +65,7 @@ export default {
this.loading = true
await this.$axios.$post('/user/recover', { email: this.email })
this.loading = false
this.$root.$message({ message: this.$t('login.check_email'), color: 'success' })
this.$root.$message('login.check_email', { color: 'success' })
},
async submit (e) {
e.preventDefault()
@ -78,9 +78,9 @@ export default {
data.append('client_id', 'self')
await this.$auth.loginWith('local', { data })
this.loading = false
this.$root.$message({ message: this.$t('login.ok'), color: 'success' })
this.$root.$message('login.ok',{ color: 'success' })
} catch (e) {
this.$root.$message({ message: this.$t('login.error'), color: 'error' })
this.$root.$message('login.error',{ color: 'error' })
this.loading = false
return
}

View file

@ -67,13 +67,11 @@ export default {
const user = await this.$axios.$post('/user/register', this.user)
// this is the first user registered
const first_user = user && user.is_admin && user.is_active
this.$root.$message({
message: first_user ? this.$t('register.first_user') : this.$t('register.complete')
})
this.$root.$message(first_user ? 'register.first_user': 'register.complete')
this.$router.replace('/')
} catch (e) {
const error = get(e, 'response.data.errors[0].message', String(e))
this.$root.$message({ message: this.$t(error), color: 'error' })
this.$root.$message(error, { color: 'error' })
}
this.loading = false
}

View file

@ -25,10 +25,7 @@ export default {
methods: {
...mapActions(['setSetting']),
save () {
this.$root.$message({
type: 'success',
message: this.$t('common.done')
})
this.$root.$message('commmon.done', { color: 'success' })
this.setSetting({ key: 'about', value: this.about })
}
},

View file

@ -447,15 +447,15 @@ export default {
this.updateMeta()
this.$router.replace('/')
this.loading = false
this.$root.$message({ type: 'success', message: this.$auth.loggedIn ? this.$t('event.added') : this.$t('event.added_anon') })
this.$root.$message(this.$auth.loggedIn ? 'event.added' : 'event.added_anon', { color: 'success' })
} catch (e) {
console.error(e.response)
switch (e.request.status) {
case 413:
this.$root.$message({ type: 'error', message: this.$t('event.image_too_big') })
this.$root.$message('event.image_too_big', { color: 'error' })
break
default:
this.$root.$message({ type: 'error', message: e.response.data })
this.$root.$message(e.response.data, { color: 'error' })
}
this.loading = false
}
@ -477,26 +477,5 @@ export default {
.container {
max-width: 1400px;
}
/* #edit_page
i {
font-size: 1.3em;
}
#picker {
max-width: 600px;
}
#edit_page .el-form-item {
display: inline-flex;
}
.el-upload,
.el-upload-dragger {
overflow: hidden;
text-align: center;
margin: 0 auto;
max-width: 80%;
font-size: 2em;
} */
</style>

View file

@ -243,22 +243,22 @@ export default {
},
async blockUser (resource) {
try {
const ret = await this.$root.$confirm(this.$t('common.confirm'), this.$t('admin.user_block_confirm', { user: resource.ap_user.ap_id }))
const ret = await this.$root.$confirm('admin.user_block_confirm', { user: resource.ap_user.ap_id })
if (!ret) { return }
await this.$axios.post('/instances/toggle_user_block', { ap_id: resource.ap_user.ap_id })
this.$root.$message({ message: this.$t('admin.user_blocked', { user: resource.ap_user.ap_id }), type: 'success' })
this.$root.$message('admin.user_blocked', { user: resource.ap_user.ap_id, color: 'success' })
} catch (e) { }
},
async deleteResource (resource) {
try {
const ret = await this.$root.$confirm(this.$t('common.confirm'), this.$t('admin.delete_resource_confirm'))
const ret = await this.$root.$confirm('admin.delete_resource_confirm')
if (!ret) { return }
await this.$axios.delete(`/resources/${resource.id}`)
this.event.resources = this.event.resources.filter(r => r.id !== resource.id)
} catch (e) { }
},
copyLink () {
this.$root.$message({ message: this.$t('common.copied'), type: 'success' })
this.$root.$message('common.copied', { color: 'success' })
},
// TOFIX
resource_filter (value) {
@ -285,163 +285,5 @@ export default {
margin: 0 auto;
max-height: 83vh;
}
}
// time {
// margin: 0rem 0rem 0rem 1rem;
// display: inline-block;
// }
// #arrow {
// position: absolute;
// top: 1em;
// right: 1em;
// }
// .el-header {
// height: auto !important;
// position: sticky;
// padding-top: .4em;
// top: 0px;
// border-bottom: 1px solid lightgray;
// z-index: 1;
// overflow: hidden;
// }
// .embedDialog {
// .el-dialog {
// min-height: 500px;
// max-width: 1000px;
// width: 100%;
// }
// }
// .followDialog {
// .el-dialog {
// min-height: 300px;
// max-width: 600px;
// width: 100%;
// .el-dialog__body {
// word-break: normal !important;
// }
// }
// }
// .head {
// z-index: 1;
// position: sticky;
// top: 0px;
// padding-top: 10px;
// padding-bottom: 10px;
// background-color: white;
// border-bottom: 1px solid #e6e6e6;
// }
// .menu {
// border-right: none;
// background-color: transparent;
// }
// div.menu {
// border-left: 1px solid #e6e6e6;
// p {
// margin: 1rem 0rem 1rem 1rem;
// }
// }
// .title {
// display: table-cell;
// padding-right: 70px;
// height: 2.1em;
// font-size: 1.6rem;
// color: #404246;
// line-height: 1;
// vertical-align: middle;
// }
// pre {
// white-space: pre-line;
// word-break: break-word;
// font-size: 1em;
// font-family: inherit;
// p:empty {
// min-height: 1em;
// }
// // font-family: BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Oxygen,
// // Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, Helvetica, Arial,
// // sans-serif !important;
// }
// .main_image {
// width: 100%;
// transition: height .100s;
// height: auto;
// img {
// // object-fit: contain;
// margin: 0 auto;
// max-height: 88vh;
// }
// .loading {
// display: flex;
// justify-content: center;
// align-items: center;
// font-size: 30px;
// margin: 0 auto;
// height: 100px;
// }
// }
// #resources {
// img {
// max-width: 100%;
// }
// .card-header {
// border-left: 3px solid transparent;
// }
// .card-header:hover {
// border-left: 3px solid #888;
// }
// .invisible {
// visibility: visible !important;
// }
// .disabled {
// opacity: 0.5;
// }
// .previewImage {
// display: flex;
// flex-flow: wrap;
// justify-content: space-evenly;
// img {
// margin-left: 5px;
// margin-top: 5px;
// object-fit: cover;
// min-height: 100px;
// max-width: 45%;
// border-radius: 5px;
// border: 1px solid #ccc;
// }
// }
// }
// .nextprev {
// font-size: 10px;
// margin-bottom: 5px;
// }
// }
// @media only screen and (max-width: 768px) {
// #eventDetail {
// .menu {
// border: 0px !important;
// }
// .title {
// // font-size: 1.1em;
// line-height: 1.4em;
// color: black;
// }
// }
// }
</style>

View file

@ -28,7 +28,7 @@ export default {
},
methods: {
copyLink () {
this.$root.$message({ message: this.$t('common.copied'), type: 'success' })
this.$root.$message('common.copied', { color: 'success' })
}
}
}

View file

@ -129,8 +129,7 @@ export default {
},
methods: {
copyLink () {
// Message({ message: this.$t('common.copied'), type: 'success', showClose: true })
this.$root.$message({ message: this.$t('common.feed_url_copied') })
this.$root.$message('common.feed_url_copied')
},
add_notification () {
if (!this.notification.email) {

View file

@ -38,15 +38,10 @@ export default {
async change_password () {
try {
await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password })
this.$root.$message({
message: this.$t('common.password_updated')
})
this.$root.$message('common.password_updated')
this.$router.replace('/login')
} catch (e) {
this.$root.$message({
type: 'warning',
message: e
})
this.$root.$message(e, { color: 'warning' })
}
}
},

View file

@ -34,16 +34,10 @@ export default {
async change_password () {
try {
await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password })
this.$root.$message({
type: 'success',
message: this.$t('common.password_updated')
})
this.$root.$message('common.password_updated', { color: 'success' })
this.$router.replace('/login')
} catch (e) {
this.$root.$message({
type: 'warning',
message: e
})
this.$root.$message(e, { color: 'warning' })
}
}
}

View file

@ -33,16 +33,10 @@ export default {
async change_password () {
try {
await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password })
this.$root.$message({
type: 'success',
message: this.$t('common.password_updated')
})
this.$root.$message('common.password_updated', { color: 'succes' })
this.$router.replace('/login')
} catch (e) {
this.$root.$message({
type: 'warning',
message: e
})
this.$root.$message(e, { color: 'warning' })
}
}
}