Skip to content

Commit d3b4e9d

Browse files
committed
fix: crash when editing dcomments
1 parent e91ab22 commit d3b4e9d

4 files changed

Lines changed: 32 additions & 22 deletions

File tree

‎qcmetric/server_qc.json‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -383,47 +383,47 @@
383383
{
384384
"type": "return",
385385
"function": "approval_status_ui",
386-
"line": 51
386+
"line": 52
387387
},
388388
{
389389
"type": "return",
390390
"function": "modifications_log_ui",
391-
"line": 57
391+
"line": 58
392392
},
393393
{
394394
"type": "return",
395395
"function": "_handle_undo",
396-
"line": 64
396+
"line": 65
397397
},
398398
{
399399
"type": "return",
400400
"function": "_handle_cell_edit",
401-
"line": 82
401+
"line": 83
402402
},
403403
{
404404
"type": "return",
405405
"function": "_handle_cell_reset",
406-
"line": 127
406+
"line": 135
407407
},
408408
{
409409
"type": "return",
410410
"function": "_save_modifications",
411-
"line": 178
411+
"line": 186
412412
},
413413
{
414414
"type": "return",
415415
"function": "_export_status_report",
416-
"line": 189
416+
"line": 197
417417
},
418418
{
419419
"type": "return",
420420
"function": "_reload_data",
421-
"line": 196
421+
"line": 204
422422
},
423423
{
424424
"type": "return",
425425
"function": "_approve_data",
426-
"line": 210
426+
"line": 218
427427
}
428428
]
429429
},

‎qcmetric/server_variable_type_qc.json‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -928,47 +928,47 @@
928928
{
929929
"type": "return",
930930
"function": "approval_status_ui",
931-
"line": 51
931+
"line": 52
932932
},
933933
{
934934
"type": "return",
935935
"function": "modifications_log_ui",
936-
"line": 57
936+
"line": 58
937937
},
938938
{
939939
"type": "return",
940940
"function": "_handle_undo",
941-
"line": 64
941+
"line": 65
942942
},
943943
{
944944
"type": "return",
945945
"function": "_handle_cell_edit",
946-
"line": 82
946+
"line": 83
947947
},
948948
{
949949
"type": "return",
950950
"function": "_handle_cell_reset",
951-
"line": 127
951+
"line": 135
952952
},
953953
{
954954
"type": "return",
955955
"function": "_save_modifications",
956-
"line": 178
956+
"line": 186
957957
},
958958
{
959959
"type": "return",
960960
"function": "_export_status_report",
961-
"line": 189
961+
"line": 197
962962
},
963963
{
964964
"type": "return",
965965
"function": "_reload_data",
966-
"line": 196
966+
"line": 204
967967
},
968968
{
969969
"type": "return",
970970
"function": "_approve_data",
971-
"line": 210
971+
"line": 218
972972
}
973973
],
974974
"missing_annotations_truncated": 2

‎src/config/config_instance.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1746,10 +1746,12 @@ def _apply_field_modifications(self, df: pd.DataFrame) -> pd.DataFrame:
17461746
mods = []
17471747
for idx, row in df.iterrows():
17481748
fm = row["_field_mods"]
1749-
if fm is None:
1749+
if fm is None or (isinstance(fm, float) and pd.isna(fm)):
17501750
continue
17511751
if isinstance(fm, str):
17521752
fm = json.loads(fm)
1753+
if not isinstance(fm, list):
1754+
continue
17531755
pk_dict = {pk: row[pk] for pk in pk_columns if pk in df.columns}
17541756
serializable_pk = {}
17551757
for k, v in pk_dict.items():

‎src/server/edits.py‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def register_edits(ctx: ServerContext):
4646
_save_status_to_db = ctx._save_status_to_db
4747
load_modifications_log = ctx.load_modifications_log
4848
load_data_from_source = ctx.load_data_from_source
49+
_cached_page_data = ctx._cached_page_data
4950

5051
@render.ui
5152
def approval_status_ui():
@@ -87,12 +88,16 @@ def _handle_cell_edit():
8788
row, col, old_val, new_val = process_cell_edit_action(edit_data)
8889
print(f"DEBUG: processed edit - row={row}, col={col}, old={old_val}, new={new_val}")
8990
if row is not None and col:
90-
current_df = data.get()
91+
if is_lazy_loading() and _cached_page_data:
92+
current_df, _, _, _ = _cached_page_data()
93+
else:
94+
current_df = data.get()
9195
current_log = mods_log.get()
9296
print(f"DEBUG: config type={type(config)}, db_mode={config.app_config.database.mode if hasattr(config, 'app_config') else 'N/A'}")
9397
updated_df, updated_log = perform_cell_edit(current_df, current_log, row, col, old_val, new_val, config_instance=config)
9498
print(f"DEBUG: perform_cell_edit returned, log entries: {len(updated_log)}")
95-
data.set(updated_df)
99+
if not is_lazy_loading():
100+
data.set(updated_df)
96101
mods_log.set(updated_log)
97102

98103
pk_cols = app_config.table.primary_key
@@ -118,7 +123,10 @@ def _handle_cell_edit():
118123
print(f"Warning: Could not track edited cell: {e}")
119124

120125
save_log_to_file(updated_log, modifications_log_path)
121-
updated_df.to_json(data_dir / "data_state.json", orient="records", indent=2, default_handler=str)
126+
if not is_lazy_loading():
127+
updated_df.to_json(data_dir / "data_state.json", orient="records", indent=2, default_handler=str)
128+
else:
129+
_table_reload_trigger.set(_table_reload_trigger.get() + 1)
122130
col_label = f"{col} → {target_col}" if target_col != col else col
123131
ui.notification_show(f"Updated Row {row + 1}, {col_label}", type="message", duration=2)
124132

0 commit comments

Comments
 (0)