2019-12-04 14:14:04 +00:00
|
|
|
<template>
|
|
|
|
<v-dialog v-model="show" persistent max-width="350" class="p-photo-album-dialog" @keydown.esc="cancel">
|
|
|
|
<v-card raised elevation="24">
|
|
|
|
<v-container fluid class="pb-2 pr-2 pl-2">
|
|
|
|
<v-layout row wrap>
|
|
|
|
<v-flex xs3 text-xs-center>
|
2019-12-17 03:39:23 +00:00
|
|
|
<v-icon size="54" color="grey lighten-1" v-if="newAlbum">create_new_folder</v-icon>
|
|
|
|
<v-icon size="54" color="grey lighten-1" v-else>folder</v-icon>
|
2019-12-04 14:14:04 +00:00
|
|
|
</v-flex>
|
|
|
|
<v-flex xs9 text-xs-left align-self-center>
|
2019-12-05 03:54:31 +00:00
|
|
|
<v-autocomplete
|
|
|
|
v-model="album"
|
2019-12-17 03:39:23 +00:00
|
|
|
browser-autocomplete="off"
|
|
|
|
hint="Album Name"
|
|
|
|
:items="items"
|
2019-12-05 03:54:31 +00:00
|
|
|
:search-input.sync="search"
|
|
|
|
:loading="loading"
|
|
|
|
hide-details
|
|
|
|
item-text="AlbumName"
|
|
|
|
item-value="AlbumUUID"
|
2019-12-09 17:46:44 +00:00
|
|
|
:label="labels.select"
|
2019-12-05 03:54:31 +00:00
|
|
|
color="secondary-dark"
|
|
|
|
flat solo
|
|
|
|
>
|
|
|
|
</v-autocomplete>
|
2019-12-04 14:14:04 +00:00
|
|
|
</v-flex>
|
|
|
|
<v-flex xs12 text-xs-right class="pt-3">
|
|
|
|
<v-btn @click.stop="cancel" depressed color="grey lighten-3" class="p-photo-dialog-cancel">
|
2019-12-09 17:46:44 +00:00
|
|
|
<translate>Cancel</translate>
|
2019-12-04 14:14:04 +00:00
|
|
|
</v-btn>
|
|
|
|
<v-btn color="blue-grey lighten-2" depressed dark @click.stop="confirm"
|
2019-12-17 03:39:23 +00:00
|
|
|
class="p-photo-dialog-confirm">
|
|
|
|
<span v-if="newAlbum">{{ labels.createAlbum }}</span>
|
|
|
|
<span v-else>{{ labels.addToAlbum }}</span>
|
2019-12-04 14:14:04 +00:00
|
|
|
</v-btn>
|
|
|
|
</v-flex>
|
|
|
|
</v-layout>
|
|
|
|
</v-container>
|
|
|
|
</v-card>
|
|
|
|
</v-dialog>
|
|
|
|
</template>
|
|
|
|
<script>
|
2019-12-05 03:54:31 +00:00
|
|
|
import Album from "../model/album";
|
|
|
|
|
2019-12-04 14:14:04 +00:00
|
|
|
export default {
|
|
|
|
name: 'p-photo-album-dialog',
|
|
|
|
props: {
|
|
|
|
show: Boolean,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2019-12-17 03:39:23 +00:00
|
|
|
loading: false,
|
2019-12-05 03:54:31 +00:00
|
|
|
search: null,
|
2019-12-17 03:39:23 +00:00
|
|
|
newAlbum: null,
|
2019-12-05 03:54:31 +00:00
|
|
|
album: "",
|
|
|
|
albums: [],
|
2019-12-17 03:39:23 +00:00
|
|
|
items: [],
|
2019-12-09 17:46:44 +00:00
|
|
|
labels: {
|
|
|
|
select: this.$gettext("Select album"),
|
2019-12-17 03:39:23 +00:00
|
|
|
addToAlbum: this.$gettext("Add to album"),
|
|
|
|
createAlbum: this.$gettext("Create album"),
|
2019-12-09 17:46:44 +00:00
|
|
|
}
|
2019-12-04 14:14:04 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
cancel() {
|
|
|
|
this.$emit('cancel');
|
|
|
|
},
|
|
|
|
confirm() {
|
2019-12-17 03:39:23 +00:00
|
|
|
if(this.album === "" && this.newAlbum) {
|
|
|
|
console.log("NEW", this.album, this.newAlbum);
|
|
|
|
this.loading = true;
|
|
|
|
|
|
|
|
this.newAlbum.save().then((a) => {
|
|
|
|
this.loading = false;
|
|
|
|
this.$emit('confirm', a.AlbumUUID);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
console.log("OLD", this.album, this.newAlbum);
|
|
|
|
this.$emit('confirm', this.album);
|
|
|
|
}
|
2019-12-04 14:14:04 +00:00
|
|
|
},
|
2019-12-17 03:39:23 +00:00
|
|
|
queryServer(q) {
|
|
|
|
if(this.loading) {
|
|
|
|
return;
|
|
|
|
}
|
2019-12-05 03:54:31 +00:00
|
|
|
|
2019-12-17 03:39:23 +00:00
|
|
|
this.loading = true;
|
2019-12-05 03:54:31 +00:00
|
|
|
|
2019-12-17 03:39:23 +00:00
|
|
|
const params = {
|
|
|
|
q: q,
|
|
|
|
count: 1000,
|
|
|
|
offset: 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
Album.search(params).then(response => {
|
|
|
|
this.loading = false;
|
2019-12-05 03:54:31 +00:00
|
|
|
|
2019-12-17 03:39:23 +00:00
|
|
|
if(response.models.length > 0 && !this.album) {
|
|
|
|
this.album = response.models[0].AlbumUUID;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.albums = response.models;
|
|
|
|
this.items = [...this.albums];
|
|
|
|
}).catch(() => this.loading = false);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
search (q) {
|
|
|
|
const exists = this.albums.findIndex((album) => album.AlbumName === q);
|
|
|
|
|
|
|
|
if (exists !== -1 || !q) {
|
|
|
|
this.items = this.albums;
|
|
|
|
this.newAlbum = null;
|
|
|
|
} else {
|
|
|
|
this.newAlbum = new Album({AlbumName: q, AlbumUUID: ""});
|
|
|
|
this.items = this.albums.concat([this.newAlbum]);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.queryServer("");
|
2019-12-05 03:54:31 +00:00
|
|
|
},
|
2019-12-04 14:14:04 +00:00
|
|
|
}
|
|
|
|
</script>
|