MCPcopy Index your code
hub / github.com/json-editor/json-editor / setupButtons

Method setupButtons

src/editors/array.js:418–447  ·  view source on GitHub ↗
(minItems)

Source from the content-addressed store, hash-verified

416 }
417
418 setupButtons (minItems) {
419 const controlsNeeded = []
420
421 if (!this.value.length) {
422 this.setButtonState(this.delete_last_row_button, false)
423 this.setButtonState(this.remove_all_rows_button, false)
424 } else if (this.value.length === 1) {
425 this.setButtonState(this.remove_all_rows_button, false)
426
427 /* If there are minItems items in the array, or configured to hide the delete_last_row button, hide the delete button beneath the rows */
428 const display = !(minItems || this.hide_delete_last_row_buttons)
429 this.setButtonState(this.delete_last_row_button, display)
430 controlsNeeded.push(display)
431 } else {
432 const display1 = !(minItems || this.hide_delete_last_row_buttons)
433 this.setButtonState(this.delete_last_row_button, display1)
434 controlsNeeded.push(display1)
435
436 const display2 = !(minItems || this.hide_delete_all_rows_buttons)
437 this.setButtonState(this.remove_all_rows_button, display2)
438 controlsNeeded.push(display2)
439 }
440
441 /* If there are maxItems in the array, hide the add button beneath the rows */
442 const display = !((this.getMax() && this.getMax() <= this.rows.length) || this.hide_add_button)
443 this.setButtonState(this.add_row_button, display)
444 controlsNeeded.push(display)
445
446 return controlsNeeded.some(e => e)
447 }
448
449 refreshValue (force) {
450 const oldi = this.value ? this.value.length : 0

Callers 1

refreshValueMethod · 0.95

Calls 2

setButtonStateMethod · 0.95
getMaxMethod · 0.95

Tested by

no test coverage detected