UNPKG

@digital-blueprint/checkin-app

Version:

[GitHub Repository](https://github.com/digital-blueprint/checkin-app) | [npmjs package](https://www.npmjs.com/package/@digital-blueprint/checkin-app) | [Unpkg CDN](https://unpkg.com/browse/@digital-blueprint/checkin-app/) | [Checkin Bundle](https://github

140 lines (126 loc) 8.78 kB
let t,e,i,n,s=t=>t;function a(){return a=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},a.apply(this,arguments)} /*! * License: LGPL-2.1-or-later * Dependencies: * * @webcomponents/scoped-custom-element-registry: 0.0.9 (BSD-3-Clause) * @dbp-toolkit/app-shell: 0.3.4 (LGPL-2.1-or-later) * @dbp-toolkit/language-select: 0.3.2 (LGPL-2.1-or-later) * @dbp-toolkit/common: 0.3.5 (LGPL-2.1-or-later) * @dbp-toolkit/auth: 0.3.2 (LGPL-2.1-or-later) * event-target-shim: 6.0.2 (MIT) * @dbp-toolkit/notification: 0.3.2 (LGPL-2.1-or-later) * @dbp-toolkit/theme-switcher: 0.0.6 (LGPL-2.1-or-later) * path-to-regexp: 6.2.0 (MIT) * universal-router: 9.1.0 (MIT) * generateUrls: 9.1.0 (MIT) * @dbp-toolkit/matomo: 0.2.7 (LGPL-2.1-or-later) * @dbp-toolkit/qr-code-scanner: 0.3.3 (LGPL-2.1-or-later) * async-mutex: 0.4.0 (MIT) */import{D as o,c,A as r,g as h}from"./shared/activity.pxR99eKk.es.js";import{S as d,I as l,M as g,L as p,s as u,i as m,g as b,b as k,f as v,d as y,p as f,x as $,o as C,k as L}from"./shared/notification.fWOMSAA9.es.js";import{T as O}from"./shared/textswitch.UQb80iHx.es.js";var w={element:"dbp-check-out-request",module_src:"dbp-check-out-request.js",routing_name:"check-out-request",name:{de:"Von Orten abmelden",en:"Check-out from places"},short_name:{de:"Von Orten abmelden",en:"Check-out from places"},description:{de:"Zeigt alle angemeldeten Orte.",en:"Shows all checked-in places."},subscribe:"lang:lang,entry-point-url:entry-point-url,auth:auth"};class x extends(d(o)){constructor(){super(),this._i18n=c(),this.lang=this._i18n.language,this.activity=new r(w),this.entryPointUrl="",this.activeCheckins=[],this.loading=!1,this._initialFetchDone=!1}static get scopedElements(){return{"dbp-icon":l,"dbp-mini-spinner":g,"dbp-loading-button":p,"dbp-textswitch":O}}static get properties(){return a({},super.properties,{lang:{type:String},entryPointUrl:{type:String,attribute:"entry-point-url"},activeCheckins:{type:Array,attribute:!1},initialCheckinsLoading:{type:Boolean,attribute:!1},loading:{type:Boolean,attribute:!1}})}connectedCallback(){super.connectedCallback()}update(t){t.forEach(((t,e)=>{if("lang"===e)this._i18n.changeLanguage(this.lang)})),super.update(t)}async doCheckOut(t,e){let i="",n="",s="",a=t.target;const o=this._i18n;if(void 0!==e&&(i=e.location?e.location.identifier:"",n=e.seatNumber,s=e.location?e.location.name:""),0===i.length)u({summary:o.t("check-out.checkout-failed-title"),body:o.t("check-out.checkout-failed-body",{room:s}),type:"warning",timeout:5}),await this.sendErrorAnalyticsEvent("CheckOutRequest","CheckOutFailed",this.checkedInRoom);else{let t;this.loading=!0,a.start();try{t=await this.sendCheckOutRequest(i,n),await this.getListOfActiveCheckins()}finally{a.stop(),this.loading=!1}await this.checkCheckoutResponse(t,i,n,s,"CheckOutRequest")}}parseActiveCheckins(t){let e=Array.from(t["hydra:member"]);return e.sort(this.compareListItems),e}compareListItems(t,e){return t.location.name<e.location.name?-1:t.location.name>e.location.name?1:t.seatNumber<e.seatNumber?-1:t.seatNumber>e.seatNumber?1:0}async getListOfActiveCheckins(){this.initialCheckinsLoading=!this._initialFetchDone;try{let t=await this.getActiveCheckIns(),e=await t.json();void 0!==e&&403!==e.status&&(this.activeCheckins=this.parseActiveCheckins(e))}finally{this.initialCheckinsLoading=!1,this._initialFetchDone=!0}}async doRefreshSession(t,e){let i=e.location.identifier,n=e.seatNumber,s=e.location.name,a=t.target;a.start(),this.loading=!0;try{await this.refreshSession(i,n,s,"CheckOutRequest"),await this.getListOfActiveCheckins()}finally{a.stop(),this.loading=!1}}static get styles(){return m(t||(t=s` ${0} ${0} ${0} ${0} ${0} ${0} .checkins { display: grid; grid-template-columns: repeat(3, max-content); column-gap: 15px; row-gap: 1.5em; align-items: center; margin-top: 2em; } .header { display: grid; align-items: center; } .border { margin-top: 2rem; padding-top: 2rem; border-top: var(--dbp-border); } @media only screen and (orientation: portrait) and (max-width: 768px) { .checkins { display: block; } .header { margin-bottom: 0.5rem; } #refresh-btn { margin-top: 0.5rem; margin-bottom: 2rem; } .btn { display: flex; flex-direction: column; } .loading { justify-content: center; } } `),b(),k(!1),v(),y(),f(),h())}render(){const t=this._i18n;return!this.isLoggedIn()||this.isLoading()||this._initialFetchDone||this.initialCheckinsLoading||this.getListOfActiveCheckins(),$(e||(e=s` <div class="notification is-warning ${0}"> ${0} </div> <div class="control ${0}"> <span class="loading"> <dbp-mini-spinner text=${0}></dbp-mini-spinner> </span> </div> <div class="${0}"> <h2>${0}</h2> <p class="subheadline"> <slot name="description">${0}</slot> </p> <div class="border checkins ${0}"> ${0} <span class="control ${0}"> <span class="loading"> <dbp-mini-spinner text=${0}></dbp-mini-spinner> </span> </span> <div class="no-checkins ${0}"> ${0} </div> </div> </div> `),C({hidden:this.isLoggedIn()||this.isLoading()}),t.t("error-login-message"),C({hidden:this.isLoggedIn()||!this.isLoading()}),t.t("check-out.loading-message"),C({hidden:!this.isLoggedIn()||this.isLoading()}),this.activity.getName(this.lang),this.activity.getDescription(this.lang),C({hidden:!this.isLoggedIn()||this.isLoading()}),this.activeCheckins.map((e=>$(i||(i=s` <span class="header"> <strong>${0}</strong> ${0} ${0} ${0} </span> <div> <div class="btn"> <dbp-loading-button type="is-primary" ?disabled="${0}" value="${0}" @click="${0}" title="${0}"></dbp-loading-button> </div> </div> <div> <div class="btn"> <dbp-loading-button id="refresh-btn" ?disabled="${0}" value="${0}" @click="${0}" title="${0}"></dbp-loading-button> </div> </div> `),e.location.name,null!==e.seatNumber?$(n||(n=s` ${0}: ${0} <br /> `),t.t("check-in.seatNr"),e.seatNumber):"",t.t("check-out.checkin-until"),this.getReadableDate(e.endTime),this.loading,t.t("check-out.button-text"),(t=>{this.doCheckOut(t,e)}),t.t("check-out.button-text"),this.loading,t.t("check-in.refresh-button-text"),(t=>{this.doRefreshSession(t,e)}),t.t("check-in.refresh-button-text")))),C({hidden:this.isLoggedIn()&&!this.initialCheckinsLoading}),t.t("check-out.loading-message"),C({hidden:!this.isLoggedIn()||this.initialCheckinsLoading||0!==this.activeCheckins.length}),t.t("check-out.no-checkins-message"))}}L("dbp-check-out-request",x); //# sourceMappingURL=dbp-check-out-request.js.map