From 0ba27b2f1ddf61cc7628be864e239324544d648e Mon Sep 17 00:00:00 2001
From: Almira Krdzic
Date: Wed, 7 Nov 2018 03:05:54 +0100
Subject: [PATCH] documents fix
---
.../wiaas/includes/class-wiaas-cart.php | 6 +++-
.../wiaas/includes/db/class-wiaas-shop-db.php | 2 +-
.../class-wiaas-delivery-process-action.php | 14 ++++++++--
.../orders/customerAcceptanceActions.js | 7 ++++-
.../orders/customerQuestionnairesActions.js | 5 +++-
.../cart/components/CartUploadDocument.jsx | 13 +++++----
.../components/CoMarketCatalogSelect.jsx | 8 +++---
.../components/process/CustomerAcceptance.jsx | 3 +-
.../process/ValidateQuestionnaire.jsx | 4 +--
.../process/ValidateQuestionnaireItem.jsx | 19 ++++++++++---
.../orders/style/ProcessContainer.scss | 4 +--
frontend/src/helpers/DocumentHelper.js | 3 +-
frontend/src/helpers/ProcessHelper.js | 28 +++++++++++++++++++
13 files changed, 88 insertions(+), 28 deletions(-)
diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-cart.php b/backend/app/plugins/wiaas/includes/class-wiaas-cart.php
index df8c358..d6d2838 100644
--- a/backend/app/plugins/wiaas/includes/class-wiaas-cart.php
+++ b/backend/app/plugins/wiaas/includes/class-wiaas-cart.php
@@ -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
)
)
));
diff --git a/backend/app/plugins/wiaas/includes/db/class-wiaas-shop-db.php b/backend/app/plugins/wiaas/includes/db/class-wiaas-shop-db.php
index 83bbd75..5885d68 100644
--- a/backend/app/plugins/wiaas/includes/db/class-wiaas-shop-db.php
+++ b/backend/app/plugins/wiaas/includes/db/class-wiaas-shop-db.php
@@ -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);
diff --git a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-action.php b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-action.php
index 2917221..a977dfc 100644
--- a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-action.php
+++ b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-action.php
@@ -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
);
}
diff --git a/frontend/src/actions/orders/customerAcceptanceActions.js b/frontend/src/actions/orders/customerAcceptanceActions.js
index 7fec4e1..e3a4bd2 100644
--- a/frontend/src/actions/orders/customerAcceptanceActions.js
+++ b/frontend/src/actions/orders/customerAcceptanceActions.js
@@ -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 => {
diff --git a/frontend/src/actions/orders/customerQuestionnairesActions.js b/frontend/src/actions/orders/customerQuestionnairesActions.js
index 5a86e86..6631ddd 100644
--- a/frontend/src/actions/orders/customerQuestionnairesActions.js
+++ b/frontend/src/actions/orders/customerQuestionnairesActions.js
@@ -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 => {
diff --git a/frontend/src/containers/cart/components/CartUploadDocument.jsx b/frontend/src/containers/cart/components/CartUploadDocument.jsx
index 7d87618..67b71e7 100644
--- a/frontend/src/containers/cart/components/CartUploadDocument.jsx
+++ b/frontend/src/containers/cart/components/CartUploadDocument.jsx
@@ -70,10 +70,10 @@ class CartUploadDocument extends Component {
- {uploadedDocument.name}
-
- Drag and drop or click to replace file
-
+
+ Drag and drop or click to replace {uploadedDocument.name}.{uploadedDocument.extension}
+
+ To upload multiple files, please pack the files to one zip-file and upload the zip-file
)
: (
@@ -81,9 +81,10 @@ class CartUploadDocument extends Component {
-
+
Drag and drop or click to upload file
-
+
+ To upload multiple files, please pack the files to one zip-file and upload the zip-file
)
}
diff --git a/frontend/src/containers/coMarket/components/CoMarketCatalogSelect.jsx b/frontend/src/containers/coMarket/components/CoMarketCatalogSelect.jsx
index 4f519cf..19c63fc 100644
--- a/frontend/src/containers/coMarket/components/CoMarketCatalogSelect.jsx
+++ b/frontend/src/containers/coMarket/components/CoMarketCatalogSelect.jsx
@@ -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 });
diff --git a/frontend/src/containers/orders/components/process/CustomerAcceptance.jsx b/frontend/src/containers/orders/components/process/CustomerAcceptance.jsx
index 0d2c570..98defb4 100644
--- a/frontend/src/containers/orders/components/process/CustomerAcceptance.jsx
+++ b/frontend/src/containers/orders/components/process/CustomerAcceptance.jsx
@@ -139,6 +139,7 @@ class CustomerAcceptance extends Component {
activeClassName="upload-file-accept"
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(step.idOrder, acceptedFiles, rejectedFiles)}}>
{orderTexts.labels.UPLOAD_ACCEPTANCE_LABEL}
+ To upload multiple files, please pack the files to one zip-file and upload the zip-file
@@ -148,7 +149,7 @@ class CustomerAcceptance extends Component {
{
customerAcceptance.documents.map((document, index) =>
- {document.name}
+ {document.name}
{document.validation}
diff --git a/frontend/src/containers/orders/components/process/ValidateQuestionnaire.jsx b/frontend/src/containers/orders/components/process/ValidateQuestionnaire.jsx
index 63324b2..0da558e 100644
--- a/frontend/src/containers/orders/components/process/ValidateQuestionnaire.jsx
+++ b/frontend/src/containers/orders/components/process/ValidateQuestionnaire.jsx
@@ -27,8 +27,8 @@ class ValidateQuestionnaire extends Component {
customerQuestionnaires.map((customerQuestionnaryAction) =>
orderPackage.orderItemId === customerQuestionnaryAction.item_id)}
+ key={'validate-questionnaire-' + customerQuestionnaryAction.actionId}
+ orderPackage={orderPackages.find( orderPackage => orderPackage.orderItemId === customerQuestionnaryAction.orderItemId)}
/>
)
}
diff --git a/frontend/src/containers/orders/components/process/ValidateQuestionnaireItem.jsx b/frontend/src/containers/orders/components/process/ValidateQuestionnaireItem.jsx
index 1b2dec7..ca51461 100644
--- a/frontend/src/containers/orders/components/process/ValidateQuestionnaireItem.jsx
+++ b/frontend/src/containers/orders/components/process/ValidateQuestionnaireItem.jsx
@@ -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 {
- {document.name}
+ {document.name}
@@ -59,7 +59,8 @@ class ValidateQuestionnaireItem extends Component {
(action.comments && action.comments.length > 0) &&
{action.comments.map((comment, key) =>
-
{comment}
+
{comment.header}
+
{comment.value}
)}
}
@@ -71,6 +72,7 @@ class ValidateQuestionnaireItem extends Component {
activeClassName="upload-file-accept"
onDrop={(acceptedFiles, rejectedFiles)=>{this.uploadFile(action, acceptedFiles, rejectedFiles)}}>
{orderTexts.labels.SELECT_OR_DROP}
+ To upload multiple files, please pack the files to one zip-file and upload the zip-file
@@ -79,12 +81,21 @@ class ValidateQuestionnaireItem extends Component {
- {document.name}
+ {document.name}
{action.status.replace(/-/g,' ')}
+ {
+ (action.comments && action.comments.length > 0) &&
+
+ {action.comments.map((comment, key) =>
+
{comment.header}
+
{comment.value}
+
)}
+
+ }
diff --git a/frontend/src/containers/orders/style/ProcessContainer.scss b/frontend/src/containers/orders/style/ProcessContainer.scss
index 3e4d82e..55bfad9 100644
--- a/frontend/src/containers/orders/style/ProcessContainer.scss
+++ b/frontend/src/containers/orders/style/ProcessContainer.scss
@@ -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;
}
diff --git a/frontend/src/helpers/DocumentHelper.js b/frontend/src/helpers/DocumentHelper.js
index 3ab1f2c..8f38f5d 100644
--- a/frontend/src/helpers/DocumentHelper.js
+++ b/frontend/src/helpers/DocumentHelper.js
@@ -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 => {
diff --git a/frontend/src/helpers/ProcessHelper.js b/frontend/src/helpers/ProcessHelper.js
index 4a068bb..98a750b 100644
--- a/frontend/src/helpers/ProcessHelper.js
+++ b/frontend/src/helpers/ProcessHelper.js
@@ -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
+ };
};
\ No newline at end of file