@progressive-development/pd-order 0.5.17 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,244 +0,0 @@
1
- import { LitElement, css, html } from "lit";
2
- import { msg } from "@lit/localize";
3
- import { format } from "fecha";
4
- import "@progressive-development/pd-forms/pd-checkbox";
5
- import "@progressive-development/pd-forms/pd-radio-group";
6
- import "@progressive-development/pd-forms/pd-form-container";
7
- import "@progressive-development/pd-forms/pd-form-row";
8
- import "@progressive-development/pd-price/pd-pricetable";
9
- import "@progressive-development/pd-dialog/pd-popup";
10
- import "@progressive-development/pd-content/pd-edit-content";
11
- import { PDFontStyles, PDColorStyles } from "@progressive-development/pd-shared-styles";
12
- import "../pd-order-contacts.js";
13
- /**
14
- * @license
15
- * Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
16
- */
17
- class PdOrderSummary extends LitElement {
18
- /**
19
- * @event go-to
20
- */
21
- static get styles() {
22
- return [
23
- PDFontStyles,
24
- PDColorStyles,
25
- css`
26
- :host {
27
- display: block;
28
- }
29
-
30
- h3 {
31
- color: var(--pd-default-font-title-col);
32
- font-family: var(--pd-default-font-title-family);
33
- font-size: 1.5em;
34
- /*margin-top: 10px;
35
- margin-bottom: 20px;*/
36
- }
37
-
38
- .edit-summary-container {
39
- display: flex;
40
- flex-flow: column;
41
- flex-wrap: wrap;
42
- gap: 1em;
43
- }
44
-
45
- .payment {
46
- margin-top: 30px;
47
- padding: 5px;
48
- background-color: var(--pd-order-summary-payment-bg-col, var(--pd-default-light-col));
49
- }
50
-
51
- .pay-logo-box {
52
- display: flex;
53
- }
54
-
55
- .pay-logo {
56
- max-width: 6rem;
57
- }
58
-
59
- .pricetable {
60
- padding-top: 20px;
61
- }
62
-
63
- /* Temporär */
64
- a {
65
- cursor: pointer;
66
- font-family: var(--pd-default-font-link-family);
67
- font-size: var(--pd-default-font-link-size);
68
- color: var(--pd-default-font-link-col);
69
- }
70
- a:hover {
71
- color: var(--pd-default-font-link-col-hover);
72
- }
73
-
74
- .agree-box {
75
- padding-top: 20px;
76
- }
77
-
78
- /* Size Elements for small width */
79
- @media (max-width: 380px) {
80
- .pay-logo {
81
- max-width: 5rem;
82
- }
83
- }
84
- `
85
- ];
86
- }
87
- static get properties() {
88
- return {
89
- orderSteps: { type: Array },
90
- withPayment: { type: Boolean },
91
- withAgreement: { type: Boolean },
92
- order: { type: Object }
93
- };
94
- }
95
- constructor() {
96
- super();
97
- this.orderSteps = [];
98
- this.order = {};
99
- }
100
- firstUpdated() {
101
- this.addEventListener("edit-content", (e) => {
102
- this.dispatchEvent(
103
- new CustomEvent("go-to", {
104
- detail: {
105
- step: e.detail.step
106
- },
107
- bubbles: true,
108
- composed: true
109
- })
110
- );
111
- });
112
- this.addEventListener("validate-form", this._validateForm);
113
- }
114
- render() {
115
- if (!this.order) {
116
- return html`<p>No order is set</p>`;
117
- }
118
- return html`
119
- <h3>${msg("Übersicht", { id: "pd.order.summary.title" })}</h3>
120
- <div class="edit-summary-container">
121
- ${this.orderSteps.map((step, index) => {
122
- switch (step.key) {
123
- case "zip":
124
- case "booking":
125
- return this._getBookingSummary(index + 1, step);
126
- case "contacts":
127
- return this._getContactsSummary(index + 1, step);
128
- default:
129
- return html`
130
- <pd-edit-content
131
- contentTitle="${step.name}"
132
- stepNumber="${index + 1}"
133
- .data="${step.data}"
134
- >
135
- <slot name="${step.key}"></slot>
136
- </pd-edit-content>
137
- `;
138
- }
139
- })}
140
- </div>
141
-
142
- ${this.order.priceData ? html`
143
- <div class="payment">
144
- <h3>${msg("Rechnung", { id: "pd.order.summary.billing" })}</h3>
145
- <!--
146
- <pd-radio-group id="paymentGroupId" style="--group-direction: column;">
147
- <pd-checkbox name="direct" value="false">
148
- Pay direct, you will redirected after submit the order
149
- <div class="pay-logo-box">
150
- <img class="pay-logo" src="/images/paypal.svg">
151
- <img class="pay-logo" src="/images/visa.svg">
152
- <img class="pay-logo" src="/images/mastercard.svg">
153
- </div>
154
- </pd-checkbox>
155
- <pd-checkbox name="bill" value="false">Pay with bill (5€ additional fee)</pd-checkbox>
156
- </pd-radio-group>
157
- -->
158
- <pd-pricetable
159
- class="pricetable"
160
- .priceData="${this.order.priceData}"
161
- ></pd-pricetable>
162
- </div>
163
- ` : ""}
164
-
165
- ${this.withAgreement ? html`
166
- <pd-form-container id="submitSummaryFormId">
167
- <pd-form-row>
168
- <pd-checkbox
169
- id="agreeConditionsId"
170
- valueName="agreeId"
171
- class="agree-box"
172
- required
173
- requiredMsg="${msg("Bitte stimmen Sie den Allgemeinen Geschäftsbedingungen zu, um fortzufahren.", { id: "pd.order.summary.agree.required" })}"
174
- >
175
- ${msg(
176
- html`Stimmen Sie unseren <a @click="${this._openTermsAndConditions}" @keypress="${this._openTermsAndConditions}">Allgemeinen Geschäftsbedingungen</a> zu`,
177
- { id: "pd.order.summary.agree.link" }
178
- )}
179
- </pd-checkbox>
180
- </pd-form-row>
181
- </pd-form-container>
182
-
183
- <pd-popup id="agreePopupId">
184
- <div slot="content"><slot name="legal"></slot></div>
185
- </pd-popup>
186
- ` : ""}
187
- `;
188
- }
189
- _validateForm(e) {
190
- if (e.detail && !e.detail.singleElement && this.withAgreement) {
191
- this.shadowRoot.getElementById("submitSummaryFormId").dispatchEvent(
192
- new CustomEvent("validate-form", {
193
- detail: e.detail
194
- })
195
- );
196
- }
197
- }
198
- _getBookingSummary(index, step) {
199
- let date;
200
- if (this.order.selectedDate) {
201
- date = format(this.order.selectedDate, "DD/MM/YYYY");
202
- }
203
- const bookingData = [{ name: "Postcode:", val: this.order.zip }];
204
- if (date) {
205
- bookingData.push({ name: "Datum van herstelling:", val: date });
206
- }
207
- return html`
208
- <pd-edit-content
209
- contentTitle="${step.name}"
210
- stepNumber="${index}"
211
- .data="${bookingData}"
212
- >
213
- </pd-edit-content>
214
- `;
215
- }
216
- _getContactsSummary(index, step) {
217
- return html`
218
- <pd-edit-content
219
- contentTitle="${step.name}"
220
- stepNumber="${index}"
221
- ?editDisabled="${this.order.withLogin}"
222
- >
223
- ${this.order.contacts ? html`
224
- <pd-order-contacts
225
- ?withPayment="${this.withPayment}"
226
- .orderContact="${this.order.contacts.orderContact}"
227
- .billingContact="${this.order.contacts.billingContact}"
228
- .adminContact="${this.order.contacts.adminContact}"
229
- .propertyContact="${this.order.contacts.propertyContact}"
230
- summary
231
- >
232
- </pd-order-contacts>
233
- ` : ""}
234
- </pd-edit-content>
235
- `;
236
- }
237
- _openTermsAndConditions(e) {
238
- this.shadowRoot.getElementById("agreePopupId").showPopup();
239
- e.stopPropagation();
240
- }
241
- }
242
- export {
243
- PdOrderSummary
244
- };