mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update metadataeditor
This commit is contained in:
parent
775db5c5e8
commit
818ee2bcc3
3 changed files with 48 additions and 37 deletions
|
@ -1,4 +1,4 @@
|
|||
define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loading', 'focusManager', 'connectionManager', 'globalize', 'require', 'emby-checkbox', 'emby-input', 'emby-select', 'listViewStyle', 'emby-textarea', 'emby-button', 'paper-icon-button-light', 'css!./../formdialog'], function (itemHelper, dom, layoutManager, dialogHelper, datetime, loading, focusManager, connectionManager, globalize, require) {
|
||||
define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loading', 'focusManager', 'connectionManager', 'globalize', 'require', 'shell', 'dom', 'emby-checkbox', 'emby-input', 'emby-select', 'listViewStyle', 'emby-textarea', 'emby-button', 'paper-icon-button-light', 'css!./../formdialog'], function (itemHelper, dom, layoutManager, dialogHelper, datetime, loading, focusManager, connectionManager, globalize, require, shell, dom) {
|
||||
|
||||
var currentContext;
|
||||
var metadataEditorInfo;
|
||||
|
@ -331,6 +331,19 @@
|
|||
|
||||
function init(context, apiClient) {
|
||||
|
||||
context.querySelector('.externalIds').addEventListener('click', function (e) {
|
||||
var btnOpenExternalId = dom.parentWithClass(e.target, 'btnOpenExternalId');
|
||||
if (btnOpenExternalId) {
|
||||
var field = context.querySelector('#' + btnOpenExternalId.getAttribute('data-fieldid'));
|
||||
|
||||
var formatString = field.getAttribute('data-formatstring');
|
||||
|
||||
if (field.value) {
|
||||
shell.openUrl(formatString.replace('{0}', field.value));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
context.querySelector('.btnCancel').addEventListener('click', function () {
|
||||
|
||||
closeDialog(false);
|
||||
|
@ -370,7 +383,7 @@
|
|||
editPerson(context, {}, -1);
|
||||
});
|
||||
|
||||
context.querySelector('#peopleList').addEventListener('click', function(e) {
|
||||
context.querySelector('#peopleList').addEventListener('click', function (e) {
|
||||
|
||||
var btnDeletePerson = dom.parentWithClass(e.target, 'btnDeletePerson');
|
||||
if (btnDeletePerson) {
|
||||
|
@ -466,18 +479,6 @@
|
|||
selectEl.value = metadataInfo.ContentType || '';
|
||||
}
|
||||
|
||||
function onExternalIdChange() {
|
||||
|
||||
var formatString = this.getAttribute('data-formatstring');
|
||||
var buttonClass = this.getAttribute('data-buttonclass');
|
||||
|
||||
if (this.value) {
|
||||
document.querySelector('.' + buttonClass).setAttribute('href', formatString.replace('{0}', this.value));
|
||||
} else {
|
||||
document.querySelector('.' + buttonClass).setAttribute('href', '#');
|
||||
}
|
||||
}
|
||||
|
||||
function loadExternalIds(context, item, externalIds) {
|
||||
|
||||
var html = '';
|
||||
|
@ -489,7 +490,6 @@
|
|||
var idInfo = externalIds[i];
|
||||
|
||||
var id = "txt1" + idInfo.Key;
|
||||
var buttonId = "btnOpen1" + idInfo.Key;
|
||||
var formatString = idInfo.UrlFormatString || '';
|
||||
|
||||
var labelText = globalize.translate('sharedcomponents#LabelDynamicExternalId').replace('{0}', idInfo.Name);
|
||||
|
@ -500,11 +500,11 @@
|
|||
var value = providerIds[idInfo.Key] || '';
|
||||
|
||||
html += '<div style="flex-grow:1;">';
|
||||
html += '<input is="emby-input" class="txtExternalId" value="' + value + '" data-providerkey="' + idInfo.Key + '" data-formatstring="' + formatString + '" data-buttonclass="' + buttonId + '" id="' + id + '" label="' + labelText + '"/>';
|
||||
html += '<input is="emby-input" class="txtExternalId" value="' + value + '" data-providerkey="' + idInfo.Key + '" data-formatstring="' + formatString + '" id="' + id + '" label="' + labelText + '"/>';
|
||||
html += '</div>';
|
||||
|
||||
if (formatString) {
|
||||
html += '<a class="clearLink ' + buttonId + '" href="#" target="_blank" data-role="none" style="float: none; width: 1.75em"><button type="button" is="paper-icon-button-light" class="autoSize"><i class="md-icon">open_in_browser</i></button></a>';
|
||||
html += '<button type="button" is="paper-icon-button-light" class="btnOpenExternalId" data-fieldid="' + id + '"><i class="md-icon">open_in_browser</i></button>';
|
||||
}
|
||||
html += '</div>';
|
||||
|
||||
|
@ -513,12 +513,6 @@
|
|||
|
||||
var elem = context.querySelector('.externalIds', context);
|
||||
elem.innerHTML = html;
|
||||
|
||||
var extIdEls = elem.querySelector('.txtExternalId') || [];
|
||||
Array.prototype.forEach.call(extIdEls, function (el) {
|
||||
el.addEventListener('change', onExternalIdChange.bind(el));
|
||||
el.dispatchEvent(new Event('change'));
|
||||
});
|
||||
}
|
||||
|
||||
// Function to hide the element by selector or raw element
|
||||
|
|
|
@ -307,10 +307,14 @@ textarea {
|
|||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.background-theme-a .backgroundContainer, .dialog.background-theme-a {
|
||||
.background-theme-a .backgroundContainer {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.dialog.background-theme-a {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.dialog:not(.background-theme-a):not(.background-theme-b) {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
|
|
@ -99,6 +99,27 @@ self.addEventListener('activate', function (event) {
|
|||
);
|
||||
});
|
||||
|
||||
function getApiClient(serverId) {
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
function executeAction(action, data, serverId) {
|
||||
|
||||
return getApiClient(serverId).then(function (apiClient) {
|
||||
|
||||
switch (action) {
|
||||
case 'cancel-install':
|
||||
var id = data.id;
|
||||
return apiClient.cancelPackageInstallation(id);
|
||||
case 'restart':
|
||||
return apiClient.restartServer();
|
||||
default:
|
||||
clients.openWindow("/");
|
||||
return Promise.resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
self.addEventListener('notificationclick', function (event) {
|
||||
|
||||
var notification = event.notification;
|
||||
|
@ -107,21 +128,13 @@ self.addEventListener('notificationclick', function (event) {
|
|||
var data = notification.data;
|
||||
var serverId = data.serverId;
|
||||
var action = event.action;
|
||||
var promise;
|
||||
|
||||
switch (action) {
|
||||
case 'cancel-install':
|
||||
var id = data.id;
|
||||
console.log('cancel: ' + id);
|
||||
break;
|
||||
case 'restart':
|
||||
break;
|
||||
default:
|
||||
clients.openWindow("/");
|
||||
break;
|
||||
if (!action) {
|
||||
clients.openWindow("/");
|
||||
event.waitUntil(Promise.resolve());
|
||||
return;
|
||||
}
|
||||
|
||||
promise = promise || Promise.resolve();
|
||||
event.waitUntil(promise);
|
||||
event.waitUntil(executeAction(action, data, serverId));
|
||||
|
||||
}, false);
|
Loading…
Add table
Add a link
Reference in a new issue