Skip to content

Commit

Permalink
- Fix unfunctional filter
Browse files Browse the repository at this point in the history
- Add links to welcome page to display demos and packages with problems
- Click on search icon clears filter textbox
  • Loading branch information
cboulanger committed Jul 23, 2019
1 parent 19f10c2 commit cee5178
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
45 changes: 25 additions & 20 deletions source/class/qxl/packagebrowser/PackageBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,13 @@ qx.Class.define("qxl.packagebrowser.PackageBrowser", {

var searchIcon = new qx.ui.basic.Image("icon/16/actions/edit-find.png");
searchComposlite.add(searchIcon);
searchIcon.addListener("tap", () => this._searchTextField.setValue(""));

let stf = this._searchTextField = new qx.ui.form.TextField();
stf.setLiveUpdate(true);
stf.setAppearance("widget");
stf.setPlaceholder("Filter...");

this._searchTextField = new qx.ui.form.TextField();
this._searchTextField.setLiveUpdate(true);
this._searchTextField.setAppearance("widget");
this._searchTextField.setPlaceholder("Filter...");

var filterTimer = new qx.event.Timer(500);
filterTimer.addListener("interval", function (ev) {
Expand Down Expand Up @@ -915,9 +917,9 @@ qx.Class.define("qxl.packagebrowser.PackageBrowser", {
var searchRegExp = new RegExp("^.*" + term + ".*", "ig");
var items = this._tree.getRoot().getItems(true, true);

var showing = 0;
var found = 0;
var count = 0;
for (var i = 0; i < items.length; i++) {
for (let i = 0; i < items.length; i++) {
var folder = items[i];
var parent = folder.getParent();

Expand All @@ -926,37 +928,40 @@ qx.Class.define("qxl.packagebrowser.PackageBrowser", {
var inTags = false;

if (tags != null) {
for (var j = 0; j < tags.length; j++) {
count++;
for (let j = 0; j < tags.length; j++) {
inTags = Boolean(tags[j].match(searchRegExp));
if (inTags) {
break;
}
}
}

if (folder.getChildren().length === 0) {
count++;
}

if ((inTags || (folder.getLabel().search(searchRegExp) !== -1) || (parent.getLabel().search(searchRegExp) !== -1))) {
if (folder.getChildren().length === 0) {
showing++;
}
found++;
folder.setOpen(false);
folder.setUserData("show", true);
folder.show();
folder.getParent().setOpen(true);
folder.getParent().show();
while (parent) {
parent.setOpen(true);
parent.show();
parent = parent.getParent();
}
} else {
folder.exclude();
folder.setUserData("show", false);
if (!parent.getUserData("show")) {
folder.exclude();
}
}
}

// special case for the empty sting
// special case for the empty string
if (term === "") {
var folders = this._tree.getRoot().getItems(false, true);
var selection = this._tree.getSelection();

// close all folders
for (var i = 0; i < folders.length; i++) {
for (let i = 0; i < folders.length; i++) {
// don't close the current selected
if (folders[i] === selection[0] || folders[i] === selection[0].getParent()) {
continue;
Expand All @@ -966,7 +971,7 @@ qx.Class.define("qxl.packagebrowser.PackageBrowser", {
}

// update the status
this._status.setValue(showing + "/" + count);
this._status.setValue(found + "/" + count);
},

/**
Expand Down
8 changes: 5 additions & 3 deletions source/resource/qxl/packagebrowser/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ <h1>Welcome to the Package Browser</h1>
applications this way.</p>
<p>Please <span style="font-weight: bold">browse the packages</span> by owner
and repository on the left side or search the packages using the filter.</p>
<p>This viewer also contains a <span style="font-weight: bold">live
demo</span> of all packages that contain a compilable application, and
displays warnings and errors that were logged during the compilation.</p>
<p>This viewer also contains <span style="font-weight: bold">live
demos</span> of <a href="javascript:void(top.location.href='/#filter~demos')">
all packages that contain a compilable application</a>, and
displays <a href="javascript:void(top.location.href='/#filter~problems')">
warnings and errors</a> that were logged during the compilation.</p>
<p>To learn how to install the packages or to publish your own qooxdoo library
as a package, please consult the <span style="font-weight: bold">documentation</span>
on <a href="javascript:void(window.open('/docs/#/cli/packages'))">the qooxdoo package system</a>.</p>
Expand Down

0 comments on commit cee5178

Please sign in to comment.