* Triggered when view add button has been clicked. * @protected * @param {PipeView} view * @param {number} index
(view, index)
| 924 | * @param {number} index |
| 925 | */ |
| 926 | async viewAddButtonDidClick (view, index) { |
| 927 | // Track action |
| 928 | EventManager.trigger('pipeAddButtonClick', { pipe: this, index }) |
| 929 | |
| 930 | // Offer all bricks in the modal view |
| 931 | const modalView = this.getLibraryModalView() |
| 932 | modalView.clearFilter() |
| 933 | |
| 934 | let name |
| 935 | try { |
| 936 | name = await modalView.prompt() |
| 937 | } catch (error) { |
| 938 | // Stop here when user cancels the modal view |
| 939 | return |
| 940 | } |
| 941 | |
| 942 | // Create brick and add it to the pipe |
| 943 | const brick = this.getBrickFactory().create(name) |
| 944 | this.spliceBricks(index, 0, [brick]) |
| 945 | } |
| 946 | |
| 947 | /** |
| 948 | * Triggered when a brick is dropped on given index. |
no test coverage detected