Commit c275cfb7 authored by Romain Courteaud's avatar Romain Courteaud

Restore planning box edition.

Thanks to Rafael Monnerat.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14892 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8c1d244c
...@@ -100,13 +100,14 @@ class PlanningBoxValidator(Validator.StringBaseValidator): ...@@ -100,13 +100,14 @@ class PlanningBoxValidator(Validator.StringBaseValidator):
############## REBUILD STRUCTURE ################# ############## REBUILD STRUCTURE #################
################################################## ##################################################
# build structure # build structure
widget_instance = PlanningBoxWidgetInstance.render_structure(field=field, basic, planning = PlanningBoxWidgetInstance.render_structure(field=field,
key=key, value=value, REQUEST=REQUEST, here=here) key=key, value=value, REQUEST= REQUEST, here=here)
# getting coordinates script generator # getting coordinates script generator
planning_coordinates_method = getattr(here,'planning_coordinates') planning_coordinates_method = getattr(here,'planning_coordinates')
# calling script to generate coordinates # calling script to generate coordinates
planning_coordinates = planning_coordinates_method(structure=widget_instance) planning_coordinates = planning_coordinates_method(basic=basic,
planning=planning)
################################################## ##################################################
########## RECOVERING BLOCK MOVED DICTS ########## ########## RECOVERING BLOCK MOVED DICTS ##########
...@@ -178,7 +179,7 @@ class PlanningBoxValidator(Validator.StringBaseValidator): ...@@ -178,7 +179,7 @@ class PlanningBoxValidator(Validator.StringBaseValidator):
final_block = {} final_block = {}
# recovering the block object from block_moved informations # recovering the block object from block_moved informations
final_block['block_object'] = self.getBlockObject(block_moved['name'], \ final_block['block_object'] = self.getBlockObject(block_moved['name'], \
widget_instance.planning.content) planning.content)
# recovering original activity object # recovering original activity object
final_block['activity_origin'] = \ final_block['activity_origin'] = \
final_block['block_object'].parent_activity final_block['block_object'].parent_activity
...@@ -204,7 +205,7 @@ class PlanningBoxValidator(Validator.StringBaseValidator): ...@@ -204,7 +205,7 @@ class PlanningBoxValidator(Validator.StringBaseValidator):
block_moved['top'] = block_moved['new_Y'] - deltaY block_moved['top'] = block_moved['new_Y'] - deltaY
# abstracting axis representation (for generic processing) # abstracting axis representation (for generic processing)
if widget_instance.planning.calendar_view == 0: if planning.calendar_view == 0:
block_moved['main_axis_position'] = block_moved['top'] block_moved['main_axis_position'] = block_moved['top']
block_moved['main_axis_length'] = block_moved['height'] block_moved['main_axis_length'] = block_moved['height']
block_moved['secondary_axis_position'] = block_moved['left'] block_moved['secondary_axis_position'] = block_moved['left']
...@@ -230,7 +231,7 @@ class PlanningBoxValidator(Validator.StringBaseValidator): ...@@ -230,7 +231,7 @@ class PlanningBoxValidator(Validator.StringBaseValidator):
# now that block coordinates are recovered as well as planning # now that block coordinates are recovered as well as planning
# coordinates, recovering destination group over the main axis to know # coordinates, recovering destination group over the main axis to know
# if the block has been moved from a group to another # if the block has been moved from a group to another
group_destination = self.getDestinationGroup(widget_instance, group_destination = self.getDestinationGroup(basic, planning,
block_moved,planning_coordinates['main_axis'], block_moved,planning_coordinates['main_axis'],
group_position, group_length) group_position, group_length)
...@@ -248,7 +249,7 @@ class PlanningBoxValidator(Validator.StringBaseValidator): ...@@ -248,7 +249,7 @@ class PlanningBoxValidator(Validator.StringBaseValidator):
else: else:
# now that all informations about the main axis changes are # now that all informations about the main axis changes are
# known, checking modifications over the secondary axis. # known, checking modifications over the secondary axis.
secondary_axis_positions = self.getDestinationBounds(widget_instance, secondary_axis_positions = self.getDestinationBounds(basic, planning,
block_moved, final_block['block_object'], block_moved, final_block['block_object'],
planning_coordinates, axis_length, planning_coordinates, axis_length,
destination_group = group_destination) destination_group = group_destination)
...@@ -279,7 +280,7 @@ class PlanningBoxValidator(Validator.StringBaseValidator): ...@@ -279,7 +280,7 @@ class PlanningBoxValidator(Validator.StringBaseValidator):
################################################## ##################################################
# getting object_dict to update object properties once activities are up to # getting object_dict to update object properties once activities are up to
# date. Activities values will be updated directly on the # date. Activities values will be updated directly on the
object_dict = self.getObjectDict(widget_instance) object_dict = self.getObjectDict(basic=basic, planning=planning)
################################################## ##################################################
############# UPDATING ACTIVITIES ################ ############# UPDATING ACTIVITIES ################
...@@ -431,7 +432,7 @@ class PlanningBoxValidator(Validator.StringBaseValidator): ...@@ -431,7 +432,7 @@ class PlanningBoxValidator(Validator.StringBaseValidator):
return block return block
def getDestinationGroup(self, widget_instance, block_moved, axis_groups, def getDestinationGroup(self, basic, planning, block_moved, axis_groups,
group_position, group_length): group_position, group_length):
""" """
recover destination group from block coordinates and main axis coordinates recover destination group from block coordinates and main axis coordinates
...@@ -452,13 +453,13 @@ class PlanningBoxValidator(Validator.StringBaseValidator): ...@@ -452,13 +453,13 @@ class PlanningBoxValidator(Validator.StringBaseValidator):
if good_group_name == '': if good_group_name == '':
return None return None
# group name is known, searching corresponding group object # group name is known, searching corresponding group object
for group in widget_instance.planning.main_axis.axis_group: for group in planning.main_axis.axis_group:
if group.name == good_group_name: if group.name == good_group_name:
return group return group
return None return None
def getDestinationBounds(self, widget_instance, block_moved, block_object, def getDestinationBounds(self, basic, planning, block_moved, block_object,
planning_coordinates, axis_length, planning_coordinates, axis_length,
destination_group=None): destination_group=None):
""" """
...@@ -492,20 +493,20 @@ class PlanningBoxValidator(Validator.StringBaseValidator): ...@@ -492,20 +493,20 @@ class PlanningBoxValidator(Validator.StringBaseValidator):
# to define any data out of its group bounds. # to define any data out of its group bounds.
pass pass
if widget_instance.basic.calendar_mode: if basic.calendar_mode:
axis_range = destination_group.secondary_axis_range axis_range = destination_group.secondary_axis_range
new_start = destination_group.secondary_axis_start + \ new_start = destination_group.secondary_axis_start + \
delta_start * axis_range delta_start * axis_range
new_stop = destination_group.secondary_axis_start + \ new_stop = destination_group.secondary_axis_start + \
delta_stop * axis_range delta_stop * axis_range
else: else:
axis_range = widget_instance.basic.secondary_axis_info['bound_stop'] - \ axis_range = basic.secondary_axis_info['bound_stop'] - \
widget_instance.basic.secondary_axis_info['bound_start'] basic.secondary_axis_info['bound_start']
# defining new final block bounds # defining new final block bounds
new_start = widget_instance.basic.secondary_axis_info['bound_start'] + \ new_start = basic.secondary_axis_info['bound_start'] + \
delta_start * axis_range delta_start * axis_range
new_stop = widget_instance.basic.secondary_axis_info['bound_start'] + \ new_stop = basic.secondary_axis_info['bound_start'] + \
delta_stop * axis_range delta_stop * axis_range
return [new_start,new_stop, error] return [new_start,new_stop, error]
...@@ -561,19 +562,19 @@ class PlanningBoxValidator(Validator.StringBaseValidator): ...@@ -561,19 +562,19 @@ class PlanningBoxValidator(Validator.StringBaseValidator):
return [new_start,new_stop] return [new_start,new_stop]
def getObjectDict(self, widget_instance): def getObjectDict(self, basic, planning):
""" """
Takes all activities related to a specified object and return Takes all activities related to a specified object and return
""" """
# init dict # init dict
object_dict = {} object_dict = {}
# get property_names # get property_names
start_property = widget_instance.basic.field.get_value('x_start_bloc') start_property = basic.field.get_value('x_start_bloc')
stop_property = widget_instance.basic.field.get_value('x_stop_bloc') stop_property = basic.field.get_value('x_stop_bloc')
# get full axis length # get full axis length
axis_start = widget_instance.basic.secondary_axis_info['bound_start'] axis_start = basic.secondary_axis_info['bound_start']
axis_stop = widget_instance.basic.secondary_axis_info['bound_stop'] axis_stop = basic.secondary_axis_info['bound_stop']
for axis_group in widget_instance.planning.main_axis.axis_group: for axis_group in planning.main_axis.axis_group:
for axis_element in axis_group.axis_element_list: for axis_element in axis_group.axis_element_list:
for activity in axis_element.activity_list: for activity in axis_element.activity_list:
# for each activity, saving its properties into a dict # for each activity, saving its properties into a dict
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment