| @@ -42,21 +42,6 @@ export class ListComponent implements OnInit, AfterViewInit { | |||
| public static COLUMN_TYPE_TEXT_LINKED: string = 'text_linked'; | |||
| public static COLUMN_TYPE_WEBSITE: string = 'website'; | |||
| public static validColumnTypes: string[] = [ | |||
| ListComponent.COLUMN_TYPE_ADDRESS, | |||
| ListComponent.COLUMN_TYPE_BTN_DOWNLOAD, | |||
| ListComponent.COLUMN_TYPE_BTN_EDIT, | |||
| ListComponent.COLUMN_TYPE_BTN_REMOVE, | |||
| ListComponent.COLUMN_TYPE_CURRENCY, | |||
| ListComponent.COLUMN_TYPE_DATE, | |||
| ListComponent.COLUMN_TYPE_DETAIL, | |||
| ListComponent.COLUMN_TYPE_EMAIL, | |||
| ListComponent.COLUMN_TYPE_IMAGE, | |||
| ListComponent.COLUMN_TYPE_POSITION, | |||
| ListComponent.COLUMN_TYPE_TEXT, | |||
| ListComponent.COLUMN_TYPE_TEXT_LINKED, | |||
| ListComponent.COLUMN_TYPE_WEBSITE, | |||
| ]; | |||
| get COLUMN_TYPE_ADDRESS(): string { return ListComponent.COLUMN_TYPE_ADDRESS; } | |||
| get COLUMN_TYPE_BTN_DOWNLOAD(): string { return ListComponent.COLUMN_TYPE_BTN_DOWNLOAD; } | |||
| get COLUMN_TYPE_BTN_EDIT(): string { return ListComponent.COLUMN_TYPE_BTN_EDIT; } | |||
| @@ -115,11 +100,6 @@ export class ListComponent implements OnInit, AfterViewInit { | |||
| ) | |||
| } | |||
| setData(dataSource: any, dataLength: number): void { | |||
| this.pagingComponent.dataSource = dataSource; | |||
| this.pagingComponent.setDataLength(dataLength); | |||
| } | |||
| onSortChange = (sortState: Sort) => { | |||
| this.pagingComponent.resetPageIndex() | |||
| this.onSortFunction(sortState); | |||
| @@ -3,7 +3,6 @@ | |||
| <p #paragraphRef (click)="openSearchBox()" [class.search-empty]="!searchBoxFilled"></p> | |||
| <span class="spt-clear" *ngIf="searchBoxFilled" (click)="clearSearch()"></span> | |||
| </div> | |||
| <!-- <p>NAME {{documentForm.get(formId)}}<span>X</span></p>--> | |||
| <div class="search-toggle" [class.search-box-open]="searchBoxOpen"> | |||
| <app-list #listComponent | |||
| [getDataFunction]="getDataFunction" | |||
| @@ -19,7 +19,6 @@ export class SearchSelectComponent implements OnInit, AfterViewInit { | |||
| @Input() public documentForm!: FormGroup; | |||
| @Input() public documentFormField!: string; | |||
| @Input() public getDataFunction!: (index: number, pageSize: number, term?: string) => Observable<any>; | |||
| @Input() public dataSource: any; | |||
| @Input() public dataSet!: any; | |||
| @Input() public displayedDataField!: string; | |||
| @Input() public displayedDataSubResource!: string; | |||
| @@ -52,10 +51,6 @@ export class SearchSelectComponent implements OnInit, AfterViewInit { | |||
| } | |||
| } | |||
| setData(dataSource: any, data: any[], dataLength: number): void { | |||
| this.listComponent.setData(dataSource, dataLength); | |||
| } | |||
| onSortChange = (sortState: Sort) => { | |||
| let order: OrderFilter; | |||
| if (sortState.direction === "") { | |||
| @@ -118,7 +113,7 @@ export class SearchSelectComponent implements OnInit, AfterViewInit { | |||
| ]; | |||
| } | |||
| public static getDefaultColDefProducts(): ListColDefinition[] { | |||
| public static getDefaultColDefProducts(subResource?: string): ListColDefinition[] { | |||
| return [ | |||
| ListComponent.getDefaultColPosition(), | |||
| { | |||
| @@ -126,12 +121,14 @@ export class SearchSelectComponent implements OnInit, AfterViewInit { | |||
| text: 'overview.image', | |||
| type: ListComponent.COLUMN_TYPE_IMAGE, | |||
| field: 'imageUrl', | |||
| subResource: subResource, | |||
| } as ListColDefinition, | |||
| { | |||
| name: 'name', | |||
| text: 'form.product', | |||
| type: ListComponent.COLUMN_TYPE_TEXT, | |||
| field: 'name', | |||
| subResource: subResource, | |||
| } | |||
| ]; | |||
| } | |||
| @@ -18,8 +18,7 @@ | |||
| </div> | |||
| <div class="col-12 col-lg-6"> | |||
| <ul *ngFor="let contactPartnerProduct of contactPartnerProducts"> | |||
| <!-- TODO: contactPartnerProduct.productName ist falsch, hier muss die ID rein --> | |||
| <li><a href="/products/{{this.appHelperService.extractId(contactPartnerProduct.product?.id)}}">{{contactPartnerProduct.product?.name}}</a></li> | |||
| <li><a href="{{ appHelperService.getResourceLink(contactPartnerProduct.product) }}">{{contactPartnerProduct.product?.name}}</a></li> | |||
| </ul> | |||
| </div> | |||
| </div> | |||
| @@ -107,4 +107,6 @@ export class ContactsDetailComponent implements OnInit, AfterViewInit { | |||
| } | |||
| this.appHelperService.openModal(NewContactComponent, data, this.getContactData); | |||
| } | |||
| protected readonly AppHelperService = AppHelperService; | |||
| } | |||
| @@ -107,20 +107,14 @@ export class PartnerListComponent implements OnInit, AfterViewInit { | |||
| } as ListColDefinition | |||
| ) | |||
| } | |||
| if (this.user !== undefined) { | |||
| this.getDataFunction = this.getPartnerData; | |||
| } else if (this.product !== undefined) { | |||
| this.getDataFunction = this.getUserPartnerData | |||
| } else { | |||
| this.getDataFunction = this.getPartnerData; | |||
| } | |||
| this.getDataFunction = this.getGetDataFunction(); | |||
| } | |||
| ngAfterViewInit() { | |||
| this.listComponent.getData(); | |||
| } | |||
| getData = (): ListGetDataFunctionType => { | |||
| getGetDataFunction = (): ListGetDataFunctionType => { | |||
| if (this.user !== undefined) { | |||
| return this.getUserPartnerData; | |||
| } else if (this.product !== undefined) { | |||
| @@ -207,7 +201,7 @@ export class PartnerListComponent implements OnInit, AfterViewInit { | |||
| openModalNewPartner() { | |||
| let partner: PartnerJsonld = {} as PartnerJsonld; | |||
| partner.partnerType = this.partnerType as TypeEnum; | |||
| this.appHelperService.openModal(NewPartnerComponent, { 'partner': partner }, this.getData); | |||
| this.appHelperService.openModal(NewPartnerComponent, { 'partner': partner }, this.getGetDataFunction); | |||
| } | |||
| unassignPartner = (element: any)=> { | |||
| @@ -14,14 +14,13 @@ | |||
| <label for="product" class="form-label">{{ 'form.product' | translate }}:</label> | |||
| <ng-container *ngIf="posting.saleIri === null || posting.saleIri === undefined"> | |||
| <app-search-select *ngIf="this.posting.id === null || this.posting.id === undefined" | |||
| #productSearchSelect | |||
| [formId]="'productIri'" | |||
| [formLabelLangKey]="'form.product'" | |||
| [documentForm]="postForm" | |||
| [getDataFunction]="getProducts" | |||
| [dataSource]="dataSourceProducts" | |||
| [displayedDataField]="'name'" | |||
| [listColDefinitions]="SearchSelectComponent.getDefaultColDefPartners()" | |||
| #productSearchSelect | |||
| [formId]="'productIri'" | |||
| [formLabelLangKey]="'form.product'" | |||
| [documentForm]="postForm" | |||
| [getDataFunction]="getProducts" | |||
| [displayedDataField]="'name'" | |||
| [listColDefinitions]="SearchSelectComponent.getDefaultColDefProducts()" | |||
| > | |||
| </app-search-select> | |||
| <input id="product" type="hidden" *ngIf="this.posting.id === null || this.posting.id === undefined" | |||
| @@ -10,10 +10,7 @@ import { | |||
| } from "@app/core/api/v1"; | |||
| import {FormGroupInitializer} from "@app/_helpers/formgroup.initializer"; | |||
| import {AppHelperService} from "@app/_helpers/app-helper.service"; | |||
| import {Subscription} from "rxjs"; | |||
| import {SearchSelectComponent} from "@app/_components/search-select/search-select.component"; | |||
| import {MatTableDataSource} from "@angular/material/table"; | |||
| import {SearchInputColDef} from "@app/_components/search-input/search-input-col-def"; | |||
| import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-function-type"; | |||
| @Component({ | |||
| @@ -29,9 +26,6 @@ export class NewPostComponent implements OnInit { | |||
| protected readonly SearchSelectComponent = SearchSelectComponent; | |||
| protected postForm: FormGroup; | |||
| protected postSub: Subscription; | |||
| protected products: Array<ProductJsonld>; | |||
| protected dataSourceProducts; | |||
| constructor( | |||
| private postService: PostService, | |||
| @@ -39,9 +33,6 @@ export class NewPostComponent implements OnInit { | |||
| protected appHelperService: AppHelperService, | |||
| ) { | |||
| this.postForm = postForm; | |||
| this.postSub = new Subscription(); | |||
| this.products = []; | |||
| this.dataSourceProducts = new MatTableDataSource<ProductJsonld>(this.products); | |||
| } | |||
| ngOnInit(): void { | |||
| @@ -60,7 +51,7 @@ export class NewPostComponent implements OnInit { | |||
| if (this.postForm.valid) { | |||
| if (this.posting.id === null || this.posting.id === undefined) { | |||
| // Create new post | |||
| this.postSub = this.postService.postsPost( | |||
| this.postService.postsPost( | |||
| this.postForm.value as PostJsonld | |||
| ).subscribe( | |||
| data => { | |||
| @@ -70,7 +61,7 @@ export class NewPostComponent implements OnInit { | |||
| ); | |||
| } else { | |||
| // Edit post | |||
| this.postSub = this.postService.postsIdPatch( | |||
| this.postService.postsIdPatch( | |||
| this.appHelperService.extractId(this.posting.id), | |||
| this.postForm.value as PostJsonld | |||
| ).subscribe( | |||
| @@ -9,24 +9,22 @@ | |||
| [formLabelLangKey]="'form.product'" | |||
| [documentForm]="form" | |||
| [getDataFunction]="getUnassignedProducts" | |||
| [dataSource]="dataSourceProducts" | |||
| [displayedDataField]="'name'" | |||
| [listColDefinitions]="SearchSelectComponent.getDefaultColDefPartners()" | |||
| [listColDefinitions]="SearchSelectComponent.getDefaultColDefProducts()" | |||
| > | |||
| <input type="hidden" id="product" formControlName="productIri" value="{{partnerProduct.productIri}}"/> | |||
| </app-search-select> | |||
| </div> | |||
| <div class="mb-3" *ngIf="this.contactPartnerProduct"> | |||
| <label for="partnerProduct" class="form-label">{{ 'form.product' | translate }}:</label> | |||
| <app-search-select #partnerSearchSelect | |||
| <app-search-select #productSearchSelect | |||
| [formId]="'partnerProductIri'" | |||
| [formLabelLangKey]="'form.product'" | |||
| [documentForm]="form" | |||
| [getDataFunction]="getUnassignedPartnerProducts" | |||
| [dataSource]="dataSourcePartnerProducts" | |||
| [displayedDataField]="'name'" | |||
| [displayedDataSubResource]="'product'" | |||
| [listColDefinitions]="SearchSelectComponent.getDefaultColDefPartners()" | |||
| [listColDefinitions]="SearchSelectComponent.getDefaultColDefProducts('product')" | |||
| > | |||
| <input type="hidden" id="partnerProduct" formControlName="partnerProductIri" value="{{contactPartnerProduct.partnerProductIri}}"/> | |||
| </app-search-select> | |||
| @@ -27,10 +27,6 @@ export class AssignProductComponent implements OnInit, AfterViewInit { | |||
| @ViewChild('productSearchSelect', { static: false }) productSearchSelect!: SearchSelectComponent | |||
| protected readonly SearchSelectComponent = SearchSelectComponent; | |||
| protected products: Array<ProductJsonld>; | |||
| protected dataSourceProducts; | |||
| protected partnerProducts: Array<PartnerProductJsonld>; | |||
| protected dataSourcePartnerProducts; | |||
| protected form!: FormGroup; | |||
| constructor( | |||
| @@ -39,11 +35,6 @@ export class AssignProductComponent implements OnInit, AfterViewInit { | |||
| protected contactPartnerProductService: ContactPartnerProductService, | |||
| protected appHelperService: AppHelperService, | |||
| ) { | |||
| this.products = []; | |||
| this.dataSourceProducts = new MatTableDataSource<ProductJsonld>(this.products); | |||
| this.partnerProducts = []; | |||
| this.dataSourcePartnerProducts = new MatTableDataSource<PartnerProductJsonld>(this.partnerProducts); | |||
| } | |||
| ngOnInit(): void { | |||
| @@ -87,7 +78,6 @@ export class AssignProductComponent implements OnInit, AfterViewInit { | |||
| onSubmit() { | |||
| if (this.form.valid) { | |||
| if (this.partnerProduct !== undefined) { | |||
| // Partner product | |||
| this.partnerProductService.partnerProductsPost( | |||
| this.form.value as PartnerProductJsonld | |||
| ).subscribe( | |||
| @@ -4,12 +4,12 @@ | |||
| <form [formGroup]="saleForm" (ngSubmit)="onSubmit()"> | |||
| <div class="mb-3"> | |||
| <app-search-select #partnerSearchSelect | |||
| <label for="partnerIri" class="form-label">{{ 'form.partner' | translate }}:</label> | |||
| <app-search-select #partnerSearchSelect id="partnerIri" | |||
| [formId]="'partnerIri'" | |||
| [formLabelLangKey]="'form.partner'" | |||
| [documentForm]="saleForm" | |||
| [getDataFunction]="getPartners" | |||
| [dataSource]="dataSourcePartners" | |||
| [displayedDataField]="'name'" | |||
| [listColDefinitions]="SearchSelectComponent.getDefaultColDefPartners()" | |||
| > | |||
| @@ -18,12 +18,12 @@ | |||
| </div> | |||
| <div class="mb-3"> | |||
| <app-search-select #productSearchSelect | |||
| <label for="productIri" class="form-label">{{ 'form.product' | translate }}:</label> | |||
| <app-search-select #productSearchSelect id="productIri" | |||
| [formId]="'productIri'" | |||
| [formLabelLangKey]="'form.product'" | |||
| [documentForm]="saleForm" | |||
| [getDataFunction]="getProducts" | |||
| [dataSource]="dataSourceProducts" | |||
| [displayedDataField]="'name'" | |||
| [listColDefinitions]="SearchSelectComponent.getDefaultColDefProducts()" | |||
| > | |||
| @@ -26,17 +26,13 @@ import {ListColDefinition} from "@app/_components/list/list-col-definition"; | |||
| }) | |||
| export class NewSaleComponent implements OnInit, AfterViewInit { | |||
| @Input() public sale!: SaleJsonld; | |||
| @Input() public partner!: PartnerJsonld; | |||
| @Output() public submit: EventEmitter<ModalStatus> = new EventEmitter<ModalStatus>(); | |||
| @ViewChild('partnerSearchSelect', { static: false }) partnerSearchSelect!: SearchSelectComponent; | |||
| @ViewChild('productSearchSelect', { static: false }) productSearchSelect!: SearchSelectComponent; | |||
| protected readonly SearchSelectComponent = SearchSelectComponent; | |||
| protected saleForm: FormGroup; | |||
| protected saleSub: Subscription; | |||
| protected partners: Array<PartnerJsonld>; | |||
| protected dataSourcePartners; | |||
| protected products: Array<ProductJsonld>; | |||
| protected dataSourceProducts; | |||
| constructor( | |||
| private saleService: SaleService, | |||
| @@ -46,11 +42,6 @@ export class NewSaleComponent implements OnInit, AfterViewInit { | |||
| protected appHelperService: AppHelperService, | |||
| ) { | |||
| this.saleForm = saleForm; | |||
| this.saleSub = new Subscription(); | |||
| this.partners = []; | |||
| this.dataSourcePartners = new MatTableDataSource<PartnerJsonld>(this.partners); | |||
| this.products = []; | |||
| this.dataSourceProducts = new MatTableDataSource<ProductJsonld>(this.products); | |||
| } | |||
| ngOnInit(): void { | |||
| @@ -90,7 +81,7 @@ export class NewSaleComponent implements OnInit, AfterViewInit { | |||
| } | |||
| if (this.sale.id === null || this.sale.id === undefined) { | |||
| // Create new sale | |||
| this.saleSub = this.saleService.salesPost( | |||
| this.saleService.salesPost( | |||
| this.saleForm.value as SaleJsonld | |||
| ).subscribe( | |||
| data => { | |||
| @@ -100,7 +91,7 @@ export class NewSaleComponent implements OnInit, AfterViewInit { | |||
| ); | |||
| } else { | |||
| // Edit sale | |||
| this.saleSub = this.saleService.salesIdPatch( | |||
| this.saleService.salesIdPatch( | |||
| this.appHelperService.extractId(this.sale.id), | |||
| this.saleForm.value as SaleJsonld | |||
| ).subscribe( | |||
| @@ -120,7 +120,7 @@ export class SaleListComponent implements OnInit, AfterViewInit { | |||
| openModalNewSale() { | |||
| let sale: SaleJsonld = {} as SaleJsonld; | |||
| this.appHelperService.openModal(NewSaleComponent, { 'sale': sale }, this.listComponent.getData); | |||
| this.appHelperService.openModal(NewSaleComponent, { 'sale': sale, 'partner': this.partner }, this.listComponent.getData); | |||
| } | |||
| } | |||
| @@ -17,7 +17,6 @@ | |||
| [formLabelLangKey]="'form.product'" | |||
| [documentForm]="taskNoteForm" | |||
| [getDataFunction]="getContacts" | |||
| [dataSource]="dataSourceContacts" | |||
| [displayedDataField]="'fullName'" | |||
| [dataSet]="taskNote.contact" | |||
| [listColDefinitions]="SearchSelectComponent.getDefaultColDefContacts()" | |||
| @@ -30,10 +30,7 @@ export class NewTaskNoteComponent implements OnInit, AfterViewInit { | |||
| protected readonly SearchSelectComponent = SearchSelectComponent; | |||
| protected taskNoteForm: FormGroup; | |||
| protected taskNoteSub: Subscription; | |||
| protected contactTypes = Object.values(TaskNoteJsonld.ContactTypeEnum); | |||
| protected contacts: Array<ContactJsonld>; | |||
| protected dataSourceContacts; | |||
| constructor( | |||
| protected taskNoteService: TaskNoteService, | |||
| @@ -41,9 +38,6 @@ export class NewTaskNoteComponent implements OnInit, AfterViewInit { | |||
| protected contactService: ContactService | |||
| ) { | |||
| this.taskNoteForm = taskNoteForm; | |||
| this.taskNoteSub = new Subscription(); | |||
| this.contacts = []; | |||
| this.dataSourceContacts = new MatTableDataSource<ContactJsonld>(this.contacts); | |||
| } | |||
| ngOnInit(): void { | |||
| @@ -77,7 +71,7 @@ export class NewTaskNoteComponent implements OnInit, AfterViewInit { | |||
| if (this.taskNoteForm.valid) { | |||
| if (this.taskNote.id === null || this.taskNote.id === undefined) { | |||
| // Create new taskNote | |||
| this.taskNoteSub = this.taskNoteService.taskNotesPost( | |||
| this.taskNoteService.taskNotesPost( | |||
| this.taskNoteForm.value as TaskNoteJsonld | |||
| ).subscribe( | |||
| data => { | |||
| @@ -87,7 +81,7 @@ export class NewTaskNoteComponent implements OnInit, AfterViewInit { | |||
| ); | |||
| } else { | |||
| // Edit taskNote | |||
| this.taskNoteSub = this.taskNoteService.taskNotesIdPatch( | |||
| this.taskNoteService.taskNotesIdPatch( | |||
| this.appHelperService.extractId(this.taskNote.id), | |||
| this.taskNoteForm.value as TaskNoteJsonld | |||
| ).subscribe( | |||
| @@ -25,7 +25,6 @@ | |||
| [formLabelLangKey]="'form.product'" | |||
| [documentForm]="taskForm" | |||
| [getDataFunction]="getProducts" | |||
| [dataSource]="dataSourceProducts" | |||
| [displayedDataField]="'name'" | |||
| [dataSet]="task.product" | |||
| [listColDefinitions]="SearchSelectComponent.getDefaultColDefProducts()" | |||
| @@ -42,7 +41,6 @@ | |||
| [formLabelLangKey]="'form.user'" | |||
| [documentForm]="taskForm" | |||
| [getDataFunction]="getUsers" | |||
| [dataSource]="dataSourceUsers" | |||
| [displayedDataField]="'fullName'" | |||
| [dataSet]="task.assignedTo" | |||
| [listColDefinitions]="SearchSelectComponent.getDefaultColDefUsers()" | |||
| @@ -33,27 +33,15 @@ export class NewTaskComponent implements OnInit, AfterViewInit { | |||
| protected readonly SearchSelectComponent = SearchSelectComponent; | |||
| protected taskForm: FormGroup; | |||
| protected taskSub: Subscription; | |||
| protected dueAtValue: string; | |||
| protected users: Array<UserJsonld>; | |||
| protected dataSourceUsers; | |||
| protected products: Array<ProductJsonld>; | |||
| protected dataSourceProducts; | |||
| constructor( | |||
| protected taskService: TaskService, | |||
| protected userService: UserService, | |||
| protected productService: ProductService, | |||
| protected appHelperService: AppHelperService | |||
| ) { | |||
| this.users = []; | |||
| this.dataSourceUsers = new MatTableDataSource<UserJsonld>(this.users); | |||
| this.products = []; | |||
| this.dataSourceProducts = new MatTableDataSource<ProductJsonld>(this.products); | |||
| this.taskForm = taskForm; | |||
| this.taskSub = new Subscription(); | |||
| this.dueAtValue = ""; | |||
| } | |||
| @@ -101,7 +89,7 @@ export class NewTaskComponent implements OnInit, AfterViewInit { | |||
| if (this.taskForm.valid) { | |||
| if (this.task.id === null || this.task.id === undefined) { | |||
| // Create new task | |||
| this.taskSub = this.taskService.tasksPost( | |||
| this.taskService.tasksPost( | |||
| this.taskForm.value as TaskJsonld | |||
| ).subscribe( | |||
| data => { | |||
| @@ -111,7 +99,7 @@ export class NewTaskComponent implements OnInit, AfterViewInit { | |||
| ); | |||
| } else { | |||
| // Edit task | |||
| this.taskSub = this.taskService.tasksIdPatch( | |||
| this.taskService.tasksIdPatch( | |||
| this.appHelperService.extractId(this.task.id), | |||
| this.taskForm.value as TaskJsonld | |||
| ).subscribe( | |||