Skip to content

Commit

Permalink
OCMAKU-671 Procurement plan page in public portal is showing drafts
Browse files Browse the repository at this point in the history
  • Loading branch information
mpostelnicu committed Jun 17, 2020
1 parent 9a3ec11 commit ae3fccb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,15 @@ public String toString() {
}

/**
* Any procurement plan is exportable, even the draft ones
* Procurement Plan is exportable only if there is at least one approved/terminated tender process
*
* @return
*/
@Override
@Transactional
public boolean isExportable() {
return true;
return super.isExportable() || getProjects().stream().filter(Statusable::isExportable).
flatMap(p -> p.getTenderProcesses().stream()).anyMatch(Statusable::isExportable);
}

@Override
Expand Down
52 changes: 26 additions & 26 deletions ui/oce/makueni/procurementPlan/single/procurementPlan.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,58 @@ import FeedbackPage from '../../FeedbackPage';
class ProcurementPlan extends FeedbackPage {
constructor(props) {
super(props);

this.state = {};

this.ppID = ppState.input({
name: 'ppID',
});

this.ppInfoUrl = ppState.mapping({
name: 'ppInfoUrl',
deps: [this.ppID],
mapper: id => `${API_ROOT}/makueni/procurementPlan/id/${id}`,
});

this.ppInfo = ppState.remote({
name: 'ppInfo',
url: this.ppInfoUrl,
});
}

componentDidMount() {
const { id } = this.props;

this.ppID.assign('PP', id);

this.ppInfo.addListener('PP', () => {
this.ppInfo.getState()
.then(data => {
this.setState({ data: data });
});
});
}

componentWillUnmount() {
this.ppInfo.removeListener('PP');
}

getFeedbackSubject() {
const { data } = this.state;

let metadata;
if (data !== undefined) {
metadata = " - " + data.department.label + " - " + data.fiscalYear.name;
}
return escape("Procurement Plan" + metadata);
}

render() {
const { navigate } = this.props;
const { data } = this.state;

const { currencyFormatter, formatDate } = this.props.styling.tables;

return (<div className="procurement-plan makueni-form">
<div className="row">
<a href="#!/procurement-plan" onClick={() => navigate()} className="back-link col-md-3">
Expand All @@ -69,13 +69,13 @@ class ProcurementPlan extends FeedbackPage {
</span>
</a>
</div>

<div className="row padding-top-10">
<div className="col-md-12">
<h1 className="page-title">Procurement Plan</h1>
</div>
</div>

{
data !== undefined
? <div>
Expand All @@ -89,7 +89,7 @@ class ProcurementPlan extends FeedbackPage {
<div className="item-value">{data.fiscalYear.name}</div>
</div>
</div>

{
data.planItems !== undefined
? <div>
Expand All @@ -98,7 +98,7 @@ class ProcurementPlan extends FeedbackPage {
({data.planItems.length})
</div>
</div>

{
data.planItems.map(planItem => <div key={planItem.id} className="box">
<div className="row">
Expand All @@ -107,8 +107,8 @@ class ProcurementPlan extends FeedbackPage {
<div className="item-value">{planItem.item.label}</div>
</div>
</div>


<div className="row padding-top-10">
<div className="col-md-3">
<div className="item-label">Unit Of Issue</div>
Expand All @@ -127,7 +127,7 @@ class ProcurementPlan extends FeedbackPage {
<div className="item-value">{currencyFormatter(planItem.quantity * planItem.estimatedCost)}</div>
</div>
</div>

<div className="row padding-top-10">
<div className="col-md-3">
<div className="item-label">Procurement Method</div>
Expand All @@ -153,7 +153,7 @@ class ProcurementPlan extends FeedbackPage {
className="item-value">{currencyFormatter(planItem.targetGroupValue)}</div>
</div>
</div>

<div className="row padding-top-10">
<h4 className="col-md-12">Timing of activities (quarterly basis)</h4>
<div className="col-md-3">
Expand All @@ -175,21 +175,21 @@ class ProcurementPlan extends FeedbackPage {
</div>
</div>)
}

<div className="row padding-top-10">
<div className="col-md-6">
<div className="item-label">Procurement Plan Documents</div>

{
data.formDocs.map(doc => <div key={doc.id}>
data.formDocs && data.formDocs.map(doc => <div key={doc.id}>
<OverlayTrigger
placement="bottom"
overlay={
<Tooltip id="download-tooltip">
Click to download the file
</Tooltip>
}>

<a className="item-value download" href={doc.url} target="_blank">
<i className="glyphicon glyphicon-download"/>
<span>{doc.name}</span>
Expand All @@ -210,7 +210,7 @@ class ProcurementPlan extends FeedbackPage {
</div>
: null
}

{this.getFeedbackMessage()}
</div>);
}
Expand Down

0 comments on commit ae3fccb

Please sign in to comment.