Fix: Style of search and do not discard value on resize

pull/16/head
Juraj Nyíri 4 years ago
parent cf2bfed704
commit 53b76645ea

@ -19233,7 +19233,7 @@ style.textContent = css `
} }
.searchContainer input { .searchContainer input {
width: 100%; width: calc(100% - 26px);
padding: 10px; padding: 10px;
margin-bottom: 10px; margin-bottom: 10px;
} }
@ -19456,6 +19456,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
super(...arguments); super(...arguments);
this.plexProtocol = 'http'; this.plexProtocol = 'http';
this.movieElems = []; this.movieElems = [];
this.searchValue = '';
this.activeMovieElemData = {}; this.activeMovieElemData = {};
this.seasonElemFreshlyLoaded = false; this.seasonElemFreshlyLoaded = false;
this.episodesElemFreshlyLoaded = false; this.episodesElemFreshlyLoaded = false;
@ -19550,16 +19551,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
this.card.appendChild(this.content); this.card.appendChild(this.content);
this.appendChild(this.card); this.appendChild(this.card);
const searchContainer = document.createElement('div');
searchContainer.className = 'searchContainer';
const searchInput = document.createElement('input');
searchInput.type = 'text';
searchInput.placeholder = `Search ${this.config.libraryName}...`;
searchInput.addEventListener('keyup', () => {
console.log(searchInput.value);
});
searchContainer.appendChild(searchInput);
this.content.appendChild(searchContainer);
let count = 0; let count = 0;
const contentbg = document.createElement('div'); const contentbg = document.createElement('div');
contentbg.className = 'contentbg'; contentbg.className = 'contentbg';
@ -19591,6 +19582,17 @@ class PlexMeetsHomeAssistant extends HTMLElement {
}); });
}, 1); }, 1);
if (this.data[this.config.libraryName]) { if (this.data[this.config.libraryName]) {
const searchContainer = document.createElement('div');
searchContainer.className = 'searchContainer';
const searchInput = document.createElement('input');
searchInput.type = 'text';
searchInput.value = this.searchValue;
searchInput.placeholder = `Search ${this.config.libraryName}...`;
searchInput.addEventListener('keyup', () => {
this.searchValue = searchInput.value;
});
searchContainer.appendChild(searchInput);
this.content.appendChild(searchContainer);
// eslint-disable-next-line consistent-return // eslint-disable-next-line consistent-return
lodash.forEach(this.data[this.config.libraryName], (movieData) => { lodash.forEach(this.data[this.config.libraryName], (movieData) => {
if (!this.maxCount || count < this.maxCount) { if (!this.maxCount || count < this.maxCount) {

@ -96,7 +96,7 @@ style.textContent = css`
} }
.searchContainer input { .searchContainer input {
width: 100%; width: calc(100% - 26px);
padding: 10px; padding: 10px;
margin-bottom: 10px; margin-bottom: 10px;
} }

@ -17,6 +17,8 @@ class PlexMeetsHomeAssistant extends HTMLElement {
movieElems: any = []; movieElems: any = [];
searchValue = '';
activeMovieElem: HTMLElement | undefined; activeMovieElem: HTMLElement | undefined;
activeMovieElemData: Record<string, any> = {}; activeMovieElemData: Record<string, any> = {};
@ -158,20 +160,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.card.appendChild(this.content); this.card.appendChild(this.content);
this.appendChild(this.card); this.appendChild(this.card);
const searchContainer = document.createElement('div');
searchContainer.className = 'searchContainer';
const searchInput = document.createElement('input');
searchInput.type = 'text';
searchInput.placeholder = `Search ${this.config.libraryName}...`;
searchInput.addEventListener('keyup', () => {
console.log(searchInput.value);
});
searchContainer.appendChild(searchInput);
this.content.appendChild(searchContainer);
let count = 0; let count = 0;
const contentbg = document.createElement('div'); const contentbg = document.createElement('div');
@ -209,6 +197,20 @@ class PlexMeetsHomeAssistant extends HTMLElement {
}); });
}, 1); }, 1);
if (this.data[this.config.libraryName]) { if (this.data[this.config.libraryName]) {
const searchContainer = document.createElement('div');
searchContainer.className = 'searchContainer';
const searchInput = document.createElement('input');
searchInput.type = 'text';
searchInput.value = this.searchValue;
searchInput.placeholder = `Search ${this.config.libraryName}...`;
searchInput.addEventListener('keyup', () => {
this.searchValue = searchInput.value;
});
searchContainer.appendChild(searchInput);
this.content.appendChild(searchContainer);
// eslint-disable-next-line consistent-return // eslint-disable-next-line consistent-return
_.forEach(this.data[this.config.libraryName], (movieData: Record<string, any>) => { _.forEach(this.data[this.config.libraryName], (movieData: Record<string, any>) => {
if (!this.maxCount || count < this.maxCount) { if (!this.maxCount || count < this.maxCount) {

Loading…
Cancel
Save