@dbp-topics/dispatch
Version:
[GitHub Repository](https://github.com/digital-blueprint/dispatch-frontend) | [npmjs package](https://www.npmjs.com/package/@dbp-topics/dispatch) | [Unpkg CDN](https://unpkg.com/browse/@dbp-topics/dispatch/) | [Dispatch Bundle](https://github.com/digital-
392 lines (359 loc) • 29.9 kB
JavaScript
let t,e,i,s,d,n,r,a,o,c,l,u,h,b,p,m,g,$,v,y,f,I=t=>t;function w(){return w=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},w.apply(this,arguments)}
/*!
* License: LGPL-2.1-or-later
* Dependencies:
*
* @webcomponents/scoped-custom-element-registry: BSD-3-Clause
* @dbp-toolkit/app-shell: LGPL-2.1-or-later
* @dbp-toolkit/language-select: LGPL-2.1-or-later
* @dbp-toolkit/common: LGPL-2.1-or-later
* @dbp-toolkit/auth: LGPL-2.1-or-later
* event-target-shim: MIT
* @dbp-toolkit/notification: LGPL-2.1-or-later
* @dbp-toolkit/theme-switcher: LGPL-2.1-or-later
* path-to-regexp: MIT
* universal-router: MIT
* generateUrls: MIT
* @dbp-toolkit/matomo: LGPL-2.1-or-later
* @tugraz/web-components: LGPL-2.1-or-later
* @babel/runtime: MIT
* i18next: MIT
* @lit/reactive-element: BSD-3-Clause
* lit-html: BSD-3-Clause
* lit-element: BSD-3-Clause
* @open-wc/dedupe-mixin: MIT
* @open-wc/scoped-elements: MIT
* @popperjs/core: MIT
* tippy.js: MIT
* @dbp-toolkit/tooltip: LGPL-2.1-or-later
* @dbp-toolkit/person-select: LGPL-2.1-or-later
* @dbp-toolkit/file-handling: LGPL-2.1-or-later
* file-saver: MIT
* webdav: MIT
* tabulator-tables: MIT
* jose: MIT
* jquery: MIT
* select2: MIT
* @dbp-toolkit/resource-select: LGPL-2.1-or-later
*/import{D as q,c as S,A as x,I as j,P as R,M as C,g as k,a as L,b as _}from"./shared/styles.c9ce8bd4.es.js";import{S as A,I as D,M as N,L as F,q as B,s as E,i as V,g as P,b as z,l as M,d as O,r as U,t as W,f as G,v as T,y as H,o as J,z as K,k as Q}from"./shared/notification.431b7aff.es.js";import{R as X}from"./shared/resource-select.22699b80.es.js";import{FileSource as Y}from"./shared/file-source.7dcfb7c2.es.js";import"./shared/file-sink.a4f3cd03.es.js";import"./shared/jsonld.f5d0f523.es.js";import"./shared/_commonjsHelpers.e3705ba7.es.js";import"./shared/dbp-file-handling-lit-element.c8c0eb51.es.js";var Z={element:"dbp-create-request",module_src:"dbp-create-request.js",routing_name:"create-request",name:{de:"Versandauftrag erstellen",en:"Create dispatch order"},short_name:{de:"Versandauftrag erstellen",en:"Create dispatch order"},description:{de:"Erlaubt das Erstellen neuer Versandaufträge.",en:"Allows the creation of new dispatch orders."},subscribe:"lang,entry-point-url,auth,html-overrides,nextcloud-web-app-password-url,nextcloud-webdav-url,nextcloud-name,nextcloud-file-url,file-handling-enabled-targets"};class tt extends(A(q)){constructor(){super(),this._i18n=S(),this.lang=this._i18n.language,this.activity=new x(Z),this.entryPointUrl="",this.currentItem={},this.currentItem.files=[],this.currentItem.recipients=[],this.currentRecipient={},this.currentItem.senderGivenName="",this.currentItem.senderFamilyName="",this.currentItem.senderAddressCountry="",this.currentItem.senderPostalCode="",this.currentItem.senderAddressLocality="",this.currentItem.senderStreetAddress="",this.currentItem.senderBuildingNumber="",this.subject="",this.groupId="",this.mayRead=!1,this.mayWrite=!1,this.organizationLoaded=!1,this.showDetailsView=!1,this.hasEmptyFields=!1,this.hasSender=!1,this.hasRecipients=!1,this.requestCreated=!1,this.fileHandlingEnabledTargets="local",this.nextcloudWebAppPasswordURL="",this.nextcloudWebDavURL="",this.nextcloudName="",this.nextcloudFileURL="",this.nextcloudAuthInfo=""}static get scopedElements(){return{"dbp-icon":D,"dbp-mini-spinner":N,"dbp-loading-button":F,"dbp-icon-button":B,"dbp-inline-notification":j,"dbp-file-source":Y,"dbp-person-select":R,"dbp-resource-select":X}}static get properties(){return w({},super.properties,{lang:{type:String},entryPointUrl:{type:String,attribute:"entry-point-url"},currentItem:{type:Object,attribute:!1},currentRecipient:{type:Object,attribute:!1},subject:{type:String,attribute:!1},groupId:{type:String,attribute:!1},emptyFieldsGiven:{type:Boolean,attribute:!1},showDetailsView:{type:Boolean,attribute:!1},hasSender:{type:Boolean,attribute:!1},hasRecipients:{type:Boolean,attribute:!1},requestCreated:{type:Boolean,attribute:!1},organization:{type:String,attribute:!1},organizationId:{type:String,attribute:!1},mayWrite:{type:Boolean,attribute:!1},mayRead:{type:Boolean,attribute:!1},organizationLoaded:{type:Boolean,attribute:!1},fileHandlingEnabledTargets:{type:String,attribute:"file-handling-enabled-targets"},nextcloudWebAppPasswordURL:{type:String,attribute:"nextcloud-web-app-password-url"},nextcloudWebDavURL:{type:String,attribute:"nextcloud-webdav-url"},nextcloudName:{type:String,attribute:"nextcloud-name"},nextcloudFileURL:{type:String,attribute:"nextcloud-file-url"},nextcloudAuthInfo:{type:String,attribute:"nextcloud-auth-info"}})}update(t){t.forEach(((t,e)=>{if("lang"===e)this._i18n.changeLanguage(this.lang)})),super.update(t)}async processCreateDispatchRequest(){const t=this._i18n;try{let e=await this.sendCreateDispatchRequest(),i=await e.json();void 0!==i&&201===e.status?(E({summary:t.t("create-request.successfully-requested-title"),body:t.t("create-request.successfully-requested-text"),type:"success",timeout:5}),this.currentItem=i,this.requestCreated=!0):403===e.status?E({summary:t.t("create-request.error-requested-title"),body:t.t("error-not-permitted"),type:"danger",timeout:5}):E({summary:t.t("create-request.error-requested-title"),body:t.t("create-request.error-requested-text"),type:"danger",timeout:5})}finally{this._("#create-btn").stop()}}_onCreateRequestButtonClicked(t){this._("#create-btn").start(),C.show(this._("#add-subject-modal"),{disableScroll:!0,onClose:t=>{this.loading=!1}})}getCurrentTime(){let t=new Date;return("0"+(t.getHours()+1)).slice(-2)+":"+("0"+t.getMinutes()).slice(-2)}saveRequest(){this.clearAll(),this.requestCreated=!1}static get styles(){return V(t||(t=I`
${0}
${0}
${0}
${0}
${0}
${0}
${0}
/*${0}*/
${0}
${0}
h2:first-child {
margin-top: 0;
}
h2 {
margin-bottom: 10px;
}
.details.header {
display: block;
grid-template-columns: none;
padding-bottom: 1.5em;
border-bottom: 1px solid var(--dbp-override-muted);
text-align: start;
}
.choose-and-create-btns {
display: flex;
gap: 5px;
}
.choose-and-create-btns dbp-resource-select {
width: 30em;
margin-top: 1px;
}
`),P(),z(!1),M(),O(),U(),W(),G(),T(),k(),L())}render(){const t=this._i18n;return H(e||(e=I`
<div class="control ${0}">
<span class="loading">
<dbp-mini-spinner text=${0}></dbp-mini-spinner>
</span>
</div>
<dbp-inline-notification class="${0}"
type="warning"
body="${0}">
</dbp-inline-notification>
<div class="${0}">
<h2>${0}</h2>
<p class="subheadline">
<slot name="description">
${0}
</slot>
</p>
<slot name="activity-description">
<p>${0}</p>
</slot>
<dbp-inline-notification class="${0}"
type="warning"
body="${0}">
</dbp-inline-notification>
<div >
${0}
<div class="choose-and-create-btns">
<dbp-resource-select
id="create-resource-select"
subscribe="lang,entry-point-url,auth"
lang="${0}"
resource-path="dispatch/groups?lang=${0}"
value="${0}"
=${0}
></dbp-resource-select>
<dbp-loading-button id="create-btn" type="is-primary"
value="${0}"
="${0}"
title="${0}"
?disabled="${0}"
class="${0}"
></dbp-loading-button>
</div>
</div>
<div class="no-access-notification">
<dbp-inline-notification class="${0}"
type="danger"
body="${0}">
</dbp-inline-notification>
</div>
<div class="back-container">
<span class="back-navigation ${0}">
<a href="#" title="${0}"
="${0}"
>
<dbp-icon name="chevron-left"></dbp-icon>
${0}
</a>
</span>
</div>
<h3 class="${0}">
${0}:
</h3>
<div class="${0}">
${0}
${0}
</div>
</div>
${0}
${0}
${0}
${0}
${0}
${0}
<div class="modal micromodal-slide" id="add-subject-modal" aria-hidden="true">
<div class="modal-overlay" tabindex="-2" data-micromodal-close>
<div
class="modal-container"
id="add-subject-modal-box"
role="dialog"
aria-modal="true"
aria-labelledby="add-subject-modal-title">
<header class="modal-header">
<h3 id="add-subject-modal-title">
${0}
</h3>
<button
title="${0}"
class="modal-close"
aria-label="Close modal"
="${0}">
<dbp-icon
title="${0}"
name="close"
class="close-icon"></dbp-icon>
</button>
</header>
<main class="modal-content" id="add-subject-modal-content">
<div class="modal-content-item">
<div>
<input
type="text"
class="input"
name="tf-add-subject-fn-dialog"
id="tf-add-subject-fn-dialog"
value="${0}"
="${0}"
/>
</div>
</div>
<div class="modal-content-item">
<div>
${0}
</div>
</div>
</main>
<footer class="modal-footer">
<div class="modal-footer-btn">
<button
class="button"
data-micromodal-close
aria-label="Close this dialog window"
="${0}">
${0}
</button>
<button
class="button select-button is-primary"
id="add-subject-confirm-btn"
="${0}">
${0}
</button>
</div>
</footer>
</div>
</div>
</div>
`),J({hidden:this.isLoggedIn()||!this.isLoading()}),t.t("check-out.loading-message"),J({hidden:this.isLoggedIn()||this.isLoading()}),t.t("error-login-message"),J({hidden:!this.isLoggedIn()||this.isLoading()}),this.activity.getName(this.lang),this.activity.getDescription(this.lang),t.t("create-request.description-text"),J({hidden:!this.hasEmptyFields}),t.t("create-request.empty-fields-given"),t.t("show-requests.organization-select-description"),this.lang,this.lang,this.groupValue,(t=>{this.processSelectedSender(t)}),t.t("create-request.create-request-button-text"),(t=>{this._onCreateRequestButtonClicked(t)}),t.t("create-request.create-request-button-text"),!this.mayWrite,J({hidden:this.showDetailsView}),J({hidden:!this.isLoggedIn()||this.isLoading()||this.mayWrite||this.requestCreated||!this.organizationLoaded}),this.mayRead?t.t("create-request.error-no-writes"):t.t("error-no-read"),J({hidden:!this.isLoggedIn()||this.isLoading()||!this.showDetailsView}),t.t("create-request.back-to-create"),(t=>{this.saveRequest(t,this.currentItem)}),t.t("create-request.back-to-create"),J({hidden:!this.isLoggedIn()||this.isLoading()||!this.showDetailsView}),t.t("create-request.create-dispatch-order"),J({hidden:!this.isLoggedIn()||this.isLoading()||!this.showDetailsView}),this.currentItem&&!this.currentItem.dateSubmitted?H(i||(i=I`
<div class="request-buttons">
<div class="edit-buttons">
<dbp-loading-button id="delete-btn"
?disabled="${0}"
value="${0}"
="${0}"
title="${0}"
>
${0}
</dbp-loading-button>
</div>
<div class="submit-button">
<dbp-loading-button type="is-primary"
id="submit-btn"
?disabled="${0}"
value="${0}"
="${0}"
title="${0}"
>
${0}
</dbp-loading-button>
</div>
</div>`),this.loading||this.currentItem.dateSubmitted,t.t("show-requests.delete-button-text"),(t=>{this.deleteRequest(t,this.currentItem)}),t.t("show-requests.delete-button-text"),t.t("show-requests.delete-button-text"),this.loading||this.currentItem.dateSubmitted,t.t("show-requests.submit-button-text"),(t=>{this.submitRequest(t,this.currentItem)}),t.t("show-requests.submit-button-text"),t.t("show-requests.submit-button-text")):"",this.currentItem?H(s||(s=I`
<div class="request-item details ${0}">
<div class="details header">
<div>
<div class="header-btn">
<div class="section-titles">
${0}
${0}
</div>
</div>
<div>${0}</div>
<div class="no-subject ${0}">${0}</div>
</div>
</div>
<div class="details sender hidden ${0}">
<div class="header-btn">
<div class="section-titles">${0}</div>
${0}
</div>
<div class="sender-data">
${0}
${0}
${0}
${0}
${0}
${0}
${0}
</div>
<div class="no-sender ${0}">${0}</div>
</div>
<div class="details files ${0}">
<div class="header-btn">
<div class="section-titles">${0} <span class="section-title-counts">
${0}</span>
</div>
${0}
</div>
<div class="files-data">
${0}
<div class="no-files ${0}">${0}</div>
</div>
</div>
<div class="details recipients ${0}">
<div class="header-btn">
<div class="section-titles">${0} <span class="section-title-counts">
${0}</span>
</div>
${0}
</div>
</div>
<div class="recipients-data ${0}">
${0}
<div class="no-recipients ${0}">${0}</div>
</div>
</div>
`),J({hidden:!this.showDetailsView}),t.t("create-request.request-subject"),!this.currentItem.dateSubmitted&&this.hasSender?H(d||(d=I`
<dbp-icon-button id="edit-subject-btn"
?disabled="${0}"
="${0}"
title="${0}"
icon-name="pencil"></dbp-icon-button>`),this.loading||this.currentItem.dateSubmitted,(t=>{C.show(this._("#edit-subject-modal"),{disableScroll:!0,onClose:t=>{this.loading=!1}})}),t.t("show-requests.edit-subject-button-text")):"",this.currentItem.name,J({hidden:!this.isLoggedIn()||0!==this.subject.length}),t.t("show-requests.empty-subject-text"),J({hidden:!this.hasSubject}),t.t("show-requests.sender"),!this.currentItem.dateSubmitted&&this.hasSender?H(n||(n=I`
<dbp-icon-button id="edit-sender-btn"
?disabled="${0}"
="${0}"
title="${0}"
icon-name="pencil"></dbp-icon-button>`),this.loading||this.currentItem.dateSubmitted,(t=>{console.log("on edit sender clicked"),""!==this.currentItem.senderAddressCountry&&(this._("#edit-sender-country-select").value=this.currentItem.senderAddressCountry),C.show(this._("#edit-sender-modal"),{disableScroll:!0,onClose:t=>{this.loading=!1}})}),t.t("show-requests.edit-sender-button-text")):"",this.currentItem.senderGivenName?H(r||(r=I`${0}`),this.currentItem.senderGivenName):"",this.currentItem.senderFamilyName&&this.currentItem.senderGivenName?H(a||(a=I` ${0}`),this.currentItem.senderFamilyName):H(o||(o=I`${0}
`),this.currentItem.senderFamilyName?H(c||(c=I`${0}`),this.currentItem.senderFamilyName):""),this.currentItem.senderStreetAddress?H(l||(l=I`<br>${0}`),this.currentItem.senderStreetAddress):"",this.currentItem.senderBuildingNumber?H(u||(u=I` ${0}`),this.currentItem.senderBuildingNumber):"",this.currentItem.senderPostalCode?H(h||(h=I`<br>${0}`),this.currentItem.senderPostalCode):"",this.currentItem.senderAddressLocality?H(b||(b=I` ${0}`),this.currentItem.senderAddressLocality):"",this.currentItem.senderAddressCountry?H(p||(p=I`<br>${0}`),_()[this.currentItem.senderAddressCountry]):"",J({hidden:!this.isLoggedIn()||this.currentItem.senderFamilyName}),t.t("show-requests.empty-sender-text"),J({hidden:!this.hasSender||!this.hasSubject}),t.t("show-requests.files"),this.currentItem.files&&0!==this.currentItem.files.length?"("+this.currentItem.files.length+")":"",this.currentItem.dateSubmitted?"":H(m||(m=I`
<dbp-loading-button id="add-files-btn"
?disabled="${0}"
value="${0}"
="${0}"
title="${0}"
>
${0}
</dbp-loading-button>`),this.loading||this.currentItem.dateSubmitted,t.t("show-requests.add-files-button-text"),(t=>{this.openFileSource()}),t.t("show-requests.add-files-button-text"),t.t("show-requests.add-files-button-text")),this.currentItem.files&&this.currentItem.files.map((e=>H(g||(g=I`
<div class="file card">
<div class="left-side">
<div>${0}</div>
<div>${0}</div>
<div>${0}</div>
<div>${0}</div>
</div>
<div class="right-side">
<dbp-icon-button id="show-file-btn"
="${0}"
class="hidden" <!--TODO -->
title="${0}"
icon-name="keyword-research"></dbp-icon-button>
${0}
</div>
</div>
`),e.name,K(e.contentSize),e.fileFormat,this.convertToReadableDate(e.dateCreated),(t=>{console.log("on show file clicked")}),t.t("show-requests.show-file-button-text"),this.currentItem.dateSubmitted?"":H($||($=I`
<dbp-icon-button id="delete-file-btn"
?disabled="${0}"
="${0}"
title="${0}"
icon-name="trash"></dbp-icon-button>`),this.loading||this.currentItem.dateSubmitted,(t=>{console.log("on delete file clicked"),this.deleteFile(e)}),t.t("show-requests.delete-file-button-text"))))),J({hidden:!this.isLoggedIn()||this.currentItem.files&&0!==this.currentItem.files.length}),t.t("show-requests.empty-files-text"),J({hidden:!this.hasSender||!this.hasSubject}),t.t("show-requests.recipients"),0!==this.currentItem.recipients.length?"("+this.currentItem.recipients.length+")":"",this.currentItem.dateSubmitted?"":H(v||(v=I`
<dbp-loading-button id="add-recipient-btn"
?disabled="${0}"
value="${0}"
="${0}"
title="${0}">
${0}
</dbp-loading-button>`),this.loading||this.currentItem.dateSubmitted,t.t("show-requests.add-recipient-button-text"),(t=>{this.preloadSelectedRecipient().then((()=>{C.show(this._("#add-recipient-modal"),{disableScroll:!0,disableFocus:!1,onClose:t=>{this.loading=!1,this._("#add-recipient-btn").stop()}})}))}),t.t("show-requests.add-recipient-button-text"),t.t("show-requests.add-recipient-button-text")),J({hidden:!this.hasSender||!this.hasSubject}),this.currentItem.recipients.map((e=>H(y||(y=I`
<div class="recipient card">
<div class="left-side">
<div>${0} ${0}</div>
<div>${0} ${0}</div>
<div>${0} ${0}</div>
<div>${0}</div>
</div>
<div class="right-side">
<dbp-icon-button id="show-recipient-btn"
="${0}"
title="${0}"
icon-name="keyword-research"></dbp-icon></dbp-icon-button>
${0}
</div>
</div>
`),e.givenName,e.familyName,e.streetAddress,e.buildingNumber,e.postalCode,e.addressLocality,_()[e.addressCountry],(t=>{this.currentRecipient=e,this._("#show-recipient-btn").start();try{this.fetchDetailedRecipientInformation(e.identifier).then((()=>{C.show(this._("#show-recipient-modal"),{disableScroll:!0,onClose:t=>{this.loading=!1,this.currentRecipient={},this._("#show-recipient-btn").stop()}})}))}catch(t){this._("#show-recipient-btn").stop()}}),t.t("show-requests.show-recipient-button-text"),this.currentItem.dateSubmitted?"":H(f||(f=I`
<dbp-icon-button id="edit-recipient-btn"
?disabled="${0}"
="${0}"
title="${0}"
icon-name="pencil"></dbp-icon-button>
<dbp-icon-button id="delete-recipient-btn"
?disabled="${0}"
="${0}"
title="${0}"
icon-name="trash"></dbp-icon-button>`),this.loading||this.currentItem.dateSubmitted,(t=>{this._("#edit-recipient-btn").start();try{this.fetchDetailedRecipientInformation(e.identifier).then((()=>{this._("#edit-recipient-country-select").value=this.currentRecipient.addressCountry,this._("#tf-edit-recipient-birthdate").value=this.currentRecipient.birthDate,C.show(this._("#edit-recipient-modal"),{disableScroll:!0,onClose:t=>{this.loading=!1,this.currentRecipient={}}})}))}catch(t){this._("#edit-recipient-btn").stop()}}),t.t("show-requests.edit-recipients-button-text"),this.loading||this.currentItem.dateSubmitted,(t=>{this.deleteRecipient(t,e)}),t.t("show-requests.delete-recipient-button-text"))))),J({hidden:!this.isLoggedIn()||!this.hasSender||!this.hasSubject||0!==this.currentItem.recipients.length}),t.t("show-requests.no-recipients-text")):"",this.addFilePicker(),this.addEditSenderModal(this.currentItem),this.addAddRecipientModal(),this.addEditRecipientModal(),this.addShowRecipientModal(),this.addEditSubjectModal(),t.t("create-request.empty-subject"),t.t("show-requests.modal-close"),(()=>{C.close(this._("#add-subject-modal"))}),t.t("show-requests.modal-close"),this.subject?this.subject:"",(()=>{}),t.t("show-requests.add-subject-description"),(()=>{C.close(this._("#add-subject-modal"))}),t.t("show-requests.edit-recipient-dialog-button-cancel"),(()=>{C.close(this._("#add-subject-modal")),this.confirmAddSubject()}),t.t("show-requests.add-subject-dialog-button-ok"))}}Q("dbp-create-request",tt);
//# sourceMappingURL=dbp-create-request.js.map