• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

scriptype / writ-cms / 21603643815

02 Feb 2026 07:06PM UTC coverage: 38.574% (-0.06%) from 38.638%
21603643815

push

github

scriptype
Extract a selectContentTypesForm component from editProject

and also:
- move common into app dir
- dialog.appenChild

This form will be reused in the main project editing flow. so it was
time to componentize

621 of 3672 branches covered (16.91%)

Branch coverage included in aggregate %.

0 of 25 new or added lines in 3 files covered. (0.0%)

2171 of 3566 relevant lines covered (60.88%)

1756.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/cms/server/public/app/components/selectContentTypesForm.js
1
import { createDOMNodeFromHTML } from '../common.js'
2

NEW
3
const template = ({ defaultContentTypes }) => {
×
NEW
4
  return (
×
5
`<form>
6
  <h1>content types</h1>
NEW
7
${defaultContentTypes.map(contentType => `
×
8
<label><input type="checkbox" name="${contentType.name}">${contentType.name}</label>
9
`
10
).join('')}
11

12
  <button>Ok</button>
13
</form>`
14
  )
15
}
16

NEW
17
const selectContentTypesForm = ({ defaultContentTypes, onSubmit }) => {
×
NEW
18
  const onFormSubmit = async (e) => {
×
NEW
19
    e.preventDefault()
×
NEW
20
    const formData = new FormData($el)
×
NEW
21
    const keyValues = Array.from(formData.entries())
×
NEW
22
    const selectedKeys = keyValues.filter(([key, value]) => value === 'on').map(([key]) => key)
×
NEW
23
    const selectedContentTypes = defaultContentTypes.filter(ct => selectedKeys.includes(ct.name))
×
NEW
24
    onSubmit(selectedContentTypes)
×
25
  }
26

NEW
27
  const addEventListeners = () => {
×
NEW
28
    $el.addEventListener('submit', onFormSubmit)
×
29
  }
30

NEW
31
  const html = template({
×
32
    defaultContentTypes
33
  })
NEW
34
  const $el = createDOMNodeFromHTML(html)
×
35

NEW
36
  addEventListeners()
×
37

NEW
38
  return {
×
39
    $el
40
  }
41
}
42

43
export default selectContentTypesForm
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc