Skip to content

Commit

Permalink
Fixed issues around editing when / removing JSON when bulk editing wh…
Browse files Browse the repository at this point in the history
…en paging is enabled, but no array data is being used.
  • Loading branch information
William Troup committed Nov 25, 2024
1 parent 8fb902b commit cb5db25
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions dist/jsontree.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -1624,7 +1624,7 @@ var ContextMenu;
const i = Convert2.jsonStringToObject(o, e);
if (i.parsed) {
a = e.text.jsonUpdatedText;
if (n.paging.enabled) {
if (n.paging.enabled && Is.definedArray(n.data)) {
if (Is.defined(i.object)) {
n.data[r] = i.object;
} else {
Expand Down Expand Up @@ -1895,7 +1895,7 @@ var ContextMenu;
i(e);
}
function S(t, n) {
if (t.paging.enabled) {
if (t.paging.enabled && Is.definedArray(t.data)) {
t.data.splice(n, 1);
if (n === t._currentView.currentDataArrayPageIndex && t._currentView.currentDataArrayPageIndex > 0) {
t._currentView.currentDataArrayPageIndex -= t.paging.columnsPerPage;
Expand Down Expand Up @@ -2205,7 +2205,7 @@ var ContextMenu;
}
}
function $(t) {
if (t.paging.enabled) {
if (t.paging.enabled && Is.definedArray(t.data)) {
const n = Math.ceil((t._currentView.currentDataArrayPageIndex + 1) / t.paging.columnsPerPage);
const o = Math.ceil(t.data.length / t.paging.columnsPerPage);
const l = DomElement.createWithHTML(null, "span", "status-count", n.toFixed()).outerHTML;
Expand Down Expand Up @@ -3622,7 +3622,7 @@ var ContextMenu;
backPage: function(e) {
if (Is.definedString(e) && t.hasOwnProperty(e)) {
const n = t[e];
if (n.paging.enabled) {
if (n.paging.enabled && Is.definedArray(n.data)) {
A(t[e]);
}
}
Expand All @@ -3631,7 +3631,7 @@ var ContextMenu;
nextPage: function(e) {
if (Is.definedString(e) && t.hasOwnProperty(e)) {
const n = t[e];
if (n.paging.enabled) {
if (n.paging.enabled && Is.definedArray(n.data)) {
O(t[e]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/jsontree.esm.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dist/jsontree.js
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ var ContextMenu;
const i = Convert2.jsonStringToObject(o, e);
if (i.parsed) {
a = e.text.jsonUpdatedText;
if (n.paging.enabled) {
if (n.paging.enabled && Is.definedArray(n.data)) {
if (Is.defined(i.object)) {
n.data[r] = i.object;
} else {
Expand Down Expand Up @@ -1897,7 +1897,7 @@ var ContextMenu;
i(e);
}
function S(t, n) {
if (t.paging.enabled) {
if (t.paging.enabled && Is.definedArray(t.data)) {
t.data.splice(n, 1);
if (n === t._currentView.currentDataArrayPageIndex && t._currentView.currentDataArrayPageIndex > 0) {
t._currentView.currentDataArrayPageIndex -= t.paging.columnsPerPage;
Expand Down Expand Up @@ -2207,7 +2207,7 @@ var ContextMenu;
}
}
function $(t) {
if (t.paging.enabled) {
if (t.paging.enabled && Is.definedArray(t.data)) {
const n = Math.ceil((t._currentView.currentDataArrayPageIndex + 1) / t.paging.columnsPerPage);
const o = Math.ceil(t.data.length / t.paging.columnsPerPage);
const l = DomElement.createWithHTML(null, "span", "status-count", n.toFixed()).outerHTML;
Expand Down Expand Up @@ -3624,7 +3624,7 @@ var ContextMenu;
backPage: function(e) {
if (Is.definedString(e) && t.hasOwnProperty(e)) {
const n = t[e];
if (n.paging.enabled) {
if (n.paging.enabled && Is.definedArray(n.data)) {
A(t[e]);
}
}
Expand All @@ -3633,7 +3633,7 @@ var ContextMenu;
nextPage: function(e) {
if (Is.definedString(e) && t.hasOwnProperty(e)) {
const n = t[e];
if (n.paging.enabled) {
if (n.paging.enabled && Is.definedArray(n.data)) {
O(t[e]);
}
}
Expand Down
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.

10 changes: 5 additions & 5 deletions src/jsontree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ type JsonTreeData = Record<string, BindingOptions>;
if ( newData.parsed ) {
statusBarMessage = _configuration.text!.jsonUpdatedText!;

if ( bindingOptions.paging!.enabled ) {
if ( bindingOptions.paging!.enabled && Is.definedArray( bindingOptions.data ) ) {
if ( Is.defined( newData.object ) ) {
bindingOptions.data[ dataIndex ] = newData.object;

Expand Down Expand Up @@ -710,7 +710,7 @@ type JsonTreeData = Record<string, BindingOptions>;
}

function onRemoveArrayJson( bindingOptions: BindingOptions, dataIndex: number ) : void {
if ( bindingOptions.paging!.enabled ) {
if ( bindingOptions.paging!.enabled && Is.definedArray( bindingOptions.data ) ) {
bindingOptions.data.splice( dataIndex, 1 );

if ( dataIndex === bindingOptions._currentView.currentDataArrayPageIndex && bindingOptions._currentView.currentDataArrayPageIndex > 0 ) {
Expand Down Expand Up @@ -1158,7 +1158,7 @@ type JsonTreeData = Record<string, BindingOptions>;
}

function getFooterPageText( bindingOptions: BindingOptions ) : void {
if ( bindingOptions.paging!.enabled ) {
if ( bindingOptions.paging!.enabled && Is.definedArray( bindingOptions.data ) ) {
const currentPage: number = Math.ceil( ( bindingOptions._currentView.currentDataArrayPageIndex + 1 ) / bindingOptions.paging!.columnsPerPage! );
const totalPages: number = Math.ceil( bindingOptions.data.length / bindingOptions.paging!.columnsPerPage! );
const currentReplacement: string = DomElement.createWithHTML( null!, "span", "status-count", currentPage.toFixed() ).outerHTML;
Expand Down Expand Up @@ -3101,7 +3101,7 @@ type JsonTreeData = Record<string, BindingOptions>;
if ( Is.definedString( elementId ) && _elements_Data.hasOwnProperty( elementId ) ) {
const bindingOptions: BindingOptions = _elements_Data[ elementId ];

if ( bindingOptions.paging!.enabled ) {
if ( bindingOptions.paging!.enabled && Is.definedArray( bindingOptions.data ) ) {
onBackPage( _elements_Data[ elementId ] );
}
}
Expand All @@ -3113,7 +3113,7 @@ type JsonTreeData = Record<string, BindingOptions>;
if ( Is.definedString( elementId ) && _elements_Data.hasOwnProperty( elementId ) ) {
const bindingOptions: BindingOptions = _elements_Data[ elementId ];

if ( bindingOptions.paging!.enabled ) {
if ( bindingOptions.paging!.enabled && Is.definedArray( bindingOptions.data ) ) {
onNextPage( _elements_Data[ elementId ] );
}
}
Expand Down

0 comments on commit cb5db25

Please sign in to comment.