| 1 |
import { updateSnippet } from './requests' |
| 2 |
import type { Snippet } from '../../types/Snippet' |
| 3 |
|
| 4 |
/** |
| 5 |
* Update the priority of a snippet |
| 6 |
*/ |
| 7 |
export const updateSnippetPriority = (element: HTMLInputElement) => { |
| 8 |
const row = element.parentElement?.parentElement |
| 9 |
const snippet: Partial<Snippet> = { priority: parseFloat(element.value) } |
| 10 |
if (row) { |
| 11 |
updateSnippet('priority', row, snippet) |
| 12 |
} else { |
| 13 |
console.error('Could not update snippet information.', snippet, row) |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
export const handleSnippetPriorityChanges = () => { |
| 18 |
for (const field of <HTMLCollectionOf<HTMLInputElement>> document.getElementsByClassName('snippet-priority')) { |
| 19 |
field.addEventListener('input', () => updateSnippetPriority(field)) |
| 20 |
field.disabled = false |
| 21 |
} |
| 22 |
} |
| 23 |
|