2015-09-22 21:12:46 -07:00
|
|
|
|
(function ($, document, window) {
|
|
|
|
|
|
|
|
|
|
var query = {
|
|
|
|
|
|
|
|
|
|
StartIndex: 0,
|
|
|
|
|
Limit: 100000
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var currentResult;
|
|
|
|
|
|
|
|
|
|
function reloadList(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2016-02-04 19:01:03 -07:00
|
|
|
|
ApiClient.getSmartMatchInfos(query).then(function (infos) {
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
|
|
|
|
currentResult = infos;
|
|
|
|
|
|
|
|
|
|
populateList(page, infos);
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2016-02-04 19:01:03 -07:00
|
|
|
|
|
2016-02-09 10:13:38 -07:00
|
|
|
|
}, function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
2015-09-22 21:12:46 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function populateList(page, result) {
|
|
|
|
|
|
|
|
|
|
var infos = result.Items;
|
|
|
|
|
|
|
|
|
|
if (infos.length > 0) {
|
|
|
|
|
infos = infos.sort(function (a, b) {
|
|
|
|
|
|
2016-02-17 20:18:28 -07:00
|
|
|
|
a = a.OrganizerType + " " + (a.DisplayName || a.ItemName);
|
|
|
|
|
b = b.OrganizerType + " " + (b.DisplayName || b.ItemName);
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
|
|
|
|
if (a == b) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (a < b) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var html = "";
|
2016-02-12 23:39:23 -07:00
|
|
|
|
|
|
|
|
|
if (infos.length) {
|
|
|
|
|
html += '<div class="paperList">';
|
|
|
|
|
}
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
|
|
|
|
for (var i = 0, length = infos.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var info = infos[i];
|
|
|
|
|
|
2016-02-12 23:39:23 -07:00
|
|
|
|
html += '<paper-icon-item>';
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
2016-02-12 23:39:23 -07:00
|
|
|
|
html += '<paper-fab mini icon="folder" item-icon class="blue"></paper-fab>';
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
2016-02-12 23:39:23 -07:00
|
|
|
|
html += '<paper-item-body two-line>';
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
2016-02-17 20:18:28 -07:00
|
|
|
|
html += "<div>" + (info.DisplayName || info.ItemName) + "</div>";
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
2016-02-12 23:39:23 -07:00
|
|
|
|
html += info.MatchStrings.map(function (m) {
|
|
|
|
|
return "<div secondary>" + m + "</div>";
|
|
|
|
|
}).join('');
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
2016-02-12 23:39:23 -07:00
|
|
|
|
html += '</paper-item-body>';
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
2016-02-12 23:39:23 -07:00
|
|
|
|
html += '<paper-icon-button icon="delete" class="btnDeleteMatchEntry" data-index="' + i + '" title="' + Globalize.translate('ButtonDelete') + '"></paper-icon-button>';
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
2016-02-12 23:39:23 -07:00
|
|
|
|
html += '</paper-icon-item>';
|
2015-09-22 21:12:46 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 23:39:23 -07:00
|
|
|
|
if (infos.length) {
|
|
|
|
|
html += "</div>";
|
|
|
|
|
}
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
|
|
|
|
$('.divMatchInfos', page).html(html).trigger('create');
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-04 19:01:03 -07:00
|
|
|
|
function onApiFailure(e) {
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
|
|
|
|
|
Dashboard.alert({
|
2016-02-09 10:13:38 -07:00
|
|
|
|
message: Globalize.translate('DefaultErrorMessage')
|
2016-02-04 19:01:03 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
|
|
|
|
$(document).on('pageinit', "#libraryFileOrganizerSmartMatchPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('.divMatchInfos', page).on('click', '.btnDeleteMatchEntry', function () {
|
|
|
|
|
|
|
|
|
|
var button = this;
|
2016-02-12 23:39:23 -07:00
|
|
|
|
var index = parseInt(button.getAttribute('data-index'));
|
|
|
|
|
|
|
|
|
|
var info = currentResult.Items[index];
|
|
|
|
|
var entries = info.MatchStrings.map(function (m) {
|
|
|
|
|
return {
|
|
|
|
|
Name: info.ItemName,
|
|
|
|
|
Value: m
|
|
|
|
|
};
|
|
|
|
|
});
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
2016-02-12 23:19:28 -07:00
|
|
|
|
ApiClient.deleteSmartMatchEntries(entries).then(function () {
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
|
|
|
|
reloadList(page);
|
|
|
|
|
|
2016-02-04 19:01:03 -07:00
|
|
|
|
}, onApiFailure);
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2016-02-04 19:01:03 -07:00
|
|
|
|
}).on('pageshow', "#libraryFileOrganizerSmartMatchPage", function () {
|
2015-09-22 21:12:46 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
reloadList(page);
|
|
|
|
|
|
|
|
|
|
}).on('pagebeforehide', "#libraryFileOrganizerSmartMatchPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
currentResult = null;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, window);
|