From 9031bfbe2088c4714448ca1d5da65906c4a66ed5 Mon Sep 17 00:00:00 2001 From: Olga Boldyreva Date: Wed, 13 Jul 2022 11:29:42 +0200 Subject: [PATCH 1/2] Fix Menu (z-index) und Submenu double. --- .../jsconsole/javascript-console.js | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/javascript-console-share/src/main/amp/web/fme/components/jsconsole/javascript-console.js b/javascript-console-share/src/main/amp/web/fme/components/jsconsole/javascript-console.js index 8c082a6..7dee445 100644 --- a/javascript-console-share/src/main/amp/web/fme/components/jsconsole/javascript-console.js +++ b/javascript-console-share/src/main/amp/web/fme/components/jsconsole/javascript-console.js @@ -228,6 +228,8 @@ if (typeof String.prototype.startsWith != 'function') { container: this.id + "-documentation" }); + var menu = this.widgets.docsMenuButton.getMenu(); + menu.cfg.setProperty("zindex", 10); this.widgets.docsMenuButton.getMenu().setItemGroupTitle("Javascript", 0); this.widgets.docsMenuButton.getMenu().setItemGroupTitle("Freemarker", 1); @@ -236,13 +238,27 @@ if (typeof String.prototype.startsWith != 'function') { } }, + initSubmenuIds: function (entry, suffix) { + if (entry.submenu) { + entry.submenu.id = entry.submenu.id + suffix; + entry.submenu.itemdata.forEach(function (f) { + this.initSubmenuIds(f, suffix); + }.bind(this)); + } + }, + createScriptsSaveMenu: function(listOfScripts){ var saveMenuItems = [{ text : this.msg("button.save.create.new"), value : "NEW" }]; - saveMenuItems.push(listOfScripts); + var scripts = JSON.parse(JSON.stringify(listOfScripts));//copy + scripts.forEach(function(e) { + this.initSubmenuIds.call(this, e, "-scriptsave"); + }.bind(this)); + + saveMenuItems.push(scripts); if(this.widgets.saveMenuButton){ this.widgets.saveMenuButton.getMenu().clearContent(); @@ -257,7 +273,9 @@ if (typeof String.prototype.startsWith != 'function') { menu: saveMenuItems, container: this.id + "-scriptsave" }); - this.widgets.saveMenuButton.getMenu().subscribe("click", this.onSaveScriptClick, this); + var menu = this.widgets.saveMenuButton.getMenu(); + menu.cfg.setProperty("zindex", 10); + menu.subscribe("click", this.onSaveScriptClick, this); } @@ -269,7 +287,12 @@ if (typeof String.prototype.startsWith != 'function') { value : "NEW" }]; - loadMenuItems.push(listOfScripts); + var scripts = JSON.parse(JSON.stringify(listOfScripts));//copy + scripts.forEach(function(e) { + this.initSubmenuIds.call(this, e, "-scriptload"); + }.bind(this)); + + loadMenuItems.push(scripts); if(this.widgets.loadMenuButton){ this.widgets.loadMenuButton.getMenu().clearContent(); @@ -285,7 +308,9 @@ if (typeof String.prototype.startsWith != 'function') { container: this.id + "-scriptload" }); - this.widgets.loadMenuButton.getMenu().subscribe("click", this.onLoadScriptClick, this); + var menu = this.widgets.loadMenuButton.getMenu(); + menu.cfg.setProperty("zindex", 10); + menu.subscribe("click", this.onLoadScriptClick, this); } }, @@ -331,7 +356,9 @@ if (typeof String.prototype.startsWith != 'function') { } } - this.widgets.themeMenuButton.getMenu().subscribe("click", this.onThemeSelection, this); + var menu = this.widgets.themeMenuButton.getMenu(); + menu.cfg.setProperty("zindex", 10); + menu.subscribe("click", this.onThemeSelection, this); } }, From c7de9e17803bfbe75bb32a43b8e23945b40744bc Mon Sep 17 00:00:00 2001 From: Olga Boldyreva Date: Wed, 13 Jul 2022 14:05:20 +0200 Subject: [PATCH 2/2] Fix saving/updating script in subfolder --- .../de/fme/jsconsole/saveScript.put.json.js | 23 +++++++++++++++---- .../jsconsole/javascript-console.js | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/javascript-console-repo/src/main/amp/config/alfresco/templates/webscripts/de/fme/jsconsole/saveScript.put.json.js b/javascript-console-repo/src/main/amp/config/alfresco/templates/webscripts/de/fme/jsconsole/saveScript.put.json.js index 84d7862..3cd4f1a 100644 --- a/javascript-console-repo/src/main/amp/config/alfresco/templates/webscripts/de/fme/jsconsole/saveScript.put.json.js +++ b/javascript-console-repo/src/main/amp/config/alfresco/templates/webscripts/de/fme/jsconsole/saveScript.put.json.js @@ -2,14 +2,27 @@ var isUpdate = args.isUpdate; -var saveScript = function saveScript(){ +var createFile = function createFile(parent, path) { + var name = path.shift(); + if (path.length > 0) { + return createFile(parent.childByNamePath(name) || parent.createFolder(name), path); + } + return parent.createFile(name); +}; + +var saveScript = function saveScript() { var scriptFolder = search.selectNodes("/app:company_home/app:dictionary/app:scripts")[0]; if (scriptFolder) { var scriptNode; - if(isUpdate && isUpdate=="true"){ - scriptNode = scriptFolder.childByNamePath(args.name); + if (isUpdate && isUpdate=="true") { + if (args.name.indexOf("workspace://") == 0) { + scriptNode = search.findNode(args.name); + }else{ + scriptNode = scriptFolder.childByNamePath(args.name); + } }else{ - scriptNode = scriptFolder.createFile(args.name); + scriptNode = createFile(scriptFolder, ('' + args.name).split(/\//)); + //scriptNode = scriptFolder.createFile(args.name); } scriptNode.content = json.get('jsScript'); scriptNode.properties["jsc:freemarkerScript"].content=json.get('fmScript'); @@ -17,7 +30,7 @@ var saveScript = function saveScript(){ }else{ logger.warn('No script folder'); } -} +}; saveScript(); diff --git a/javascript-console-share/src/main/amp/web/fme/components/jsconsole/javascript-console.js b/javascript-console-share/src/main/amp/web/fme/components/jsconsole/javascript-console.js index 7dee445..9268723 100644 --- a/javascript-console-share/src/main/amp/web/fme/components/jsconsole/javascript-console.js +++ b/javascript-console-share/src/main/amp/web/fme/components/jsconsole/javascript-console.js @@ -2131,7 +2131,7 @@ if (typeof String.prototype.startsWith != 'function') { saveAsExistingScript : function ACJC_saveAsExistingScript(filename, nodeRef) { Alfresco.util.Ajax.request({ - url: Alfresco.constants.PROXY_URI + "de/fme/jsconsole/savescript.json?name="+encodeURIComponent(filename)+"&isUpdate=true", + url: Alfresco.constants.PROXY_URI + "de/fme/jsconsole/savescript.json?name="+encodeURIComponent(nodeRef)+"&isUpdate=true", method: Alfresco.util.Ajax.PUT, dataStr: YAHOO.lang.JSON.stringify({'jsScript':this.widgets.codeMirrorScript.getValue(), 'fmScript':this.widgets.codeMirrorTemplate.getValue()}), requestContentType: "application/json; charset=utf-8",