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

Method addRow

src/editors/array.js:483–534  ·  view source on GitHub ↗
(value, initial)

Source from the content-addressed store, hash-verified

481 }
482
483 addRow (value, initial) {
484 const i = this.rows.length
485
486 this.rows[i] = this.getElementEditor(i)
487 this.row_cache[i] = this.rows[i]
488
489 if (this.tabs_holder) {
490 this.rows[i].tab_text = document.createElement('span')
491 this.rows[i].tab_text.textContent = this.rows[i].getHeaderText()
492 if (this.schema.format === 'tabs-top') {
493 this.rows[i].tab = this.theme.getTopTab(this.rows[i].tab_text, this.getValidId(this.rows[i].path))
494 this.theme.addTopTab(this.tabs_holder, this.rows[i].tab)
495 } else {
496 this.rows[i].tab = this.theme.getTab(this.rows[i].tab_text, this.getValidId(this.rows[i].path))
497 this.theme.addTab(this.tabs_holder, this.rows[i].tab)
498 }
499 this.rows[i].tab.addEventListener('click', (e) => {
500 this.active_tab = this.rows[i].tab
501 this.refreshTabs()
502 e.preventDefault()
503 e.stopPropagation()
504 })
505 this._supportDragDrop(this.rows[i].tab)
506 } else {
507 this._supportDragDrop(this.rows[i].container, true)
508 }
509
510 const controlsHolder = this.rows[i].title_controls || this.rows[i].array_controls
511
512 /* Buttons to delete row, move row up, and move row down */
513 if (!this.hide_delete_buttons) {
514 this.rows[i].delete_button = this._createDeleteButton(i, controlsHolder)
515 }
516
517 /* Button to copy an array element and add it as last element */
518 if (this.show_copy_button) {
519 this.rows[i].copy_button = this._createCopyButton(i, controlsHolder)
520 }
521
522 if (i && !this.hide_move_buttons) {
523 this.rows[i].moveup_button = this._createMoveUpButton(i, controlsHolder)
524 }
525
526 if (!this.hide_move_buttons) {
527 this.rows[i].movedown_button = this._createMoveDownButton(i, controlsHolder)
528 }
529
530 if (typeof value !== 'undefined') this.rows[i].setValue(value, initial)
531 this.refreshTabs()
532
533 return this.rows[i]
534 }
535
536 _createDeleteButton (i, holder) {
537 const button = this.getButton(this.getItemTitle(), 'delete', 'button_delete_row_title', [this.getItemTitle()])

Callers 2

setValueMethod · 0.95
_createAddRowButtonMethod · 0.95

Calls 14

getElementEditorMethod · 0.95
refreshTabsMethod · 0.95
_supportDragDropMethod · 0.95
_createDeleteButtonMethod · 0.95
_createCopyButtonMethod · 0.95
_createMoveUpButtonMethod · 0.95
_createMoveDownButtonMethod · 0.95
getHeaderTextMethod · 0.80
getValidIdMethod · 0.80
getTopTabMethod · 0.45
addTopTabMethod · 0.45
getTabMethod · 0.45

Tested by

no test coverage detected