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
c40d576c
Commit
c40d576c
authored
Jun 21, 2011
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Sencha TT:
- Changed the way asynchronous AJAX calls return values
parent
58f13ccd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
25 deletions
+78
-25
intranet-rest-create-procs.tcl
tcl/intranet-rest-create-procs.tcl
+49
-16
intranet-rest-procs.tcl
tcl/intranet-rest-procs.tcl
+29
-9
No files found.
tcl/intranet-rest-create-procs.tcl
View file @
c40d576c
...
...
@@ -107,7 +107,8 @@ ad_proc -private im_rest_post_object_type_im_project {
# Write Audit Trail
im_project_audit -project_id
$rest
_oid -action create
return
$rest
_oid
set hash_array
(
rest_oid
)
$rest
_oid
return
[
array
get hash_array
]
}
...
...
@@ -232,7 +233,9 @@ ad_proc -private im_rest_post_object_type_im_ticket {
im_project_audit -project_id
$rest
_oid -action create
ns_log Notice
"im_rest_post_object_type_im_ticket: Successfully created object with object_id=
$rest
_oid"
return
$rest
_oid
set hash_array
(
rest_oid
)
$rest
_oid
set hash_array
(
ticket_id
)
$rest
_oid
return
[
array
get hash_array
]
}
...
...
@@ -338,7 +341,9 @@ ad_proc -private im_rest_post_object_type_im_timesheet_task {
im_audit -user_id
$user
_id -object_type
$rest
_otype -object_id
$rest
_oid -action create
return
$rest
_oid
set hash_array
(
rest_oid
)
$rest
_oid
set hash_array
(
task_id
)
$rest
_oid
return
[
array
get hash_array
]
}
...
...
@@ -421,7 +426,9 @@ ad_proc -private im_rest_post_object_type_im_trans_task {
im_audit -user_id
$user
_id -object_type
$rest
_otype -object_id
$rest
_oid -action create
return
$rest
_oid
set hash_array
(
rest_oid
)
$rest
_oid
set hash_array
(
task_id
)
$rest
_oid
return
[
array
get hash_array
]
}
...
...
@@ -572,7 +579,9 @@ ad_proc -private im_rest_post_object_type_im_company {
im_audit -user_id
$user
_id -object_type
$rest
_otype -object_id
$rest
_oid -action create
return
$rest
_oid
set hash_array
(
rest_oid
)
$rest
_oid
set hash_array
(
company_id
)
$rest
_oid
return
[
array
get hash_array
]
}
...
...
@@ -678,7 +687,9 @@ ad_proc -private im_rest_post_object_type_im_user_absence {
im_audit -user_id
$user
_id -object_type
$rest
_otype -object_id
$rest
_oid -action create
return
$rest
_oid
set hash_array
(
rest_oid
)
$rest
_oid
set hash_array
(
absence_id
)
$rest
_oid
return
[
array
get hash_array
]
}
# --------------------------------------------------------
...
...
@@ -861,7 +872,11 @@ ad_proc -private im_rest_post_object_type_user {
im_audit -user_id
$user
_id -object_type
$rest
_otype -object_id
$new
_user_id -action create
return
$new
_user_id
set rest_oid
$new
_user_id
set hash_array
(
rest_oid
)
$rest
_oid
set hash_array
(
user_id
)
$rest
_oid
return
[
array
get hash_array
]
}
...
...
@@ -965,7 +980,9 @@ ad_proc -private im_rest_post_object_type_im_invoice {
im_audit -user_id
$user
_id -object_type
$rest
_otype -object_id
$rest
_oid -action create
return
$rest
_oid
set hash_array
(
rest_oid
)
$rest
_oid
set hash_array
(
invoice_id
)
$rest
_oid
return
[
array
get hash_array
]
}
...
...
@@ -998,7 +1015,9 @@ ad_proc -private im_rest_post_object_type_im_trans_invoice {
im_audit -user_id
$user
_id -object_type
$rest
_otype -object_id
$rest
_oid -action create
return
$rest
_oid
set hash_array(rest_oid)
$rest
_oid
set hash_array(invoice_id)
$rest
_oid
return
[
array
get hash_array
]
}
...
...
@@ -1095,7 +1114,9 @@ ad_proc -private im_rest_post_object_type_im_invoice_item {
# No audit here, invoice_item is not a real object
# im_audit -user_id
$user
_id -object_type
$rest
_otype -object_id
$rest
_oid -action create
return
$rest
_oid
set hash_array
(
rest_oid
)
$rest
_oid
set hash_array
(
item_id
)
$rest
_oid
return
[
array
get hash_array
]
}
...
...
@@ -1184,7 +1205,9 @@ ad_proc -private im_rest_post_object_type_im_hour {
# Not a real object, so no audit!
# im_audit -user_id
$user
_id -object_type
$rest
_otype -object_id
$rest
_oid -action create
return
$rest
_oid
set hash_array
(
rest_oid
)
$rest
_oid
set hash_array
(
hour_id
)
$rest
_oid
return
[
array
get hash_array
]
}
...
...
@@ -1329,7 +1352,9 @@ ad_proc -private im_rest_post_object_type_membership_rel {
im_audit -user_id
$user
_id -object_type
$rest
_otype -object_id
$rest
_oid -action create
return
$rest
_oid
set hash_array
(
rest_oid
)
$rest
_oid
set hash_array
(
rel_id
)
$rest
_oid
return
[
array
get hash_array
]
}
...
...
@@ -1406,7 +1431,9 @@ ad_proc -private im_rest_post_object_type_im_biz_object_member {
im_audit -user_id
$user
_id -object_type
$rest
_otype -object_id
$rest
_oid -action create
return
$rest
_oid
set hash_array
(
rest_oid
)
$rest
_oid
set hash_array
(
rel_id
)
$rest
_oid
return
[
array
get hash_array
]
}
...
...
@@ -1482,7 +1509,9 @@ ad_proc -private im_rest_post_object_type_im_ticket_ticket_rel {
im_audit -user_id
$user
_id -object_type
$rest
_otype -object_id
$rest
_oid -action create
return
$rest
_oid
set hash_array
(
rest_oid
)
$rest
_oid
set hash_array
(
rel_id
)
$rest
_oid
return
[
array
get hash_array
]
}
...
...
@@ -1557,7 +1586,9 @@ ad_proc -private im_rest_post_object_type_im_key_account_rel {
im_audit -user_id
$user
_id -object_type
$rest
_otype -object_id
$rest
_oid -action create
return
$rest
_oid
set hash_array
(
rest_oid
)
$rest
_oid
set hash_array
(
rel_id
)
$rest
_oid
return
[
array
get hash_array
]
}
...
...
@@ -1631,6 +1662,8 @@ ad_proc -private im_rest_post_object_type_im_company_employee_rel {
im_audit -user_id
$user
_id -object_type
$rest
_otype -object_id
$rest
_oid -action create
return
$rest
_oid
set hash_array
(
rest_oid
)
$rest
_oid
set hash_array
(
rel_id
)
$rest
_oid
return
[
array
get hash_array
]
}
tcl/intranet-rest-procs.tcl
View file @
c40d576c
...
...
@@ -959,7 +959,7 @@ ad_proc -private im_rest_get_object_type {
json
{
# Calculate the total number of objects
set total
[
db_string total
"select count(*) from (
$unlimited
_sql) t"
-default 0
]
set result
"{
\"
success
\"
: true,
\n\"
total
\"
:
$total
,
\n\"
message
\"
:
\"
Data loaded
\"
,
\n\"
data
\"
:
\[\n
$result
\n\]\n
}"
set result
"{
\"
success
\"
: true,
\n\"
total
\"
:
$total
,
\n\"
message
\"
:
\"
im_rest_get_object_type:
Data loaded
\"
,
\n\"
data
\"
:
\[\n
$result
\n\]\n
}"
doc_return 200
"text/html"
$result
return
}
...
...
@@ -1288,7 +1288,7 @@ ad_proc -private im_rest_get_im_categories {
}
json
{
# Deal with different JSON variants for different AJAX frameworks
set result
"{
\"
success
\"
: true,
\n\"
message
\"
:
\"
Data loaded
\"
,
\n\"
data
\"
:
\[\n
$result
\n\]\n
}"
set result
"{
\"
success
\"
: true,
\n\"
message
\"
:
\"
im_rest_get_im_categories:
Data loaded
\"
,
\n\"
data
\"
:
\[\n
$result
\n\]\n
}"
doc_return 200
"text/html"
$result
return
}
...
...
@@ -1420,13 +1420,17 @@ ad_proc -private im_rest_post_object_type {
if
{
0 !=
[
llength
[
info
commands im_rest_post_object_type_$rest_otype
]]}
{
ns_log Notice
"im_rest_post_object_type: Before calling im_rest_post_object_type_
$rest
_otype"
set rest_oid
[
eval
[
list
im_rest_post_object_type_$rest_otype
\
array set hash_array
[
eval
[
list
im_rest_post_object_type_$rest_otype
\
-format
$format
\
-user_id
$user
_id
\
-content
$content
\
-rest_otype
$rest
_otype
\
]]
ns_log Notice
"im_rest_post_object_type: After calling im_rest_post_object_type_
$rest
_otype. rest_oid=
$rest
_oid"
# Extract the object's id from the return array and write into object_id in case a client needs the info
set rest_oid
$hash
_array
(
rest_oid
)
set hash_array
(
object_id
)
$rest
_oid
ns_log Notice
"im_rest_post_object_type: After calling im_rest_post_object_type_
$rest
_otype: rest_oid=
$rest
_oid, hash_array=
[
array
get hash_array
]
"
switch
$format
{
html
{
...
...
@@ -1438,9 +1442,16 @@ ad_proc -private im_rest_post_object_type {
</table>
[
im_footer
]
"
}
json
{
set data
"
\[
{
\"
object_id
\"
:
$rest
_oid}
\]
"
set result
"{
\"
success
\"
: true,
\n\"
message
\"
:
\"
Object created
\"
,
\n\"
data
\"
:
$data
\n\n
}"
json
{
# Return a JSON structure with all fields of the object.
set data_list
[
list
]
foreach key
[
array
names hash_array
]
{
set value
$hash
_array
(
$key
)
lappend data_list
"
\"
$key
\"
:
\"
[
ns_quotehtml
$value
]
\"
"
}
set data
"
\[
{
[
join
$data
_list
", "
]
}
\]
"
set result
"{
\"
success
\"
:
\"
true
\"
,
\"
message
\"
:
\"
Object updated
\"
,
\"
data
\"
:
$data
}"
doc_return 200
"text/html"
$result
}
xml
{
...
...
@@ -1523,8 +1534,17 @@ ad_proc -private im_rest_post_object {
"
}
json
{
set data
"
\[
{
\"
object_id
\"
:
$rest
_oid}
\]
"
set result
"{
\"
success
\"
: true,
\n\"
message
\"
:
\"
Object created
\"
,
\n\"
data
\"
:
$data
\n\n
}"
# Empty data: The empty array is necessary for Sencha in order to call callbacks
# without error. However, adding data here will create empty records in the store later,
# so the array needs to be empty.
set data_list
[
list
]
foreach key
[
array
names hash_array
]
{
set value
$hash
_array
(
$key
)
lappend data_list
"
\"
$key
\"
:
\"
[
ns_quotehtml
$value
]
\"
"
}
set data
"
\[
{
[
join
$data
_list
", "
]
}
\]
"
set result
"{
\"
success
\"
:
\"
true
\"
,
\"
message
\"
:
\"
Object updated
\"
,
\"
data
\"
:
$data
}"
doc_return 200
"text/html"
$result
}
xml
{
...
...
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