bugs fixes
This commit is contained in:
parent
419e6a1a71
commit
46953da4cc
7 changed files with 131 additions and 62 deletions
|
|
@ -29,6 +29,9 @@
|
|||
</template>
|
||||
|
||||
<v-list>
|
||||
<v-list-item @click="openPreviewModal()">
|
||||
<v-list-item-title>Prévisualiser votre page</v-list-item-title>
|
||||
</v-list-item>
|
||||
<v-list-item @click="goToPage()">
|
||||
<v-list-item-title>Ouvrir la page publique</v-list-item-title>
|
||||
</v-list-item>
|
||||
|
|
@ -205,11 +208,24 @@
|
|||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<Preview
|
||||
ref="preview"
|
||||
:enabled="previewModal"
|
||||
:id="$store.state.delegate._id"
|
||||
:slug="$store.state.delegate.slug"
|
||||
:dialogTitle="'Prévisualiser votre page publique'"
|
||||
@close="previewModal = false"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Preview from '../components/Preview'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Preview
|
||||
},
|
||||
data: () => ({
|
||||
enabled: false,
|
||||
loading: true,
|
||||
|
|
@ -222,7 +238,8 @@ export default {
|
|||
publishModal: false,
|
||||
askingApprovalLoading: false,
|
||||
rejectionDetailsModal: false,
|
||||
showPassword: false
|
||||
showPassword: false,
|
||||
previewModal: false
|
||||
}),
|
||||
created () {
|
||||
this.init()
|
||||
|
|
@ -252,6 +269,14 @@ export default {
|
|||
// }, 3000)
|
||||
},
|
||||
methods: {
|
||||
openPreviewModal () {
|
||||
this.save(false).then(() => {
|
||||
this.$refs.preview.reload()
|
||||
this.previewModal = true
|
||||
}).catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
selectRoute (route) {
|
||||
const path = route.path.split('/')
|
||||
const name = path[path.length - 1]
|
||||
|
|
@ -295,8 +320,10 @@ export default {
|
|||
const proposedVersion = res.data.data.organization.proposedVersion
|
||||
const tags = res.data.data.tags
|
||||
this.$store.commit('SET_DELEGATE', {
|
||||
_id: organization._id,
|
||||
adminName: organization.adminName,
|
||||
email: organization.email,
|
||||
slug: organization.slugs[organization.slugs.length - 1],
|
||||
publicUrl: process.env.VUE_APP_BASE_URL + '/association/' + organization.slugs[organization.slugs.length - 1],
|
||||
validationState: organization.validationState,
|
||||
rejectionDescription: organization.rejectionDescription
|
||||
|
|
@ -326,41 +353,47 @@ export default {
|
|||
window.localStorage.removeItem('delegateToken')
|
||||
this.$router.push('/')
|
||||
},
|
||||
save () {
|
||||
this.isSaving = true
|
||||
const data = this.$store.state.data
|
||||
data.pricing = data.pricing.map(i => {
|
||||
delete i._id
|
||||
return i
|
||||
})
|
||||
data.schedule = data.schedule.map(i => {
|
||||
delete i._id
|
||||
if (Array.isArray(i.when) && i.when.length > 0) {
|
||||
i.when = i.when.map(w => {
|
||||
delete w._id
|
||||
return w
|
||||
save (showSuccessAlert = true) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.isSaving = true
|
||||
const data = this.$store.state.data
|
||||
data.pricing = data.pricing.map(i => {
|
||||
delete i._id
|
||||
return i
|
||||
})
|
||||
data.schedule = data.schedule.map(i => {
|
||||
delete i._id
|
||||
if (Array.isArray(i.when) && i.when.length > 0) {
|
||||
i.when = i.when.map(w => {
|
||||
delete w._id
|
||||
return w
|
||||
})
|
||||
}
|
||||
return i
|
||||
})
|
||||
if (Array.isArray(data.contacts.peoples)) {
|
||||
data.contacts.peoples = data.contacts.peoples.map(p => {
|
||||
delete p._id
|
||||
return p
|
||||
})
|
||||
}
|
||||
return i
|
||||
})
|
||||
if (Array.isArray(data.contacts.peoples)) {
|
||||
data.contacts.peoples = data.contacts.peoples.map(p => {
|
||||
delete p._id
|
||||
return p
|
||||
})
|
||||
}
|
||||
this.$apitator.put('/delegate', data, { withAuth: true }).then(() => {
|
||||
this.isSaving = false
|
||||
this.$store.commit('ADD_ALERT', {
|
||||
color: 'success',
|
||||
text: 'Vos changements ont été sauvegardés !'
|
||||
})
|
||||
}).catch(err => {
|
||||
console.log(err.data)
|
||||
this.isSaving = false
|
||||
this.$store.commit('ADD_ALERT', {
|
||||
color: 'error',
|
||||
text: 'Impossible de sauvegarder vos changements'
|
||||
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 => {
|
||||
console.log(err.data)
|
||||
this.isSaving = false
|
||||
this.$store.commit('ADD_ALERT', {
|
||||
color: 'error',
|
||||
text: 'Impossible de sauvegarder vos changements'
|
||||
})
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
|
@ -378,20 +411,34 @@ export default {
|
|||
window.open(this.$store.state.delegate.publicUrl, '_blank').focus()
|
||||
},
|
||||
openPublishModal () {
|
||||
// compute if the user can ask approval
|
||||
this.$store.commit('VALIDATE_MAIN', isValid => {
|
||||
if (isValid) {
|
||||
this.publishModal = true
|
||||
this.save()
|
||||
} else {
|
||||
this.$store.commit('ADD_ALERT', {
|
||||
color: 'error',
|
||||
text: 'Vous devez remplir tout les champs requis afin de publier'
|
||||
})
|
||||
this.publishModal = false
|
||||
}
|
||||
this.canPublish = isValid
|
||||
const open = () => {
|
||||
// compute if the user can ask approval
|
||||
this.$store.commit('VALIDATE_MAIN', isValid => {
|
||||
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'
|
||||
})
|
||||
this.publishModal = false
|
||||
}
|
||||
this.canPublish = isValid
|
||||
})
|
||||
}
|
||||
this.$store.state.validateMain = false
|
||||
this.$router.push({ name: 'DelegateMain' }, () => {
|
||||
this.$store.commit('ON_MAIN_READY', () => {
|
||||
open()
|
||||
return true
|
||||
})
|
||||
})
|
||||
if (this.$route.name === 'DelegateMain') {
|
||||
open()
|
||||
}
|
||||
},
|
||||
askApproval () {
|
||||
this.askingApprovalLoading = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue