Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 1 | import {MDCTooltip} from '@material/tooltip'; |
| 2 | |
| 3 | import ThreadModel from '../../../../models/Thread.js'; |
| 4 | import ThreadExtraInfoService from '../services/thread.js'; |
| 5 | |
| 6 | import BaseExtraInfoInjection from './base.js'; |
| 7 | |
| 8 | export default class ThreadQuestionExtraInfoInjection extends |
| 9 | BaseExtraInfoInjection { |
| 10 | inject(threadInfo, injectionDetails) { |
| 11 | const [chips, tooltips] = |
Adrià Vilanova Martínez | 4b2582d | 2023-11-16 01:56:04 +0100 | [diff] [blame] | 12 | ThreadExtraInfoService.getThreadChips(threadInfo.thread.data); |
Adrià Vilanova Martínez | 19f6a65 | 2023-11-15 19:38:50 +0100 | [diff] [blame] | 13 | this.#injectChips(chips, injectionDetails.stateChips); |
| 14 | for (const tooltip of tooltips) new MDCTooltip(tooltip); |
| 15 | } |
| 16 | |
| 17 | #injectChips(chips, stateChipsElement) { |
| 18 | const stateChipsContainer = stateChipsElement.querySelector( |
| 19 | '.scTailwindThreadQuestionStatechipsroot'); |
| 20 | const container = stateChipsContainer ?? stateChipsElement; |
| 21 | const shouldCreateContainer = stateChipsContainer === null; |
| 22 | this.addExtraInfoChips(chips, container, shouldCreateContainer); |
| 23 | } |
| 24 | } |