inviton-powerduck 0.0.185 → 0.0.186

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.
@@ -14,12 +14,52 @@ import FormItemWrapper from '../form/form-item-wrapper';
14
14
  import NotificationProvider from '../ui/notification';
15
15
 
16
16
  interface PhotoManagerArgs {
17
+ /**
18
+ * The photos to manage
19
+ */
17
20
  photos: Photo[];
21
+
22
+ /**
23
+ * Whether to show the upload button
24
+ */
18
25
  showUploadButton?: boolean;
26
+
27
+ /**
28
+ * The URL to upload photos to
29
+ */
19
30
  uploadUrl?: string;
31
+
32
+ /**
33
+ * The URL where photos are stored
34
+ */
20
35
  photosUrl?: string;
36
+
37
+ /**
38
+ * Whether at least one photo is mandatory
39
+ */
21
40
  mandatory?: boolean;
22
- changed: (args: { action: 'addition' | 'removal' }) => void;
41
+
42
+ /**
43
+ * Key in server response where file data is located after upload
44
+ */
45
+ responseFileKey?: string;
46
+
47
+ /**
48
+ * Called when the photo collection has changed
49
+ */
50
+ changed: (args: PhotoManagerChangedArgs) => void;
51
+ }
52
+
53
+ interface PhotoManagerChangedArgs {
54
+ /**
55
+ * The action that occurred
56
+ */
57
+ action: 'addition' | 'removal';
58
+
59
+ /**
60
+ * The current photos
61
+ */
62
+ photos: Photo[];
23
63
  }
24
64
 
25
65
  class PhotoManagerUberModel extends Photo {
@@ -28,10 +68,6 @@ class PhotoManagerUberModel extends Photo {
28
68
  SortOrder: number = null;
29
69
  }
30
70
 
31
- class TsxComponentExtended<P> extends TsxComponentExtendedBase<P> {
32
-
33
- }
34
-
35
71
  const rootValidations: ValidationRuleset<PhotoManagerComponent> = {
36
72
  photos: new ValidationBuilder().customRule('atLeastOnePhoto', function (this: PhotoManagerComponent) {
37
73
  if (this.mandatory == true) {
@@ -43,13 +79,14 @@ const rootValidations: ValidationRuleset<PhotoManagerComponent> = {
43
79
  };
44
80
 
45
81
  @Component({ validations: rootValidations })
46
- class PhotoManagerComponent extends TsxComponentExtended<PhotoManagerArgs> implements PhotoManagerArgs {
82
+ class PhotoManagerComponent extends TsxComponentExtendedBase<PhotoManagerArgs> implements PhotoManagerArgs {
47
83
  @Prop() photos!: Photo[];
48
84
  @Prop() mandatory?: boolean;
49
85
  @Prop() uploadUrl!: string;
50
86
  @Prop() photosUrl!: string;
51
87
  @Prop() showUploadButton!: boolean;
52
- @Prop() changed!: (args: { action: 'addition' | 'removal' }) => void;
88
+ @Prop() responseFileKey?: string;
89
+ @Prop() changed!: (args: PhotoManagerChangedArgs) => void;
53
90
 
54
91
  translateItems(): DropzoneGalleryItem[] {
55
92
  if (isNullOrEmpty(this.photos)) {
@@ -68,22 +105,16 @@ class PhotoManagerComponent extends TsxComponentExtended<PhotoManagerArgs> imple
68
105
  }
69
106
 
70
107
  parseServerResponse(resp): DropzoneGalleryItem {
71
- if (resp.fileData == null) {
72
- throw new Error('break');
108
+ const key = this.responseFileKey || 'fileData';
109
+ if (resp[key] == null) {
110
+ throw new Error(`Invalid server response, missing key ${key}`);
73
111
  }
74
112
 
75
- const retVal: PhotoManagerUberModel = resp.fileData;
76
- retVal.Id = resp.fileData.id;
77
- retVal.ImageUrl = this.getFullPath(resp.fileData);
113
+ const retVal: PhotoManagerUberModel = resp[key];
114
+ retVal.Id = retVal.id;
115
+ retVal.ImageUrl = this.getFullPath(retVal);
78
116
  retVal.SortOrder = this.photos.length + 1;
79
117
  return retVal;
80
- // console.log(resp.fileData);
81
-
82
- // return {
83
- // Id: resp.fileData.id,
84
- // ImageUrl: this.getFullPath(resp.fileData),
85
- // SortOrder: this.photos.length + 1,
86
- // };
87
118
  }
88
119
 
89
120
  render(h) {
@@ -124,7 +155,10 @@ class PhotoManagerComponent extends TsxComponentExtended<PhotoManagerArgs> imple
124
155
  }}
125
156
  removedFile={(item) => {
126
157
  if (this.changed != null) {
127
- this.changed({ action: 'removal' });
158
+ this.changed({
159
+ action: 'removal',
160
+ photos: this.photos,
161
+ });
128
162
  }
129
163
  }}
130
164
  changed={(items) => {
@@ -141,7 +175,10 @@ class PhotoManagerComponent extends TsxComponentExtended<PhotoManagerArgs> imple
141
175
  }
142
176
 
143
177
  if (this.changed != null) {
144
- this.changed({ action: 'addition' });
178
+ this.changed({
179
+ action: 'addition',
180
+ photos: this.photos,
181
+ });
145
182
  }
146
183
  }}
147
184
  />
@@ -1,6 +1,6 @@
1
- export const SKILIFT_SVG: string = `
2
- <svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="512.000000pt" height="512.000000pt" viewBox="0 0 512.000000 512.000000" preserveAspectRatio="xMidYMid meet">
3
- <g transform="translate(0.000000,512.000000) scale(0.100000,-0.100000)" fill="currentColor" stroke="none">
4
- <path d="M3911 4254 l-1153 -354 -40 34 c-77 66 -211 76 -290 20 -57 -40 -107 -107 -114 -153 l-6 -38 -1127 -345 -1126 -345 -3 -103 c-2 -94 -1 -102 15 -98 10 3 529 161 1154 353 l1135 347 43 -28 42 -29 -5 -55 c-2 -30 -21 -279 -42 -552 l-38 -498 -360 0 c-200 0 -390 -5 -426 -11 -173 -27 -319 -153 -371 -320 -18 -56 -19 -99 -19 -594 0 -495 1 -538 19 -594 50 -161 183 -281 350 -317 98 -20 1924 -20 2022 0 167 36 300 156 350 317 18 56 19 99 19 588 0 444 -2 536 -16 586 -44 170 -197 307 -374 335 -36 5 -227 10 -426 10 l-360 0 -38 498 c-21 273 -40 522 -43 552 -5 53 -4 56 25 73 40 23 72 69 93 131 l17 49 153 48 c85 26 309 95 499 153 852 260 1595 488 1598 490 1 2 1 48 0 103 l-3 100 -1154 -353z m-1913 -2666 l2 -358 -260 0 -260 0 0 353 c0 195 3 357 7 361 4 3 119 5 257 4 l251 -3 3 -357z m820 0 l2 -358 -260 0 -260 0 0 353 c0 195 3 357 7 361 4 3 119 5 257 4 l251 -3 3 -357z m820 0 l2 -358 -260 0 -260 0 0 353 c0 195 3 357 7 361 4 3 119 5 257 4 l251 -3 3 -357z"/>
5
- </g>
6
- </svg>`;
1
+ export const SKILIFT_SVG: string = `
2
+ <svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="512.000000pt" height="512.000000pt" viewBox="0 0 512.000000 512.000000" preserveAspectRatio="xMidYMid meet">
3
+ <g transform="translate(0.000000,512.000000) scale(0.100000,-0.100000)" fill="currentColor" stroke="none">
4
+ <path d="M3911 4254 l-1153 -354 -40 34 c-77 66 -211 76 -290 20 -57 -40 -107 -107 -114 -153 l-6 -38 -1127 -345 -1126 -345 -3 -103 c-2 -94 -1 -102 15 -98 10 3 529 161 1154 353 l1135 347 43 -28 42 -29 -5 -55 c-2 -30 -21 -279 -42 -552 l-38 -498 -360 0 c-200 0 -390 -5 -426 -11 -173 -27 -319 -153 -371 -320 -18 -56 -19 -99 -19 -594 0 -495 1 -538 19 -594 50 -161 183 -281 350 -317 98 -20 1924 -20 2022 0 167 36 300 156 350 317 18 56 19 99 19 588 0 444 -2 536 -16 586 -44 170 -197 307 -374 335 -36 5 -227 10 -426 10 l-360 0 -38 498 c-21 273 -40 522 -43 552 -5 53 -4 56 25 73 40 23 72 69 93 131 l17 49 153 48 c85 26 309 95 499 153 852 260 1595 488 1598 490 1 2 1 48 0 103 l-3 100 -1154 -353z m-1913 -2666 l2 -358 -260 0 -260 0 0 353 c0 195 3 357 7 361 4 3 119 5 257 4 l251 -3 3 -357z m820 0 l2 -358 -260 0 -260 0 0 353 c0 195 3 357 7 361 4 3 119 5 257 4 l251 -3 3 -357z m820 0 l2 -358 -260 0 -260 0 0 353 c0 195 3 357 7 361 4 3 119 5 257 4 l251 -3 3 -357z"/>
5
+ </g>
6
+ </svg>`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "inviton-powerduck",
3
3
  "type": "module",
4
- "version": "0.0.185",
4
+ "version": "0.0.186",
5
5
  "files": [
6
6
  "app/",
7
7
  "common/",