2020-05-04 12:44:12 +02:00
|
|
|
define(['dialogHelper', 'loading', 'connectionManager', 'require', 'globalize', 'scrollHelper', 'layoutManager', 'focusManager', 'browser', 'emby-input', 'emby-checkbox', 'paper-icon-button-light', 'css!./../formdialog', 'material-icons', 'cardStyle'], function (dialogHelper, loading, connectionManager, require, globalize, scrollHelper, layoutManager, focusManager, browser) {
|
|
|
|
'use strict';
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-11-11 12:28:27 +03:00
|
|
|
var enableFocusTransform = !browser.slow && !browser.edge;
|
|
|
|
|
2019-01-10 15:39:37 +03:00
|
|
|
var currentItem;
|
|
|
|
var currentItemType;
|
|
|
|
var currentServerId;
|
|
|
|
var currentResolve;
|
|
|
|
var currentReject;
|
|
|
|
var hasChanges = false;
|
|
|
|
var currentSearchResult;
|
2018-10-23 01:05:09 +03:00
|
|
|
|
|
|
|
function getApiClient() {
|
2019-01-10 15:39:37 +03:00
|
|
|
return connectionManager.getApiClient(currentServerId);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function searchForIdentificationResults(page) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
var lookupInfo = {
|
|
|
|
ProviderIds: {}
|
|
|
|
};
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
var i;
|
|
|
|
var length;
|
2020-05-04 12:44:12 +02:00
|
|
|
var identifyField = page.querySelectorAll('.identifyField');
|
2019-01-10 15:39:37 +03:00
|
|
|
var value;
|
|
|
|
for (i = 0, length = identifyField.length; i < length; i++) {
|
|
|
|
|
|
|
|
value = identifyField[i].value;
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
if (identifyField[i].type === 'number') {
|
2019-01-10 15:39:37 +03:00
|
|
|
value = parseInt(value);
|
|
|
|
}
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
lookupInfo[identifyField[i].getAttribute('data-lookup')] = value;
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var hasId = false;
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
var txtLookupId = page.querySelectorAll('.txtLookupId');
|
2019-01-10 15:39:37 +03:00
|
|
|
for (i = 0, length = txtLookupId.length; i < length; i++) {
|
|
|
|
|
|
|
|
value = txtLookupId[i].value;
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
hasId = true;
|
|
|
|
}
|
2020-05-04 12:44:12 +02:00
|
|
|
lookupInfo.ProviderIds[txtLookupId[i].getAttribute('data-providerkey')] = value;
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasId && !lookupInfo.Name) {
|
2020-05-04 12:44:12 +02:00
|
|
|
require(['toast'], function (toast) {
|
|
|
|
toast(globalize.translate('PleaseEnterNameOrId'));
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
lookupInfo = {
|
2018-10-23 01:05:09 +03:00
|
|
|
SearchInfo: lookupInfo
|
2019-01-10 15:39:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
if (currentItem && currentItem.Id) {
|
|
|
|
lookupInfo.ItemId = currentItem.Id;
|
2019-11-23 00:29:38 +09:00
|
|
|
} else {
|
2019-01-10 15:39:37 +03:00
|
|
|
lookupInfo.IncludeDisabledProviders = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
loading.show();
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var apiClient = getApiClient();
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
apiClient.ajax({
|
2020-05-04 12:44:12 +02:00
|
|
|
type: 'POST',
|
|
|
|
url: apiClient.getUrl('Items/RemoteSearch/' + currentItemType),
|
2018-10-23 01:05:09 +03:00
|
|
|
data: JSON.stringify(lookupInfo),
|
2020-05-04 12:44:12 +02:00
|
|
|
contentType: 'application/json',
|
|
|
|
dataType: 'json'
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
}).then(function (results) {
|
|
|
|
|
|
|
|
loading.hide();
|
|
|
|
showIdentificationSearchResults(page, results);
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function showIdentificationSearchResults(page, results) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
var identificationSearchResults = page.querySelector('.identificationSearchResults');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('.popupIdentifyForm').classList.add('hide');
|
|
|
|
identificationSearchResults.classList.remove('hide');
|
|
|
|
page.querySelector('.identifyOptionsForm').classList.add('hide');
|
|
|
|
page.querySelector('.dialogContentInner').classList.remove('dialog-content-centered');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
var html = '';
|
2019-11-23 00:29:38 +09:00
|
|
|
var i;
|
|
|
|
var length;
|
2018-10-23 01:05:09 +03:00
|
|
|
for (i = 0, length = results.length; i < length; i++) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
var result = results[i];
|
|
|
|
html += getSearchResultHtml(result, i);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
var elem = page.querySelector('.identificationSearchResultList');
|
2018-10-23 01:05:09 +03:00
|
|
|
elem.innerHTML = html;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
function onSearchImageClick() {
|
2020-05-04 12:44:12 +02:00
|
|
|
var index = parseInt(this.getAttribute('data-index'));
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
var currentResult = results[index];
|
|
|
|
|
|
|
|
if (currentItem != null) {
|
|
|
|
|
|
|
|
showIdentifyOptions(page, currentResult);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
finishFindNewDialog(page, currentResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
var searchImages = elem.querySelectorAll('.card');
|
2019-01-10 15:39:37 +03:00
|
|
|
for (i = 0, length = searchImages.length; i < length; i++) {
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
searchImages[i].addEventListener('click', onSearchImageClick);
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (layoutManager.tv) {
|
|
|
|
focusManager.autoFocus(identificationSearchResults);
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function finishFindNewDialog(dlg, identifyResult) {
|
2019-01-10 15:39:37 +03:00
|
|
|
currentSearchResult = identifyResult;
|
|
|
|
hasChanges = true;
|
|
|
|
loading.hide();
|
|
|
|
|
|
|
|
dialogHelper.close(dlg);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function showIdentifyOptions(page, identifyResult) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
var identifyOptionsForm = page.querySelector('.identifyOptionsForm');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('.popupIdentifyForm').classList.add('hide');
|
|
|
|
page.querySelector('.identificationSearchResults').classList.add('hide');
|
|
|
|
identifyOptionsForm.classList.remove('hide');
|
|
|
|
page.querySelector('#chkIdentifyReplaceImages').checked = true;
|
|
|
|
page.querySelector('.dialogContentInner').classList.add('dialog-content-centered');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
currentSearchResult = identifyResult;
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var lines = [];
|
2019-01-10 15:39:37 +03:00
|
|
|
lines.push(identifyResult.Name);
|
|
|
|
|
|
|
|
if (identifyResult.ProductionYear) {
|
|
|
|
lines.push(identifyResult.ProductionYear);
|
|
|
|
}
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
var resultHtml = lines.join('<br/>');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
if (identifyResult.ImageUrl) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var displayUrl = getSearchImageDisplayUrl(identifyResult.ImageUrl, identifyResult.SearchProviderName);
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
resultHtml = '<div style="display:flex;align-items:center;"><img src="' + displayUrl + '" style="max-height:240px;" /><div style="margin-left:1em;">' + resultHtml + '</div>';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('.selectedSearchResult').innerHTML = resultHtml;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
focusManager.focus(identifyOptionsForm.querySelector('.btnSubmit'));
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getSearchResultHtml(result, index) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-11-11 12:28:27 +03:00
|
|
|
// TODO move card creation code to Card component
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
var html = '';
|
|
|
|
var cssClass = 'card scalableCard';
|
|
|
|
var cardBoxCssClass = 'cardBox';
|
2019-01-10 15:39:37 +03:00
|
|
|
var padderClass;
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
if (currentItemType === 'Episode') {
|
|
|
|
cssClass += ' backdropCard backdropCard-scalable';
|
|
|
|
padderClass = 'cardPadder-backdrop';
|
|
|
|
} else if (currentItemType === 'MusicAlbum' || currentItemType === 'MusicArtist') {
|
|
|
|
cssClass += ' squareCard squareCard-scalable';
|
|
|
|
padderClass = 'cardPadder-square';
|
2019-11-23 00:29:38 +09:00
|
|
|
} else {
|
2020-05-04 12:44:12 +02:00
|
|
|
cssClass += ' portraitCard portraitCard-scalable';
|
|
|
|
padderClass = 'cardPadder-portrait';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
2019-11-11 12:28:27 +03:00
|
|
|
if (layoutManager.tv) {
|
2020-05-04 12:44:12 +02:00
|
|
|
cssClass += ' show-focus';
|
2019-11-11 12:28:27 +03:00
|
|
|
|
|
|
|
if (enableFocusTransform) {
|
2020-05-04 12:44:12 +02:00
|
|
|
cssClass += ' show-animation';
|
2019-11-11 12:28:27 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
cardBoxCssClass += ' cardBox-bottompadded';
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
html += '<button type="button" class="' + cssClass + '" data-index="' + index + '">';
|
|
|
|
html += '<div class="' + cardBoxCssClass + '">';
|
|
|
|
html += '<div class="cardScalable">';
|
|
|
|
html += '<div class="' + padderClass + '"></div>';
|
|
|
|
|
|
|
|
html += '<div class="cardContent searchImage">';
|
|
|
|
|
|
|
|
if (result.ImageUrl) {
|
|
|
|
var displayUrl = getSearchImageDisplayUrl(result.ImageUrl, result.SearchProviderName);
|
|
|
|
|
|
|
|
html += '<div class="cardImageContainer coveredImage" style="background-image:url(\'' + displayUrl + '\');"></div>';
|
|
|
|
} else {
|
|
|
|
|
|
|
|
html += '<div class="cardImageContainer coveredImage defaultCardBackground defaultCardBackground1"><div class="cardText cardCenteredText">' + result.Name + '</div></div>';
|
|
|
|
}
|
2020-05-04 12:44:12 +02:00
|
|
|
html += '</div>';
|
|
|
|
html += '</div>';
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var numLines = 2;
|
2020-05-04 12:44:12 +02:00
|
|
|
if (currentItemType === 'MusicAlbum') {
|
2019-01-10 15:39:37 +03:00
|
|
|
numLines++;
|
|
|
|
}
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var lines = [result.Name];
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
if (result.AlbumArtist) {
|
|
|
|
lines.push(result.AlbumArtist.Name);
|
|
|
|
}
|
|
|
|
if (result.ProductionYear) {
|
|
|
|
lines.push(result.ProductionYear);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i = 0; i < numLines; i++) {
|
|
|
|
|
|
|
|
if (i === 0) {
|
|
|
|
html += '<div class="cardText cardText-first cardTextCentered">';
|
|
|
|
} else {
|
|
|
|
html += '<div class="cardText cardText-secondary cardTextCentered">';
|
|
|
|
}
|
2020-05-04 12:44:12 +02:00
|
|
|
html += lines[i] || ' ';
|
|
|
|
html += '</div>';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
html += '</div>';
|
|
|
|
html += '</button>';
|
2019-01-10 15:39:37 +03:00
|
|
|
return html;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getSearchImageDisplayUrl(url, provider) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var apiClient = getApiClient();
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
return apiClient.getUrl('Items/RemoteSearch/Image', { imageUrl: url, ProviderName: provider });
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function submitIdentficationResult(page) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
loading.show();
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var options = {
|
2020-05-04 12:44:12 +02:00
|
|
|
ReplaceAllImages: page.querySelector('#chkIdentifyReplaceImages').checked
|
2019-01-10 15:39:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
var apiClient = getApiClient();
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
apiClient.ajax({
|
2020-05-04 12:44:12 +02:00
|
|
|
type: 'POST',
|
|
|
|
url: apiClient.getUrl('Items/RemoteSearch/Apply/' + currentItem.Id, options),
|
2018-10-23 01:05:09 +03:00
|
|
|
data: JSON.stringify(currentSearchResult),
|
2020-05-04 12:44:12 +02:00
|
|
|
contentType: 'application/json'
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
}).then(function () {
|
|
|
|
|
|
|
|
hasChanges = true;
|
|
|
|
loading.hide();
|
|
|
|
|
|
|
|
dialogHelper.close(page);
|
|
|
|
|
|
|
|
}, function () {
|
|
|
|
|
|
|
|
loading.hide();
|
|
|
|
|
|
|
|
dialogHelper.close(page);
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function showIdentificationForm(page, item) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var apiClient = getApiClient();
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
apiClient.getJSON(apiClient.getUrl('Items/' + item.Id + '/ExternalIdInfos')).then(function (idList) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
var html = '';
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
for (var i = 0, length = idList.length; i < length; i++) {
|
|
|
|
|
|
|
|
var idInfo = idList[i];
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
var id = 'txtLookup' + idInfo.Key;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
html += '<div class="inputContainer">';
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-03-22 13:08:10 -07:00
|
|
|
var fullName = idInfo.Name;
|
|
|
|
if (idInfo.Type) {
|
2020-05-04 12:44:12 +02:00
|
|
|
fullName = idInfo.Name + ' ' + globalize.translate(idInfo.Type);
|
2020-03-22 13:08:10 -07:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
var idLabel = globalize.translate('LabelDynamicExternalId', fullName);
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
html += '<input is="emby-input" class="txtLookupId" data-providerkey="' + idInfo.Key + '" id="' + id + '" label="' + idLabel + '"/>';
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
html += '</div>';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('#txtLookupName').value = '';
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
if (item.Type === 'Person' || item.Type === 'BoxSet') {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('.fldLookupYear').classList.add('hide');
|
|
|
|
page.querySelector('#txtLookupYear').value = '';
|
2019-01-10 15:39:37 +03:00
|
|
|
} else {
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('.fldLookupYear').classList.remove('hide');
|
|
|
|
page.querySelector('#txtLookupYear').value = '';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('.identifyProviderIds').innerHTML = html;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('.formDialogHeaderTitle').innerHTML = globalize.translate('Identify');
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function showEditor(itemId) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
loading.show();
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
require(['text!./itemidentifier.template.html'], function (template) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var apiClient = getApiClient();
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
|
|
|
|
|
|
|
|
currentItem = item;
|
|
|
|
currentItemType = currentItem.Type;
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var dialogOptions = {
|
2020-05-11 21:43:41 +02:00
|
|
|
size: 'small',
|
2019-01-10 15:39:37 +03:00
|
|
|
removeOnClose: true,
|
|
|
|
scrollY: false
|
2018-10-23 01:05:09 +03:00
|
|
|
};
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
if (layoutManager.tv) {
|
2020-05-04 12:44:12 +02:00
|
|
|
dialogOptions.size = 'fullscreen';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var dlg = dialogHelper.createDialog(dialogOptions);
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.classList.add('formDialog');
|
|
|
|
dlg.classList.add('recordingDialog');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
var html = '';
|
|
|
|
html += globalize.translateDocument(template, 'core');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
dlg.innerHTML = html;
|
|
|
|
|
2019-01-27 22:10:07 +01:00
|
|
|
// Has to be assigned a z-index after the call to .open()
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.addEventListener('close', onDialogClosed);
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
if (layoutManager.tv) {
|
2020-05-04 12:44:12 +02:00
|
|
|
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
2019-10-18 17:05:50 +03:00
|
|
|
if (item.Path) {
|
|
|
|
dlg.querySelector('.fldPath').classList.remove('hide');
|
|
|
|
} else {
|
|
|
|
dlg.querySelector('.fldPath').classList.add('hide');
|
|
|
|
}
|
|
|
|
|
|
|
|
dlg.querySelector('.txtPath').innerHTML = item.Path || '';
|
|
|
|
|
2019-01-10 15:39:37 +03:00
|
|
|
dialogHelper.open(dlg);
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.querySelector('.popupIdentifyForm').addEventListener('submit', function (e) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
searchForIdentificationResults(dlg);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.querySelector('.identifyOptionsForm').addEventListener('submit', function (e) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
submitIdentficationResult(dlg);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.querySelector('.btnCancel').addEventListener('click', function (e) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
dialogHelper.close(dlg);
|
|
|
|
});
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.classList.add('identifyDialog');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
showIdentificationForm(dlg, item);
|
|
|
|
loading.hide();
|
|
|
|
});
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function onDialogClosed() {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
loading.hide();
|
|
|
|
if (hasChanges) {
|
|
|
|
currentResolve();
|
|
|
|
} else {
|
|
|
|
currentReject();
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function showEditorFindNew(itemName, itemYear, itemType, resolveFunc) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
currentItem = null;
|
|
|
|
currentItemType = itemType;
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
require(['text!./itemidentifier.template.html'], function (template) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var dialogOptions = {
|
2020-05-11 21:43:41 +02:00
|
|
|
size: 'small',
|
2019-01-10 15:39:37 +03:00
|
|
|
removeOnClose: true,
|
|
|
|
scrollY: false
|
2018-10-23 01:05:09 +03:00
|
|
|
};
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
if (layoutManager.tv) {
|
2020-05-04 12:44:12 +02:00
|
|
|
dialogOptions.size = 'fullscreen';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var dlg = dialogHelper.createDialog(dialogOptions);
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.classList.add('formDialog');
|
|
|
|
dlg.classList.add('recordingDialog');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
var html = '';
|
|
|
|
html += globalize.translateDocument(template, 'core');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
dlg.innerHTML = html;
|
|
|
|
|
|
|
|
if (layoutManager.tv) {
|
2020-05-04 12:44:12 +02:00
|
|
|
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
dialogHelper.open(dlg);
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.querySelector('.btnCancel').addEventListener('click', function (e) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
dialogHelper.close(dlg);
|
|
|
|
});
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.querySelector('.popupIdentifyForm').addEventListener('submit', function (e) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
searchForIdentificationResults(dlg);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.addEventListener('close', function () {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
loading.hide();
|
|
|
|
var foundItem = hasChanges ? currentSearchResult : null;
|
|
|
|
|
|
|
|
resolveFunc(foundItem);
|
|
|
|
});
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.classList.add('identifyDialog');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
showIdentificationFormFindNew(dlg, itemName, itemYear, itemType);
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function showIdentificationFormFindNew(dlg, itemName, itemYear, itemType) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.querySelector('#txtLookupName').value = itemName;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
if (itemType === 'Person' || itemType === 'BoxSet') {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.querySelector('.fldLookupYear').classList.add('hide');
|
|
|
|
dlg.querySelector('#txtLookupYear').value = '';
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.querySelector('.fldLookupYear').classList.remove('hide');
|
|
|
|
dlg.querySelector('#txtLookupYear').value = itemYear;
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.querySelector('.formDialogHeaderTitle').innerHTML = globalize.translate('Search');
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
return {
|
2019-01-10 15:39:37 +03:00
|
|
|
show: function (itemId, serverId) {
|
|
|
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
|
|
|
currentResolve = resolve;
|
|
|
|
currentReject = reject;
|
|
|
|
currentServerId = serverId;
|
|
|
|
hasChanges = false;
|
|
|
|
|
|
|
|
showEditor(itemId);
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
},
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
showFindNew: function (itemName, itemYear, itemType, serverId) {
|
|
|
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
|
|
|
currentServerId = serverId;
|
|
|
|
|
|
|
|
hasChanges = false;
|
|
|
|
showEditorFindNew(itemName, itemYear, itemType, resolve);
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
};
|
2019-01-27 22:10:07 +01:00
|
|
|
});
|