Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-rest
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
Commits
11dc614e
Commit
11dc614e
authored
Jun 26, 2015
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Gantt Editor:
Working on tree panel
parent
74673c00
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
40 deletions
+94
-40
intranet-rest-util-procs.tcl
tcl/intranet-rest-util-procs.tcl
+1
-1
project-task-tree-update.tcl
www/data-source/project-task-tree-update.tcl
+63
-27
project-task-tree.json.tcl
www/data-source/project-task-tree.json.tcl
+30
-12
No files found.
tcl/intranet-rest-util-procs.tcl
View file @
11dc614e
...
...
@@ -466,7 +466,7 @@ ad_proc -public im_rest_object_type_update_sql {
Updates all the object's tables with the information from the
hash array.
}
{
ns_log Notice
"im_rest_object_type_update_sql: format=
$format
, rest_otype=
$rest
_otype, rest_oid=
$rest
_oid, hash_array=
[
array
get hash_array
]
"
ns_log Notice
"im_rest_object_type_update_sql: format=
$format
, rest_otype=
$rest
_otype, rest_oid=
$rest
_oid, hash_array=
$hash
_array
"
# Stuff the list of variables into a hash
array set hash
$hash
_array
...
...
www/data-source/project-task-tree-update.tcl
View file @
11dc614e
...
...
@@ -5,13 +5,21 @@
ad_page_contract
{
Recieves a POST request from Sencha for an update
of in-line editing a TreeGrid
@param project_id The project
@author frank.bergmann@project-open.com
}
{
{
debug_p 0
}
}
# ---------------------------------------------------------------
# Security
# ---------------------------------------------------------------
# Check that the current_user_id has write permissions to the project
set
current_user_id
[
ad_maybe_redirect_for_registration
]
# ---------------------------------------------------------------
# Extract parameters
# Parameters may be send via the URL (project_id=...
)
or via JSON
...
...
@@ -30,44 +38,72 @@ foreach tuple $tuple_list {
# Parse the JSON POST data
set
post_content
[
ns_conn content
]
array
set json_hash
[
util::json::parse
$post
_content
]
# ns_log Notice "project-trask-tree-update: json_content=[array get json_hash
]
"
set json_list
$json
_hash(_object_);
# ns_log Notice "
project-trask-tree-update: json_list=$json_list
"
array set json_var_hash
$json
_list
foreach var
[
array
names json_var_hash
]
{
set value
$json
_var_hash(
$var
)
set var_hash(
$var
)
$value
ns_log Notice "
project-trask-tree-update:
$var
=$value
"
}
# Check that there was a task_id variable
if {!
[
info
exists var_hash
(
task_id
)]
} {
doc_return 200 "
text/plain
" "
{
success:false, message:'Undefined task_id in URL'
}
"
ad_script_abort
}
ns_log Notice
"project-trask-tree-update: json_hash=
[
array
get json_hash
]
"
# ---------------------------------------------------------------
#
Security
#
Procedure to update a task
# ---------------------------------------------------------------
# Check that the current_user_id has write permissions to the project
set current_user_id
[
ad_maybe_redirect_for_registration
]
set task_id
$var
_hash(task_id)
im_security_alert_check_integer -location "
/sencha-task-editor/treegrid-update.tcl: task_id
" -value
$task
_id
im_timesheet_task_permissions
$current
_user_id
$task
_id view read write admin
if {!
$write
} {
doc_return 200 "
text/plain
" "
{
success:false, message: 'No permissions to read task_id=$task_id for user=$current_user_id'
}
"
ad_script_abort
ad_proc im_rest_project_task_tree_update
{
-var_hash_list
}
{
Update a single task based on the values from var_hash
}
{
ns_log Notice
"project-trask-tree-update: im_rest_project_task_tree_update: var_hash_list=
$var
_hash_list"
set current_user_id
[
ad_get_user_id
]
array set var_hash
$var
_hash_list
# Get the project/task_id
set project_id
""
if
{[
info
exists var_hash
(
project_id
)]
&&
""
!=
$var
_hash
(
project_id
)}
{
set project_id
$var
_hash
(
project_id
)
}
if
{[
info
exists var_hash
(
task_id
)]
&&
""
!=
$var
_hash
(
task_id
)}
{
set project_id
$var
_hash
(
task_id
)
}
if
{[
info
exists var_hash
(
id
)]
&&
""
!=
$var
_hash
(
id
)}
{
set project_id
$var
_hash
(
id
)
}
if
{
""
==
$project
_id
}
{
doc_return 200
"text/plain"
"{success:false, message:'Undefined task_id or roject_id in POST data:
[
array
get var_hash
]
'}"
ad_script_abort
}
set object_type
[
util_memoize
[
list
db_string otype
"select object_type from acs_objects where object_id =
$project
_id"
]]
${object_type}
_permissions
$current
_user_id
$project
_id view read write admin
if
{
!$write
}
{
doc_return 200
"text/plain"
"{success:false, message: 'No permissions to write project_id=
$project
_id for user=
$current
_user_id'}"
ad_script_abort
}
im_rest_object_type_update_sql
\
-format
"json"
\
-rest_otype
"im_timesheet_task"
\
-rest_oid
$project
_id
\
-hash_array
$var
_hash_list
}
# ---------------------------------------------------------------
#
Perform the update
#
Check for single or multiple updates
# ---------------------------------------------------------------
if
{[
info
exists json_hash
(
_object_
)]}
{
set json_list
$json
_hash
(
_object_
)
ns_log Notice
"project-trask-tree-update: object: json_list=
$json
_list"
im_rest_project_task_tree_update -var_hash_list
$json
_list
}
if
{[
info
exists json_hash
(
_array_
)]}
{
set json_array
$json
_hash
(
_array_
)
ns_log Notice
"project-trask-tree-update: array=
$json
_array"
foreach array_elem
$json
_array
{
ns_log Notice
"project-trask-tree-update: array_elem=
$array
_elem"
set obj
[
lindex
$array
_elem 0
]
set json_list
[
lindex
$array
_elem 1
]
ns_log Notice
"project-trask-tree-update: decomposing array_elem:
$obj
=
$json
_list"
im_rest_project_task_tree_update -var_hash_list
$json
_list
}
}
# ---------------------------------------------------------------
# Return a success JSON
# ---------------------------------------------------------------
doc_return 200 "
text/plain
" "
\{
success:true, message: 'Successfully updated task'
\}
"
doc_return 200
"text/plain"
"
\{
success:true, message: 'Successfully updated task
(s)
'
\}
"
www/data-source/project-task-tree.json.tcl
View file @
11dc614e
...
...
@@ -75,7 +75,34 @@ db_foreach assignee $assignee_sql {
set assignee_hash
(
$object
_id_one
)
$assignees
}
# ad_return_complaint 1 [join [array get assignee_hash
]
"<br>"
]
# --------------------------------------------
# Get the list of projects that should not be displayed
#
set
non_display_projects_sql
"
select distinct sub_p.project_id -- Select all sup-projects of somehow non-displays
from im_projects super_p,
im_projects sub_p
where sub_p.tree_sortkey between super_p.tree_sortkey and tree_right(super_p.tree_sortkey) and
sub_p.project_id != :project_id and
super_p.project_id in (
-- The list of projects that should not be displayed
select p.project_id
from im_projects p,
acs_objects o,
im_projects main_p
where main_p.project_id = :project_id and
main_p.project_id != p.project_id and
p.project_id = o.object_id and
p.tree_sortkey between main_p.tree_sortkey and tree_right(main_p.tree_sortkey) and
o.object_type = 'im_project'
)
"
# set non_display_projects [db_list non_display_projects $non_display_projects_sql
]
set
non_display_projects
[
list
]
lappend
non_display_projects 0
# ad_return_complaint 1 $non_display_projects
# --------------------------------------------
# Get all the variables valid for timesheet task
...
...
@@ -106,7 +133,8 @@ set projects_sql "
bts.user_id = :current_user_id
)
where main_p.project_id = :project_id and
p.tree_sortkey between main_p.tree_sortkey and tree_right(main_p.tree_sortkey)
p.tree_sortkey between main_p.tree_sortkey and tree_right(main_p.tree_sortkey) and
p.project_id not in (
[
join
$non
_display_projects
","
]
)
order by
coalesce(p.sort_order, 0)
"
...
...
@@ -114,22 +142,16 @@ set projects_sql "
# Read the query into a Multirow, so that we can order
# it according to sort_order within the individual sub-levels.
db_multirow task_multirow task_list
$projects
_sql
{
# By default keep the main project
"open"
.
if
{
""
==
$parent
_id
}
{
set expanded
"true"
}
}
# Sort the tree according to the specified sort order
# "sort_order" is an integer, so we have to tell the sort algorithm to use integer sorting
ns_log Notice
"project-tree.json.tcl: starting to sort multirow"
multirow_sort_tree -integer task_multirow project_id parent_id sort_order
set
title
""
set
task_json
""
set
ctr 0
set
old_level 1
...
...
@@ -203,10 +225,8 @@ ${indent}\texpanded:$expanded,
set mapped_value
[
string
map
{
"
\n
"
"<br>"
"
\r
"
""
}
$value
]
append task_json
"
${indent}
\t
$var:
'
$mapped
_value',
\n
"
}
append task_json
"
${indent}
\t
leaf:
$leaf
_json"
incr ctr
set old_level
$level
}
...
...
@@ -221,8 +241,6 @@ while {$level < $old_level} {
for
{
set
i 0
}
{
$i
<
$old
_level
}
{
incr
i
}
{
append indent
"
\t
"
}
}
doc_return 200
"text/plain"
"{'text':'.','children':
\[
$task
_json
}
...
...
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