| 1 | class Panel { |
| 2 | /** |
| 3 | * Creates a new Panel consisting of a sign and an exit tab. |
| 4 | * @param {string} color - Background color of the sign and exit tab. |
| 5 | * @param {Sign} sign - Sign to make up the panel. |
| 6 | * @param {String} corner - Choice of Sharp or Rounded Corners on the Panel |
| 7 | * @param {ExitTab} [exitTab=null] - Optional exit tab to include in the panel. |
| 8 | */ |
| 9 | constructor(sign, color, exitTabs = [], corner) { |
| 10 | if (Object.keys(lib.colors).includes(color)) { |
| 11 | this.color = color; |
| 12 | } else { |
| 13 | this.color = "Green"; |
| 14 | } |
| 15 | if (Object.keys(this.cornerType).includes(corner)) { |
| 16 | this.corner = corner; |
| 17 | } else { |
| 18 | this.corner = this.cornerType[0]; |
| 19 | } |
| 20 | |
| 21 | this.sign = sign; |
| 22 | this.exitTabs = exitTabs; |
| 23 | |
| 24 | } |
| 25 | |
| 26 | newExitTab() { |
| 27 | const exitTab = new ExitTab(); |
| 28 | |
| 29 | this.exitTabs.push(exitTab); |
| 30 | } |
| 31 | |
| 32 | deleteExitTab(index,secondaryIndex) { |
| 33 | if (this.exitTabs.nestedExitTabs.length > 0) { |
| 34 | this.exitTabs.nestedExitTabs.splice(secondaryIndex, 1); |
| 35 | } else { |
| 36 | this.exitTabs.splice(index,1); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | duplicateExitTab(index) { |
| 41 | const exisitingTab = this.exitTabs[index]; |
| 42 | |
| 43 | const newNest = [] |
| 44 | |
| 45 | for (const nest of exisitingTab.nestedExitTabs) { |
| 46 | newNest.push(Object.assign(new ExitTab(), nest)) |
| 47 | } |
| 48 | |
| 49 | const exitTab = new ExitTab({ |
| 50 | number : exisitingTab.number, |
| 51 | position : exisitingTab.position, |
| 52 | width : exisitingTab.width, |
| 53 | color : exisitingTab.color, |
| 54 | variant : exisitingTab.variant, |
| 55 | icon : exisitingTab.icon, |
| 56 | fullBorder : exisitingTab.fullBorder, |
| 57 | borderThickness : exisitingTab.borderThickness, |
| 58 | minHeight : exisitingTab.minHeight, |
| 59 | nestedExitTabs : newNest |
| 60 | }); |
nothing calls this directly
no outgoing calls
no test coverage detected