Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-budget
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-budget
Commits
83a4df30
Commit
83a4df30
authored
Mar 23, 2021
by
Project Open
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Budget WIP
parent
d01d7b9b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
37 deletions
+70
-37
budget-tree-component.adp
lib/budget-tree-component.adp
+25
-8
intranet-budget-procs.tcl
tcl/intranet-budget-procs.tcl
+8
-0
budget-tree-action.tcl
www/data-source/budget-tree-action.tcl
+37
-29
No files found.
lib/budget-tree-component.adp
View file @
83a4df30
...
...
@@ -622,11 +622,11 @@ function launchBudgetTreePanel() {
{text: 'Managers', coltype: 'all', flex: 1, dataIndex: 'members', sortable: true, editor: false,
memberStore: budgetManagerStore,
editor: Ext.create('PO.view.field.POObjectMembers', {
gridPanelId: 'budgetTreePanel',
debug: true,
memberStore: budgetManagerStore,
groupStore: budgetGroupStore
}),
gridPanelId: 'budgetTreePanel',
debug: true,
memberStore: budgetManagerStore,
groupStore: budgetGroupStore
}),
renderer: function(value, context, model, columnX, columnY, nodeStore, treeView, e) {
var gridColumn = context.column;
var editor = gridColumn.getEditor();
...
...
@@ -763,19 +763,36 @@ function launchBudgetTreePanel() {
}
},
/**
* Switch between the three different "views" {all|nonce|conf|actuals|time}
* that determine which columns to be shown.
*/
switchColumns: function(setColtype) {
var me = this;
if (me.debug) console.log('PO.budget.BudgetTreePanel.switchColumns('+coltype+'): Starting');
me.suspendLayout = true;
me.suspendEvents();
// Hide all columns except for coltype=all
for (var i = me.columns.length-1; i >= 0; i--) {
if (me.debug) console.log('PO.budget.BudgetTreePanel.switchColumns: i='+i);
var coltype = me.columns[i].coltype;
me.columns[i].setVisible( ("all" == coltype) );
if (coltype == setColtype) me.columns[i].setVisible(true);
var visible = ("all" == coltype);
if (coltype == setColtype) visible = true;
var col = me.columns[i];
var isVisible = col.isVisible();
if (visible != isVisible) {
col.setVisible(visible);
}
}
if (me.debug) console.log('PO.budget.BudgetTreePanel.initComponent: Finished');
me.resumeEvents();
me.suspendLayout = false;
me.doLayout();
if (me.debug) console.log('PO.budget.BudgetTreePanel.switchColumns: Finished');
},
/**
...
...
tcl/intranet-budget-procs.tcl
View file @
83a4df30
...
...
@@ -505,6 +505,14 @@ ad_proc -public im_budget_item_permissions {user_id budget_item_id view_var read
set user_is_admin_p
[
im_is_user_site_wide_or_intranet_admin
$user
_id
]
set user_is_wheel_p
[
im_profile::member_p -profile_id
[
im_wheel_group_id
]
-user_id
$user
_id
]
# Being a
"member"
of a budget item means being a member of _this_
# item, or any of it's parents
set user_is_group_member_p
[
im_biz_object_member_p
$user
_id
$budget
_item_id
]
set user_is_group_admin_p
[
im_biz_object_admin_p
$user
_id
$budget
_item_id
]
...
...
www/data-source/budget-tree-action.tcl
View file @
83a4df30
...
...
@@ -32,7 +32,7 @@ ad_proc im_budget_tree_action {
Process an update on budget or cost items and update the database
accordingly
}
{
ns_log Notice
"action -action=
$action
, -json_list=
$json
_list"
ns_log Notice
"
im_budget_tree_
action -action=
$action
, -json_list=
$json
_list"
set current_user_id
[
auth::require_login
]
# Get hash with var-value entries from JSON
...
...
@@ -41,12 +41,12 @@ ad_proc im_budget_tree_action {
if
{
""
eq
$object
_id
}
{
return
};
# May happen when trying to save incomplete model
set object_type
$json
_hash
(
object_type
)
if
{
""
eq
$object
_type
}
{
ns_log Error
"action: found empty object_type='
$object
_type': json_list=
$json
_list"
ns_log Error
"
im_budget_tree_
action: found empty object_type='
$object
_type': json_list=
$json
_list"
return
}
ns_log Notice
"action: After getting oid and otype: object_id=
$object
_id, object_type=
$object
_type"
ns_log Notice
"
im_budget_tree_
action: After getting oid and otype: object_id=
$object
_id, object_type=
$object
_type"
if
{
$object
_type ni
{
"im_budget_item"
"im_cost"
"im_invoice"
"im_timesheet_invoice"
}}
{
ns_log Error
"action: unrecognized object_type=
$object
_type, skipping"
ns_log Error
"
im_budget_tree_
action: unrecognized object_type=
$object
_type, skipping"
return
}
...
...
@@ -120,9 +120,9 @@ ad_proc im_budget_tree_action {
:budget_item_status_id,
:budget_item_project_id
)"
]
ns_log Notice
"action: Created new BI with budget_item_id=
$id
with id=
$id
from object_id=
$object
_id"
ns_log Notice
"
im_budget_tree_
action: Created new BI with budget_item_id=
$id
with id=
$id
from object_id=
$object
_id"
if
{
$id
ne
$object
_id
}
{
ns_log Error
"action: After create new BI: New id=
$id
is different from object_id=
$object
_id"
ns_log Error
"
im_budget_tree_
action: After create new BI: New id=
$id
is different from object_id=
$object
_id"
}
}
...
...
@@ -135,7 +135,7 @@ ad_proc im_budget_tree_action {
set val
[
lindex
$line
_pieces 1
]
if
{
""
eq
$var
}
{
continue
}
set audit_hash
(
$var
)
$val
# ns_log Notice
"action: audit_hash('
$var
') = '
$val
'"
# ns_log Notice
"
im_budget_tree_
action: audit_hash('
$var
') = '
$val
'"
}
set ignore_vars
{
...
...
@@ -154,7 +154,6 @@ nr
object_type
parentId
tree_sortkey
members
}
# Translate between JSON variable names and database column names
...
...
@@ -171,12 +170,12 @@ members
set translate_hash
(
description
)
note
}
default
{
ns_log Error
"action: translate: unrecognized object_type='
$object
_type'"
ns_log Error
"
im_budget_tree_
action: translate: unrecognized object_type='
$object
_type'"
}
}
set audit_vars
[
array
names audit_hash
]
# ns_log Notice
"action: audit_vars=
$audit
_vars"
# ns_log Notice
"
im_budget_tree_
action: audit_vars=
$audit
_vars"
foreach var
[
array
names json_hash
]
{
if
{
$var
in
$ignore
_vars
}
{
continue
}
...
...
@@ -186,7 +185,7 @@ members
set audit_var
$var
set json_var
$var
if
{[
info
exists translate_hash
(
$audit
_var
)]}
{
# ns_log Notice
"action: found translation_hash(
$audit
_var) =
$translate
_hash(
$audit
_var)"
# ns_log Notice
"
im_budget_tree_
action: found translation_hash(
$audit
_var) =
$translate
_hash(
$audit
_var)"
set audit_var
$translate
_hash
(
$audit
_var
)
}
...
...
@@ -196,7 +195,7 @@ members
if
{
""
ne
$json
_val &&
$audit
_var ni
$audit
_vars
}
{
# Check if the json var exists in the DB. Ignore empty values...
ns_log Error
"action: found json_var='
$json
_var', audit_var=
$audit
_var, val='
$json
_val' which doesn't exist in audit_vars=
$audit
_vars"
ns_log Error
"
im_budget_tree_
action: found json_var='
$json
_var', audit_var=
$audit
_var, val='
$json
_val' which doesn't exist in audit_vars=
$audit
_vars"
continue
}
set audit_val
""
...
...
@@ -209,26 +208,26 @@ members
# -----------------------------------------------------
# Update the value
ns_log Notice
"action: Found update: json_var=
$json
_var, audit_var=
$audit
_var, audit_val=
$audit
_val, json_val=
$json
_val"
ns_log Notice
"
im_budget_tree_
action: Found update: json_var=
$json
_var, audit_var=
$audit
_var, audit_val=
$audit
_val, json_val=
$json
_val"
set id
$json
_hash
(
id
)
set object_type
$json
_hash
(
object_type
)
ns_log Notice
"action: id=
$object
_id, object_type=
$object
_type"
ns_log Notice
"
im_budget_tree_
action: id=
$object
_id, object_type=
$object
_type"
switch
$object
_type
{
"im_budget_item"
{
ns_log Notice
"action: update im_budget_items set
$audit
_var =
$json
_val where budget_item_id =
$object
_id"
ns_log Notice
"
im_budget_tree_
action: update im_budget_items set
$audit
_var =
$json
_val where budget_item_id =
$object
_id"
db_dml update_bi
"update im_budget_items set
$audit
_var = :json_val where budget_item_id = :object_id"
}
"im_cost"
-
"im_invoice"
-
"im_timesheet_invoice"
{
# Only allow to update the budget_item_id. Everything
else
is for the owner of the cost item
set cost_vars
{
budget_item_id
}
if
{
$audit
_var ni
$cost
_vars
}
{
continue
}
ns_log Notice
"action: update costs set
$audit
_var = '
$json
_val' where budget_item_id = '
$object
_id'"
ns_log Notice
"
im_budget_tree_
action: update costs set
$audit
_var = '
$json
_val' where budget_item_id = '
$object
_id'"
# db_dml update_bi "update costs set $audit_var = :json_val where budget_item_id = :object_id"
}
default
{
ns_log Error
"action: Unknown object_type=
$object
_type"
ns_log Error
"
im_budget_tree_
action: Unknown object_type=
$object
_type"
}
}
...
...
@@ -238,16 +237,16 @@ members
# ----------------------------------------------------------
# Handle
"members"
and store as business object members
set members_json_list
$json
_hash
(
members
)
ns_log Notice
"
action: xxx
: about to process bi=
$object
_id with members=
$members
_json_list"
ns_log Notice
"
im_budget_tree_action
: about to process bi=
$object
_id with members=
$members
_json_list"
set member_header
[
lindex
$members
_json_list 0
]
ns_log Notice
"
action: xxx
: member_header=
$member
_header"
ns_log Notice
"
im_budget_tree_action
: member_header=
$member
_header"
set member_json_list
[
lindex
$members
_json_list 1
]
ns_log Notice
"
action: xxx
: member_json_list=
$member
_json_list"
ns_log Notice
"
im_budget_tree_action
: member_json_list=
$member
_json_list"
if
{
"_array_"
eq
$member
_header
}
{
# ----------------------------------------------------------
# Create a hash array of existing budget item members
set bi_members_sql
"
select object_id_two as user_id,
...
...
@@ -260,31 +259,40 @@ members
db_foreach existing_bi_members
$bi
_members_sql
{
set existing_member_hash
(
$user
_id
)
$role
_id
}
ns_log Notice
"im_budget_tree_action: existing_member_hash =
[
array
get existing_member_hash
]
"
# ----------------------------------------------------------
# Create new members
foreach array_elem
$member
_json_list
{
ns_log Notice
"budget-tree-
action: xxx
: members: array_elem=
$array
_elem"
ns_log Notice
"budget-tree-
im_budget_tree_action
: members: array_elem=
$array
_elem"
set obj
[
lindex
$array
_elem 0
]
set json_list
[
lindex
$array
_elem 1
]
ns_log Notice
"budget-tree-
action: xxx
: members: decomposing array_elem:
$obj
=
$json
_list"
ns_log Notice
"budget-tree-
im_budget_tree_action
: members: decomposing array_elem:
$obj
=
$json
_list"
if
{
"_object_"
eq
$obj
}
{
# json_list contains something like:
#
{
id 9714684682000 user_id 8864 role 1300
}
array unset member_hash
array set member_hash
$json
_list
ns_log Notice
"budget-tree-
action: xxx
: member_hash=
[
array
get member_hash
]
"
ns_log Notice
"budget-tree-
im_budget_tree_action
: member_hash=
[
array
get member_hash
]
"
set user_id
$member
_hash
(
user_id
)
set role_id
$member
_hash
(
role_id
)
# Add the dude to the budget item
set new_member_hash
(
$user
_id
)
$role
_id
set existing_role_id 0
if
{[
info
exists existing_member_hash
(
$user
_id
)]}
{
set existing_role_id
$existing
_member_hash
(
$user
_id
)
}
if
{[
info
exists existing_member_hash
(
$user
_id
)]}
{
set existing_role_id
$existing
_member_hash
(
$user
_id
)
}
ns_log Notice
"im_budget_tree_action: role_id=
$role
_id, existing_role_id=
$existing
_role_id"
if
{
$existing
_role_id !=
$role
_id
}
{
ns_log Notice
"im_budget_tree_action: im_biz_object_add_role
$user
_id
$object
_id
$role
_id"
set rel_id
[
im_biz_object_add_role
$user
_id
$object
_id
$role
_id
]
}
}
else
{
ns_log Error
"
action: xxx
: Did not find '_object_' as first element in array_elem=
$array
_elem"
ns_log Error
"
im_budget_tree_action
: Did not find '_object_' as first element in array_elem=
$array
_elem"
}
}
...
...
@@ -294,18 +302,18 @@ members
set existing_role_id
$existing
_member_hash
(
$uid
)
if
{
!
[
info
exists new_member_hash
(
$uid
)]}
{
# There was an entry in the existing_members_hash, but not anymore in JSON data
ns_log Notice
"budget-tree-
action: xxx
: deleting membership of user_id=
$uid
"
ns_log Notice
"budget-tree-
im_budget_tree_action
: deleting membership of user_id=
$uid
"
db_string del_rel
"select im_biz_object_member__delete(:object_id, :uid)"
}
}
}
else
{
ns_log Error
"
action: xxx
: Did not find '_array_' as first element in members=
$members
_json_list"
ns_log Error
"
im_budget_tree_action
: Did not find '_array_' as first element in members=
$members
_json_list"
}
ns_log Notice
"action: Finished"
ns_log Notice
"
im_budget_tree_
action: Finished"
return 0
;
# Return 1 if we want to iterate
}
...
...
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