()
| 745 | } |
| 746 | |
| 747 | _createAddRowButton () { |
| 748 | const button = this.getButton(this.getItemTitle(), 'add', 'button_add_row_title', [this.getItemTitle()]) |
| 749 | button.classList.add('json-editor-btntype-add') |
| 750 | button.addEventListener('click', (e) => { |
| 751 | e.preventDefault() |
| 752 | e.stopPropagation() |
| 753 | const i = this.rows.length |
| 754 | let editor |
| 755 | if (this.row_cache[i]) { |
| 756 | editor = this.rows[i] = this.row_cache[i] |
| 757 | this.rows[i].setValue(this.rows[i].getDefault(), true) |
| 758 | // override cached value, so optional properties are not checked. |
| 759 | if (typeof this.rows[i].deactivateNonRequiredProperties === 'function') { |
| 760 | this.rows[i].deactivateNonRequiredProperties(true) |
| 761 | } |
| 762 | this.rows[i].container.style.display = '' |
| 763 | if (this.rows[i].tab) this.rows[i].tab.style.display = '' |
| 764 | this.rows[i].register() |
| 765 | } else { |
| 766 | editor = this.addRow() |
| 767 | } |
| 768 | this.active_tab = this.rows[i].tab |
| 769 | this.refreshTabs() |
| 770 | this.refreshValue() |
| 771 | this.onChange(true) |
| 772 | this.jsoneditor.trigger('addRow', editor) |
| 773 | }) |
| 774 | this.controls.appendChild(button) |
| 775 | return button |
| 776 | } |
| 777 | |
| 778 | _createDeleteLastRowButton () { |
| 779 | const button = this.getButton('button_delete_last', 'subtract', 'button_delete_last_title', [this.getItemTitle()]) |
no test coverage detected