Technical documentation - Download documents for a list of parts in order page

Overview

This artile explain how is working and how to configure the downloading of documents related to parts in order page.


Version 5.0

Function is available in version 5.0 and later.


Configuration

The lines to add in profile.config

<DownloadDocumentEnabled>true</DownloadDocumentEnabled>
<DownloadDocumentBarEnabled>true</DownloadDocumentBarEnabled>
<DocumentNodeIdentifier>_Documents</DocumentNodeIdentifier>

First enable "Download all documents" choice in Download dropdown button from summary tab. Second line enable the document selector in the same view. Third is a regex to identify a node located in the root of the catalogue. The regex will match the persistent identity of the nodes in the root of the catalogue and include all documents in and under that node.


In clientName.css, the icon colors can be defined. It will be black if checked, grey otherwise. This is what we put in our dometic.css.

/*Icon color if document is checked, dometic green here*/
.icon-checked{color: #00b140!important;}

/*Icon color if document unchecked, grey*/
.document-icon{color: #bdc3c7;}

How It works

View :

The document bar is in the partial view _OrderCartDownloadDocuments.cshtml in WebViewer/Views/Orders. It contains :

  • Two buttons : "Download All documents" and "Download selected documents"
  • A document container. For each document there are : his name, a checkbox and the icon corresponding to the type of document.

Script :

In assert.ordercart.js :

  • a function handling click on document icon : check/uncheck the checkbox and change icon color
  • a function handling click on document checkbox : change icon color
  • a function handling click on "Download Selected Documents" : get checked documents, post them to the controller (PostSelectedDocumentName method) and return their zip (DownloadDocumentZip method)

Model :

ViewModel used in the view : DownloadDocumentViewModel 

Controller :

There are 3 methods used in OrderController :

  • ActionResult DownloadAllDocument() : return a zip of all documents linked to parts
  • ActionResult DownloadSelectedDocumentList(IList<DocumentViewModel> referredDocuments) : return a zip of documents passed in parameters
  • ActionResult PostSelectedDocumentName(string[] docName) : post a list of document name, create a TempData with the zip inside
  • ActionResult DownloadDocumentZip(string fileGuid, string fileName) : Return the zip called filename from the TempData fileGuid