Skip to content

Commit

Permalink
Fix import-choose to show correct response for shared and group folders
Browse files Browse the repository at this point in the history
  • Loading branch information
NLiefrink committed May 25, 2021
1 parent 6d9c6f4 commit 86b92d2
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 38 deletions.
4 changes: 3 additions & 1 deletion editor/importpages/import-choose.php
Expand Up @@ -54,7 +54,9 @@
array_splice($workspace->items, $i, 1);
continue;
}
if ((($template == "xerte" && $item->type != "nottingham") || ($template == "site" && $item->type != "site")) && $item->type != "workspace" && $item->type != "folder")
$temptype = str_replace("_group", "", $item->type);
$temptype = str_replace("_shared", "", $temptype);
if ((($template == "xerte" && $temptype != "nottingham") || ($template == "site" && $temptype != "site")) && $temptype != "workspace" && $temptype != "folder" && $temptype != "group")
{
unset($workspace->nodes->{$item->id});
array_splice($workspace->items, $i, 1);
Expand Down
103 changes: 66 additions & 37 deletions editor/js/import-choose.js
Expand Up @@ -128,7 +128,12 @@ function CheckAll() {

function getIcon(nodetype)
{
switch(nodetype)
var nodetypetemp = nodetype;
if (nodetype){
nodetypetemp = nodetype.replace("_group", "");
nodetypetemp = nodetypetemp.replace("_shared", "");
}
switch(nodetypetemp)
{
case "workspace":
icon = "website_code/images/folder_workspace.gif";
Expand All @@ -139,8 +144,11 @@ function getIcon(nodetype)
case "folder":
icon = "website_code/images/Icon_Folder.gif";
break;
case "group":
icon = "website_code/images/Icon_Shared.gif";
break;
default:
icon = "website_code/images/Icon_Page_" + nodetype + ".gif";
icon = "website_code/images/Icon_Page_" + nodetypetemp + ".gif";
}
return icon;
}
Expand Down Expand Up @@ -229,10 +237,30 @@ function init_workspace()
folder_children = folder_children.concat(workspace.templates);
node_types["folder"] = create_node_type("folder", folder_children);

//shared folder
var shared_children = workspace.sharedtemplates;
node_types["folder_shared"] = create_node_type("folder_shared", shared_children);

//group
var group_children = workspace.grouptemplates;
node_types["group"] = create_node_type("group", group_children);

//group folder
node_types["folder_group"] = create_node_type("folder_group", group_children);

$.each(workspace.templates, function () {
node_types[this] = create_node_type(this, [""]);
});

$.each(workspace.grouptemplates, function () {
node_types[this] = create_node_type(this, [""]);
});

$.each(workspace.sharedtemplates, function () {
node_types[this] = create_node_type(this, [""]);
});


// Remove _ from project names
$.each(workspace.items, function () {
this.text = this.text.replace(/_/g, ' ');
Expand Down Expand Up @@ -276,42 +304,43 @@ function init_workspace()
lastTreeItemTimestamp = e.timeStamp;

xot_id = treenode.node.original.xot_id;
var temptype = treenode.node.type.replace("_group", "");
temptype = temptype.replace("_shared", "");
if (temptype == 'folder' || temptype == 'workspace' || temptype == 'group') {

if (treenode.node.children.length > 0) {
// WE CAN OPEN FOLDER HERE
}

$("#mergeGlossaryCheck").prop("checked", false);
$("#mergeGlossary").hide();
$("#pages").html("");
$("#merge").hide();
$(".merge_title").show();

$("#pages").html("Select project on left.");
}
else {
var data = jsonData[xot_id];
if(data != undefined){

showPageData(xot_id, data);

if (treenode.node.type == 'folder' || treenode.node.type == 'workspace') {

if (treenode.node.children.length > 0) {
// WE CAN OPEN FOLDER HERE
}

$("#mergeGlossaryCheck").prop("checked", false);
$("#mergeGlossary").hide();
$("#pages").html("");
$("#merge").hide();
$(".merge_title").show();

$("#pages").html("Select project on left.");
}
else {
var data = jsonData[xot_id];
if(data != undefined){

showPageData(xot_id, data);

}
else { // haven't loaded that page yet
var url="editor/importpages/import-pagedata.php?id=" + xot_id;
var now = new Date().getTime();
$.ajax({
type: "GET",
url: url + "&t=" + now,
dataType: "html",
success: function (response) {
jsonData[xot_id] = JSON.parse(response);
showPageData(xot_id, jsonData[xot_id]);
}
});
}
}
}
else { // haven't loaded that page yet
var url="editor/importpages/import-pagedata.php?id=" + xot_id;
var now = new Date().getTime();
$.ajax({
type: "GET",
url: url + "&t=" + now,
dataType: "html",
success: function (response) {
jsonData[xot_id] = JSON.parse(response);
showPageData(xot_id, jsonData[xot_id]);
}
});
}
}
});
}
}
Expand Down

0 comments on commit 86b92d2

Please sign in to comment.