@progressive-development/pd-contact 0.1.59 → 0.1.61

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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Progressive Development Contact component",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "author": "PD Progressive Development",
6
- "version": "0.1.59",
6
+ "version": "0.1.61",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "scripts": {
@@ -17,7 +17,7 @@
17
17
  "storybook:build": "npm run analyze -- --exclude dist && build-storybook"
18
18
  },
19
19
  "dependencies": {
20
- "@progressive-development/pd-forms": "^0.2.12",
20
+ "@progressive-development/pd-forms": "^0.2.13",
21
21
  "@progressive-development/pd-shared-styles": "^0.1.1",
22
22
  "lit": "^2.2.0"
23
23
  },
package/src/PdContact.js CHANGED
@@ -62,11 +62,7 @@
62
62
  return {
63
63
 
64
64
  addressTitle: { type: String },
65
- addressRef: { type: String },
66
- /**
67
- * address type, business (true) or private (false), refactor, ist state internal? => _business, state:true
68
- */
69
- business: { type: Boolean },
65
+ addressRef: { type: String },
70
66
  /**
71
67
  * summary (true) or view (false) contact data
72
68
  */
@@ -77,21 +73,32 @@
77
73
  requiredFields: { type: Array },
78
74
  contact: { type: Object },
79
75
  match: { type: Object },
76
+ /**
77
+ * address type, business (true) or private (false), refactor, ist state internal? => _business, state:true
78
+ */
79
+ _business: { type: Boolean, state: true },
80
80
  _errorMap: { type: Object },
81
81
  };
82
82
  }
83
83
 
84
- constructor() {
85
- super();
86
- this.addressTitle = 'Adres';
87
- this.requiredFields = [];
88
- this.summary = false;
89
- this.business = false;
90
- this.match = {};
91
- this._errorMap = new Map();
92
- }
84
+ constructor() {
85
+ super();
86
+ this.addressTitle = 'Adres';
87
+ this.requiredFields = [];
88
+ this.summary = false;
89
+ this.match = {};
90
+ this._business = false;
91
+ this._errorMap = new Map();
92
+ }
93
+
94
+ update(changedProperties) {
95
+ if (changedProperties.has("contact") && this.contact) {
96
+ this._business = this.contact.business;
97
+ }
98
+ super.update(changedProperties);
99
+ }
93
100
 
94
- connectedCallback() {
101
+ connectedCallback() {
95
102
  super.connectedCallback();
96
103
  // add validation event listener
97
104
  this.addEventListener('validate-form', this._validateForm);
@@ -103,13 +110,13 @@
103
110
  this.removeEventListener('validate-form', this._validateForm);
104
111
  }
105
112
 
106
- firstUpdated() {
107
- this.addEventListener('key-pressed', e => {
108
- this._errorMap.set(e.detail.name, '');
109
- super.requestUpdate();
110
- });
113
+ firstUpdated() {
114
+ this.addEventListener('key-pressed', e => {
115
+ this._errorMap.set(e.detail.name, '');
116
+ super.requestUpdate();
117
+ });
111
118
 
112
- // first validation if form is already filled (edit)
119
+ // first validation if form is already filled (edit)
113
120
  if (this.contact) {
114
121
  const detail = {
115
122
  errorMap: new Map()
@@ -118,7 +125,7 @@
118
125
  new CustomEvent("validate-form", {detail})
119
126
  );
120
127
  }
121
- }
128
+ }
122
129
 
123
130
  render() {
124
131
  return html`
@@ -147,7 +154,7 @@
147
154
  </pd-radio-group>
148
155
  </pd-form-row>
149
156
 
150
- ${this.business
157
+ ${this._business
151
158
  ? html`
152
159
  <pd-form-row class="contact-form">
153
160
  <pd-input
@@ -155,6 +162,7 @@
155
162
  class="quarter2"
156
163
  label="Naam onderneming"
157
164
  ?required="${this._isRequired("companyName")}"
165
+ value="${this.contact ? this.contact.companyName : ""}"
158
166
  valueName="companyName"
159
167
  autoCompleteName="organization"
160
168
  ></pd-input>
@@ -165,6 +173,7 @@
165
173
  ?required="${this._isRequired("vatNr")}"
166
174
  field-type="vat"
167
175
  valueName="vatNr"
176
+ value="${this.contact ? this.contact.vatNr : ""}"
168
177
  autoCompleteName="vat"
169
178
  ></pd-input>
170
179
  </pd-form-row>
@@ -319,7 +328,7 @@
319
328
  }
320
329
 
321
330
  _switchAddressType(e) {
322
- this.business = e.detail.name === 'business';
331
+ this._business = e.detail.name === 'business';
323
332
  }
324
333
 
325
334
  _isRequired(field) {
@@ -452,16 +461,16 @@
452
461
  }
453
462
 
454
463
  _setFormData() {
455
- const companyName = this.business
464
+ const companyName = this._business
456
465
  ? this.shadowRoot.getElementById('compNameId').value
457
466
  : undefined;
458
- const vatNr = this.business
467
+ const vatNr = this._business
459
468
  ? this.shadowRoot.getElementById('vatId').value
460
469
  : undefined;
461
- const firstName = this.business
470
+ const firstName = this._business
462
471
  ? undefined
463
472
  : this.shadowRoot.getElementById('firstNameId').value;
464
- const lastName = this.business
473
+ const lastName = this._business
465
474
  ? undefined
466
475
  : this.shadowRoot.getElementById('lastNameId').value;
467
476
  const street = this.shadowRoot.getElementById('streetId').value;
@@ -471,10 +480,10 @@
471
480
  const zip = this.shadowRoot.getElementById('zipId').value;
472
481
  const city = this.shadowRoot.getElementById('cityId').value;
473
482
  const phone1 = this.shadowRoot.getElementById('phoneId').value;
474
- const email = this.shadowRoot.getElementById('mailId').value;
483
+ const email = this.shadowRoot.getElementById('mailId').value;
475
484
 
476
- this.contact = {
477
- business: this.business,
485
+ return {
486
+ business: this._business,
478
487
  companyName,
479
488
  vatNr,
480
489
  firstName,
@@ -487,8 +496,6 @@
487
496
  phone1,
488
497
  email,
489
498
  };
490
-
491
- return {...this.contact};
492
499
  }
493
500
 
494
501
  _getFullName() {
@@ -32,6 +32,24 @@ function TemplateView({summary}) {
32
32
  }}"></pd-contact>`;
33
33
  }
34
34
 
35
+ function TemplateViewBusiness({summary}) {
36
+ console.log(summary);
37
+ return html`
38
+ <h3>View Contact</h3>
39
+ <pd-contact ?summary="${summary}" .contact="${{
40
+ business: true,
41
+ companyName: 'PD Progressive Develpoment',
42
+ vatNr: "DE0123456789",
43
+ street: 'Musterstrasse',
44
+ streetNr: '23b',
45
+ zip: '9040',
46
+ city: 'Gent',
47
+ phone1: '0221 992344234',
48
+ mobil: '0175/9923443',
49
+ email: 'peter@muster.be'
50
+ }}"></pd-contact>`;
51
+ }
52
+
35
53
  export const ContactForm = Template.bind({});
36
54
  ContactForm.args = {
37
55
  };
@@ -45,3 +63,8 @@ export const ContactPreparedForm = TemplateView.bind({});
45
63
  ContactView.args = {
46
64
  summary: "false"
47
65
  };
66
+
67
+ export const ContactPreparedFormCompany = TemplateViewBusiness.bind({});
68
+ ContactView.args = {
69
+ summary: "false"
70
+ };