Florian Eisenmenger 2 лет назад
Родитель
Сommit
266b581fab
2 измененных файлов: 22 добавлений и 0 удалений
  1. +2
    -0
      matsen-tool/src/app/products/products-detail/products-detail.component.html
  2. +20
    -0
      matsen-tool/src/app/products/products-detail/products-detail.component.ts

+ 2
- 0
matsen-tool/src/app/products/products-detail/products-detail.component.html Просмотреть файл

@@ -22,6 +22,8 @@
ngSrc="{{product.imageUrl}}" width="247" height="94" ngSrc="{{product.imageUrl}}" width="247" height="94"
alt="{{product.name}}" title="{{product.name}}"/> alt="{{product.name}}" title="{{product.name}}"/>
</div> </div>
<span class="position-absolute bi bi-pencil p-2" data-type="user-tool" data-action="edit"
(click)="openModalEditProduct()"></span>
</div> </div>
</div> </div>
</div> </div>

+ 20
- 0
matsen-tool/src/app/products/products-detail/products-detail.component.ts Просмотреть файл

@@ -3,6 +3,10 @@ import {environment} from "@environments/environment";
import {ActivatedRoute} from "@angular/router"; import {ActivatedRoute} from "@angular/router";
import {Subscription} from "rxjs"; import {Subscription} from "rxjs";
import {ProductJsonld, ProductService} from "@app/core/api/v1"; import {ProductJsonld, ProductService} from "@app/core/api/v1";
import {NewContactComponent} from "@app/contacts/new-contact/new-contact.component";
import {ModalStatus} from "@app/_helpers/modal.states";
import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap";
import {NewProductComponent} from "@app/products/new-product/new-product.component";


@Component({ @Component({
selector: 'app-products-detail', selector: 'app-products-detail',
@@ -16,9 +20,14 @@ export class ProductsDetailComponent implements OnInit, AfterViewInit {
protected productDetailSub: Subscription; protected productDetailSub: Subscription;
protected product: ProductJsonld; protected product: ProductJsonld;


protected modalOptions: NgbModalOptions = {
centered: true
};

constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
private productService: ProductService, private productService: ProductService,
private modalService: NgbModal
) { ) {
this.id = ""; this.id = "";
this.productDetailSub = new Subscription(); this.productDetailSub = new Subscription();
@@ -46,4 +55,15 @@ export class ProductsDetailComponent implements OnInit, AfterViewInit {
} }
); );
} }

openModalEditProduct() {
const modalRefProduct = this.modalService.open(NewProductComponent, this.modalOptions);
modalRefProduct.componentInstance.product = this.product;
modalRefProduct.componentInstance.submit.subscribe((modalStatus: ModalStatus) => {
if (modalStatus === ModalStatus.Submitted) {
modalRefProduct.dismiss();
this.getProductData();
}
});
}
} }

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