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:
@@ -740,6 +740,7 @@ class Wiaas_Cart {
|
|||||||
|
|
||||||
$documents_ids = array();
|
$documents_ids = array();
|
||||||
|
|
||||||
|
// Retrieve all document ids attached to cart content
|
||||||
foreach ($items as $key => $item) {
|
foreach ($items as $key => $item) {
|
||||||
if (!isset($item['_wiaas_standard_package'])) {
|
if (!isset($item['_wiaas_standard_package'])) {
|
||||||
continue;
|
continue;
|
||||||
@@ -757,16 +758,19 @@ class Wiaas_Cart {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retrieve all customer visible template documents attached to cart content
|
||||||
$q = new WP_Query();
|
$q = new WP_Query();
|
||||||
$retrieved_items = $q->query(array(
|
$retrieved_items = $q->query(array(
|
||||||
'post_status' => 'publish',
|
'post_status' => 'publish',
|
||||||
'post_type' => 'wiaas_doc',
|
'post_type' => 'wiaas_doc',
|
||||||
'post__in' => array_keys($documents_ids),
|
'post__in' => array_keys($documents_ids),
|
||||||
|
'meta_key' => '_wiaas_doc_visible',
|
||||||
|
'meta_value' => 'yes', // visible to customer
|
||||||
'tax_query' => array(
|
'tax_query' => array(
|
||||||
array(
|
array(
|
||||||
'taxonomy' => 'wiaas_doc_type',
|
'taxonomy' => 'wiaas_doc_type',
|
||||||
'field' => 'slug',
|
'field' => 'slug',
|
||||||
'terms' => array_keys(self::$cart_doc_types),
|
'terms' => array_keys(self::$cart_doc_types), // templates only
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ class Wiaas_Shop_DB {
|
|||||||
|
|
||||||
$shops = array_map(function($result_row) {
|
$shops = array_map(function($result_row) {
|
||||||
return array(
|
return array(
|
||||||
'owner_id' => $result_row->shop_owner_id,
|
'owner_id' => absint($result_row->shop_owner_id),
|
||||||
'order_type' => $result_row->order_type
|
'order_type' => $result_row->order_type
|
||||||
);
|
);
|
||||||
}, $results);
|
}, $results);
|
||||||
|
|||||||
@@ -308,6 +308,7 @@ class Wiaas_Delivery_Process_Action {
|
|||||||
|
|
||||||
$documents[] = array(
|
$documents[] = array(
|
||||||
'name' => $info['basename'],
|
'name' => $info['basename'],
|
||||||
|
'extension' => $info['extension'],
|
||||||
'url' => $acceptance_documents_field->get_download_url( $file_path, true )
|
'url' => $acceptance_documents_field->get_download_url( $file_path, true )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -365,18 +366,25 @@ class Wiaas_Delivery_Process_Action {
|
|||||||
|
|
||||||
$document = array(
|
$document = array(
|
||||||
'name' => $info['basename'],
|
'name' => $info['basename'],
|
||||||
|
'extension' => $info['extension'],
|
||||||
'url' => $document_field->get_download_url( $file_path, true )
|
'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_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);
|
$discussion_items = json_decode($action_entry[$discussion_field->id], ARRAY_A);
|
||||||
|
|
||||||
$formated_comments = array();
|
$formatted_comments = array();
|
||||||
|
|
||||||
if (is_array($discussion_items)) {
|
if (is_array($discussion_items)) {
|
||||||
foreach ($discussion_items as $item) {
|
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'],
|
'action_id' => $action_entry['id'],
|
||||||
'document' => $document,
|
'document' => $document,
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
'comments' => $formated_comments
|
'comments' => $formatted_comments
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
updateMessages
|
updateMessages
|
||||||
} from '../notification/notificationActions';
|
} from '../notification/notificationActions';
|
||||||
import HtmlClient from '../../helpers/HtmlClient';
|
import HtmlClient from '../../helpers/HtmlClient';
|
||||||
|
import { fromWiaasCustomerAcceptance } from '../../helpers/ProcessHelper';
|
||||||
|
|
||||||
const htmlClient = new HtmlClient();
|
const htmlClient = new HtmlClient();
|
||||||
|
|
||||||
@@ -32,7 +33,11 @@ export const fetchCustomerAcceptance = (idOrder) => {
|
|||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
dispatch(recieveCustomerAcceptance(response.data));
|
dispatch(
|
||||||
|
recieveCustomerAcceptance(
|
||||||
|
fromWiaasCustomerAcceptance(response.data)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
API_SERVER
|
API_SERVER
|
||||||
} from '../../config';
|
} from '../../config';
|
||||||
|
import { fromWiaasCustomerQuestionnaire } from '../../helpers/ProcessHelper';
|
||||||
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
UPLOAD_CUSTOMER_QUESTIONNAIRE,
|
UPLOAD_CUSTOMER_QUESTIONNAIRE,
|
||||||
@@ -41,7 +43,8 @@ export const fetchCustomerQuestionnaires = (idOrder) => {
|
|||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (typeof response.data !== 'undefined') {
|
if (typeof response.data !== 'undefined') {
|
||||||
dispatch(receiveCustomerQuestionnaires(response.data));
|
const questionnairesData = response.data.map(cData => fromWiaasCustomerQuestionnaire(cData));
|
||||||
|
dispatch(receiveCustomerQuestionnaires(questionnairesData));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|||||||
@@ -70,10 +70,10 @@ class CartUploadDocument extends Component {
|
|||||||
<h1 className="drop-zone-icon">
|
<h1 className="drop-zone-icon">
|
||||||
<i className="fa fa-upload"></i>
|
<i className="fa fa-upload"></i>
|
||||||
</h1>
|
</h1>
|
||||||
<h6 className="drop-zone-text">{uploadedDocument.name}</h6>
|
<p className="drop-zone-text">
|
||||||
<span className="drop-zone-text">
|
Drag and drop or click to replace <strong>{uploadedDocument.name}.{uploadedDocument.extension}</strong>
|
||||||
Drag and drop or click to replace file
|
</p>
|
||||||
</span>
|
<p className="drop-zone-text">To upload multiple files, please pack the files to one zip-file and upload the zip-file</p>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
: (
|
: (
|
||||||
@@ -81,9 +81,10 @@ class CartUploadDocument extends Component {
|
|||||||
<h1 className="drop-zone-icon pending-upload">
|
<h1 className="drop-zone-icon pending-upload">
|
||||||
<i className="fa fa-upload"></i>
|
<i className="fa fa-upload"></i>
|
||||||
</h1>
|
</h1>
|
||||||
<span className="drop-zone-text">
|
<p className="drop-zone-text">
|
||||||
Drag and drop or click to upload file
|
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>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ class CoMarketCatalogSelect extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps){
|
componentWillReceiveProps(nextProps){
|
||||||
// if(nextProps.activeModule==='cart' && nextProps.shops && nextProps.cartItems && nextProps.cartItems.length > 0){
|
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 });
|
const cartShop = nextProps.shops.find( shop => { return shop.id === nextProps.cartItems[0].idCommercialLead });
|
||||||
// nextProps.dispatch(selectShop(cartShop));
|
nextProps.dispatch(selectShop(cartShop));
|
||||||
// }
|
}
|
||||||
|
|
||||||
if(nextProps.shops && nextProps.idCommercialLead && nextProps.activeModule === 'co-market'){
|
if(nextProps.shops && nextProps.idCommercialLead && nextProps.activeModule === 'co-market'){
|
||||||
const shop = nextProps.shops.find( shop => {return shop.id === nextProps.idCommercialLead });
|
const shop = nextProps.shops.find( shop => {return shop.id === nextProps.idCommercialLead });
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ class CustomerAcceptance extends Component {
|
|||||||
activeClassName="upload-file-accept"
|
activeClassName="upload-file-accept"
|
||||||
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(step.idOrder, acceptedFiles, rejectedFiles)}}>
|
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(step.idOrder, acceptedFiles, rejectedFiles)}}>
|
||||||
<h5 className="drop-zone-text">{orderTexts.labels.UPLOAD_ACCEPTANCE_LABEL}</h5>
|
<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>
|
</Dropzone>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xl="4" lg="7" md="8">
|
<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}>
|
customerAcceptance.documents.map((document, index) => <div key={'acceptance-documnet-' + index}>
|
||||||
<span className="document-link">
|
<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>
|
||||||
<span className="document-status">
|
<span className="document-status">
|
||||||
{document.validation} <div className={'status-icon ' + document.validation}></div>
|
{document.validation} <div className={'status-icon ' + document.validation}></div>
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ class ValidateQuestionnaire extends Component {
|
|||||||
customerQuestionnaires.map((customerQuestionnaryAction) =>
|
customerQuestionnaires.map((customerQuestionnaryAction) =>
|
||||||
<ValidateQuestionnaireItem
|
<ValidateQuestionnaireItem
|
||||||
action={customerQuestionnaryAction}
|
action={customerQuestionnaryAction}
|
||||||
key={'validate-questionnaire-' + customerQuestionnaryAction.action_id}
|
key={'validate-questionnaire-' + customerQuestionnaryAction.actionId}
|
||||||
orderPackage={orderPackages.find( orderPackage => orderPackage.orderItemId === customerQuestionnaryAction.item_id)}
|
orderPackage={orderPackages.find( orderPackage => orderPackage.orderItemId === customerQuestionnaryAction.orderItemId)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class ValidateQuestionnaireItem extends Component {
|
|||||||
uploadFile(action,acceptedFiles, rejectedFiles) {
|
uploadFile(action,acceptedFiles, rejectedFiles) {
|
||||||
if(acceptedFiles && acceptedFiles.length){
|
if(acceptedFiles && acceptedFiles.length){
|
||||||
const file = acceptedFiles[0];
|
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) {
|
// if(rejectedFiles && rejectedFiles.length) {
|
||||||
@@ -48,7 +48,7 @@ class ValidateQuestionnaireItem extends Component {
|
|||||||
<div>
|
<div>
|
||||||
|
|
||||||
<span className="document-link">
|
<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>
|
||||||
<br />
|
<br />
|
||||||
<span className="document-status">
|
<span className="document-status">
|
||||||
@@ -59,7 +59,8 @@ class ValidateQuestionnaireItem extends Component {
|
|||||||
(action.comments && action.comments.length > 0) &&
|
(action.comments && action.comments.length > 0) &&
|
||||||
<div>
|
<div>
|
||||||
{action.comments.map((comment, key) => <div key={'step-comment-' + document.idDocument + '-' + key} className="step-comment">
|
{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>)}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -71,6 +72,7 @@ class ValidateQuestionnaireItem extends Component {
|
|||||||
activeClassName="upload-file-accept"
|
activeClassName="upload-file-accept"
|
||||||
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(action, acceptedFiles, rejectedFiles)}}>
|
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(action, acceptedFiles, rejectedFiles)}}>
|
||||||
<h5 className="drop-zone-text">{orderTexts.labels.SELECT_OR_DROP}</h5>
|
<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>
|
</Dropzone>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
@@ -79,12 +81,21 @@ class ValidateQuestionnaireItem extends Component {
|
|||||||
<Row>
|
<Row>
|
||||||
<Col>
|
<Col>
|
||||||
<span className="document-link">
|
<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>
|
||||||
<br />
|
<br />
|
||||||
<span className="document-status">
|
<span className="document-status">
|
||||||
{action.status.replace(/-/g,' ')} <div className={'status-icon ' + action.status}></div>
|
{action.status.replace(/-/g,' ')} <div className={'status-icon ' + action.status}></div>
|
||||||
</span>
|
</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>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ $link-line-height: 1.5rem;
|
|||||||
.upload-file-drop-zone {
|
.upload-file-drop-zone {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: 3px dashed $borderColor;
|
border: 3px dashed $borderColor;
|
||||||
height: 10rem;
|
padding: 2rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
@@ -206,7 +206,6 @@ $link-line-height: 1.5rem;
|
|||||||
|
|
||||||
.drop-zone-text {
|
.drop-zone-text {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 4rem 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.document-link {
|
.document-link {
|
||||||
@@ -357,7 +356,6 @@ $link-line-height: 1.5rem;
|
|||||||
|
|
||||||
.drop-zone-text {
|
.drop-zone-text {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 4rem 0;
|
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ const iconTypes = {
|
|||||||
xls: 'file-excel-o',
|
xls: 'file-excel-o',
|
||||||
xlsx: 'file-excel-o',
|
xlsx: 'file-excel-o',
|
||||||
ppt: 'file-powerpoint-o',
|
ppt: 'file-powerpoint-o',
|
||||||
pptx: 'file-powerpoint-o'
|
pptx: 'file-powerpoint-o',
|
||||||
|
zip: 'file-zip-o'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getDocumentIcon = extension => {
|
export const getDocumentIcon = extension => {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
import {getDocumentIcon} from "./DocumentHelper";
|
||||||
|
|
||||||
export const fromWiaasProcessStep = (step) => {
|
export const fromWiaasProcessStep = (step) => {
|
||||||
return {
|
return {
|
||||||
@@ -14,3 +15,30 @@ export const fromWiaasProcessStep = (step) => {
|
|||||||
status: step.status,
|
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
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user