Merge pull request #9228 from Piccirello/addCategory

Add save path and category editing to WebUI
This commit is contained in:
Vladimir Golovnev
2018-09-13 19:43:28 +03:00
committed by GitHub
12 changed files with 199 additions and 65 deletions

View File

@@ -327,13 +327,21 @@ window.addEvent('load', function() {
syncMainDataLastResponseId = response['rid'];
}
if (response['categories']) {
response['categories'].each(function(category) {
var categoryHash = genHash(category);
category_list[categoryHash] = {
name: category,
torrents: []
};
});
for (var key in response['categories']) {
var category = response['categories'][key];
var categoryHash = genHash(key);
if (category_list[categoryHash] !== undefined) {
// only the save path can change for existing categories
category_list[categoryHash].savePath = category.savePath;
}
else {
category_list[categoryHash] = {
name: category.name,
savePath: category.savePath,
torrents: []
};
}
}
update_categories = true;
}
if (response['categories_removed']) {

View File

@@ -387,9 +387,13 @@ var CategoriesFilterContextMenu = new Class({
Extends: ContextMenu,
updateMenuItems: function() {
var id = this.options.element.id;
if (id != CATEGORIES_ALL && id != CATEGORIES_UNCATEGORIZED)
if ((id != CATEGORIES_ALL) && (id != CATEGORIES_UNCATEGORIZED)) {
this.showItem('EditCategory');
this.showItem('DeleteCategory');
else
}
else {
this.hideItem('EditCategory');
this.hideItem('DeleteCategory');
}
}
});

View File

@@ -120,3 +120,14 @@ function escapeHtml(str) {
div.appendChild(document.createTextNode(str));
return div.innerHTML;
}
function safeTrim(value) {
try {
return value.trim();
}
catch (e) {
if (e instanceof TypeError)
return "";
throw e;
}
}

View File

@@ -458,20 +458,21 @@ initializeWindows = function() {
};
torrentNewCategoryFN = function() {
var action = "set";
var hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new MochaUI.Window({
id: 'newCategoryPage',
title: "QBT_TR(New Category)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: 'iframe',
contentURL: 'newcategory.html?hashes=' + hashes.join('|'),
contentURL: 'newcategory.html?action=' + action + '&hashes=' + hashes.join('|'),
scrollbars: false,
resizable: false,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 250,
height: 100
height: 150
});
}
};
@@ -494,18 +495,39 @@ initializeWindows = function() {
};
createCategoryFN = function() {
var action = "create";
new MochaUI.Window({
id: 'newCategoryPage',
title: "QBT_TR(New Category)QBT_TR[CONTEXT=CategoryFilterWidget]",
loadMethod: 'iframe',
contentURL: 'newcategory.html',
contentURL: 'newcategory.html?action=' + action,
scrollbars: false,
resizable: false,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 250,
height: 100
height: 150
});
updateMainData();
};
editCategoryFN = function(categoryHash) {
var action = "edit";
var categoryName = category_list[categoryHash].name;
var savePath = category_list[categoryHash].savePath;
new MochaUI.Window({
id: 'editCategoryPage',
title: "QBT_TR(Edit Category)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: 'iframe',
contentURL: 'newcategory.html?action=' + action + '&categoryName=' + categoryName + '&savePath=' + savePath,
scrollbars: false,
resizable: false,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 250,
height: 150
});
updateMainData();
};