Skip to content

Commit

Permalink
Fixed a huge fault that caused errors to occur when attempting to bul…
Browse files Browse the repository at this point in the history
…k edit the JSON in a column (or single view).
  • Loading branch information
William Troup committed Nov 18, 2024
1 parent 5967aa8 commit 73b3758
Show file tree
Hide file tree
Showing 7 changed files with 561 additions and 548 deletions.
536 changes: 270 additions & 266 deletions dist/jsontree.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jsontree.esm.js.map

Large diffs are not rendered by default.

536 changes: 270 additions & 266 deletions dist/jsontree.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jsontree.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jsontree.min.js

Large diffs are not rendered by default.

29 changes: 17 additions & 12 deletions src/jsontree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ type JsonTreeData = Record<string, BindingOptions>;
if ( dataIndex === bindingOptions._currentView.currentDataArrayPageIndex && bindingOptions._currentView.currentDataArrayPageIndex > 0 ) {
bindingOptions._currentView.currentDataArrayPageIndex -= bindingOptions.paging!.columnsPerPage!
}

updateColumnNodesAndControlButtonsForArrayIndexDeleted( bindingOptions, dataIndex );
}

} else {
Expand Down Expand Up @@ -708,6 +710,21 @@ type JsonTreeData = Record<string, BindingOptions>;
bindingOptions.data = null;
}

updateColumnNodesAndControlButtonsForArrayIndexDeleted( bindingOptions, dataIndex );
renderControlContainer( bindingOptions );
setFooterStatusText( bindingOptions, _configuration.text!.arrayJsonItemDeleted! );
}

function onCopy( bindingOptions: BindingOptions, data: any ) : void {
const copyDataJson: string = JSON.stringify( Convert.toJsonStringifyClone( data, _configuration, bindingOptions ), bindingOptions.events!.onCopyJsonReplacer, bindingOptions.jsonIndentSpaces );

navigator.clipboard.writeText( copyDataJson );

setFooterStatusText( bindingOptions, _configuration.text!.copiedText! );
Trigger.customEvent( bindingOptions.events!.onCopy!, bindingOptions._currentView.element, copyDataJson );
}

function updateColumnNodesAndControlButtonsForArrayIndexDeleted( bindingOptions: BindingOptions, dataIndex: number ) : void {
const newContentPanelsOpen = {} as ContentPanelsForArrayIndex;
const newControlButtonsOpen = {} as ControlButtonsOpenStateArrayIndex;

Expand Down Expand Up @@ -736,18 +753,6 @@ type JsonTreeData = Record<string, BindingOptions>;

bindingOptions._currentView.contentPanelsOpen = newContentPanelsOpen;
bindingOptions._currentView.controlButtonsOpen = newControlButtonsOpen;

renderControlContainer( bindingOptions );
setFooterStatusText( bindingOptions, _configuration.text!.arrayJsonItemDeleted! );
}

function onCopy( bindingOptions: BindingOptions, data: any ) : void {
const copyDataJson: string = JSON.stringify( Convert.toJsonStringifyClone( data, _configuration, bindingOptions ), bindingOptions.events!.onCopyJsonReplacer, bindingOptions.jsonIndentSpaces );

navigator.clipboard.writeText( copyDataJson );

setFooterStatusText( bindingOptions, _configuration.text!.copiedText! );
Trigger.customEvent( bindingOptions.events!.onCopy!, bindingOptions._currentView.element, copyDataJson );
}


Expand Down
2 changes: 1 addition & 1 deletion src/ts/data/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export namespace Convert {
result = object.toString();

} else if ( Is.definedFunction( object ) ) {
result = Default.getFunctionName( object, configuration ).name;
result = Default.getFunctionName( object, configuration, bindingOptions ).name;

} else if ( Is.definedRegExp( object ) ) {
result = object.source;
Expand Down

0 comments on commit 73b3758

Please sign in to comment.