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

Method refreshValue

src/editors/array.js:449–481  ·  view source on GitHub ↗
(force)

Source from the content-addressed store, hash-verified

447 }
448
449 refreshValue (force) {
450 const oldi = this.value ? this.value.length : 0
451 /* Get the value for this editor */
452 this.value = this.rows.map(editor => editor.getValue())
453
454 if (oldi !== this.value.length || force) {
455 /* If we currently have minItems items in the array */
456 const minItems = this.schema.minItems && this.schema.minItems >= this.rows.length
457
458 this.rows.forEach((editor, i) => {
459 /* Hide the move down button for the last row */
460 if (editor.movedown_button) {
461 const display = (i !== this.rows.length - 1)
462 this.setButtonState(editor.movedown_button, display)
463 }
464
465 /* Hide the delete button if we have minItems items */
466 if (editor.delete_button) {
467 this.setButtonState(editor.delete_button, !minItems)
468 }
469
470 /* Get the value for this editor */
471 this.value[i] = editor.getValue()
472 })
473
474 if (this.setupButtons(minItems) && !this.collapsed) {
475 this.controls.style.display = 'inline-block'
476 } else {
477 this.controls.style.display = 'none'
478 }
479 }
480 this.serialized = JSON.stringify(this.value)
481 }
482
483 addRow (value, initial) {
484 const i = this.rows.length

Callers 4

onChildEditorChangeMethod · 0.95
setValueMethod · 0.95
_createCopyButtonMethod · 0.95
_createAddRowButtonMethod · 0.95

Calls 3

setButtonStateMethod · 0.95
setupButtonsMethod · 0.95
getValueMethod · 0.45

Tested by

no test coverage detected