Update RepoControls.plugin.js

This commit is contained in:
Mirco Wittrien 2020-03-24 15:46:41 +01:00
parent 7ca1d8c822
commit 9725f7a462
1 changed files with 40 additions and 40 deletions

View File

@ -6,7 +6,7 @@ var RepoControls = (_ => {
return class RepoControls { return class RepoControls {
getName () {return "RepoControls";} getName () {return "RepoControls";}
getVersion () {return "1.3.7";} getVersion () {return "1.3.8";}
getAuthor () {return "DevilBro";} getAuthor () {return "DevilBro";}
@ -15,10 +15,9 @@ var RepoControls = (_ => {
constructor () { constructor () {
this.patchedModules = { this.patchedModules = {
after: { after: {
V2C_List: "render", V2C_ContentColumn: "render",
V2C_PluginCard: "render", V2C_PluginCard: "render",
V2C_ThemeCard: "render", V2C_ThemeCard: "render",
V2C_ContentColumn: "render"
} }
}; };
} }
@ -136,7 +135,7 @@ var RepoControls = (_ => {
processV2CThemeCard (e) { processV2CThemeCard (e) {
if (!e.instance.props.RCdata) return; if (!e.instance.props.RCdata) return;
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props: [["className", "bda-controls"]]}); let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props: [["className", BDFDB.disCN._repocontrols]]});
if (index > -1) { if (index > -1) {
let settings = BDFDB.DataUtils.get(this, "settings"); let settings = BDFDB.DataUtils.get(this, "settings");
if (settings.addDeleteButton) children[index].props.children.unshift(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, { if (settings.addDeleteButton) children[index].props.children.unshift(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
@ -172,7 +171,7 @@ var RepoControls = (_ => {
} }
}) })
})); }));
this.highlightSearchKey(e); this.highlightsearchKey(e);
} }
} }
@ -231,27 +230,27 @@ var RepoControls = (_ => {
})); }));
} }
sortEntries (instance, parent, searchkey = parent.props.searchkey) { sortEntries (instance, parent, searchKey = parent.props.searchKey) {
if (instance) instance = BDFDB.ReactUtils.findOwner(instance, {key: ["plugin-list", "theme-list"]}); if (instance) instance = BDFDB.ReactUtils.findOwner(instance, {key: ["plugin-list", "theme-list"]});
let sortings = BDFDB.DataUtils.get(this, "sortings"); let sortings = BDFDB.DataUtils.get(this, "sortings");
parent.props.searchkey = (searchkey || "").toUpperCase(); parent.props.searchKey = (searchKey || "").toUpperCase();
if (!parent.props.entries) parent.props.entries = parent.props.children; if (!parent.props.entries) parent.props.entries = parent.props.children;
let entries = [].concat(parent.props.entries); let entries = [].concat(parent.props.entries);
for (let i in entries) { for (let i in entries) {
let entry = entries[i]; let entry = BDFDB.ReactUtils.findChild(entries[i], {props: ["plugin", "theme"], someProps: true});
if (entry) {
if (!entry.props.RCdata) { if (!entry.props.RCdata) {
entry.props.RCdata = {}; entry.props.RCdata = {};
if (entry.props.plugin) { if (entry.props.plugin) {
["name", "author", "version", "description"].forEach(key => { ["name", "author", "version", "description"].forEach(key => {
let funcname = "get" + key.charAt(0).toUpperCase() + key.slice(1); let funcName = "get" + BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(key);
let value = typeof entry.props.plugin[funcname] == "function" ? entry.props.plugin[funcname]() : ""; let value = typeof entry.props.plugin[funcName] == "function" ? entry.props.plugin[funcName]() : "";
if (value) entry.props.RCdata[key] = value.toUpperCase().trim(); entry.props.RCdata[key] = value && value.toUpperCase().trim() || "";
else entry.props.RCdata[key] = "";
}); });
entry.props.RCdata.type = "plugin"; entry.props.RCdata.type = "plugin";
entry.props.RCdata.enabled = BDFDB.BDUtils.isPluginEnabled(entry.key) ? 1 : 2; entry.props.RCdata.enabled = BDFDB.BDUtils.isPluginEnabled(entry.key) ? 1 : 2;
@ -260,8 +259,7 @@ var RepoControls = (_ => {
} }
else if (entry.props.theme) { else if (entry.props.theme) {
["name", "author", "version", "description"].forEach(key => { ["name", "author", "version", "description"].forEach(key => {
if (entry.props.theme[key]) entry.props.RCdata[key] = entry.props.theme[key].toUpperCase().trim(); entry.props.RCdata[key] = entry.props.theme[key] && entry.props.theme[key].toUpperCase().trim() || "";
else entry.props.RCdata[key] = "";
}); });
entry.props.RCdata.type = "theme"; entry.props.RCdata.type = "theme";
entry.props.RCdata.enabled = BDFDB.BDUtils.isThemeEnabled(entry.key) ? 1 : 2; entry.props.RCdata.enabled = BDFDB.BDUtils.isThemeEnabled(entry.key) ? 1 : 2;
@ -273,8 +271,10 @@ var RepoControls = (_ => {
entry.props.RCdata.moddate = stats && stats.mtime.getTime(); entry.props.RCdata.moddate = stats && stats.mtime.getTime();
entry.props.RCdata.search = [entry.props.RCdata.name, entry.props.RCdata.author, entry.props.RCdata.description].filter(n => n).join(" "); entry.props.RCdata.search = [entry.props.RCdata.name, entry.props.RCdata.author, entry.props.RCdata.description].filter(n => n).join(" ");
} }
entry.props.RCdata.searchkey = parent.props.searchkey; entry.props.RCdata.searchKey = parent.props.searchKey;
if (parent.props.searchkey && entry.props.RCdata.search.indexOf(parent.props.searchkey) == -1) entries[i] = null; if (parent.props.searchKey && entry.props.RCdata.search.indexOf(parent.props.searchKey) == -1) entries[i] = null;
else entries[i].props.RCdata = entry.props.RCdata;
}
} }
let order = sortings.order == "asc" ? -1 : 1; let order = sortings.order == "asc" ? -1 : 1;
@ -290,13 +290,13 @@ var RepoControls = (_ => {
} }
} }
highlightSearchKey (e) { highlightsearchKey (e) {
if (!e.instance.props.RCdata.searchkey) return; if (!e.instance.props.RCdata.searchKey) return;
[BDFDB.disCN._reponame, BDFDB.disCN._repoauthor, BDFDB.disCN._repodescription].forEach(className => { [BDFDB.disCN._reponame, BDFDB.disCN._repoauthor, BDFDB.disCN._repodescription].forEach(className => {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props: [["className", className]]}); let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props: [["className", className]]});
if (index > -1) { if (index > -1) {
let originalText = BDFDB.StringUtils.htmlEscape(children[index].props.children); let originalText = BDFDB.StringUtils.htmlEscape(children[index].props.children);
let highlightedText = BDFDB.StringUtils.highlight(originalText, e.instance.props.RCdata.searchkey); let highlightedText = BDFDB.StringUtils.highlight(originalText, e.instance.props.RCdata.searchKey);
if (highlightedText != originalText) children[index].props.children = BDFDB.ReactUtils.elementToReact(BDFDB.DOMUtils.create(highlightedText)); if (highlightedText != originalText) children[index].props.children = BDFDB.ReactUtils.elementToReact(BDFDB.DOMUtils.create(highlightedText));
} }
}); });