- Gallery: added deleting images.
This commit is contained in:
@@ -7,6 +7,7 @@ import { IGallery, IImgGallery } from '../../model/GlobalStore'
|
|||||||
import { CMyPage } from '../CMyPage'
|
import { CMyPage } from '../CMyPage'
|
||||||
import GlobalModule from '../../store/Modules/GlobalStore'
|
import GlobalModule from '../../store/Modules/GlobalStore'
|
||||||
import { GlobalStore } from '../../store/Modules'
|
import { GlobalStore } from '../../store/Modules'
|
||||||
|
import { copyToClipboard } from 'quasar'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'CGallery',
|
name: 'CGallery',
|
||||||
@@ -60,8 +61,15 @@ export default class CGallery extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const draggedId = e.dataTransfer.getData('text')
|
const draggedId = e.dataTransfer.getData('text')
|
||||||
|
let dragout = ''
|
||||||
|
try {
|
||||||
|
dragout = e.target.parentNode.parentNode.id
|
||||||
|
} catch (e) {
|
||||||
|
dragout = ''
|
||||||
|
}
|
||||||
const draggedEl = document.getElementById(draggedId)
|
const draggedEl = document.getElementById(draggedId)
|
||||||
console.log('draggedId', draggedId, 'draggedEl', draggedEl)
|
console.log('draggedId', draggedId, 'draggedEl', draggedEl)
|
||||||
|
console.log('dragout', dragout)
|
||||||
|
|
||||||
// check if original parent node
|
// check if original parent node
|
||||||
if (draggedEl.parentNode === e.target) {
|
if (draggedEl.parentNode === e.target) {
|
||||||
@@ -70,20 +78,41 @@ export default class CGallery extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const myindex = this.listimages.findIndex((rec) => rec._id === draggedId)
|
const myindex = this.listimages.findIndex((rec) => rec._id === draggedId)
|
||||||
const myrec = this.listimages[myindex]
|
const myrec: IImgGallery = this.listimages[myindex]
|
||||||
let myrecprec = null
|
|
||||||
if (myindex > 0)
|
|
||||||
myrecprec = this.listimages[myindex - 1]
|
|
||||||
|
|
||||||
console.log('myrec', myrec, 'myrecprec', myrecprec, 'ord1', myrec.order, 'ordprec', myrecprec.order)
|
let myrecprec: IImgGallery = null
|
||||||
|
let myrecout: IImgGallery = null
|
||||||
|
const myindexout = this.listimages.findIndex((rec) => rec._id === dragout)
|
||||||
|
myrecout = this.listimages[myindexout]
|
||||||
|
let myindexprec = myindexout - 1
|
||||||
|
|
||||||
if (myrecprec) {
|
if (myindexprec < 0)
|
||||||
let diff = (myrec.order - myrecprec.order) / 2
|
myindexprec = 0
|
||||||
|
|
||||||
|
if (myindex === myindexout)
|
||||||
|
return
|
||||||
|
|
||||||
|
myrecprec = this.listimages[myindexprec]
|
||||||
|
|
||||||
|
console.log('myrec', myrec, 'myrecprec', myrecout)
|
||||||
|
|
||||||
|
if (myrec && myrecout)
|
||||||
|
console.log('myrec', myrec, 'myrecprec', myrecout, 'ord1', myrec.order, 'myrecout', myrecout.order)
|
||||||
|
|
||||||
|
if (myrecout) {
|
||||||
|
let diff = 0
|
||||||
|
const ord2 = myrecprec.order
|
||||||
|
const ord1 = myrecout.order
|
||||||
|
diff = Math.round((ord1 - ord2) / 2)
|
||||||
if (diff <= 0)
|
if (diff <= 0)
|
||||||
diff++
|
diff++
|
||||||
myrec.order = myrecprec.order + diff
|
console.log('diff', diff)
|
||||||
|
let mynum = 0
|
||||||
|
mynum = myrecprec.order + diff
|
||||||
|
console.log('mynum', mynum)
|
||||||
|
myrec.order = mynum
|
||||||
} else {
|
} else {
|
||||||
myrec.order = (myrec.order - 1)
|
myrec.order = Math.round(myrec.order) - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('myrec.order', myrec.order)
|
console.log('myrec.order', myrec.order)
|
||||||
@@ -99,6 +128,7 @@ export default class CGallery extends Vue {
|
|||||||
get getclass() {
|
get getclass() {
|
||||||
return (this.edit) ? 'my-card-gallery' : 'my-card-gallery-view' + ' text-center'
|
return (this.edit) ? 'my-card-gallery' : 'my-card-gallery-view' + ' text-center'
|
||||||
}
|
}
|
||||||
|
|
||||||
get getclimg() {
|
get getclimg() {
|
||||||
return (this.edit) ? 'myimg' : 'myimg-view'
|
return (this.edit) ? 'myimg' : 'myimg-view'
|
||||||
}
|
}
|
||||||
@@ -141,11 +171,18 @@ export default class CGallery extends Vue {
|
|||||||
return 'statics/upload/' + this.gall.directory + `/` + rec.imagefile
|
return 'statics/upload/' + this.gall.directory + `/` + rec.imagefile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public copytoclipboard(rec) {
|
||||||
|
const filename = this.getfullname(rec)
|
||||||
|
copyToClipboard(filename).then(() => {
|
||||||
|
tools.showNotif(this.$q, this.$t('dialog.copyclipboard') + ' \'' + filename + '\'')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
public async deleteFile(rec) {
|
public async deleteFile(rec) {
|
||||||
const filename = this.getfullname(rec)
|
const filename = this.getfullname(rec)
|
||||||
|
|
||||||
// Delete File on server:
|
// Delete File on server:
|
||||||
const ris = await GlobalStore.actions.DeleteFile({filename})
|
const ris = await GlobalStore.actions.DeleteFile({ filename })
|
||||||
if (ris)
|
if (ris)
|
||||||
this.deleted(rec)
|
this.deleted(rec)
|
||||||
|
|
||||||
@@ -155,4 +192,12 @@ export default class CGallery extends Vue {
|
|||||||
this.$emit('showandsave', this.listimages)
|
this.$emit('showandsave', this.listimages)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getsrcimg(mygallery) {
|
||||||
|
|
||||||
|
if (tools.getextfile(mygallery.imagefile) === 'pdf')
|
||||||
|
return 'statics/images/images/pdf.jpg'
|
||||||
|
else
|
||||||
|
return 'statics/upload/' + this.gall.directory + `/` + mygallery.imagefile
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
<div v-for="(mygallery, index) in listimages" :key="index" v-if="index === 0">
|
<div v-for="(mygallery, index) in listimages" :key="index" v-if="index === 0">
|
||||||
<div class="q-pa-md q-gutter-md">
|
<div class="q-pa-md q-gutter-md">
|
||||||
<q-card :class="getclass">
|
<q-card :class="getclass">
|
||||||
<q-img :src="`statics/upload/` + gall.directory + `/` + mygallery.imagefile" :class="getclimg"
|
<q-img :src="getsrcimg(mygallery)" :class="getclimg"
|
||||||
:alt="mygallery.alt">
|
:alt="mygallery.alt">
|
||||||
<div class="absolute-bottom text-shadow">
|
<div class="absolute-bottom text-shadow">
|
||||||
{{listimages.length}} immagini
|
{{listimages.length}} files
|
||||||
</div>
|
</div>
|
||||||
</q-img>
|
</q-img>
|
||||||
</q-card>
|
</q-card>
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
@drop="onDrop"
|
@drop="onDrop"
|
||||||
>
|
>
|
||||||
|
|
||||||
<q-img :src="`statics/upload/` + gall.directory + `/` + mygallery.imagefile"
|
<q-img :src="getsrcimg(mygallery)"
|
||||||
:class="getclimg"
|
:class="getclimg"
|
||||||
:alt="mygallery.alt">
|
:alt="mygallery.alt">
|
||||||
<div class="absolute-bottom text-shadow">
|
<div class="absolute-bottom text-shadow">
|
||||||
@@ -40,19 +40,47 @@
|
|||||||
</div>
|
</div>
|
||||||
</q-img>
|
</q-img>
|
||||||
|
|
||||||
<!--Order: {{mygallery.order}} -->
|
|
||||||
<q-input v-model="mygallery.alt"
|
<!--
|
||||||
label="Alt"
|
<q-input v-model="mygallery._id"
|
||||||
|
label="Id"
|
||||||
dense
|
dense
|
||||||
@keyup.enter.stop
|
@keyup.enter.stop
|
||||||
@input="save"
|
@input="save"
|
||||||
debounce="1000"
|
debounce="1000"
|
||||||
autofocus>
|
autofocus>
|
||||||
</q-input>
|
</q-input>
|
||||||
|
-->
|
||||||
|
<q-field
|
||||||
|
stack-label
|
||||||
|
dense
|
||||||
|
label="FileName">
|
||||||
|
<template v-slot:control>
|
||||||
|
<div class="self-center full-width no-outline" tabindex="0">{{mygallery.imagefile}}</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</q-field>
|
||||||
|
|
||||||
|
<!--<q-input v-model="mygallery.order"
|
||||||
|
:label="$t('disc.order')"
|
||||||
|
dense
|
||||||
|
@keyup.enter.stop
|
||||||
|
@input="save"
|
||||||
|
debounce="1000"
|
||||||
|
autofocus>
|
||||||
|
</q-input>-->
|
||||||
|
<!--<q-input v-model="mygallery.alt"
|
||||||
|
label="Alt"
|
||||||
|
dense
|
||||||
|
@keyup.enter.stop
|
||||||
|
@input="save"
|
||||||
|
debounce="1000"
|
||||||
|
autofocus>
|
||||||
|
</q-input>-->
|
||||||
|
|
||||||
<q-input v-model="mygallery.description"
|
<q-input v-model="mygallery.description"
|
||||||
dense
|
dense
|
||||||
label="Description"
|
:label="$t('proj.longdescr')"
|
||||||
@keyup.enter.stop
|
@keyup.enter.stop
|
||||||
@input="save"
|
@input="save"
|
||||||
debounce="1000"
|
debounce="1000"
|
||||||
@@ -60,6 +88,8 @@
|
|||||||
</q-input>
|
</q-input>
|
||||||
|
|
||||||
<q-card-actions align="center">
|
<q-card-actions align="center">
|
||||||
|
<q-btn flat round color="blue" icon="fas fa-copy" size="sm"
|
||||||
|
@click="copytoclipboard(mygallery)"></q-btn>
|
||||||
<q-btn flat round color="red" icon="fas fa-trash-alt" size="sm"
|
<q-btn flat round color="red" icon="fas fa-trash-alt" size="sm"
|
||||||
@click="deleteFile(mygallery)"></q-btn>
|
@click="deleteFile(mygallery)"></q-btn>
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
@@ -69,8 +99,8 @@
|
|||||||
<div class="q-pa-sm">
|
<div class="q-pa-sm">
|
||||||
<div v-if="edit" class="q-gutter-sm " style="max-height: 200px; width: 208px;">
|
<div v-if="edit" class="q-gutter-sm " style="max-height: 200px; width: 208px;">
|
||||||
<q-uploader
|
<q-uploader
|
||||||
label="Aggiungi Immagine"
|
label="Aggiungi Immagine o PDF"
|
||||||
accept=".jpg, image/*"
|
accept=".jpg, image/*, .pdf"
|
||||||
:url="tools.geturlupload()+`/` + gall.directory"
|
:url="tools.geturlupload()+`/` + gall.directory"
|
||||||
:headers="tools.getheaders()"
|
:headers="tools.getheaders()"
|
||||||
:max-file-size="2000000"
|
:max-file-size="2000000"
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ export default class Newsletter extends MixinBase {
|
|||||||
|
|
||||||
public async mounted() {
|
public async mounted() {
|
||||||
await this.load()
|
await this.load()
|
||||||
this.tab = tools.getCookie('formnews', 'check')
|
// this.tab = tools.getCookie('formnews', 'check')
|
||||||
|
this.tab = this.$route.params.idparam
|
||||||
this.emailtextheader = this.getValDb('EMAIL_TEXT', true)
|
this.emailtextheader = this.getValDb('EMAIL_TEXT', true)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
accept=".jpg, image/*"
|
accept=".jpg, image/*"
|
||||||
:url="tools.geturlupload()+`/gallery_home`"
|
:url="tools.geturlupload()+`/gallery_home`"
|
||||||
:headers="tools.getheaders()"
|
:headers="tools.getheaders()"
|
||||||
max-file-size=2000000
|
:max-file-size="2000000"
|
||||||
multiple
|
multiple
|
||||||
style="max-width: 300px"
|
style="max-width: 300px"
|
||||||
></q-uploader>
|
></q-uploader>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
accept=".jpg, image/*"
|
accept=".jpg, image/*"
|
||||||
:url="tools.geturlupload()+`/img`"
|
:url="tools.geturlupload()+`/img`"
|
||||||
:headers="tools.getheaders()"
|
:headers="tools.getheaders()"
|
||||||
max-file-size=1000000
|
:max-file-size="1000000"
|
||||||
multiple
|
multiple
|
||||||
style="max-width: 300px"
|
style="max-width: 300px"
|
||||||
></q-uploader>
|
></q-uploader>
|
||||||
|
|||||||
@@ -828,6 +828,7 @@ namespace Actions {
|
|||||||
|
|
||||||
const arrpagesroute: IListRoutes[] = []
|
const arrpagesroute: IListRoutes[] = []
|
||||||
for (const page of state.mypage) {
|
for (const page of state.mypage) {
|
||||||
|
if (page.active) {
|
||||||
arrpagesroute.push({
|
arrpagesroute.push({
|
||||||
path: '/' + page.path,
|
path: '/' + page.path,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
@@ -840,6 +841,7 @@ namespace Actions {
|
|||||||
level_parent: page.l_par,
|
level_parent: page.l_par,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const last = {
|
const last = {
|
||||||
path: '*',
|
path: '*',
|
||||||
|
|||||||
@@ -2843,6 +2843,10 @@ export const tools = {
|
|||||||
return [{ name: 'x-auth', value: UserStore.state.x_auth_token }]
|
return [{ name: 'x-auth', value: UserStore.state.x_auth_token }]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getextfile(filename) {
|
||||||
|
return filename.split('.').pop().toLowerCase()
|
||||||
|
},
|
||||||
|
|
||||||
getelembylang(arr) {
|
getelembylang(arr) {
|
||||||
const mylang = toolsext.getLocale()
|
const mylang = toolsext.getLocale()
|
||||||
for (const elem in arr) {
|
for (const elem in arr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user