Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree selector for ignore patterns #9132

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions gui/default/assets/css/overrides.css
Original file line number Diff line number Diff line change
Expand Up @@ -349,31 +349,41 @@ ul.three-columns li, ul.two-columns li {
z-index: 980;
}

/*
* Folder Tree Ignores tweaks
*/

#folderGlobalTree .fancytree-container {
padding-left: 0;
}

/*
* Restore Versions tweaks
*/

#restoreTree-container {
#restoreTree-container, #folderGlobalTree-container {
overflow-y: scroll;
resize: vertical;
/* Limit height to prevent vertical screen overflow. */
max-height: calc(100vh - 390px);
/* Always fit at least one folder with dropdown open. */
min-height: 136px;
}

@media (min-width: 768px) {
#restoreTree-container {
max-height: calc(100vh - 401px);
}
}

@media (min-width: 992px) {
#restoreTree-container {
max-height: calc(100vh - 333px);
}
}

/* Ignore fixed height when manually resized. */
#restoreTree-container[style*="height"] {
#restoreTree-container[style*="height"], #folderGlobalTree-container[style*="height"] {
max-height: none;
}

Expand Down Expand Up @@ -545,8 +555,8 @@ ul.three-columns li, ul.two-columns li {

/* Make a "well" look more like a readonly text input when grouped with a button */
.input-group .well-sm {
padding-top: 6px;
padding-bottom: 6px;
padding-top: 6px;
padding-bottom: 6px;
}

/* CJK languages don't use italic at all, hence don't force it on them. */
Expand Down
10 changes: 10 additions & 0 deletions gui/default/assets/css/tree.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
.fancytree-container {
cursor: pointer;
width: 100%;
list-style-type: none;
}

.fancytree-container ul {
list-style-type: none;
}

.fancytree-hide {
Expand All @@ -33,10 +38,15 @@
.fancytree-expander,
.fancytree-icon {
margin-top: 4px;
margin-left: 10px;
vertical-align: top;
width: 16px;
}

.fancytree-helper-indeterminate-cb:before {
content: "\f14a";
}

.fancytree-childcounter {
background: #777;
border-radius: 10px;
Expand Down
80 changes: 80 additions & 0 deletions gui/default/fancyTreeGlobalDataWorker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const generatedByTreeSelector = "// Generated by tree selector";

var ignores = [];
var invalidPattern = false;
var selectedAll = false;
var itemCount = 0;

// To prevent running multiple jobs at once.
// When new job starts old one cancel itself.
var latestReqId = 0;

self.onmessage = function (msg) {
//console.log("fancyTreeGlobalDataWorker | start", "data", msg.data)
const newReqId = Date.now();
latestReqId = newReqId;

// Just cancellation message.
if (!msg.data?.data) {
//console.log("fancyTreeGlobalDataWorker | cancel requested")
return;
}

ignores = msg.data.ignorePatterns;
if (ignores[0] !== generatedByTreeSelector) {
invalidPattern = true;
ignores = [];
} else {
ignores = ignores.slice(1, -1)
}

//console.log("fancyTreeGlobalDataWorker | ignores.length", ignores.length)
const selectAllPattern = ignores.length == 0 || (ignores.length == 1 && ignores[0] == "");
selectedAll = true;
itemCount = 0;

self.postMessage({
data: formatGlobalTreeNodes(msg.data.data, "", newReqId, !selectAllPattern),
invalidPattern: invalidPattern,
selectedAll: selectedAll,
itemCount: itemCount,
});
inProgress = false;
//console.log("fancyTreeGlobalDataWorker | finished");
}

function formatGlobalTreeNodes(data, parentKey, reqId, parentIgnored = true) {
if (reqId != latestReqId) {
//console.log("fancyTreeGlobalDataWorker | cancelled", reqId)
return null;
}

var result = [];
// console.log("formatGlobalTreeNodes(worker)", "data", data, "parentKey", parentKey, "parentIgnored", parentIgnored)
data.forEach(function (node) {
const isFolder = node.type == "FILE_INFO_TYPE_DIRECTORY";
const key = parentKey + "/" + node.name;
const found = ignores.find(function (ignoreKey) {
return key == ignoreKey.slice(1);
});

const ignored = parentIgnored && !found;
if (ignored)
selectedAll = false;

result.push({
children: isFolder && node.children?.length > 0 ? formatGlobalTreeNodes(node.children, key, reqId, ignored) : [],
key: key,
title: node.name,
folder: isFolder,
selected: !ignored
});
if (reqId != latestReqId) {
//console.log("fancyTreeGlobalDataWorker | cancelled", reqId)
return null;
}
});

itemCount += result.length;
return result;
}
Loading
Loading