Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCMAKU-671 Procurement plan page in public portal is showing drafts #572

Merged
merged 2 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
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