Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI fix and sub-folder loading/saving for acs 7.2 #100

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,35 @@

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');
scriptNode.save();
}else{
logger.warn('No script folder');
}
}
};

saveScript();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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);
}


Expand All @@ -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();
Expand All @@ -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);
}
},

Expand Down Expand Up @@ -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);
}
},

Expand Down Expand Up @@ -2104,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",
Expand Down