Skip to content

Commit

Permalink
Local storing method enhance, inheritance level fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed Jan 17, 2016
1 parent deb3baf commit 76d46b8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 51 deletions.
12 changes: 6 additions & 6 deletions cache/projectTemplate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Description>
Cache Class Explorer vX.X.X/*build.replace:pkg.version*/
Class contains methods that return structured classes/packages data.</Description>
<TimeChanged>63928,63957.580821</TimeChanged>
<TimeChanged>63934,52160.80625</TimeChanged>
<TimeCreated>63653,67019.989197</TimeCreated>

<Method name="getAllNamespacesList">
Expand Down Expand Up @@ -87,8 +87,8 @@ Return structured data about class.</Description>
<Private>1</Private>
<ReturnType>%ZEN.proxyObject</ReturnType>
<Implementation><![CDATA[
if ((level'="")&&(+currLevel>+level)) quit ""
set currLevel=$increment(currLevel)
if ((level'="")&&(+currLevel>+level)) quit ""
set currLevel=$increment(currLevel)
set classDefinition = ##class(%Dictionary.ClassDefinition).%OpenId(className)
set compiledClassDefinition = ##class(%Dictionary.CompiledClass).%OpenId(className)
if (classDefinition = "") || (oData.classes.%DispatchGetProperty(classDefinition.Name) '= "") quit ""
Expand Down Expand Up @@ -213,7 +213,7 @@ Return structured data about class.</Description>
do oIndices.%DispatchSetProperty(ind.Name, oProp)
}
do ..collectInheritance(oData, oClass.Super)
do ..collectInheritance(oData, oClass.Super, level, currLevel)
quit oClass
]]></Implementation>
Expand Down Expand Up @@ -305,13 +305,13 @@ Return extended inheritance names</Description>
Fill inheritance data
Returns new (correct) super</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>oData:%ZEN.proxyObject,super:%String</FormalSpec>
<FormalSpec>oData:%ZEN.proxyObject,super:%String,level:%String="",currLevel:%Integer=0</FormalSpec>
<Private>1</Private>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
set superParts = $LISTFROMSTRING(super, ",")
for i=1:1:$LISTLENGTH(superParts) {
do ..fillClassData(oData, $LISTGET(superParts, i))
do ..fillClassData(oData, $LISTGET(superParts, i), level, currLevel)
}
quit $$$OK
]]></Implementation>
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.13.4",
"version": "1.14.0",
"description": "Class Explorer for InterSystems Caché",
"directories": {
"test": "test"
Expand Down
75 changes: 31 additions & 44 deletions web/js/CacheClassExplorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,27 @@ var CacheClassExplorer = function (treeViewContainer, classViewContainer) {
dependencyLevel: id("setting.dependencyLevel")
}
};
var selfAux = this;
var settingsValue = function (name, defaultVal) {
try{
if (selfAux.elements.settings[name].type=="checkbox") {
return localStorage.getItem(name) === null ? (defaultVal || false)
: localStorage.getItem(name) === "true"
}
if (["text", "number"].indexOf(selfAux.elements.settings[name].type) >= 0) {
var ret = localStorage.getItem(name);
if (ret === null) ret = defaultVal;
return ret;
}
} catch (error) {
return localStorage.getItem(name) === null ? (defaultVal || false)
: localStorage.getItem(name) === "true" }

var getSettingsValue = function (name, defaultVal) {
var item = localStorage.getItem(name);
try {
return item ? JSON.parse(item).data : defaultVal;
} catch (e) { // non-parsable data
return defaultVal;
}
};

// note: this.elements is required to be modified with the same name as settings keys
this.settings = {
showDataTypesOnDiagram: settingsValue("showDataTypesOnDiagram"),
showClassIcons: settingsValue("showClassIcons", true),
showPropertyIcons: settingsValue("showPropertyIcons", true),
showParameters: settingsValue("showParameters", true),
showProperties: settingsValue("showProperties", true),
showMethods: settingsValue("showMethods", true),
showQueries: settingsValue("showQueries", true),
showXDatas: settingsValue("showXDatas", true),
dependencyLevel: settingsValue("dependencyLevel", "")
showDataTypesOnDiagram: getSettingsValue("showDataTypesOnDiagram"),
showClassIcons: getSettingsValue("showClassIcons", true),
showPropertyIcons: getSettingsValue("showPropertyIcons", true),
showParameters: getSettingsValue("showParameters", true),
showProperties: getSettingsValue("showProperties", true),
showMethods: getSettingsValue("showMethods", true),
showQueries: getSettingsValue("showQueries", true),
showXDatas: getSettingsValue("showXDatas", true),
dependencyLevel: getSettingsValue("dependencyLevel", "")
};

this.UI = new UI(this);
Expand All @@ -103,28 +96,22 @@ var CacheClassExplorer = function (treeViewContainer, classViewContainer) {
CacheClassExplorer.prototype.initSettings = function () {

var self = this,
textChanged = "Please, re-render diagram to make changes apply.";
TEXT_CHANGED = "Please, re-render diagram to make changes apply.";

for (var st in this.elements.settings) {
if (!this.elements.settings[st]) {
console.warn(st, "is Bred Sivoi Cobyly.");
continue;
}

if (["text", "number"].indexOf(this.elements.settings[st].type) >= 0) this.elements.settings[st].value = this.settings[st];
if (this.elements.settings[st].type == "checkbox") this.elements.settings[st].checked = this.settings[st];

var element = this.elements.settings[st];

// dropdown ("select") support is not predicted
element[element.type === "checkbox" ? "checked" : "value"] = this.settings[st];

this.elements.settings[st].addEventListener("change", (function (st) {
return function (e) {
self.elements.settingsExtraText.innerHTML = textChanged;
if (["text", "number"].indexOf((e.target || e.srcElement).type) >= 0) self.settings[st] = (e.target || e.srcElement).value
if ((e.target || e.srcElement).type == "checkbox") self.settings[st] = (e.target || e.srcElement).checked
localStorage.setItem(
st,
self.settings[st]
);
};
})(st));
element.addEventListener("change", (function (st, element) { return function () {
self.elements.settingsExtraText.innerHTML = TEXT_CHANGED;
localStorage.setItem(st, self.settings[st] = JSON.stringify({
data: element[element.type === "checkbox" ? "checked" : "value"]
}));
}; })(st, element));

}

};
Expand Down Expand Up @@ -172,7 +159,7 @@ CacheClassExplorer.prototype.updateURL = function () {
var obj = {
name: this.classTree.SELECTED_NAME,
type: this.classTree.SELECTED_TYPE,
level: this.classTree.SELECTED_LEVEL,
level: this.classTree.SELECTED_LEVEL
};

if (this.NAMESPACE) obj["namespace"] = this.NAMESPACE;
Expand Down

0 comments on commit 76d46b8

Please sign in to comment.