diff --git a/Frontend/vue-project/src/components/CatalogFilms.vue b/Frontend/vue-project/src/components/CatalogFilms.vue index 7050903..9c03735 100644 --- a/Frontend/vue-project/src/components/CatalogFilms.vue +++ b/Frontend/vue-project/src/components/CatalogFilms.vue @@ -19,7 +19,9 @@ ], selectedGenres: [], genreUrl: 'genre/', - genres: [] + genres: [], + open: [], + len: undefined } }, created() { @@ -44,6 +46,22 @@ for(var j=0; j +import axios from 'axios'; +import CatalogMixins from '../mixins/CatalogMixins.js'; +import Film from "../models/Film"; +import Genre from "../models/Genre"; +import DataService from '../services/DataService'; + +export default { +mixins: [ +CatalogMixins +], +data() { +return { +getAllUrl: 'film/', +dataUrl: 'film', +transformer: (data) => new Film(data), +headers: [ +{ name: 'name', label: 'Название' } +], +headersGenres: [ +{ name: 'name', label: 'Жанр' } +], +selectedItemsGenres: [], +genreUrl: 'genre/', +genres: [], +dataFilterUrl: 'genre/film/' +} +}, +created() { +DataService.readAll(this.genreUrl, (data) => new Genre(data)) +.then(data => { +this.genres = data; +}); +}, +methods: { +addGenre(filmId) { +let genreId = document.getElementById('genres').value; +let response = axios.post(`http://localhost:8080/film/add_genre/${filmId}?genre_id=${genreId}`); +console.log(response); +}, +delGenre(filmId) { +let genreId = document.getElementById('genres').value; +let response = axios.delete(`http://localhost:8080/film/del_genre/${filmId}?genre_id=${genreId}`); +console.log(response); +}, +itemsGenres(genreIds) { +let result = []; +if (typeof genreIds === 'undefined') { +return; +} +this.genres.forEach(genre => { +for (let i = 0; i < genreIds.length; i++) { +if (genre.id === genreIds[i]) { +result.push(genre); +} +} +}); +return result; +}, + filter() { + let genreId = document.getElementById('genreFilterSelect').value; + DataService.readAll(this.dataFilterUrl + this.genreId, (data) => new Genre(data)) + .then(data => { + this.items = data; + }); + }, +clearFilters() { +this.loadItems(); +this.id = null; +this.name = null; +this.genreId = null; +} +} +} + + + \ No newline at end of file diff --git a/Frontend/vue-project/src/components/Table.vue b/Frontend/vue-project/src/components/Table.vue index 732105b..40f8348 100644 --- a/Frontend/vue-project/src/components/Table.vue +++ b/Frontend/vue-project/src/components/Table.vue @@ -1,5 +1,6 @@