Commit 3f0262e6 authored by Michail Tzanatos's avatar Michail Tzanatos
Browse files

added delete-product-spec-characteristic logic

parent b648407f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ import { EditProductCatalogsComponent } from './p_product/admin/productCatalogMa
import { EditProductCategoriesComponent } from './p_product/admin/productCatalogManagement/edit-product-categories/edit-product-categories.component';
import { EditProductSpecsComponent } from './p_product/admin/productCatalogManagement/edit-product-specs/edit-product-specs.component';
import { EditProductSpecCharacteristicsComponent } from './p_product/admin/productCatalogManagement/edit-product-specs/edit-product-spec-characteristics/edit-product-spec-characteristics.component';
import { DeleteProductSpecCharacteristicsComponent } from './p_product/admin/productCatalogManagement/edit-product-specs/delete-product-spec-characteristics/delete-product-spec-characteristics.component';
import { DeleteProductCatalogsComponent } from './p_product/admin/productCatalogManagement/delete-product-catalogs/delete-product-catalogs.component';
import { DeleteProductCategoriesComponent } from './p_product/admin/productCatalogManagement/delete-product-categories/delete-product-categories.component';
import { DeleteProductSpecsComponent } from './p_product/admin/productCatalogManagement/delete-product-specs/delete-product-specs.component';
@@ -36,6 +37,7 @@ import { AssignSubcategoriesComponent } from './p_product/admin/productCatalogMa
        EditProductCategoriesComponent,
        EditProductSpecsComponent,
        EditProductSpecCharacteristicsComponent,
        DeleteProductSpecCharacteristicsComponent,
        DeleteProductCatalogsComponent,
        DeleteProductCategoriesComponent,
        DeleteProductSpecsComponent,
+12 −0
Original line number Diff line number Diff line
<h4 mat-dialog-title class="shadowed mb-3">
    <i class="far fa-trash-alt mr-2"></i>
    <span>Confirm deletion</span>
</h4>
<div mat-dialog-content>
    Are you sure you want to permanently delete characteristic <b><dfn>{{data.specToBeDeleted.name}}</dfn></b> ?
</div>

<div mat-dialog-actions class="d-flex justify-content-end">
    <button type="button" class="btn btn-outline-danger m-2" (click)="closeDialog()">Cancel</button>
    <button type="button" class="btn btn-danger m-2" (click)="confirmDelete()">Delete</button>
</div>
 No newline at end of file
+0 −0

Empty file added.

+45 −0
Original line number Diff line number Diff line
import { trigger } from "@angular/animations";
import { Component, Inject, OnInit } from "@angular/core";
import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog";
import { ProductSpecification, ProductSpecificationCharacteristicRes, ProductSpecificationUpdate } from "src/app/openApis/productCatalogManagement/models";
import { ProductSpecificationService } from "src/app/openApis/productCatalogManagement/services";
import { fadeIn, simpleFade } from "src/app/shared/animations/animations";


@Component({
    selector: 'app-delete-product-spec-characteristics',
    templateUrl: './delete-product-spec-characteristics.component.html',
    styleUrls: ['./delete-product-spec-characteristics.component.scss'],
    animations: [trigger('fadeIn', fadeIn()), trigger('simpleFade', simpleFade())]
})
export class DeleteProductSpecCharacteristicsComponent implements OnInit {
    constructor(
        @Inject(MAT_DIALOG_DATA) public data: {
        productSpec: ProductSpecification
        productSpecCharacteristicArray:ProductSpecificationCharacteristicRes[], 
        specToBeDeleted: ProductSpecificationCharacteristicRes
        },
        private dialogRef: MatDialogRef<DeleteProductSpecCharacteristicsComponent>,
        private specService: ProductSpecificationService
    ) { }

    ngOnInit() {
    }

    confirmDelete() { 
        // this.dialogRef.close('deleted')
        const updateSpecObj: ProductSpecificationUpdate = {
        productSpecCharacteristic: this.data.productSpecCharacteristicArray
        }

        this.specService.patchProductSpecification({ id: this.data.productSpec.id, productSpecification: updateSpecObj }).subscribe(
        data => {},
        error => console.error(error),
        () => this.dialogRef.close('deleted')
        )
    }

    closeDialog() {
        this.dialogRef.close()
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -257,7 +257,7 @@
                                                            Default Values </th>
                                                        <td mat-cell *matCellDef="let element">
                                                            <span
                                                                *ngFor="let val of element.serviceSpecCharacteristicValue; let last = last"
                                                                *ngFor="let val of element.productSpecCharacteristicValue; let last = last"
                                                                [class.hidden]="!val || !val.isDefault">
                                                                <span
                                                                    *ngIf="val && val.isDefault">{{val.value.value}}
@@ -291,7 +291,7 @@
                                                                    (click)="cloneProductSpecCharacteristic(element)"><i
                                                                        class="far fa-copy"></i></button>
                                                                <button class="btn btn-danger btn-sm"
                                                                    (click)="openCharacteristicDesignDialog(element)"><i
                                                                    (click)="openCharacteristicDeleteDialog(element)"><i
                                                                        class="far fa-trash-alt"></i></button>
                                                            </div>
                                                        </td>
Loading