@sneat/ext-assetus-components 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/esm2022/index.js +2 -0
  2. package/esm2022/index.js.map +1 -0
  3. package/esm2022/lib/asset-add/add-asset-base-component.js +48 -0
  4. package/esm2022/lib/asset-add/add-asset-base-component.js.map +1 -0
  5. package/esm2022/lib/asset-add/asset-add-document/asset-add-document.component.js +166 -0
  6. package/esm2022/lib/asset-add/asset-add-document/asset-add-document.component.js.map +1 -0
  7. package/esm2022/lib/asset-add/asset-add-dwelling/asset-add-dwelling.component.js +115 -0
  8. package/esm2022/lib/asset-add/asset-add-dwelling/asset-add-dwelling.component.js.map +1 -0
  9. package/esm2022/lib/asset-add/asset-add-vehicle/asset-add-vehicle.component.js +173 -0
  10. package/esm2022/lib/asset-add/asset-add-vehicle/asset-add-vehicle.component.js.map +1 -0
  11. package/esm2022/lib/asset-add/index.js +4 -0
  12. package/esm2022/lib/asset-add/index.js.map +1 -0
  13. package/esm2022/lib/asset-base-page.js +30 -0
  14. package/esm2022/lib/asset-base-page.js.map +1 -0
  15. package/esm2022/lib/asset-card/asset-card.component.js +41 -0
  16. package/esm2022/lib/asset-card/asset-card.component.js.map +1 -0
  17. package/esm2022/lib/asset-component-base-params.js +16 -0
  18. package/esm2022/lib/asset-component-base-params.js.map +1 -0
  19. package/esm2022/lib/asset-possesion-card/asset-possession-card.component.js +36 -0
  20. package/esm2022/lib/asset-possesion-card/asset-possession-card.component.js.map +1 -0
  21. package/esm2022/lib/asset-reg-number-input/asset-reg-number-input.component.js +118 -0
  22. package/esm2022/lib/asset-reg-number-input/asset-reg-number-input.component.js.map +1 -0
  23. package/esm2022/lib/assets-list/assets-list.component.js +138 -0
  24. package/esm2022/lib/assets-list/assets-list.component.js.map +1 -0
  25. package/esm2022/lib/edit-dwelling-card/edit-dwelling-card.component.js +121 -0
  26. package/esm2022/lib/edit-dwelling-card/edit-dwelling-card.component.js.map +1 -0
  27. package/esm2022/lib/index.js +14 -0
  28. package/esm2022/lib/index.js.map +1 -0
  29. package/esm2022/lib/make-model-card/make-model-card.component.js +68 -0
  30. package/esm2022/lib/make-model-card/make-model-card.component.js.map +1 -0
  31. package/esm2022/lib/mileage-dialog/mileage-dialog.component.js +128 -0
  32. package/esm2022/lib/mileage-dialog/mileage-dialog.component.js.map +1 -0
  33. package/esm2022/lib/period-segment/period-segment.component.js +24 -0
  34. package/esm2022/lib/period-segment/period-segment.component.js.map +1 -0
  35. package/esm2022/lib/real-estate-location/real-estate-location.component.js +22 -0
  36. package/esm2022/lib/real-estate-location/real-estate-location.component.js.map +1 -0
  37. package/esm2022/lib/services/asset-service.dto.js +2 -0
  38. package/esm2022/lib/services/asset-service.dto.js.map +1 -0
  39. package/esm2022/lib/services/asset-service.js +59 -0
  40. package/esm2022/lib/services/asset-service.js.map +1 -0
  41. package/esm2022/lib/services/assetus-services.module.js +17 -0
  42. package/esm2022/lib/services/assetus-services.module.js.map +1 -0
  43. package/esm2022/lib/services/assetus-space.service.js +18 -0
  44. package/esm2022/lib/services/assetus-space.service.js.map +1 -0
  45. package/esm2022/lib/services/index.js +5 -0
  46. package/esm2022/lib/services/index.js.map +1 -0
  47. package/esm2022/lib/vehicle-card/vehicle-card.component.js +160 -0
  48. package/esm2022/lib/vehicle-card/vehicle-card.component.js.map +1 -0
  49. package/esm2022/lib/vehicle-engine/vehicle-engine.component.js +98 -0
  50. package/esm2022/lib/vehicle-engine/vehicle-engine.component.js.map +1 -0
  51. package/esm2022/sneat-ext-assetus-components.js +5 -0
  52. package/esm2022/sneat-ext-assetus-components.js.map +1 -0
  53. package/index.d.ts +1 -0
  54. package/lib/asset-add/add-asset-base-component.d.ts +20 -0
  55. package/lib/asset-add/asset-add-document/asset-add-document.component.d.ts +26 -0
  56. package/lib/asset-add/asset-add-dwelling/asset-add-dwelling.component.d.ts +16 -0
  57. package/lib/asset-add/asset-add-vehicle/asset-add-vehicle.component.d.ts +26 -0
  58. package/lib/asset-add/index.d.ts +3 -0
  59. package/lib/asset-base-page.d.ts +15 -0
  60. package/lib/asset-card/asset-card.component.d.ts +13 -0
  61. package/lib/asset-component-base-params.d.ts +9 -0
  62. package/lib/asset-possesion-card/asset-possession-card.component.d.ts +12 -0
  63. package/lib/asset-reg-number-input/asset-reg-number-input.component.d.ts +31 -0
  64. package/lib/assets-list/assets-list.component.d.ts +25 -0
  65. package/lib/edit-dwelling-card/edit-dwelling-card.component.d.ts +23 -0
  66. package/lib/index.d.ts +13 -0
  67. package/lib/make-model-card/make-model-card.component.d.ts +20 -0
  68. package/lib/mileage-dialog/mileage-dialog.component.d.ts +33 -0
  69. package/lib/period-segment/period-segment.component.d.ts +10 -0
  70. package/lib/real-estate-location/real-estate-location.component.d.ts +7 -0
  71. package/lib/services/asset-service.d.ts +19 -0
  72. package/lib/services/asset-service.dto.d.ts +23 -0
  73. package/lib/services/assetus-services.module.d.ts +6 -0
  74. package/lib/services/assetus-space.service.d.ts +10 -0
  75. package/lib/services/index.d.ts +4 -0
  76. package/lib/vehicle-card/vehicle-card.component.d.ts +34 -0
  77. package/lib/vehicle-engine/vehicle-engine.component.d.ts +14 -0
  78. package/package.json +27 -0
  79. package/sneat-ext-assetus-components.d.ts +5 -0
  80. package/tsconfig.lib.prod.tsbuildinfo +1 -0
@@ -0,0 +1,2 @@
1
+ export * from './lib';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/extensions/assetus/components/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC","sourcesContent":["export * from './lib';\n"]}
@@ -0,0 +1,48 @@
1
+ import { Component, inject } from '@angular/core';
2
+ import { FormControl, UntypedFormGroup, Validators } from '@angular/forms';
3
+ import { SpaceBaseComponent } from '@sneat/space-components';
4
+ import { AssetService } from '../services';
5
+ import * as i0 from "@angular/core";
6
+ export class AddAssetBaseComponent extends SpaceBaseComponent {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.isSubmitting = false;
10
+ this.titleForm = new UntypedFormGroup({
11
+ title: new FormControl('', Validators.required),
12
+ });
13
+ this.assetService = inject(AssetService);
14
+ }
15
+ static { this.metadata = {
16
+ inputs: ['space'],
17
+ }; }
18
+ createAssetAndGoToAssetPage(request, space) {
19
+ if (!this.space) {
20
+ throw new Error('no team context');
21
+ }
22
+ this.assetService
23
+ .createAsset(this.space, request)
24
+ .subscribe({
25
+ next: (asset) => {
26
+ this.spaceParams.spaceNavService
27
+ .navigateForwardToSpacePage(space, 'asset/' + asset.id, {
28
+ replaceUrl: true,
29
+ state: { asset, space },
30
+ })
31
+ .catch(this.spaceParams.errorLogger.logErrorHandler(`failed to navigate to team page`));
32
+ },
33
+ error: (err) => {
34
+ this.isSubmitting = false;
35
+ this.spaceParams.errorLogger.logError(err, 'Failed to create a new asset');
36
+ },
37
+ });
38
+ }
39
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: AddAssetBaseComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
40
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.0", type: AddAssetBaseComponent, isStandalone: true, selector: "ng-component", usesInheritance: true, ngImport: i0, template: '', isInline: true }); }
41
+ }
42
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: AddAssetBaseComponent, decorators: [{
43
+ type: Component,
44
+ args: [{
45
+ template: '',
46
+ }]
47
+ }] });
48
+ //# sourceMappingURL=add-asset-base-component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-asset-base-component.js","sourceRoot":"","sources":["../../../../../../../../libs/extensions/assetus/components/src/lib/asset-add/add-asset-base-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EA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CAAC,QAAQ,CACnC,GAAG,EACH,8BAA8B,CAC/B,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;IACP,CAAC;8GAjDmB,qBAAqB;kGAArB,qBAAqB,+FAF/B,EAAE;;2FAEQ,qBAAqB;kBAH1C,SAAS;mBAAC;oBACT,QAAQ,EAAE,EAAE;iBACb","sourcesContent":["import { Component, inject } from '@angular/core';\nimport { FormControl, UntypedFormGroup, Validators } from '@angular/forms';\nimport { IContactusSpaceDboAndID } from '@sneat/contactus-core';\nimport { AssetExtraType, IAssetExtra } from '@sneat/mod-assetus-core';\nimport { SpaceBaseComponent } from '@sneat/space-components';\nimport { ISpaceContext } from '@sneat/space-models';\nimport { AssetService, ICreateAssetRequest } from '../services';\n\n@Component({\n template: '',\n})\nexport abstract class AddAssetBaseComponent extends SpaceBaseComponent {\n public static readonly metadata = {\n inputs: ['space'],\n };\n\n public contactusSpace?: IContactusSpaceDboAndID;\n public country?: string;\n\n public isSubmitting = false;\n\n public titleForm = new UntypedFormGroup({\n title: new FormControl<string>('', Validators.required),\n });\n\n protected readonly assetService = inject(AssetService);\n\n protected createAssetAndGoToAssetPage<\n ExtraType extends AssetExtraType,\n Extra extends IAssetExtra,\n >(\n request: ICreateAssetRequest<ExtraType, Extra>,\n space: ISpaceContext,\n ): void {\n if (!this.space) {\n throw new Error('no team context');\n }\n this.assetService\n .createAsset<ExtraType, Extra>(this.space, request)\n .subscribe({\n next: (asset) => {\n this.spaceParams.spaceNavService\n .navigateForwardToSpacePage(space, 'asset/' + asset.id, {\n replaceUrl: true,\n state: { asset, space },\n })\n .catch(\n this.spaceParams.errorLogger.logErrorHandler(\n `failed to navigate to team page`,\n ),\n );\n },\n error: (err) => {\n this.isSubmitting = false;\n this.spaceParams.errorLogger.logError(\n err,\n 'Failed to create a new asset',\n );\n },\n });\n }\n}\n"]}
@@ -0,0 +1,166 @@
1
+ import { Component, Input } from '@angular/core';
2
+ import { FormsModule } from '@angular/forms';
3
+ import { IonButton, IonButtons, IonCard, IonDatetime, IonIcon, IonInput, IonItem, IonPopover, } from '@ionic/angular/standalone';
4
+ import { ClassName, SelectFromListComponent } from '@sneat/ui';
5
+ import { SpaceComponentBaseParams } from '@sneat/space-components';
6
+ import { format, parseISO } from 'date-fns';
7
+ import { AddAssetBaseComponent } from '../add-asset-base-component';
8
+ import * as i0 from "@angular/core";
9
+ import * as i1 from "@angular/forms";
10
+ export class AssetAddDocumentComponent extends AddAssetBaseComponent {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.documentTypes = [
14
+ { id: 'car', title: 'Car', iconName: 'car-outline' },
15
+ { id: 'motorbike', title: 'Motorbike', iconName: 'bicycle-outline' },
16
+ // { id: 'bicycle', title: 'Bicycle', iconName: 'bicycle-outline' }, this is a sport asset
17
+ { id: 'boat', title: 'Boat', iconName: 'boat-outline' },
18
+ ];
19
+ this.countryIso2 = 'IE';
20
+ this.regNumber = '';
21
+ this.vin = '';
22
+ this.yearOfBuild = '';
23
+ // public make = '';
24
+ // public model = '';
25
+ this.engine = '';
26
+ this.nctExpires = ''; // ISO date string 'YYYY-MM-DD'
27
+ this.taxExpires = ''; // ISO date string 'YYYY-MM-DD'
28
+ this.nextServiceDue = ''; // ISO date string 'YYYY-MM-DD'
29
+ }
30
+ ngOnChanges(changes) {
31
+ const spaceChanges = changes['space'];
32
+ if (spaceChanges && this.space) {
33
+ const a = this.documentAsset ?? {
34
+ id: '',
35
+ space: this.space ?? { id: '' },
36
+ dbo: {
37
+ status: 'draft',
38
+ category: 'vehicle',
39
+ extraType: 'document',
40
+ extra: {},
41
+ spaceID: this.space?.id,
42
+ type: this.documentType,
43
+ title: '',
44
+ possession: undefined,
45
+ createdAt: new Date().toISOString(),
46
+ createdBy: '-',
47
+ updatedAt: new Date().toISOString(),
48
+ updatedBy: '-',
49
+ },
50
+ };
51
+ this.documentAsset = { ...a, space: this.space };
52
+ }
53
+ }
54
+ onAssetChanged(_asset) {
55
+ // TODO: Implement asset changed logic
56
+ }
57
+ onVehicleTypeChanged() {
58
+ if (this.documentAsset?.dbo) {
59
+ this.documentAsset = {
60
+ ...this.documentAsset,
61
+ dbo: {
62
+ ...this.documentAsset.dbo,
63
+ type: this.documentType,
64
+ extraType: 'document',
65
+ extra: {},
66
+ },
67
+ };
68
+ }
69
+ }
70
+ formatDate(value) {
71
+ return value && !Array.isArray(value)
72
+ ? format(parseISO(value), 'dd MMMM yyyy')
73
+ : '';
74
+ }
75
+ submitDocumentForm() {
76
+ if (!this.space) {
77
+ throw 'no team context';
78
+ }
79
+ if (!this.documentType) {
80
+ throw 'no vehicleType';
81
+ }
82
+ const assetDto = this.documentAsset?.dbo;
83
+ if (!assetDto) {
84
+ throw new Error('no asset');
85
+ }
86
+ this.isSubmitting = true;
87
+ let request = {
88
+ asset: {
89
+ ...assetDto,
90
+ status: 'active',
91
+ category: 'vehicle',
92
+ },
93
+ spaceID: this.space?.id,
94
+ };
95
+ if (this.yearOfBuild) {
96
+ request = {
97
+ ...request,
98
+ asset: { ...request.asset, yearOfBuild: +this.yearOfBuild },
99
+ };
100
+ }
101
+ // if (this.vin) {
102
+ // vehicle.vin = this.vin;
103
+ // }
104
+ // if (this.countryIso2) {
105
+ // request.countryID = this.countryIso2;
106
+ // }
107
+ // if (this.taxExpires) {
108
+ // vehicle.taxExpires = this.taxExpires;
109
+ // }
110
+ // if (this.nctExpires) {
111
+ // vehicle.nctExpires = this.nctExpires;
112
+ // }
113
+ // if (this.nextServiceDue) {
114
+ // vehicle.nextServiceDue = this.nextServiceDue;
115
+ // }
116
+ // const { engine } = this;
117
+ // if (engine) {
118
+ // const engineLower = engine.toLowerCase();
119
+ // request.engine = engine;
120
+ // if (engineLower.includes('petrol')) {
121
+ // request.fuelType = 'petrol';
122
+ // } else if (engineLower.includes('diesel')) {
123
+ // request.fuelType = 'diesel';
124
+ // }
125
+ // const size = engine.match(/(\d+(\.\d)?)+L/);
126
+ // console.log('size:', size);
127
+ // if (size) {
128
+ // // tslint:disable-next-line:no-magic-numbers
129
+ // request.engineCC = +size[1] * 1000;
130
+ // }
131
+ // }
132
+ this.createAssetAndGoToAssetPage(request, this.space);
133
+ }
134
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: AssetAddDocumentComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
135
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.0", type: AssetAddDocumentComponent, isStandalone: true, selector: "sneat-asset-add-document", inputs: { documentAsset: "documentAsset" }, providers: [
136
+ {
137
+ provide: ClassName,
138
+ useValue: 'AssetAddVehicleComponent',
139
+ },
140
+ SpaceComponentBaseParams,
141
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "@if (documentType) {\n <h1 class=\"ion-padding\">New {{ documentType }}</h1>\n} @else {\n <h1 class=\"ion-padding\">New vehicle</h1>\n}\n\n@if (!documentType) {\n <ion-card>\n <sneat-select-from-list\n [(ngModel)]=\"documentType\"\n (ngModelChange)=\"onVehicleTypeChanged()\"\n [isFilterable]=\"false\"\n title=\"Type\"\n [items]=\"documentTypes\"\n />\n </ion-card>\n}\n\n<ion-card>\n <ion-item>\n <!-- Datetime in popover with input -->\n <ion-input label=\"Taxed till\" [value]=\"taxExpires\" />\n <ion-buttons slot=\"end\">\n <ion-button fill=\"clear\" id=\"open-date-input-2\">\n <ion-icon icon=\"calendar\" />\n </ion-button>\n </ion-buttons>\n <ion-popover trigger=\"open-date-input-2\" show-backdrop=\"false\">\n <ng-template>\n <ion-datetime\n #popoverDatetime2\n presentation=\"date\"\n (ionChange)=\"taxExpires = formatDate(popoverDatetime2.value)\"\n />\n </ng-template>\n </ion-popover>\n </ion-item>\n <!--\t\t<ion-item>-->\n <!--\t\t\t<ion-label>NCT till</ion-label>-->\n <!--\t\t\t<ion-datetime max=\"2021\" [(ngModel)]=\"nctExpires\"></ion-datetime>-->\n <!--\t\t</ion-item>-->\n <!--\t\t<ion-item>-->\n <!--\t\t\t<ion-label>Service due</ion-label>-->\n <!--\t\t\t<ion-datetime max=\"2021\" [(ngModel)]=\"nextServiceDue\"></ion-datetime>-->\n <!--\t\t</ion-item>-->\n</ion-card>\n\n@if (documentAsset?.dbo?.extra?.[\"regNumber\"]) {\n <ion-button\n [color]=\"documentAsset?.dbo?.extra?.['regNumber'] ? 'primary' : 'light'\"\n size=\"large\"\n class=\"ion-margin\"\n expand=\"full\"\n [disabled]=\"!space || isSubmitting\"\n (click)=\"submitDocumentForm()\"\n >\n @if (isSubmitting) {\n Adding vehicle...\n } @else {\n Add vehicle\n }\n </ion-button>\n}\n\n<div style=\"height: 300px\"></div>\n<!--TODO: workaround for calendar overlap -->\n", dependencies: [{ kind: "component", type: IonCard, selector: "ion-card", inputs: ["button", "color", "disabled", "download", "href", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: SelectFromListComponent, selector: "sneat-select-from-list", inputs: ["value", "filterLabel", "label", "listLabel", "listLabelColor", "isFilterable", "isLoading", "items", "items$", "lastItemLines", "labelPlacement", "justify", "other", "canAdd", "filterItem", "selectMode", "isReadonly", "$isProcessing", "sortBy"], outputs: ["valueChange", "filterChanged"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: IonItem, selector: "ion-item", inputs: ["button", "color", "detail", "detailIcon", "disabled", "download", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "counter", "counterFormatter", "debounce", "disabled", "enterkeyhint", "errorText", "fill", "helperText", "inputmode", "label", "labelPlacement", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "shape", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: IonButtons, selector: "ion-buttons", inputs: ["collapse"] }, { kind: "component", type: IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "form", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"] }, { kind: "component", type: IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }, { kind: "component", type: IonPopover, selector: "ion-popover" }, { kind: "component", type: IonDatetime, selector: "ion-datetime", inputs: ["cancelText", "clearText", "color", "dayValues", "disabled", "doneText", "firstDayOfWeek", "formatOptions", "highlightedDates", "hourCycle", "hourValues", "isDateEnabled", "locale", "max", "min", "minuteValues", "mode", "monthValues", "multiple", "name", "preferWheel", "presentation", "readonly", "showAdjacentDays", "showClearButton", "showDefaultButtons", "showDefaultTimeLabel", "showDefaultTitle", "size", "titleSelectedDatesFormatter", "value", "yearValues"] }] }); }
142
+ }
143
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: AssetAddDocumentComponent, decorators: [{
144
+ type: Component,
145
+ args: [{ selector: 'sneat-asset-add-document', providers: [
146
+ {
147
+ provide: ClassName,
148
+ useValue: 'AssetAddVehicleComponent',
149
+ },
150
+ SpaceComponentBaseParams,
151
+ ], imports: [
152
+ IonCard,
153
+ SelectFromListComponent,
154
+ FormsModule,
155
+ IonItem,
156
+ IonInput,
157
+ IonButtons,
158
+ IonButton,
159
+ IonIcon,
160
+ IonPopover,
161
+ IonDatetime,
162
+ ], template: "@if (documentType) {\n <h1 class=\"ion-padding\">New {{ documentType }}</h1>\n} @else {\n <h1 class=\"ion-padding\">New vehicle</h1>\n}\n\n@if (!documentType) {\n <ion-card>\n <sneat-select-from-list\n [(ngModel)]=\"documentType\"\n (ngModelChange)=\"onVehicleTypeChanged()\"\n [isFilterable]=\"false\"\n title=\"Type\"\n [items]=\"documentTypes\"\n />\n </ion-card>\n}\n\n<ion-card>\n <ion-item>\n <!-- Datetime in popover with input -->\n <ion-input label=\"Taxed till\" [value]=\"taxExpires\" />\n <ion-buttons slot=\"end\">\n <ion-button fill=\"clear\" id=\"open-date-input-2\">\n <ion-icon icon=\"calendar\" />\n </ion-button>\n </ion-buttons>\n <ion-popover trigger=\"open-date-input-2\" show-backdrop=\"false\">\n <ng-template>\n <ion-datetime\n #popoverDatetime2\n presentation=\"date\"\n (ionChange)=\"taxExpires = formatDate(popoverDatetime2.value)\"\n />\n </ng-template>\n </ion-popover>\n </ion-item>\n <!--\t\t<ion-item>-->\n <!--\t\t\t<ion-label>NCT till</ion-label>-->\n <!--\t\t\t<ion-datetime max=\"2021\" [(ngModel)]=\"nctExpires\"></ion-datetime>-->\n <!--\t\t</ion-item>-->\n <!--\t\t<ion-item>-->\n <!--\t\t\t<ion-label>Service due</ion-label>-->\n <!--\t\t\t<ion-datetime max=\"2021\" [(ngModel)]=\"nextServiceDue\"></ion-datetime>-->\n <!--\t\t</ion-item>-->\n</ion-card>\n\n@if (documentAsset?.dbo?.extra?.[\"regNumber\"]) {\n <ion-button\n [color]=\"documentAsset?.dbo?.extra?.['regNumber'] ? 'primary' : 'light'\"\n size=\"large\"\n class=\"ion-margin\"\n expand=\"full\"\n [disabled]=\"!space || isSubmitting\"\n (click)=\"submitDocumentForm()\"\n >\n @if (isSubmitting) {\n Adding vehicle...\n } @else {\n Add vehicle\n }\n </ion-button>\n}\n\n<div style=\"height: 300px\"></div>\n<!--TODO: workaround for calendar overlap -->\n" }]
163
+ }], propDecorators: { documentAsset: [{
164
+ type: Input
165
+ }] } });
166
+ //# sourceMappingURL=asset-add-document.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-add-document.component.js","sourceRoot":"","sources":["../../../../../../../../../libs/extensions/assetus/components/src/lib/asset-add/asset-add-document/asset-add-document.component.ts","../../../../../../../../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AAiC;QACjC,gDAAgD;QAChD,iCAAiC;QACjC,KAAK;QACL,gDAAgD;QAChD,+BAA+B;QAC/B,eAAe;QACf,iDAAiD;QACjD,wCAAwC;QACxC,KAAK;QACL,IAAI;QAEJ,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;8GA1IU,yBAAyB;kGAAzB,yBAAyB,mHApBzB;YACT;gBACE,OAAO,EAAE,SAAS;gBAClB,QAAQ,EAAE,0BAA0B;aACrC;YACD,wBAAwB;SACzB,sECnCH,04DAkEA,4CD7BI,OAAO,yLACP,uBAAuB,6WACvB,WAAW,+VACX,OAAO,0NACP,QAAQ,8eACR,UAAU,8EACV,SAAS,oPACT,OAAO,2JACP,UAAU,wDACV,WAAW;;2FAGF,yBAAyB;kBAvBrC,SAAS;+BACE,0BAA0B,aAEzB;wBACT;4BACE,OAAO,EAAE,SAAS;4BAClB,QAAQ,EAAE,0BAA0B;yBACrC;wBACD,wBAAwB;qBACzB,WACQ;wBACP,OAAO;wBACP,uBAAuB;wBACvB,WAAW;wBACX,OAAO;wBACP,QAAQ;wBACR,UAAU;wBACV,SAAS;wBACT,OAAO;wBACP,UAAU;wBACV,WAAW;qBACZ;;sBAOA,KAAK","sourcesContent":["import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport {\n IonButton,\n IonButtons,\n IonCard,\n IonDatetime,\n IonIcon,\n IonInput,\n IonItem,\n IonPopover,\n} from '@ionic/angular/standalone';\nimport { ClassName, ISelectItem, SelectFromListComponent } from '@sneat/ui';\nimport { timestamp } from '@sneat/dto';\nimport {\n AssetPossession,\n AssetVehicleType,\n IAssetContext,\n IAssetDocumentContext,\n IAssetDocumentExtra,\n} from '@sneat/mod-assetus-core';\nimport { SpaceComponentBaseParams } from '@sneat/space-components';\nimport { format, parseISO } from 'date-fns';\nimport { ICreateAssetRequest } from '../../services';\nimport { AddAssetBaseComponent } from '../add-asset-base-component';\n\n@Component({\n selector: 'sneat-asset-add-document',\n templateUrl: './asset-add-document.component.html',\n providers: [\n {\n provide: ClassName,\n useValue: 'AssetAddVehicleComponent',\n },\n SpaceComponentBaseParams,\n ],\n imports: [\n IonCard,\n SelectFromListComponent,\n FormsModule,\n IonItem,\n IonInput,\n IonButtons,\n IonButton,\n IonIcon,\n IonPopover,\n IonDatetime,\n ],\n})\nexport class AssetAddDocumentComponent\n extends AddAssetBaseComponent\n implements OnChanges\n{\n // @Input() public override space?: ISpaceContext;\n @Input() public documentAsset?: IAssetDocumentContext;\n\n protected documentType?: AssetVehicleType;\n protected readonly documentTypes: ISelectItem[] = [\n { id: 'car', title: 'Car', iconName: 'car-outline' },\n { id: 'motorbike', title: 'Motorbike', iconName: 'bicycle-outline' },\n // { id: 'bicycle', title: 'Bicycle', iconName: 'bicycle-outline' }, this is a sport asset\n { id: 'boat', title: 'Boat', iconName: 'boat-outline' },\n ];\n\n protected countryIso2 = 'IE';\n protected regNumber = '';\n protected vin = '';\n protected yearOfBuild = '';\n // public make = '';\n // public model = '';\n protected engine = '';\n protected engines?: string[];\n\n protected nctExpires = ''; // ISO date string 'YYYY-MM-DD'\n protected taxExpires = ''; // ISO date string 'YYYY-MM-DD'\n protected nextServiceDue = ''; // ISO date string 'YYYY-MM-DD'\n\n ngOnChanges(changes: SimpleChanges): void {\n const spaceChanges = changes['space'];\n if (spaceChanges && this.space) {\n const a: IAssetContext<'document'> = this.documentAsset ?? {\n id: '',\n space: this.space ?? { id: '' },\n dbo: {\n status: 'draft',\n category: 'vehicle',\n extraType: 'document',\n extra: {},\n spaceID: this.space?.id,\n type: this.documentType,\n title: '',\n possession: undefined as unknown as AssetPossession,\n createdAt: new Date().toISOString() as unknown as timestamp,\n createdBy: '-',\n updatedAt: new Date().toISOString() as unknown as timestamp,\n updatedBy: '-',\n },\n };\n this.documentAsset = { ...a, space: this.space };\n }\n }\n\n protected onAssetChanged(_asset: IAssetContext): void {\n // TODO: Implement asset changed logic\n }\n\n protected onVehicleTypeChanged(): void {\n if (this.documentAsset?.dbo) {\n this.documentAsset = {\n ...this.documentAsset,\n dbo: {\n ...this.documentAsset.dbo,\n type: this.documentType,\n extraType: 'document',\n extra: {},\n },\n };\n }\n }\n\n protected formatDate(value?: string | string[] | null): string {\n return value && !Array.isArray(value)\n ? format(parseISO(value), 'dd MMMM yyyy')\n : '';\n }\n\n protected submitDocumentForm(): void {\n if (!this.space) {\n throw 'no team context';\n }\n if (!this.documentType) {\n throw 'no vehicleType';\n }\n const assetDto = this.documentAsset?.dbo;\n if (!assetDto) {\n throw new Error('no asset');\n }\n this.isSubmitting = true;\n let request: ICreateAssetRequest<'document', IAssetDocumentExtra> = {\n asset: {\n ...assetDto,\n status: 'active',\n category: 'vehicle',\n },\n spaceID: this.space?.id,\n };\n if (this.yearOfBuild) {\n request = {\n ...request,\n asset: { ...request.asset, yearOfBuild: +this.yearOfBuild },\n };\n }\n\n // if (this.vin) {\n // \tvehicle.vin = this.vin;\n // }\n // if (this.countryIso2) {\n // \trequest.countryID = this.countryIso2;\n // }\n // if (this.taxExpires) {\n // \tvehicle.taxExpires = this.taxExpires;\n // }\n // if (this.nctExpires) {\n // \tvehicle.nctExpires = this.nctExpires;\n // }\n // if (this.nextServiceDue) {\n // \tvehicle.nextServiceDue = this.nextServiceDue;\n // }\n\n // const { engine } = this;\n // if (engine) {\n // \tconst engineLower = engine.toLowerCase();\n // \trequest.engine = engine;\n // \tif (engineLower.includes('petrol')) {\n // \t\trequest.fuelType = 'petrol';\n // \t} else if (engineLower.includes('diesel')) {\n // \t\trequest.fuelType = 'diesel';\n // \t}\n // \tconst size = engine.match(/(\\d+(\\.\\d)?)+L/);\n // \tconsole.log('size:', size);\n // \tif (size) {\n // \t\t// tslint:disable-next-line:no-magic-numbers\n // \t\trequest.engineCC = +size[1] * 1000;\n // \t}\n // }\n\n this.createAssetAndGoToAssetPage(request, this.space);\n }\n}\n","@if (documentType) {\n <h1 class=\"ion-padding\">New {{ documentType }}</h1>\n} @else {\n <h1 class=\"ion-padding\">New vehicle</h1>\n}\n\n@if (!documentType) {\n <ion-card>\n <sneat-select-from-list\n [(ngModel)]=\"documentType\"\n (ngModelChange)=\"onVehicleTypeChanged()\"\n [isFilterable]=\"false\"\n title=\"Type\"\n [items]=\"documentTypes\"\n />\n </ion-card>\n}\n\n<ion-card>\n <ion-item>\n <!-- Datetime in popover with input -->\n <ion-input label=\"Taxed till\" [value]=\"taxExpires\" />\n <ion-buttons slot=\"end\">\n <ion-button fill=\"clear\" id=\"open-date-input-2\">\n <ion-icon icon=\"calendar\" />\n </ion-button>\n </ion-buttons>\n <ion-popover trigger=\"open-date-input-2\" show-backdrop=\"false\">\n <ng-template>\n <ion-datetime\n #popoverDatetime2\n presentation=\"date\"\n (ionChange)=\"taxExpires = formatDate(popoverDatetime2.value)\"\n />\n </ng-template>\n </ion-popover>\n </ion-item>\n <!--\t\t<ion-item>-->\n <!--\t\t\t<ion-label>NCT till</ion-label>-->\n <!--\t\t\t<ion-datetime max=\"2021\" [(ngModel)]=\"nctExpires\"></ion-datetime>-->\n <!--\t\t</ion-item>-->\n <!--\t\t<ion-item>-->\n <!--\t\t\t<ion-label>Service due</ion-label>-->\n <!--\t\t\t<ion-datetime max=\"2021\" [(ngModel)]=\"nextServiceDue\"></ion-datetime>-->\n <!--\t\t</ion-item>-->\n</ion-card>\n\n@if (documentAsset?.dbo?.extra?.[\"regNumber\"]) {\n <ion-button\n [color]=\"documentAsset?.dbo?.extra?.['regNumber'] ? 'primary' : 'light'\"\n size=\"large\"\n class=\"ion-margin\"\n expand=\"full\"\n [disabled]=\"!space || isSubmitting\"\n (click)=\"submitDocumentForm()\"\n >\n @if (isSubmitting) {\n Adding vehicle...\n } @else {\n Add vehicle\n }\n </ion-button>\n}\n\n<div style=\"height: 300px\"></div>\n<!--TODO: workaround for calendar overlap -->\n"]}
@@ -0,0 +1,115 @@
1
+ import { Component, Input } from '@angular/core';
2
+ import { FormsModule } from '@angular/forms';
3
+ import { IonButton, IonCard } from '@ionic/angular/standalone';
4
+ import { ClassName, SelectFromListComponent } from '@sneat/ui';
5
+ import { SpaceComponentBaseParams } from '@sneat/space-components';
6
+ import { AddDwellingCardComponent } from '../../edit-dwelling-card/edit-dwelling-card.component';
7
+ import { AddAssetBaseComponent } from '../add-asset-base-component';
8
+ import * as i0 from "@angular/core";
9
+ import * as i1 from "@angular/forms";
10
+ export class AssetAddDwellingComponent extends AddAssetBaseComponent {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.dwellingTypes = [
14
+ { id: 'house', title: 'House', iconName: 'home-outline' },
15
+ { id: 'apartment', title: 'Apartment', iconName: 'business-outline' },
16
+ { id: 'room', title: 'Room', iconName: 'storefront-outline' },
17
+ ];
18
+ }
19
+ ngOnChanges(changes) {
20
+ if (changes['space'] && this.space) {
21
+ this.dwellingAsset = this.dwellingAsset ?? {
22
+ id: '',
23
+ space: this.space ?? { id: '' },
24
+ dbo: {
25
+ status: 'draft',
26
+ category: 'dwelling',
27
+ extraType: 'dwelling',
28
+ extra: {
29
+ rent_price: { value: 0, currency: 'USD' },
30
+ },
31
+ spaceID: this.space?.id,
32
+ type: this.dwellingType,
33
+ title: 'My dwelling',
34
+ possession: 'owning',
35
+ createdAt: new Date().toISOString(),
36
+ createdBy: '-',
37
+ updatedAt: new Date().toISOString(),
38
+ updatedBy: '-',
39
+ },
40
+ };
41
+ }
42
+ }
43
+ onDwellingTypeChanged() {
44
+ if (this.dwellingAsset?.dbo) {
45
+ this.dwellingAsset = {
46
+ ...this.dwellingAsset,
47
+ dbo: {
48
+ ...this.dwellingAsset.dbo,
49
+ type: this.dwellingType,
50
+ },
51
+ };
52
+ }
53
+ }
54
+ onAssetChanged(asset) {
55
+ this.dwellingAsset = asset;
56
+ }
57
+ submitDwellingForm() {
58
+ // console.log('submitDwellingForm', this.dwellingAsset);
59
+ if (!this.space) {
60
+ throw new Error('no team context');
61
+ }
62
+ if (!this.dwellingAsset) {
63
+ throw new Error('no dwellingType');
64
+ }
65
+ const assetDto = this.dwellingAsset?.dbo;
66
+ if (!assetDto) {
67
+ throw new Error('no asset');
68
+ }
69
+ this.isSubmitting = true;
70
+ if (assetDto.extra) {
71
+ if (assetDto.extra.numberOfBedrooms) {
72
+ assetDto.extra.numberOfBedrooms = +assetDto.extra?.numberOfBedrooms;
73
+ }
74
+ if (assetDto.extra.areaSqM) {
75
+ assetDto.extra.areaSqM = +assetDto.extra?.areaSqM;
76
+ }
77
+ }
78
+ const request = {
79
+ asset: {
80
+ ...assetDto,
81
+ status: 'active',
82
+ category: 'dwelling',
83
+ },
84
+ spaceID: this.space?.id,
85
+ };
86
+ this.createAssetAndGoToAssetPage(request, this.space);
87
+ }
88
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: AssetAddDwellingComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
89
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.0", type: AssetAddDwellingComponent, isStandalone: true, selector: "sneat-asset-add-dwelling", inputs: { dwellingAsset: "dwellingAsset" }, providers: [
90
+ {
91
+ provide: ClassName,
92
+ useValue: 'AssetAddDwellingComponent',
93
+ },
94
+ SpaceComponentBaseParams,
95
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "@if (dwellingType) {\n <h1 class=\"ion-padding\">New {{ dwellingType }}</h1>\n} @else {\n <h1 class=\"ion-padding\">New dwelling</h1>\n}\n\n@if (dwellingType) {\n <sneat-edit-dwelling-card\n [space]=\"space\"\n [(dwellingAsset)]=\"dwellingAsset\"\n (dwellingAssetChange)=\"onAssetChanged($event)\"\n />\n} @else {\n <ion-card>\n <sneat-select-from-list\n [(ngModel)]=\"dwellingType\"\n (ngModelChange)=\"onDwellingTypeChanged()\"\n [isFilterable]=\"false\"\n title=\"Type\"\n [items]=\"dwellingTypes\"\n />\n </ion-card>\n}\n\n@if (dwellingAsset?.dbo?.type || dwellingAsset?.dbo?.countryID) {\n <ion-button\n [color]=\"dwellingAsset?.dbo?.type ? 'primary' : 'light'\"\n size=\"large\"\n class=\"ion-margin\"\n expand=\"full\"\n [disabled]=\"!space || isSubmitting\"\n (click)=\"submitDwellingForm()\"\n >\n @if (isSubmitting) {\n Adding dwelling...\n } @else {\n Add dwelling\n }\n </ion-button>\n}\n", dependencies: [{ kind: "component", type: AddDwellingCardComponent, selector: "sneat-edit-dwelling-card", inputs: ["space", "dwellingAsset"], outputs: ["dwellingAssetChange"] }, { kind: "component", type: IonCard, selector: "ion-card", inputs: ["button", "color", "disabled", "download", "href", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: SelectFromListComponent, selector: "sneat-select-from-list", inputs: ["value", "filterLabel", "label", "listLabel", "listLabelColor", "isFilterable", "isLoading", "items", "items$", "lastItemLines", "labelPlacement", "justify", "other", "canAdd", "filterItem", "selectMode", "isReadonly", "$isProcessing", "sortBy"], outputs: ["valueChange", "filterChanged"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "form", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"] }] }); }
96
+ }
97
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: AssetAddDwellingComponent, decorators: [{
98
+ type: Component,
99
+ args: [{ selector: 'sneat-asset-add-dwelling', providers: [
100
+ {
101
+ provide: ClassName,
102
+ useValue: 'AssetAddDwellingComponent',
103
+ },
104
+ SpaceComponentBaseParams,
105
+ ], imports: [
106
+ AddDwellingCardComponent,
107
+ IonCard,
108
+ SelectFromListComponent,
109
+ FormsModule,
110
+ IonButton,
111
+ ], template: "@if (dwellingType) {\n <h1 class=\"ion-padding\">New {{ dwellingType }}</h1>\n} @else {\n <h1 class=\"ion-padding\">New dwelling</h1>\n}\n\n@if (dwellingType) {\n <sneat-edit-dwelling-card\n [space]=\"space\"\n [(dwellingAsset)]=\"dwellingAsset\"\n (dwellingAssetChange)=\"onAssetChanged($event)\"\n />\n} @else {\n <ion-card>\n <sneat-select-from-list\n [(ngModel)]=\"dwellingType\"\n (ngModelChange)=\"onDwellingTypeChanged()\"\n [isFilterable]=\"false\"\n title=\"Type\"\n [items]=\"dwellingTypes\"\n />\n </ion-card>\n}\n\n@if (dwellingAsset?.dbo?.type || dwellingAsset?.dbo?.countryID) {\n <ion-button\n [color]=\"dwellingAsset?.dbo?.type ? 'primary' : 'light'\"\n size=\"large\"\n class=\"ion-margin\"\n expand=\"full\"\n [disabled]=\"!space || isSubmitting\"\n (click)=\"submitDwellingForm()\"\n >\n @if (isSubmitting) {\n Adding dwelling...\n } @else {\n Add dwelling\n }\n </ion-button>\n}\n" }]
112
+ }], propDecorators: { dwellingAsset: [{
113
+ type: Input
114
+ }] } });
115
+ //# sourceMappingURL=asset-add-dwelling.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-add-dwelling.component.js","sourceRoot":"","sources":["../../../../../../../../../libs/extensions/assetus/components/src/lib/asset-add/asset-add-dwelling/asset-add-dwelling.component.ts","../../../../../../../../../libs/extensions/assetus/components/src/lib/asset-add/asset-add-dwelling/asset-add-dwelling.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAA4B,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAe,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAQ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C;QACH,CAAC;QAED,MAAM,OAAO,GAAyD;YACpE,KAAK,EAAE;gBACL,GAAG,QAAQ;gBACX,MAAM,EAAE,QAAQ;gBAChB,QAAQ,EAAE,UAAU;aACrB;YACD,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE;SACxB,CAAC;QAEF,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;8GAvFU,yBAAyB;kGAAzB,yBAAyB,mHAfzB;YACT;gBACE,OAAO,EAAE,SAAS;gBAClB,QAAQ,EAAE,2BAA2B;aACtC;YACD,wBAAwB;SACzB,sECzBH,49BAwCA,4CDbI,wBAAwB,2IACxB,OAAO,yLACP,uBAAuB,6WACvB,WAAW,+VACX,SAAS;;2FAGA,yBAAyB;kBAlBrC,SAAS;+BACE,0BAA0B,aAEzB;wBACT;4BACE,OAAO,EAAE,SAAS;4BAClB,QAAQ,EAAE,2BAA2B;yBACtC;wBACD,wBAAwB;qBACzB,WACQ;wBACP,wBAAwB;wBACxB,OAAO;wBACP,uBAAuB;wBACvB,WAAW;wBACX,SAAS;qBACV;;sBAMA,KAAK","sourcesContent":["import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { IonButton, IonCard } from '@ionic/angular/standalone';\nimport { ClassName, ISelectItem, SelectFromListComponent } from '@sneat/ui';\nimport { timestamp } from '@sneat/dto';\nimport {\n AssetRealEstateType,\n IAssetContext,\n IAssetDwellingContext,\n IAssetDwellingExtra,\n} from '@sneat/mod-assetus-core';\nimport { SpaceComponentBaseParams } from '@sneat/space-components';\nimport { AddDwellingCardComponent } from '../../edit-dwelling-card/edit-dwelling-card.component';\nimport { ICreateAssetRequest } from '../../services';\nimport { AddAssetBaseComponent } from '../add-asset-base-component';\n\n@Component({\n selector: 'sneat-asset-add-dwelling',\n templateUrl: './asset-add-dwelling.component.html',\n providers: [\n {\n provide: ClassName,\n useValue: 'AssetAddDwellingComponent',\n },\n SpaceComponentBaseParams,\n ],\n imports: [\n AddDwellingCardComponent,\n IonCard,\n SelectFromListComponent,\n FormsModule,\n IonButton,\n ],\n})\nexport class AssetAddDwellingComponent\n extends AddAssetBaseComponent\n implements OnChanges\n{\n @Input() public dwellingAsset?: IAssetDwellingContext;\n\n protected dwellingType?: AssetRealEstateType;\n protected readonly dwellingTypes: ISelectItem[] = [\n { id: 'house', title: 'House', iconName: 'home-outline' },\n { id: 'apartment', title: 'Apartment', iconName: 'business-outline' },\n { id: 'room', title: 'Room', iconName: 'storefront-outline' },\n ];\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes['space'] && this.space) {\n this.dwellingAsset = this.dwellingAsset ?? {\n id: '',\n space: this.space ?? { id: '' },\n dbo: {\n status: 'draft',\n category: 'dwelling',\n extraType: 'dwelling',\n extra: {\n rent_price: { value: 0, currency: 'USD' },\n },\n spaceID: this.space?.id,\n type: this.dwellingType,\n title: 'My dwelling',\n possession: 'owning',\n createdAt: new Date().toISOString() as unknown as timestamp,\n createdBy: '-',\n updatedAt: new Date().toISOString() as unknown as timestamp,\n updatedBy: '-',\n },\n };\n }\n }\n\n protected onDwellingTypeChanged(): void {\n if (this.dwellingAsset?.dbo) {\n this.dwellingAsset = {\n ...this.dwellingAsset,\n dbo: {\n ...this.dwellingAsset.dbo,\n type: this.dwellingType,\n },\n };\n }\n }\n\n protected onAssetChanged(asset: IAssetContext): void {\n this.dwellingAsset = asset as IAssetDwellingContext;\n }\n\n protected submitDwellingForm(): void {\n // console.log('submitDwellingForm', this.dwellingAsset);\n if (!this.space) {\n throw new Error('no team context');\n }\n if (!this.dwellingAsset) {\n throw new Error('no dwellingType');\n }\n const assetDto = this.dwellingAsset?.dbo;\n if (!assetDto) {\n throw new Error('no asset');\n }\n this.isSubmitting = true;\n\n if (assetDto.extra) {\n if (assetDto.extra.numberOfBedrooms) {\n assetDto.extra.numberOfBedrooms = +assetDto.extra?.numberOfBedrooms;\n }\n if (assetDto.extra.areaSqM) {\n assetDto.extra.areaSqM = +assetDto.extra?.areaSqM;\n }\n }\n\n const request: ICreateAssetRequest<'dwelling', IAssetDwellingExtra> = {\n asset: {\n ...assetDto,\n status: 'active',\n category: 'dwelling',\n },\n spaceID: this.space?.id,\n };\n\n this.createAssetAndGoToAssetPage(request, this.space);\n }\n}\n","@if (dwellingType) {\n <h1 class=\"ion-padding\">New {{ dwellingType }}</h1>\n} @else {\n <h1 class=\"ion-padding\">New dwelling</h1>\n}\n\n@if (dwellingType) {\n <sneat-edit-dwelling-card\n [space]=\"space\"\n [(dwellingAsset)]=\"dwellingAsset\"\n (dwellingAssetChange)=\"onAssetChanged($event)\"\n />\n} @else {\n <ion-card>\n <sneat-select-from-list\n [(ngModel)]=\"dwellingType\"\n (ngModelChange)=\"onDwellingTypeChanged()\"\n [isFilterable]=\"false\"\n title=\"Type\"\n [items]=\"dwellingTypes\"\n />\n </ion-card>\n}\n\n@if (dwellingAsset?.dbo?.type || dwellingAsset?.dbo?.countryID) {\n <ion-button\n [color]=\"dwellingAsset?.dbo?.type ? 'primary' : 'light'\"\n size=\"large\"\n class=\"ion-margin\"\n expand=\"full\"\n [disabled]=\"!space || isSubmitting\"\n (click)=\"submitDwellingForm()\"\n >\n @if (isSubmitting) {\n Adding dwelling...\n } @else {\n Add dwelling\n }\n </ion-button>\n}\n"]}
@@ -0,0 +1,173 @@
1
+ import { Component, Input } from '@angular/core';
2
+ import { FormsModule } from '@angular/forms';
3
+ import { IonButton, IonCard } from '@ionic/angular/standalone';
4
+ import { SelectFromListComponent } from '@sneat/ui';
5
+ import { SpaceComponentBaseParams } from '@sneat/space-components';
6
+ import { EngineTypes, FuelTypes, } from '@sneat/mod-assetus-core';
7
+ import { format, parseISO } from 'date-fns';
8
+ import { VehicleCardComponent } from '../../vehicle-card/vehicle-card.component';
9
+ import { AddAssetBaseComponent } from '../add-asset-base-component';
10
+ import { ClassName } from '@sneat/ui';
11
+ import * as i0 from "@angular/core";
12
+ import * as i1 from "@angular/forms";
13
+ export class AssetAddVehicleComponent extends AddAssetBaseComponent {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.vehicleTypes = [
17
+ { id: 'car', title: 'Car', iconName: 'car-outline' },
18
+ { id: 'motorbike', title: 'Motorbike', iconName: 'bicycle-outline' },
19
+ // { id: 'bicycle', title: 'Bicycle', iconName: 'bicycle-outline' }, this is a sport asset
20
+ { id: 'boat', title: 'Boat', iconName: 'boat-outline' },
21
+ ];
22
+ this.countryIso2 = 'IE';
23
+ this.regNumber = '';
24
+ this.vin = '';
25
+ this.yearOfBuild = '';
26
+ // protected make = '';
27
+ // protected model = '';
28
+ this.engine = '';
29
+ this.nctExpires = ''; // ISO date string 'YYYY-MM-DD'
30
+ this.taxExpires = ''; // ISO date string 'YYYY-MM-DD'
31
+ this.nextServiceDue = ''; // ISO date string 'YYYY-MM-DD'
32
+ }
33
+ ngOnChanges(changes) {
34
+ if (changes['space'] && this.space) {
35
+ const a = this.vehicleAsset ?? {
36
+ id: '',
37
+ space: this.space ?? { id: '' },
38
+ dbo: {
39
+ status: 'draft',
40
+ category: 'vehicle',
41
+ extraType: 'vehicle',
42
+ extra: {
43
+ make: '',
44
+ model: '',
45
+ engineFuel: FuelTypes.unknown,
46
+ engineType: EngineTypes.unknown,
47
+ },
48
+ spaceID: this.space?.id,
49
+ type: this.vehicleType,
50
+ possession: 'owning',
51
+ createdAt: new Date().toISOString(),
52
+ createdBy: '-',
53
+ updatedAt: new Date().toISOString(),
54
+ updatedBy: '-',
55
+ },
56
+ };
57
+ this.vehicleAsset = { ...a, space: this.space };
58
+ }
59
+ }
60
+ onAssetChanged(asset) {
61
+ this.vehicleAsset = asset;
62
+ }
63
+ onVehicleTypeChanged() {
64
+ if (this.vehicleAsset?.dbo) {
65
+ this.vehicleAsset = {
66
+ ...this.vehicleAsset,
67
+ dbo: {
68
+ ...this.vehicleAsset.dbo,
69
+ type: this.vehicleType,
70
+ extraType: 'vehicle',
71
+ extra: {
72
+ make: '',
73
+ model: '',
74
+ regNumber: '',
75
+ engineType: '',
76
+ engineFuel: '',
77
+ },
78
+ },
79
+ };
80
+ }
81
+ }
82
+ formatDate(value) {
83
+ return value && !Array.isArray(value)
84
+ ? format(parseISO(value), 'dd MMMM yyyy')
85
+ : '';
86
+ }
87
+ submitVehicleForm() {
88
+ if (!this.space) {
89
+ throw 'no team context';
90
+ }
91
+ if (!this.vehicleType) {
92
+ throw 'no vehicleType';
93
+ }
94
+ const assetDto = this.vehicleAsset?.dbo;
95
+ if (!assetDto) {
96
+ throw new Error('no asset');
97
+ }
98
+ this.isSubmitting = true;
99
+ let request = {
100
+ asset: {
101
+ ...assetDto,
102
+ status: 'active',
103
+ category: 'vehicle',
104
+ },
105
+ spaceID: this.space?.id,
106
+ };
107
+ if (this.yearOfBuild) {
108
+ request = {
109
+ ...request,
110
+ asset: { ...request.asset, yearOfBuild: +this.yearOfBuild },
111
+ };
112
+ }
113
+ // if (this.vin) {
114
+ // vehicle.vin = this.vin;
115
+ // }
116
+ // if (this.countryIso2) {
117
+ // request.countryID = this.countryIso2;
118
+ // }
119
+ // if (this.taxExpires) {
120
+ // vehicle.taxExpires = this.taxExpires;
121
+ // }
122
+ // if (this.nctExpires) {
123
+ // vehicle.nctExpires = this.nctExpires;
124
+ // }
125
+ // if (this.nextServiceDue) {
126
+ // vehicle.nextServiceDue = this.nextServiceDue;
127
+ // }
128
+ // const { engine } = this;
129
+ // if (engine) {
130
+ // const engineLower = engine.toLowerCase();
131
+ // request.engine = engine;
132
+ // if (engineLower.includes('petrol')) {
133
+ // request.fuelType = 'petrol';
134
+ // } else if (engineLower.includes('diesel')) {
135
+ // request.fuelType = 'diesel';
136
+ // }
137
+ // const size = engine.match(/(\d+(\.\d)?)+L/);
138
+ // console.log('size:', size);
139
+ // if (size) {
140
+ // // tslint:disable-next-line:no-magic-numbers
141
+ // request.engineCC = +size[1] * 1000;
142
+ // }
143
+ // }
144
+ this.createAssetAndGoToAssetPage(request, this.space);
145
+ }
146
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: AssetAddVehicleComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
147
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.0", type: AssetAddVehicleComponent, isStandalone: true, selector: "sneat-asset-add-vehicle", inputs: { vehicleAsset: "vehicleAsset" }, providers: [
148
+ {
149
+ provide: ClassName,
150
+ useValue: 'AssetAddVehicleComponent',
151
+ },
152
+ SpaceComponentBaseParams,
153
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "@if (vehicleType) {\n <h1 class=\"ion-padding\">New {{ vehicleType }}</h1>\n} @else {\n <h1 class=\"ion-padding\">New vehicle</h1>\n}\n\n@if (vehicleType) {\n <sneat-vehicle-card\n [space]=\"space\"\n [(vehicleAsset)]=\"vehicleAsset\"\n (vehicleAssetChange)=\"onAssetChanged($event)\"\n />\n} @else {\n <ion-card>\n <sneat-select-from-list\n [(ngModel)]=\"vehicleType\"\n (ngModelChange)=\"onVehicleTypeChanged()\"\n [isFilterable]=\"false\"\n title=\"Type\"\n [items]=\"vehicleTypes\"\n />\n </ion-card>\n}\n\n@if (vehicleAsset?.dbo?.extra?.model || vehicleAsset?.dbo?.extra?.regNumber) {\n <ion-button\n [color]=\"vehicleAsset?.dbo?.extra?.model ? 'primary' : 'light'\"\n size=\"large\"\n class=\"ion-margin\"\n expand=\"full\"\n [disabled]=\"!space || isSubmitting\"\n (click)=\"submitVehicleForm()\"\n >\n @if (isSubmitting) {\n Adding vehicle...\n } @else {\n Add vehicle\n }\n </ion-button>\n}\n\n<div style=\"height: 300px\"></div>\n<!--TODO: workaround for calendar overlap -->\n", dependencies: [{ kind: "component", type: SelectFromListComponent, selector: "sneat-select-from-list", inputs: ["value", "filterLabel", "label", "listLabel", "listLabelColor", "isFilterable", "isLoading", "items", "items$", "lastItemLines", "labelPlacement", "justify", "other", "canAdd", "filterItem", "selectMode", "isReadonly", "$isProcessing", "sortBy"], outputs: ["valueChange", "filterChanged"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: IonCard, selector: "ion-card", inputs: ["button", "color", "disabled", "download", "href", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: VehicleCardComponent, selector: "sneat-vehicle-card", inputs: ["space", "vehicleAsset", "make", "model", "yearBuild"], outputs: ["vehicleAssetChange"] }, { kind: "component", type: IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "form", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"] }] }); }
154
+ }
155
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: AssetAddVehicleComponent, decorators: [{
156
+ type: Component,
157
+ args: [{ selector: 'sneat-asset-add-vehicle', providers: [
158
+ {
159
+ provide: ClassName,
160
+ useValue: 'AssetAddVehicleComponent',
161
+ },
162
+ SpaceComponentBaseParams,
163
+ ], imports: [
164
+ SelectFromListComponent,
165
+ FormsModule,
166
+ IonCard,
167
+ VehicleCardComponent,
168
+ IonButton,
169
+ ], template: "@if (vehicleType) {\n <h1 class=\"ion-padding\">New {{ vehicleType }}</h1>\n} @else {\n <h1 class=\"ion-padding\">New vehicle</h1>\n}\n\n@if (vehicleType) {\n <sneat-vehicle-card\n [space]=\"space\"\n [(vehicleAsset)]=\"vehicleAsset\"\n (vehicleAssetChange)=\"onAssetChanged($event)\"\n />\n} @else {\n <ion-card>\n <sneat-select-from-list\n [(ngModel)]=\"vehicleType\"\n (ngModelChange)=\"onVehicleTypeChanged()\"\n [isFilterable]=\"false\"\n title=\"Type\"\n [items]=\"vehicleTypes\"\n />\n </ion-card>\n}\n\n@if (vehicleAsset?.dbo?.extra?.model || vehicleAsset?.dbo?.extra?.regNumber) {\n <ion-button\n [color]=\"vehicleAsset?.dbo?.extra?.model ? 'primary' : 'light'\"\n size=\"large\"\n class=\"ion-margin\"\n expand=\"full\"\n [disabled]=\"!space || isSubmitting\"\n (click)=\"submitVehicleForm()\"\n >\n @if (isSubmitting) {\n Adding vehicle...\n } @else {\n Add vehicle\n }\n </ion-button>\n}\n\n<div style=\"height: 300px\"></div>\n<!--TODO: workaround for calendar overlap -->\n" }]
170
+ }], propDecorators: { vehicleAsset: [{
171
+ type: Input
172
+ }] } });
173
+ //# sourceMappingURL=asset-add-vehicle.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-add-vehicle.component.js","sourceRoot":"","sources":["../../../../../../../../../libs/extensions/assetus/components/src/lib/asset-add/asset-add-vehicle/asset-add-vehicle.component.ts","../../../../../../../../../libs/extensions/assetus/components/src/lib/asset-add/asset-add-vehicle/asset-add-vehicle.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAA4B,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAe,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAEL,WAAW,EACX,SAAS,GAIV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;;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ACrC;YACD,wBAAwB;SACzB,sEC7BH,mjCA2CA,4CDZI,uBAAuB,6WACvB,WAAW,+VACX,OAAO,yLACP,oBAAoB,iKACpB,SAAS;;2FAGA,wBAAwB;kBAlBpC,SAAS;+BACE,yBAAyB,aAExB;wBACT;4BACE,OAAO,EAAE,SAAS;4BAClB,QAAQ,EAAE,0BAA0B;yBACrC;wBACD,wBAAwB;qBACzB,WACQ;wBACP,uBAAuB;wBACvB,WAAW;wBACX,OAAO;wBACP,oBAAoB;wBACpB,SAAS;qBACV;;sBAMA,KAAK","sourcesContent":["import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { IonButton, IonCard } from '@ionic/angular/standalone';\nimport { ISelectItem, SelectFromListComponent } from '@sneat/ui';\nimport { timestamp } from '@sneat/dto';\nimport { SpaceComponentBaseParams } from '@sneat/space-components';\nimport {\n AssetVehicleType,\n EngineTypes,\n FuelTypes,\n IAssetContext,\n IAssetVehicleContext,\n IAssetVehicleExtra,\n} from '@sneat/mod-assetus-core';\nimport { format, parseISO } from 'date-fns';\nimport { ICreateAssetRequest } from '../../services';\nimport { VehicleCardComponent } from '../../vehicle-card/vehicle-card.component';\nimport { AddAssetBaseComponent } from '../add-asset-base-component';\nimport { ClassName } from '@sneat/ui';\n\n@Component({\n selector: 'sneat-asset-add-vehicle',\n templateUrl: './asset-add-vehicle.component.html',\n providers: [\n {\n provide: ClassName,\n useValue: 'AssetAddVehicleComponent',\n },\n SpaceComponentBaseParams,\n ],\n imports: [\n SelectFromListComponent,\n FormsModule,\n IonCard,\n VehicleCardComponent,\n IonButton,\n ],\n})\nexport class AssetAddVehicleComponent\n extends AddAssetBaseComponent\n implements OnChanges\n{\n @Input() public vehicleAsset?: IAssetVehicleContext;\n\n protected vehicleType?: AssetVehicleType;\n protected readonly vehicleTypes: ISelectItem[] = [\n { id: 'car', title: 'Car', iconName: 'car-outline' },\n { id: 'motorbike', title: 'Motorbike', iconName: 'bicycle-outline' },\n // { id: 'bicycle', title: 'Bicycle', iconName: 'bicycle-outline' }, this is a sport asset\n { id: 'boat', title: 'Boat', iconName: 'boat-outline' },\n ];\n\n protected countryIso2 = 'IE';\n protected regNumber = '';\n protected vin = '';\n protected yearOfBuild = '';\n // protected make = '';\n // protected model = '';\n protected engine = '';\n protected engines?: string[];\n\n protected nctExpires = ''; // ISO date string 'YYYY-MM-DD'\n protected taxExpires = ''; // ISO date string 'YYYY-MM-DD'\n protected nextServiceDue = ''; // ISO date string 'YYYY-MM-DD'\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes['space'] && this.space) {\n const a: IAssetVehicleContext = this.vehicleAsset ?? {\n id: '',\n space: this.space ?? { id: '' },\n dbo: {\n status: 'draft',\n category: 'vehicle',\n extraType: 'vehicle',\n extra: {\n make: '',\n model: '',\n engineFuel: FuelTypes.unknown,\n engineType: EngineTypes.unknown,\n },\n spaceID: this.space?.id,\n type: this.vehicleType,\n possession: 'owning',\n createdAt: new Date().toISOString() as unknown as timestamp,\n createdBy: '-',\n updatedAt: new Date().toISOString() as unknown as timestamp,\n updatedBy: '-',\n },\n };\n this.vehicleAsset = { ...a, space: this.space };\n }\n }\n\n protected onAssetChanged(asset: IAssetContext): void {\n this.vehicleAsset = asset as IAssetVehicleContext;\n }\n\n onVehicleTypeChanged(): void {\n if (this.vehicleAsset?.dbo) {\n this.vehicleAsset = {\n ...this.vehicleAsset,\n dbo: {\n ...this.vehicleAsset.dbo,\n type: this.vehicleType,\n extraType: 'vehicle',\n extra: {\n make: '',\n model: '',\n regNumber: '',\n engineType: '',\n engineFuel: '',\n },\n },\n };\n }\n }\n\n formatDate(value?: string | string[] | null): string {\n return value && !Array.isArray(value)\n ? format(parseISO(value), 'dd MMMM yyyy')\n : '';\n }\n\n protected submitVehicleForm(): void {\n if (!this.space) {\n throw 'no team context';\n }\n if (!this.vehicleType) {\n throw 'no vehicleType';\n }\n const assetDto = this.vehicleAsset?.dbo;\n if (!assetDto) {\n throw new Error('no asset');\n }\n this.isSubmitting = true;\n let request: ICreateAssetRequest<'vehicle', IAssetVehicleExtra> = {\n asset: {\n ...assetDto,\n status: 'active',\n category: 'vehicle',\n },\n spaceID: this.space?.id,\n };\n if (this.yearOfBuild) {\n request = {\n ...request,\n asset: { ...request.asset, yearOfBuild: +this.yearOfBuild },\n };\n }\n\n // if (this.vin) {\n // \tvehicle.vin = this.vin;\n // }\n // if (this.countryIso2) {\n // \trequest.countryID = this.countryIso2;\n // }\n // if (this.taxExpires) {\n // \tvehicle.taxExpires = this.taxExpires;\n // }\n // if (this.nctExpires) {\n // \tvehicle.nctExpires = this.nctExpires;\n // }\n // if (this.nextServiceDue) {\n // \tvehicle.nextServiceDue = this.nextServiceDue;\n // }\n\n // const { engine } = this;\n // if (engine) {\n // \tconst engineLower = engine.toLowerCase();\n // \trequest.engine = engine;\n // \tif (engineLower.includes('petrol')) {\n // \t\trequest.fuelType = 'petrol';\n // \t} else if (engineLower.includes('diesel')) {\n // \t\trequest.fuelType = 'diesel';\n // \t}\n // \tconst size = engine.match(/(\\d+(\\.\\d)?)+L/);\n // \tconsole.log('size:', size);\n // \tif (size) {\n // \t\t// tslint:disable-next-line:no-magic-numbers\n // \t\trequest.engineCC = +size[1] * 1000;\n // \t}\n // }\n\n this.createAssetAndGoToAssetPage(request, this.space);\n }\n}\n","@if (vehicleType) {\n <h1 class=\"ion-padding\">New {{ vehicleType }}</h1>\n} @else {\n <h1 class=\"ion-padding\">New vehicle</h1>\n}\n\n@if (vehicleType) {\n <sneat-vehicle-card\n [space]=\"space\"\n [(vehicleAsset)]=\"vehicleAsset\"\n (vehicleAssetChange)=\"onAssetChanged($event)\"\n />\n} @else {\n <ion-card>\n <sneat-select-from-list\n [(ngModel)]=\"vehicleType\"\n (ngModelChange)=\"onVehicleTypeChanged()\"\n [isFilterable]=\"false\"\n title=\"Type\"\n [items]=\"vehicleTypes\"\n />\n </ion-card>\n}\n\n@if (vehicleAsset?.dbo?.extra?.model || vehicleAsset?.dbo?.extra?.regNumber) {\n <ion-button\n [color]=\"vehicleAsset?.dbo?.extra?.model ? 'primary' : 'light'\"\n size=\"large\"\n class=\"ion-margin\"\n expand=\"full\"\n [disabled]=\"!space || isSubmitting\"\n (click)=\"submitVehicleForm()\"\n >\n @if (isSubmitting) {\n Adding vehicle...\n } @else {\n Add vehicle\n }\n </ion-button>\n}\n\n<div style=\"height: 300px\"></div>\n<!--TODO: workaround for calendar overlap -->\n"]}