Skip to content

Commit

Permalink
avniproject/avni-client#1256 | Introduce new sampleCard for Nested Re…
Browse files Browse the repository at this point in the history
…portCards
  • Loading branch information
himeshr committed Jan 25, 2024
1 parent 16a526a commit 1ee8849
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
36 changes: 34 additions & 2 deletions src/formDesigner/common/SampleRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,44 @@ export const sampleWorkListUpdationRule = () => {
};`;
};

export const sampleCardQuery = () => {
return `// Documentation - https://docs.mongodb.com/realm-legacy/docs/javascript/latest/index.html#queries
export const sampleCardQuery = isNested => {
if (isNested) {
return `// Documentation - https://docs.mongodb.com/realm-legacy/docs/javascript/latest/index.html#queries
'use strict';
({params, imports}) => {
const individualsList = params.db.objects('Individual').filtered("individual.voided == false");
// const firstFilterIndividualsList = _.filter(individualsList, function(o) { return cond1; });
// const secondFilterIndividualsList = _.filter(individualsList, function(o) { return cond2; });
// return {reportCards: [
// {
// cardName: 'nested-1',
// cardColor: '#123456',
// textColor: '#654321',
// primaryValue: firstFilterIndividualsList.length,
// secondaryValue: '(5%)',
// lineListFunction: () => {
// return params.db.objects('Individual').filtered("individual.voided == false && cond1")
// }
// },
// {
// cardName: 'nested-2',
// cardColor: '#654321',
// textColor: '#123456',
// primaryValue: secondFilterIndividualsList.length,
// secondaryValue: '(5%)',
// lineListFunction: () => {
// return params.db.objects('Individual').filtered("individual.voided == false && cond2")
// }
// }
// ]
};`;
} else {
return `// Documentation - https://docs.mongodb.com/realm-legacy/docs/javascript/latest/index.html#queries
'use strict';
({params, imports}) => {
// return params.db.objects('Individual').filtered("individual.voided == false");
};`;
}
};

export const sampleLinkFunction = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export const CreateEditReportCard = ({ edit, ...props }) => {
<React.Fragment>
<AvniFormLabel label={"Query"} toolTipKey={"APP_DESIGNER_CARD_QUERY"} />
<JSEditor
value={card.query || sampleCardQuery()}
value={card.query || sampleCardQuery(card.nested)}
onValueChange={event => dispatch({ type: "query", payload: event })}
/>
</React.Fragment>
Expand Down

0 comments on commit 1ee8849

Please sign in to comment.