@sumaris-net/ngx-components 1.22.11-rc16 → 1.22.11-rc19

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.
Files changed (48) hide show
  1. package/bundles/sumaris-net.ngx-components.umd.js +1350 -641
  2. package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
  3. package/bundles/sumaris-net.ngx-components.umd.min.js +2 -2
  4. package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
  5. package/doc/build.md +2 -2
  6. package/esm2015/public_api.js +11 -4
  7. package/esm2015/src/app/core/services/account.service.js +2 -2
  8. package/esm2015/src/app/core/table/entities-table-datasource.class.js +3 -2
  9. package/esm2015/src/app/shared/file/file.service.js +20 -19
  10. package/esm2015/src/app/shared/file/images.utils.js +166 -0
  11. package/esm2015/src/app/shared/image/gallery/image-gallery.component.js +160 -0
  12. package/esm2015/src/app/shared/image/gallery/image-gallery.module.js +29 -0
  13. package/esm2015/src/app/shared/image/gallery/testing/gallery.service.testing.js +92 -0
  14. package/esm2015/src/app/shared/image/gallery/testing/gallery.testing.js +31 -0
  15. package/esm2015/src/app/shared/image/gallery/testing/gallery.testing.module.js +38 -0
  16. package/esm2015/src/app/shared/image/image.module.js +36 -0
  17. package/esm2015/src/app/shared/image/image.service.js +208 -0
  18. package/esm2015/src/app/shared/shared.module.js +1 -1
  19. package/esm2015/src/app/shared/shared.testing.module.js +9 -3
  20. package/esm2015/src/app/social/job/job.service.js +2 -2
  21. package/esm2015/src/app/social/user-event/testing/user-event.testing.model.js +5 -1
  22. package/esm2015/src/app/social/user-event/testing/user-event.testing.service.js +7 -3
  23. package/esm2015/src/app/social/user-event/user-event.model.js +1 -1
  24. package/esm2015/src/app/social/user-event/user-event.service.js +22 -16
  25. package/esm2015/src/environments/environment.js +5 -1
  26. package/esm2015/sumaris-net.ngx-components.js +2 -2
  27. package/fesm2015/sumaris-net.ngx-components.js +1855 -1281
  28. package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
  29. package/package.json +13 -6
  30. package/public_api.d.ts +10 -3
  31. package/src/app/shared/file/file.service.d.ts +5 -5
  32. package/src/app/shared/file/images.utils.d.ts +19 -0
  33. package/src/app/shared/image/gallery/image-gallery.component.d.ts +42 -0
  34. package/src/app/shared/image/gallery/image-gallery.module.d.ts +2 -0
  35. package/src/app/shared/image/gallery/testing/gallery.service.testing.d.ts +30 -0
  36. package/src/app/shared/image/gallery/testing/gallery.testing.d.ts +13 -0
  37. package/src/app/shared/image/gallery/testing/gallery.testing.module.d.ts +2 -0
  38. package/src/app/shared/image/image.module.d.ts +4 -0
  39. package/src/app/shared/image/image.service.d.ts +46 -0
  40. package/src/app/social/user-event/testing/user-event.testing.model.d.ts +1 -0
  41. package/src/app/social/user-event/testing/user-event.testing.service.d.ts +2 -1
  42. package/src/app/social/user-event/user-event.model.d.ts +3 -2
  43. package/src/app/social/user-event/user-event.service.d.ts +13 -11
  44. package/src/assets/i18n/fr.json +7 -0
  45. package/sumaris-net.ngx-components.d.ts +1 -1
  46. package/sumaris-net.ngx-components.metadata.json +1 -1
  47. package/esm2015/src/app/shared/file/base64-image-reader.js +0 -141
  48. package/src/app/shared/file/base64-image-reader.d.ts +0 -18
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/cdk/table'), require('@angular/cdk/a11y'), require('@angular/cdk/overlay'), require('@angular/cdk/scrolling'), require('@angular/material/core'), require('@angular/material/table'), require('@angular/material/sort'), require('@angular/material/paginator'), require('@angular/material/form-field'), require('@angular/material/input'), require('@angular/material/checkbox'), require('@angular/material/expansion'), require('@angular/material/toolbar'), require('@angular/material/icon'), require('@angular/material/button'), require('@angular/material/menu'), require('@angular/material/select'), require('@angular/material/card'), require('@angular/material/tabs'), require('@angular/material/stepper'), require('@angular/material/list'), require('@angular/material/button-toggle'), require('@angular/material/progress-spinner'), require('@angular/material/progress-bar'), require('@angular/material/radio'), require('@angular/material/badge'), require('@angular/material/slide-toggle'), require('@angular/material/dialog'), require('@angular/material/autocomplete'), require('@angular/forms'), require('rxjs'), require('rxjs/operators'), require('@angular/animations'), require('@ngx-translate/core'), require('@ionic/angular'), require('moment'), require('@angular/material-moment-adapter'), require('@ionic-native/keyboard/ngx'), require('angular2-text-mask'), require('ngx-material-timepicker'), require('@angular/material/datepicker'), require('@angular/material/divider'), require('@angular/material/tooltip'), require('@angular/material/chips'), require('@angular/router'), require('@angular/platform-browser'), require('@angular/common/http'), require('ngx-color-picker'), require('@ionic-native/native-audio/ngx'), require('@ionic-native/vibration/ngx'), require('@ionic-native/audio-management/ngx'), require('@ionic-native/native-audio/ngx/index'), require('@ionic-native/vibration/ngx/index'), require('@ionic-native/audio-management/ngx/index'), require('uuid/v4'), require('@angular/cdk/drag-drop'), require('ngx-markdown'), require('tweetnacl'), require('@ionic/storage'), require('zone.js/dist/zone-error'), require('@ionic-native/splash-screen/ngx'), require('@ionic-native/network/ngx'), require('ionic-cache'), require('ionic-cache/dist/cache.service'), require('@ionic-native/network/ngx/index'), require('@ionic-native/splash-screen/ngx/index'), require('@ionic-native/status-bar/ngx'), require('@angular/cdk/platform'), require('@ionic-native/in-app-browser/ngx'), require('@apollo/client/core'), require('apollo-angular'), require('@apollo/client/link/ws'), require('@apollo/client/utilities'), require('@apollo/client/link/retry'), require('apollo-link-queue'), require('apollo-link-serialize'), require('apollo-link-logger'), require('apollo-angular/http'), require('apollo3-cache-persist'), require('@ionic-native/downloader/ngx'), require('@ionic-native/status-bar/ngx/index'), require('@ionic-native/keyboard/ngx/index'), require('@ionic-native/in-app-browser/ngx/index'), require('@ionic-native/downloader/ngx/index'), require('@angular/cdk/text-field'), require('@e-is/ngx-material-table'), require('@angular/cdk/collections'), require('ngx-jdenticon'), require('tweetnacl-util'), require('scrypt-async'), require('hammerjs'), require('moment-timezone')) :
3
- typeof define === 'function' && define.amd ? define('@sumaris-net/ngx-components', ['exports', '@angular/core', '@angular/common', '@angular/cdk/table', '@angular/cdk/a11y', '@angular/cdk/overlay', '@angular/cdk/scrolling', '@angular/material/core', '@angular/material/table', '@angular/material/sort', '@angular/material/paginator', '@angular/material/form-field', '@angular/material/input', '@angular/material/checkbox', '@angular/material/expansion', '@angular/material/toolbar', '@angular/material/icon', '@angular/material/button', '@angular/material/menu', '@angular/material/select', '@angular/material/card', '@angular/material/tabs', '@angular/material/stepper', '@angular/material/list', '@angular/material/button-toggle', '@angular/material/progress-spinner', '@angular/material/progress-bar', '@angular/material/radio', '@angular/material/badge', '@angular/material/slide-toggle', '@angular/material/dialog', '@angular/material/autocomplete', '@angular/forms', 'rxjs', 'rxjs/operators', '@angular/animations', '@ngx-translate/core', '@ionic/angular', 'moment', '@angular/material-moment-adapter', '@ionic-native/keyboard/ngx', 'angular2-text-mask', 'ngx-material-timepicker', '@angular/material/datepicker', '@angular/material/divider', '@angular/material/tooltip', '@angular/material/chips', '@angular/router', '@angular/platform-browser', '@angular/common/http', 'ngx-color-picker', '@ionic-native/native-audio/ngx', '@ionic-native/vibration/ngx', '@ionic-native/audio-management/ngx', '@ionic-native/native-audio/ngx/index', '@ionic-native/vibration/ngx/index', '@ionic-native/audio-management/ngx/index', 'uuid/v4', '@angular/cdk/drag-drop', 'ngx-markdown', 'tweetnacl', '@ionic/storage', 'zone.js/dist/zone-error', '@ionic-native/splash-screen/ngx', '@ionic-native/network/ngx', 'ionic-cache', 'ionic-cache/dist/cache.service', '@ionic-native/network/ngx/index', '@ionic-native/splash-screen/ngx/index', '@ionic-native/status-bar/ngx', '@angular/cdk/platform', '@ionic-native/in-app-browser/ngx', '@apollo/client/core', 'apollo-angular', '@apollo/client/link/ws', '@apollo/client/utilities', '@apollo/client/link/retry', 'apollo-link-queue', 'apollo-link-serialize', 'apollo-link-logger', 'apollo-angular/http', 'apollo3-cache-persist', '@ionic-native/downloader/ngx', '@ionic-native/status-bar/ngx/index', '@ionic-native/keyboard/ngx/index', '@ionic-native/in-app-browser/ngx/index', '@ionic-native/downloader/ngx/index', '@angular/cdk/text-field', '@e-is/ngx-material-table', '@angular/cdk/collections', 'ngx-jdenticon', 'tweetnacl-util', 'scrypt-async', 'hammerjs', 'moment-timezone'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['sumaris-net'] = global['sumaris-net'] || {}, global['sumaris-net']['ngx-components'] = {}), global.ng.core, global.ng.common, global.ng.cdk.table, global.ng.cdk.a11y, global.ng.cdk.overlay, global.ng.cdk.scrolling, global.ng.material.core, global.ng.material.table, global.ng.material.sort, global.ng.material.paginator, global.ng.material.formField, global.ng.material.input, global.ng.material.checkbox, global.ng.material.expansion, global.ng.material.toolbar, global.ng.material.icon, global.ng.material.button, global.ng.material.menu, global.ng.material.select, global.ng.material.card, global.ng.material.tabs, global.ng.material.stepper, global.ng.material.list, global.ng.material.buttonToggle, global.ng.material.progressSpinner, global.ng.material.progressBar, global.ng.material.radio, global.ng.material.badge, global.ng.material.slideToggle, global.ng.material.dialog, global.ng.material.autocomplete, global.ng.forms, global.rxjs, global.rxjs.operators, global.ng.animations, global['ngx-translate'].core, global.ionic.angular, global.moment, global.ng.materialMomentAdapter, global['ionic-native'].keyboard.ngx, global['angular2-text-mask'], global['ngx-material-timepicker'], global.ng.material.datepicker, global.ng.material.divider, global.ng.material.tooltip, global.ng.material.chips, global.ng.router, global.ng.platformBrowser, global.ng.common.http, global['ngx-color-picker'], global['ionic-native']['native-audio'].ngx, global['ionic-native'].vibration.ngx, global['ionic-native']['audio-management'].ngx, global['ionic-native']['native-audio'].ngx.index, global['ionic-native'].vibration.ngx.index, global['ionic-native']['audio-management'].ngx.index, global.uuid.v4, global.ng.cdk.dragDrop, global['ngx-markdown'], global.tweetnacl, global.ionic.storage, null, global['ionic-native']['splash-screen'].ngx, global['ionic-native'].network.ngx, global['ionic-cache'], global['ionic-cache/dist/cache'].service, global['ionic-native'].network.ngx.index, global['ionic-native']['splash-screen'].ngx.index, global['ionic-native']['status-bar'].ngx, global.ng.cdk.platform, global['ionic-native']['in-app-browser'].ngx, global.apollo.client.core, global['apollo-angular'], global.apollo.client.link.ws, global.apollo.client.utilities, global.apollo.client.link.retry, global['apollo-link-queue'], global['apollo-link-serialize'], global['apollo-link-logger'], global['apollo-angular'].http, global['apollo3-cache-persist'], global['ionic-native'].downloader.ngx, global['ionic-native']['status-bar'].ngx.index, global['ionic-native'].keyboard.ngx.index, global['ionic-native']['in-app-browser'].ngx.index, global['ionic-native'].downloader.ngx.index, global.ng.cdk.textField, global['e-is']['ngx-material-table'], global.ng.cdk.collections, global['ngx-jdenticon'], null, null, null, global['moment-timezone']));
5
- }(this, (function (exports, i0, i1$4, table$1, a11y, overlay, scrolling, i1$3, table, sort$1, paginator, formField, input, checkbox, expansion, toolbar, icon, button, menu, select, card, tabs, stepper, list, buttonToggle, progressSpinner, progressBar, radio, badge, slideToggle, i2, autocomplete, i1, rxjs, operators, animations, i1$2, i1$5, momentImported, i1$1, ngx, angular2TextMask, ngxMaterialTimepicker, datepicker, divider, tooltip, chips, i3, i1$6, i2$1, ngxColorPicker, ngx$2, ngx$3, ngx$1, i2$2, i3$1, i4, uuidv4Imported, dragDrop, ngxMarkdown, tweetnacl, i3$2, zoneError, ngx$5, ngx$4, ionicCache, i6, i9, i10, ngx$7, i2$4, ngx$8, core, i2$3, ws, utilities, retry, QueueLink, SerializingLink, loggerLink, i3$3, apollo3CachePersist, ngx$6, i14, i15, i17, i18, textField, ngxMaterialTable, collections, ngxJdenticon, tweetnaclUtil, scryptAsync, hammerjs, momentTZImported) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/cdk/table'), require('@angular/cdk/a11y'), require('@angular/cdk/overlay'), require('@angular/cdk/scrolling'), require('@angular/material/core'), require('@angular/material/table'), require('@angular/material/sort'), require('@angular/material/paginator'), require('@angular/material/form-field'), require('@angular/material/input'), require('@angular/material/checkbox'), require('@angular/material/expansion'), require('@angular/material/toolbar'), require('@angular/material/icon'), require('@angular/material/button'), require('@angular/material/menu'), require('@angular/material/select'), require('@angular/material/card'), require('@angular/material/tabs'), require('@angular/material/stepper'), require('@angular/material/list'), require('@angular/material/button-toggle'), require('@angular/material/progress-spinner'), require('@angular/material/progress-bar'), require('@angular/material/radio'), require('@angular/material/badge'), require('@angular/material/slide-toggle'), require('@angular/material/dialog'), require('@angular/material/autocomplete'), require('@angular/forms'), require('rxjs'), require('rxjs/operators'), require('@angular/animations'), require('@ngx-translate/core'), require('@ionic/angular'), require('moment'), require('@angular/material-moment-adapter'), require('@ionic-native/keyboard/ngx'), require('angular2-text-mask'), require('ngx-material-timepicker'), require('@angular/material/datepicker'), require('@angular/material/divider'), require('@angular/material/tooltip'), require('@angular/material/chips'), require('@angular/router'), require('@angular/platform-browser'), require('@angular/common/http'), require('ngx-color-picker'), require('@ionic-native/native-audio/ngx'), require('@ionic-native/vibration/ngx'), require('@ionic-native/audio-management/ngx'), require('@ionic-native/native-audio/ngx/index'), require('@ionic-native/vibration/ngx/index'), require('@ionic-native/audio-management/ngx/index'), require('uuid/v4'), require('@angular/cdk/drag-drop'), require('ngx-markdown'), require('tweetnacl'), require('@ionic/storage'), require('zone.js/dist/zone-error'), require('@ionic-native/splash-screen/ngx'), require('@ionic-native/network/ngx'), require('ionic-cache'), require('ionic-cache/dist/cache.service'), require('@ionic-native/network/ngx/index'), require('@ionic-native/splash-screen/ngx/index'), require('@ionic-native/status-bar/ngx'), require('@angular/cdk/platform'), require('@ionic-native/in-app-browser/ngx'), require('@apollo/client/core'), require('apollo-angular'), require('@apollo/client/link/ws'), require('@apollo/client/utilities'), require('@apollo/client/link/retry'), require('apollo-link-queue'), require('apollo-link-serialize'), require('apollo-link-logger'), require('apollo-angular/http'), require('apollo3-cache-persist'), require('@ionic-native/downloader/ngx'), require('@ionic-native/status-bar/ngx/index'), require('@ionic-native/keyboard/ngx/index'), require('@ionic-native/in-app-browser/ngx/index'), require('@ionic-native/downloader/ngx/index'), require('@ionic-native/image-picker/ngx'), require('@ionic-native/media-capture/ngx'), require('@ionic-native/photo-viewer/ngx'), require('@ionic-native/image-picker/ngx/index'), require('@ionic-native/photo-viewer/ngx/index'), require('@ionic-native/media-capture/ngx/index'), require('@angular/cdk/collections'), require('@e-is/ngx-material-table'), require('ngx-jdenticon'), require('@angular/cdk/text-field'), require('tweetnacl-util'), require('scrypt-async'), require('hammerjs'), require('moment-timezone')) :
3
+ typeof define === 'function' && define.amd ? define('@sumaris-net/ngx-components', ['exports', '@angular/core', '@angular/common', '@angular/cdk/table', '@angular/cdk/a11y', '@angular/cdk/overlay', '@angular/cdk/scrolling', '@angular/material/core', '@angular/material/table', '@angular/material/sort', '@angular/material/paginator', '@angular/material/form-field', '@angular/material/input', '@angular/material/checkbox', '@angular/material/expansion', '@angular/material/toolbar', '@angular/material/icon', '@angular/material/button', '@angular/material/menu', '@angular/material/select', '@angular/material/card', '@angular/material/tabs', '@angular/material/stepper', '@angular/material/list', '@angular/material/button-toggle', '@angular/material/progress-spinner', '@angular/material/progress-bar', '@angular/material/radio', '@angular/material/badge', '@angular/material/slide-toggle', '@angular/material/dialog', '@angular/material/autocomplete', '@angular/forms', 'rxjs', 'rxjs/operators', '@angular/animations', '@ngx-translate/core', '@ionic/angular', 'moment', '@angular/material-moment-adapter', '@ionic-native/keyboard/ngx', 'angular2-text-mask', 'ngx-material-timepicker', '@angular/material/datepicker', '@angular/material/divider', '@angular/material/tooltip', '@angular/material/chips', '@angular/router', '@angular/platform-browser', '@angular/common/http', 'ngx-color-picker', '@ionic-native/native-audio/ngx', '@ionic-native/vibration/ngx', '@ionic-native/audio-management/ngx', '@ionic-native/native-audio/ngx/index', '@ionic-native/vibration/ngx/index', '@ionic-native/audio-management/ngx/index', 'uuid/v4', '@angular/cdk/drag-drop', 'ngx-markdown', 'tweetnacl', '@ionic/storage', 'zone.js/dist/zone-error', '@ionic-native/splash-screen/ngx', '@ionic-native/network/ngx', 'ionic-cache', 'ionic-cache/dist/cache.service', '@ionic-native/network/ngx/index', '@ionic-native/splash-screen/ngx/index', '@ionic-native/status-bar/ngx', '@angular/cdk/platform', '@ionic-native/in-app-browser/ngx', '@apollo/client/core', 'apollo-angular', '@apollo/client/link/ws', '@apollo/client/utilities', '@apollo/client/link/retry', 'apollo-link-queue', 'apollo-link-serialize', 'apollo-link-logger', 'apollo-angular/http', 'apollo3-cache-persist', '@ionic-native/downloader/ngx', '@ionic-native/status-bar/ngx/index', '@ionic-native/keyboard/ngx/index', '@ionic-native/in-app-browser/ngx/index', '@ionic-native/downloader/ngx/index', '@ionic-native/image-picker/ngx', '@ionic-native/media-capture/ngx', '@ionic-native/photo-viewer/ngx', '@ionic-native/image-picker/ngx/index', '@ionic-native/photo-viewer/ngx/index', '@ionic-native/media-capture/ngx/index', '@angular/cdk/collections', '@e-is/ngx-material-table', 'ngx-jdenticon', '@angular/cdk/text-field', 'tweetnacl-util', 'scrypt-async', 'hammerjs', 'moment-timezone'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['sumaris-net'] = global['sumaris-net'] || {}, global['sumaris-net']['ngx-components'] = {}), global.ng.core, global.ng.common, global.ng.cdk.table, global.ng.cdk.a11y, global.ng.cdk.overlay, global.ng.cdk.scrolling, global.ng.material.core, global.ng.material.table, global.ng.material.sort, global.ng.material.paginator, global.ng.material.formField, global.ng.material.input, global.ng.material.checkbox, global.ng.material.expansion, global.ng.material.toolbar, global.ng.material.icon, global.ng.material.button, global.ng.material.menu, global.ng.material.select, global.ng.material.card, global.ng.material.tabs, global.ng.material.stepper, global.ng.material.list, global.ng.material.buttonToggle, global.ng.material.progressSpinner, global.ng.material.progressBar, global.ng.material.radio, global.ng.material.badge, global.ng.material.slideToggle, global.ng.material.dialog, global.ng.material.autocomplete, global.ng.forms, global.rxjs, global.rxjs.operators, global.ng.animations, global['ngx-translate'].core, global.ionic.angular, global.moment, global.ng.materialMomentAdapter, global['ionic-native'].keyboard.ngx, global['angular2-text-mask'], global['ngx-material-timepicker'], global.ng.material.datepicker, global.ng.material.divider, global.ng.material.tooltip, global.ng.material.chips, global.ng.router, global.ng.platformBrowser, global.ng.common.http, global['ngx-color-picker'], global['ionic-native']['native-audio'].ngx, global['ionic-native'].vibration.ngx, global['ionic-native']['audio-management'].ngx, global['ionic-native']['native-audio'].ngx.index, global['ionic-native'].vibration.ngx.index, global['ionic-native']['audio-management'].ngx.index, global.uuid.v4, global.ng.cdk.dragDrop, global['ngx-markdown'], global.tweetnacl, global.ionic.storage, null, global['ionic-native']['splash-screen'].ngx, global['ionic-native'].network.ngx, global['ionic-cache'], global['ionic-cache/dist/cache'].service, global['ionic-native'].network.ngx.index, global['ionic-native']['splash-screen'].ngx.index, global['ionic-native']['status-bar'].ngx, global.ng.cdk.platform, global['ionic-native']['in-app-browser'].ngx, global.apollo.client.core, global['apollo-angular'], global.apollo.client.link.ws, global.apollo.client.utilities, global.apollo.client.link.retry, global['apollo-link-queue'], global['apollo-link-serialize'], global['apollo-link-logger'], global['apollo-angular'].http, global['apollo3-cache-persist'], global['ionic-native'].downloader.ngx, global['ionic-native']['status-bar'].ngx.index, global['ionic-native'].keyboard.ngx.index, global['ionic-native']['in-app-browser'].ngx.index, global['ionic-native'].downloader.ngx.index, global.ngx$9, global.ngx$b, global.ngx$a, global.i5, global.i6$1, global.i7, global.ng.cdk.collections, global['e-is']['ngx-material-table'], global['ngx-jdenticon'], global.ng.cdk.textField, null, null, null, global['moment-timezone']));
5
+ }(this, (function (exports, i0, i1$4, table$1, a11y, overlay, scrolling, i1$3, table, sort$1, paginator, formField, input, checkbox, expansion, toolbar, icon, button, menu, select, card, tabs, stepper, list, buttonToggle, progressSpinner, progressBar, radio, badge, slideToggle, i2, autocomplete, i1, rxjs, operators, animations, i1$2, i1$5, momentImported, i1$1, ngx, angular2TextMask, ngxMaterialTimepicker, datepicker, divider, tooltip, chips, i3, i1$6, i2$1, ngxColorPicker, ngx$2, ngx$3, ngx$1, i2$2, i3$1, i4, uuidv4Imported, dragDrop, ngxMarkdown, tweetnacl, i3$2, zoneError, ngx$5, ngx$4, ionicCache, i6, i9, i10, ngx$7, i2$4, ngx$8, core, i2$3, ws, utilities, retry, QueueLink, SerializingLink, loggerLink, i3$3, apollo3CachePersist, ngx$6, i14, i15, i17, i18, ngx$9, ngx$b, ngx$a, i5, i6$1, i7, collections, ngxMaterialTable, ngxJdenticon, textField, tweetnaclUtil, scryptAsync, hammerjs, momentTZImported) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -10553,44 +10553,97 @@
10553
10553
  },] }
10554
10554
  ];
10555
10555
 
10556
+ var UploadFile = /** @class */ (function (_super) {
10557
+ __extends(UploadFile, _super);
10558
+ function UploadFile() {
10559
+ return _super !== null && _super.apply(this, arguments) || this;
10560
+ }
10561
+ return UploadFile;
10562
+ }(File));
10563
+ var FileResponse = /** @class */ (function () {
10564
+ function FileResponse(init) {
10565
+ this.type = i2$1.HttpEventType.Response;
10566
+ this.body = isNotNil(init === null || init === void 0 ? void 0 : init.body) ? init.body : null;
10567
+ this.status = (init === null || init === void 0 ? void 0 : init.status) || 0;
10568
+ this.statusText = (init === null || init === void 0 ? void 0 : init.statusText) || 'OK';
10569
+ }
10570
+ return FileResponse;
10571
+ }());
10572
+ function isProgressEvent(event) {
10573
+ return event && (event.type === i2$1.HttpEventType.UploadProgress
10574
+ || event.type === i2$1.HttpEventType.DownloadProgress);
10575
+ }
10576
+ function isResponseEvent(event) {
10577
+ return event && event.type === i2$1.HttpEventType.Response;
10578
+ }
10579
+
10556
10580
  var IMAGE_DEFAULTS = {
10557
10581
  MAX_HEIGHT: 480,
10558
10582
  MAX_WIDTH: 640,
10559
10583
  THUMB_MAX_HEIGHT: 200,
10560
10584
  THUMB_MAX_WIDTH: 200
10561
10585
  };
10562
- var Base64ImageReader = /** @class */ (function () {
10563
- function Base64ImageReader() {
10586
+ // @dynamic
10587
+ var ImagesUtils = /** @class */ (function () {
10588
+ function ImagesUtils() {
10564
10589
  }
10565
- Base64ImageReader.prototype.readFromBlob = function (file) {
10566
- return __awaiter(this, void 0, void 0, function () {
10567
- var dataUrl;
10568
- return __generator(this, function (_a) {
10569
- switch (_a.label) {
10570
- case 0:
10571
- if (!file)
10572
- throw new Error('Illegal argument: missing file');
10573
- return [4 /*yield*/, new Promise(function (resolve, reject) {
10574
- var reader = new FileReader();
10575
- reader.addEventListener('load', function (event) { return resolve(reader.result); }, false);
10576
- reader.readAsDataURL(file);
10577
- })];
10578
- case 1:
10579
- dataUrl = _a.sent();
10580
- return [2 /*return*/, dataUrl];
10581
- }
10582
- });
10583
- });
10590
+ ImagesUtils.readAsDataURL = function (file, opts) {
10591
+ var _this = this;
10592
+ var $progress = new rxjs.Subject();
10593
+ var reader = new FileReader();
10594
+ // Listen progress
10595
+ reader.onprogress = function (e) {
10596
+ var total = e.total || 1;
10597
+ var loaded = e.total || 0;
10598
+ if (loaded < total)
10599
+ $progress.next({ type: i2$1.HttpEventType.UploadProgress, loaded: loaded, total: total });
10600
+ };
10601
+ // Listen end
10602
+ reader.onloadend = function (e) {
10603
+ var body = reader.result;
10604
+ if (typeof body === 'string') {
10605
+ $progress.next(new FileResponse({ body: body }));
10606
+ $progress.complete();
10607
+ }
10608
+ else {
10609
+ console.error("[image-utils] Cannot read file '" + file.name + "' as text");
10610
+ $progress.error("Cannot read file as text");
10611
+ }
10612
+ };
10613
+ // Listen error
10614
+ reader.onerror = function (event) {
10615
+ console.error('[image-utils] Error while reading file:', event);
10616
+ $progress.error(event);
10617
+ };
10618
+ // Start reading the file
10619
+ reader.readAsDataURL(file);
10620
+ // Resize image, if need
10621
+ if (opts) {
10622
+ return $progress.pipe(operators.mergeMap(function (event) { return __awaiter(_this, void 0, void 0, function () {
10623
+ var body;
10624
+ return __generator(this, function (_a) {
10625
+ switch (_a.label) {
10626
+ case 0:
10627
+ if (!(event instanceof FileResponse)) return [3 /*break*/, 2];
10628
+ return [4 /*yield*/, ImagesUtils.resizeBase64(event.body, opts)];
10629
+ case 1:
10630
+ body = _a.sent();
10631
+ return [2 /*return*/, new FileResponse({ body: body })];
10632
+ case 2: return [2 /*return*/, event];
10633
+ }
10634
+ });
10635
+ }); }));
10636
+ }
10637
+ return $progress.asObservable();
10584
10638
  };
10585
- Base64ImageReader.prototype.readAndResizeFromUrl = function (path, opts) {
10639
+ ImagesUtils.readAndResizeFromUrl = function (fileUrl, opts) {
10586
10640
  return __awaiter(this, void 0, void 0, function () {
10587
10641
  var img, err_1;
10588
- var _this = this;
10589
10642
  return __generator(this, function (_a) {
10590
10643
  switch (_a.label) {
10591
10644
  case 0:
10592
- if (isNilOrBlank(path))
10593
- throw new Error('Illegal argument: missing path');
10645
+ if (isNilOrBlank(fileUrl))
10646
+ throw new Error('Illegal argument: missing fileUrl');
10594
10647
  img = document.createElement('img');
10595
10648
  // Need to avoid CORS error
10596
10649
  // (see https://stackoverflow.com/questions/22710627/tainted-canvases-may-not-be-exported)
@@ -10599,14 +10652,14 @@
10599
10652
  case 1:
10600
10653
  _a.trys.push([1, 3, 4, 5]);
10601
10654
  return [4 /*yield*/, new Promise(function (resolve, reject) {
10602
- img.addEventListener('load', _this.createImageOnLoadResizeFn(resolve, reject, opts), false);
10655
+ img.addEventListener('load', ImagesUtils.createImageOnLoadResizeFn(resolve, reject, opts), false);
10603
10656
  img.addEventListener('error', reject);
10604
- img.src = path;
10657
+ img.src = fileUrl;
10605
10658
  })];
10606
10659
  case 2: return [2 /*return*/, _a.sent()];
10607
10660
  case 3:
10608
10661
  err_1 = _a.sent();
10609
- throw new Error("Failed to load and resize image {" + path + "}");
10662
+ throw new Error("Failed to load and resize image {" + fileUrl + "}");
10610
10663
  case 4:
10611
10664
  img.remove();
10612
10665
  return [7 /*endfinally*/];
@@ -10615,15 +10668,12 @@
10615
10668
  });
10616
10669
  });
10617
10670
  };
10618
- Base64ImageReader.prototype.readAndResizeFromBlob = function (file, opts) {
10671
+ ImagesUtils.resizeBase64 = function (dataUrl, opts) {
10619
10672
  return __awaiter(this, void 0, void 0, function () {
10620
10673
  var img;
10621
- var _this = this;
10622
10674
  return __generator(this, function (_a) {
10623
10675
  switch (_a.label) {
10624
10676
  case 0:
10625
- if (!file)
10626
- throw new Error('Illegal argument: missing file');
10627
10677
  img = document.createElement('img');
10628
10678
  // Need to avoid CORS error
10629
10679
  // (see https://stackoverflow.com/questions/22710627/tainted-canvases-may-not-be-exported)
@@ -10632,13 +10682,9 @@
10632
10682
  case 1:
10633
10683
  _a.trys.push([1, , 3, 4]);
10634
10684
  return [4 /*yield*/, new Promise(function (resolve, reject) {
10635
- var reader = new FileReader();
10636
- reader.addEventListener('load', function (event) {
10637
- // Resize image
10638
- img.onload = _this.createImageOnLoadResizeFn(resolve, reject, opts);
10639
- img.src = reader.result;
10640
- }, false);
10641
- reader.readAsDataURL(file);
10685
+ img.addEventListener('load', ImagesUtils.createImageOnLoadResizeFn(resolve, reject, opts), false);
10686
+ img.addEventListener('error', reject);
10687
+ img.src = dataUrl;
10642
10688
  })];
10643
10689
  case 2: return [2 /*return*/, _a.sent()];
10644
10690
  case 3:
@@ -10649,8 +10695,7 @@
10649
10695
  });
10650
10696
  });
10651
10697
  };
10652
- /* -- protected methods -- */
10653
- Base64ImageReader.prototype.createImageOnLoadResizeFn = function (resolve, reject, opts) {
10698
+ ImagesUtils.createImageOnLoadResizeFn = function (resolve, reject, opts) {
10654
10699
  return function (event) {
10655
10700
  var maxWidth = (opts && opts.thumbnail ? IMAGE_DEFAULTS.THUMB_MAX_WIDTH : (opts && opts.maxWidth || IMAGE_DEFAULTS.MAX_WIDTH));
10656
10701
  var maxHeight = (opts && opts.thumbnail ? IMAGE_DEFAULTS.THUMB_MAX_HEIGHT : (opts && opts.maxHeight || IMAGE_DEFAULTS.MAX_HEIGHT));
@@ -10716,7 +10761,7 @@
10716
10761
  }
10717
10762
  };
10718
10763
  };
10719
- return Base64ImageReader;
10764
+ return ImagesUtils;
10720
10765
  }());
10721
10766
 
10722
10767
  var uuidv4 = uuidv4Imported__namespace;
@@ -10751,28 +10796,28 @@
10751
10796
  var jobsFactories = (sources || []).map(function (source) { return function () { return _this.getImage(source, Object.assign({}, opts)); }; });
10752
10797
  return chainPromises(jobsFactories);
10753
10798
  };
10754
- FileService.prototype.getImage = function (source, opts) {
10799
+ FileService.prototype.getImage = function (fileUrl, opts) {
10755
10800
  return __awaiter(this, void 0, void 0, function () {
10756
- var responseType, debug, now, lastSlashIndex, fileName, targetFilePath, blob, err_1, dataUrl;
10801
+ var outputType, debug, now, lastSlashIndex, fileName, targetFilePath, blob, err_1, dataUrl;
10757
10802
  return __generator(this, function (_a) {
10758
10803
  switch (_a.label) {
10759
10804
  case 0:
10760
- responseType = opts && opts.responseType || (this.canUseFileSystem ? 'file' : 'dataUrl');
10805
+ outputType = opts && opts.outputType || (this.canUseFileSystem ? 'fileUrl' : 'dataUrl');
10761
10806
  debug = this._debug /*&& (!opts || !opts.fileTransfer)*/;
10762
10807
  now = debug && Date.now();
10763
10808
  if (debug)
10764
- console.debug("[file] Fetching image {" + source + "} into " + responseType + "...");
10765
- lastSlashIndex = source.lastIndexOf('/');
10809
+ console.debug("[file] Fetching image {" + fileUrl + "} into " + outputType + "...");
10810
+ lastSlashIndex = fileUrl.lastIndexOf('/');
10766
10811
  if (lastSlashIndex === -1)
10767
- throw new Error('Invalid URL: ' + source);
10768
- fileName = lastSlashIndex < (source.length - 1) && source.substring(lastSlashIndex + 1) || uuidv4();
10769
- if (!(responseType === 'file' && this.canUseFileSystem)) return [3 /*break*/, 4];
10770
- console.warn("WARN: [file] Fetching image {" + source + "} in local file...");
10812
+ throw new Error('Invalid URL: ' + fileUrl);
10813
+ fileName = lastSlashIndex < (fileUrl.length - 1) && fileUrl.substring(lastSlashIndex + 1) || uuidv4();
10814
+ if (!(outputType === 'fileUrl' && this.canUseFileSystem)) return [3 /*break*/, 4];
10815
+ console.warn("WARN: [file] Downloading image {" + fileUrl + "} in local filesystem...");
10771
10816
  targetFilePath = this._imageDirectory + fileName;
10772
10817
  _a.label = 1;
10773
10818
  case 1:
10774
10819
  _a.trys.push([1, 3, , 4]);
10775
- return [4 /*yield*/, firstNotNilPromise(this.http.get(source, {
10820
+ return [4 /*yield*/, firstNotNilPromise(this.http.get(fileUrl, {
10776
10821
  observe: 'body',
10777
10822
  responseType: 'blob',
10778
10823
  reportProgress: false
@@ -10784,25 +10829,25 @@
10784
10829
  //const fileTransfer = (opts && opts.fileTransfer) || this.transfer.create();
10785
10830
  //await fileTransfer.download(source, targetFilePath);
10786
10831
  if (debug)
10787
- console.debug("[file] Fetching image {" + source + "} into " + responseType + " [OK] in " + (Date.now() - now) + "ms");
10832
+ console.debug("[file] Fetching image {" + fileUrl + "} into " + outputType + " [OK] in " + (Date.now() - now) + "ms");
10788
10833
  return [2 /*return*/, targetFilePath];
10789
10834
  case 3:
10790
10835
  err_1 = _a.sent();
10791
- console.error("[file] Error while download " + source + ": " + (err_1 && err_1.message || err_1));
10836
+ console.error("[file] Error while download " + fileUrl + ": " + (err_1 && err_1.message || err_1));
10792
10837
  // Continue (fallback to data Url)
10793
- responseType = 'dataUrl';
10838
+ outputType = 'dataUrl';
10794
10839
  return [3 /*break*/, 4];
10795
10840
  case 4:
10796
- if (!(responseType === 'dataUrl')) return [3 /*break*/, 6];
10797
- return [4 /*yield*/, new Base64ImageReader().readAndResizeFromUrl(source, opts)];
10841
+ if (!(outputType === 'dataUrl')) return [3 /*break*/, 6];
10842
+ return [4 /*yield*/, ImagesUtils.readAndResizeFromUrl(fileUrl, opts)];
10798
10843
  case 5:
10799
10844
  dataUrl = _a.sent();
10800
10845
  if (debug)
10801
- console.debug("[file] Fetching image {" + source + "} into " + responseType + " [OK] in " + (Date.now() - now) + "ms");
10846
+ console.debug("[file] Fetching image {" + fileUrl + "} into " + outputType + " [OK] in " + (Date.now() - now) + "ms");
10802
10847
  return [2 /*return*/, dataUrl];
10803
10848
  case 6:
10804
10849
  // Keep original URL
10805
- return [2 /*return*/, source];
10850
+ return [2 /*return*/, fileUrl];
10806
10851
  }
10807
10852
  });
10808
10853
  });
@@ -10834,7 +10879,8 @@
10834
10879
  providedIn: 'root',
10835
10880
  deps: [
10836
10881
  i1$5.Platform,
10837
- i2$1.HttpClient
10882
+ i2$1.HttpClient,
10883
+ ENVIRONMENT
10838
10884
  ]
10839
10885
  },] }
10840
10886
  ];
@@ -11421,6 +11467,10 @@
11421
11467
  {
11422
11468
  host: 'test.sumaris.net',
11423
11469
  port: 443
11470
+ },
11471
+ {
11472
+ host: 'server.e-is.pro',
11473
+ port: 443
11424
11474
  }
11425
11475
  ],
11426
11476
  defaultAppName: 'SUMARiS',
@@ -17184,7 +17234,7 @@
17184
17234
  if (!(hasAvatarUrl && this.network.online)) return [3 /*break*/, 2];
17185
17235
  return [4 /*yield*/, this.file.getImage(json.avatar, {
17186
17236
  thumbnail: true,
17187
- responseType: 'dataUrl'
17237
+ outputType: 'dataUrl'
17188
17238
  })
17189
17239
  .then(function (dataUrl) {
17190
17240
  if (dataUrl && _this._debug)
@@ -18159,30 +18209,6 @@
18159
18209
  ]; };
18160
18210
  var templateObject_1$1, templateObject_2$1, templateObject_3$1, templateObject_4$1, templateObject_5$1;
18161
18211
 
18162
- var UploadFile = /** @class */ (function (_super) {
18163
- __extends(UploadFile, _super);
18164
- function UploadFile() {
18165
- return _super !== null && _super.apply(this, arguments) || this;
18166
- }
18167
- return UploadFile;
18168
- }(File));
18169
- var FileResponse = /** @class */ (function () {
18170
- function FileResponse(init) {
18171
- this.type = i2$1.HttpEventType.Response;
18172
- this.body = isNotNil(init === null || init === void 0 ? void 0 : init.body) ? init.body : null;
18173
- this.status = (init === null || init === void 0 ? void 0 : init.status) || 0;
18174
- this.statusText = (init === null || init === void 0 ? void 0 : init.statusText) || 'OK';
18175
- }
18176
- return FileResponse;
18177
- }());
18178
- function isProgressEvent(event) {
18179
- return event && (event.type === i2$1.HttpEventType.UploadProgress
18180
- || event.type === i2$1.HttpEventType.DownloadProgress);
18181
- }
18182
- function isResponseEvent(event) {
18183
- return event && event.type === i2$1.HttpEventType.Response;
18184
- }
18185
-
18186
18212
  var UploadFilePopover = /** @class */ (function () {
18187
18213
  function UploadFilePopover(popoverController, translate, cd) {
18188
18214
  this.popoverController = popoverController;
@@ -19945,593 +19971,498 @@
19945
19971
  return FormFieldValuesHolder;
19946
19972
  }());
19947
19973
 
19948
- // eslint-disable-next-line @angular-eslint/directive-class-suffix
19949
- var AppForm = /** @class */ (function () {
19950
- function AppForm(injector, form) {
19951
- var _this = this;
19952
- this._subscription = new rxjs.Subscription();
19953
- this._enable = false;
19954
- this.i18nFieldPrefix = null;
19955
- this.readySubject = new rxjs.BehaviorSubject(false);
19956
- this.loadingSubject = new rxjs.BehaviorSubject(true);
19957
- this.errorSubject = new rxjs.BehaviorSubject(undefined);
19958
- this.debug = false;
19959
- this.onCancel = new i0.EventEmitter();
19960
- this.onSubmit = new i0.EventEmitter();
19961
- if (form)
19962
- this.setForm(form);
19963
- this.translate = injector.get(i1$2.TranslateService);
19964
- this.settings = injector.get(LocalSettingsService);
19965
- this.errorTranslator = injector.get(FormErrorTranslator);
19966
- this.autocompleteHelper = new MatAutocompleteConfigHolder(this.settings && {
19967
- getUserAttributes: function (a, b) { return _this.settings.getFieldDisplayAttributes(a, b); }
19968
- });
19969
- this.autocompleteFields = this.autocompleteHelper.fields;
19974
+ var ImageService = /** @class */ (function (_super) {
19975
+ __extends(ImageService, _super);
19976
+ function ImageService(platform, settings, translate, popoverController, imagePicker, photoViewer, mediaCapture, actionSheetController, environment) {
19977
+ var _this = _super.call(this, platform) || this;
19978
+ _this.platform = platform;
19979
+ _this.settings = settings;
19980
+ _this.translate = translate;
19981
+ _this.popoverController = popoverController;
19982
+ _this.imagePicker = imagePicker;
19983
+ _this.photoViewer = photoViewer;
19984
+ _this.mediaCapture = mediaCapture;
19985
+ _this.actionSheetController = actionSheetController;
19986
+ _this.environment = environment;
19987
+ _this.defaultMaxHeight = 1024;
19988
+ _this.defaultMaxWidth = 1024;
19989
+ _this._debug = !environment.production;
19990
+ if (_this._debug)
19991
+ console.debug('[image] Creating service');
19992
+ return _this;
19970
19993
  }
19971
- Object.defineProperty(AppForm.prototype, "_loading", {
19972
- /**
19973
- * @deprecated
19974
- */
19975
- get: function () {
19976
- return this.loadingSubject.value;
19977
- },
19978
- /**
19979
- * @deprecated
19980
- */
19981
- set: function (value) {
19982
- this.loadingSubject.next(value);
19983
- },
19984
- enumerable: false,
19985
- configurable: true
19986
- });
19987
- Object.defineProperty(AppForm.prototype, "_$ready", {
19988
- /**
19989
- * @deprecated
19990
- */
19991
- get: function () {
19992
- return this.readySubject;
19993
- },
19994
- enumerable: false,
19995
- configurable: true
19996
- });
19997
- Object.defineProperty(AppForm.prototype, "_$loading", {
19998
- /**
19999
- * @deprecated
20000
- */
20001
- get: function () {
20002
- return this.loadingSubject;
20003
- },
20004
- enumerable: false,
20005
- configurable: true
20006
- });
20007
- Object.defineProperty(AppForm.prototype, "error", {
20008
- get: function () {
20009
- return this.errorSubject.value;
20010
- },
20011
- set: function (error) {
20012
- this.setError(error);
20013
- },
20014
- enumerable: false,
20015
- configurable: true
20016
- });
20017
- Object.defineProperty(AppForm.prototype, "loading", {
20018
- get: function () {
20019
- return this.loadingSubject.value;
20020
- },
20021
- enumerable: false,
20022
- configurable: true
20023
- });
20024
- Object.defineProperty(AppForm.prototype, "loaded", {
20025
- get: function () {
20026
- return !this.loadingSubject.value;
20027
- },
20028
- enumerable: false,
20029
- configurable: true
20030
- });
20031
- Object.defineProperty(AppForm.prototype, "value", {
20032
- get: function () {
20033
- return this.form.value;
20034
- },
20035
- set: function (data) {
20036
- this.setValue(data);
20037
- },
20038
- enumerable: false,
20039
- configurable: true
20040
- });
20041
- Object.defineProperty(AppForm.prototype, "dirty", {
20042
- get: function () {
20043
- var _a;
20044
- return ((_a = this.form) === null || _a === void 0 ? void 0 : _a.dirty) || false;
20045
- },
20046
- enumerable: false,
20047
- configurable: true
20048
- });
20049
- Object.defineProperty(AppForm.prototype, "invalid", {
20050
- get: function () {
20051
- return !this.form || this.form.invalid;
20052
- },
20053
- enumerable: false,
20054
- configurable: true
20055
- });
20056
- Object.defineProperty(AppForm.prototype, "pending", {
20057
- get: function () {
20058
- return !this.form || (this.form.dirty && this.form.pending);
20059
- },
20060
- enumerable: false,
20061
- configurable: true
20062
- });
20063
- Object.defineProperty(AppForm.prototype, "valid", {
20064
- get: function () {
20065
- var _a;
20066
- return ((_a = this.form) === null || _a === void 0 ? void 0 : _a.valid) || false;
20067
- },
20068
- enumerable: false,
20069
- configurable: true
20070
- });
20071
- Object.defineProperty(AppForm.prototype, "empty", {
20072
- get: function () {
20073
- return !this.form || (!this.form.dirty && !this.form.touched);
20074
- },
20075
- enumerable: false,
20076
- configurable: true
20077
- });
20078
- Object.defineProperty(AppForm.prototype, "untouched", {
20079
- get: function () {
20080
- return !this.form || this.form.untouched;
20081
- },
20082
- enumerable: false,
20083
- configurable: true
20084
- });
20085
- Object.defineProperty(AppForm.prototype, "enabled", {
20086
- get: function () {
20087
- return this._enable;
20088
- },
20089
- enumerable: false,
20090
- configurable: true
20091
- });
20092
- Object.defineProperty(AppForm.prototype, "disabled", {
20093
- get: function () {
20094
- return !this._enable;
20095
- },
20096
- enumerable: false,
20097
- configurable: true
20098
- });
20099
- AppForm.prototype.disable = function (opts) {
20100
- var _a;
20101
- (_a = this.form) === null || _a === void 0 ? void 0 : _a.disable(opts);
20102
- if (this._enable) {
20103
- this._enable = false;
20104
- if (!opts || opts.emitEvent !== true)
20105
- this.markForCheck();
20106
- }
20107
- };
20108
- AppForm.prototype.enable = function (opts) {
20109
- var _a;
20110
- (_a = this.form) === null || _a === void 0 ? void 0 : _a.enable(opts);
20111
- if (!this._enable) {
20112
- this._enable = true;
20113
- if (!opts || opts.emitEvent !== true)
20114
- this.markForCheck();
20115
- }
20116
- };
20117
- Object.defineProperty(AppForm.prototype, "form", {
20118
- get: function () {
20119
- return this._form;
20120
- },
20121
- set: function (value) {
20122
- this.setForm(value);
20123
- },
20124
- enumerable: false,
20125
- configurable: true
20126
- });
20127
- AppForm.prototype.ngOnInit = function () {
20128
- this._enable ? this.enable() : this.disable();
20129
- this.errorTranslatorOptions = this.errorTranslatorOptions || {
20130
- controlPathTranslator: this
20131
- };
20132
- };
20133
- AppForm.prototype.ngOnDestroy = function () {
20134
- this._subscription.unsubscribe();
20135
- this.readySubject.unsubscribe();
20136
- this.loadingSubject.unsubscribe();
20137
- this.errorSubject.unsubscribe();
20138
- this.onCancel.unsubscribe();
20139
- this.onSubmit.unsubscribe();
20140
- };
20141
- AppForm.prototype.cancel = function () {
19994
+ ImageService.prototype.ngOnStart = function () {
20142
19995
  return __awaiter(this, void 0, void 0, function () {
20143
- return __generator(this, function (_b) {
20144
- this.onCancel.emit();
19996
+ return __generator(this, function (_a) {
19997
+ console.info('[image] Starting...');
20145
19998
  return [2 /*return*/];
20146
19999
  });
20147
20000
  });
20148
20001
  };
20149
- /**
20150
- *
20151
- * @param event
20152
- * @param opts allow to skip validation check, using {checkValid: false}
20153
- */
20154
- AppForm.prototype.doSubmit = function (event, opts) {
20002
+ ImageService.prototype.show = function (url, title, opts) {
20003
+ if (!url)
20004
+ return;
20005
+ // If desktop: open upload popover
20006
+ if (!this.platform.isCordova()) {
20007
+ console.warn('TODO: implement photo viewer fallback, when no cordova');
20008
+ return;
20009
+ }
20010
+ this.photoViewer.show(url, title, Object.assign({ share: true, closeButton: true }, opts));
20011
+ };
20012
+ ImageService.prototype.add = function (event, opts) {
20155
20013
  return __awaiter(this, void 0, void 0, function () {
20014
+ var sheet, role, _a, image;
20156
20015
  return __generator(this, function (_b) {
20157
20016
  switch (_b.label) {
20158
20017
  case 0:
20159
- if (!this._form) {
20160
- this.markAllAsTouched({ emitEvent: true });
20161
- return [2 /*return*/];
20018
+ // If desktop: open upload popover
20019
+ if (!this.platform.isCordova()) {
20020
+ return [2 /*return*/, this.addUploadedImages(event, opts)];
20162
20021
  }
20163
- if (!((!opts || opts.checkValid !== false) && !this._form.valid)) return [3 /*break*/, 2];
20164
- // Wait validation end
20165
- return [4 /*yield*/, AppFormUtils.waitWhilePending(this._form)];
20022
+ return [4 /*yield*/, this.actionSheetController.create({
20023
+ backdropDismiss: true,
20024
+ buttons: [
20025
+ {
20026
+ role: 'camera',
20027
+ text: this.translate.instant('IMAGE.BTN_CAMERA_SOURCE'),
20028
+ icon: 'camera'
20029
+ },
20030
+ {
20031
+ role: 'gallery',
20032
+ text: this.translate.instant('IMAGE.BTN_GALLERY_SOURCE'),
20033
+ icon: 'images'
20034
+ }
20035
+ ]
20036
+ })];
20166
20037
  case 1:
20167
- // Wait validation end
20038
+ sheet = _b.sent();
20039
+ return [4 /*yield*/, sheet.present()];
20040
+ case 2:
20168
20041
  _b.sent();
20169
- // Form is invalid: exit (+ log if debug)
20170
- if (this._form.invalid) {
20171
- this.markAllAsTouched({ emitEvent: true });
20172
- if (this.debug)
20173
- AppFormUtils.logFormErrors(this._form);
20174
- return [2 /*return*/];
20042
+ return [4 /*yield*/, sheet.onDidDismiss()];
20043
+ case 3:
20044
+ role = (_b.sent()).role;
20045
+ if (!role)
20046
+ return [2 /*return*/]; // User cancelled
20047
+ _a = role;
20048
+ switch (_a) {
20049
+ case 'camera': return [3 /*break*/, 4];
20050
+ case 'gallery': return [3 /*break*/, 6];
20175
20051
  }
20176
- _b.label = 2;
20177
- case 2:
20178
- // Emit event
20179
- this.onSubmit.emit(event);
20180
- return [2 /*return*/];
20052
+ return [3 /*break*/, 8];
20053
+ case 4: return [4 /*yield*/, this.addImageFromCamera()];
20054
+ case 5:
20055
+ image = _b.sent();
20056
+ return [2 /*return*/, image ? [image] : undefined];
20057
+ case 6: return [4 /*yield*/, this.addImagesFromGallery()];
20058
+ case 7: return [2 /*return*/, _b.sent()];
20059
+ case 8: return [2 /*return*/]; // User cancelled (e.g. backdrop click)
20181
20060
  }
20182
20061
  });
20183
20062
  });
20184
20063
  };
20185
- AppForm.prototype.setForm = function (form) {
20186
- var _this = this;
20187
- if (this._form !== form) {
20188
- this._form = form;
20189
- this._subscription.add(this._form.statusChanges.subscribe(function (status) { return _this.markForCheck(); }));
20190
- }
20191
- };
20192
- AppForm.prototype.setValue = function (data, opts) {
20193
- if (!data) {
20194
- console.warn('[form] Trying to set an empty value to form. Skipping');
20195
- return;
20196
- }
20197
- // DEBUG
20198
- //if (this.debug) console.debug('[form] Updating form (using entity)', data);
20199
- // Convert object to json, then apply it to form (e.g. convert 'undefined' into 'null')
20200
- AppFormUtils.copyEntity2Form(data, this.form, Object.assign({ emitEvent: false, onlySelf: true }, opts));
20201
- if (!opts || opts.emitEvent !== true) {
20202
- this.markForCheck();
20203
- }
20204
- };
20205
- AppForm.prototype.reset = function (data, opts) {
20206
- if (data) {
20207
- if (this.debug)
20208
- console.debug('[form] Resetting form (using entity)', data);
20209
- // Convert object to json, then apply it to form (e.g. convert 'undefined' into 'null')
20210
- var json = AppFormUtils.getFormValueFromEntity(data, this.form);
20211
- this.form.reset(json, { emitEvent: false, onlySelf: true });
20212
- }
20213
- else {
20214
- this.form.reset(null, { emitEvent: false, onlySelf: true });
20215
- }
20216
- if (!opts || opts.emitEvent !== true)
20217
- this.markForCheck();
20218
- };
20219
- AppForm.prototype.markAsPristine = function (opts) {
20220
- this.form.markAsPristine(opts);
20221
- if (!opts || opts.emitEvent !== false)
20222
- this.markForCheck();
20223
- };
20224
- AppForm.prototype.markAsUntouched = function (opts) {
20225
- this.form.markAsUntouched(opts);
20226
- if (!opts || opts.emitEvent !== false)
20227
- this.markForCheck();
20228
- };
20229
- /**
20230
- * @deprecated prefer to use markAllAsTouched()
20231
- * @param opts
20232
- */
20233
- AppForm.prototype.markAsTouched = function (opts) {
20234
- // this.form.markAllAsTouched() // This is not working well (e.g. in TripForm)
20235
- console.warn('TODO: Replace this call by markAllAsTouched() - because of changes in ngx-components >= 0.16.0');
20236
- AppFormUtils.markAsTouched(this.form, opts);
20237
- if (!opts || opts.emitEvent !== false)
20238
- this.markForCheck();
20239
- };
20240
- AppForm.prototype.markAllAsTouched = function (opts) {
20241
- // this.form.markAllAsTouched() // This is not working well (e.g. in TripForm)
20242
- AppFormUtils.markAllAsTouched(this.form, opts);
20243
- if (!opts || opts.emitEvent !== false)
20244
- this.markForCheck();
20245
- };
20246
- AppForm.prototype.markAsDirty = function (opts) {
20247
- this.form.markAsDirty(opts);
20248
- if (!opts || opts.emitEvent !== false)
20249
- this.markForCheck();
20250
- };
20251
- AppForm.prototype.markAsLoading = function (opts) {
20252
- this.setLoading(true, opts);
20253
- };
20254
- AppForm.prototype.markAsLoaded = function (opts) {
20255
- this.setLoading(false, opts);
20256
- };
20257
- AppForm.prototype.markAsReady = function (opts) {
20258
- if (this.readySubject.value !== true) {
20259
- this.readySubject.next(true);
20260
- // If subclasses implements OnReady
20261
- if (typeof this['ngOnReady'] === 'function') {
20262
- this.ngOnReady();
20263
- }
20264
- }
20265
- };
20266
- /**
20267
- * Wait form is ready
20268
- * @param opts
20269
- */
20270
- AppForm.prototype.ready = function (opts) {
20271
- if (this.readySubject.value)
20272
- return Promise.resolve();
20273
- return waitForTrue(this.readySubject, opts);
20274
- };
20275
- /**
20276
- * Wait form is not busy (=loaded)
20277
- * @param opts
20278
- */
20279
- AppForm.prototype.waitIdle = function (opts) {
20280
- if (!this.loadingSubject.value)
20281
- return Promise.resolve();
20282
- return waitForFalse(this.loadingSubject, opts);
20283
- };
20284
- AppForm.prototype.updateValueAndValidity = function (opts) {
20285
- AppFormUtils.updateValueAndValidity(this.form, opts);
20286
- if (!opts || opts.emitEvent !== false)
20287
- this.markForCheck();
20288
- };
20289
- AppForm.prototype.translateControlPath = function (path) {
20290
- var _a;
20291
- var i18nFieldName = this.getI18nFieldName(path);
20292
- return ((_a = this.translate) === null || _a === void 0 ? void 0 : _a.instant(i18nFieldName)) || i18nFieldName;
20293
- };
20294
- /* -- protected methods -- */
20295
- AppForm.prototype.getFormError = function (form, opts) {
20296
- if (!form || !this.errorTranslator)
20297
- return undefined;
20298
- return this.errorTranslator.translateFormErrors(this.form, Object.assign({ controlPathTranslator: this }, opts));
20299
- };
20300
- AppForm.prototype.getI18nFieldName = function (path) {
20301
- return (this.i18nFieldPrefix || '') + changeCaseToUnderscore(path).toUpperCase();
20302
- };
20303
- AppForm.prototype.registerSubscription = function (sub) {
20304
- return this._subscription.add(sub);
20305
- };
20306
- AppForm.prototype.unregisterSubscription = function (sub) {
20307
- this._subscription.remove(sub);
20308
- };
20309
- AppForm.prototype.registerAutocompleteField = function (fieldName, opts) {
20310
- return this.autocompleteHelper.add(fieldName, opts);
20311
- };
20312
- AppForm.prototype.setError = function (value, opts) {
20313
- if (this.errorSubject.value !== value) {
20314
- this.errorSubject.next(value);
20315
- if (!opts || opts.emitEvent !== false) {
20316
- this.markForCheck();
20317
- }
20318
- }
20319
- };
20320
- AppForm.prototype.markForCheck = function () {
20321
- // Should be overwritten by subclasses
20322
- console.warn('markForCheck() has been called, but is not overwritten by component ' + this.constructor.name);
20323
- };
20324
- /* -- private function -- */
20325
- AppForm.prototype.setLoading = function (value, opts) {
20326
- if (this.loadingSubject.value !== value) {
20327
- this.loadingSubject.next(value);
20328
- if (!opts || opts.emitEvent !== false) {
20329
- this.markForCheck();
20330
- }
20331
- }
20332
- };
20333
- return AppForm;
20334
- }());
20335
- AppForm.decorators = [
20336
- { type: i0.Directive }
20337
- ];
20338
- AppForm.ctorParameters = function () { return [
20339
- { type: i0.Injector },
20340
- { type: i1.FormGroup }
20341
- ]; };
20342
- AppForm.propDecorators = {
20343
- debug: [{ type: i0.Input }],
20344
- tabindex: [{ type: i0.Input }],
20345
- errorTranslatorOptions: [{ type: i0.Input }],
20346
- form: [{ type: i0.Input }],
20347
- onCancel: [{ type: i0.Output }],
20348
- onSubmit: [{ type: i0.Output }]
20349
- };
20350
-
20351
- var TextForm = /** @class */ (function (_super) {
20352
- __extends(TextForm, _super);
20353
- function TextForm(injector, cd, formBuilder) {
20354
- var _this = _super.call(this, injector) || this;
20355
- _this.injector = injector;
20356
- _this.cd = cd;
20357
- _this.formBuilder = formBuilder;
20358
- _this.showError = true;
20359
- _this.multiline = true;
20360
- _this.autoHeight = false;
20361
- _this.maxLength = 2000;
20362
- _this.autofocus = false;
20363
- _this.textAreaChanges = new i0.EventEmitter();
20364
- return _this;
20365
- }
20366
- TextForm.prototype.ngOnInit = function () {
20367
- var form = this.formBuilder.group({
20368
- text: [null, isNotNil(this.maxLength)
20369
- ? i1.Validators.maxLength(this.maxLength)
20370
- : undefined
20371
- ]
20064
+ ImageService.prototype.addUploadedImages = function (event, opts) {
20065
+ return __awaiter(this, void 0, void 0, function () {
20066
+ var data;
20067
+ var _this = this;
20068
+ return __generator(this, function (_a) {
20069
+ switch (_a.label) {
20070
+ case 0: return [4 /*yield*/, FilesUtils.showUploadPopover(this.popoverController, event, {
20071
+ uniqueFile: true,
20072
+ fileExtension: '.png, .jpg',
20073
+ instantUpload: true,
20074
+ uploadFn: function (file) { return ImagesUtils.readAsDataURL(file, Object.assign({ maxWidth: _this.defaultMaxWidth, maxHeight: _this.defaultMaxHeight }, opts)); }
20075
+ })];
20076
+ case 1:
20077
+ data = (_a.sent()).data;
20078
+ if (isEmptyArray(data))
20079
+ return [2 /*return*/]; // No files uploaded: skip
20080
+ return [2 /*return*/, (data || [])
20081
+ .map(function (file) { return file.response.body; }) // Get response body = data as base64
20082
+ .map(function (dataUrl) { return ({ dataUrl: dataUrl }); })];
20083
+ }
20084
+ });
20372
20085
  });
20373
- this.control = form.get('text');
20374
- this.setForm(form);
20375
- _super.prototype.ngOnInit.call(this);
20376
20086
  };
20377
- TextForm.prototype.textAreaChanged = function (event) {
20378
- this.textAreaChanges.emit(this.control.value);
20379
- };
20380
- TextForm.prototype.containerResize = function () {
20381
- var _a;
20382
- (_a = this.autosizeDirective) === null || _a === void 0 ? void 0 : _a.resizeToFitContent(true);
20383
- };
20384
- TextForm.prototype.focusInput = function () {
20385
- if (this.textArea)
20386
- focusInput(this.textArea);
20387
- if (this.textInput)
20388
- focusInput(this.textInput);
20087
+ ImageService.prototype.addImageFromCamera = function (opts) {
20088
+ return __awaiter(this, void 0, void 0, function () {
20089
+ var outputType, file, _a, dataUrl, err_1;
20090
+ return __generator(this, function (_b) {
20091
+ switch (_b.label) {
20092
+ case 0:
20093
+ console.info('[image-service] Capturing new image from camera...');
20094
+ outputType = toNumber(opts === null || opts === void 0 ? void 0 : opts.outputType, ngx$9.OutputType.DATA_URL);
20095
+ return [4 /*yield*/, this.mediaCapture.captureImage({
20096
+ limit: 1
20097
+ }).then(function (data) {
20098
+ return data && data[0];
20099
+ }, function (err) {
20100
+ console.error("[image-service] Failed to capture new image - Error code: " + ((err === null || err === void 0 ? void 0 : err.code) || 'unknown'));
20101
+ return undefined;
20102
+ })];
20103
+ case 1:
20104
+ file = _b.sent();
20105
+ if (!(file === null || file === void 0 ? void 0 : file.fullPath))
20106
+ return [2 /*return*/]; // Skip
20107
+ console.info('[image-service] new picture path:' + file.fullPath);
20108
+ _b.label = 2;
20109
+ case 2:
20110
+ _b.trys.push([2, 8, , 9]);
20111
+ _a = outputType;
20112
+ switch (_a) {
20113
+ case ngx$9.OutputType.FILE_URL: return [3 /*break*/, 3];
20114
+ case ngx$9.OutputType.DATA_URL: return [3 /*break*/, 4];
20115
+ }
20116
+ return [3 /*break*/, 6];
20117
+ case 3: return [2 /*return*/, { url: file.fullPath }];
20118
+ case 4:
20119
+ console.info("[image-service] Converting file " + file.fullPath + " into dataUrl...");
20120
+ return [4 /*yield*/, ImagesUtils.readAndResizeFromUrl(file.fullPath, {
20121
+ maxWidth: this.defaultMaxWidth,
20122
+ maxHeight: this.defaultMaxHeight
20123
+ })];
20124
+ case 5:
20125
+ dataUrl = _b.sent();
20126
+ return [2 /*return*/, { dataUrl: dataUrl }];
20127
+ case 6: throw new Error("Unknown outputType: " + outputType);
20128
+ case 7: return [3 /*break*/, 9];
20129
+ case 8:
20130
+ err_1 = _b.sent();
20131
+ console.error('[image-service] Failed while processing image', err_1);
20132
+ return [2 /*return*/, undefined];
20133
+ case 9: return [2 /*return*/];
20134
+ }
20135
+ });
20136
+ });
20389
20137
  };
20390
- TextForm.prototype.markForCheck = function () {
20391
- this.cd.markForCheck();
20138
+ ImageService.prototype.addImagesFromGallery = function (opts) {
20139
+ return __awaiter(this, void 0, void 0, function () {
20140
+ var outputType, canReadPictures, err_2, data, items, err_3;
20141
+ return __generator(this, function (_a) {
20142
+ switch (_a.label) {
20143
+ case 0:
20144
+ console.debug('[image-service] Adding images from gallery...');
20145
+ outputType = toNumber(opts === null || opts === void 0 ? void 0 : opts.outputType, ngx$9.OutputType.DATA_URL);
20146
+ _a.label = 1;
20147
+ case 1:
20148
+ _a.trys.push([1, 6, , 7]);
20149
+ return [4 /*yield*/, this.imagePicker.hasReadPermission()];
20150
+ case 2:
20151
+ canReadPictures = _a.sent();
20152
+ if (!!canReadPictures) return [3 /*break*/, 5];
20153
+ return [4 /*yield*/, this.imagePicker.requestReadPermission()];
20154
+ case 3:
20155
+ _a.sent();
20156
+ return [4 /*yield*/, this.imagePicker.hasReadPermission()];
20157
+ case 4:
20158
+ canReadPictures = _a.sent();
20159
+ if (!canReadPictures) {
20160
+ console.error('No read permission, after calling requestReadPermission() without error!! skip');
20161
+ return [2 /*return*/];
20162
+ }
20163
+ _a.label = 5;
20164
+ case 5: return [3 /*break*/, 7];
20165
+ case 6:
20166
+ err_2 = _a.sent();
20167
+ console.error(err_2);
20168
+ return [2 /*return*/]; // Cancelled
20169
+ case 7:
20170
+ _a.trys.push([7, 9, , 10]);
20171
+ return [4 /*yield*/, this.imagePicker.getPictures({
20172
+ maximumImagesCount: 1,
20173
+ //height: this._maxImageHeight
20174
+ allow_video: false,
20175
+ outputType: outputType
20176
+ })];
20177
+ case 8:
20178
+ data = _a.sent();
20179
+ items = !data || Array.isArray(data) ? data : [data];
20180
+ if (isEmptyArray(items))
20181
+ return [2 /*return*/]; // No images selected: skip
20182
+ console.info("[image-service] User select " + items.length + " image(s)");
20183
+ console.debug("[image-service] Selected image: " + JSON.stringify(items));
20184
+ // Convert to entity
20185
+ switch (outputType) {
20186
+ case ngx$9.OutputType.FILE_URL:
20187
+ return [2 /*return*/, items.map(function (url) { return ({ url: url }); })];
20188
+ case ngx$9.OutputType.DATA_URL:
20189
+ return [2 /*return*/, items.map(function (dataUrl) { return ({ dataUrl: dataUrl }); })];
20190
+ default:
20191
+ throw new Error("Unknown outputType: " + outputType);
20192
+ }
20193
+ return [3 /*break*/, 10];
20194
+ case 9:
20195
+ err_3 = _a.sent();
20196
+ console.error('[image-service] Failed to get image from gallery', err_3);
20197
+ return [2 /*return*/, undefined];
20198
+ case 10: return [2 /*return*/];
20199
+ }
20200
+ });
20201
+ });
20392
20202
  };
20393
- return TextForm;
20394
- }(AppForm));
20395
- TextForm.decorators = [
20396
- { type: i0.Component, args: [{
20397
- selector: 'app-text-form',
20398
- template: "<form class=\"form-container\" [formGroup]=\"form\" (ngSubmit)=\"doSubmit($event)\">\n <mat-form-field *ngIf=\"multiline; else monoline\">\n <textarea\n #textArea\n matInput\n [formControl]=\"control\"\n [placeholder]=\"placeholder\"\n [readonly]=\"control.disabled\"\n [class.fixed-height]=\"!autoHeight\"\n [cdkTextareaAutosize]=\"autoHeight\"\n (keyup)=\"textAreaChanged($event)\"\n (keydown.control.enter)=\"onSubmit.emit($event)\"\n [autofocus]=\"autofocus\"\n ></textarea>\n <mat-error *ngIf=\"control.hasError('maxlength')\">\n {{ 'ERROR.FIELD_MAX_LENGTH' | translate: control.errors['maxlength'] }}\n </mat-error>\n <mat-hint *ngIf=\"maxLength\" align=\"end\">\n {{ 'INFO.TEXT_PROGRESS' | translate: { current: textArea.value?.length || 0, max: maxLength } }}\n </mat-hint>\n </mat-form-field>\n <ng-template #monoline>\n <mat-form-field>\n <input\n #textInput\n matInput\n [formControl]=\"control\"\n [placeholder]=\"placeholder\"\n [readonly]=\"disabled\"\n [appAutofocus]=\"autofocus\"\n (keydown.control.enter)=\"onSubmit.emit($event)\"\n />\n <mat-error *ngIf=\"control.hasError('maxlength')\">\n {{ 'ERROR.FIELD_MAX_LENGTH' | translate: control.errors['maxlength'] }}\n </mat-error>\n <mat-hint *ngIf=\"maxLength\" align=\"end\">\n {{ 'INFO.TEXT_PROGRESS' | translate: { current: textInput.value?.length || 0, max: maxLength } }}\n </mat-hint>\n </mat-form-field>\n </ng-template>\n</form>\n",
20399
- styles: ["textarea.fixed-height{height:11.5em}"]
20400
- },] }
20203
+ return ImageService;
20204
+ }(StartableService));
20205
+ ImageService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ImageService_Factory() { return new ImageService(i0.ɵɵinject(PlatformService), i0.ɵɵinject(LocalSettingsService), i0.ɵɵinject(i1$2.TranslateService), i0.ɵɵinject(i1$5.PopoverController), i0.ɵɵinject(i5.ImagePicker), i0.ɵɵinject(i6$1.PhotoViewer), i0.ɵɵinject(i7.MediaCapture), i0.ɵɵinject(i1$5.ActionSheetController), i0.ɵɵinject(ENVIRONMENT)); }, token: ImageService, providedIn: "root" });
20206
+ ImageService.decorators = [
20207
+ { type: i0.Injectable, args: [{ providedIn: 'root', deps: [ENVIRONMENT] },] }
20401
20208
  ];
20402
- TextForm.ctorParameters = function () { return [
20403
- { type: i0.Injector },
20404
- { type: i0.ChangeDetectorRef },
20405
- { type: i1.FormBuilder }
20209
+ ImageService.ctorParameters = function () { return [
20210
+ { type: PlatformService },
20211
+ { type: LocalSettingsService },
20212
+ { type: i1$2.TranslateService },
20213
+ { type: i1$5.PopoverController },
20214
+ { type: ngx$9.ImagePicker },
20215
+ { type: ngx$a.PhotoViewer },
20216
+ { type: ngx$b.MediaCapture },
20217
+ { type: i1$5.ActionSheetController },
20218
+ { type: Environment, decorators: [{ type: i0.Inject, args: [ENVIRONMENT,] }] }
20406
20219
  ]; };
20407
- TextForm.propDecorators = {
20408
- showError: [{ type: i0.Input }],
20409
- placeholder: [{ type: i0.Input }],
20410
- multiline: [{ type: i0.Input }],
20411
- autoHeight: [{ type: i0.Input }],
20412
- maxLength: [{ type: i0.Input }],
20413
- autofocus: [{ type: i0.Input }],
20414
- textAreaChanges: [{ type: i0.Output }],
20415
- textArea: [{ type: i0.ViewChild, args: ['textArea',] }],
20416
- textInput: [{ type: i0.ViewChild, args: ['textInput',] }],
20417
- autosizeDirective: [{ type: i0.ViewChild, args: [textField.CdkTextareaAutosize,] }]
20418
- };
20419
20220
 
20420
- var TextPopover = /** @class */ (function () {
20421
- function TextPopover(popoverController, translate) {
20422
- this.popoverController = popoverController;
20423
- this.translate = translate;
20424
- this.placeholder = '';
20425
- this.editing = true;
20426
- this.multiline = true;
20427
- this.maxLength = 2000;
20428
- this.autofocus = false;
20429
- this.subscription = new rxjs.Subscription();
20221
+ var AppImageGalleryComponent = /** @class */ (function () {
20222
+ function AppImageGalleryComponent(image, platform, cd, environment) {
20223
+ this.image = image;
20224
+ this.platform = platform;
20225
+ this.cd = cd;
20226
+ this._onDestroy = new rxjs.Subject();
20227
+ this._subscription = new rxjs.Subscription();
20228
+ this.showToolbar = true;
20229
+ this.colSize = 4;
20230
+ this.autoLoad = true;
20231
+ this.viewChange = new rxjs.BehaviorSubject({ start: 0, end: Number.MAX_VALUE });
20232
+ // DEV log
20233
+ this.debug = environment && !environment.production;
20430
20234
  }
20431
- Object.defineProperty(TextPopover.prototype, "disabled", {
20235
+ Object.defineProperty(AppImageGalleryComponent.prototype, "dataSource", {
20432
20236
  get: function () {
20433
- return this.form.disabled;
20237
+ return this._dataSource;
20434
20238
  },
20435
- enumerable: false,
20436
- configurable: true
20437
- });
20438
- Object.defineProperty(TextPopover.prototype, "enabled", {
20439
- get: function () {
20440
- return this.form.enabled;
20239
+ set: function (dataSource) {
20240
+ if (this._dataSource !== dataSource) {
20241
+ this._switchDataSource(dataSource);
20242
+ }
20441
20243
  },
20442
20244
  enumerable: false,
20443
20245
  configurable: true
20444
20246
  });
20445
- Object.defineProperty(TextPopover.prototype, "valid", {
20247
+ Object.defineProperty(AppImageGalleryComponent.prototype, "enabled", {
20446
20248
  get: function () {
20447
- var _a;
20448
- return ((_a = this.form) === null || _a === void 0 ? void 0 : _a.valid) || false;
20249
+ return !this.disabled;
20449
20250
  },
20450
20251
  enumerable: false,
20451
20252
  configurable: true
20452
20253
  });
20453
- Object.defineProperty(TextPopover.prototype, "value", {
20254
+ Object.defineProperty(AppImageGalleryComponent.prototype, "rows", {
20454
20255
  get: function () {
20455
- var _a;
20456
- return (_a = this.form) === null || _a === void 0 ? void 0 : _a.value.text;
20256
+ return this._data;
20457
20257
  },
20458
20258
  enumerable: false,
20459
20259
  configurable: true
20460
20260
  });
20461
- TextPopover.prototype.ngOnInit = function () {
20462
- this.enable();
20261
+ AppImageGalleryComponent.prototype.ngOnInit = function () {
20262
+ this.mobile = toBoolean(this.mobile, isMobile(window));
20263
+ this.readOnly = toBoolean(this.readOnly, false);
20463
20264
  };
20464
- TextPopover.prototype.ngAfterViewInit = function () {
20465
- var _this = this;
20466
- setTimeout(function () { return _this.form.setValue({ text: _this.text }); }, 0);
20265
+ AppImageGalleryComponent.prototype.ngAfterContentChecked = function () {
20266
+ if (this.dataSource && !this._renderChangeSubscription) {
20267
+ this._observeRenderChanges();
20268
+ }
20467
20269
  };
20468
- TextPopover.prototype.onValidate = function (event) {
20270
+ AppImageGalleryComponent.prototype.ngOnDestroy = function () {
20271
+ this._onDestroy.next();
20272
+ this._onDestroy.complete();
20273
+ this._subscription.unsubscribe();
20274
+ if (collections.isDataSource(this.dataSource)) {
20275
+ this.dataSource.disconnect(this);
20276
+ }
20277
+ };
20278
+ AppImageGalleryComponent.prototype.show = function (event, image) {
20469
20279
  return __awaiter(this, void 0, void 0, function () {
20470
- var value, err_1;
20280
+ return __generator(this, function (_a) {
20281
+ if (!image || (event === null || event === void 0 ? void 0 : event.defaultPrevented))
20282
+ return [2 /*return*/];
20283
+ this.image.show(image.url || image.dataUrl, image.title || '', { share: true, closeButton: true });
20284
+ return [2 /*return*/];
20285
+ });
20286
+ });
20287
+ };
20288
+ AppImageGalleryComponent.prototype.add = function (event) {
20289
+ return __awaiter(this, void 0, void 0, function () {
20290
+ var images, images_1, images_1_1, image, row, added;
20291
+ var e_1, _a;
20471
20292
  return __generator(this, function (_b) {
20472
20293
  switch (_b.label) {
20473
- case 0: return [4 /*yield*/, waitWhilePending(this.form)];
20294
+ case 0: return [4 /*yield*/, this.image.add(event)];
20474
20295
  case 1:
20475
- _b.sent();
20476
- if (!this.valid) {
20477
- logFormErrors(this.form.control);
20296
+ images = _b.sent();
20297
+ if (isEmptyArray(images))
20478
20298
  return [2 /*return*/];
20299
+ console.info("[image-gallery] Adding new " + images.length + " image(s)", images);
20300
+ try {
20301
+ for (images_1 = __values(images), images_1_1 = images_1.next(); !images_1_1.done; images_1_1 = images_1.next()) {
20302
+ image = images_1_1.value;
20303
+ this._dataSource.createNew(0);
20304
+ row = this._dataSource.getRow(-1);
20305
+ row.currentData = image;
20306
+ added = row.confirmEditCreate();
20307
+ if (!added) {
20308
+ console.warn('Cannot confirmEditCreate new image!');
20309
+ break;
20310
+ }
20311
+ }
20479
20312
  }
20480
- _b.label = 2;
20481
- case 2:
20482
- _b.trys.push([2, 4, , 5]);
20483
- value = this.value;
20484
- this.disable();
20485
- return [4 /*yield*/, this.popoverController.dismiss(value)];
20486
- case 3:
20487
- _b.sent();
20488
- this.form.error = null;
20489
- return [3 /*break*/, 5];
20490
- case 4:
20491
- err_1 = _b.sent();
20492
- this.form.error = (err_1 && err_1.message) || err_1;
20493
- this.enable();
20494
- return [3 /*break*/, 5];
20495
- case 5: return [2 /*return*/];
20313
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
20314
+ finally {
20315
+ try {
20316
+ if (images_1_1 && !images_1_1.done && (_a = images_1.return)) _a.call(images_1);
20317
+ }
20318
+ finally { if (e_1) throw e_1.error; }
20319
+ }
20320
+ return [2 /*return*/];
20496
20321
  }
20497
20322
  });
20498
20323
  });
20499
20324
  };
20500
- TextPopover.prototype.disable = function () {
20501
- this.form.disable();
20325
+ AppImageGalleryComponent.prototype.remove = function (event, row) {
20326
+ return __awaiter(this, void 0, void 0, function () {
20327
+ return __generator(this, function (_a) {
20328
+ if (event === null || event === void 0 ? void 0 : event.defaultPrevented)
20329
+ return [2 /*return*/];
20330
+ event === null || event === void 0 ? void 0 : event.preventDefault();
20331
+ if (row.id === -1) {
20332
+ console.info('[image-gallery] Removing new image');
20333
+ row.cancelOrDelete();
20334
+ }
20335
+ else {
20336
+ console.info('[image-gallery] Removing image (at #' + row.id + ')');
20337
+ row.delete();
20338
+ }
20339
+ return [2 /*return*/];
20340
+ });
20341
+ });
20502
20342
  };
20503
- TextPopover.prototype.enable = function () {
20504
- if (this.editing)
20505
- this.form.enable();
20343
+ AppImageGalleryComponent.prototype.toggleViewMode = function (event) {
20344
+ console.log(event);
20345
+ if (this.colSize === 12) {
20346
+ this.colSize = 4;
20347
+ }
20348
+ else {
20349
+ this.colSize = 12;
20350
+ }
20351
+ this.cd.markForCheck();
20506
20352
  };
20507
- TextPopover.prototype.cancel = function () {
20508
- this.popoverController.dismiss();
20353
+ AppImageGalleryComponent.prototype._switchDataSource = function (dataSource) {
20354
+ if (collections.isDataSource(this._dataSource)) {
20355
+ this._dataSource.disconnect(this);
20356
+ }
20357
+ this._dataSource = dataSource;
20509
20358
  };
20510
- TextPopover.prototype.ngOnDestroy = function () {
20511
- this.subscription.unsubscribe();
20359
+ AppImageGalleryComponent.prototype._observeRenderChanges = function () {
20360
+ var _this = this;
20361
+ // If no data source has been set, there is nothing to observe for changes.
20362
+ if (!this.dataSource) {
20363
+ return;
20364
+ }
20365
+ var dataStream;
20366
+ if (collections.isDataSource(this.dataSource)) {
20367
+ dataStream = this.dataSource.connect(this);
20368
+ }
20369
+ if (dataStream === undefined) {
20370
+ throw this.getTableUnknownDataSourceError();
20371
+ }
20372
+ this._renderChangeSubscription = dataStream.pipe(operators.takeUntil(this._onDestroy))
20373
+ .subscribe(function (data) {
20374
+ _this._data = data || [];
20375
+ _this.cd.markForCheck();
20376
+ });
20512
20377
  };
20513
- return TextPopover;
20378
+ AppImageGalleryComponent.prototype.getTableUnknownDataSourceError = function () {
20379
+ return Error("Provided data source did not match an array, Observable, or DataSource");
20380
+ };
20381
+ return AppImageGalleryComponent;
20514
20382
  }());
20515
- TextPopover.decorators = [
20383
+ AppImageGalleryComponent.decorators = [
20516
20384
  { type: i0.Component, args: [{
20517
- selector: 'app-text-popover',
20518
- template: "\n<ion-content class=\"ion-padding\" cdkTrapFocus [cdkTrapFocusAutoCapture]=\"true\">\n <ion-item *ngIf=\"form.error\" visible-xs visible-sm visible-mobile lines=\"none\">\n <ion-icon color=\"danger\" slot=\"start\" name=\"alert-circle\"></ion-icon>\n <ion-label color=\"danger\" class=\"error\" [innerHTML]=\"form.error|translate\"></ion-label>\n </ion-item>\n\n <app-text-form #form [placeholder]=\"placeholder\"\n [multiline]=\"multiline\"\n [maxLength]=\"maxLength\"\n [autofocus]=\"editing && autofocus\"\n (onSubmit)=\"onValidate($event)\"\n ></app-text-form>\n</ion-content>\n\n<ion-footer>\n <ion-toolbar>\n <ion-row class=\"ion-no-padding\" nowrap>\n <ion-col>\n\n </ion-col>\n\n <ion-col size=\"auto\">\n <ion-button fill=\"clear\" color=\"dark\" (click)=\"cancel()\">\n <ion-label translate>COMMON.BTN_CANCEL</ion-label>\n </ion-button>\n <ion-button\n [fill]=\"disabled ? 'clear' : 'solid'\"\n (click)=\"onValidate($event)\"\n (keyup.enter)=\"onValidate($event)\"\n color=\"tertiary\"\n [disabled]=\"disabled\"\n [title]=\"'COMMON.BTN_VALIDATE_WITH_SHORTCUT_HELP'|translate\">\n <ion-label translate>COMMON.BTN_VALIDATE</ion-label>\n </ion-button>\n </ion-col>\n </ion-row>\n </ion-toolbar>\n</ion-footer>\n"
20385
+ selector: 'app-image-gallery',
20386
+ template: "\n<ion-toolbar color=\"light\" *ngIf=\"showToolbar\">\n <!-- Add -->\n <button mat-icon-button\n *ngIf=\"!readOnly && !mobile && enabled\"\n [title]=\"'COMMON.BTN_ADD'|translate\"\n (click)=\"add($event)\">\n <mat-icon>add</mat-icon>\n </button>\n\n <ion-buttons slot=\"end\">\n <!-- Toggle view mode -->\n <ion-segment (ionChange)=\"toggleViewMode($event)\" color=\"accent\" [value]=\"colSize\">\n <ion-segment-button value=\"4\">\n <mat-icon>view_module</mat-icon>\n </ion-segment-button>\n <ion-segment-button value=\"12\">\n <mat-icon>view_list</mat-icon>\n </ion-segment-button>\n </ion-segment>\n </ion-buttons>\n</ion-toolbar>\n\n<ion-grid>\n <ion-row>\n <ion-col *ngFor=\"let row of rows\" [size]=\"colSize\">\n <ion-card *ngIf=\"row|propertyGet:'currentData'; let image\"\n (click)=\"show($event, image)\"\n tappable\n @fadeInAnimation>\n\n <!-- debug -->\n <ion-card-header class=\"ion-no-padding\" color=\"light\">\n <mat-toolbar>\n <ion-label class=\"ion-padding-start\" *ngIf=\"image.title; else addTitleButton\">{{image.title}}</ion-label>\n <ng-template #addTitleButton>\n <!-- <a class=\"button-text\"-->\n <!-- *ngIf=\"showImageTitle && !readOnly\"-->\n <!-- (click)=\"editTitle($event)\" translate>IMAGE.GALLERY.BTN_ADD_TITLE</a>-->\n </ng-template>\n\n <div class=\"toolbar-spacer\"></div>\n\n <button mat-icon-button *ngIf=\"!readOnly\"\n [title]=\"'COMMON.BTN_DELETE'|translate\"\n [disabled]=\"disabled\"\n (click)=\"remove($event, row)\">\n <mat-icon>delete</mat-icon>\n </button>\n </mat-toolbar>\n\n </ion-card-header>\n\n\n <img [src]=\"image.url||image.dataUrl\">\n\n <ion-card-content *ngIf=\"debug\">\n <ion-text >{{image.url}}</ion-text>\n </ion-card-content>\n </ion-card>\n </ion-col>\n </ion-row>\n</ion-grid>\n\n<!-- FAB button: add -->\n<ion-fab slot=\"fixed\" vertical=\"bottom\" horizontal=\"end\"\n *ngIf=\"showToolbar && mobile\"\n [class.cdk-visually-hidden]=\"disabled\"\n @fadeInOutAnimation>\n\n <ion-fab-button color=\"tertiary\" (click)=\"add($event)\">\n <ion-icon name=\"camera\"></ion-icon>\n <ion-icon name=\"add\" class=\"icon-secondary\" style=\"left: 33px; top: 9px; font-size: 20px;\"></ion-icon>\n </ion-fab-button>\n</ion-fab>\n\n\n\n\n",
20387
+ animations: [fadeInAnimation, fadeInOutAnimation],
20388
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
20389
+ styles: [".mat-toolbar-single-row,mat-toolbar{padding:0;height:42px}"]
20519
20390
  },] }
20520
20391
  ];
20521
- TextPopover.ctorParameters = function () { return [
20522
- { type: i1$5.PopoverController },
20523
- { type: i1$2.TranslateService }
20392
+ AppImageGalleryComponent.ctorParameters = function () { return [
20393
+ { type: ImageService },
20394
+ { type: i1$5.Platform },
20395
+ { type: i0.ChangeDetectorRef },
20396
+ { type: Environment, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [ENVIRONMENT,] }] }
20524
20397
  ]; };
20525
- TextPopover.propDecorators = {
20526
- form: [{ type: i0.ViewChild, args: ['form', { static: true },] }],
20527
- text: [{ type: i0.Input }],
20528
- placeholder: [{ type: i0.Input }],
20529
- editing: [{ type: i0.Input }],
20530
- multiline: [{ type: i0.Input }],
20531
- maxLength: [{ type: i0.Input }],
20532
- autofocus: [{ type: i0.Input }]
20398
+ AppImageGalleryComponent.propDecorators = {
20399
+ debug: [{ type: i0.Input }],
20400
+ readOnly: [{ type: i0.Input }],
20401
+ disabled: [{ type: i0.Input }],
20402
+ showToolbar: [{ type: i0.Input }],
20403
+ mobile: [{ type: i0.Input }],
20404
+ colSize: [{ type: i0.Input }],
20405
+ autoLoad: [{ type: i0.Input }],
20406
+ dataSource: [{ type: i0.Input }]
20533
20407
  };
20534
20408
 
20409
+ var ImageGalleryModule = /** @class */ (function () {
20410
+ function ImageGalleryModule() {
20411
+ }
20412
+ return ImageGalleryModule;
20413
+ }());
20414
+ ImageGalleryModule.decorators = [
20415
+ { type: i0.NgModule, args: [{
20416
+ imports: [
20417
+ i1$4.CommonModule,
20418
+ i1$5.IonicModule,
20419
+ SharedMaterialModule,
20420
+ SharedPipesModule,
20421
+ i1$2.TranslateModule.forChild(),
20422
+ ],
20423
+ declarations: [
20424
+ // Components
20425
+ AppImageGalleryComponent
20426
+ ],
20427
+ exports: [
20428
+ // Components
20429
+ AppImageGalleryComponent
20430
+ ]
20431
+ },] }
20432
+ ];
20433
+
20434
+ var ImageModule = /** @class */ (function () {
20435
+ function ImageModule() {
20436
+ }
20437
+ ImageModule.forRoot = function () {
20438
+ console.debug('[image] Creating module (root)');
20439
+ return {
20440
+ ngModule: ImageModule,
20441
+ providers: [
20442
+ // Common service
20443
+ ImageService,
20444
+ // Cordova service
20445
+ ngx$9.ImagePicker,
20446
+ ngx$b.MediaCapture,
20447
+ ngx$a.PhotoViewer
20448
+ ]
20449
+ };
20450
+ };
20451
+ return ImageModule;
20452
+ }());
20453
+ ImageModule.decorators = [
20454
+ { type: i0.NgModule, args: [{
20455
+ imports: [
20456
+ i1$4.CommonModule,
20457
+ ImageGalleryModule
20458
+ ],
20459
+ exports: [
20460
+ // Sub module
20461
+ ImageGalleryModule
20462
+ ]
20463
+ },] }
20464
+ ];
20465
+
20535
20466
  var ResizableDirective = /** @class */ (function () {
20536
20467
  function ResizableDirective(document, elementRef) {
20537
20468
  var _this = this;
@@ -21540,6 +21471,409 @@
21540
21471
  form: [{ type: i0.ViewChild, args: ['form', { static: true },] }]
21541
21472
  };
21542
21473
 
21474
+ // eslint-disable-next-line @angular-eslint/directive-class-suffix
21475
+ var AppForm = /** @class */ (function () {
21476
+ function AppForm(injector, form) {
21477
+ var _this = this;
21478
+ this._subscription = new rxjs.Subscription();
21479
+ this._enable = false;
21480
+ this.i18nFieldPrefix = null;
21481
+ this.readySubject = new rxjs.BehaviorSubject(false);
21482
+ this.loadingSubject = new rxjs.BehaviorSubject(true);
21483
+ this.errorSubject = new rxjs.BehaviorSubject(undefined);
21484
+ this.debug = false;
21485
+ this.onCancel = new i0.EventEmitter();
21486
+ this.onSubmit = new i0.EventEmitter();
21487
+ if (form)
21488
+ this.setForm(form);
21489
+ this.translate = injector.get(i1$2.TranslateService);
21490
+ this.settings = injector.get(LocalSettingsService);
21491
+ this.errorTranslator = injector.get(FormErrorTranslator);
21492
+ this.autocompleteHelper = new MatAutocompleteConfigHolder(this.settings && {
21493
+ getUserAttributes: function (a, b) { return _this.settings.getFieldDisplayAttributes(a, b); }
21494
+ });
21495
+ this.autocompleteFields = this.autocompleteHelper.fields;
21496
+ }
21497
+ Object.defineProperty(AppForm.prototype, "_loading", {
21498
+ /**
21499
+ * @deprecated
21500
+ */
21501
+ get: function () {
21502
+ return this.loadingSubject.value;
21503
+ },
21504
+ /**
21505
+ * @deprecated
21506
+ */
21507
+ set: function (value) {
21508
+ this.loadingSubject.next(value);
21509
+ },
21510
+ enumerable: false,
21511
+ configurable: true
21512
+ });
21513
+ Object.defineProperty(AppForm.prototype, "_$ready", {
21514
+ /**
21515
+ * @deprecated
21516
+ */
21517
+ get: function () {
21518
+ return this.readySubject;
21519
+ },
21520
+ enumerable: false,
21521
+ configurable: true
21522
+ });
21523
+ Object.defineProperty(AppForm.prototype, "_$loading", {
21524
+ /**
21525
+ * @deprecated
21526
+ */
21527
+ get: function () {
21528
+ return this.loadingSubject;
21529
+ },
21530
+ enumerable: false,
21531
+ configurable: true
21532
+ });
21533
+ Object.defineProperty(AppForm.prototype, "error", {
21534
+ get: function () {
21535
+ return this.errorSubject.value;
21536
+ },
21537
+ set: function (error) {
21538
+ this.setError(error);
21539
+ },
21540
+ enumerable: false,
21541
+ configurable: true
21542
+ });
21543
+ Object.defineProperty(AppForm.prototype, "loading", {
21544
+ get: function () {
21545
+ return this.loadingSubject.value;
21546
+ },
21547
+ enumerable: false,
21548
+ configurable: true
21549
+ });
21550
+ Object.defineProperty(AppForm.prototype, "loaded", {
21551
+ get: function () {
21552
+ return !this.loadingSubject.value;
21553
+ },
21554
+ enumerable: false,
21555
+ configurable: true
21556
+ });
21557
+ Object.defineProperty(AppForm.prototype, "value", {
21558
+ get: function () {
21559
+ return this.form.value;
21560
+ },
21561
+ set: function (data) {
21562
+ this.setValue(data);
21563
+ },
21564
+ enumerable: false,
21565
+ configurable: true
21566
+ });
21567
+ Object.defineProperty(AppForm.prototype, "dirty", {
21568
+ get: function () {
21569
+ var _a;
21570
+ return ((_a = this.form) === null || _a === void 0 ? void 0 : _a.dirty) || false;
21571
+ },
21572
+ enumerable: false,
21573
+ configurable: true
21574
+ });
21575
+ Object.defineProperty(AppForm.prototype, "invalid", {
21576
+ get: function () {
21577
+ return !this.form || this.form.invalid;
21578
+ },
21579
+ enumerable: false,
21580
+ configurable: true
21581
+ });
21582
+ Object.defineProperty(AppForm.prototype, "pending", {
21583
+ get: function () {
21584
+ return !this.form || (this.form.dirty && this.form.pending);
21585
+ },
21586
+ enumerable: false,
21587
+ configurable: true
21588
+ });
21589
+ Object.defineProperty(AppForm.prototype, "valid", {
21590
+ get: function () {
21591
+ var _a;
21592
+ return ((_a = this.form) === null || _a === void 0 ? void 0 : _a.valid) || false;
21593
+ },
21594
+ enumerable: false,
21595
+ configurable: true
21596
+ });
21597
+ Object.defineProperty(AppForm.prototype, "empty", {
21598
+ get: function () {
21599
+ return !this.form || (!this.form.dirty && !this.form.touched);
21600
+ },
21601
+ enumerable: false,
21602
+ configurable: true
21603
+ });
21604
+ Object.defineProperty(AppForm.prototype, "untouched", {
21605
+ get: function () {
21606
+ return !this.form || this.form.untouched;
21607
+ },
21608
+ enumerable: false,
21609
+ configurable: true
21610
+ });
21611
+ Object.defineProperty(AppForm.prototype, "enabled", {
21612
+ get: function () {
21613
+ return this._enable;
21614
+ },
21615
+ enumerable: false,
21616
+ configurable: true
21617
+ });
21618
+ Object.defineProperty(AppForm.prototype, "disabled", {
21619
+ get: function () {
21620
+ return !this._enable;
21621
+ },
21622
+ enumerable: false,
21623
+ configurable: true
21624
+ });
21625
+ AppForm.prototype.disable = function (opts) {
21626
+ var _a;
21627
+ (_a = this.form) === null || _a === void 0 ? void 0 : _a.disable(opts);
21628
+ if (this._enable) {
21629
+ this._enable = false;
21630
+ if (!opts || opts.emitEvent !== true)
21631
+ this.markForCheck();
21632
+ }
21633
+ };
21634
+ AppForm.prototype.enable = function (opts) {
21635
+ var _a;
21636
+ (_a = this.form) === null || _a === void 0 ? void 0 : _a.enable(opts);
21637
+ if (!this._enable) {
21638
+ this._enable = true;
21639
+ if (!opts || opts.emitEvent !== true)
21640
+ this.markForCheck();
21641
+ }
21642
+ };
21643
+ Object.defineProperty(AppForm.prototype, "form", {
21644
+ get: function () {
21645
+ return this._form;
21646
+ },
21647
+ set: function (value) {
21648
+ this.setForm(value);
21649
+ },
21650
+ enumerable: false,
21651
+ configurable: true
21652
+ });
21653
+ AppForm.prototype.ngOnInit = function () {
21654
+ this._enable ? this.enable() : this.disable();
21655
+ this.errorTranslatorOptions = this.errorTranslatorOptions || {
21656
+ controlPathTranslator: this
21657
+ };
21658
+ };
21659
+ AppForm.prototype.ngOnDestroy = function () {
21660
+ this._subscription.unsubscribe();
21661
+ this.readySubject.unsubscribe();
21662
+ this.loadingSubject.unsubscribe();
21663
+ this.errorSubject.unsubscribe();
21664
+ this.onCancel.unsubscribe();
21665
+ this.onSubmit.unsubscribe();
21666
+ };
21667
+ AppForm.prototype.cancel = function () {
21668
+ return __awaiter(this, void 0, void 0, function () {
21669
+ return __generator(this, function (_b) {
21670
+ this.onCancel.emit();
21671
+ return [2 /*return*/];
21672
+ });
21673
+ });
21674
+ };
21675
+ /**
21676
+ *
21677
+ * @param event
21678
+ * @param opts allow to skip validation check, using {checkValid: false}
21679
+ */
21680
+ AppForm.prototype.doSubmit = function (event, opts) {
21681
+ return __awaiter(this, void 0, void 0, function () {
21682
+ return __generator(this, function (_b) {
21683
+ switch (_b.label) {
21684
+ case 0:
21685
+ if (!this._form) {
21686
+ this.markAllAsTouched({ emitEvent: true });
21687
+ return [2 /*return*/];
21688
+ }
21689
+ if (!((!opts || opts.checkValid !== false) && !this._form.valid)) return [3 /*break*/, 2];
21690
+ // Wait validation end
21691
+ return [4 /*yield*/, AppFormUtils.waitWhilePending(this._form)];
21692
+ case 1:
21693
+ // Wait validation end
21694
+ _b.sent();
21695
+ // Form is invalid: exit (+ log if debug)
21696
+ if (this._form.invalid) {
21697
+ this.markAllAsTouched({ emitEvent: true });
21698
+ if (this.debug)
21699
+ AppFormUtils.logFormErrors(this._form);
21700
+ return [2 /*return*/];
21701
+ }
21702
+ _b.label = 2;
21703
+ case 2:
21704
+ // Emit event
21705
+ this.onSubmit.emit(event);
21706
+ return [2 /*return*/];
21707
+ }
21708
+ });
21709
+ });
21710
+ };
21711
+ AppForm.prototype.setForm = function (form) {
21712
+ var _this = this;
21713
+ if (this._form !== form) {
21714
+ this._form = form;
21715
+ this._subscription.add(this._form.statusChanges.subscribe(function (status) { return _this.markForCheck(); }));
21716
+ }
21717
+ };
21718
+ AppForm.prototype.setValue = function (data, opts) {
21719
+ if (!data) {
21720
+ console.warn('[form] Trying to set an empty value to form. Skipping');
21721
+ return;
21722
+ }
21723
+ // DEBUG
21724
+ //if (this.debug) console.debug('[form] Updating form (using entity)', data);
21725
+ // Convert object to json, then apply it to form (e.g. convert 'undefined' into 'null')
21726
+ AppFormUtils.copyEntity2Form(data, this.form, Object.assign({ emitEvent: false, onlySelf: true }, opts));
21727
+ if (!opts || opts.emitEvent !== true) {
21728
+ this.markForCheck();
21729
+ }
21730
+ };
21731
+ AppForm.prototype.reset = function (data, opts) {
21732
+ if (data) {
21733
+ if (this.debug)
21734
+ console.debug('[form] Resetting form (using entity)', data);
21735
+ // Convert object to json, then apply it to form (e.g. convert 'undefined' into 'null')
21736
+ var json = AppFormUtils.getFormValueFromEntity(data, this.form);
21737
+ this.form.reset(json, { emitEvent: false, onlySelf: true });
21738
+ }
21739
+ else {
21740
+ this.form.reset(null, { emitEvent: false, onlySelf: true });
21741
+ }
21742
+ if (!opts || opts.emitEvent !== true)
21743
+ this.markForCheck();
21744
+ };
21745
+ AppForm.prototype.markAsPristine = function (opts) {
21746
+ this.form.markAsPristine(opts);
21747
+ if (!opts || opts.emitEvent !== false)
21748
+ this.markForCheck();
21749
+ };
21750
+ AppForm.prototype.markAsUntouched = function (opts) {
21751
+ this.form.markAsUntouched(opts);
21752
+ if (!opts || opts.emitEvent !== false)
21753
+ this.markForCheck();
21754
+ };
21755
+ /**
21756
+ * @deprecated prefer to use markAllAsTouched()
21757
+ * @param opts
21758
+ */
21759
+ AppForm.prototype.markAsTouched = function (opts) {
21760
+ // this.form.markAllAsTouched() // This is not working well (e.g. in TripForm)
21761
+ console.warn('TODO: Replace this call by markAllAsTouched() - because of changes in ngx-components >= 0.16.0');
21762
+ AppFormUtils.markAsTouched(this.form, opts);
21763
+ if (!opts || opts.emitEvent !== false)
21764
+ this.markForCheck();
21765
+ };
21766
+ AppForm.prototype.markAllAsTouched = function (opts) {
21767
+ // this.form.markAllAsTouched() // This is not working well (e.g. in TripForm)
21768
+ AppFormUtils.markAllAsTouched(this.form, opts);
21769
+ if (!opts || opts.emitEvent !== false)
21770
+ this.markForCheck();
21771
+ };
21772
+ AppForm.prototype.markAsDirty = function (opts) {
21773
+ this.form.markAsDirty(opts);
21774
+ if (!opts || opts.emitEvent !== false)
21775
+ this.markForCheck();
21776
+ };
21777
+ AppForm.prototype.markAsLoading = function (opts) {
21778
+ this.setLoading(true, opts);
21779
+ };
21780
+ AppForm.prototype.markAsLoaded = function (opts) {
21781
+ this.setLoading(false, opts);
21782
+ };
21783
+ AppForm.prototype.markAsReady = function (opts) {
21784
+ if (this.readySubject.value !== true) {
21785
+ this.readySubject.next(true);
21786
+ // If subclasses implements OnReady
21787
+ if (typeof this['ngOnReady'] === 'function') {
21788
+ this.ngOnReady();
21789
+ }
21790
+ }
21791
+ };
21792
+ /**
21793
+ * Wait form is ready
21794
+ * @param opts
21795
+ */
21796
+ AppForm.prototype.ready = function (opts) {
21797
+ if (this.readySubject.value)
21798
+ return Promise.resolve();
21799
+ return waitForTrue(this.readySubject, opts);
21800
+ };
21801
+ /**
21802
+ * Wait form is not busy (=loaded)
21803
+ * @param opts
21804
+ */
21805
+ AppForm.prototype.waitIdle = function (opts) {
21806
+ if (!this.loadingSubject.value)
21807
+ return Promise.resolve();
21808
+ return waitForFalse(this.loadingSubject, opts);
21809
+ };
21810
+ AppForm.prototype.updateValueAndValidity = function (opts) {
21811
+ AppFormUtils.updateValueAndValidity(this.form, opts);
21812
+ if (!opts || opts.emitEvent !== false)
21813
+ this.markForCheck();
21814
+ };
21815
+ AppForm.prototype.translateControlPath = function (path) {
21816
+ var _a;
21817
+ var i18nFieldName = this.getI18nFieldName(path);
21818
+ return ((_a = this.translate) === null || _a === void 0 ? void 0 : _a.instant(i18nFieldName)) || i18nFieldName;
21819
+ };
21820
+ /* -- protected methods -- */
21821
+ AppForm.prototype.getFormError = function (form, opts) {
21822
+ if (!form || !this.errorTranslator)
21823
+ return undefined;
21824
+ return this.errorTranslator.translateFormErrors(this.form, Object.assign({ controlPathTranslator: this }, opts));
21825
+ };
21826
+ AppForm.prototype.getI18nFieldName = function (path) {
21827
+ return (this.i18nFieldPrefix || '') + changeCaseToUnderscore(path).toUpperCase();
21828
+ };
21829
+ AppForm.prototype.registerSubscription = function (sub) {
21830
+ return this._subscription.add(sub);
21831
+ };
21832
+ AppForm.prototype.unregisterSubscription = function (sub) {
21833
+ this._subscription.remove(sub);
21834
+ };
21835
+ AppForm.prototype.registerAutocompleteField = function (fieldName, opts) {
21836
+ return this.autocompleteHelper.add(fieldName, opts);
21837
+ };
21838
+ AppForm.prototype.setError = function (value, opts) {
21839
+ if (this.errorSubject.value !== value) {
21840
+ this.errorSubject.next(value);
21841
+ if (!opts || opts.emitEvent !== false) {
21842
+ this.markForCheck();
21843
+ }
21844
+ }
21845
+ };
21846
+ AppForm.prototype.markForCheck = function () {
21847
+ // Should be overwritten by subclasses
21848
+ console.warn('markForCheck() has been called, but is not overwritten by component ' + this.constructor.name);
21849
+ };
21850
+ /* -- private function -- */
21851
+ AppForm.prototype.setLoading = function (value, opts) {
21852
+ if (this.loadingSubject.value !== value) {
21853
+ this.loadingSubject.next(value);
21854
+ if (!opts || opts.emitEvent !== false) {
21855
+ this.markForCheck();
21856
+ }
21857
+ }
21858
+ };
21859
+ return AppForm;
21860
+ }());
21861
+ AppForm.decorators = [
21862
+ { type: i0.Directive }
21863
+ ];
21864
+ AppForm.ctorParameters = function () { return [
21865
+ { type: i0.Injector },
21866
+ { type: i1.FormGroup }
21867
+ ]; };
21868
+ AppForm.propDecorators = {
21869
+ debug: [{ type: i0.Input }],
21870
+ tabindex: [{ type: i0.Input }],
21871
+ errorTranslatorOptions: [{ type: i0.Input }],
21872
+ form: [{ type: i0.Input }],
21873
+ onCancel: [{ type: i0.Output }],
21874
+ onSubmit: [{ type: i0.Output }]
21875
+ };
21876
+
21543
21877
  var AuthForm = /** @class */ (function (_super) {
21544
21878
  __extends(AuthForm, _super);
21545
21879
  function AuthForm(injector, platform, formBuilder, settings, configService, modalCtrl, network, cd, environment) {
@@ -24893,6 +25227,190 @@
24893
25227
  },] }
24894
25228
  ];
24895
25229
 
25230
+ var TextPopover = /** @class */ (function () {
25231
+ function TextPopover(popoverController, translate) {
25232
+ this.popoverController = popoverController;
25233
+ this.translate = translate;
25234
+ this.placeholder = '';
25235
+ this.editing = true;
25236
+ this.multiline = true;
25237
+ this.maxLength = 2000;
25238
+ this.autofocus = false;
25239
+ this.subscription = new rxjs.Subscription();
25240
+ }
25241
+ Object.defineProperty(TextPopover.prototype, "disabled", {
25242
+ get: function () {
25243
+ return this.form.disabled;
25244
+ },
25245
+ enumerable: false,
25246
+ configurable: true
25247
+ });
25248
+ Object.defineProperty(TextPopover.prototype, "enabled", {
25249
+ get: function () {
25250
+ return this.form.enabled;
25251
+ },
25252
+ enumerable: false,
25253
+ configurable: true
25254
+ });
25255
+ Object.defineProperty(TextPopover.prototype, "valid", {
25256
+ get: function () {
25257
+ var _a;
25258
+ return ((_a = this.form) === null || _a === void 0 ? void 0 : _a.valid) || false;
25259
+ },
25260
+ enumerable: false,
25261
+ configurable: true
25262
+ });
25263
+ Object.defineProperty(TextPopover.prototype, "value", {
25264
+ get: function () {
25265
+ var _a;
25266
+ return (_a = this.form) === null || _a === void 0 ? void 0 : _a.value.text;
25267
+ },
25268
+ enumerable: false,
25269
+ configurable: true
25270
+ });
25271
+ TextPopover.prototype.ngOnInit = function () {
25272
+ this.enable();
25273
+ };
25274
+ TextPopover.prototype.ngAfterViewInit = function () {
25275
+ var _this = this;
25276
+ setTimeout(function () { return _this.form.setValue({ text: _this.text }); }, 0);
25277
+ };
25278
+ TextPopover.prototype.onValidate = function (event) {
25279
+ return __awaiter(this, void 0, void 0, function () {
25280
+ var value, err_1;
25281
+ return __generator(this, function (_b) {
25282
+ switch (_b.label) {
25283
+ case 0: return [4 /*yield*/, waitWhilePending(this.form)];
25284
+ case 1:
25285
+ _b.sent();
25286
+ if (!this.valid) {
25287
+ logFormErrors(this.form.control);
25288
+ return [2 /*return*/];
25289
+ }
25290
+ _b.label = 2;
25291
+ case 2:
25292
+ _b.trys.push([2, 4, , 5]);
25293
+ value = this.value;
25294
+ this.disable();
25295
+ return [4 /*yield*/, this.popoverController.dismiss(value)];
25296
+ case 3:
25297
+ _b.sent();
25298
+ this.form.error = null;
25299
+ return [3 /*break*/, 5];
25300
+ case 4:
25301
+ err_1 = _b.sent();
25302
+ this.form.error = (err_1 && err_1.message) || err_1;
25303
+ this.enable();
25304
+ return [3 /*break*/, 5];
25305
+ case 5: return [2 /*return*/];
25306
+ }
25307
+ });
25308
+ });
25309
+ };
25310
+ TextPopover.prototype.disable = function () {
25311
+ this.form.disable();
25312
+ };
25313
+ TextPopover.prototype.enable = function () {
25314
+ if (this.editing)
25315
+ this.form.enable();
25316
+ };
25317
+ TextPopover.prototype.cancel = function () {
25318
+ this.popoverController.dismiss();
25319
+ };
25320
+ TextPopover.prototype.ngOnDestroy = function () {
25321
+ this.subscription.unsubscribe();
25322
+ };
25323
+ return TextPopover;
25324
+ }());
25325
+ TextPopover.decorators = [
25326
+ { type: i0.Component, args: [{
25327
+ selector: 'app-text-popover',
25328
+ template: "\n<ion-content class=\"ion-padding\" cdkTrapFocus [cdkTrapFocusAutoCapture]=\"true\">\n <ion-item *ngIf=\"form.error\" visible-xs visible-sm visible-mobile lines=\"none\">\n <ion-icon color=\"danger\" slot=\"start\" name=\"alert-circle\"></ion-icon>\n <ion-label color=\"danger\" class=\"error\" [innerHTML]=\"form.error|translate\"></ion-label>\n </ion-item>\n\n <app-text-form #form [placeholder]=\"placeholder\"\n [multiline]=\"multiline\"\n [maxLength]=\"maxLength\"\n [autofocus]=\"editing && autofocus\"\n (onSubmit)=\"onValidate($event)\"\n ></app-text-form>\n</ion-content>\n\n<ion-footer>\n <ion-toolbar>\n <ion-row class=\"ion-no-padding\" nowrap>\n <ion-col>\n\n </ion-col>\n\n <ion-col size=\"auto\">\n <ion-button fill=\"clear\" color=\"dark\" (click)=\"cancel()\">\n <ion-label translate>COMMON.BTN_CANCEL</ion-label>\n </ion-button>\n <ion-button\n [fill]=\"disabled ? 'clear' : 'solid'\"\n (click)=\"onValidate($event)\"\n (keyup.enter)=\"onValidate($event)\"\n color=\"tertiary\"\n [disabled]=\"disabled\"\n [title]=\"'COMMON.BTN_VALIDATE_WITH_SHORTCUT_HELP'|translate\">\n <ion-label translate>COMMON.BTN_VALIDATE</ion-label>\n </ion-button>\n </ion-col>\n </ion-row>\n </ion-toolbar>\n</ion-footer>\n"
25329
+ },] }
25330
+ ];
25331
+ TextPopover.ctorParameters = function () { return [
25332
+ { type: i1$5.PopoverController },
25333
+ { type: i1$2.TranslateService }
25334
+ ]; };
25335
+ TextPopover.propDecorators = {
25336
+ form: [{ type: i0.ViewChild, args: ['form', { static: true },] }],
25337
+ text: [{ type: i0.Input }],
25338
+ placeholder: [{ type: i0.Input }],
25339
+ editing: [{ type: i0.Input }],
25340
+ multiline: [{ type: i0.Input }],
25341
+ maxLength: [{ type: i0.Input }],
25342
+ autofocus: [{ type: i0.Input }]
25343
+ };
25344
+
25345
+ var TextForm = /** @class */ (function (_super) {
25346
+ __extends(TextForm, _super);
25347
+ function TextForm(injector, cd, formBuilder) {
25348
+ var _this = _super.call(this, injector) || this;
25349
+ _this.injector = injector;
25350
+ _this.cd = cd;
25351
+ _this.formBuilder = formBuilder;
25352
+ _this.showError = true;
25353
+ _this.multiline = true;
25354
+ _this.autoHeight = false;
25355
+ _this.maxLength = 2000;
25356
+ _this.autofocus = false;
25357
+ _this.textAreaChanges = new i0.EventEmitter();
25358
+ return _this;
25359
+ }
25360
+ TextForm.prototype.ngOnInit = function () {
25361
+ var form = this.formBuilder.group({
25362
+ text: [null, isNotNil(this.maxLength)
25363
+ ? i1.Validators.maxLength(this.maxLength)
25364
+ : undefined
25365
+ ]
25366
+ });
25367
+ this.control = form.get('text');
25368
+ this.setForm(form);
25369
+ _super.prototype.ngOnInit.call(this);
25370
+ };
25371
+ TextForm.prototype.textAreaChanged = function (event) {
25372
+ this.textAreaChanges.emit(this.control.value);
25373
+ };
25374
+ TextForm.prototype.containerResize = function () {
25375
+ var _a;
25376
+ (_a = this.autosizeDirective) === null || _a === void 0 ? void 0 : _a.resizeToFitContent(true);
25377
+ };
25378
+ TextForm.prototype.focusInput = function () {
25379
+ if (this.textArea)
25380
+ focusInput(this.textArea);
25381
+ if (this.textInput)
25382
+ focusInput(this.textInput);
25383
+ };
25384
+ TextForm.prototype.markForCheck = function () {
25385
+ this.cd.markForCheck();
25386
+ };
25387
+ return TextForm;
25388
+ }(AppForm));
25389
+ TextForm.decorators = [
25390
+ { type: i0.Component, args: [{
25391
+ selector: 'app-text-form',
25392
+ template: "<form class=\"form-container\" [formGroup]=\"form\" (ngSubmit)=\"doSubmit($event)\">\n <mat-form-field *ngIf=\"multiline; else monoline\">\n <textarea\n #textArea\n matInput\n [formControl]=\"control\"\n [placeholder]=\"placeholder\"\n [readonly]=\"control.disabled\"\n [class.fixed-height]=\"!autoHeight\"\n [cdkTextareaAutosize]=\"autoHeight\"\n (keyup)=\"textAreaChanged($event)\"\n (keydown.control.enter)=\"onSubmit.emit($event)\"\n [autofocus]=\"autofocus\"\n ></textarea>\n <mat-error *ngIf=\"control.hasError('maxlength')\">\n {{ 'ERROR.FIELD_MAX_LENGTH' | translate: control.errors['maxlength'] }}\n </mat-error>\n <mat-hint *ngIf=\"maxLength\" align=\"end\">\n {{ 'INFO.TEXT_PROGRESS' | translate: { current: textArea.value?.length || 0, max: maxLength } }}\n </mat-hint>\n </mat-form-field>\n <ng-template #monoline>\n <mat-form-field>\n <input\n #textInput\n matInput\n [formControl]=\"control\"\n [placeholder]=\"placeholder\"\n [readonly]=\"disabled\"\n [appAutofocus]=\"autofocus\"\n (keydown.control.enter)=\"onSubmit.emit($event)\"\n />\n <mat-error *ngIf=\"control.hasError('maxlength')\">\n {{ 'ERROR.FIELD_MAX_LENGTH' | translate: control.errors['maxlength'] }}\n </mat-error>\n <mat-hint *ngIf=\"maxLength\" align=\"end\">\n {{ 'INFO.TEXT_PROGRESS' | translate: { current: textInput.value?.length || 0, max: maxLength } }}\n </mat-hint>\n </mat-form-field>\n </ng-template>\n</form>\n",
25393
+ styles: ["textarea.fixed-height{height:11.5em}"]
25394
+ },] }
25395
+ ];
25396
+ TextForm.ctorParameters = function () { return [
25397
+ { type: i0.Injector },
25398
+ { type: i0.ChangeDetectorRef },
25399
+ { type: i1.FormBuilder }
25400
+ ]; };
25401
+ TextForm.propDecorators = {
25402
+ showError: [{ type: i0.Input }],
25403
+ placeholder: [{ type: i0.Input }],
25404
+ multiline: [{ type: i0.Input }],
25405
+ autoHeight: [{ type: i0.Input }],
25406
+ maxLength: [{ type: i0.Input }],
25407
+ autofocus: [{ type: i0.Input }],
25408
+ textAreaChanges: [{ type: i0.Output }],
25409
+ textArea: [{ type: i0.ViewChild, args: ['textArea',] }],
25410
+ textInput: [{ type: i0.ViewChild, args: ['textInput',] }],
25411
+ autosizeDirective: [{ type: i0.ViewChild, args: [textField.CdkTextareaAutosize,] }]
25412
+ };
25413
+
24896
25414
  var AppUpdateOfflineModeCard = /** @class */ (function () {
24897
25415
  function AppUpdateOfflineModeCard() {
24898
25416
  this.onUpdateClick = new i0.EventEmitter();
@@ -25889,7 +26407,8 @@
25889
26407
  this.asyncCreateNew(insertAt);
25890
26408
  };
25891
26409
  EntitiesTableDataSource.prototype.connect = function (collectionViewer) {
25892
- // DEBUG console.debug("[entities-datasource] connect");
26410
+ // DEBUG
26411
+ //console.debug("[entities-datasource] connect");
25893
26412
  return _super_1.prototype.connect.call(this, collectionViewer);
25894
26413
  };
25895
26414
  EntitiesTableDataSource.prototype.disconnect = function (collectionViewer) {
@@ -30336,7 +30855,7 @@
30336
30855
  var _this = this;
30337
30856
  return __generator(this, function (_b) {
30338
30857
  switch (_b.label) {
30339
- case 0: return [4 /*yield*/, Promise.all(((res === null || res === void 0 ? void 0 : res.data) || []).map(function (value) { return _this.processUserEvent(value, _this); }))];
30858
+ case 0: return [4 /*yield*/, Promise.all(((res === null || res === void 0 ? void 0 : res.data) || []).map(function (value) { return _this.processUserEvent(value); }))];
30340
30859
  case 1:
30341
30860
  data = _b.sent();
30342
30861
  if (now) {
@@ -30397,7 +30916,7 @@
30397
30916
  })];
30398
30917
  case 1:
30399
30918
  res = _b.sent();
30400
- return [4 /*yield*/, Promise.all(((res === null || res === void 0 ? void 0 : res.data) || []).map(function (value) { return _this.processUserEvent(value, _this); }))];
30919
+ return [4 /*yield*/, Promise.all(((res === null || res === void 0 ? void 0 : res.data) || []).map(function (value) { return _this.processUserEvent(value); }))];
30401
30920
  case 2:
30402
30921
  data = _b.sent();
30403
30922
  if (now)
@@ -30420,6 +30939,22 @@
30420
30939
  });
30421
30940
  });
30422
30941
  };
30942
+ AbstractUserEventService.prototype.load = function (id, opts) {
30943
+ return __awaiter(this, void 0, void 0, function () {
30944
+ var filter, data;
30945
+ return __generator(this, function (_b) {
30946
+ switch (_b.label) {
30947
+ case 0:
30948
+ filter = this.defaultFilter();
30949
+ filter.includedIds = [id];
30950
+ return [4 /*yield*/, this.loadPage({ offset: 0, size: 1 }, filter, opts)];
30951
+ case 1:
30952
+ data = (_b.sent()).data;
30953
+ return [2 /*return*/, data && data[0]];
30954
+ }
30955
+ });
30956
+ });
30957
+ };
30423
30958
  AbstractUserEventService.prototype.add = function (entity) {
30424
30959
  return __awaiter(this, void 0, void 0, function () {
30425
30960
  var withContent;
@@ -30427,7 +30962,6 @@
30427
30962
  switch (_b.label) {
30428
30963
  case 0: return [4 /*yield*/, this.processUserEvent(entity)];
30429
30964
  case 1:
30430
- // TODO set an id !!!!!!!!!!!!!!!!!!!!!!!!!
30431
30965
  entity = _b.sent();
30432
30966
  if (!entity)
30433
30967
  return [2 /*return*/]; // Rejected
@@ -30439,7 +30973,9 @@
30439
30973
  });
30440
30974
  // Update count
30441
30975
  this._countSubject.next(this._countSubject.value + 1);
30442
- return [2 /*return*/];
30976
+ // Add id
30977
+ console.log('TODO: add an ID to user event ?');
30978
+ return [2 /*return*/, entity];
30443
30979
  }
30444
30980
  });
30445
30981
  });
@@ -30547,7 +31083,7 @@
30547
31083
  });
30548
31084
  }
30549
31085
  if (!(!opts || opts.toEntity !== false)) return [3 /*break*/, 2];
30550
- return [4 /*yield*/, Promise.all((data || []).map(function (value) { return _this.processUserEvent(value, _this); }))];
31086
+ return [4 /*yield*/, Promise.all((data || []).map(function (value) { return _this.processUserEvent(value); }))];
30551
31087
  case 1: return [2 /*return*/, _b.sent()];
30552
31088
  case 2: return [2 /*return*/, data];
30553
31089
  }
@@ -30801,16 +31337,15 @@
30801
31337
  (_a = this._listenSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
30802
31338
  this._listenSubscription = undefined;
30803
31339
  };
30804
- AbstractUserEventService.prototype.processUserEvent = function (source, that) {
31340
+ AbstractUserEventService.prototype.processUserEvent = function (source) {
30805
31341
  return __awaiter(this, void 0, void 0, function () {
30806
31342
  var target, listeners, listeners_1, listeners_1_1, listener, res, _b, e_3_1;
30807
31343
  var e_3, _c;
30808
31344
  return __generator(this, function (_d) {
30809
31345
  switch (_d.label) {
30810
31346
  case 0:
30811
- that = that || this;
30812
- target = that.fromObject(source);
30813
- listeners = (that.listeners || [])
31347
+ target = this.fromObject(source);
31348
+ listeners = (this.listeners || [])
30814
31349
  .filter(function (listener) { return !!listener.onReceived; })
30815
31350
  .filter(function (listener) { return listener.accept(target); });
30816
31351
  _d.label = 1;
@@ -30835,8 +31370,8 @@
30835
31370
  target = _b;
30836
31371
  return [3 /*break*/, 7];
30837
31372
  case 6:
30838
- if (that._debug)
30839
- console.debug(that._logPrefix + "Event has been rejected by a listener", source);
31373
+ if (this._debug)
31374
+ console.debug(this._logPrefix + "Event has been rejected by a listener", source);
30840
31375
  return [3 /*break*/, 8];
30841
31376
  case 7:
30842
31377
  listeners_1_1 = listeners_1.next();
@@ -30870,8 +31405,8 @@
30870
31405
  return [2 /*return*/];
30871
31406
  // set read date
30872
31407
  userEvents.forEach(function (userEvent) { return userEvent.readDate = moment$6(); });
30873
- localEntities = userEvents.filter(function (userEvent) { return !userEvent.id || userEvent.id < 0; });
30874
- remoteEntities = userEvents.filter(function (userEvent) { return userEvent.id > 0; });
31408
+ localEntities = userEvents.filter(EntityUtils.isLocal);
31409
+ remoteEntities = userEvents.filter(EntityUtils.isRemote);
30875
31410
  // save local entities
30876
31411
  if (localEntities.length) {
30877
31412
  if (this._debug)
@@ -30910,9 +31445,6 @@
30910
31445
  recipients: [this.defaultRecipient()]
30911
31446
  };
30912
31447
  };
30913
- AbstractUserEventService.prototype.defaultRecipient = function () {
30914
- return this.accountService.person.pubkey;
30915
- };
30916
31448
  AbstractUserEventService.prototype.fillDefaultProperties = function (entity) {
30917
31449
  };
30918
31450
  AbstractUserEventService.prototype.unreadEvents = function (events) {
@@ -31605,7 +32137,7 @@
31605
32137
  _this.environment = environment;
31606
32138
  _this._logPrefix = '[job-progression-service] ';
31607
32139
  // For DEV only
31608
- _this._debug = !(environment === null || environment === void 0 ? void 0 : environment.production);
32140
+ _this._debug = environment && !environment.production;
31609
32141
  return _this;
31610
32142
  }
31611
32143
  JobProgressionService.prototype.listenChanges = function (id, options) {
@@ -33551,8 +34083,167 @@
33551
34083
  },] }
33552
34084
  ];
33553
34085
 
34086
+ // @dynamic
34087
+ exports.ImageAttachment = /** @class */ (function (_super) {
34088
+ __extends(ImageAttachment, _super);
34089
+ function ImageAttachment() {
34090
+ var _this = _super.apply(this, __spread(arguments)) || this;
34091
+ _this.dataUrl = null;
34092
+ _this.url = null;
34093
+ _this.title = null;
34094
+ return _this;
34095
+ }
34096
+ ImageAttachment.prototype.fromObject = function (source, opts) {
34097
+ _super.prototype.fromObject.call(this, source, opts);
34098
+ this.url = source.url;
34099
+ this.dataUrl = source.dataUrl;
34100
+ this.title = source.title;
34101
+ };
34102
+ return ImageAttachment;
34103
+ }(Entity));
34104
+ exports.ImageAttachment = __decorate([
34105
+ EntityClass({ typename: 'ImageAttachmentVO' })
34106
+ ], exports.ImageAttachment);
34107
+ // @dynamic
34108
+ exports.ImageAttachmentFilter = /** @class */ (function (_super) {
34109
+ __extends(ImageAttachmentFilter, _super);
34110
+ function ImageAttachmentFilter() {
34111
+ return _super !== null && _super.apply(this, arguments) || this;
34112
+ }
34113
+ return ImageAttachmentFilter;
34114
+ }(EntityFilter));
34115
+ exports.ImageAttachmentFilter = __decorate([
34116
+ EntityClass({ typename: 'ImageAttachmentFilterVO' })
34117
+ ], exports.ImageAttachmentFilter);
34118
+ var ImageAttachmentService = /** @class */ (function (_super) {
34119
+ __extends(ImageAttachmentService, _super);
34120
+ function ImageAttachmentService(platform) {
34121
+ var _this = _super.call(this, platform) || this;
34122
+ _this.platform = platform;
34123
+ _this.$images = new rxjs.BehaviorSubject([
34124
+ { id: 0, url: 'https://test.sumaris.net/assets/img/bg/ray-1.jpg', title: 'ray #1' },
34125
+ { id: 1, url: 'https://test.sumaris.net/assets/img/bg/ray-2.jpg', title: 'ray #2' }
34126
+ ]);
34127
+ console.debug('[gallery-testing-service] Create service');
34128
+ return _this;
34129
+ }
34130
+ ImageAttachmentService.prototype.ngOnStart = function () {
34131
+ return Promise.resolve(undefined);
34132
+ };
34133
+ ImageAttachmentService.prototype.watchAll = function (offset, size, sortBy, sortDirection, filter, opts) {
34134
+ console.debug('[gallery-testing-service] Watching images...');
34135
+ return this.$images
34136
+ .pipe(operators.map(function (images) {
34137
+ var data = (images || []).map(exports.ImageAttachment.fromObject);
34138
+ data = EntityUtils.sort(data, sortBy, sortDirection);
34139
+ console.debug("[gallery-testing-service] Loaded " + data.length + " images...");
34140
+ return { data: data, total: data.length };
34141
+ }));
34142
+ };
34143
+ ImageAttachmentService.prototype.saveAll = function (entities, opts) {
34144
+ return __awaiter(this, void 0, void 0, function () {
34145
+ var currentId;
34146
+ return __generator(this, function (_a) {
34147
+ if (!entities)
34148
+ return [2 /*return*/, []];
34149
+ currentId = this.$images.value.reduce(function (res, image) { return Math.max(res, +(image === null || image === void 0 ? void 0 : image.id) || 0); }, 0);
34150
+ entities.filter(function (item) { return isNil(item.id); })
34151
+ .forEach(function (item) {
34152
+ item.id = ++currentId;
34153
+ });
34154
+ this.$images.next(__spread(this.$images.value, entities));
34155
+ return [2 /*return*/];
34156
+ });
34157
+ });
34158
+ };
34159
+ ImageAttachmentService.prototype.deleteAll = function (entities, opts) {
34160
+ return __awaiter(this, void 0, void 0, function () {
34161
+ var deletedIds, filteredData;
34162
+ return __generator(this, function (_a) {
34163
+ deletedIds = (entities || []).map(function (item) { return item.id; }).filter(isNotNil);
34164
+ filteredData = (this.$images.value).filter(function (item) { return !deletedIds.includes(item.id); });
34165
+ this.$images.next(filteredData);
34166
+ return [2 /*return*/];
34167
+ });
34168
+ });
34169
+ };
34170
+ ImageAttachmentService.prototype.asFilter = function (filter) {
34171
+ return exports.ImageAttachmentFilter.fromObject(filter);
34172
+ };
34173
+ return ImageAttachmentService;
34174
+ }(StartableService));
34175
+ ImageAttachmentService.decorators = [
34176
+ { type: i0.Injectable }
34177
+ ];
34178
+ ImageAttachmentService.ctorParameters = function () { return [
34179
+ { type: i1$5.Platform }
34180
+ ]; };
34181
+
34182
+ var GalleryTestPage = /** @class */ (function () {
34183
+ function GalleryTestPage(dataService) {
34184
+ this.dataService = dataService;
34185
+ this._subscription = new rxjs.Subscription();
34186
+ this.dataSource = new EntitiesTableDataSource(exports.ImageAttachment, this.dataService);
34187
+ }
34188
+ GalleryTestPage.prototype.ngOnInit = function () {
34189
+ this._subscription.add(this.dataSource.watchAll(0, 100, null, null, null)
34190
+ .subscribe());
34191
+ };
34192
+ GalleryTestPage.prototype.ngOnDestroy = function () {
34193
+ this._subscription.unsubscribe();
34194
+ };
34195
+ return GalleryTestPage;
34196
+ }());
34197
+ GalleryTestPage.decorators = [
34198
+ { type: i0.Component, args: [{
34199
+ selector: 'app-gallery-test-page',
34200
+ template: "<ion-header>\n <ion-toolbar color=\"primary\">\n\n <ion-buttons slot=\"start\">\n <ion-back-button></ion-back-button>\n </ion-buttons>\n\n <ion-title>Image gallery</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content>\n <app-image-gallery [dataSource]=\"dataSource\">\n </app-image-gallery>\n</ion-content>\n",
34201
+ providers: [
34202
+ { provide: ImageAttachmentService, useClass: ImageAttachmentService }
34203
+ ]
34204
+ },] }
34205
+ ];
34206
+ GalleryTestPage.ctorParameters = function () { return [
34207
+ { type: ImageAttachmentService }
34208
+ ]; };
34209
+
34210
+ var routes$4 = [
34211
+ {
34212
+ path: 'gallery',
34213
+ pathMatch: 'full',
34214
+ component: GalleryTestPage
34215
+ },
34216
+ ];
34217
+ var ImageGalleryTestingModule = /** @class */ (function () {
34218
+ function ImageGalleryTestingModule() {
34219
+ }
34220
+ return ImageGalleryTestingModule;
34221
+ }());
34222
+ ImageGalleryTestingModule.decorators = [
34223
+ { type: i0.NgModule, args: [{
34224
+ imports: [
34225
+ i1$4.CommonModule,
34226
+ i1$5.IonicModule,
34227
+ ImageGalleryModule,
34228
+ i1$2.TranslateModule.forChild(),
34229
+ i3.RouterModule.forChild(routes$4),
34230
+ i1$2.TranslateModule.forChild(),
34231
+ ],
34232
+ declarations: [
34233
+ // Components
34234
+ GalleryTestPage
34235
+ ],
34236
+ exports: [
34237
+ i3.RouterModule,
34238
+ // Components
34239
+ GalleryTestPage
34240
+ ]
34241
+ },] }
34242
+ ];
34243
+
33554
34244
  var SHARED_TESTING_PAGES = __spread(SHARED_MATERIAL_TESTING_PAGES, [
33555
34245
  { label: 'Shared other components', divider: true },
34246
+ { label: 'Image gallery', page: '/testing/shared/gallery' },
33556
34247
  { label: 'Toast', page: '/testing/shared/toast' },
33557
34248
  { label: 'File upload', page: '/testing/shared/upload-file' }
33558
34249
  ]);
@@ -33565,17 +34256,20 @@
33565
34256
  { type: i0.NgModule, args: [{
33566
34257
  imports: [
33567
34258
  i1$4.CommonModule,
34259
+ i1$5.IonicModule,
33568
34260
  i1$2.TranslateModule.forChild(),
33569
34261
  // Testing sub-modules
33570
34262
  MaterialTestingModule,
33571
34263
  ToastTestingModule,
33572
- UploadFileTestingModule
34264
+ UploadFileTestingModule,
34265
+ ImageGalleryTestingModule
33573
34266
  ],
33574
34267
  exports: [
33575
34268
  // Testing sub-modules
33576
34269
  MaterialTestingModule,
33577
34270
  ToastTestingModule,
33578
- UploadFileTestingModule
34271
+ UploadFileTestingModule,
34272
+ ImageGalleryTestingModule
33579
34273
  ]
33580
34274
  },] }
33581
34275
  ];
@@ -33963,7 +34657,7 @@
33963
34657
  { type: i1$5.PopoverController }
33964
34658
  ]; };
33965
34659
 
33966
- var routes$4 = [
34660
+ var routes$5 = [
33967
34661
  {
33968
34662
  path: 'text-popover',
33969
34663
  pathMatch: 'full',
@@ -33981,7 +34675,7 @@
33981
34675
  i1$4.CommonModule,
33982
34676
  i1$5.IonicModule,
33983
34677
  i1$2.TranslateModule.forChild(),
33984
- i3.RouterModule.forChild(routes$4)
34678
+ i3.RouterModule.forChild(routes$5)
33985
34679
  ],
33986
34680
  declarations: [
33987
34681
  TextPopoverTestingPage
@@ -33998,7 +34692,7 @@
33998
34692
  { label: 'Table', page: '/testing/core/table' },
33999
34693
  { label: 'Text popover', page: '/testing/core/text-popover' }
34000
34694
  ];
34001
- var routes$5 = [
34695
+ var routes$6 = [
34002
34696
  {
34003
34697
  path: '',
34004
34698
  pathMatch: 'full',
@@ -34025,7 +34719,7 @@
34025
34719
  imports: [
34026
34720
  i1$4.CommonModule,
34027
34721
  i1$2.TranslateModule.forChild(),
34028
- i3.RouterModule.forChild(routes$5),
34722
+ i3.RouterModule.forChild(routes$6),
34029
34723
  // Sub modules
34030
34724
  TableTestingModule,
34031
34725
  TextPopoverTestingModule
@@ -34202,6 +34896,7 @@
34202
34896
  this.recipients = source.recipients || [];
34203
34897
  this.startDate = fromDateISOString(source.startDate);
34204
34898
  this.excludeRead = source.excludeRead || false;
34899
+ this.includedIds = source.includedIds || [];
34205
34900
  };
34206
34901
  UserEventTestFilter.prototype.buildFilter = function () {
34207
34902
  var _this = this;
@@ -34221,6 +34916,9 @@
34221
34916
  if (isNotNil(this.startDate)) {
34222
34917
  filterFns.push(function (t) { return _this.startDate.isSameOrBefore(t.creationDate); });
34223
34918
  }
34919
+ if (isNotEmptyArray(this.includedIds)) {
34920
+ filterFns.push(function (t) { return _this.includedIds.includes(t.id); });
34921
+ }
34224
34922
  if (this.excludeRead === true) {
34225
34923
  filterFns.push(function (t) { return isNil(t.readSignature); }); // todo or t.signature ?
34226
34924
  }
@@ -34272,7 +34970,7 @@
34272
34970
  ], this.$userEvents.value));
34273
34971
  this._countSubject.next((this._countSubject.value || 0) + 1);
34274
34972
  this.$newUserEvents.next([entity]);
34275
- return [2 /*return*/];
34973
+ return [2 /*return*/, entity];
34276
34974
  }
34277
34975
  });
34278
34976
  });
@@ -34335,6 +35033,9 @@
34335
35033
  });
34336
35034
  });
34337
35035
  };
35036
+ UserEventTestService.prototype.defaultRecipient = function () {
35037
+ return this.accountService.isLogin() ? this.accountService.person.pubkey : undefined;
35038
+ };
34338
35039
  UserEventTestService.prototype.watchAll = function (offset, size, sortBy, sortDirection, filter, opts) {
34339
35040
  var _this = this;
34340
35041
  return this.$userEvents.pipe(operators.map(function (userEvents) {
@@ -34377,7 +35078,7 @@
34377
35078
  { type: AccountService },
34378
35079
  { type: NetworkService },
34379
35080
  { type: i1$2.TranslateService },
34380
- { type: Environment, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [ENVIRONMENT,] }] }
35081
+ { type: Environment, decorators: [{ type: i0.Inject, args: [ENVIRONMENT,] }] }
34381
35082
  ]; };
34382
35083
 
34383
35084
  var moment$a = momentImported__namespace;
@@ -34637,7 +35338,7 @@
34637
35338
  { label: 'User event', page: '/testing/social/user-event' },
34638
35339
  { label: 'Job progression', page: '/testing/social/job-progression' }
34639
35340
  ];
34640
- var routes$6 = [
35341
+ var routes$7 = [
34641
35342
  {
34642
35343
  path: 'job-progression',
34643
35344
  pathMatch: 'full',
@@ -34659,7 +35360,7 @@
34659
35360
  imports: [
34660
35361
  i1$4.CommonModule,
34661
35362
  i1$2.TranslateModule.forChild(),
34662
- i3.RouterModule.forChild(routes$6),
35363
+ i3.RouterModule.forChild(routes$7),
34663
35364
  JobTestingModule,
34664
35365
  UserEventTestingModule
34665
35366
  ],
@@ -34709,6 +35410,7 @@
34709
35410
  exports.AppHelpModal = AppHelpModal;
34710
35411
  exports.AppIconComponent = AppIconComponent;
34711
35412
  exports.AppIconModule = AppIconModule;
35413
+ exports.AppImageGalleryComponent = AppImageGalleryComponent;
34712
35414
  exports.AppInMemoryTable = AppInMemoryTable;
34713
35415
  exports.AppInstallUpgradeCard = AppInstallUpgradeCard;
34714
35416
  exports.AppListForm = AppListForm;
@@ -34737,7 +35439,6 @@
34737
35439
  exports.AutocompleteTestPage = AutocompleteTestPage;
34738
35440
  exports.AutofocusDirective = AutofocusDirective;
34739
35441
  exports.Base58 = Base58;
34740
- exports.Base64ImageReader = Base64ImageReader;
34741
35442
  exports.BaseEntityService = BaseEntityService;
34742
35443
  exports.BaseGraphqlService = BaseGraphqlService;
34743
35444
  exports.BaseGraphqlServiceOptions = BaseGraphqlServiceOptions;
@@ -34791,6 +35492,7 @@
34791
35492
  exports.FileResponse = FileResponse;
34792
35493
  exports.FileService = FileService;
34793
35494
  exports.FileSizePipe = FileSizePipe;
35495
+ exports.FilesUtils = FilesUtils;
34794
35496
  exports.FormArrayHelper = FormArrayHelper;
34795
35497
  exports.FormButtonsBarComponent = FormButtonsBarComponent;
34796
35498
  exports.FormButtonsBarToken = FormButtonsBarToken;
@@ -34803,6 +35505,7 @@
34803
35505
  exports.FormGetPipe = FormGetPipe;
34804
35506
  exports.FormGetValuePipe = FormGetValuePipe;
34805
35507
  exports.Fragments = Fragments$1;
35508
+ exports.GalleryTestPage = GalleryTestPage;
34806
35509
  exports.GraphqlService = GraphqlService;
34807
35510
  exports.HAMMER_PRESS_TIME = HAMMER_PRESS_TIME;
34808
35511
  exports.HAMMER_TAP_TIME = HAMMER_TAP_TIME;
@@ -34811,6 +35514,11 @@
34811
35514
  exports.Hotkeys = Hotkeys;
34812
35515
  exports.HotkeysDialogComponent = HotkeysDialogComponent;
34813
35516
  exports.IMAGE_DEFAULTS = IMAGE_DEFAULTS;
35517
+ exports.ImageAttachmentService = ImageAttachmentService;
35518
+ exports.ImageGalleryTestingModule = ImageGalleryTestingModule;
35519
+ exports.ImageModule = ImageModule;
35520
+ exports.ImageService = ImageService;
35521
+ exports.ImagesUtils = ImagesUtils;
34814
35522
  exports.InMemoryEntitiesService = InMemoryEntitiesService;
34815
35523
  exports.IsLoginAccountPipe = IsLoginAccountPipe;
34816
35524
  exports.IsNilOrBlankPipe = IsNilOrBlankPipe;
@@ -34867,6 +35575,7 @@
34867
35575
  exports.MessageService = MessageService;
34868
35576
  exports.MessageTypeList = MessageTypeList;
34869
35577
  exports.MessageTypes = MessageTypes;
35578
+ exports.MimeTypes = MimeTypes;
34870
35579
  exports.ModalToolbarComponent = ModalToolbarComponent;
34871
35580
  exports.NetworkService = NetworkService;
34872
35581
  exports.NgInitDirective = NgInitDirective;
@@ -35121,7 +35830,7 @@
35121
35830
  exports.ɵa = CustomReuseStrategy;
35122
35831
  exports.ɵb = MatNumpadDomService;
35123
35832
  exports.ɵc = isFocusableElement;
35124
- exports.ɵd = FilesUtils;
35833
+ exports.ɵd = ImageGalleryModule;
35125
35834
  exports.ɵe = RegisterForm;
35126
35835
  exports.ɵf = AccountValidatorService;
35127
35836
  exports.ɵg = RegisterModal;