Skip to content

Commit f20b60f

Browse files
authored
Merge pull request #150 from mercedes-benz/VULCAN-947/ActionRules
VULCAN-947/ bug fixes for checkbox disabled
2 parents 958cd79 + c603900 commit f20b60f

File tree

2 files changed

+110
-102
lines changed

2 files changed

+110
-102
lines changed

src/chart/table/TableActionsHelper.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ export const convertConditionsToExpression = (conditions, row) => {
3030
};
3131

3232
const evaluateCondition = (condition, row) => {
33-
const fieldValue = row[condition.field];
33+
let fieldValue = row[condition.field];
34+
35+
// Handle Neo4j integer format
36+
if (fieldValue && typeof fieldValue === 'object' && 'low' in fieldValue && 'high' in fieldValue) {
37+
// Assuming we only care about the 'low' value for comparisons
38+
fieldValue = String(fieldValue.low);
39+
}
40+
3441
switch (condition.condition) {
3542
case '=':
3643
return fieldValue === condition.value;

src/extensions/actions/ActionsRuleCreationModal.tsx

+102-101
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ export const NeoCustomReportActionsModal = ({
375375
const td2Styling = (type) => ({ width: type === 'bar' ? '15%' : '30%' });
376376
const td2DropdownClassname = (type) => `n-align-middle n-pr-1 ${type === 'bar' ? 'n-w-full' : 'n-w-2/5'}`;
377377
const td2Autocomplete = (type, index, rule) =>
378-
type !== 'bar' && rule.condition !== 'rowCheck' ? (
378+
(type !== 'bar' && rule.condition !== 'rowCheck' ? (
379379
<Autocomplete
380380
className='n-align-middle n-inline-block n-w-/5'
381381
disableClearable={true}
@@ -406,7 +406,7 @@ export const NeoCustomReportActionsModal = ({
406406
/>
407407
) : (
408408
<></>
409-
);
409+
));
410410
const td4Styling = (type) => ({ width: type === 'bar' ? '45%' : '40%' });
411411
const td4DropdownClassname = 'n-align-middle, n-w-1/3';
412412
const td6Styling = (type) => ({ width: type === 'bar' ? '30%' : '20%' });
@@ -577,114 +577,115 @@ export const NeoCustomReportActionsModal = ({
577577
</td>
578578
</tr>
579579
</table>
580+
{rules.some((rule) => rule?.condition === 'rowCheck') && (
581+
<table>
582+
<tr>
583+
<td colSpan={7}>
584+
<tr>
585+
<th colSpan={7} className='n-text-center n-font-bold n-py-2'>
586+
Report Pre Conditions
587+
</th>
588+
</tr>
589+
</td>
590+
</tr>
591+
{preConditions.map((con, i) => {
592+
return (
593+
<tr>
594+
<td width='2.5%' className='n-pr-1'>
595+
<span className='n-pr-1'>{i + 1}.</span>
596+
<span className='n-font-bold'>IF</span>
597+
</td>
598+
<td width='100%'>
599+
<div style={{ border: '2px dashed grey' }} className='n-p-1'>
600+
<Autocomplete
601+
className='n-align-middle n-inline-block n-w-5/12 n-pr-1'
602+
disableClearable={true}
603+
id={`autocomplete-label-type${i}`}
604+
size='small'
605+
noOptionsText='*Specify an exact field name'
606+
options={createFieldVariableSuggestions(null, null, null).filter((e) =>
607+
e.toLowerCase().includes(con.field.toLowerCase())
608+
)}
609+
value={con.field ? con.field : ''}
610+
inputValue={con.field ? con.field : ''}
611+
popupIcon={<></>}
612+
style={{ minWidth: 125 }}
613+
onInputChange={(event, value) => {
614+
updatePreConditionFieldById(i, 'field', value);
615+
}}
616+
onChange={(event, newValue) => {
617+
updatePreConditionFieldById(i, 'field', newValue);
618+
}}
619+
renderInput={(params) => (
620+
<TextField
621+
{...params}
622+
placeholder='Field name...'
623+
InputLabelProps={{ shrink: true }}
624+
style={{ padding: '6px 0 7px' }}
625+
size={'small'}
626+
/>
627+
)}
628+
/>
629+
<Dropdown
630+
type='select'
631+
className='n-align-middle n-w-2/12 n-pr-1'
632+
selectProps={{
633+
onChange: (newValue) => updatePreConditionFieldById(i, 'condition', newValue?.value),
634+
options: PRE_CONDITIONS_RULES.map((option) => ({
635+
label: option.label,
636+
value: option.value,
637+
})),
638+
value: { label: con.condition, value: con.condition },
639+
}}
640+
style={{ minWidth: 70, display: 'inline-block' }}
641+
fluid
642+
/>
643+
<TextInput
644+
className='n-align-middle n-inline-block n-w-5/12'
645+
style={{ minWidth: 100 }}
646+
placeholder='Value...'
647+
value={con.value}
648+
onChange={(e) => updatePreConditionFieldById(i, 'value', e.target.value)}
649+
fluid
650+
></TextInput>
651+
</div>
652+
</td>
580653

581-
<table>
582-
<tr>
583-
<td colSpan={7}>
584-
<tr>
585-
<th colSpan={7} className='n-text-center n-font-bold n-py-2'>
586-
Report Pre Conditions
587-
</th>
588-
</tr>
589-
</td>
590-
</tr>
591-
{preConditions.map((con, i) => {
592-
return (
593-
<tr>
594-
<td width='2.5%' className='n-pr-1'>
595-
<span className='n-pr-1'>{i + 1}.</span>
596-
<span className='n-font-bold'>IF</span>
597-
</td>
598-
<td width='100%'>
599-
<div style={{ border: '2px dashed grey' }} className='n-p-1'>
600-
<Autocomplete
601-
className='n-align-middle n-inline-block n-w-5/12 n-pr-1'
602-
disableClearable={true}
603-
id={`autocomplete-label-type${i}`}
604-
size='small'
605-
noOptionsText='*Specify an exact field name'
606-
options={createFieldVariableSuggestions(null, null, null).filter((e) =>
607-
e.toLowerCase().includes(con.field.toLowerCase())
608-
)}
609-
value={con.field ? con.field : ''}
610-
inputValue={con.field ? con.field : ''}
611-
popupIcon={<></>}
612-
style={{ minWidth: 125 }}
613-
onInputChange={(event, value) => {
614-
updatePreConditionFieldById(i, 'field', value);
615-
}}
616-
onChange={(event, newValue) => {
617-
updatePreConditionFieldById(i, 'field', newValue);
618-
}}
619-
renderInput={(params) => (
620-
<TextField
621-
{...params}
622-
placeholder='Field name...'
623-
InputLabelProps={{ shrink: true }}
624-
style={{ padding: '6px 0 7px' }}
625-
size={'small'}
626-
/>
627-
)}
628-
/>
629-
<Dropdown
630-
type='select'
631-
className='n-align-middle n-w-2/12 n-pr-1'
632-
selectProps={{
633-
onChange: (newValue) => updatePreConditionFieldById(i, 'condition', newValue?.value),
634-
options: PRE_CONDITIONS_RULES.map((option) => ({
635-
label: option.label,
636-
value: option.value,
637-
})),
638-
value: { label: con.condition, value: con.condition },
654+
<td width='5%'>
655+
<IconButton
656+
aria-label='remove rule'
657+
size='medium'
658+
style={{ marginLeft: 10 }}
659+
floating
660+
onClick={() => {
661+
setPreConditions((prevItems) => prevItems.filter((_, j) => j !== i));
639662
}}
640-
style={{ minWidth: 70, display: 'inline-block' }}
641-
fluid
642-
/>
643-
<TextInput
644-
className='n-align-middle n-inline-block n-w-5/12'
645-
style={{ minWidth: 100 }}
646-
placeholder='Value...'
647-
value={con.value}
648-
onChange={(e) => updatePreConditionFieldById(i, 'value', e.target.value)}
649-
fluid
650-
></TextInput>
651-
</div>
652-
</td>
653-
654-
<td width='5%'>
663+
>
664+
<XMarkIconOutline />
665+
</IconButton>
666+
</td>
667+
</tr>
668+
);
669+
})}
670+
671+
<tr>
672+
<td colSpan={7}>
673+
<div className='n-text-center n-mt-1'>
655674
<IconButton
656-
aria-label='remove rule'
675+
aria-label='add'
657676
size='medium'
658-
style={{ marginLeft: 10 }}
659677
floating
660678
onClick={() => {
661-
setPreConditions((prevItems) => prevItems.filter((_, j) => j !== i));
679+
setPreConditions([...preConditions, defaultPreCondition]);
662680
}}
663681
>
664-
<XMarkIconOutline />
682+
<PlusIconOutline />
665683
</IconButton>
666-
</td>
667-
</tr>
668-
);
669-
})}
670-
671-
<tr>
672-
<td colSpan={7}>
673-
<div className='n-text-center n-mt-1'>
674-
<IconButton
675-
aria-label='add'
676-
size='medium'
677-
floating
678-
onClick={() => {
679-
setPreConditions([...preConditions, defaultPreCondition]);
680-
}}
681-
>
682-
<PlusIconOutline />
683-
</IconButton>
684-
</div>
685-
</td>
686-
</tr>
687-
</table>
684+
</div>
685+
</td>
686+
</tr>
687+
</table>
688+
)}
688689
</div>
689690
</Dialog.Content>
690691
<Dialog.Actions>

0 commit comments

Comments
 (0)