Loading plugins/ead_basket/ead_basket.css 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * Le porte-documents */ #porte-document-contenu { padding-left: 0; } .porte-document-doc-group { list-style-type: none; border: var(--ead-box-border); border-radius: 5px; margin-bottom: 0.5em; padding: 0.5em; width: 80vw; } #porte-document-contenu li { list-style-type: none; border: var(--ead-box-border); border-radius: 5px; margin-bottom: 0.5em; padding: 0.5em; } #porte-document-contenu li:hover { cursor: ns-resize; } #porte-document-contenu li button { margin-right: 1em; } section.porte-documents { margin-top: 5.1em; padding: 1em; margin-bottom: 3em; } .sortable-ghost { opacity: 1; background: var(--ead-selected-bg-color); } .sortable-drag { opacity: 0; } No newline at end of file plugins/ead_basket/ead_basket.xqm +38 −21 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ import module namespace max.config = 'pddn/max/config' at '../../rxq/config.xqm' import module namespace max.util = 'pddn/max/util' at '../../rxq/util.xqm'; import module namespace rest = "http://exquery.org/ns/restxq"; import module namespace max.html = 'pddn/max/html' at '../../rxq/html.xqm'; import module namespace max.api = 'pddn/max/max_api' at '../../rxq/max_api.xqm'; declare variable $max.plugin.ead_basket:PLUGIN_ID := "ead_basket"; Loading Loading @@ -31,18 +32,22 @@ declare %rest:query-param("items", "{$items}") %rest:path("/{$projectId}/ead/basket.pdf") function max.plugin.ead_basket:basketpdf($projectId, $items){ let $dbPath := max.config:getProjectDBPath($projectId) let $items_list := fn:tokenize($items, ",") let $routeDoc := fn:substring-before($items_list[1], '|') let $eadHeader := doc($dbPath || '/' || $routeDoc)//*:eadheader/node() let $frontmatter := doc($dbPath || '/' || $routeDoc)//*:frontmatter/node() let $content:= <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="UTF-8"/> <title>Contenu du porte-documents</title> </head> <body> {max.plugin.ead_basket:basketItemsForPDF($projectId, $items)} </body> </html> let $pdf := max.util:xml2pdf($content, max.util:maxHome()||"ui/xsl/core/xhtml2fo.xsl",$projectId,$projectId) <ead xmlns="urn:isbn:1-931666-22-9"> <eadheader>{$eadHeader}</eadheader> <frontmatter>{$frontmatter}</frontmatter> <archdesc>{ for $item in $items_list let $nodeId := fn:substring-after($item, "|") return max.api:getXMLByID($dbPath, $nodeId) }</archdesc> </ead> let $pdf := max.util:xml2pdf($content, max.util:getProjectFoXsl($projectId), $projectId,$projectId) return (<rest:response> Loading Loading @@ -84,15 +89,13 @@ function max.plugin.ead_basket:basket($projectId){ <h2>Porte-documents</h2> <p> Votre porte-documents regroupe tous les documents que vous avez mis de côté pendant votre visite. Vous pouvez retirer des documents, les ordonner (glissé/déposé), puis faire une sortie PDF. Vous pouvez retirer des documents, les consulter ou faire une sortie PDF. </p> <p> <button class="btnMakePDF">Faire une sortie PDF</button> </p> <ul id="porte-document-contenu"> </ul> <div id="porte-document-contenu"> </div> <p> <button class="btnClearBasket">Vider le porte-documents</button> <!--<button id="btnDlAllPDF">Télécharger tous les PDF</button>--> </p> </section> ) Loading @@ -117,6 +120,20 @@ declare %output:method("html") %rest:POST("{$itemsList}") function max.plugin.ead_basket:basketData($projectId, $itemsList){ for $item in $itemsList/json/_ for $items in $itemsList/json/_ group by $docName := fn:substring-before($items, "|") let $dbPath := max.config:getProjectDBPath($projectId) let $title := doc(concat($dbPath, '/', $docName))/*:ead/*:eadheader/*:filedesc/*:titlestmt/*:titleproper//text() let $result := <div class="porte-document-doc-group"> <h3>{$title}</h3> { for $item in $items return max.plugin.ead_basket:itemPorteDocuments($projectId, $item) } <p> <button class="btnMakePDF">Faire une sortie PDF</button> </p> </div> return $result }; ui/css/ead.css +0 −40 Original line number Diff line number Diff line Loading @@ -313,46 +313,6 @@ nav.article_actions label>input { vertical-align: middle; } /* * Le porte-documents */ #porte-document-contenu { padding-left: 0; } #porte-document-contenu li { list-style-type: none; border: var(--ead-box-border); border-radius: 5px; margin-bottom: 0.5em; padding: 0.5em; } #porte-document-contenu li:hover { cursor: ns-resize; } #porte-document-contenu li button { margin-right: 1em; } section.porte-documents { margin-top: 5.1em; padding: 1em; margin-bottom: 3em; } .sortable-ghost { opacity: 1; background: var(--ead-selected-bg-color); } .sortable-drag { opacity: 0; } /* pour le bouton du porte-document */ section.browse nav.article_actions { Loading ui/js/ead.js +35 −1 Original line number Diff line number Diff line Loading @@ -147,9 +147,43 @@ async function initPorteDocumentsPage(project_id) { for (var i = 0, len = pdf_buttons.length; i < len; i++) { pdf_buttons[i].addEventListener("click", function () { console.log(basket.items().concat(",")); window.open(baseURI + project_id + "/ead/basket.pdf?items=" + (basket.items().join()), '_blank'); let docItems = [] this.parentNode.parentNode.querySelectorAll("li").forEach(notice => { let noticeId = notice.dataset.node_id docItems.push(noticeId) }); window.open(baseURI + project_id + "/ead/basket.pdf?items=" + (docItems.join()), '_blank'); }); } // OVP: à terminer let dlAllButton = document.getElementById("btnDlAllPDF") dlAllButton.addEventListener("click", function () { let PDFList = [] document.querySelectorAll(".porte-document-doc-group").forEach(PDFGroup => { let PDF = {} let docItems = [] let docId = PDFGroup.querySelector("li").dataset.node_id.split('|')[0] PDFGroup.querySelectorAll("li").forEach(notice => { let noticeId = notice.dataset.node_id.split('|')[1] docItems.push(noticeId) }) Object.defineProperty(PDF, 'doc', { value: docId, enumerable: true }); Object.defineProperty(PDF, 'itemList', { value: docItems, enumerable: true }); let result = JSON.stringify(PDF) console.log(result) }) }); } } Loading Loading
plugins/ead_basket/ead_basket.css 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * Le porte-documents */ #porte-document-contenu { padding-left: 0; } .porte-document-doc-group { list-style-type: none; border: var(--ead-box-border); border-radius: 5px; margin-bottom: 0.5em; padding: 0.5em; width: 80vw; } #porte-document-contenu li { list-style-type: none; border: var(--ead-box-border); border-radius: 5px; margin-bottom: 0.5em; padding: 0.5em; } #porte-document-contenu li:hover { cursor: ns-resize; } #porte-document-contenu li button { margin-right: 1em; } section.porte-documents { margin-top: 5.1em; padding: 1em; margin-bottom: 3em; } .sortable-ghost { opacity: 1; background: var(--ead-selected-bg-color); } .sortable-drag { opacity: 0; } No newline at end of file
plugins/ead_basket/ead_basket.xqm +38 −21 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ import module namespace max.config = 'pddn/max/config' at '../../rxq/config.xqm' import module namespace max.util = 'pddn/max/util' at '../../rxq/util.xqm'; import module namespace rest = "http://exquery.org/ns/restxq"; import module namespace max.html = 'pddn/max/html' at '../../rxq/html.xqm'; import module namespace max.api = 'pddn/max/max_api' at '../../rxq/max_api.xqm'; declare variable $max.plugin.ead_basket:PLUGIN_ID := "ead_basket"; Loading Loading @@ -31,18 +32,22 @@ declare %rest:query-param("items", "{$items}") %rest:path("/{$projectId}/ead/basket.pdf") function max.plugin.ead_basket:basketpdf($projectId, $items){ let $dbPath := max.config:getProjectDBPath($projectId) let $items_list := fn:tokenize($items, ",") let $routeDoc := fn:substring-before($items_list[1], '|') let $eadHeader := doc($dbPath || '/' || $routeDoc)//*:eadheader/node() let $frontmatter := doc($dbPath || '/' || $routeDoc)//*:frontmatter/node() let $content:= <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="UTF-8"/> <title>Contenu du porte-documents</title> </head> <body> {max.plugin.ead_basket:basketItemsForPDF($projectId, $items)} </body> </html> let $pdf := max.util:xml2pdf($content, max.util:maxHome()||"ui/xsl/core/xhtml2fo.xsl",$projectId,$projectId) <ead xmlns="urn:isbn:1-931666-22-9"> <eadheader>{$eadHeader}</eadheader> <frontmatter>{$frontmatter}</frontmatter> <archdesc>{ for $item in $items_list let $nodeId := fn:substring-after($item, "|") return max.api:getXMLByID($dbPath, $nodeId) }</archdesc> </ead> let $pdf := max.util:xml2pdf($content, max.util:getProjectFoXsl($projectId), $projectId,$projectId) return (<rest:response> Loading Loading @@ -84,15 +89,13 @@ function max.plugin.ead_basket:basket($projectId){ <h2>Porte-documents</h2> <p> Votre porte-documents regroupe tous les documents que vous avez mis de côté pendant votre visite. Vous pouvez retirer des documents, les ordonner (glissé/déposé), puis faire une sortie PDF. Vous pouvez retirer des documents, les consulter ou faire une sortie PDF. </p> <p> <button class="btnMakePDF">Faire une sortie PDF</button> </p> <ul id="porte-document-contenu"> </ul> <div id="porte-document-contenu"> </div> <p> <button class="btnClearBasket">Vider le porte-documents</button> <!--<button id="btnDlAllPDF">Télécharger tous les PDF</button>--> </p> </section> ) Loading @@ -117,6 +120,20 @@ declare %output:method("html") %rest:POST("{$itemsList}") function max.plugin.ead_basket:basketData($projectId, $itemsList){ for $item in $itemsList/json/_ for $items in $itemsList/json/_ group by $docName := fn:substring-before($items, "|") let $dbPath := max.config:getProjectDBPath($projectId) let $title := doc(concat($dbPath, '/', $docName))/*:ead/*:eadheader/*:filedesc/*:titlestmt/*:titleproper//text() let $result := <div class="porte-document-doc-group"> <h3>{$title}</h3> { for $item in $items return max.plugin.ead_basket:itemPorteDocuments($projectId, $item) } <p> <button class="btnMakePDF">Faire une sortie PDF</button> </p> </div> return $result };
ui/css/ead.css +0 −40 Original line number Diff line number Diff line Loading @@ -313,46 +313,6 @@ nav.article_actions label>input { vertical-align: middle; } /* * Le porte-documents */ #porte-document-contenu { padding-left: 0; } #porte-document-contenu li { list-style-type: none; border: var(--ead-box-border); border-radius: 5px; margin-bottom: 0.5em; padding: 0.5em; } #porte-document-contenu li:hover { cursor: ns-resize; } #porte-document-contenu li button { margin-right: 1em; } section.porte-documents { margin-top: 5.1em; padding: 1em; margin-bottom: 3em; } .sortable-ghost { opacity: 1; background: var(--ead-selected-bg-color); } .sortable-drag { opacity: 0; } /* pour le bouton du porte-document */ section.browse nav.article_actions { Loading
ui/js/ead.js +35 −1 Original line number Diff line number Diff line Loading @@ -147,9 +147,43 @@ async function initPorteDocumentsPage(project_id) { for (var i = 0, len = pdf_buttons.length; i < len; i++) { pdf_buttons[i].addEventListener("click", function () { console.log(basket.items().concat(",")); window.open(baseURI + project_id + "/ead/basket.pdf?items=" + (basket.items().join()), '_blank'); let docItems = [] this.parentNode.parentNode.querySelectorAll("li").forEach(notice => { let noticeId = notice.dataset.node_id docItems.push(noticeId) }); window.open(baseURI + project_id + "/ead/basket.pdf?items=" + (docItems.join()), '_blank'); }); } // OVP: à terminer let dlAllButton = document.getElementById("btnDlAllPDF") dlAllButton.addEventListener("click", function () { let PDFList = [] document.querySelectorAll(".porte-document-doc-group").forEach(PDFGroup => { let PDF = {} let docItems = [] let docId = PDFGroup.querySelector("li").dataset.node_id.split('|')[0] PDFGroup.querySelectorAll("li").forEach(notice => { let noticeId = notice.dataset.node_id.split('|')[1] docItems.push(noticeId) }) Object.defineProperty(PDF, 'doc', { value: docId, enumerable: true }); Object.defineProperty(PDF, 'itemList', { value: docItems, enumerable: true }); let result = JSON.stringify(PDF) console.log(result) }) }); } } Loading