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

202 lines (187 loc) 14.1 kB
let e,t,i,s,a=e=>e;function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},n.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{S as l,I as r,M as o,L as c,s as h,i as d,g as m,b as p,d as u,p as g,l as b,q as y,x as v,o as k,k as $}from"./shared/notification.fWOMSAA9.es.js";import{T as f}from"./shared/textswitch.UQb80iHx.es.js";import{C,s as S}from"./shared/check-in-place-select.6YIWD7RZ.es.js";import{D as I,c as E,A as N,g as _}from"./shared/activity.pxR99eKk.es.js";import"./shared/utils.uVgKQcsS.es.js";var x={element:"dbp-guest-check-in",module_src:"dbp-guest-check-in.js",routing_name:"guest-check-in",name:{de:"Gast an Ort anmelden",en:"Check-in guest at a place"},short_name:{de:"Gast an Ort anmelden",en:"Check-in guest at a place"},description:{de:"Meldet einen Gast an einem Ort an.",en:"Logs a guest in one place."},subscribe:"lang,entry-point-url,auth,html-overrides"};class T extends(l(I)){constructor(){super(),this._i18n=E(),this.lang=this._i18n.language,this.activity=new N(x),this.entryPointUrl="",this.isRoomSelected=!1,this.roomCapacity=0,this.locationHash="",this.locationName="",this.guestEmail="",this.seatNr="",this.endTime,this.isEmailSet=!1}static get scopedElements(){return{"dbp-icon":r,"dbp-mini-spinner":o,"dbp-loading-button":c,"dbp-textswitch":f,"dbp-check-in-place-select":C}}static get properties(){return n({},super.properties,{lang:{type:String},entryPointUrl:{type:String,attribute:"entry-point-url"},seatNr:{type:Number,attribute:!1},guestEmail:{type:String,attribute:!1},isRoomSelected:{type:Boolean,attribute:!1},roomCapacity:{type:Number,attribute:!1},isEmailSet:{type:Boolean,attribute:!1}})}connectedCallback(){super.connectedCallback()}update(e){e.forEach(((e,t)=>{if("lang"===t)this._i18n.changeLanguage(this.lang)})),super.update(e)}processSelectedPlaceInformation(e){this.isRoomSelected=!0,this.roomCapacity=e.detail.capacity,this.locationHash=e.detail.room,this.locationName=e.detail.name}setSeatNumber(e){let t=parseInt(this._("#select-seat").value);t=isNaN(t)?"":t,this.seatNr=Math.min(this.roomCapacity,t),this._("#select-seat").value=this.seatNr}validateEmail(e){return!!e.match(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/)}processEmailInput(e){""!=this._("#email-field").value?(this.guestEmail=this._("#email-field").value,this.isEmailSet=!0):(this.isEmailSet=!1,this.guestEmail="")}parseTime(){let e=this._("#end-time").value.split(":");if(2===e.length){const i=e[0],s=e[1];this.endTime=new Date,this.endTime.setHours(i),this.endTime.setMinutes(s);var t=new Date;return t.getHours()<i||t.getHours()===i&&t.getMinutes()<=s||this.endTime.setTime(this.endTime.getTime()+864e5),!0}return!1}async sendGuestCheckInRequest(e,t,i,s){let a,n={location:"/checkin/places/"+t,seatNumber:parseInt(i),email:e,endTime:s};const l={method:"POST",headers:{"Content-Type":"application/ld+json",Authorization:"Bearer "+this.auth.token},body:JSON.stringify(n)};return a=await this.httpGetAsync(this.entryPointUrl+"/checkin/guest-check-in-actions",l),a}async _onCheckInClicked(e){let t=!0,i=e.target;if(!i.disabled)try{i.start(),await this.initCheckIn()}catch(e){t=!1}finally{i.stop(),i.disabled=t}}async _atChangeInput(e){this._("#do-manually-checkin")&&(this._("#do-manually-checkin").disabled=!this.isRoomSelected||!this.isEmailSet||this.isRoomSelected&&null!==this.roomCapacity&&this.seatNr<=0)}async initCheckIn(){const e=this._i18n;if(!this.validateEmail(this.guestEmail))return h({summary:e.t("guest-check-in.invalid-email-address-title"),body:e.t("guest-check-in.invalid-email-address-body"),type:"danger",timeout:5}),void this.sendSetPropertyEvent("analytics-event",{category:"GuestCheckInRequest",action:"GuestCheckInFailedInvalidEmail"});if(!this.parseTime())return void h({summary:e.t("guest-check-in.no-time-title"),body:e.t("guest-check-in.no-time-body"),type:"danger",timeout:5});null===this.roomCapacity&&this.seatNr>=0&&(this.seatNr="");let t=this.locationHash,i=this.locationName,s=this.seatNr,a="GuestCheckInRequest";if(this.locationHash.length<=0)return this.saveWrongHashAndNotify(e.t("check-in.error-title"),e.t("check-in.error-body"),t,s),void this.sendSetPropertyEvent("analytics-event",{category:a,action:"GuestCheckInFailedNoLocationHash"});let n=await this.sendGuestCheckInRequest(this.guestEmail,this.locationHash,this.seatNr,this.endTime);await this.checkCheckinResponse(n,t,s,i,a)}getCurrentTime(){let e=new Date;return("0"+(e.getHours()+1)).slice(-2)+":"+("0"+e.getMinutes()).slice(-2)}hasPermissions(){return!(!this.auth.person||!Array.isArray(this.auth.person.roles))&&(!!this.auth.person.roles.includes("ROLE_STAFF")||!!this.auth.person.roles.includes("ROLE_SCOPE_LOCATION-CHECK-IN-GUEST"))}static get styles(){return d(e||(e=a` ${0} ${0} ${0} ${0} ${0} ${0} h2 { margin-top: 0; margin-bottom: 0px; } .field { margin-bottom: 1rem !important; } #email-field { padding-left: 8px; font-weight: 300; color: inherit; border: var(--dbp-border); border-color: var(--dbp-muted); line-height: 100%; height: 28px; width: 100%; } ::placeholder { color: inherit; opacity: 1; } #select-seat { padding-left: 8px; font-weight: 300; color: inherit; border: var(--dbp-border); border-color: var(--dbp-muted); line-height: 100%; height: 28px; } #end-time { padding-left: 8px; font-weight: 300; color: inherit; border: var(--dbp-border); border-color: var(--dbp-muted); line-height: 100%; height: 28px; } @media only screen and (orientation: portrait) and (max-width: 768px) { .btn { display: flex; flex-direction: column; text-align: center; margin-bottom: 0.5rem; } #select-seat { width: 100%; } #end-time { width: 100%; } } `),m(),p(!1),u(),g(),_(),b())}render(){const e=y(S),n=this._i18n;return v(t||(t=a` <div class="control ${0}"> <span class="loading"> <dbp-mini-spinner text=${0}></dbp-mini-spinner> </span> </div> <div class="notification is-danger ${0}"> ${0} </div> <div class="notification is-warning ${0}"> ${0} </div> <div class="${0}"> <link rel="stylesheet" href="${0}" /> <h2>${0}</h2> <p class="subheadline"> <slot name="description">${0}</slot> </p> <slot name="activity-description"> <p>${0}</p> <p>${0}</p> </slot> ${0} </div> `),k({hidden:this.isLoggedIn()||!this.isLoading()}),n.t("check-out.loading-message"),k({hidden:this.hasPermissions()||!this.isLoggedIn()||this.isLoading()}),n.t("guest-check-in.error-permission-message"),k({hidden:this.isLoggedIn()||this.isLoading()||!this.hasPermissions()}),n.t("error-login-message"),k({hidden:!this.isLoggedIn()||!this.hasPermissions()||this.isLoading()}),e,this.activity.getName(this.lang),this.activity.getDescription(this.lang),n.t("guest-check-in.how-to"),n.t("guest-check-in.data-protection"),this.hasPermissions()?v(i||(i=a` <div class="border"> <div class="container"> <div class="field"> <label class="label">${0}</label> <div class="control"> <input type="email" class="input" id="email-field" placeholder="mail@email.at" name="email" .value="${0}" @input="${0}" /> </div> </div> <div class="field"> <label class="label"> ${0} </label> <div class="control"> <dbp-check-in-place-select subscribe="auth" lang="${0}" entry-point-url="${0}" @change="${0}" @input="${0}"></dbp-check-in-place-select> </div> </div> <div class="field ${0}"> <link rel="stylesheet" href="${0}" /> <label class="label"> ${0} </label> <div class="control"> <input class="input" type="text" name="seat-number" .value="${0}" id="select-seat" min="1" max="${0}" placeholder="1-${0}" maxlength="4" inputmode="numeric" pattern="[0-9]*" ?disabled=${0} @input="${0}" /> </div> </div> <div class="field"> <label class="label"> ${0} </label> <div class="control"> <input type="time" class="input" placeholder="hh:mm" id="end-time" name="endTime" .defaultValue="${0}" @input="${0}" /> </div> </div> <div class="btn"> <dbp-loading-button id="do-manually-checkin" type="is-primary" value="${0}" @click="${0}" title="${0}" ?disabled=${0}></dbp-loading-button> </div> </div> </div> `),n.t("guest-check-in.email"),this.guestEmail,(e=>{this.processEmailInput(e),this._atChangeInput(e)}),n.t("check-in.manually-place"),this.lang,this.entryPointUrl,(e=>{this.processSelectedPlaceInformation(e)}),(e=>{this._atChangeInput(e)}),k({hidden:!this.isRoomSelected||null===this.roomCapacity}),e,n.t("check-in.manually-seat"),this.seatNr,this.roomCapacity,this.roomCapacity,!this.isRoomSelected,(e=>{this.setSeatNumber(e),this._atChangeInput(e)}),n.t("guest-check-in.end-time"),this.getCurrentTime(),(e=>{this._atChangeInput(e)}),n.t("check-in.manually-checkin-button-text"),this._onCheckInClicked,n.t("check-in.manually-checkin-button-text"),!this.isRoomSelected||!this.isEmailSet||this.isRoomSelected&&null!==this.roomCapacity&&this.seatNr<=0):v(s||(s=a``)))}}$("dbp-guest-check-in",T); //# sourceMappingURL=dbp-guest-check-in.js.map