mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 18:16:20 +00:00
fix editing task name and time from webui
This commit is contained in:
@@ -1544,6 +1544,13 @@ class Sequence(blenderbim.core.tool.Sequence):
|
|||||||
def generate_gantt_browser_chart(
|
def generate_gantt_browser_chart(
|
||||||
cls, task_json: list[dict[str, Any]], work_schedule: ifcopenshell.entity_instance
|
cls, task_json: list[dict[str, Any]], work_schedule: ifcopenshell.entity_instance
|
||||||
) -> None:
|
) -> None:
|
||||||
|
# with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html"), "w") as f:
|
||||||
|
# with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.mustache"), "r") as t:
|
||||||
|
# task_b64 = base64.b64encode(bytes(json.dumps(task_json), "utf-8")).decode("utf-8")
|
||||||
|
# f.write(
|
||||||
|
# pystache.render(t.read(), {"json_data": task_b64, "data": json.dumps(work_schedule.get_info())})
|
||||||
|
# )
|
||||||
|
# webbrowser.open("file://" + os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html"))
|
||||||
gantt_data = {"tasks": task_json, "work_schedule": work_schedule.get_info(recursive=True)}
|
gantt_data = {"tasks": task_json, "work_schedule": work_schedule.get_info(recursive=True)}
|
||||||
tool.Web.send_webui_data(extra_data=gantt_data, extra_data_key="gantt_data", event="gantt_data")
|
tool.Web.send_webui_data(extra_data=gantt_data, extra_data_key="gantt_data", event="gantt_data")
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ web_operator_queue = queue.Queue()
|
|||||||
IFC_TASK_ATTRIBUTE_MAP = {
|
IFC_TASK_ATTRIBUTE_MAP = {
|
||||||
"pStart": "ScheduleStart",
|
"pStart": "ScheduleStart",
|
||||||
"pEnd": "ScheduleFinish",
|
"pEnd": "ScheduleFinish",
|
||||||
"pName": "",
|
"pName": "Name",
|
||||||
"pRes": "",
|
"pRes": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,17 +175,22 @@ class Web(blenderbim.core.tool.Web):
|
|||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
if operator_data["type"] == "editTask":
|
if operator_data["type"] == "editTask":
|
||||||
task_id = int(operator_data["taskId"])
|
task_id = int(operator_data["taskId"])
|
||||||
task_time = ifc_file.by_id(task_id).TaskTime
|
task = ifc_file.by_id(task_id)
|
||||||
|
task_time = task.TaskTime
|
||||||
column = operator_data["column"]
|
column = operator_data["column"]
|
||||||
new_value = operator_data["value"]
|
new_value = operator_data["value"]
|
||||||
|
|
||||||
# editing a parent task time will throw an exception
|
|
||||||
try:
|
try:
|
||||||
|
ifcopenshell.api.sequence.edit_task(
|
||||||
|
ifc_file, task, attributes={IFC_TASK_ATTRIBUTE_MAP[column]: str(new_value)}
|
||||||
|
)
|
||||||
|
except AttributeError:
|
||||||
|
if task_time is None:
|
||||||
|
ifcopenshell.api.sequence.add_task_time(ifc_file, task)
|
||||||
|
task_time = task.TaskTime
|
||||||
ifcopenshell.api.sequence.edit_task_time(
|
ifcopenshell.api.sequence.edit_task_time(
|
||||||
ifc_file, task_time=task_time, attributes={IFC_TASK_ATTRIBUTE_MAP[column]: str(new_value)}
|
ifc_file, task_time=task_time, attributes={IFC_TASK_ATTRIBUTE_MAP[column]: str(new_value)}
|
||||||
)
|
)
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
bpy.ops.bim.load_task_properties()
|
bpy.ops.bim.load_task_properties()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user