lazy evaluation, styles

This commit is contained in:
les 2020-10-09 00:42:03 +02:00
parent 55dc023019
commit 721d6e0a8b
9 changed files with 138 additions and 101 deletions

View file

@ -4,16 +4,18 @@
v-card-subtitle(v-html="$t('admin.place_description')") v-card-subtitle(v-html="$t('admin.place_description')")
v-dialog(v-model='dialog' width='600') v-dialog(v-model='dialog' width='600')
v-card v-card(color='secondary')
v-card-title {{$t('admin.edit_place')}} v-card-title {{$t('admin.edit_place')}}
v-card-text v-card-text
v-form v-form(v-model='valid' ref='form' lazy-validation)
v-text-field( v-text-field(
:rules="[$validators.required('common.name')]"
:label="$t('common.name')" :label="$t('common.name')"
v-model='place.name' v-model='place.name'
:placeholder='$t("common.name")') :placeholder='$t("common.name")')
v-text-field( v-text-field(
:rules="[$validators.required('common.address')]"
:label="$t('common.address')" :label="$t('common.address')"
v-model='place.address' v-model='place.address'
:placeholder='$t("common.address")') :placeholder='$t("common.address")')
@ -21,11 +23,11 @@
v-card-actions v-card-actions
v-spacer v-spacer
v-btn(@click='dialog=false' color='warning') {{$t('common.cancel')}} v-btn(@click='dialog=false' color='warning') {{$t('common.cancel')}}
v-btn(@click='savePlace' color='primary' :loading='loading' :disable='loading') {{$t('common.save')}} v-btn(@click='savePlace' color='primary' :loading='loading'
:disable='!valid || loading') {{$t('common.save')}}
v-card-text v-card-text
v-data-table( v-data-table(
@click:row='selectPlace'
:headers='headers' :headers='headers'
:items='places') :items='places')
template(v-slot:item.actions='{item}') template(v-slot:item.actions='{item}')
@ -39,6 +41,7 @@ export default {
return { return {
loading: false, loading: false,
dialog: false, dialog: false,
valid: false,
place: { name: '', address: '', id: null }, place: { name: '', address: '', id: null },
headers: [ headers: [
{ value: 'name', text: 'Name' }, { value: 'name', text: 'Name' },
@ -57,6 +60,7 @@ export default {
this.dialog = true this.dialog = true
}, },
async savePlace () { async savePlace () {
if (!this.$refs.form.validate()) return
this.loading = true this.loading = true
await this.$axios.$put('/place', this.place) await this.$axios.$put('/place', this.place)
this.updateMeta() this.updateMeta()

View file

@ -6,15 +6,16 @@
append-icon='mdi-magnify' outlined rounded append-icon='mdi-magnify' outlined rounded
label='Search' label='Search'
single-line hide-details) single-line hide-details)
v-btn(color='primary' text @click='newUserDialog = true') <v-icon>mdi-plus</v-icon> {{$t('common.new_user')}}
v-btn(color='primary' text @click='newUserDialog = true') <v-icon>mdi-plus</v-icon> {{$t('common.new_user')}}
//- ADD NEW USER //- ADD NEW USER
v-dialog(v-model='newUserDialog' :fullscreen="$vuetify.breakpoint.xsOnly") v-dialog(v-model='newUserDialog' :fullscreen="$vuetify.breakpoint.xsOnly")
v-card v-card(color='secondary')
v-card-title {{$t('common.new_user')}} v-card-title {{$t('common.new_user')}}
v-card-text v-card-text
v-form(v-model='valid') v-form(v-model='valid' ref='user_form' lazy-validation)
v-text-field(v-model='new_user.email' v-text-field(v-model='new_user.email'
:label="$t('common.email')" :label="$t('common.email')"
:rules="$validators.email") :rules="$validators.email")
@ -85,6 +86,7 @@ export default {
} }
}, },
async createUser () { async createUser () {
if (!this.$refs.user_form.validate()) return
try { try {
this.loading = true this.loading = true
const user = await this.$axios.$post('/user', this.new_user) const user = await this.$axios.$post('/user', this.new_user)

View file

@ -31,7 +31,20 @@ export default {
} }
</script> </script>
<style lang="less"> <style lang="less">
// html, body {
// overflow: hidden;
// max-height: 100%;
// }
.v-dialog { .v-dialog {
max-width: 800px; max-width: 800px;
} }
.theme--dark.v-list {
background-color: #333;
}
.v-autocomplete__content.v-menu__content {
scrollbar-width: thin;
scrollbar-color: #FF4511;
}
</style> </style>

View file

@ -7,7 +7,7 @@
v-card-subtitle(v-text="$t('login.description')") v-card-subtitle(v-text="$t('login.description')")
v-card-text v-card-text
v-form(v-model='valid' ref='form') v-form(v-model='valid' ref='form' lazy-validation)
v-text-field(v-model='email' type='email' v-text-field(v-model='email' type='email'
:rules='$validators.email' autofocus :rules='$validators.email' autofocus
:placeholder='$t("common.email")' :placeholder='$t("common.email")'
@ -68,7 +68,7 @@ export default {
this.$root.$message('login.check_email', { color: 'success' }) this.$root.$message('login.check_email', { color: 'success' })
}, },
async submit (e) { async submit (e) {
e.preventDefault() if (!this.$refs.form.validate()) return
try { try {
this.loading = true this.loading = true
const data = new URLSearchParams() const data = new URLSearchParams()

View file

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

View file

@ -5,55 +5,49 @@
v-card-text v-card-text
v-form(v-model='valid') v-form(v-model='valid')
//- NOT LOGGED EVENT //- Not logged event
div(v-if='!$auth.loggedIn') div(v-if='!$auth.loggedIn')
v-divider <v-icon name='user-secret'/> {{$t('event.anon')}} v-divider <v-icon name='user-secret'/> {{$t('event.anon')}}
p(v-html="$t('event.anon_description')") p(v-html="$t('event.anon_description')")
//- title //- Title
v-text-field.mb-3(v-model='event.title' v-text-field.mb-3(
@change='v => event.title = v'
:value = 'event.title'
:rules="[$validators.required('common.title')]" :rules="[$validators.required('common.title')]"
:label="$t('event.what_description')" :label="$t('event.what_description')"
autofocus autofocus
ref='title') ref='title')
//- description //- Description
//- span {{$t('event.description_description')}}
Editor( Editor(
v-model='event.description' v-model='event.description'
:label="$t('event.description_description')" :placeholder="$t('event.description_description')"
style='max-height: 400px;') max-height='400px')
//- tags //- Where
v-combobox.mt-3(v-model='event.tags'
chips small-chips multiple deletable-chips hide-no-data hide-selected persistent-hint
:delimiters="[',', ' ']"
:items="tags.map(t => t.tag)"
:label="$t('common.tags')")
//- WHERE
v-combobox.mt-2(v-model='event.place.name' v-combobox.mt-2(v-model='event.place.name'
:rules="[$validators.required()]" :rules="[$validators.required('common.where')]"
:label="$t('common.where')" :label="$t('common.where')"
:hint="$t('event.where_description')" :hint="$t('event.where_description')"
persistent-hint persistent-hint
:items="places" :items="places"
item-text='name' item-text='name'
@input='selectPlace') @change='selectPlace')
template(v-slot:item="{ item }") //- template(v-slot:item="{ item }")
v-list v-list-item(color='primary')
v-list-item-content v-list-item-content(color='pink')
v-list-item-title {{item.name}} v-list-item-title {{item.name}}
v-list-item-subtitle {{item.address}} v-list-item-subtitle {{item.address}}
v-text-field.mt-3(ref='address' v-text-field.mt-3(ref='address'
:rules="[$validators.required()]" :rules="[$validators.required('common.address')]"
:label="$t('common.address')" :label="$t('common.address')"
v-model='event.place.address' @change="v => event.place.address = v"
:value="event.place.address"
:disabled='disableAddress') :disabled='disableAddress')
//- WHEN //- When
//- v-divider <v-icon name='clock'/> {{$t('common.when')}}
.text-center .text-center
v-btn-toggle(v-model="event.type" color='primary') v-btn-toggle(v-model="event.type" color='primary')
v-btn(value='normal' label="normal") {{$t('event.normal')}} v-btn(value='normal' label="normal") {{$t('event.normal')}}
@ -97,7 +91,7 @@
template(v-slot:activator='{ on }') template(v-slot:activator='{ on }')
v-text-field( v-text-field(
:label="$t('event.from')" :label="$t('event.from')"
:rules="[$validators.required()]" :rules="[$validators.required('event.from')]"
:value='time.start' :value='time.start'
v-on='on' v-on='on'
clearable) clearable)
@ -148,6 +142,13 @@
persistent-hint persistent-hint
accept='image/*') accept='image/*')
//- tags
v-combobox.mt-3(v-model='event.tags'
chips small-chips multiple deletable-chips hide-no-data hide-selected persistent-hint
:delimiters="[',', ' ']"
:items="tags.map(t => t.tag)"
:label="$t('common.tags')")
v-card-actions v-card-actions
v-spacer v-spacer
v-btn(@click='done' :loading='loading' :disabled='!valid || loading || !date' v-btn(@click='done' :loading='loading' :disabled='!valid || loading || !date'
@ -228,7 +229,7 @@ export default {
loading: false, loading: false,
mediaUrl: '', mediaUrl: '',
queryTags: '', queryTags: '',
disableAddress: true, disableAddress: false,
frequencies: [ frequencies: [
{ value: '1w', text: this.$t('event.each_week') }, { value: '1w', text: this.$t('event.each_week') },
{ value: '2w', text: this.$t('event.each_2w') }, { value: '2w', text: this.$t('event.each_2w') },
@ -360,12 +361,10 @@ export default {
return attributes return attributes
} }
}, },
// mounted () {
// this.$refs.title.focus()
// },
methods: { methods: {
...mapActions(['addEvent', 'updateEvent', 'updateMeta', 'updateEvents']), ...mapActions(['addEvent', 'updateEvent', 'updateMeta', 'updateEvents']),
selectPlace (p) { selectPlace (p) {
console.error('sono dentro selectePlace')
const place = p && this.places.find(place => place.id === p.id) const place = p && this.places.find(place => place.id === p.id)
if (place && place.address) { if (place && place.address) {
this.event.place.name = p.name this.event.place.name = p.name
@ -375,7 +374,7 @@ export default {
this.disableAddress = false this.disableAddress = false
this.event.place.address = '' this.event.place.address = ''
} }
this.$nextTick(this.$refs.address.focus) // this.$nextTick(() => this.$refs.address.focus() )
}, },
// recurrentDays () { // recurrentDays () {
// if (this.event.type !== 'recurrent' || !this.date || !this.date.length) { return } // if (this.event.type !== 'recurrent' || !this.date || !this.date.length) { return }

View file

@ -1,59 +1,72 @@
<template lang="pug"> <template lang="pug">
v-card.h-event.eventDetail v-card.h-event.eventDetail
v-container v-container
v-list-item(two-line)
v-list-item-content
v-list-item-title
time.dt-start(:datetime='event.start_datetime|unixFormat("YYYY-MM-DD HH:mm")')
v-icon mdi-date
b {{event|when}}
small ({{event.start_datetime|from}})
v-list-item-title
b.p-location {{event.place.name}}
span - {{event.place.address}}
h2 {{event.title}}
.v-btn--absolute.v-btn--right.v-btn--top //- event admin controls
v-btn.mr-1(nuxt icon outlined color='primary' EventAdmin(v-if='is_mine' :event='event')
:to='`/event/${event.prev}`' :disabled='!event.prev')
v-icon mdi-arrow-left //- v-list-item(two-line)
v-btn(nuxt bottom right outlined icon color='primary' //- v-list-item-content
:to='`/event/${event.next}`' :disabled='!event.next') .text-h5.text-sm-h4
v-icon mdi-arrow-right b {{event.title}}
v-row
v-col.col-12.col-lg-9
//- TOFIX: avoid reflow
//- event image
v-img.main_image.mb-3(
contain
:src='imgPath'
:lazy-src='thumbImgPath'
v-if='event.image_path')
//- template(v-slot:placeholder)
//- v-row(
//- class="fill-height ma-0"
//- align="center"
//- justify="center")
//- v-progress-circular(indeterminate
//- color="grey lighten-5")
v-col.col-12.col-lg-3
v-card(color='secondary')
v-card-text.white--text
time.dt-start.text-h5(:datetime='event.start_datetime|unixFormat("YYYY-MM-DD HH:mm")')
v-icon mdi-calendar
b.ml-2 {{event|when}}
p.subtitle-1 {{event.start_datetime|from}}
.text-h5
v-icon mdi-map-marker
b.p-location.ml-2 {{event.place.name}}
p.subtitle-1 {{event.place.address}}
//- info & actions
v-list
v-list-item(link)
v-list-item-content.primary--text.text-uppercase(
v-clipboard:success='copyLink'
v-clipboard:copy='`${settings.baseurl}/event/${event.id}`') {{$t('common.copy_link')}}
v-list-item(link)
v-list-item-content.primary--text.text-uppercase(@click='showEmbed=true' text color='primary') {{$t('common.embed')}}
v-list-item(link)
v-list-item-content.primary--text.text-uppercase(:href='`${settings.baseurl}/api/event/${event.id}.ics`' text color='primary') {{$t('common.add_to_calendar')}}
v-container v-container
v-dialog(v-model='showEmbed') v-dialog(v-model='showEmbed')
EmbedEvent(:event='event') EmbedEvent(:event='event' @close='showEmbed=false')
//- TOFIX: avoid reflow
//- event image
v-img.main_image.mb-3(
contain
:src='imgPath'
:lazy-src='thumbImgPath'
v-if='event.image_path')
//- template(v-slot:placeholder)
//- v-row(
//- class="fill-height ma-0"
//- align="center"
//- justify="center")
//- v-progress-circular(indeterminate
//- color="grey lighten-5")
div.p-description(v-html='event.description') div.p-description(v-html='event.description')
v-chip.p-category.ml-1(small v-for='tag in event.tags' color='primary' outlined :key='tag') {{tag}} v-chip.p-category.ml-1(small v-for='tag in event.tags' color='primary' outlined :key='tag') {{tag}}
//- info & actions //- //- info & actions
v-btn(text color='primary' //- v-btn(text color='primary'
v-clipboard:success='copyLink' //- v-clipboard:success='copyLink'
v-clipboard:copy='`${settings.baseurl}/event/${event.id}`') {{$t('common.copy_link')}} //- v-clipboard:copy='`${settings.baseurl}/event/${event.id}`') {{$t('common.copy_link')}}
v-btn(@click='showEmbed=true' text color='primary') {{$t('common.embed')}} //- v-btn(@click='showEmbed=true' text color='primary') {{$t('common.embed')}}
v-btn(:href='`${settings.baseurl}/api/event/${event.id}.ics`' text color='primary') {{$t('common.add_to_calendar')}} //- v-btn(:href='`${settings.baseurl}/api/event/${event.id}.ics`' text color='primary') {{$t('common.add_to_calendar')}}
EventAdmin(v-if='is_mine' :event='event')
//- hr
//- resources from fediverse //- resources from fediverse
#resources.mt-1(v-if='settings.enable_federation') #resources.mt-1(v-if='settings.enable_federation')
@ -61,11 +74,11 @@
small.mr-3 🔖 {{event.likes.length}} small.mr-3 🔖 {{event.likes.length}}
small {{event.boost.length}}<br/> small {{event.boost.length}}<br/>
p.p-2 //- p.p-2
v-btn(type='text' @click='showFollowMe=true') {{$t('event.interact_with_me')}} //- v-btn(type='text' @click='showFollowMe=true') {{$t('event.interact_with_me')}}
span(v-if='settings.enable_resources && event.resources.length') - {{$tc('common.n_resources', event.resources.length)}} //- span(v-if='settings.enable_resources && event.resources.length') - {{$tc('common.n_resources', event.resources.length)}}
v-dialog(v-model='showFollowMe' destroy-on-close max-width='500px') //- v-dialog(v-model='showFollowMe' destroy-on-close max-width='500px')
h4(slot='title') {{$t('common.follow_me_title')}} h4(slot='title') {{$t('common.follow_me_title')}}
FollowMe(@close='showFollowMe=false' is-dialog) FollowMe(@close='showFollowMe=false' is-dialog)
@ -102,6 +115,15 @@
span.previewImage(@click='showResource(resource)') span.previewImage(@click='showResource(resource)')
img(v-for='img in resource.data.attachment' :src='img.url') img(v-for='img in resource.data.attachment' :src='img.url')
//- Next/prev arrow
.text-center
v-btn.mr-2(nuxt icon outlined color='primary'
:to='`/event/${event.prev}`' :disabled='!event.prev')
v-icon mdi-arrow-left
v-btn(nuxt bottom right outlined icon color='primary'
:to='`/event/${event.next}`' :disabled='!event.next')
v-icon mdi-arrow-right
</template> </template>
<script> <script>
import { mapState } from 'vuex' import { mapState } from 'vuex'
@ -286,4 +308,5 @@ export default {
max-height: 83vh; max-height: 83vh;
} }
} }
</style> </style>

View file

@ -1,5 +1,5 @@
<template lang='pug'> <template lang='pug'>
v-card v-card(color='secondary')
v-card-title(v-text="$t('common.embed_title')") v-card-title(v-text="$t('common.embed_title')")
v-card-text v-card-text
v-row(:gutter='10') v-row(:gutter='10')
@ -9,7 +9,8 @@ v-card
v-col.mt-2(:span='12' :xs='24' v-html='code') v-col.mt-2(:span='12' :xs='24' v-html='code')
v-card-actions v-card-actions
v-spacer v-spacer
v-btn(slot='append' v-clipboard:copy='code' v-clipboard:success='copyLink' color="primary") {{$t("common.copy")}} v-btn(color='warning' @click="$emit('close')") {{$t("common.cancel")}}
v-btn(v-clipboard:copy='code' v-clipboard:success='copyLink' color="primary") {{$t("common.copy")}}
</template> </template>
<script> <script>
import { mapState } from 'vuex' import { mapState } from 'vuex'

View file

@ -1,15 +1,10 @@
<template lang="pug"> <template lang="pug">
v-main v-container
v-card
p {{$auth.user.email}} v-card-title.text-h5 {{$auth.user.email}}
//- el-form(action='/api/user' method='PUT' @submit.native.prevent='update_settings' inline label-width='200px') v-card-text
//- el-form-item(:label="$t('settings.change_password')") p {{$t('settings.remove_account')}}
//- el-input(v-model='password' type='password') v-btn.black--text(color='warning' @click='remove_account') {{$t('common.remove')}}
//- el-button(type='success' native-type='submit') {{$t('common.save')}}
p {{$t('settings.danger_section')}}
p {{$t('settings.remove_account')}}
v-btn(color='danger' @click='remove_account') {{$t('common.remove')}}
</template> </template>
<script> <script>
import { mapState } from 'vuex' import { mapState } from 'vuex'