(param: Param, constrainedBy?: ParamRow, nullable = false)
| 99 | constrainedBy?: ParamRow; |
| 100 | |
| 101 | constructor(param: Param, constrainedBy?: ParamRow, nullable = false) { |
| 102 | if (!param.selections) |
| 103 | throw new Error('Property "selections" expected.'); |
| 104 | super(param, gui.Picker.create(), nullable); |
| 105 | |
| 106 | this.selections = param.selections instanceof Function ? param.selections() : param.selections; |
| 107 | |
| 108 | // Listen to controlling param's change and update. |
| 109 | if (constrainedBy) { |
| 110 | this.constrainedBy = constrainedBy; |
| 111 | constrainedBy.affects.push(this); |
| 112 | constrainedBy.subscribeOnChange(() => { |
| 113 | this.update(); |
| 114 | // Iterate all params constrained by this. |
| 115 | this.affects.forEach(p => p.update()); |
| 116 | }); |
| 117 | } |
| 118 | // There is a description field in selection. |
| 119 | if (this.selections.length > 0 && |
| 120 | typeof this.selections[0].value == 'object' && |
| 121 | 'description' in this.selections[0].value) { |
| 122 | this.createDescription(); |
| 123 | this.subscribeOnChange(() => this.#updateDescription()); |
| 124 | } |
| 125 | // Fill the picker with selections. |
| 126 | this.update(); |
| 127 | } |
| 128 | |
| 129 | update() { |
| 130 | let selections = this.selections; |
nothing calls this directly
no test coverage detected