Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple checkboxes update #1840

Open
wants to merge 1 commit into
base: 5.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions src/tactic/react/table_layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,9 @@ class SelectEditor {
}, helpers[index]))));
return;
} else if (mode == "checkbox") {
if (this.value == null) {
if (this.value == null && labels.length > 1) {
this.value = values[2];
} else if (this.value == null) {
this.value = values[1];
}
this.el = React.createElement("div", {
Expand All @@ -852,7 +854,50 @@ class SelectEditor {
display: "flex",
alignItems: "center"
}
}, React.createElement(Checkbox, {
}, labels.length > 1 ? React.createElement(React.Fragment, null, React.createElement(Checkbox, {
checked: this.value === values[0],
onChange: e => {
if (this.value === values[0]) {
this.value = values[2];
} else if (this.value === values[1]) {
this.value = values[0];
} else if (this.value === values[2]) {
this.value = values[0];
}
e.name = name;
if (params.onchange) {
params.onchange(e, this.value);
}
},
style: {
cursor: "pointer",
alignSelf: "flex-start"
}
}), React.createElement("div", {
style: {
fontSize: "0.8rem",
textAlign: "center"
}
}, labels[0]), React.createElement(Checkbox, {
checked: this.value === values[1],
onChange: e => {
if (this.value === values[0]) {
this.value = values[1];
} else if (this.value === values[1]) {
this.value = values[2];
} else if (this.value === values[2]) {
this.value = values[1];
}
e.name = name;
if (params.onchange) {
params.onchange(e, this.value);
}
},
style: {
cursor: "pointer",
alignSelf: "flex-start"
}
})) : React.createElement(Checkbox, {
checked: this.value === values[0],
onChange: e => {
if (this.value === values[0]) {
Expand All @@ -874,7 +919,7 @@ class SelectEditor {
fontSize: "0.8rem",
textAlign: "center"
}
}, labels[0])));
}, labels.length > 1 ? labels[1] : labels[0])));
return;
}
this.el = React.createElement(TextField, {
Expand Down
63 changes: 61 additions & 2 deletions src/tactic/react/table_layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1210,13 +1210,71 @@ class SelectEditor {

else if (mode == "checkbox") {
//Default to not checked
if (this.value == null) {
if (this.value == null && labels.length > 1) {
this.value = values[2];
}
else if (this.value == null) {
this.value = values[1];
}




this.el = (
<div style={{display: "flex", flexDirection: layout, gap: "20px"}}>
<div style={{width: "100%", display: "flex", alignItems: "center"}}>
{labels.length > 1 ? <><Checkbox
checked={this.value === values[0]}
onChange={ e => {
if (this.value === values[0]){
this.value = values[2];
}
else if (this.value === values[1]){
this.value = values[0];
}
else if (this.value === values[2]){
this.value = values[0];
}
// Need to add this
e.name = name;

if (params.onchange) {
params.onchange(e, this.value);
}
}}
style={{
cursor: "pointer",
alignSelf: "flex-start"
}}
/>
<div style={{
fontSize: "0.8rem",
textAlign: "center",
}}>{labels[0]}</div>
<Checkbox
checked={this.value === values[1]}
onChange={ e => {
if (this.value === values[0]){
this.value = values[1];
}
else if (this.value === values[1]){
this.value = values[2];
}
else if (this.value === values[2]){
this.value = values[1];
}
// Need to add this
e.name = name;

if (params.onchange) {
params.onchange(e, this.value);
}
}}
style={{
cursor: "pointer",
alignSelf: "flex-start"
}}
/></>:
<Checkbox
checked={this.value === values[0]}
onChange={ e => {
Expand All @@ -1238,10 +1296,11 @@ class SelectEditor {
alignSelf: "flex-start"
}}
/>
}
<div style={{
fontSize: "0.8rem",
textAlign: "center",
}}>{labels[0]}</div>
}}>{labels.length > 1 ? labels[1] : labels[0]}</div>
</div>
</div>
)
Expand Down