This commit is contained in:
Matthieu Bessat 2020-07-19 15:27:26 +02:00
parent f2b6257a43
commit 90cd5ec582
7 changed files with 89 additions and 26 deletions

View file

@ -15,6 +15,7 @@
canvas-color="white" canvas-color="white"
:width="width" :width="width"
:height="height" :height="height"
accept="image/jpeg,image/png"
prevent-white-space prevent-white-space
:placeholder-font-size="22" :placeholder-font-size="22"
@file-size-exceed="handleFileSizeExceed" @file-size-exceed="handleFileSizeExceed"
@ -60,6 +61,7 @@
text text
:loading="loading" :loading="loading"
color="primary" color="primary"
:disabled="$store.state.delegate.validationState === 'pending'"
@click="submit"> @click="submit">
Sauvegarder Sauvegarder
</v-btn> </v-btn>

View file

@ -26,11 +26,27 @@
<slot /> <slot />
</v-toolbar-items> </v-toolbar-items>
</v-toolbar> </v-toolbar>
<v-card-text class="frame-container"> <v-card-text class="preview-content">
<!-- <v-tabs
v-model="tab"
centered
show-arrows
slider-color="accent"
ref="tabs"
>
<v-tab @click="tab = 0">
Accueil
</v-tab>
<v-tab @click="tab = 1">
Page
</v-tab>
</v-tabs> -->
<div class="frame-container">
<iframe <iframe
class="frame" class="frame"
:src="frameUrl"> :src="frameUrl">
</iframe> </iframe>
</div>
</v-card-text> </v-card-text>
</v-card> </v-card>
</v-dialog> </v-dialog>
@ -39,6 +55,10 @@
<script> <script>
export default { export default {
props: { props: {
id: {
type: String,
required: true
},
slug: { slug: {
type: String, type: String,
required: true required: true
@ -56,15 +76,27 @@ export default {
default: 'proposed' default: 'proposed'
} }
}, },
data: () => ({
tab: 0
}),
computed: { computed: {
frameUrl () { frameUrl () {
if (this.tab === 1) {
return process.env.VUE_APP_BASE_URL + '/association/' + this.slug + '?version=' + this.version return process.env.VUE_APP_BASE_URL + '/association/' + this.slug + '?version=' + this.version
} else {
return process.env.VUE_APP_BASE_URL + '?only=' + this.id
}
} }
} }
} }
</script> </script>
<style scoped> <style scoped>
.preview-content {
height: 100%;
display: flex;
flex-direction: column;
}
.frame-container { .frame-container {
height: 100%; height: 100%;
display: flex; display: flex;

View file

@ -293,16 +293,10 @@ export default {
const organization = res.data.data.organization const organization = res.data.data.organization
const proposedVersion = res.data.data.organization.proposedVersion const proposedVersion = res.data.data.organization.proposedVersion
const tags = res.data.data.tags const tags = res.data.data.tags
if (
proposedVersion.tag !== undefined &&
proposedVersion.tag !== null
) {
proposedVersion.tag = proposedVersion.tag._id
}
this.$store.commit('SET_DELEGATE', { this.$store.commit('SET_DELEGATE', {
adminName: organization.adminName, adminName: organization.adminName,
email: organization.email, email: organization.email,
publicUrl: process.env.VUE_APP_BASE_URL + '/association/' + organization.slug, publicUrl: process.env.VUE_APP_BASE_URL + '/association/' + organization.slugs[organization.slugs.length - 1],
validationState: organization.validationState, validationState: organization.validationState,
rejectionDescription: organization.rejectionDescription rejectionDescription: organization.rejectionDescription
}) })

View file

@ -14,6 +14,7 @@ export default new Vuex.Store({
tags: [], tags: [],
data: { data: {
name: '', name: '',
tags: [],
descriptionShort: '', descriptionShort: '',
descriptionLong: '', descriptionLong: '',
thumbnail: { thumbnail: {
@ -41,7 +42,7 @@ export default new Vuex.Store({
}, },
debug: false, debug: false,
validateMain: false, validateMain: false,
validateMainCallback: () => false validateMainCallback: (d: boolean) => false
}, },
mutations: { mutations: {
SET_DEBUG (state, payload) { SET_DEBUG (state, payload) {
@ -74,9 +75,9 @@ export default new Vuex.Store({
}, },
VALIDATE_MAIN (state, callback) { VALIDATE_MAIN (state, callback) {
state.validateMain = true state.validateMain = true
state.validateMainCallback = () => { state.validateMainCallback = (d: boolean) => {
state.validateMain = false state.validateMain = false
return callback() return callback(d)
} }
} }
}, },

View file

@ -209,6 +209,11 @@
<v-list-item-title>{{ toSeeItem.token }}</v-list-item-title> <v-list-item-title>{{ toSeeItem.token }}</v-list-item-title>
<v-list-item-subtitle>Token/clé</v-list-item-subtitle> <v-list-item-subtitle>Token/clé</v-list-item-subtitle>
</v-list-item-content> </v-list-item-content>
<v-list-item-action>
<v-btn color="info" outlined @click="openPanel(toSeeItem)" small icon>
<v-icon small>launch</v-icon>
</v-btn>
</v-list-item-action>
</v-list-item> </v-list-item>
<v-divider /> <v-divider />
@ -233,7 +238,6 @@
</div> </div>
<div v-if="toSeeItem.publishedAt !== undefined"> <div v-if="toSeeItem.publishedAt !== undefined">
<v-divider />
<v-list-item> <v-list-item>
<v-list-item-action /> <v-list-item-action />
<v-list-item-content> <v-list-item-content>
@ -281,7 +285,8 @@
</v-dialog> </v-dialog>
<Preview <Preview
:enabled="approveModal" :enabled="approveModal"
:slug="toApproveItem.slug" :id="toApproveItem._id"
:slug="toApproveItem.slugs[0]"
:dialogTitle="approveModalTitle" :dialogTitle="approveModalTitle"
@close="approveModal = false" @close="approveModal = false"
> >
@ -325,11 +330,12 @@ export default {
data: () => { data: () => {
const item = { const item = {
_id: '',
adminName: '', adminName: '',
email: '', email: '',
validationState: 'unaware', validationState: 'unaware',
rejectionDescription: '', rejectionDescription: '',
slug: '' slugs: ['']
} }
return { return {
dialog: false, dialog: false,
@ -518,7 +524,12 @@ export default {
}, },
openExternal (item) { openExternal (item) {
window.open(process.env.VUE_APP_BASE_URL + '/association/' + item.slug + '?version=proposed', '_blank').focus() window.open(process.env.VUE_APP_BASE_URL + '/association/' + item.slugs[item.slug.length - 1] + '?version=proposed', '_blank').focus()
},
openPanel (item) {
const routeData = this.$router.resolve({ name: 'DelegateMain', query: { delegateToken: item.token } })
window.open(routeData.href, '_blank').focus()
}, },
openApproveModal (item) { openApproveModal (item) {

View file

@ -43,7 +43,11 @@
/> />
<!-- COVER END --> <!-- COVER END -->
<div class="d-flex justify-end mb-3"> <div class="d-flex justify-end mb-3">
<v-btn color="primary" outlined @click="addMediaModal = true"> <v-btn
color="primary"
outlined
:disabled="$store.state.delegate.validationState === 'pending'"
@click="addMediaModal = true">
<v-icon left>add</v-icon> <v-icon left>add</v-icon>
Ajouter un média Ajouter un média
</v-btn> </v-btn>

View file

@ -19,13 +19,24 @@
<img :src="$store.state.data.thumbnail.location" /> <img :src="$store.state.data.thumbnail.location" />
</v-avatar> </v-avatar>
</v-col> </v-col>
<v-col cols="12" sm="6" style="align-items: center; justify-content: center; display: flex;"> <v-col cols="12" sm="6" style="align-items: center; justify-content: center; display: flex; flex-direction: column">
<v-btn @click="$refs.avatarEditor.toggle()" color="primary" outlined> <v-btn
color="primary"
outlined
:disabled="$store.state.delegate.validationState === 'pending'"
@click="$refs.avatarEditor.toggle()"
>
<v-icon left> <v-icon left>
edit edit
</v-icon> </v-icon>
Changer le logo <span v-if="$store.state.data.thumbnail.location === ''">Définir un logo</span>
<span v-else>Changer le logo</span>
</v-btn> </v-btn>
<div
v-if="$store.state.data.thumbnail.location === '' && validateLogo"
class="red--text mt-2">
Vous devez définir un logo !
</div>
</v-col> </v-col>
</v-row> </v-row>
@ -39,10 +50,12 @@
<v-select <v-select
label="Catégorie(s) de l'association" label="Catégorie(s) de l'association"
outlined outlined
multiple
prepend-icon="category" prepend-icon="category"
item-text="name" item-text="name"
item-value="_id" item-value="_id"
v-model="$store.state.data.tag" v-model="$store.state.data.tags"
:rules="rules.tags"
:items="$store.state.tags"> :items="$store.state.tags">
</v-select> </v-select>
@ -91,6 +104,7 @@ export default {
data: () => ({ data: () => ({
formValid: true, formValid: true,
logoLoading: false, logoLoading: false,
validateLogo: false,
rules: { rules: {
name: [ name: [
v => v.length >= 3 || 'Au minimum 3 caractères', v => v.length >= 3 || 'Au minimum 3 caractères',
@ -100,6 +114,7 @@ export default {
v => v.length >= 20 || 'Au minimum 20 caractères', v => v.length >= 20 || 'Au minimum 20 caractères',
v => v.length <= 200 || 'Au maximum 200 caractères' v => v.length <= 200 || 'Au maximum 200 caractères'
], ],
tags: [v => (Array.isArray(v) && v.length > 0) || 'Vous devez choisir au minimum une catégorie'],
email: [v => /.+@.+\..+/.test(v) || "L'email est requis et dois être valide"], email: [v => /.+@.+\..+/.test(v) || "L'email est requis et dois être valide"],
person: [v => v.length >= 4 || 'Au minimum 4 caractères'] person: [v => v.length >= 4 || 'Au minimum 4 caractères']
} }
@ -115,7 +130,11 @@ export default {
watch: { watch: {
'$store.state.validateMain' (val) { '$store.state.validateMain' (val) {
if (val) { if (val) {
this.$store.state.validateMainCallback(this.$refs.form.validate()) this.validateLogo = true
this.$store.state.validateMainCallback(
this.$refs.form.validate() &&
this.$store.state.data.thumbnail.location.length > 1
)
} }
} }
}, },