2016-02-17 21:57:19 -07:00
|
|
|
|
define([], function () {
|
2014-07-18 12:07:28 -07:00
|
|
|
|
|
2015-03-14 21:17:35 -07:00
|
|
|
|
var currentDialogOptions;
|
|
|
|
|
|
2016-01-30 12:31:22 -07:00
|
|
|
|
function submitJob(dlg, userId, syncOptions, form, paperDialogHelper) {
|
2014-12-12 20:56:30 -07:00
|
|
|
|
|
|
|
|
|
if (!userId) {
|
|
|
|
|
throw new Error('userId cannot be null');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!syncOptions) {
|
|
|
|
|
throw new Error('syncOptions cannot be null');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!form) {
|
|
|
|
|
throw new Error('form cannot be null');
|
|
|
|
|
}
|
2014-07-22 09:36:34 -07:00
|
|
|
|
|
2014-12-30 09:36:49 -07:00
|
|
|
|
var target = $('#selectSyncTarget', form).val();
|
2014-07-26 10:30:15 -07:00
|
|
|
|
|
|
|
|
|
if (!target) {
|
2014-07-22 09:36:34 -07:00
|
|
|
|
|
2014-12-12 20:56:30 -07:00
|
|
|
|
Dashboard.alert(Globalize.translate('MessagePleaseSelectDeviceToSyncTo'));
|
2014-07-22 09:36:34 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
|
|
|
|
|
userId: userId,
|
2014-07-26 10:30:15 -07:00
|
|
|
|
TargetId: target,
|
2014-07-22 09:36:34 -07:00
|
|
|
|
|
2014-12-18 21:20:07 -07:00
|
|
|
|
ParentId: syncOptions.ParentId,
|
|
|
|
|
Category: syncOptions.Category
|
2014-07-22 09:36:34 -07:00
|
|
|
|
};
|
|
|
|
|
|
2015-03-15 12:10:27 -07:00
|
|
|
|
setJobValues(options, form);
|
|
|
|
|
|
2014-12-30 09:36:49 -07:00
|
|
|
|
if (syncOptions.items && syncOptions.items.length) {
|
|
|
|
|
options.ItemIds = (syncOptions.items || []).map(function (i) {
|
|
|
|
|
return i.Id || i;
|
|
|
|
|
}).join(',');
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-22 09:36:34 -07:00
|
|
|
|
ApiClient.ajax({
|
|
|
|
|
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: ApiClient.getUrl("Sync/Jobs"),
|
|
|
|
|
data: JSON.stringify(options),
|
2015-08-15 13:33:53 -07:00
|
|
|
|
contentType: "application/json",
|
|
|
|
|
dataType: 'json'
|
2014-07-22 09:36:34 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}).then(function () {
|
2014-07-22 09:36:34 -07:00
|
|
|
|
|
2016-01-30 12:31:22 -07:00
|
|
|
|
paperDialogHelper.close(dlg);
|
2014-12-12 20:56:30 -07:00
|
|
|
|
Dashboard.alert(Globalize.translate('MessageSyncJobCreated'));
|
2014-07-22 09:36:34 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-15 12:10:27 -07:00
|
|
|
|
function setJobValues(job, form) {
|
|
|
|
|
|
|
|
|
|
var bitrate = $('#txtBitrate', form).val() || null;
|
|
|
|
|
|
|
|
|
|
if (bitrate) {
|
|
|
|
|
bitrate = parseFloat(bitrate) * 1000000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
job.Name = $('#txtSyncJobName', form).val();
|
|
|
|
|
job.Quality = $('#selectQuality', form).val() || null;
|
|
|
|
|
job.Profile = $('#selectProfile', form).val() || null;
|
|
|
|
|
job.Bitrate = bitrate;
|
|
|
|
|
job.ItemLimit = $('#txtItemLimit', form).val() || null;
|
|
|
|
|
job.SyncNewContent = $('#chkSyncNewContent', form).checked();
|
|
|
|
|
job.UnwatchedOnly = $('#chkUnwatchedOnly', form).checked();
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-14 21:17:35 -07:00
|
|
|
|
function renderForm(options) {
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
|
2016-02-07 14:16:02 -07:00
|
|
|
|
require(['paper-checkbox', 'paper-input', 'jqmcollapsible'], function () {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
renderFormInternal(options);
|
|
|
|
|
resolve();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderFormInternal(options) {
|
|
|
|
|
|
2015-03-14 21:17:35 -07:00
|
|
|
|
var elem = options.elem;
|
|
|
|
|
var dialogOptions = options.dialogOptions;
|
|
|
|
|
|
|
|
|
|
var targets = dialogOptions.Targets;
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
2015-03-14 21:24:43 -07:00
|
|
|
|
if (options.showName || dialogOptions.Options.indexOf('Name') != -1) {
|
2015-03-14 21:17:35 -07:00
|
|
|
|
|
2015-08-17 09:52:56 -07:00
|
|
|
|
html += '<div>';
|
|
|
|
|
html += '<paper-input type="text" id="txtSyncJobName" class="txtSyncJobName" required="required" label="' + Globalize.translate('LabelSyncJobName') + '"></paper-input>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '<br/>';
|
2015-03-14 21:17:35 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<div>';
|
2015-03-14 21:39:29 -07:00
|
|
|
|
if (options.readOnlySyncTarget) {
|
2015-08-17 09:52:56 -07:00
|
|
|
|
html += '<paper-input type="text" id="selectSyncTarget" readonly label="' + Globalize.translate('LabelSyncTo') + '"></paper-input>';
|
2015-03-14 21:39:29 -07:00
|
|
|
|
} else {
|
2016-02-08 14:15:31 -07:00
|
|
|
|
html += '<label for="selectSyncTarget" class="selectLabel">' + Globalize.translate('LabelSyncTo') + '</label>';
|
2015-03-14 21:39:29 -07:00
|
|
|
|
html += '<select id="selectSyncTarget" required="required" data-mini="true">';
|
2015-03-14 21:17:35 -07:00
|
|
|
|
|
2015-03-14 21:39:29 -07:00
|
|
|
|
html += targets.map(function (t) {
|
2015-03-14 21:17:35 -07:00
|
|
|
|
|
2015-06-01 11:36:09 -07:00
|
|
|
|
var isSelected = t.Id == AppInfo.deviceId;
|
|
|
|
|
var selectedHtml = isSelected ? ' selected="selected"' : '';
|
|
|
|
|
return '<option' + selectedHtml + ' value="' + t.Id + '">' + t.Name + '</option>';
|
2015-03-14 21:17:35 -07:00
|
|
|
|
|
2015-03-14 21:39:29 -07:00
|
|
|
|
}).join('');
|
|
|
|
|
html += '</select>';
|
|
|
|
|
if (!targets.length) {
|
|
|
|
|
html += '<div class="fieldDescription">' + Globalize.translate('LabelSyncNoTargetsHelp') + '</div>';
|
|
|
|
|
html += '<div class="fieldDescription"><a href="https://github.com/MediaBrowser/Wiki/wiki/Sync" target="_blank">' + Globalize.translate('ButtonLearnMore') + '</a></div>';
|
|
|
|
|
}
|
2015-03-14 21:17:35 -07:00
|
|
|
|
}
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="fldProfile" style="display:none;">';
|
|
|
|
|
html += '<br/>';
|
2016-02-08 14:15:31 -07:00
|
|
|
|
html += '<label for="selectProfile" class="selectLabel">' + Globalize.translate('LabelProfile') + '</label>';
|
2015-03-14 21:17:35 -07:00
|
|
|
|
html += '<select id="selectProfile" data-mini="true">';
|
|
|
|
|
html += '</select>';
|
|
|
|
|
html += '<div class="fieldDescription profileDescription"></div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="fldQuality" style="display:none;">';
|
|
|
|
|
html += '<br/>';
|
2016-02-08 14:15:31 -07:00
|
|
|
|
html += '<label for="selectQuality" class="selectLabel">' + Globalize.translate('LabelQuality') + '</label>';
|
2015-03-14 21:17:35 -07:00
|
|
|
|
html += '<select id="selectQuality" data-mini="true" required="required">';
|
|
|
|
|
html += '</select>';
|
|
|
|
|
html += '<div class="fieldDescription qualityDescription"></div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="fldBitrate" style="display:none;">';
|
|
|
|
|
html += '<br/>';
|
|
|
|
|
html += '<div>';
|
2015-08-17 09:52:56 -07:00
|
|
|
|
html += '<paper-input type="number" step=".1" min=".1" id="txtBitrate" label="' + Globalize.translate('LabelBitrateMbps') + '"></paper-input>';
|
2015-03-14 21:17:35 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
if (dialogOptions.Options.indexOf('UnwatchedOnly') != -1) {
|
|
|
|
|
html += '<br/>';
|
|
|
|
|
html += '<div>';
|
2015-08-17 09:52:56 -07:00
|
|
|
|
html += '<paper-checkbox id="chkUnwatchedOnly">' + Globalize.translate('OptionSyncUnwatchedVideosOnly') + '</paper-checkbox>';
|
|
|
|
|
html += '<div class="fieldDescription paperCheckboxFieldDescription">' + Globalize.translate('OptionSyncUnwatchedVideosOnlyHelp') + '</div>';
|
2015-03-14 21:17:35 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-01 11:36:09 -07:00
|
|
|
|
if (dialogOptions.Options.indexOf('SyncNewContent') != -1 ||
|
|
|
|
|
dialogOptions.Options.indexOf('ItemLimit') != -1) {
|
|
|
|
|
|
2015-03-14 21:17:35 -07:00
|
|
|
|
html += '<br/>';
|
2015-06-01 11:36:09 -07:00
|
|
|
|
html += '<div data-role="collapsible" data-mini="true">';
|
|
|
|
|
html += '<h2>' + Globalize.translate('HeaderAdvanced') + '</h2>';
|
|
|
|
|
html += '<div style="padding:0 0 1em;">';
|
|
|
|
|
if (dialogOptions.Options.indexOf('SyncNewContent') != -1) {
|
|
|
|
|
html += '<br/>';
|
|
|
|
|
html += '<div>';
|
2015-08-17 09:52:56 -07:00
|
|
|
|
html += '<paper-checkbox id="chkSyncNewContent" checked>' + Globalize.translate('OptionAutomaticallySyncNewContent') + '</paper-checkbox>';
|
|
|
|
|
html += '<div class="fieldDescription paperCheckboxFieldDescription">' + Globalize.translate('OptionAutomaticallySyncNewContentHelp') + '</div>';
|
2015-06-01 11:36:09 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dialogOptions.Options.indexOf('ItemLimit') != -1) {
|
|
|
|
|
html += '<div>';
|
2015-08-17 09:52:56 -07:00
|
|
|
|
html += '<paper-input type="number" step="1" min="1" id="txtItemLimit" label="' + Globalize.translate('LabelItemLimit') + '"></paper-input>';
|
2015-06-01 11:36:09 -07:00
|
|
|
|
html += '<div class="fieldDescription">' + Globalize.translate('LabelItemLimitHelp') + '</div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
html += '</div>';
|
2015-03-14 21:17:35 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//html += '</div>';
|
|
|
|
|
//html += '</div>';
|
|
|
|
|
|
2016-02-07 14:48:08 -07:00
|
|
|
|
$(elem).html(html).trigger('create');
|
2015-03-14 21:17:35 -07:00
|
|
|
|
|
|
|
|
|
$('#selectSyncTarget', elem).on('change', function () {
|
|
|
|
|
|
|
|
|
|
loadQualityOptions(elem, this.value, options.dialogOptionsFn);
|
|
|
|
|
|
|
|
|
|
}).trigger('change');
|
|
|
|
|
|
|
|
|
|
$('#selectProfile', elem).on('change', function () {
|
|
|
|
|
|
|
|
|
|
onProfileChange(elem, this.value);
|
|
|
|
|
|
|
|
|
|
}).trigger('change');
|
|
|
|
|
|
|
|
|
|
$('#selectQuality', elem).on('change', function () {
|
|
|
|
|
|
|
|
|
|
onQualityChange(elem, this.value);
|
|
|
|
|
|
|
|
|
|
}).trigger('change');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-12 20:56:30 -07:00
|
|
|
|
function showSyncMenu(options) {
|
2014-07-18 12:07:28 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
requirejs(["registrationservices"], function () {
|
|
|
|
|
RegistrationServices.validateFeature('sync').then(function () {
|
2015-07-29 19:08:35 -07:00
|
|
|
|
showSyncMenuInternal(options);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showSyncMenuInternal(options) {
|
|
|
|
|
|
2016-01-30 12:31:22 -07:00
|
|
|
|
require(['paperdialoghelper', 'paper-fab'], function (paperDialogHelper) {
|
2014-07-22 09:36:34 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
var userId = Dashboard.getCurrentUserId();
|
2014-12-18 21:20:07 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
var dialogOptionsQuery = {
|
|
|
|
|
UserId: userId,
|
|
|
|
|
ItemIds: (options.items || []).map(function (i) {
|
|
|
|
|
return i.Id || i;
|
|
|
|
|
}).join(','),
|
2014-12-16 22:30:31 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ParentId: options.ParentId,
|
|
|
|
|
Category: options.Category
|
|
|
|
|
};
|
2014-07-22 09:36:34 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getJSON(ApiClient.getUrl('Sync/Options', dialogOptionsQuery)).then(function (dialogOptions) {
|
2014-07-22 09:36:34 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
currentDialogOptions = dialogOptions;
|
2014-07-22 09:36:34 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
var dlg = paperDialogHelper.createDialog({
|
|
|
|
|
size: 'small',
|
2016-01-30 13:59:09 -07:00
|
|
|
|
removeOnClose: true,
|
|
|
|
|
autoFocus: false
|
2015-12-14 08:43:03 -07:00
|
|
|
|
});
|
2015-02-04 23:13:20 -07:00
|
|
|
|
|
2016-01-30 13:59:09 -07:00
|
|
|
|
dlg.classList.add('ui-body-a');
|
|
|
|
|
dlg.classList.add('background-theme-a');
|
|
|
|
|
dlg.classList.add('popupEditor');
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
var html = '';
|
2016-02-10 19:56:24 -07:00
|
|
|
|
html += '<div class="dialogHeader">';
|
2016-02-12 23:55:13 -07:00
|
|
|
|
html += '<paper-icon-button icon="arrow-back" class="btnCancel" tabindex="-1"></paper-icon-button>';
|
2016-02-10 19:56:24 -07:00
|
|
|
|
html += '<div class="dialogHeaderTitle">';
|
|
|
|
|
html += Globalize.translate('SyncMedia');
|
|
|
|
|
html += '</div>';
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-02-10 19:56:24 -07:00
|
|
|
|
html += '<a href="https://github.com/MediaBrowser/Wiki/wiki/Sync" target="_blank" class="clearLink" style="margin-top:0;display:inline-block;vertical-align:middle;margin-left:auto;"><paper-button class="mini"><iron-icon icon="info"></iron-icon><span>' + Globalize.translate('ButtonHelp') + '</span></paper-button></a>';
|
2014-07-22 09:36:34 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
html += '</div>';
|
2014-12-13 14:26:04 -07:00
|
|
|
|
|
2016-02-10 19:56:24 -07:00
|
|
|
|
html += '<form class="formSubmitSyncRequest" style="margin: auto;">';
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
html += '<div class="formFields"></div>';
|
2014-07-22 09:36:34 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
html += '<p>';
|
|
|
|
|
html += '<button type="submit" data-role="none" class="clearButton"><paper-button raised class="submit block"><iron-icon icon="sync"></iron-icon><span>' + Globalize.translate('ButtonSync') + '</span></paper-button></button>';
|
|
|
|
|
html += '</p>';
|
2014-07-22 09:36:34 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
html += '</form>';
|
2014-07-22 09:36:34 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
dlg.innerHTML = html;
|
|
|
|
|
document.body.appendChild(dlg);
|
2014-07-22 09:36:34 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
paperDialogHelper.open(dlg);
|
2014-07-18 12:07:28 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
$('form', dlg).on('submit', function () {
|
2015-03-14 21:17:35 -07:00
|
|
|
|
|
2016-01-30 12:31:22 -07:00
|
|
|
|
submitJob(dlg, userId, options, this, paperDialogHelper);
|
2015-12-14 08:43:03 -07:00
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnCancel', dlg).on('click', function () {
|
|
|
|
|
paperDialogHelper.close(dlg);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
renderForm({
|
|
|
|
|
elem: $('.formFields', dlg),
|
|
|
|
|
dialogOptions: dialogOptions,
|
|
|
|
|
dialogOptionsFn: getTargetDialogOptionsFn(dialogOptionsQuery)
|
|
|
|
|
});
|
2015-03-14 21:17:35 -07:00
|
|
|
|
});
|
2015-06-17 23:23:44 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
});
|
2014-07-19 21:46:29 -07:00
|
|
|
|
}
|
2014-07-18 12:07:28 -07:00
|
|
|
|
|
2015-03-14 21:17:35 -07:00
|
|
|
|
function getTargetDialogOptionsFn(query) {
|
|
|
|
|
|
|
|
|
|
return function (targetId) {
|
|
|
|
|
|
|
|
|
|
query.TargetId = targetId;
|
|
|
|
|
return ApiClient.getJSON(ApiClient.getUrl('Sync/Options', query));
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 21:57:19 -07:00
|
|
|
|
function setQualityFieldVisible(form, visible) {
|
|
|
|
|
|
|
|
|
|
if (visible) {
|
|
|
|
|
$('.fldQuality', form).show();
|
|
|
|
|
$('#selectQuality', form).attr('required', 'required');
|
|
|
|
|
} else {
|
|
|
|
|
$('.fldQuality', form).hide();
|
|
|
|
|
$('#selectQuality', form).removeAttr('required');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-14 21:17:35 -07:00
|
|
|
|
function onProfileChange(form, profileId) {
|
|
|
|
|
|
|
|
|
|
var options = currentDialogOptions || {};
|
|
|
|
|
var option = (options.ProfileOptions || []).filter(function (o) {
|
|
|
|
|
return o.Id == profileId;
|
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
|
|
if (option) {
|
|
|
|
|
$('.profileDescription', form).html(option.Description || '');
|
2015-03-14 21:24:43 -07:00
|
|
|
|
setQualityFieldVisible(form, options.QualityOptions.length > 0 && option.EnableQualityOptions && options.Options.indexOf('Quality') != -1);
|
2015-03-14 21:17:35 -07:00
|
|
|
|
} else {
|
|
|
|
|
$('.profileDescription', form).html('');
|
2015-03-14 21:24:43 -07:00
|
|
|
|
setQualityFieldVisible(form, options.QualityOptions.length > 0 && options.Options.indexOf('Quality') != -1);
|
2015-03-14 21:17:35 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onQualityChange(form, qualityId) {
|
2015-03-11 22:08:36 -07:00
|
|
|
|
|
2015-03-14 21:17:35 -07:00
|
|
|
|
var options = currentDialogOptions || {};
|
|
|
|
|
var option = (options.QualityOptions || []).filter(function (o) {
|
|
|
|
|
return o.Id == qualityId;
|
|
|
|
|
})[0];
|
2015-03-11 22:08:36 -07:00
|
|
|
|
|
2015-03-14 21:17:35 -07:00
|
|
|
|
if (option) {
|
|
|
|
|
$('.qualityDescription', form).html(option.Description || '');
|
|
|
|
|
} else {
|
|
|
|
|
$('.qualityDescription', form).html('');
|
|
|
|
|
}
|
2015-03-11 22:08:36 -07:00
|
|
|
|
|
2015-03-14 21:17:35 -07:00
|
|
|
|
if (qualityId == 'custom') {
|
|
|
|
|
$('.fldBitrate', form).show();
|
|
|
|
|
$('#txtBitrate', form).attr('required', 'required');
|
|
|
|
|
} else {
|
|
|
|
|
$('.fldBitrate', form).hide();
|
2015-03-15 12:10:27 -07:00
|
|
|
|
$('#txtBitrate', form).removeAttr('required').val('');
|
2015-03-14 21:17:35 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-11 22:08:36 -07:00
|
|
|
|
|
2015-03-14 21:17:35 -07:00
|
|
|
|
function renderTargetDialogOptions(form, options) {
|
|
|
|
|
|
|
|
|
|
currentDialogOptions = options;
|
|
|
|
|
|
2015-03-16 20:48:05 -07:00
|
|
|
|
if (options.ProfileOptions.length && options.Options.indexOf('Profile') != -1) {
|
2015-03-14 21:17:35 -07:00
|
|
|
|
$('.fldProfile', form).show();
|
|
|
|
|
$('#selectProfile', form).attr('required', 'required');
|
|
|
|
|
} else {
|
|
|
|
|
$('.fldProfile', form).hide();
|
|
|
|
|
$('#selectProfile', form).removeAttr('required');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setQualityFieldVisible(options.QualityOptions.length > 0);
|
|
|
|
|
|
|
|
|
|
$('#selectProfile', form).html(options.ProfileOptions.map(function (o) {
|
|
|
|
|
|
|
|
|
|
var selectedAttribute = o.IsDefault ? ' selected="selected"' : '';
|
|
|
|
|
return '<option value="' + o.Id + '"' + selectedAttribute + '>' + o.Name + '</option>';
|
|
|
|
|
|
2015-09-03 10:01:51 -07:00
|
|
|
|
}).join('')).trigger('change');
|
2015-03-14 21:17:35 -07:00
|
|
|
|
|
|
|
|
|
$('#selectQuality', form).html(options.QualityOptions.map(function (o) {
|
|
|
|
|
|
|
|
|
|
var selectedAttribute = o.IsDefault ? ' selected="selected"' : '';
|
|
|
|
|
return '<option value="' + o.Id + '"' + selectedAttribute + '>' + o.Name + '</option>';
|
|
|
|
|
|
2015-09-03 10:01:51 -07:00
|
|
|
|
}).join('')).trigger('change');
|
2015-03-11 22:08:36 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 21:57:19 -07:00
|
|
|
|
function loadQualityOptions(form, targetId, dialogOptionsFn) {
|
2015-10-05 19:50:20 -07:00
|
|
|
|
|
2016-02-17 21:57:19 -07:00
|
|
|
|
dialogOptionsFn(targetId).then(function (options) {
|
2016-02-03 17:04:59 -07:00
|
|
|
|
|
2016-02-17 21:57:19 -07:00
|
|
|
|
renderTargetDialogOptions(form, options);
|
|
|
|
|
});
|
2014-07-18 12:07:28 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 21:57:19 -07:00
|
|
|
|
return {
|
2014-07-18 12:07:28 -07:00
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
showMenu: showSyncMenu,
|
2015-03-15 12:10:27 -07:00
|
|
|
|
renderForm: renderForm,
|
|
|
|
|
setJobValues: setJobValues
|
2014-07-18 12:07:28 -07:00
|
|
|
|
};
|
2016-02-17 21:57:19 -07:00
|
|
|
|
});
|