diff --git a/dmp-frontend/src/app/ui/dmp/editor/cost-editor/cost-listing/cost-listing.component.html b/dmp-frontend/src/app/ui/dmp/editor/cost-editor/cost-listing/cost-listing.component.html new file mode 100644 index 000000000..1fb26780b --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/editor/cost-editor/cost-listing/cost-listing.component.html @@ -0,0 +1,32 @@ + + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+ + + + + +
diff --git a/dmp-frontend/src/app/ui/dmp/editor/cost-editor/cost-listing/cost-listing.component.scss b/dmp-frontend/src/app/ui/dmp/editor/cost-editor/cost-listing/cost-listing.component.scss new file mode 100644 index 000000000..52f45cc20 --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/editor/cost-editor/cost-listing/cost-listing.component.scss @@ -0,0 +1,10 @@ +.listing-container { + height: fit-content; + width: fit-content; + background-color: whitesmoke; +} + + +.cost-element { + margin-bottom: 1em; +} diff --git a/dmp-frontend/src/app/ui/dmp/editor/cost-editor/cost-listing/cost-listing.component.ts b/dmp-frontend/src/app/ui/dmp/editor/cost-editor/cost-listing/cost-listing.component.ts new file mode 100644 index 000000000..1272e51c6 --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/editor/cost-editor/cost-listing/cost-listing.component.ts @@ -0,0 +1,51 @@ +import { Component, OnInit, Input } from '@angular/core'; +import { BaseComponent } from '@common/base/base.component'; +import { FormArray } from '@angular/forms'; +import { takeUntil } from 'rxjs/operators'; +import { CostModel } from '@app/core/model/dmp/cost'; +import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; +import { CurrencyService } from '@app/core/services/currency/currency.service'; +import { Observable } from 'rxjs'; +import { LocalFetchModel } from '@app/core/model/local-fetch/local-fetch.model'; + +@Component({ + selector: 'app-cost-listing', + templateUrl: './cost-listing.component.html', + styleUrls: ['./cost-listing.component.scss'] +}) +export class CostListingComponent extends BaseComponent implements OnInit { + + @Input() form: FormArray; + + costs: CostModel[] = []; + + currencyAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { + filterFn: this.searchCurrency.bind(this), + initialItems: () => this.searchCurrency(''), + displayFn: (item) => typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name, + titleFn: (item) => typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name, + valueAssign: (item) => this.getValue(item) + }; + + constructor( + private currencyService: CurrencyService, + ) { + super(); + } + + ngOnInit() { + this.form.valueChanges.pipe(takeUntil(this._destroyed)).subscribe(value => { + this.costs = value; + }); + } + + searchCurrency(like: string): Observable { + return this.currencyService.get(like); +} + + getValue(item: any): any { + console.log(item); + return item; + } + +} diff --git a/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.html b/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.html index 5e18a75dd..2d85e7ccc 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.html @@ -140,10 +140,12 @@ -
- +
+ Costs + +
diff --git a/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.scss b/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.scss index 05d8ae793..595aabb5c 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.scss +++ b/dmp-frontend/src/app/ui/dmp/editor/general-tab/general-tab.component.scss @@ -37,3 +37,7 @@ ::ng-deep .mat-form-field-appearance-legacy .mat-form-field-wrapper { padding-bottom: 1.25em; } + +.cost-placeholder { + text-decoration: underline; +}