Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-rest-fs-openacs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-rest-fs-openacs
Commits
7963279e
Commit
7963279e
authored
Dec 12, 2018
by
salo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added projects data source
parent
26a5b7b1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
9 deletions
+68
-9
file-tree.json.adp
www/file-tree.json.adp
+2
-2
file-tree.json.tcl
www/file-tree.json.tcl
+16
-7
projects.json.tcl
www/projects.json.tcl
+50
-0
No files found.
www/file-tree.json.adp
View file @
7963279e
{
'text':'.','children': [
{
"success":true, "data":
@file_json;noquote@
}
]
}
}
www/file-tree.json.tcl
View file @
7963279e
...
...
@@ -127,7 +127,7 @@ template::multirow foreach file_multirow {
# This is the first child of the previous item
# Increasing the level always happens in steps of 1
if
{
$level
>
$old
_level
}
{
append file_json
",
\n
${indent}
\t
children
:
\[\n
"
append file_json
",
\n
${indent}
\t
\"
children
\"
:
\[\n
"
}
# A group of children needs to be closed.
...
...
@@ -153,16 +153,21 @@ template::multirow foreach file_multirow {
for
{
set
i 0
}
{
$i
<
$level
}
{
incr
i
}
{
append indent
"
\t
"
}
if
{
0 ==
$num
_children
}
{
set leaf_json
"true"
}
else
{
set leaf_json
"false"
}
if
{
"folder"
==
$type
}
{
set leaf_json
"false"
}
set quoted_char_map
{
"
\n
"
"
\\
n"
"
\r
"
"
\\
r"
"
\"
"
"
\\\"
"
"
\\
"
"
\\\\
"
}
set quoted_file_name
[
string
map
$quoted
_char_map
$file
_name
]
append file_json
"
${indent}
\{
${indent}
\t
id
:
$file
_id,
${indent}
\t
name
:
\"
$quoted
_file_name
\"
,
${indent}
\t
iconCls
:
\"
icon-
$type
\"
,
${indent}
\t
expanded
:
$expanded
,
${indent}
\t
\"
id
\"
:
$file
_id,
${indent}
\t
\"
name
\"
:
\"
$quoted
_file_name
\"
,
${indent}
\t
\"
iconCls
\"
:
\"
icon-
$type
\"
,
${indent}
\t
\"
expanded
\"
:
$expanded
,
"
if
{
"folder"
==
$type
&& 0 ==
$num
_children
}
{
append file_json
"
${indent}
\t\"
children
\"
:
\[\]
,
\n
"
}
foreach var
$valid
_vars
{
# Skip xml_* variables
(
only used by MS-File
)
if
{[
regexp
{
^xml_
}
$var
match
]}
{
continue
}
...
...
@@ -170,9 +175,9 @@ ${indent}\texpanded:$expanded,
# Append the value to the JSON output
set value
[
set
$var
]
set quoted_value
[
string
map
$quoted
_char_map
$value
]
append file_json
"
${indent}
\t
$var
:
\"
$quoted
_value
\"
,
\n
"
append file_json
"
${indent}
\t
\"
$var
\"
:
\"
$quoted
_value
\"
,
\n
"
}
append file_json
"
${indent}
\t
leaf
:
$leaf
_json"
append file_json
"
${indent}
\t
\"
leaf
\"
:
$leaf
_json"
incr ctr
set old_level
$level
...
...
@@ -188,3 +193,7 @@ while {$level < $old_level} {
for
{
set
i 0
}
{
$i
<
$old
_level
}
{
incr
i
}
{
append indent
"
\t
"
}
}
set
json_string
"
\{\"
success
\"
: true,
\"
children
\"
:
$file
_json
\n\}\n\}\n
"
ns_log Debug
"file-tree.json returning (
$json
_string)"
doc_return 200
"application/json"
$json
_string
www/projects.json.tcl
0 → 100644
View file @
7963279e
# /packages/intranet-rest-fs-openacs/www/file-tree.json.tcl
#
# Copyright (C
)
2013-2018
]
project-open
[
ad_page_contract
{
Returns a JSON tree structure suitable for batch-loading a project TreeStore
@param object_id ]po
[
Business Object to which the FS belongs.
0 identifies the global
"Home"
FS
@author frank.bergmann@project-open.com
@param node Passed by ExtJS to load sub-trees of a tree.
Normally not used, just in case of error.
}
{
}
set
user_id
[
auth::require_login
]
set
query
{
select
project_id,
project_nr,
project_name
from
acs_rels r,
im_projects p
where
p.parent_id is null
and r.object_id_one = p.project_id
and r.object_id_two = :user_id
}
set
json_projects
[
list
]
db_foreach projects_list
$query
{
lappend json_projects
[
util::json::object::create
[
list
\
project_id
$project
_id
\
project_nr
$project
_nr
\
project_name
$project
_name
\
expanded false
\
leaf true
\
]]
}
set
json_string
[
util::json::gen
[
util::json::object::create
[
list
\
success true
\
children
[
util::json::array::create
$json
_projects
]
\
]]]
doc_return 200
"application/json"
$json
_string
# vi:set expandtab shiftwidth=4 softtabstop=4 :
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment