@progressive-development/pd-order 0.1.124 → 0.1.126

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,213 +0,0 @@
1
- /* eslint-disable lit-a11y/click-events-have-key-events */
2
- /* eslint-disable lit-a11y/anchor-is-valid */
3
- /**
4
- * @license
5
- * Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
6
- */
7
-
8
- import { LitElement, html, css } from 'lit';
9
-
10
- import '@progressive-development/pd-content/pd-collapse.js';
11
- import '@progressive-development/pd-contact/pd-contact.js';
12
-
13
- import { PDFontStyles } from '@progressive-development/pd-shared-styles';
14
-
15
- /**
16
- * An example element.
17
- *
18
- * @slot - This element has a slot
19
- * @csspart button - The button
20
- */
21
- export class PdOrderContacts extends LitElement {
22
-
23
- static get styles() {
24
- return [
25
- PDFontStyles,
26
- css`
27
- :host {
28
- display: block;
29
- }
30
-
31
- p {
32
- color: var(--pd-default-font-content-col);
33
- font-size: var(--pd-default-font-content-size);
34
- font-family: var(--pd-default-font-content-family);
35
- max-width: 1000px;
36
- }
37
-
38
- a {
39
- cursor: pointer;
40
- font-family: var(--pd-default-font-link-family);
41
- font-size: var(--pd-default-font-link-size);
42
- color: var(--pd-default-font-link-col);
43
- }
44
-
45
- a:hover {
46
- color: var(--pd-default-font-link-col-hover);
47
- }
48
-
49
- .collapse-contact {
50
- padding: 10px;
51
- }
52
-
53
- .summary-box {
54
- display: flex;
55
- flex-wrap: wrap;
56
- gap: 10px;
57
- }
58
-
59
- .first-contact {
60
- min-width: 200px;
61
- }
62
- `];
63
- }
64
-
65
- static get properties() {
66
- return {
67
- /**
68
- * List with required contact fields, if not set use default (previous existing values to be consitent during update)
69
- */
70
- requiredFields: { type: Array },
71
- orderContact: { type: Object },
72
- billingContact: { type: Object },
73
- summary: { type: Boolean },
74
- withPayment: { type: Boolean },
75
- match: { type: Object },
76
- _ownBillingContact: { type: Boolean },
77
- };
78
- }
79
-
80
- constructor() {
81
- super();
82
- this._ownBillingContact = false;
83
- this.requiredFields = [];
84
- this.match = {};
85
- }
86
-
87
- connectedCallback() {
88
- super.connectedCallback();
89
- // add validation event listener
90
- this.addEventListener('validate-form', this._validateForm);
91
- }
92
-
93
- disconnectedCallback() {
94
- super.connectedCallback();
95
- // add validation event listener
96
- this.removeEventListener('validate-form', this._validateForm);
97
- }
98
-
99
- firstUpdated() {
100
- // only one of the collapse shoud be open
101
- this.addEventListener('toggle-accordion', e => {
102
- const origin = e.composedPath()[0]; // Warum geht target nicht?
103
- const collapsiblePanels = this.shadowRoot.querySelectorAll(
104
- 'pd-collapse'
105
- );
106
- collapsiblePanels.forEach(panel => {
107
- if (panel !== origin) {
108
- panel.close();
109
- }
110
- });
111
- });
112
- }
113
-
114
- render() {
115
- if (this.summary) {
116
- return this._renderSummary();
117
- }
118
- return this._renderEditContacts();
119
- }
120
-
121
- _renderEditContacts() {
122
- return html`
123
- <pd-collapse id="orderContactCollapseId" active>
124
- <div slot="header" class="header">Adres onderhoud</div>
125
- <pd-contact
126
- id="orderContactId"
127
- class="collapse-contact"
128
- slot="content"
129
- .requiredFields="${this.requiredFields}"
130
- .contact="${this.orderContact}"
131
- .match="${this.match}"
132
- ></pd-contact>
133
- </pd-collapse>
134
-
135
- ${this.withPayment ? html`
136
- <pd-collapse id="billingContactCollapseId">
137
- <div slot="header" class="header">Facturatieadres</div>
138
- <div slot="content">
139
- ${this._ownBillingContact
140
- ? html`
141
- <p>
142
- <a @click="${() => {this._ownBillingContact = false;}}"
143
- >Gebruik adres onderhoud als facturatieadres</a
144
- >
145
- </p>
146
- <pd-contact
147
- id="billingContactId"
148
- class="collapse-contact"
149
- .requiredField="${this.requiredFields}"
150
- .contact="${this.billingContact}"
151
- ></pd-contact>
152
- `
153
- : html`
154
- <p>Het adres waar het onderhoud plaatsvindt, wordt gebruikt als facturatieadres.</p>
155
- <p>
156
- <a @click="${() => {
157
- this._ownBillingContact = true;}}">Creëer een ander facturatieadres.</a>
158
- </p>
159
- `}
160
- </div>
161
- </pd-collapse>`: ''}
162
- `;
163
- }
164
-
165
- _renderSummary() {
166
- return html`
167
- <div class="summary-box">
168
- <pd-contact
169
- class="first-contact"
170
- addressTitle="Onderhoud"
171
- .contact="${this.orderContact}"
172
- summary
173
- ></pd-contact>
174
- ${this.billingContact ? html`
175
- <pd-contact
176
- addressTitle="Facturatie"
177
- addressRef="adres onderhoud"
178
- .contact="${this.billingContact}"
179
- summary
180
- ></pd-contact>` : ''}
181
- </div>
182
- `;
183
- }
184
-
185
- _validateForm(e) {
186
-
187
- if (e.detail && !e.detail.singleElement) {
188
- this.shadowRoot.getElementById("orderContactId").dispatchEvent(
189
- new CustomEvent("validate-form", {
190
- detail: e.detail
191
- })
192
- );
193
-
194
- const errorSize = e.detail.errorMap.size;
195
- if (errorSize > 0) {
196
- this.shadowRoot.getElementById('orderContactCollapseId').open();
197
- }
198
-
199
- // if billing is set too
200
- if (this._ownBillingContact) {
201
- this.shadowRoot.getElementById("billingContactId").dispatchEvent(
202
- new CustomEvent("validate-form", {
203
- detail: e.detail
204
- })
205
- );
206
- if (e.detail.errorMap.size > errorSize) {
207
- this.shadowRoot.getElementById('billingContactCollapseId').open();
208
- }
209
- }
210
- }
211
- }
212
- }
213
-
@@ -1,276 +0,0 @@
1
- /* eslint-disable lit-a11y/anchor-is-valid */
2
- /**
3
- * @license
4
- * Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
5
- */
6
-
7
- import { LitElement, html, css } from 'lit';
8
- import { format } from 'fecha';
9
-
10
- import '@progressive-development/pd-forms/pd-checkbox.js';
11
- import '@progressive-development/pd-forms/pd-radio-group.js';
12
- import '@progressive-development/pd-content/pd-edit-content.js';
13
- import '@progressive-development/pd-price/pd-pricetable.js';
14
- import '@progressive-development/pd-dialog/pd-popup.js';
15
- import '@progressive-development/pd-forms/pd-form-container.js';
16
- import '@progressive-development/pd-forms/pd-form-row.js';
17
-
18
- import { PDFontStyles, PDColorStyles } from '@progressive-development/pd-shared-styles';
19
-
20
- import '../pd-order-contacts.js';
21
-
22
- /**
23
- * An example element.
24
- *
25
- * @slot - This element has a slot
26
- * @csspart button - The button
27
- */
28
- export class PdOrderSummary extends LitElement {
29
-
30
- /**
31
- * @event go-to
32
- */
33
-
34
- static get styles() {
35
- return [
36
- PDFontStyles, PDColorStyles,
37
- css`
38
- :host {
39
- display: block;
40
- }
41
-
42
- h3 {
43
- color: var(--pd-default-font-title-col);
44
- font-family: var(--pd-default-font-title-family);
45
- font-size: 1.5em;
46
- /*margin-top: 10px;
47
- margin-bottom: 20px;*/
48
- }
49
-
50
- .edit-summary-container {
51
- display: flex;
52
- flex-flow: column;
53
- flex-wrap: wrap;
54
- gap: 1em;
55
- }
56
-
57
- .payment {
58
- margin-top: 30px;
59
- padding: 5px;
60
- background-color: var(--pd-order-summary-payment-bg-col, var(--pd-default-light-col));
61
- }
62
-
63
- .pay-logo-box {
64
- display: flex;
65
- }
66
-
67
- .pay-logo {
68
- max-width: 6rem;
69
- }
70
-
71
- .pricetable {
72
- padding-top: 20px;
73
- }
74
-
75
- /* Temporär */
76
- a {
77
- cursor: pointer;
78
- font-family: var(--pd-default-font-link-family);
79
- font-size: var(--pd-default-font-link-size);
80
- color: var(--pd-default-font-link-col);
81
- }
82
- a:hover {
83
- color: var(--pd-default-font-link-col-hover);
84
- }
85
-
86
- .agree-box {
87
- padding-top: 20px;
88
- }
89
-
90
- /* Size Elements for small width */
91
- @media (max-width: 380px) {
92
- .pay-logo {
93
- max-width: 5rem;
94
- }
95
- }
96
- `];
97
- }
98
-
99
- static get properties() {
100
- return {
101
- orderSteps: { type: Array },
102
- withPayment: { type: Boolean },
103
- withAgreement: { type: Boolean },
104
- order: { type: Object },
105
- };
106
- }
107
-
108
- constructor() {
109
- super();
110
- this.orderSteps = [];
111
- this.order = {};
112
- }
113
-
114
- firstUpdated() {
115
- this.addEventListener('edit-content', e => {
116
- this.dispatchEvent(
117
- new CustomEvent('go-to', {
118
- detail: {
119
- step: e.detail.step,
120
- },
121
- bubbles: true,
122
- composed: true,
123
- })
124
- );
125
- });
126
-
127
- this.addEventListener('validate-form', this._validateForm);
128
- }
129
-
130
- render() {
131
-
132
- if (!this.order) {
133
- return html`<p>No order is set</p>`;
134
- }
135
-
136
- return html`
137
- <h3>Overzicht</h3>
138
- <div class="edit-summary-container">
139
- ${this.orderSteps.map((step, index) => {
140
- switch (step.key) {
141
- case 'zip':
142
- case 'booking':
143
- return this._getBookingSummary(index + 1, step);
144
- case 'contacts':
145
- return this._getContactsSummary(index + 1, step);
146
- default:
147
- return html`
148
- <pd-edit-content
149
- contentTitle="${step.name}"
150
- stepNumber="${index + 1}"
151
- .data="${step.data}"
152
- >
153
- <slot name="${step.key}"></slot>
154
- </pd-edit-content>
155
- `;
156
- }
157
- })}
158
- </div>
159
-
160
- ${this.order.priceData ? html`
161
- <div class="payment">
162
- <h3>Facturatie</h3>
163
- <!--
164
- <pd-radio-group id="paymentGroupId" style="--group-direction: column;">
165
- <pd-checkbox name="direct" value="false">
166
- Pay direct, you will redirected after submit the order
167
- <div class="pay-logo-box">
168
- <img class="pay-logo" src="/images/paypal.svg">
169
- <img class="pay-logo" src="/images/visa.svg">
170
- <img class="pay-logo" src="/images/mastercard.svg">
171
- </div>
172
- </pd-checkbox>
173
- <pd-checkbox name="bill" value="false">Pay with bill (5€ additional fee)</pd-checkbox>
174
- </pd-radio-group>
175
- -->
176
- <pd-pricetable
177
- class="pricetable"
178
- .priceData="${this.order.priceData}"
179
- ></pd-pricetable>
180
- </div>
181
- ` : ''}
182
-
183
- ${this.withAgreement ? html`
184
- <pd-form-container id="submitSummaryFormId">
185
- <pd-form-row>
186
- <pd-checkbox
187
- id="agreeConditionsId"
188
- valueName="agreeId"
189
- class="agree-box"
190
- required
191
- requiredMsg="Ga akkoord met de algemene voorwaarden om uw order te bevestigen."
192
- >
193
- Ga akkoord met onze
194
- <a
195
- @click="${this._openTermsAndConditions}"
196
- @keypress="${this._openTermsAndConditions}"
197
- >algemene voorwaarden</a
198
- >
199
- </pd-checkbox>
200
- </pd-form-row>
201
- </pd-form-container>
202
-
203
- <pd-popup id="agreePopupId">
204
- <div slot="content"><slot name="legal"></slot></div>
205
- </pd-popup>
206
- ` : ""}
207
- `;
208
- }
209
-
210
- _validateForm(e) {
211
- if (e.detail && !e.detail.singleElement && this.withAgreement) {
212
- this.shadowRoot.getElementById("submitSummaryFormId").dispatchEvent(
213
- new CustomEvent("validate-form", {
214
- detail: e.detail
215
- })
216
- );
217
- }
218
- }
219
-
220
- _getBookingSummary(index, step) {
221
- let date;
222
- if (this.order.selectedDate) {
223
- date = format(this.order.selectedDate, 'DD/MM/YYYY');
224
- }
225
- const bookingData = [{ name: 'Postcode:', val: this.order.zip }];
226
- if (date) {
227
- bookingData.push({ name: 'Datum van herstelling:', val: date });
228
- }
229
-
230
- return html`
231
- <pd-edit-content
232
- contentTitle="${step.name}"
233
- stepNumber="${index}"
234
- .data="${bookingData}"
235
- >
236
- </pd-edit-content>
237
- `;
238
- }
239
-
240
- _getContactsSummary(index, step) {
241
- return html`
242
- <pd-edit-content
243
- contentTitle="${step.name}"
244
- stepNumber="${index}"
245
- ?editDisabled="${this.order.withLogin}"
246
- >
247
- ${this.order.contacts
248
- ? html`
249
- <pd-order-contacts
250
- ?withPayment="${this.withPayment}"
251
- .orderContact="${this.order.contacts.orderContact}"
252
- .billingContact="${this.order.contacts.billingContact}"
253
- summary
254
- >
255
- </pd-order-contacts>
256
- `
257
- : ''}
258
- </pd-edit-content>
259
- `;
260
- }
261
-
262
-
263
- _openTermsAndConditions(e) {
264
- // TODO: [TIM-28] Bei key-pressed event => Auf enter prüfen...
265
-
266
- // Alternative über eigenen Link: window.open(url, '_blank').focus();
267
-
268
- // open popup
269
- this.shadowRoot.getElementById('agreePopupId').showPopup();
270
-
271
- // stop event, do not edit check-box, when link is clicked
272
- e.stopPropagation();
273
- }
274
-
275
- }
276
-
@@ -1,26 +0,0 @@
1
- import { html } from 'lit';
2
- import '../pd-booking.js';
3
-
4
- export default {
5
- title: 'PdOrder/Booking',
6
- component: 'pd-booking',
7
- argTypes: {
8
-
9
- },
10
- };
11
-
12
- function BookingTemplate() {
13
- return html`
14
- <pd-booking id="bookCompId" custTok="123456" item="REPAIR">
15
- <p slot="description">
16
- We repair all heatings from our supported brands. The price includes the 1st our of work and the out-calll fee.
17
- Needed repair parts or additional ours not included.
18
- </p>
19
- </pd-booking>
20
- `;
21
- }
22
-
23
- export const Booking = BookingTemplate.bind({});
24
- Booking.args = {
25
- };
26
-
@@ -1,17 +0,0 @@
1
- import { html } from 'lit';
2
-
3
- export default {
4
- title: 'PdOrder',
5
- component: 'pd-order',
6
- argTypes: {
7
-
8
- },
9
- };
10
-
11
- function Template() {
12
- return html`
13
- <p>ToDo: Examples Overview</p>
14
- `;
15
- }
16
-
17
- export const Examples = Template.bind({});
@@ -1,78 +0,0 @@
1
- import { html } from 'lit';
2
- import '../pd-order-contacts.js';
3
-
4
- export default {
5
- title: 'PdOrder/Order Contacts',
6
- component: 'pd-order-contacts',
7
- argTypes: {
8
-
9
- },
10
- };
11
-
12
- function Template({ summary, orderContact, billingContact }) {
13
- return html`
14
- <pd-order-contacts id="testOrderId" ?summary="${summary}" .orderContact="${orderContact}"
15
- .billingContact="${billingContact}"></pd-order-contacts>
16
-
17
- <h2>Test Validation</h2>
18
- <button @click="${() => {
19
-
20
- document.getElementById("testOrderId").validateInput();
21
-
22
- }}">Test Validate</button>
23
- `;
24
- }
25
-
26
- export const OrderContacts = Template.bind({});
27
- OrderContacts.args = {
28
- summary: false,
29
- };
30
-
31
- export const OrderContactsView = Template.bind({});
32
- OrderContactsView.args = {
33
- summary: true,
34
- orderContact: {
35
- firstName: 'Peter',
36
- lastName: 'Musterman',
37
- street: 'Musterstrasse',
38
- streetNr: '34a',
39
- zip: '6041',
40
- city: 'Gent',
41
- phone1: '0221/9923443',
42
- mobil: '0175/9923443',
43
- email: 'peter@muster.be'
44
- },
45
- billingContact: {
46
- firstName: 'Peter',
47
- lastName: 'Billing',
48
- street: 'Billinggäßchen',
49
- streetNr: '12',
50
- zip: '6039',
51
- city: 'Gent'
52
- }
53
- };
54
-
55
- export const OrderContactsPrepared = Template.bind({});
56
- OrderContactsPrepared.args = {
57
- summary: false,
58
- orderContact: {
59
- firstName: 'Peter',
60
- lastName: 'Musterman',
61
- street: 'Musterstrasse',
62
- streetNr: '34a',
63
- zip: '6041',
64
- city: 'Gent',
65
- phone1: '0221/9923443',
66
- mobil: '0175/9923443',
67
- email: 'peter@muster.be'
68
- },
69
- billingContact: {
70
- firstName: 'Peter',
71
- lastName: 'Billing',
72
- street: 'Billinggäßchen',
73
- streetNr: '12',
74
- zip: '6039',
75
- city: 'Gent'
76
- }
77
- };
78
-
@@ -1,103 +0,0 @@
1
- import { html } from 'lit';
2
- import '../pd-order-summary.js';
3
-
4
- export default {
5
- title: 'PdOrder/Order Summary',
6
- component: 'pd-order-summary',
7
- argTypes: {},
8
- };
9
-
10
- const agb = html`
11
- <h1>AGB</h1>
12
- <p>Text zu der Einleitung der AGBs.</p>
13
- <h2>Sub Title</h2>
14
- <p>Text zu der Einleitung der AGBs.</p>
15
- <h3>Detail Punkt</h3>
16
- <p>Text zu der Einleitung der AGBs.</p>
17
- `;
18
-
19
- function Template({ orderContact, billingContact }) {
20
- const heatingData = [
21
- { name: 'Period:', val: '24 maanden' },
22
- { name: 'Brand:', val: 'Bosch' },
23
- { name: 'Type:', val: '--' },
24
- { name: 'House age:', val: '> 10 Years' },
25
- { name: 'Description:', val: 'Heating is defect, not warm' },
26
- ];
27
- return html`
28
- <pd-order-summary
29
- id="testSummaryId"
30
- withAgreement
31
- withPayment
32
- .order="${{
33
- contacts: { orderContact, billingContact },
34
- priceData: {
35
- tax: 0.1,
36
- articles: [
37
- {
38
- name: 'Maintenance Bronze (heating support for 2 years)',
39
- price: 123.5,
40
- },
41
- ],
42
- },
43
- zip: 9060,
44
- selectedDate: new Date(Date.now()),
45
- }}"
46
- .orderSteps="${[
47
- { key: 'booking', name: 'Date' },
48
- { key: 'heating', name: 'Heating', data: heatingData },
49
- { key: 'contacts', name: 'Address' },
50
- ]}"
51
- >
52
- <span slot="legal">${agb}</span>
53
- </pd-order-summary>
54
-
55
- <h2>Test Validation</h2>
56
- <button
57
- @click="${() => {
58
- document.getElementById('testSummaryId').validateInput();
59
- }}"
60
- >
61
- Test Validate
62
- </button>
63
- `;
64
- }
65
-
66
- export const OrderSummary = Template.bind({});
67
- OrderSummary.args = {
68
- orderContact: {
69
- firstName: 'Peter',
70
- lastName: 'Musterman',
71
- street: 'Musterstrasse',
72
- streetNr: '34a',
73
- zip: '6041',
74
- city: 'Gent',
75
- phone: '0221/9923443',
76
- mobil: '0175/9923443',
77
- email: 'peter@muster.be',
78
- },
79
- billingContact: {
80
- firstName: 'Peter',
81
- lastName: 'Billing',
82
- street: 'Billinggäßchen',
83
- streetNr: '12',
84
- zip: '6039',
85
- city: 'Gent',
86
- },
87
- };
88
-
89
- export const OrderSummaryEmptyBilling = Template.bind({});
90
- OrderSummaryEmptyBilling.args = {
91
- summary: true,
92
- orderContact: {
93
- firstName: 'Peter',
94
- lastName: 'Musterman',
95
- street: 'Musterstrasse',
96
- streetNr: '34a',
97
- zip: '6041',
98
- city: 'Gent',
99
- phone: '0221/9923443',
100
- mobil: '0175/9923443',
101
- email: 'peter@muster.be',
102
- },
103
- };