mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Started to implement clear plugin metadata.
Right now it doesn't care what your answer to the dialog is, I need to event handle or promise that.
This commit is contained in:
@@ -47,6 +47,23 @@ var pluginMenuProto = Object.create(HTMLElement.prototype, {
|
||||
loot.query(request).catch(processCefError);
|
||||
} else if (evt.target.id == 'clearMetadata') {
|
||||
showMessageDialog('Clear Plugin Metadata', 'Are you sure you want to clear all existing user-added metadata from "' + pluginCard.querySelector('h1').textContent + '"?');
|
||||
|
||||
var request = JSON.stringify({
|
||||
name: 'clearPluginMetadata',
|
||||
args: [
|
||||
pluginCard.getElementsByTagName('h1')[0].textContent
|
||||
]
|
||||
});
|
||||
|
||||
loot.query(request).then(function(result){
|
||||
/* Need to also empty the UI-side user metadata. */
|
||||
for (var i = 0; i < loot.game.plugins.length; ++i) {
|
||||
if (loot.game.plugins[i].id == pluginID) {
|
||||
loot.game.plugins[i].userlist = undefined;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}).catch(processCefError);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -323,20 +323,14 @@ function Plugin(obj) {
|
||||
document.getElementById('pluginsNav').appendChild(li);
|
||||
}
|
||||
|
||||
Plugin.prototype.changeAction = function(change) {
|
||||
console.log(change);
|
||||
}
|
||||
|
||||
Plugin.prototype.observer = function(changes) {
|
||||
//console.log(changes);
|
||||
changes.forEach(function(change) {
|
||||
//for (var i = 0; i < changes.length; ++i) {
|
||||
|
||||
if (change.name == 'name') {
|
||||
change.object.card.querySelector('h1').textContent = change.object[change.name];
|
||||
console.log(change);
|
||||
if (change.name == 'userlist') {
|
||||
change.object.li.setAttribute('data-edits', change.object[change.name] != undefined);
|
||||
change.object.card.setAttribute('data-edits', change.object[change.name] != undefined);
|
||||
}
|
||||
});
|
||||
//changes.forEach(changeAction);
|
||||
}
|
||||
|
||||
this.createCard();
|
||||
|
||||
@@ -260,6 +260,20 @@ namespace loot {
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
else if (requestName == "clearPluginMetadata") {
|
||||
// Has one arg, which is the name of the plugin to copy metadata for.
|
||||
const string pluginName = req["args"][0].as<string>();
|
||||
BOOST_LOG_TRIVIAL(debug) << "Clearing user metadata for plugin " << pluginName;
|
||||
|
||||
auto pluginIt = find(g_app_state.CurrentGame().userlist.plugins.begin(), g_app_state.CurrentGame().userlist.plugins.end(), Plugin(pluginName));
|
||||
|
||||
if (pluginIt != g_app_state.CurrentGame().userlist.plugins.end()) {
|
||||
g_app_state.CurrentGame().userlist.plugins.erase(pluginIt);
|
||||
}
|
||||
|
||||
callback->Success("");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user