File tree Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,10 @@ All notable changes to this project will be documented in this file.
55
66## [ Unreleased]
77
8+ - [ #264 ] ( https://github.com/os2display/display-admin-client/pull/264 )
9+ - Added checkbox options component for use in calendar modifiers.
810- [ #260 ] ( https://github.com/os2display/display-admin-client/pull/260 )
9- - Bug in multiselect, fixed by removing duplicates by key both ` @id ` and ` id `
10-
11+ - Bug in multiselect, fixed by removing duplicates by key both ` @id ` and ` id `
1112- [ #259 ] ( https://github.com/os2display/display-admin-client/pull/259 )
1213 - Add saving of playlists/groups with screen (as opposed to _ after_ )
1314 - Clean up ` screen-manager.jsx `
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import FormTable from "../../util/forms/form-table/form-table";
99import FileSelector from "./file-selector" ;
1010import StationSelector from "./station/station-selector" ;
1111import RadioButtons from "../../util/forms/radio-buttons" ;
12+ import CheckboxOptions from "../../util/forms/checkbox-options.jsx" ;
1213
1314/**
1415 * Render form elements for content form.
@@ -52,6 +53,9 @@ function ContentForm({
5253 let returnElement ;
5354 let defaultMimetypes = null ;
5455 switch ( formData . input ) {
56+ case "checkbox-options" :
57+ returnElement = < CheckboxOptions formData = { formData } data = { formStateObject } onChange = { onChange } /> ;
58+ break ;
5559 case "image" :
5660 case "video" :
5761 case "file" :
Original file line number Diff line number Diff line change 1+ import { React } from "react" ;
2+
3+ function CheckboxOptions ( { formData, data, onChange} ) {
4+ const values = data [ formData . name ] ;
5+
6+ const containsValue = ( value ) => {
7+ return values . includes ( value ) ;
8+ }
9+
10+ const onOptionChange = ( { target} ) => {
11+ const value = target . value ;
12+
13+ const newValues = [ ...values ] ;
14+
15+ if ( newValues . includes ( value ) ) {
16+ newValues . splice ( newValues . indexOf ( value ) , 1 ) ;
17+ } else {
18+ newValues . push ( value ) ;
19+ }
20+
21+ onChange ( {
22+ target : { id : formData . name , value : newValues } ,
23+ } ) ;
24+ }
25+
26+ return ( < >
27+ {
28+ formData . options . map ( option =>
29+ < div className = { formData . formGroupClasses } >
30+ < input type = "checkbox" key = { option . value } value = { option . value } onChange = { onOptionChange } checked = { containsValue ( option . value ) } /> { option . title }
31+ </ div >
32+ )
33+ }
34+ </ > ) ;
35+ }
36+
37+ export default CheckboxOptions ;
You can’t perform that action at this time.
0 commit comments