Skip to content
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.

Commit

Permalink
Conditional display of milestone implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
sandoche committed Jul 14, 2022
1 parent 383b632 commit ae4ec53
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions resources/GrantApplication/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const AdminJS = require('adminjs');
const GrantApplication = require('api.grants/modules/GrantApplication/GrantApplicationModel');
const config = require('../../config/app');
const isMilestoneVisible = require('./isMilestoneVisible');

const grantApplication = {
resource: GrantApplication,
Expand Down Expand Up @@ -95,6 +96,7 @@ const grantApplication = {
};
},
component: false,
isVisible: isMilestoneVisible,
},
rejectMilestone: {
icon: 'Close',
Expand Down Expand Up @@ -125,6 +127,7 @@ const grantApplication = {
};
},
component: false,
isVisible: isMilestoneVisible,
},
signAgreement: {
icon: 'DocumentSigned',
Expand Down
13 changes: 13 additions & 0 deletions resources/GrantApplication/isMilestoneVisible.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const isMilestoneVisible = (context) => {
const { record } = context;

const milestones = record.param('milestones');

const currentMilestone = milestones.find(
(milestone) => milestone.dateSubmission && milestone.isNearProposalValid && milestone.dateInterviewScheduled && !(milestone.dateRejection || milestone.dateValidation),
);

return !!currentMilestone;
};

module.exports = isMilestoneVisible;

0 comments on commit ae4ec53

Please sign in to comment.