Skip to content

Commit

Permalink
Show only mapped classes checkbox add
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed Jan 3, 2017
1 parent ceeee06 commit 561fd1a
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 26 deletions.
18 changes: 10 additions & 8 deletions cache/projectTemplate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,24 @@ Return list with all namespaces</Description>
<Description>
Returns structured class tree with all classes available in current namespace</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>namespace:%String</FormalSpec>
<FormalSpec>namespace:%String,showMapped=0</FormalSpec>
<ReturnType>%ZEN.proxyObject</ReturnType>
<Implementation><![CDATA[
zn:$GET(namespace)'="" namespace
set resp = ##class(%ZEN.proxyObject).%New()
set classes = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:Summary")
set showSystem = (namespace="%SYS")
do $System.OBJ.GetClassList(.classes, "/system="_showSystem_" /percent="
_showSystem_" /mapped=" _ showMapped)
set objects = ##class(%Library.ArrayOfObjects).%New()
set lastParts = $LB()
set level = 1
do objects.SetAt(resp, level)
do classes.Execute()
while (classes.Next()) {
set name = classes.Data("Name")
if ($EXTRACT(name, 1, 1) = "%") && ($NAMESPACE '= "%SYS") { continue }
set name = $order(classes(""))
while (name '= "") {
//if ($EXTRACT(name, 1, 1) = "%") && ($NAMESPACE '= "%SYS") { continue }
set parts = $LISTFROMSTRING(name, ".")
set level = 1
while ((level < $LISTLENGTH(parts)) && ($LISTGET(lastParts, level) = ("/"_$LISTGET(parts, level)))) {
Expand All @@ -67,12 +68,13 @@ Returns structured class tree with all classes available in current namespace</D
do objects.SetAt(resp, level)
}
if ($LISTLENGTH(parts) = level) {
do resp.%DispatchSetProperty($LISTGET(parts, level), classes.Data("Hidden"))
do resp.%DispatchSetProperty($LISTGET(parts, level), 0)
}
set lastParts = parts
for i=1:1:$LISTLENGTH(lastParts)-1 {
set $LIST(lastParts, i) = "/"_$LISTGET(lastParts, i)
}
set name = $order(classes(name))
}
quit objects.GetAt(1)
Expand Down Expand Up @@ -461,7 +463,7 @@ Method returns whole class tree visible in the current namespace.</Description>
<ClassMethod>1</ClassMethod>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
do ##class(ClassExplorer.ClassView).getClassTree(%request.Get("namespace")).%ToJSON(, "o")
do ##class(ClassExplorer.ClassView).getClassTree(%request.Get("namespace"), %request.Get("mapped")).%ToJSON(, "o")
return $$$OK
]]></Implementation>
</Method>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CacheClassExplorer",
"version": "1.18.1",
"version": "1.19.0",
"description": "Class Explorer for InterSystems Caché",
"directories": { "test": "test" },
"dependencies": {},
Expand Down
13 changes: 12 additions & 1 deletion web/css/treeView.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
z-index: 1;
}

.ui-sideSearchBlock > input {
.ui-sideSearchBlock input[type=search] {
display: block;
box-sizing: border-box;
border: 1px solid gray;
Expand All @@ -26,6 +26,17 @@
height: 22px;
}

.ui-sideSearchBlock label {
cursor: pointer;
user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}

.ui-sideSearchBlock input[type=checkbox] {
vertical-align: middle;
}

.tv-package-name.minimized + .tv-package-content {
display: none;
}
Expand Down
10 changes: 9 additions & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@
<div class="ui-body" id="ui-body">
<div class="ui-sideBlock">
<div class="ui-sideSearchBlock" id="searchBlock">
<input type="search" id="classTreeSearch" placeholder="Search in class tree..."/>
<div>
<label>
<input type="checkbox" id="showMappedCheckbox"/>
Show Mapped Classes
</label>
</div>
<div>
<input type="search" id="classTreeSearch" placeholder="Search in class tree..."/>
</div>
</div>
<div id="treeView">

Expand Down
13 changes: 3 additions & 10 deletions web/js/CacheClassExplorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var CacheClassExplorer = function (treeViewContainer, classViewContainer) {
subLabel: id("subLabel"),
closeHelp: id("closeHelp"),
settingsExtraText: id("settingsExtraText"),
showMappedCheckbox: id("showMappedCheckbox"),
settings: {
showDataTypesOnDiagram: id("setting.showDataTypesOnDiagram"),
showClassIcons: id("setting.showClassIcons"),
Expand Down Expand Up @@ -150,16 +151,10 @@ CacheClassExplorer.prototype.updateNamespaces = function (nsData) {
*/
CacheClassExplorer.prototype.setNamespace = function (namespace) {

var self = this;

this.NAMESPACE = namespace;
this.classTree.setSelectedClassList([]);

self.classTree.container.textContent = "";
self.classTree.showLoader();
this.source.getClassTree(function (err, data) {
if (!err) self.classTree.updateTree(data);
});
this.classTree.update();

this.updateNamespace();
this.updateURL();
Expand Down Expand Up @@ -269,9 +264,7 @@ CacheClassExplorer.prototype.init = function () {

restored = this.restoreFromURL();
this.classTree.showLoader();
this.source.getClassTree(function (err, data) {
if (!err) self.classTree.updateTree(data);
});
this.classTree.init();
this.source.getNamespacesInfo(function (err, data) {
if (restored && restored.namespace) data.currentNamespace = restored.namespace;
if (!err) self.updateNamespaces(data);
Expand Down
29 changes: 26 additions & 3 deletions web/js/ClassTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var ClassTree = function (parent, treeViewContainer) {
this.SELECTED_TYPE = null; // "class" || "package"
this.SELECTED_ELEMENT = null;
this.SELECTED_LEVEL = null;
this.INCLUDE_MAPPED = this.cacheClassExplorer.elements.showMappedCheckbox.checked;
this.treeObject = null;
/**
* @private
Expand All @@ -25,6 +26,10 @@ var ClassTree = function (parent, treeViewContainer) {
this.cacheClassExplorer.elements.classTreeSearch.addEventListener("input", function (e) {
self.searchChanged.call(self, (e.target || e.srcElement).value);
});
this.cacheClassExplorer.elements.showMappedCheckbox.addEventListener("change", function () {
self.INCLUDE_MAPPED = self.cacheClassExplorer.elements.showMappedCheckbox.checked;
self.update();
});

window.addEventListener("resize", function () {
self.updateSizes();
Expand All @@ -34,6 +39,19 @@ var ClassTree = function (parent, treeViewContainer) {

};

ClassTree.prototype.update = function () {

var self = this;

this.cacheClassExplorer.elements.classTreeSearch.value = "";
this.container.textContent = "";
this.showLoader();
this.cacheClassExplorer.source.getClassTree(this.INCLUDE_MAPPED, function (err, data) {
if (!err) self.updateTree(data);
});

};

ClassTree.prototype.setSelectedClassList = function (list) {

// this enables saved view to be consistent for any class names order
Expand Down Expand Up @@ -70,7 +88,8 @@ ClassTree.prototype.removeLoader = function () {
if (!this.loader) return;

this.cacheClassExplorer.elements.classTreeSearch.value = "";
this.loader.parentNode.removeChild(this.loader);
if (this.loader.parentNode)
this.loader.parentNode.removeChild(this.loader);
this.loader = null;

};
Expand Down Expand Up @@ -255,7 +274,7 @@ ClassTree.prototype.updateTree = function (treeObject, doNotChangeRoot) {
arr = [];

for (i in object) {
arr.push({ name: getRealName(i), val: object[i] });
arr.push({ name: getRealName(i), val: object[i], isPackage: i[0] === "/" });
}

arr.sort(function (a, b) {
Expand All @@ -268,7 +287,7 @@ ClassTree.prototype.updateTree = function (treeObject, doNotChangeRoot) {
if (rec = append(
rootElement,
element.name,
typeof element.val === "object",
element.isPackage,
path.join("."),
level
)) {
Expand All @@ -282,4 +301,8 @@ ClassTree.prototype.updateTree = function (treeObject, doNotChangeRoot) {

if (!doNotChangeRoot) this.treeObject = treeObject;

};

ClassTree.prototype.init = function () {
this.update();
};
6 changes: 4 additions & 2 deletions web/js/Source.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ var Source = function (cacheUMLExplorer) {

/**
* Return class tree.
* @param {boolean} includeMapped
* @param {Source~dataCallback} callback
*/
Source.prototype.getClassTree = function (callback) {
Source.prototype.getClassTree = function (includeMapped, callback) {

lib.load(
this.URL + "/GetClassTree"
+ (this.cue.NAMESPACE ? "?namespace=" + encodeURIComponent(this.cue.NAMESPACE) : ""),
+ (this.cue.NAMESPACE ? "?namespace=" + encodeURIComponent(this.cue.NAMESPACE) : "")
+ "&mapped=" + (includeMapped ? "1" : "0"),
null,
callback
);
Expand Down

0 comments on commit 561fd1a

Please sign in to comment.