Merge branch 'documents-fix' into 'development'

Documents fix

See merge request saburly/wiaas/new-wiaas!63
This commit was merged in pull request #63.
This commit is contained in:
Bilal Catic
2018-11-07 10:17:46 +00:00
13 changed files with 88 additions and 28 deletions

View File

@@ -740,6 +740,7 @@ class Wiaas_Cart {
$documents_ids = array();
// Retrieve all document ids attached to cart content
foreach ($items as $key => $item) {
if (!isset($item['_wiaas_standard_package'])) {
continue;
@@ -757,16 +758,19 @@ class Wiaas_Cart {
}
}
// Retrieve all customer visible template documents attached to cart content
$q = new WP_Query();
$retrieved_items = $q->query(array(
'post_status' => 'publish',
'post_type' => 'wiaas_doc',
'post__in' => array_keys($documents_ids),
'meta_key' => '_wiaas_doc_visible',
'meta_value' => 'yes', // visible to customer
'tax_query' => array(
array(
'taxonomy' => 'wiaas_doc_type',
'field' => 'slug',
'terms' => array_keys(self::$cart_doc_types),
'terms' => array_keys(self::$cart_doc_types), // templates only
)
)
));

View File

@@ -147,7 +147,7 @@ class Wiaas_Shop_DB {
$shops = array_map(function($result_row) {
return array(
'owner_id' => $result_row->shop_owner_id,
'owner_id' => absint($result_row->shop_owner_id),
'order_type' => $result_row->order_type
);
}, $results);

View File

@@ -308,6 +308,7 @@ class Wiaas_Delivery_Process_Action {
$documents[] = array(
'name' => $info['basename'],
'extension' => $info['extension'],
'url' => $acceptance_documents_field->get_download_url( $file_path, true )
);
}
@@ -365,18 +366,25 @@ class Wiaas_Delivery_Process_Action {
$document = array(
'name' => $info['basename'],
'extension' => $info['extension'],
'url' => $document_field->get_download_url( $file_path, true )
);
$discussion_field = GFCommon::get_fields_by_type(GFAPI::get_form($action_entry['form_id']), 'workflow_discussion')[0];
$discussion_items = json_decode($action_entry[$discussion_field->id], ARRAY_A);
$formated_comments = array();
$formatted_comments = array();
if (is_array($discussion_items)) {
foreach ($discussion_items as $item) {
$formated_comments[] = $discussion_field->format_discussion_item( $item, 'text', $action_entry_id );
$formatted = $discussion_field->format_discussion_item( $item, 'text', $action_entry_id );
$formatted = explode("\n", $formatted);
$formatted_comments[] = array(
'header' => $formatted[0],
'value' => $formatted[1]
);
}
}
@@ -408,7 +416,7 @@ class Wiaas_Delivery_Process_Action {
'action_id' => $action_entry['id'],
'document' => $document,
'status' => $status,
'comments' => $formated_comments
'comments' => $formatted_comments
);
}

View File

@@ -12,6 +12,7 @@ import {
updateMessages
} from '../notification/notificationActions';
import HtmlClient from '../../helpers/HtmlClient';
import { fromWiaasCustomerAcceptance } from '../../helpers/ProcessHelper';
const htmlClient = new HtmlClient();
@@ -32,7 +33,11 @@ export const fetchCustomerAcceptance = (idOrder) => {
})
.then(response => {
if (response.data) {
dispatch(recieveCustomerAcceptance(response.data));
dispatch(
recieveCustomerAcceptance(
fromWiaasCustomerAcceptance(response.data)
)
);
}
})
.catch(error => {

View File

@@ -1,6 +1,8 @@
import {
API_SERVER
} from '../../config';
import { fromWiaasCustomerQuestionnaire } from '../../helpers/ProcessHelper';
import {
UPLOAD_CUSTOMER_QUESTIONNAIRE,
@@ -41,7 +43,8 @@ export const fetchCustomerQuestionnaires = (idOrder) => {
})
.then(response => {
if (typeof response.data !== 'undefined') {
dispatch(receiveCustomerQuestionnaires(response.data));
const questionnairesData = response.data.map(cData => fromWiaasCustomerQuestionnaire(cData));
dispatch(receiveCustomerQuestionnaires(questionnairesData));
}
})
.catch(error => {

View File

@@ -70,10 +70,10 @@ class CartUploadDocument extends Component {
<h1 className="drop-zone-icon">
<i className="fa fa-upload"></i>
</h1>
<h6 className="drop-zone-text">{uploadedDocument.name}</h6>
<span className="drop-zone-text">
Drag and drop or click to replace file
</span>
<p className="drop-zone-text">
Drag and drop or click to replace <strong>{uploadedDocument.name}.{uploadedDocument.extension}</strong>
</p>
<p className="drop-zone-text">To upload multiple files, please pack the files to one zip-file and upload the zip-file</p>
</div>
)
: (
@@ -81,9 +81,10 @@ class CartUploadDocument extends Component {
<h1 className="drop-zone-icon pending-upload">
<i className="fa fa-upload"></i>
</h1>
<span className="drop-zone-text">
<p className="drop-zone-text">
Drag and drop or click to upload file
</span>
</p>
<p className="drop-zone-text">To upload multiple files, please pack the files to one zip-file and upload the zip-file</p>
</div>
)
}

View File

@@ -25,10 +25,10 @@ class CoMarketCatalogSelect extends Component {
}
componentWillReceiveProps(nextProps){
// if(nextProps.activeModule==='cart' && nextProps.shops && nextProps.cartItems && nextProps.cartItems.length > 0){
// const cartShop = this.props.shops.find( shop => { return shop.id === this.props.cartItems[0].idCommercialLead });
// nextProps.dispatch(selectShop(cartShop));
// }
if(nextProps.activeModule==='cart' && nextProps.shops && nextProps.cartItems && nextProps.cartItems.length > 0){
const cartShop = nextProps.shops.find( shop => { return shop.id === nextProps.cartItems[0].idCommercialLead });
nextProps.dispatch(selectShop(cartShop));
}
if(nextProps.shops && nextProps.idCommercialLead && nextProps.activeModule === 'co-market'){
const shop = nextProps.shops.find( shop => {return shop.id === nextProps.idCommercialLead });

View File

@@ -139,6 +139,7 @@ class CustomerAcceptance extends Component {
activeClassName="upload-file-accept"
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(step.idOrder, acceptedFiles, rejectedFiles)}}>
<h5 className="drop-zone-text">{orderTexts.labels.UPLOAD_ACCEPTANCE_LABEL}</h5>
<p className="drop-zone-text">To upload multiple files, please pack the files to one zip-file and upload the zip-file</p>
</Dropzone>
</Col>
<Col xl="4" lg="7" md="8">
@@ -148,7 +149,7 @@ class CustomerAcceptance extends Component {
{
customerAcceptance.documents.map((document, index) => <div key={'acceptance-documnet-' + index}>
<span className="document-link">
<i className={'fa fa-file'}></i> <a download href={document.url}> {document.name} </a>
<i className={`fa fa-${document.icon}`}></i> <a download href={document.url}> {document.name} </a>
</span>
<span className="document-status">
{document.validation} <div className={'status-icon ' + document.validation}></div>

View File

@@ -27,8 +27,8 @@ class ValidateQuestionnaire extends Component {
customerQuestionnaires.map((customerQuestionnaryAction) =>
<ValidateQuestionnaireItem
action={customerQuestionnaryAction}
key={'validate-questionnaire-' + customerQuestionnaryAction.action_id}
orderPackage={orderPackages.find( orderPackage => orderPackage.orderItemId === customerQuestionnaryAction.item_id)}
key={'validate-questionnaire-' + customerQuestionnaryAction.actionId}
orderPackage={orderPackages.find( orderPackage => orderPackage.orderItemId === customerQuestionnaryAction.orderItemId)}
/>
)
}

View File

@@ -19,7 +19,7 @@ class ValidateQuestionnaireItem extends Component {
uploadFile(action,acceptedFiles, rejectedFiles) {
if(acceptedFiles && acceptedFiles.length){
const file = acceptedFiles[0];
this.props.dispatch(uploadCustomerQuestionnaire(action.order_id, action.action_id, file));
this.props.dispatch(uploadCustomerQuestionnaire(action.orderId, action.actionId, file));
}
// if(rejectedFiles && rejectedFiles.length) {
@@ -48,7 +48,7 @@ class ValidateQuestionnaireItem extends Component {
<div>
<span className="document-link">
<i className={'fa fa-file'}></i> <a download href={document.url}> {document.name} </a>
<i className={`fa fa-${document.icon}`}></i> <a download href={document.url}> {document.name} </a>
</span>
<br />
<span className="document-status">
@@ -59,7 +59,8 @@ class ValidateQuestionnaireItem extends Component {
(action.comments && action.comments.length > 0) &&
<div>
{action.comments.map((comment, key) => <div key={'step-comment-' + document.idDocument + '-' + key} className="step-comment">
<div>{comment}</div>
<strong>{comment.header}</strong>
<p>{comment.value}</p>
</div>)}
</div>
}
@@ -71,6 +72,7 @@ class ValidateQuestionnaireItem extends Component {
activeClassName="upload-file-accept"
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(action, acceptedFiles, rejectedFiles)}}>
<h5 className="drop-zone-text">{orderTexts.labels.SELECT_OR_DROP}</h5>
<p className="drop-zone-text">To upload multiple files, please pack the files to one zip-file and upload the zip-file</p>
</Dropzone>
</Col>
</Row>
@@ -79,12 +81,21 @@ class ValidateQuestionnaireItem extends Component {
<Row>
<Col>
<span className="document-link">
<i className={'fa fa-file'}></i> <a download href={document.url}> {document.name} </a>
<i className={`fa fa-${document.icon}`}></i> <a download href={document.url}> {document.name} </a>
</span>
<br />
<span className="document-status">
{action.status.replace(/-/g,' ')} <div className={'status-icon ' + action.status}></div>
</span>
{
(action.comments && action.comments.length > 0) &&
<div>
{action.comments.map((comment, key) => <div key={'step-comment-' + document.idDocument + '-' + key} className="step-comment">
<strong>{comment.header}</strong>
<p>{comment.value}</p>
</div>)}
</div>
}
</Col>
</Row>
</div>

View File

@@ -181,7 +181,7 @@ $link-line-height: 1.5rem;
.upload-file-drop-zone {
width: 100%;
border: 3px dashed $borderColor;
height: 10rem;
padding: 2rem;
cursor: pointer;
border-radius: 4px;
}
@@ -206,7 +206,6 @@ $link-line-height: 1.5rem;
.drop-zone-text {
text-align: center;
padding: 4rem 0;
}
.document-link {
@@ -357,7 +356,6 @@ $link-line-height: 1.5rem;
.drop-zone-text {
text-align: center;
padding: 4rem 0;
font-size: 1rem;
}

View File

@@ -9,7 +9,8 @@ const iconTypes = {
xls: 'file-excel-o',
xlsx: 'file-excel-o',
ppt: 'file-powerpoint-o',
pptx: 'file-powerpoint-o'
pptx: 'file-powerpoint-o',
zip: 'file-zip-o'
};
export const getDocumentIcon = extension => {

View File

@@ -1,4 +1,5 @@
import moment from "moment";
import {getDocumentIcon} from "./DocumentHelper";
export const fromWiaasProcessStep = (step) => {
return {
@@ -13,4 +14,31 @@ export const fromWiaasProcessStep = (step) => {
shortDesc: step.short_desc,
status: step.status,
}
};
export const fromWiaasCustomerAcceptance = cData => {
return {
actionId: cData['action_id'],
expiration: cData.expiration,
declineReason: cData['decline_reason'],
status: cData.status,
documents: cData.documents ? cData.documents.map(document => {
document.icon = getDocumentIcon(document.extension);
return document;
}) : []
};
};
export const fromWiaasCustomerQuestionnaire = cData => {
const document = cData.document;
document.icon = getDocumentIcon(document.extension);
return {
actionId: cData['action_id'],
orderItemId: cData['item_id'],
document,
status: cData.status,
orderId: cData['order_id'],
comments: cData.comments
};
};