apply suggestion

This commit is contained in:
grafixeyehero 2020-07-23 03:07:53 +03:00
parent 7fe80dcbf1
commit f54b13224d
2 changed files with 43 additions and 36 deletions

View File

@ -89,29 +89,37 @@ import 'emby-input';
});
}
export class showEditor {
constructor(itemType, options, availableOptions) {
return import('text!./components/imageOptionsEditor/imageOptionsEditor.template.html').then(({default: template}) => {
return new Promise((resolve) => {
const dlg = dialogHelper.createDialog({
size: 'small',
removeOnClose: true,
scrollY: false
});
dlg.classList.add('formDialog');
dlg.innerHTML = globalize.translateDocument(template);
dlg.addEventListener('close', () => {
saveValues(dlg, options);
});
loadValues(dlg, itemType, options, availableOptions);
dialogHelper.open(dlg).then(resolve, resolve);
dlg.querySelector('.btnCancel').addEventListener('click', () => {
dialogHelper.close(dlg);
});
});
async function showEditor(itemType, options, availableOptions) {
const response = await fetch('components/imageOptionsEditor/imageOptionsEditor.template.html');
const template = await response.text();
var dlg = dialogHelper.createDialog({
size: 'small',
removeOnClose: true,
scrollY: false
});
dlg.classList.add('formDialog');
dlg.innerHTML = globalize.translateDocument(template);
dlg.addEventListener('close', function () {
saveValues(dlg, options);
});
loadValues(dlg, itemType, options, availableOptions);
dialogHelper.open(dlg).then(() => {
return;
}).catch(() => {
return;
});
dlg.querySelector('.btnCancel').addEventListener('click', function () {
dialogHelper.close(dlg);
});
}
export class editor {
constructor() {
this.show = showEditor;
}
}
/* eslint-enable indent */
export default showEditor;
export default editor;

View File

@ -306,7 +306,7 @@ import 'emby-input';
}
function showImageOptionsForType(type) {
import('imageoptionseditor').then(ImageOptionsEditor => {
import('imageoptionseditor').then(({default: ImageOptionsEditor}) => {
let typeOptions = getTypeOptions(currentLibraryOptions, type);
if (!typeOptions) {
typeOptions = {
@ -315,7 +315,8 @@ import 'emby-input';
currentLibraryOptions.TypeOptions.push(typeOptions);
}
const availableOptions = getTypeOptions(currentAvailableOptions || {}, type);
new ImageOptionsEditor.showEditor(type, typeOptions, availableOptions);
const imageOptionsEditor = new ImageOptionsEditor();
imageOptionsEditor.show(type, typeOptions, availableOptions);
});
}
@ -356,25 +357,23 @@ import 'emby-input';
parent.querySelector('.imageFetchers').addEventListener('click', onImageFetchersContainerClick);
}
export function embed(parent, contentType, libraryOptions) {
export async function embed(parent, contentType, libraryOptions) {
currentLibraryOptions = {
TypeOptions: []
};
currentAvailableOptions = null;
const isNewLibrary = null === libraryOptions;
isNewLibrary && parent.classList.add('newlibrary');
return import('text!./libraryoptionseditor.template.html').then(({default: template}) => {
return new Promise((resolve) => {
parent.innerHTML = globalize.translateDocument(template);
populateRefreshInterval(parent.querySelector('#selectAutoRefreshInterval'));
const promises = [populateLanguages(parent), populateCountries(parent.querySelector('#selectCountry'))];
Promise.all(promises).then(() => {
return setContentType(parent, contentType).then(() => {
libraryOptions && setLibraryOptions(parent, libraryOptions);
bindEvents(parent);
resolve();
});
});
const response = await fetch('components/libraryoptionseditor/libraryoptionseditor.template.html');
const template = await response.text();
parent.innerHTML = globalize.translateDocument(template);
populateRefreshInterval(parent.querySelector('#selectAutoRefreshInterval'));
const promises = [populateLanguages(parent), populateCountries(parent.querySelector('#selectCountry'))];
Promise.all(promises).then(function() {
return setContentType(parent, contentType).then(function() {
libraryOptions && setLibraryOptions(parent, libraryOptions);
bindEvents(parent);
return;
});
});
}