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

Method _createDeleteLastRowButton

src/editors/array.js:778–810  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

776 }
777
778 _createDeleteLastRowButton () {
779 const button = this.getButton('button_delete_last', 'subtract', 'button_delete_last_title', [this.getItemTitle()])
780 button.classList.add('json-editor-btntype-deletelast')
781 button.addEventListener('click', (e) => {
782 e.preventDefault()
783 e.stopPropagation()
784
785 if (!this.askConfirmation()) {
786 return false
787 }
788
789 const rows = this.getValue()
790 let newActiveTab = null
791
792 const editorValue = rows.pop()
793
794 this.setValue(rows)
795
796 if (this.rows[this.rows.length - 1]) {
797 newActiveTab = this.rows[this.rows.length - 1].tab
798 }
799
800 if (newActiveTab) {
801 this.active_tab = newActiveTab
802 this.refreshTabs()
803 }
804
805 this.onChange(true)
806 this.jsoneditor.trigger('deleteRow', editorValue)
807 })
808 this.controls.appendChild(button)
809 return button
810 }
811
812 _createRemoveAllRowsButton () {
813 const button = this.getButton('button_delete_all', 'delete', 'button_delete_all_title')

Callers 1

addControlsMethod · 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