Florian Eisenmenger 1 год назад
Родитель
Сommit
715338fee7
4 измененных файлов: 38 добавлений и 20 удалений
  1. +2
    -0
      matsen-tool/src/app/_components/search-select/search-select.component.ts
  2. +29
    -19
      matsen-tool/src/app/_views/posts/new-post/new-post.component.html
  3. +2
    -0
      matsen-tool/src/app/_views/posts/new-post/new-post.component.ts
  4. +5
    -1
      matsen-tool/src/app/_views/posts/post-list/post-list.component.ts

+ 2
- 0
matsen-tool/src/app/_components/search-select/search-select.component.ts Просмотреть файл

@@ -98,8 +98,10 @@ export class SearchSelectComponent implements OnInit, AfterViewInit {
this.documentForm.get(this.formId)?.setValue(row.id);
if (this.displayedDataSubResource !== undefined) {
this.paragraphRef.nativeElement.textContent = row[this.displayedDataSubResource][this.displayedDataField];
console.log(row[this.displayedDataSubResource][this.displayedDataField]);
} else {
this.paragraphRef.nativeElement.textContent = row[this.displayedDataField];
console.log(row[this.displayedDataField]);
}
this.searchBoxFilled = true;
this.searchBoxOpen = false;


+ 29
- 19
matsen-tool/src/app/_views/posts/new-post/new-post.component.html Просмотреть файл

@@ -1,38 +1,48 @@
<h2 *ngIf="!posting.id">{{'basic.new-post' | translate}}</h2>
<h2 *ngIf="posting.id">{{'basic.edit-post' | translate}}</h2>
<h2 *ngIf="!posting.id">{{ 'basic.new-post' | translate }}</h2>
<h2 *ngIf="posting.id">{{ 'basic.edit-post' | translate }}</h2>
<div class="spt-form">
<form [formGroup]="postForm" (ngSubmit)="onSubmit()">
<div class="mb-3">
<label for="headline" class="form-label">{{'form.headline' | translate}}:</label>
<input type="text" class="form-control" id="headline" formControlName="headline" />
<label for="headline" class="form-label">{{ 'form.headline' | translate }}:</label>
<input type="text" class="form-control" id="headline" formControlName="headline"/>
<div class="form-text" *ngIf="postForm.get('headline')?.invalid && postForm.get('headline')?.touched">
{{'form.headline' | translate}} {{'form.mandatory' | translate}}.
{{ 'form.headline' | translate }} {{ 'form.mandatory' | translate }}.
</div>
</div>

<div class="mb-3">
<app-search-select *ngIf="this.posting.id === null || this.posting.id === undefined" #productSearchSelect
[formId]="'productIri'"
[formLabelLangKey]="'form.product'"
[documentForm]="postForm"
[getDataFunction]="getProducts"
[dataSource]="dataSourceProducts"
[searchSelectColDefs]="colDefProducts"
>
</app-search-select>
<input type="hidden" *ngIf="this.posting.id === null || this.posting.id === undefined" formControlName="product"/>
<input type="text" *ngIf="this.posting.id !== null && this.posting.id !== undefined" class="form-control" disabled value="{{posting.product?.name}}" />
<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"
[searchSelectColDefs]="colDefProducts"
[displayedDataField]="'name'"
>
</app-search-select>
<input type="hidden" *ngIf="this.posting.id === null || this.posting.id === undefined"
formControlName="product"/>
</ng-container>
<input type="text"
*ngIf="posting.saleIri !== null && posting.saleIri !== undefined && (this.posting.id === null || this.posting.id === undefined)"
class="form-control" disabled value="{{product?.name}}"/>
<input type="text" *ngIf="this.posting.id !== null && this.posting.id !== undefined" class="form-control"
disabled value="{{posting.product?.name}}"/>
</div>

<div class="mb-3">
<label for="message" class="form-label">{{'form.message' | translate}}:</label>
<label for="message" class="form-label">{{ 'form.message' | translate }}:</label>
<textarea class="form-control" id="message" formControlName="message" cols="50" rows="5"></textarea>
<div class="form-text" *ngIf="postForm.get('message')?.invalid && postForm.get('message')?.touched">
{{'form.message' | translate}} {{'form.mandatory' | translate}}.
{{ 'form.message' | translate }} {{ 'form.mandatory' | translate }}.
</div>
</div>

<button type="submit" class="btn btn-primary" [disabled]="postForm.invalid">{{'form.send' | translate}}</button>
<button type="submit" class="btn btn-primary" [disabled]="postForm.invalid">{{ 'form.send' | translate }}
</button>
</form>
</div>


+ 2
- 0
matsen-tool/src/app/_views/posts/new-post/new-post.component.ts Просмотреть файл

@@ -22,6 +22,7 @@ import {SearchInputColDef} from "@app/_components/search-input/search-input-col-
})
export class NewPostComponent implements OnInit {
@Input() public posting!: PostJsonld;
@Input() public product!: ProductJsonld;
@Output() public submit: EventEmitter<ModalStatus> = new EventEmitter<ModalStatus>();
@ViewChild('productSearchSelect', { static: false }) productSearchSelect!: SearchSelectComponent;

@@ -48,6 +49,7 @@ export class NewPostComponent implements OnInit {
}

ngOnInit(): void {
console.log(this.posting);
this.postForm = FormGroupInitializer.initFormGroup(this.postForm, this.posting);
}



+ 5
- 1
matsen-tool/src/app/_views/posts/post-list/post-list.component.ts Просмотреть файл

@@ -135,6 +135,7 @@ export class PostListComponent implements OnInit, AfterViewInit {
}

openModalNewPost() {
let postInputs: any = {};
let post: PostJsonld = {} as PostJsonld;

if (this.partner !== undefined) {
@@ -142,9 +143,12 @@ export class PostListComponent implements OnInit, AfterViewInit {
}
if (this.sale !== undefined) {
post.partnerIri = this.sale?.partnerIri;
post.productIri = this.sale?.productIri;
post.saleIri = this.sale?.id;
postInputs['product'] = this.sale.product;
}
this.appHelperService.openModal(NewPostComponent, { 'posting': post }, this.getPostsData);
postInputs['posting'] = post;
this.appHelperService.openModal(NewPostComponent, postInputs, this.getPostsData);
}

openModalEditPost(post: PostJsonld) {


Загрузка…
Отмена
Сохранить