Галерея с переключением

This commit is contained in:
iriska-gri committed 2023-12-05 13:14:41 +03:00
1 parent 395b0b9fe3
commit 319608f1a1
19 files changed
+67 -43

No files matched your search

+59 -38
View File
@@ -321,6 +321,7 @@
>
</v-img>
<v-card-text class="pt-6">
<!-- <div class="font-weight-light text-grey text-h6 mb-2">
@@ -496,11 +497,42 @@
height="900"
class="flex-column "
>
<v-card class="pa-4">
<v-btn density="compact" icon="mdi-plus" @click="forgetgallery('plus')"></v-btn>
<v-btn density="compact" icon="mdi-minus" @click="forgetgallery('minus')"></v-btn>
{{imgsrc}}
{{galleryimges}}
<v-card class="pa-4 h-100 flex-column d-flex">
<v-row>
<v-col class="flex-grow-0 align-self-center">
<v-btn
density="compact"
variant="text"
icon="mdi-chevron-left"
@click = "indximg +=1"
/>
</v-col>
<v-col class="bg-green">2</v-col>
<v-col class="d-flex flex-column flex-grow-1">
<v-row class="flex-grow-0">
<v-col class="bg-grey">3</v-col>
<v-col class=" bg-red">5</v-col>
</v-row>
<v-row>
<v-col class="flex-column d-flex align-end align-self-center">
<v-btn
density="compact"
variant="text"
icon="mdi-chevron-right"
@click = "indximg -=1"
/>
</v-col>
</v-row>
</v-col>
</v-row>
<!-- <v-btn density="compact" icon="mdi-plus" @click = "indximg +=1"></v-btn>
</v-btn>
{{indximg}}
{{galleryimges}} -->
<!-- {{cidimg}}
-->
<!-- <v-img
class="d-flex h-100"
@@ -552,18 +584,18 @@ export default {
const newss=ref([])
const galleryimges=ref([])
const dialogCommentShow = ref(false)
const gallery = ref(false)
const dialogfoto = ref(false)
const burl = baseURL.slice(0,-1)
const textcomment = ref('')
const idnews = ref(0)
const page = ref(1)
const selecnews = ref(2)
const route = useRoute()
const imgsrc = ref(1)
let str = `api/navigation/news/?name=${route.path}&page=${page.value-1}&selected=${selecnews.value}`
@@ -602,21 +634,9 @@ export default {
}
const galleryimg = (id) => {
getfromserver(`api/navigation/gallery/?id=${id}`, galleryimges)
}
const openImg = (imgid) => {
console.log(imgid);
imgsrc.value = ''
dialogfoto.value = true
imgsrc.value = imgid
galleryimg(imgid)
}
const addComment = () => {
axiosApiInstance.post(`api/navigation/news/`, {news: idnews.value, text: textcomment.value}).then(result => {
@@ -690,22 +710,25 @@ export default {
return name.familyname + ' ' + name.name[0] + '.' + name.parentname[0]+ '.'
}
const forgetgallery = (hu) => {
if (hu =="plus") {
imgsrc.value += 1
}
else if (imgsrc.value !=0 && hu == "minus") {
imgsrc.value -= 1
}
galleryimg(imgsrc.value)
console.log(imgsrc.value, hu, 'ffffffffffffffffffffffff');
// ------------------------------ Галерея
const galleryimges=ref([])
const dialogfoto = ref(false)
const indximg = ref('')
const openImg = (idimg) => {
dialogfoto.value = true
indximg.value = newss.value.result[0].gallery.findIndex(e=>e.id == idimg)
}
watch(()=>indximg ,(newValue,oldValue)=>{
if(newValue){
galleryimges.value = newss.value.result[0].gallery[newValue.value]
}
}, {deep:true})
return {
newss,
@@ -732,10 +755,8 @@ export default {
gallery,
openImg,
dialogfoto,
imgsrc,
galleryimges,
forgetgallery
indximg
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

+5 -2
View File
@@ -7,9 +7,8 @@ class GalleryInline(admin.TabularInline):
model = Gallery
fields = ( 'img', 'get_html_photo')
readonly_fields=('get_html_photo',)
can_delete = False
show_change_link = False
extra = 0
extra = 1
def get_html_photo(self, object):
if object.img:
@@ -33,10 +32,14 @@ class NewsAdmin(admin.ModelAdmin):
if object.link:
return mark_safe(f"<img src='{object.link.url}' width=50>")
get_html_photo.short_description="Превью изображения"
inlines = [GalleryInline]
class CarouselsAdmin(admin.ModelAdmin):
list_display=('title', 'cdate', 'enddate', 'get_html_photo', 'link','published', 'sender', 'order')
readonly_fields=('get_html_photo',)
+1 -1
View File
@@ -69,7 +69,7 @@ class ScoreNews(models.Model):
class Gallery(models.Model):
img = models.ImageField(upload_to='newsgallery/%Y/%m/%d', null=True, verbose_name='Изображение')
news = models.ForeignKey(News, editable=False, on_delete=models.PROTECT, related_name='get_gallery_news', verbose_name='Новость')
cdate =models.DateTimeField(auto_now_add=True, verbose_name='Дата создания')
cdate =models.DateTimeField(auto_now_add=True, null=True, verbose_name='Дата создания')
class Meta:
+2 -2
View File
@@ -26,8 +26,8 @@ class LinkAPIView(ListAPIView):
class GalleryAPIView(ListAPIView):
def get(self, request):
gal = Gallery.objects.filter(id=int(request.GET.get('id')))
gal = Gallery.objects.filter(id=int(request.GET.get('idimg')), news_id=int(request.GET.get('idnews')))
result = GallerySerializer(gal, many=True).data
return Response(result)