Skip to content

Commit

Permalink
Merge pull request #572 from devgateway/fix/OCMAKU-671
Browse files Browse the repository at this point in the history
OCMAKU-671 Procurement plan page in public portal is showing drafts
lilitk authored Jun 17, 2020
2 parents d206e63 + 7c44d23 commit 6d87010
Showing 2 changed files with 42 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -133,13 +133,27 @@ public String toString() {
}

/**
* Any procurement plan is exportable, even the draft ones
* please read first OCMAKU-477 to understand why we need to export draft procurement plans.
* <p>
* the rule to determine if a procurement plan will be published is now the following (by "exportable"
* we mean terminated or approved):
* <p>
* if the procurement plan is exportable - it gets published
* if the procurement plan is draft AND it contains at least one exportable project which contains at least
* one tender process which is exportable
* <p>
* This has implications on the public portal pages, since draft submission of procurement plans is
* <p>
* procurement plans can be exported without file uploads
* procurement plans can be exported without approval dates
*
* @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
52 changes: 26 additions & 26 deletions ui/oce/makueni/procurementPlan/single/procurementPlan.jsx
Original file line number Diff line number Diff line change
@@ -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">
@@ -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>
@@ -89,7 +89,7 @@ class ProcurementPlan extends FeedbackPage {
<div className="item-value">{data.fiscalYear.name}</div>
</div>
</div>

{
data.planItems !== undefined
? <div>
@@ -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">
@@ -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>
@@ -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>
@@ -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">
@@ -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>
@@ -210,7 +210,7 @@ class ProcurementPlan extends FeedbackPage {
</div>
: null
}

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

0 comments on commit 6d87010

Please sign in to comment.