2020-07-14 23:58:34 +02:00
< template >
2020-07-17 11:25:50 +02:00
< div >
2020-07-14 23:58:34 +02:00
< div v-if = "enabled" >
< v-toolbar
2020-07-16 09:11:12 +02:00
color = "orange darken-3"
2020-07-14 23:58:34 +02:00
dark
flat
>
2020-07-22 10:00:12 +02:00
< v-toolbar-title > { { $store . state . data . name } } < / v-toolbar-title >
2020-07-14 23:58:34 +02:00
< v-spacer > < / v-spacer >
2020-07-16 09:11:12 +02:00
< v-btn
outlined
class = "mr-3"
: disabled = "$store.state.delegate.validationState === 'pending'"
@ click = "openPublishModal()"
>
2020-07-14 23:58:34 +02:00
Publier
< / v-btn >
2020-07-15 22:31:02 +02:00
< v-menu bottom close -on -content -click >
< template v -slot : activator = "{ on, attrs }" >
< v-btn
class = "mr-2"
icon
v - bind = "attrs"
v - on = "on"
>
< v-icon > more _vert < / v-icon >
< / v-btn >
< / template >
< v-list >
2020-07-23 12:42:43 +02:00
< v-list-item @click ="openPreviewModal()" >
< v-list-item-title > Prévisualiser votre page < / v-list-item-title >
< / v-list-item >
2020-07-15 22:31:02 +02:00
< v-list-item @click ="goToPage()" >
< v-list-item-title > Ouvrir la page publique < / v-list-item-title >
< / v-list-item >
2020-08-25 15:09:40 +02:00
< v-list-item @click ="openDestroyModal()" >
< v-list-item-title > Supprimer votre association < / v-list-item-title >
< / v-list-item >
2020-07-15 22:31:02 +02:00
< v-list-item @click ="logout()" >
< v-list-item-title > Se déconnecter < / v-list-item-title >
< / v-list-item >
< / v-list >
< / v-menu >
<!--
< v-btn icon @click ="goToPage()" >
< v-icon > open _in _new < / v-icon >
< / v-btn >
2020-07-14 23:58:34 +02:00
< v-btn icon @click ="logout()" >
< v-icon > exit _to _app < / v-icon >
2020-07-15 22:31:02 +02:00
< / v-btn > -- >
2020-07-14 23:58:34 +02:00
< template v -slot : extension >
< v-tabs
v - model = "tab"
centered
show - arrows
2020-07-16 09:11:12 +02:00
slider - color = "accent"
2020-07-14 23:58:34 +02:00
ref = "tabs"
>
< v-tab @click ="navigate('DelegateMain')" >
2020-07-17 11:25:50 +02:00
Présentation
2020-07-14 23:58:34 +02:00
< / v-tab >
< v-tab @click ="navigate('DelegateGallery')" >
Images / vidéos
< / v-tab >
2020-07-18 00:10:58 +02:00
< v-tab @click ="navigate('DelegateDescription')" >
2020-07-17 11:25:50 +02:00
Description
2020-07-14 23:58:34 +02:00
< / v-tab >
< v-tab @click ="navigate('DelegateSchedule')" >
Horaires
< / v-tab >
< v-tab @click ="navigate('DelegatePricing')" >
Tarifs
< / v-tab >
< v-tab @click ="navigate('DelegateContact')" >
Contact
< / v-tab >
< / v-tabs >
< / template >
< / v-toolbar >
< v-container fluid >
< v-row class = "justify-center" >
2020-07-15 15:21:53 +02:00
< v-col cols = "12" sm = "12" md = "8" lg = "7" xl = "5" >
2020-07-16 09:11:12 +02:00
< v-alert
v - if = "$store.state.delegate.validationState === 'rejected'"
prominent
2020-07-25 12:34:20 +02:00
dense
2020-07-16 09:11:12 +02:00
type = "info"
border = "left"
color = "error" >
< v-row align = "center" >
< v-col class = "grow" >
2020-07-25 12:34:20 +02:00
Les changements apportés ont été refusés , vous devez donc les modifier
2020-07-16 09:11:12 +02:00
< / v-col >
< v-col class = "shrink" >
< v-btn outlined @ click = "rejectionDetailsModal = true" > Pourquoi ? < / v-btn >
< / v-col >
< / v-row >
< / v-alert >
< v-alert
v - if = "$store.state.delegate.validationState === 'pending'"
2020-08-03 18:18:03 +02:00
dense
2020-07-16 09:11:12 +02:00
type = "error"
color = "error" >
2020-08-03 18:18:03 +02:00
Votre association est verrouillée car elle est en attente d ' une vérification , même si vous pouvez faire des changements il sera impossible de les sauvegarder .
2020-07-16 09:11:12 +02:00
< / v-alert >
2020-07-14 23:58:34 +02:00
< router-view > < / router-view >
< div class = "mt-3 d-flex justify-end" >
2020-07-16 09:11:12 +02:00
< v-btn
color = "success"
: loading = "isSaving"
@ click = "save()"
: disabled = "$store.state.delegate.validationState === 'pending'"
>
< v-icon left >
check _circle
< / v-icon >
Sauvegarder
< / v-btn >
2020-07-14 23:58:34 +02:00
< / div >
< / v-col >
< / v-row >
< / v-container >
< / div >
< div v-if = "!enabled && loading" class="d-flex align-center justify-center mt-10 pt-10" >
< v-progress-circular indeterminate color = "primary" / >
< / div >
< div v-if = "!enabled && !loading" class="d-flex align-center justify-center mt-5" >
< v-card max -width = " 600 " >
< v-card-title >
Connexion au panel de modification
< / v-card-title >
< v-card-text >
< p >
2020-07-17 11:25:50 +02:00
Vous n 'êtes pas encore connecté à l' interface de modification de votre association , veuillez copier - coller la clé qui vous a été envoyé par e - mail dans la boîte ci - dessous .
2020-07-14 23:58:34 +02:00
< / p >
2020-07-15 15:21:53 +02:00
< v-text-field
2020-07-17 11:25:50 +02:00
label = "Clé"
2020-07-16 17:42:49 +02:00
autofocus
v - model = "token"
: type = "showPassword ? 'text' : 'password'"
: append - icon = "showPassword ? 'mdi-eye' : 'mdi-eye-off'"
v - on : keydown . enter = "submitForm()"
@ click : append = "showPassword = !showPassword" / >
2020-07-14 23:58:34 +02:00
< / v-card-text >
< v-card-actions >
< v-spacer / >
< v-btn
color = "primary"
@ click = "submitForm()"
: disabled = "token === ''" >
Se connecter
< / v-btn >
< / v-card-actions >
< / v-card >
< / div >
2020-07-16 09:11:12 +02:00
< v-dialog v-model = "publishModal" max-width="700px" >
< v-card >
2020-07-15 22:31:02 +02:00
< v-card-title >
2020-07-16 09:11:12 +02:00
Demander une vérification humaine
2020-07-15 22:31:02 +02:00
< / v-card-title >
< v-card-text >
2020-07-16 09:11:12 +02:00
< div v-if = "canPublish" >
< p >
2020-08-03 18:18:03 +02:00
Avant que vos changements ne soient publiés et accessibles à l ' adresse < a :href = "$store.state.delegate.publicUrl" > { { $store . state . delegatePublicUrl } } < / a > , ils doivent être vérifiés par la personne en charge de la publication .
2020-07-16 09:11:12 +02:00
< / p >
< p >
Veillez à ne pas demander de vérification manuelle trop souvent : veuillez limiter vos demandes .
Nous vous demandons de bien relire vos différentes modifications apportés afin de corriger d ' éventuelles erreurs
< / p >
< p >
La vérification étant manuelle et prenant du temps humain nous vous demandons de bien vouloir être patient , le résultat de cette vérification sera notifé à l ' adresse { { this . $store . state . delegate . email } } .
< / p >
< v-alert type = "warning" class = "mb-0" >
2020-08-03 18:18:03 +02:00
Attention , l 'action de demander une vérification entraîne le verouillage de l' association , il ne sera plus possible de faire des modifications sur cette interface jusqu ' a ce que vos changements soient validés ou rejetés .
2020-07-16 09:11:12 +02:00
< / v-alert >
< / div >
< v-alert v -else type = "error" class = "mt-2 mb-0" >
Vous ne pouvez pas être publié car vous n ' avez pas remplis les champs requis
< / v-alert >
2020-07-15 22:31:02 +02:00
< / v-card-text >
< v-card-actions >
2020-07-16 17:42:49 +02:00
< v-btn text @ click = "publishModal = false" > Fermer < / v-btn >
2020-07-15 22:31:02 +02:00
< v-spacer / >
2020-07-16 17:42:49 +02:00
< v-btn
color = "primary"
text
: disabled = "!canPublish"
: loading = "askingApprovalLoading"
@ click = "askApproval()" >
Demander une vérification
< / v-btn >
2020-07-15 22:31:02 +02:00
< / v-card-actions >
< / v-card >
< / v-dialog >
2020-07-16 09:11:12 +02:00
< v-dialog v-model = "rejectionDetailsModal" max-width="700px" >
< v-card >
< v-card-title >
Détails sur le refus de publication
< / v-card-title >
< v-card-text >
< p >
Vos changements ont été refusés , veuillez prendre connaissance de la raison :
< / p >
< blockquote >
{ { $store . state . delegate . rejectionDescription } }
< / blockquote >
< / v-card-text >
< v-card-actions >
< v-spacer / >
< v-btn color = "primary" text @ click = "rejectionDetailsModal = false" > Fermer < / v-btn >
< / v-card-actions >
< / v-card >
< / v-dialog >
2020-08-25 15:09:40 +02:00
< v-dialog v-model = "destroyModal" max-width="600px" >
< v-card >
< v-card-title >
Êtes vous sur de vouloir supprimer votre association ?
< / v-card-title >
< v-card-text >
< p >
< b > Attention , ceci est une action pottentiellement dangereuse ! < / b >
< / p >
< p >
La suppression de votre association entraine une supression < b > DEFINITIVE < / b > de manière < b > IMMEDIATE < / b > de toute les données associés à votre association ( textes , images , vidéos ... ) .
< / p >
< p >
Cette action est < b > IRREVERSIBLE < / b > .
< / p >
< / v-card-text >
< v-card-actions >
< div style = "display:flex; justify-content:space-between; flex-wrap: wrap; width: 100%" >
< v-btn color = "primary" text @ click = "destroyModal = false" > Fermer < / v-btn >
< v-btn
: loading = "destroyLoading"
color = "error" text
@ click = "destroy" >
je comprends , supprimer
< / v-btn >
< / div >
< / v-card-actions >
< / v-card >
< / v-dialog >
2020-07-23 12:42:43 +02:00
< Preview
ref = "preview"
: enabled = "previewModal"
: id = "$store.state.delegate._id"
: slug = "$store.state.delegate.slug"
2020-07-25 12:34:20 +02:00
: dialogTitle = "'Prévisualisation'"
2020-07-23 12:42:43 +02:00
@ close = "previewModal = false"
/ >
2020-07-17 11:25:50 +02:00
< / div >
2020-07-14 23:58:34 +02:00
< / template >
< script >
2020-07-23 12:42:43 +02:00
import Preview from '../components/Preview'
2020-07-14 23:58:34 +02:00
export default {
2020-07-23 12:42:43 +02:00
components : {
Preview
} ,
2020-07-14 23:58:34 +02:00
data : ( ) => ( {
enabled : false ,
loading : true ,
token : '' ,
loadingHandle : null ,
isSaving : false ,
2020-07-15 22:31:02 +02:00
tab : 0 ,
slug : '' ,
canPublish : false ,
2020-07-16 09:11:12 +02:00
publishModal : false ,
askingApprovalLoading : false ,
2020-07-16 17:42:49 +02:00
rejectionDetailsModal : false ,
2020-07-23 12:42:43 +02:00
showPassword : false ,
2020-08-25 15:09:40 +02:00
previewModal : false ,
destroyModal : false ,
destroyLoading : false
2020-07-14 23:58:34 +02:00
} ) ,
created ( ) {
this . init ( )
} ,
2020-07-15 15:21:53 +02:00
watch : {
2020-07-15 22:31:02 +02:00
$route ( to ) {
2020-07-15 15:21:53 +02:00
this . selectRoute ( to )
}
} ,
2020-07-14 23:58:34 +02:00
mounted ( ) {
2020-07-22 10:00:12 +02:00
this . $store . commit ( 'SET_TITLE' , "Modification de l'association" )
2020-07-15 15:21:53 +02:00
this . selectRoute ( this . $route )
2020-07-14 23:58:34 +02:00
/ * *
* this is very ugly I kown
* /
// setTimeout(() => {
// window.dispatchEvent(new Event('resize'))
// }, 100)
// const i = setInterval(() => {
// window.dispatchEvent(new Event('resize'))
// }, 500)
// setTimeout(() => {
// window.dispatchEvent(new Event('resize'))
// }, 1000)
// setTimeout(() => {
// clearInterval(i)
// }, 3000)
} ,
methods : {
2020-07-23 12:42:43 +02:00
openPreviewModal ( ) {
this . save ( false ) . then ( ( ) => {
this . $refs . preview . reload ( )
this . previewModal = true
} ) . catch ( ( err ) => {
console . log ( err )
} )
} ,
2020-07-15 15:21:53 +02:00
selectRoute ( route ) {
const path = route . path . split ( '/' )
const name = path [ path . length - 1 ]
2020-07-18 00:10:58 +02:00
const routes = [ '' , 'gallery' , 'description' , 'schedule' , 'pricing' , 'contact' ]
2020-07-15 15:21:53 +02:00
this . tab = routes . indexOf ( name )
} ,
2020-07-14 23:58:34 +02:00
init ( ) {
this . enabled = false
this . loadingHandle = setTimeout ( ( ) => {
this . loading = true
} , 300 )
let inUrl = false
let delegateToken = ( new URL ( window . location ) ) . searchParams . get ( 'delegateToken' )
if ( this . token !== '' ) {
delegateToken = this . token
}
if ( delegateToken === null ) {
delegateToken = window . localStorage . getItem ( 'delegateToken' )
if ( delegateToken === null || delegateToken === 'null' ) {
clearTimeout ( this . loadingHandle )
this . loading = false
return
}
} else {
inUrl = true
}
2020-07-29 23:23:20 +02:00
// get the size
// this.$apitator.get('/delegate/size', { withAuth: true }).then(res => {
// console.log(res.data.data)
// })
2020-07-14 23:58:34 +02:00
this . $apitator . setAuthorizationToken ( delegateToken )
// verify the token
this . $apitator . get ( '/delegate' , { withAuth : true } ) . then ( res => {
window . localStorage . setItem ( 'delegateToken' , delegateToken )
if ( this . token !== '' ) {
this . $router . push ( { query : { delegateToken : this . token } } )
}
clearTimeout ( this . loadingHandle )
this . loading = false
this . enabled = true
2020-07-15 15:21:53 +02:00
const organization = res . data . data . organization
2020-07-15 22:31:02 +02:00
const proposedVersion = res . data . data . organization . proposedVersion
2020-07-15 15:21:53 +02:00
const tags = res . data . data . tags
2020-07-16 09:11:12 +02:00
this . $store . commit ( 'SET_DELEGATE' , {
2020-07-23 12:42:43 +02:00
_id : organization . _id ,
2020-07-16 09:11:12 +02:00
adminName : organization . adminName ,
email : organization . email ,
2020-07-23 12:42:43 +02:00
slug : organization . slugs [ organization . slugs . length - 1 ] ,
2020-07-19 15:27:26 +02:00
publicUrl : process . env . VUE _APP _BASE _URL + '/association/' + organization . slugs [ organization . slugs . length - 1 ] ,
2020-07-16 09:11:12 +02:00
validationState : organization . validationState ,
rejectionDescription : organization . rejectionDescription
} )
2020-07-15 22:31:02 +02:00
this . $store . commit ( 'SET_DATA' , proposedVersion )
2020-07-15 15:21:53 +02:00
this . $store . commit ( 'SET_TAGS' , tags )
2020-07-14 23:58:34 +02:00
this . $nextTick ( ( ) => {
setTimeout ( this . $refs . tabs . callSlider , 200 )
setTimeout ( this . $refs . tabs . callSlider , 400 )
setTimeout ( this . $refs . tabs . callSlider , 500 )
setTimeout ( this . $refs . tabs . callSlider , 1000 )
setTimeout ( this . $refs . tabs . callSlider , 1500 )
} )
2020-07-15 22:31:02 +02:00
} ) . catch ( err => {
console . log ( err )
2020-07-14 23:58:34 +02:00
clearTimeout ( this . loadingHandle )
this . loading = false
if ( this . token !== '' || inUrl ) {
this . $store . commit ( 'ADD_ALERT' , {
color : 'error' ,
2020-07-17 11:25:50 +02:00
text : 'Clé invalide !'
2020-07-14 23:58:34 +02:00
} )
}
} )
} ,
logout ( ) {
window . localStorage . removeItem ( 'delegateToken' )
this . $router . push ( '/' )
} ,
2020-07-23 12:42:43 +02:00
save ( showSuccessAlert = true ) {
return new Promise ( ( resolve , reject ) => {
this . isSaving = true
const data = this . $store . state . data
this . $apitator . put ( '/delegate' , data , { withAuth : true } ) . then ( ( ) => {
this . isSaving = false
if ( showSuccessAlert ) {
this . $store . commit ( 'ADD_ALERT' , {
color : 'success' ,
text : 'Vos changements ont été sauvegardés !'
} )
}
resolve ( )
} ) . catch ( err => {
2020-07-29 23:23:20 +02:00
console . log ( err . response )
if ( err . response != null ) {
console . log ( err . response . data )
console . log ( err . response . code )
}
2020-07-23 12:42:43 +02:00
this . isSaving = false
2020-07-29 23:23:20 +02:00
if ( err . response != null && err . response . status === 413 ) {
this . $store . commit ( 'ADD_ALERT' , {
color : 'error' ,
text : 'Le contenu renseigné est trop grand, vous devez le réduire'
} )
} else {
this . $store . commit ( 'ADD_ALERT' , {
color : 'error' ,
text : 'Impossible de sauvegarder vos changements'
} )
}
2020-07-23 12:42:43 +02:00
reject ( err )
2020-07-14 23:58:34 +02:00
} )
} )
} ,
navigate ( routeName ) {
if ( routeName !== this . $route . name ) {
this . $router . push ( { name : routeName } )
}
} ,
submitForm ( ) {
if ( this . token !== '' ) {
this . init ( )
}
2020-07-15 22:31:02 +02:00
} ,
goToPage ( ) {
2020-07-18 00:10:58 +02:00
window . open ( this . $store . state . delegate . publicUrl , '_blank' ) . focus ( )
2020-07-15 22:31:02 +02:00
} ,
openPublishModal ( ) {
2020-07-23 12:42:43 +02:00
const open = ( ) => {
// compute if the user can ask approval
2020-07-23 13:14:31 +02:00
// check against rules in the store
const validation = [ ]
const keys = Object . keys ( this . $store . state . mainRules )
keys . forEach ( key => {
let value = ''
if ( key . indexOf ( 'contacts.' ) !== - 1 ) {
value = this . $store . state . data . contacts [ key . replace ( 'contacts.' , '' ) ]
2020-07-23 12:42:43 +02:00
} else {
2020-07-23 13:14:31 +02:00
value = this . $store . state . data [ key ]
2020-07-23 12:42:43 +02:00
}
2020-07-23 13:14:31 +02:00
const rules = this . $store . state . mainRules [ key ]
validation . push ( rules . map ( r => r ( value ) ) . filter ( r => r === true ) . length === rules . length )
2020-07-23 12:42:43 +02:00
} )
2020-07-23 13:14:31 +02:00
validation . push ( this . $store . state . data . thumbnail . location . length > 1 )
const isValid = validation . filter ( v => v ) . length === validation . length
if ( isValid ) {
this . publishModal = true
this . save ( false ) . catch ( ( err ) => {
console . log ( err )
} )
} else {
this . $store . commit ( 'ADD_ALERT' , {
color : 'error' ,
text : 'Vous devez remplir tout les champs requis afin de publier'
} )
if ( this . $route . name !== 'DelegateMain' ) {
this . $store . commit ( 'ON_MAIN_READY' , ( ) => {
return true
} )
this . $router . push ( { name : 'DelegateMain' } , ( ) => {
this . $store . commit ( 'VALIDATE_MAIN' )
} )
} else {
this . $store . commit ( 'VALIDATE_MAIN' )
}
this . publishModal = false
}
this . canPublish = isValid
2020-07-23 12:42:43 +02:00
}
this . $store . state . validateMain = false
2020-07-23 13:14:31 +02:00
open ( )
2020-07-15 22:31:02 +02:00
} ,
askApproval ( ) {
2020-07-16 09:11:12 +02:00
this . askingApprovalLoading = true
2020-07-16 17:42:49 +02:00
this . $apitator . post ( '/delegate/submit' , { } , { withAuth : true } ) . then ( ( ) => {
2020-07-16 09:11:12 +02:00
this . publishModal = false
this . askingApprovalLoading = false
this . $store . commit ( 'SET_DELEGATE' , { validationState : 'pending' } )
this . $store . commit ( 'ADD_ALERT' , {
color : 'success' ,
text : 'Les changements vont êtres soumis à une vérification manuelle'
} )
} ) . catch ( err => {
console . log ( err . data )
2020-07-16 17:42:49 +02:00
this . askingApprovalLoading = false
2020-07-16 09:11:12 +02:00
this . $store . commit ( 'ADD_ALERT' , {
color : 'error' ,
text : "Impossible de soumettre l'association"
} )
} )
2020-08-25 15:09:40 +02:00
} ,
openDestroyModal ( ) {
this . destroyModal = true
} ,
destroy ( ) {
this . destroyLoading = true
this . $apitator . delete ( '/delegate/' , { withAuth : true } ) . then ( ( ) => {
this . destroyModal = false
this . destroyLoading = false
this . $store . commit ( 'ADD_ALERT' , {
color : 'success' ,
text : "Votre association vient d'être supprimé, bonne continuation!"
} )
this . logout ( )
} ) . catch ( err => {
console . error ( err )
this . destroyLoading = false
this . $store . commit ( 'ADD_ALERT' , {
color : 'error' ,
text : "Impossible de supprimer l'association"
} )
} )
2020-07-14 23:58:34 +02:00
}
}
}
< / script >