2.0
Juraj Nyíri 3 years ago
parent 403c07ae0b
commit 97cafbdf7b

@ -19486,7 +19486,11 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
} }
if (!lodash.isEmpty(this.libraryName.value)) { if (!lodash.isEmpty(this.libraryName.value)) {
this.config.libraryName = this.libraryName.value; this.config.libraryName = this.libraryName.value;
this.config.sort = `${this.sort.value}:${this.sortOrder.value}`; let sortOrderValue = 'asc';
if (lodash.isEqual(this.sortOrder.value, 'Descending')) {
sortOrderValue = 'desc';
}
this.config.sort = `${this.sort.value}:${sortOrderValue}`;
if (lodash.isEmpty(this.maxCount.value)) { if (lodash.isEmpty(this.maxCount.value)) {
this.config.maxCount = ''; this.config.maxCount = '';
} }
@ -19649,23 +19653,26 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.plexValidSection.appendChild(this.sort); this.plexValidSection.appendChild(this.sort);
this.sortOrder.innerHTML = ''; this.sortOrder.innerHTML = '';
const sortOrderItems = document.createElement('paper-listbox'); const sortOrderItems = document.createElement('paper-listbox');
sortOrderItems.appendChild(addDropdownItem('asc')); sortOrderItems.appendChild(addDropdownItem('Ascending'));
sortOrderItems.appendChild(addDropdownItem('desc')); sortOrderItems.appendChild(addDropdownItem('Descending'));
sortOrderItems.slot = 'dropdown-content'; sortOrderItems.slot = 'dropdown-content';
this.sortOrder.label = 'Sort Order'; this.sortOrder.label = 'Sort Order';
this.sortOrder.appendChild(sortOrderItems); this.sortOrder.appendChild(sortOrderItems);
this.sortOrder.style.width = '100%'; this.sortOrder.style.width = '100%';
this.sortOrder.addEventListener('value-changed', this.valueUpdated); this.sortOrder.addEventListener('value-changed', this.valueUpdated);
if (lodash.isEmpty(this.config.sort)) { if (lodash.isEmpty(this.config.sort)) {
this.sortOrder.value = 'asc'; this.sortOrder.value = 'Ascending';
} }
else { else {
const sortOrder = this.config.sort.split(':')[1]; const sortOrder = this.config.sort.split(':')[1];
if (lodash.isEmpty(sortOrder)) { if (lodash.isEmpty(sortOrder)) {
this.sortOrder.value = 'asc'; this.sortOrder.value = 'Ascending';
} }
else { else if (lodash.isEqual(sortOrder, 'asc')) {
this.sortOrder.value = sortOrder; this.sortOrder.value = 'Ascending';
}
else if (lodash.isEqual(sortOrder, 'desc')) {
this.sortOrder.value = 'Descending';
} }
} }
this.plexValidSection.appendChild(this.sortOrder); this.plexValidSection.appendChild(this.sortOrder);

@ -79,7 +79,11 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
if (!_.isEmpty(this.libraryName.value)) { if (!_.isEmpty(this.libraryName.value)) {
this.config.libraryName = this.libraryName.value; this.config.libraryName = this.libraryName.value;
this.config.sort = `${this.sort.value}:${this.sortOrder.value}`; let sortOrderValue = 'asc';
if (_.isEqual(this.sortOrder.value, 'Descending')) {
sortOrderValue = 'desc';
}
this.config.sort = `${this.sort.value}:${sortOrderValue}`;
if (_.isEmpty(this.maxCount.value)) { if (_.isEmpty(this.maxCount.value)) {
this.config.maxCount = ''; this.config.maxCount = '';
} else { } else {
@ -256,21 +260,23 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.sortOrder.innerHTML = ''; this.sortOrder.innerHTML = '';
const sortOrderItems: any = document.createElement('paper-listbox'); const sortOrderItems: any = document.createElement('paper-listbox');
sortOrderItems.appendChild(addDropdownItem('asc')); sortOrderItems.appendChild(addDropdownItem('Ascending'));
sortOrderItems.appendChild(addDropdownItem('desc')); sortOrderItems.appendChild(addDropdownItem('Descending'));
sortOrderItems.slot = 'dropdown-content'; sortOrderItems.slot = 'dropdown-content';
this.sortOrder.label = 'Sort Order'; this.sortOrder.label = 'Sort Order';
this.sortOrder.appendChild(sortOrderItems); this.sortOrder.appendChild(sortOrderItems);
this.sortOrder.style.width = '100%'; this.sortOrder.style.width = '100%';
this.sortOrder.addEventListener('value-changed', this.valueUpdated); this.sortOrder.addEventListener('value-changed', this.valueUpdated);
if (_.isEmpty(this.config.sort)) { if (_.isEmpty(this.config.sort)) {
this.sortOrder.value = 'asc'; this.sortOrder.value = 'Ascending';
} else { } else {
const sortOrder = this.config.sort.split(':')[1]; const sortOrder = this.config.sort.split(':')[1];
if (_.isEmpty(sortOrder)) { if (_.isEmpty(sortOrder)) {
this.sortOrder.value = 'asc'; this.sortOrder.value = 'Ascending';
} else { } else if (_.isEqual(sortOrder, 'asc')) {
this.sortOrder.value = sortOrder; this.sortOrder.value = 'Ascending';
} else if (_.isEqual(sortOrder, 'desc')) {
this.sortOrder.value = 'Descending';
} }
} }
this.plexValidSection.appendChild(this.sortOrder); this.plexValidSection.appendChild(this.sortOrder);

Loading…
Cancel
Save