Skip to content

Commit

Permalink
[ASL-4590] Limit injecting licence holder field to PDF (#954)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-horton-ho-sas authored Oct 14, 2024
1 parent 5490467 commit 6b36786
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 47 deletions.
17 changes: 1 addition & 16 deletions client/schema/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,13 @@ export function getGrantedSubsections(schemaVersion) {

export function getSubsections(schemaVersion) {
const schema = versions[schemaVersion];
const subsections = Object.values(schema())
return Object.values(schema())
.reduce((sections, section) => {
return {
...sections,
...(section.subsections || {})
};
}, {});

if (schemaVersion === 1) {
// inject the project licence holder into introductory details
const field = [
{
label: 'Licence holder',
name: 'licenceHolder',
type: 'holder-name'
}
];

subsections['introduction'].fields.splice(1, 0, field);
}

return subsections;
}

export default versions;
53 changes: 25 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@asl/projects",
"version": "15.6.8",
"version": "15.6.9",
"description": "ASL PPL prototype",
"main": "client/external.js",
"styles": "assets/scss/projects.scss",
Expand Down
19 changes: 17 additions & 2 deletions views/pdf/v1/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,27 @@ import { getGrantedSubsections, getSubsections } from '../../../client/schema';
import StaticSection from '../../../client/components/static-section';
import StandardConditions from '../components/standard-conditions';

function injectLicenceHolder(subsections) {
// inject the project licence holder into introductory details
const field = [
{
label: 'Licence holder',
name: 'licenceHolder',
type: 'holder-name'
}
];

subsections['introduction'].fields.splice(1, 0, field);

return subsections;
}

export default function PDF() {
const project = useSelector(state => state.project);
const isFullApplication = useSelector(state => state.application.isFullApplication);

const sections = isFullApplication
? Object.values(getSubsections(1))
? Object.values(injectLicenceHolder(getSubsections(1)))
.filter(s => !s.show || s.show(project))
: Object.values(getGrantedSubsections(1))
.filter(s => !s.granted.show || s.granted.show(project))
Expand All @@ -31,5 +46,5 @@ export default function PDF() {
!isFullApplication && <StandardConditions />
}
</div>
)
);
}

0 comments on commit 6b36786

Please sign in to comment.