Skip to content

Commit

Permalink
avniproject/avni-client#1273 - edit edit form rule
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed Feb 8, 2024
1 parent eacad7b commit 4401474
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 2,596 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"prettier": "1.17.1",
"pretty-quick": "^1.11.1",
"redux-saga-test-plan": "^3.7.0",
"source-map-explorer": "^2.0.1"
"source-map-explorer": "^2.0.1",
"@babel/helper-environment-visitor": "7.22.20"
}
}
10 changes: 10 additions & 0 deletions src/formDesigner/common/SampleRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ export const sampleDecisionRule = entityName => {
};`;
};

export const sampleEditFormRule = () => {
return `//SAMPLE EDIT FORM RULE
"use strict";
({params, imports}) => {
const {entity, form, services, entityContext, myUserGroups, userInfo} = params;
const output = {}; // https://avni.readme.io/docs/writing-rules#16-edit-form-rule
return output;
};`;
};

export const sampleVisitScheduleRule = entityName => {
return `//SAMPLE RULE EXAMPLE
"use strict";
Expand Down
13 changes: 13 additions & 0 deletions src/formDesigner/components/FormLevelRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import PropTypes from "prop-types";
import {
sampleChecklistRule,
sampleDecisionRule,
sampleEditFormRule,
sampleTaskScheduleRule,
sampleValidationRule,
sampleVisitScheduleRule
Expand Down Expand Up @@ -93,6 +94,18 @@ const FormLevelRules = ({ form, disabled, onDeclarativeRuleUpdate, encounterType
};
return (
<div>
<RulePanel
title={"Edit Form Rule"}
details={
<Fragment>
<JSEditor
value={form.editFormRule || sampleEditFormRule()}
onValueChange={x => props.onRuleUpdate("editFormRule", x)}
/>
</Fragment>
}
/>

<DeclarativeFormRule
title={"Decision Rule"}
onValueChange={jsonData => onDeclarativeRuleUpdate("decisionDeclarativeRule", jsonData)}
Expand Down
Loading

0 comments on commit 4401474

Please sign in to comment.