Skip to content

Commit

Permalink
Merge pull request #754 from the-deep/feature-assessment-export
Browse files Browse the repository at this point in the history
Feature assessment export
  • Loading branch information
pprabesh authored Apr 8, 2019
2 parents 6632007 + 1764629 commit b85e1a6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/redux/initial-state/dev-lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,8 @@
"-73426620": "Ascending",
"-8251517": "Descending",
"-20881567": "Alphabetical Ascending",
"-93837566": "Alphabetical Descending"
"-93837566": "Alphabetical Descending",
"-58642627": "Start assessment export"
},
"links": {
"browserExtension": {
Expand Down Expand Up @@ -1384,7 +1385,8 @@
"projectLabel": 31,
"cantLoadProject": 646,
"afLabel": 379,
"cantLoadAf": 648
"cantLoadAf": 648,
"startAssessmentExportButtonLabel": -58642627
},
"fourHundredFour": {
"errorFourHundredFour": 870,
Expand Down Expand Up @@ -2636,4 +2638,4 @@
"tabularTabTitle": 142
}
}
}
}
48 changes: 44 additions & 4 deletions src/views/Export/ExportHeader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ import { reverseRoute } from '@togglecorp/fujs';
import { FgRestBuilder } from '#rsu/rest';
import Button from '#rsca/Button';
import PrimaryButton from '#rsca/Button/PrimaryButton';
import AccentButton from '#rsca/Button/AccentButton';

import Cloak from '#components/general/Cloak';
import {
urlForExportTrigger,
createParamsForExportTrigger,
} from '#rest';
import { pathNames } from '#constants';
import {
pathNames,
viewsAcl,
} from '#constants';
import _ts from '#ts';
import notify from '#notify';

Expand Down Expand Up @@ -59,7 +64,7 @@ export default class ExportHeader extends React.PureComponent {
}
));

export = (onSuccess, isPreview = false, pdf = false) => {
export = (onSuccess, isPreview = false, pdf = false, exportItem = 'entry') => {
// Let's start by collecting the filters
const {
projectId,
Expand All @@ -71,12 +76,15 @@ export default class ExportHeader extends React.PureComponent {
} = this.props;

let exportType;
if (activeExportTypeKey === 'word' || activeExportTypeKey === 'pdf') {
if (exportItem === 'assessment') {
exportType = 'excel';
} else if (activeExportTypeKey === 'word' || activeExportTypeKey === 'pdf') {
exportType = 'report';
} else {
exportType = activeExportTypeKey;
}


const filters = {
project: projectId,
export_type: exportType,
Expand All @@ -86,12 +94,17 @@ export default class ExportHeader extends React.PureComponent {
report_structure: this.createReportStructureForExport(reportStructure || emptyList),
is_preview: isPreview,
pdf,
export_item: exportItem,
};

if (this.exportRequest) {
this.exportRequest.stop();
}
this.exportRequest = this.createRequestForExport({ filters }, onSuccess);

this.exportRequest = this.createRequestForExport({
filters,
}, onSuccess);

this.exportRequest.start();
}

Expand Down Expand Up @@ -120,6 +133,20 @@ export default class ExportHeader extends React.PureComponent {
this.export(exportFn, false, this.props.activeExportTypeKey === 'pdf');
}

handleAssessmentExportClick = () => {
const exportFn = (exportId) => {
console.log('Exporting to ', exportId);
notify.send({
title: _ts('export', 'headerExport'),
type: notify.type.SUCCESS,
message: _ts('export', 'exportStartedNotifyMessage'),
duration: 15000,
});
};

this.export(exportFn, false, false, 'assessment');
}

handlePreview = () => {
this.export(this.props.onPreview, true, this.props.activeExportTypeKey === 'pdf');
}
Expand Down Expand Up @@ -151,6 +178,19 @@ export default class ExportHeader extends React.PureComponent {
>
{_ts('export', 'showPreviewButtonLabel')}
</Button>
<Cloak
// NOTE: this is temporary, will be moved to new page
{...viewsAcl.arys}
render={
<AccentButton
className={styles.button}
onClick={this.handleAssessmentExportClick}
disabled={this.props.pending}
>
{_ts('export', 'startAssessmentExportButtonLabel')}
</AccentButton>
}
/>
<PrimaryButton
className={styles.button}
onClick={this.handleExport}
Expand Down
1 change: 1 addition & 0 deletions src/views/Export/ExportHeader/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
.link {
@extend %button-like-link;
margin-left: $spacing-small;
font-weight: $font-weight-bold;
}
}
}

0 comments on commit b85e1a6

Please sign in to comment.