From 76d46b8051debb275f03cec59a29aacc70549980 Mon Sep 17 00:00:00 2001 From: ZitRo Date: Sun, 17 Jan 2016 15:00:01 +0200 Subject: [PATCH] Local storing method enhance, inheritance level fix --- cache/projectTemplate.xml | 12 +++--- package.json | 2 +- web/js/CacheClassExplorer.js | 75 +++++++++++++++--------------------- 3 files changed, 38 insertions(+), 51 deletions(-) diff --git a/cache/projectTemplate.xml b/cache/projectTemplate.xml index 4f2848d..58e6d11 100644 --- a/cache/projectTemplate.xml +++ b/cache/projectTemplate.xml @@ -4,7 +4,7 @@ Cache Class Explorer vX.X.X/*build.replace:pkg.version*/ Class contains methods that return structured classes/packages data. -63928,63957.580821 +63934,52160.80625 63653,67019.989197 @@ -87,8 +87,8 @@ Return structured data about class. 1 %ZEN.proxyObject +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 "" @@ -213,7 +213,7 @@ Return structured data about class. do oIndices.%DispatchSetProperty(ind.Name, oProp) } - do ..collectInheritance(oData, oClass.Super) + do ..collectInheritance(oData, oClass.Super, level, currLevel) quit oClass ]]> @@ -305,13 +305,13 @@ Return extended inheritance names Fill inheritance data Returns new (correct) super 1 -oData:%ZEN.proxyObject,super:%String +oData:%ZEN.proxyObject,super:%String,level:%String="",currLevel:%Integer=0 1 %Status diff --git a/package.json b/package.json index 54e16a9..48b154d 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "CacheClassExplorer", - "version": "1.13.4", + "version": "1.14.0", "description": "Class Explorer for InterSystems Caché", "directories": { "test": "test" diff --git a/web/js/CacheClassExplorer.js b/web/js/CacheClassExplorer.js index b75edf4..c0191b1 100755 --- a/web/js/CacheClassExplorer.js +++ b/web/js/CacheClassExplorer.js @@ -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); @@ -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)); + } }; @@ -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;