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

Method _createDeleteButton

src/editors/array.js:536–576  ·  view source on GitHub ↗
(i, holder)

Source from the content-addressed store, hash-verified

534 }
535
536 _createDeleteButton (i, holder) {
537 const button = this.getButton(this.getItemTitle(), 'delete', 'button_delete_row_title', [this.getItemTitle()])
538 button.classList.add('delete', 'json-editor-btntype-delete')
539 button.setAttribute('data-i', i)
540 button.addEventListener('click', e => {
541 e.preventDefault()
542 e.stopPropagation()
543
544 if (!this.askConfirmation()) {
545 return false
546 }
547
548 const i = e.currentTarget.getAttribute('data-i') * 1
549 const newval = this.getValue().filter((row, j) => j !== i)
550 let newActiveTab = null
551
552 const editor = this.rows[i]
553 const editorValue = editor.getValue()
554
555 this.setValue(newval)
556
557 if (this.rows[i]) {
558 newActiveTab = this.rows[i].tab
559 } else if (this.rows[i - 1]) {
560 newActiveTab = this.rows[i - 1].tab
561 }
562
563 if (newActiveTab) {
564 this.active_tab = newActiveTab
565 this.refreshTabs()
566 }
567
568 this.onChange(true)
569 this.jsoneditor.trigger('deleteRow', editorValue)
570 })
571
572 if (holder) {
573 holder.appendChild(button)
574 }
575 return button
576 }
577
578 _createCopyButton (i, holder) {
579 const button = this.getButton(this.getItemTitle(), 'copy', 'button_copy_row_title', [this.getItemTitle()])

Callers 1

addRowMethod · 0.95

Calls 9

getItemTitleMethod · 0.95
askConfirmationMethod · 0.95
setValueMethod · 0.95
refreshTabsMethod · 0.95
addMethod · 0.80
triggerMethod · 0.80
getButtonMethod · 0.45
getValueMethod · 0.45
onChangeMethod · 0.45

Tested by

no test coverage detected