@@ -51,8 +31,7 @@
[units$]="units$"
(quantityChange)="changeQuantity($event)"
(locationChange)="changeMixLocation($event)"
- (deduct)="deductMixQuantities($event)"
- [(printingError)]="printingError">
+ (deduct)="deductMixQuantities($event)">
diff --git a/src/app/modules/colors/pages/explore/explore.component.ts b/src/app/modules/colors/pages/explore/explore.component.ts
index 34348ba..610f44c 100644
--- a/src/app/modules/colors/pages/explore/explore.component.ts
+++ b/src/app/modules/colors/pages/explore/explore.component.ts
@@ -1,63 +1,65 @@
-import {Component} from '@angular/core';
-import {RecipeService} from "../../services/recipe.service";
-import {ActivatedRoute, Router} from "@angular/router";
-import {SubscribingComponent} from "../../../shared/components/subscribing.component";
-import {Recipe} from "../../../shared/model/recipe.model";
-import {Observable, Subject} from "rxjs";
-import {UNIT_GALLON, UNIT_LITER, UNIT_MILLILITER} from "../../../shared/units";
+import {Component} from '@angular/core'
+import {RecipeService} from '../../services/recipe.service'
+import {ActivatedRoute, Router} from '@angular/router'
+import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
+import {Recipe} from '../../../shared/model/recipe.model'
+import {Observable, Subject} from 'rxjs'
+import {ErrorModel, ErrorService} from '../../../shared/service/error.service'
+import {AlertService} from '../../../shared/service/alert.service'
+import {GlobalAlertHandlerComponent} from '../../../shared/components/global-alert-handler/global-alert-handler.component'
@Component({
selector: 'cre-explore',
templateUrl: './explore.component.html',
styleUrls: ['./explore.component.sass']
})
-export class ExploreComponent extends SubscribingComponent {
- readonly unitConstants = {UNIT_MILLILITER, UNIT_LITER, UNIT_GALLON}
-
+export class ExploreComponent extends ErrorHandlingComponent {
recipe: Recipe | null
- error: string
deductErrorBody = {}
- success: string
units$ = new Subject
()
hasModifications = false
note: string | null
quantitiesChanges = new Map>()
mixesLocationChanges = new Map()
- printingError = 2
- // Errors
- readonly ERROR_UNKNOWN = 'unknown'
- readonly ERROR_DEDUCT = 'deduct'
- // Success
- readonly SUCCESS_SAVE = 'save'
- readonly SUCCESS_DEDUCT = 'deduct'
+ handledErrorModels: ErrorModel[] = [{
+ filter: error => error.status === 409,
+ consumer: error => this.deductErrorBody = error.error,
+ messageProducer: () => 'Certains produit ne sont pas en quantité suffisante dans l\'inventaire'
+ }]
constructor(
private recipeService: RecipeService,
+ private alertService: AlertService,
+ errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
- super(activatedRoute, router)
+ super(errorService, activatedRoute, router)
}
ngOnInit(): void {
super.ngOnInit()
+ GlobalAlertHandlerComponent.extraTopMarginMultiplier = 2.5
const id = parseInt(this.activatedRoute.snapshot.paramMap.get('id'))
- this.subscribe(
- this.recipeService.getById(id),
- {
- next: r => {
- this.recipe = r
- this.note = r.note
- },
- error: err => this.handleNotFoundError(err, '/colors/list')
+ this.subscribeEntityById(
+ this.recipeService,
+ id,
+ r => {
+ this.recipe = r
+ this.note = r.note
},
- 1
+ '/colors/list'
)
}
+ ngOnDestroy() {
+ super.ngOnDestroy();
+ GlobalAlertHandlerComponent.extraTopMarginMultiplier = 0
+ }
+
changeUnits(unit: string) {
this.units$.next(unit)
}
@@ -68,7 +70,9 @@ export class ExploreComponent extends SubscribingComponent {
}
changeQuantity(event: { id: number, materialId: number, quantity: number }) {
- if (!this.quantitiesChanges.has(event.id)) this.quantitiesChanges.set(event.id, new Map())
+ if (!this.quantitiesChanges.has(event.id)) {
+ this.quantitiesChanges.set(event.id, new Map())
+ }
this.quantitiesChanges.get(event.id).set(event.materialId, event.quantity)
}
@@ -80,19 +84,7 @@ export class ExploreComponent extends SubscribingComponent {
saveModifications() {
this.subscribe(
this.recipeService.saveExplorerModifications(this.recipe.id, this.note, this.mixesLocationChanges),
- {
- next: () => {
- this.hasModifications = false
- this.error = null
- this.success = this.SUCCESS_SAVE
- },
- error: err => {
- this.success = null
- this.error = this.ERROR_UNKNOWN
- console.error(err)
- }
- },
- 1
+ () => this.alertService.pushSuccess('Les modifications ont été enregistrées')
)
}
@@ -107,23 +99,7 @@ export class ExploreComponent extends SubscribingComponent {
performDeductQuantities(observable: Observable) {
this.subscribe(
observable,
- {
- next: () => {
- this.error = null
- this.success = this.SUCCESS_DEDUCT
- },
- error: err => {
- this.success = null
- if (err.status === 409) { // There is not enough of one or more materials in the inventory
- this.error = this.ERROR_DEDUCT
- this.deductErrorBody = err.error
- } else {
- this.error = this.ERROR_UNKNOWN
- console.error(err)
- }
- }
- },
- 1
+ () => this.alertService.pushSuccess('Les quantités des produits utilisés ont été déduites de l\'inventaire')
)
}
}
diff --git a/src/app/modules/colors/pages/list/list.component.ts b/src/app/modules/colors/pages/list/list.component.ts
index 1107b7e..ca2c87d 100644
--- a/src/app/modules/colors/pages/list/list.component.ts
+++ b/src/app/modules/colors/pages/list/list.component.ts
@@ -1,30 +1,34 @@
-import {Component} from '@angular/core';
-import {SubscribingComponent} from "../../../shared/components/subscribing.component";
-import {RecipeService} from "../../services/recipe.service";
-import {EmployeePermission} from "../../../shared/model/employee";
-import {AccountService} from "../../../accounts/services/account.service";
-import {Recipe} from "../../../shared/model/recipe.model";
-import {ActivatedRoute, Router} from "@angular/router";
+import {Component} from '@angular/core'
+import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
+import {RecipeService} from '../../services/recipe.service'
+import {EmployeePermission} from '../../../shared/model/employee'
+import {AccountService} from '../../../accounts/services/account.service'
+import {Recipe} from '../../../shared/model/recipe.model'
+import {ActivatedRoute, Router} from '@angular/router'
+import {ErrorModel, ErrorService} from '../../../shared/service/error.service'
@Component({
selector: 'cre-list',
templateUrl: './list.component.html',
styleUrls: ['./list.component.sass']
})
-export class ListComponent extends SubscribingComponent {
+export class ListComponent extends ErrorHandlingComponent {
recipes$ = this.recipeService.allSortedByCompany
tableCols = ['name', 'description', 'sample', 'iconNotApproved', 'buttonView', 'buttonEdit']
searchQuery = ""
panelForcedExpanded = false
recipesHidden = []
+ handledErrorModels: ErrorModel[]
+
constructor(
private recipeService: RecipeService,
private accountService: AccountService,
+ errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
- super(activatedRoute, router)
+ super(errorService, activatedRoute, router)
}
ngOnInit() {
diff --git a/src/app/modules/colors/pages/mix/mix-add/mix-add.component.ts b/src/app/modules/colors/pages/mix/mix-add/mix-add.component.ts
index ca267d1..3916658 100644
--- a/src/app/modules/colors/pages/mix/mix-add/mix-add.component.ts
+++ b/src/app/modules/colors/pages/mix/mix-add/mix-add.component.ts
@@ -1,26 +1,30 @@
-import {Component} from '@angular/core';
-import {Material} from "../../../../shared/model/material.model";
-import {MaterialService} from "../../../../material/service/material.service";
-import {ActivatedRoute, Router} from "@angular/router";
-import {SubscribingComponent} from "../../../../shared/components/subscribing.component";
-import {MixService} from "../../../services/mix.service";
+import {Component} from '@angular/core'
+import {Material} from '../../../../shared/model/material.model'
+import {MaterialService} from '../../../../material/service/material.service'
+import {ActivatedRoute, Router} from '@angular/router'
+import {ErrorHandlingComponent, SubscribingComponent} from '../../../../shared/components/subscribing.component'
+import {MixService} from '../../../services/mix.service'
+import {ErrorHandler, ErrorModel, ErrorService} from '../../../../shared/service/error.service'
@Component({
selector: 'cre-mix-add',
templateUrl: './mix-add.component.html',
styleUrls: ['./mix-add.component.sass']
})
-export class MixAddComponent extends SubscribingComponent {
+export class MixAddComponent extends ErrorHandlingComponent {
recipeId: number | null
materials: Material[] | null
+ handledErrorModels: ErrorModel[]
+
constructor(
private materialService: MaterialService,
private mixService: MixService,
+ errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
- super(activatedRoute, router)
+ super(errorService, activatedRoute, router)
}
ngOnInit(): void {
@@ -30,14 +34,14 @@ export class MixAddComponent extends SubscribingComponent {
this.subscribe(
this.materialService.getAllForMixCreation(this.recipeId),
- {next: m => this.materials = m}
+ m => this.materials = m
)
}
submit(values) {
- this.subscribe(
+ this.subscribeAndNavigate(
this.mixService.saveWithUnits(values.name, values.recipeId, values.materialTypeId, values.mixMaterials, values.units),
- {next: () => this.urlUtils.navigateTo(`/color/edit/${this.recipeId}`)}
+ `/color/edit/${this.recipeId}`
)
}
}
diff --git a/src/app/modules/colors/pages/mix/mix-edit/mix-edit.component.ts b/src/app/modules/colors/pages/mix/mix-edit/mix-edit.component.ts
index 981998d..f463f5f 100644
--- a/src/app/modules/colors/pages/mix/mix-edit/mix-edit.component.ts
+++ b/src/app/modules/colors/pages/mix/mix-edit/mix-edit.component.ts
@@ -1,27 +1,31 @@
-import {Component} from '@angular/core';
-import {ActivatedRoute, Router} from "@angular/router";
-import {SubscribingComponent} from "../../../../shared/components/subscribing.component";
-import {Material} from "../../../../shared/model/material.model";
-import {MaterialService} from "../../../../material/service/material.service";
-import {MixService} from "../../../services/mix.service";
+import {Component} from '@angular/core'
+import {ActivatedRoute, Router} from '@angular/router'
+import {ErrorHandlingComponent} from '../../../../shared/components/subscribing.component'
+import {Material} from '../../../../shared/model/material.model'
+import {MaterialService} from '../../../../material/service/material.service'
+import {MixService} from '../../../services/mix.service'
+import {ErrorModel, ErrorService} from '../../../../shared/service/error.service'
@Component({
selector: 'cre-mix-edit',
templateUrl: './mix-edit.component.html',
styleUrls: ['./mix-edit.component.sass']
})
-export class MixEditComponent extends SubscribingComponent {
+export class MixEditComponent extends ErrorHandlingComponent {
mixId: number | null
recipeId: number | null
materials: Material[] | null
+ handledErrorModels: ErrorModel[]
+
constructor(
private materialService: MaterialService,
private mixService: MixService,
+ errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
- super(activatedRoute, router)
+ super(errorService, activatedRoute, router)
}
ngOnInit(): void {
@@ -32,14 +36,14 @@ export class MixEditComponent extends SubscribingComponent {
this.subscribe(
this.materialService.getAllForMixUpdate(this.mixId),
- {next: m => this.materials = m}
+ m => this.materials = m
)
}
submit(values) {
- this.subscribe(
+ this.subscribeAndNavigate(
this.mixService.updateWithUnits(this.mixId, values.name, values.materialTypeId, values.mixMaterials, values.units),
- {next: () => this.urlUtils.navigateTo(`/color/edit/${this.recipeId}`)}
+ `/color/edit/${this.recipeId}`
)
}
}
diff --git a/src/app/modules/company/pages/add/add.component.html b/src/app/modules/company/pages/add/add.component.html
index 75daec8..a63280a 100644
--- a/src/app/modules/company/pages/add/add.component.html
+++ b/src/app/modules/company/pages/add/add.component.html
@@ -1,8 +1,6 @@
diff --git a/src/app/modules/company/pages/add/add.component.ts b/src/app/modules/company/pages/add/add.component.ts
index fd0db62..0579fe3 100644
--- a/src/app/modules/company/pages/add/add.component.ts
+++ b/src/app/modules/company/pages/add/add.component.ts
@@ -1,16 +1,17 @@
-import {Component} from '@angular/core';
-import {CompanyService} from "../../service/company.service";
-import {FormBuilder, Validators} from "@angular/forms";
-import {SubscribingComponent} from "../../../shared/components/subscribing.component";
-import {FormField} from "../../../shared/components/entity-add/entity-add.component";
-import {ActivatedRoute, Router} from "@angular/router";
+import {Component} from '@angular/core'
+import {CompanyService} from '../../service/company.service'
+import {Validators} from '@angular/forms'
+import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
+import {FormField} from '../../../shared/components/entity-add/entity-add.component'
+import {ActivatedRoute, Router} from '@angular/router'
+import {ErrorModel, ErrorService} from '../../../shared/service/error.service'
@Component({
selector: 'cre-add',
templateUrl: './add.component.html',
styleUrls: ['./add.component.sass']
})
-export class AddComponent extends SubscribingComponent {
+export class AddComponent extends ErrorHandlingComponent {
formFields: FormField[] = [
{
name: 'name',
@@ -23,31 +24,31 @@ export class AddComponent extends SubscribingComponent {
]
}
]
- unknownError = false
- errorMessage: string | null
+ submittedValues: any | null
+
+ handledErrorModels: ErrorModel[] = [{
+ filter: error => error.status === 409,
+ messageProducer: () => `Une bannière avec le nom '${this.submittedValues.name}' existe déjà`
+ }]
constructor(
private companyService: CompanyService,
+ errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
- super(activatedRoute, router)
+ super(errorService, activatedRoute, router)
+ }
+
+ ngOnInit() {
+ super.ngOnInit()
}
submit(values) {
- this.subscribe(
+ this.submittedValues = values
+ this.subscribeAndNavigate(
this.companyService.save(values.name),
- {
- next: () => this.router.navigate(['/catalog/company/list']),
- error: err => {
- if (err.status === 409) {
- this.errorMessage = `Une bannière avec le nom '${values.name}' existe déjà`
- } else {
- this.unknownError = true
- console.log(err)
- }
- }
- }
+ '/catalog/company/list'
)
}
}
diff --git a/src/app/modules/company/pages/edit/edit.component.html b/src/app/modules/company/pages/edit/edit.component.html
index d3211cd..04864a7 100644
--- a/src/app/modules/company/pages/edit/edit.component.html
+++ b/src/app/modules/company/pages/edit/edit.component.html
@@ -6,8 +6,6 @@
deletePermission="REMOVE_COMPANY"
[entity]="company"
[formFields]="formFields"
- [unknownError]="unknownError"
- [customError]="errorMessage"
(submit)="submit($event)"
(delete)="delete()">
diff --git a/src/app/modules/company/pages/edit/edit.component.ts b/src/app/modules/company/pages/edit/edit.component.ts
index b828812..af7ebbf 100644
--- a/src/app/modules/company/pages/edit/edit.component.ts
+++ b/src/app/modules/company/pages/edit/edit.component.ts
@@ -1,17 +1,18 @@
-import {Component} from '@angular/core';
-import {SubscribingComponent} from "../../../shared/components/subscribing.component";
-import {Company} from "../../../shared/model/company.model";
-import {FormField} from "../../../shared/components/entity-add/entity-add.component";
-import {FormBuilder, Validators} from "@angular/forms";
-import {CompanyService} from "../../service/company.service";
-import {ActivatedRoute, Router} from "@angular/router";
+import {Component} from '@angular/core'
+import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
+import {Company} from '../../../shared/model/company.model'
+import {FormField} from '../../../shared/components/entity-add/entity-add.component'
+import {Validators} from '@angular/forms'
+import {CompanyService} from '../../service/company.service'
+import {ActivatedRoute, Router} from '@angular/router'
+import {ErrorModel, ErrorService} from '../../../shared/service/error.service'
@Component({
selector: 'cre-edit',
templateUrl: './edit.component.html',
styleUrls: ['./edit.component.sass']
})
-export class EditComponent extends SubscribingComponent {
+export class EditComponent extends ErrorHandlingComponent {
company: Company | null
formFields: FormField[] = [
{
@@ -25,64 +26,44 @@ export class EditComponent extends SubscribingComponent {
]
}
]
- unknownError = false
- errorMessage: string | null
+
+ handledErrorModels: ErrorModel[] = [{
+ filter: error => error.status === 409,
+ messageProducer: error => `Une bannière avec le nom '${error.error.id}' existe déjà`
+ }]
constructor(
private companyService: CompanyService,
+ errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
- super(activatedRoute, router)
+ super(errorService, activatedRoute, router)
}
ngOnInit(): void {
super.ngOnInit()
const id = parseInt(this.activatedRoute.snapshot.paramMap.get('id'))
- this.subscribe(
- this.companyService.getById(id),
- {
- next: company => this.company = company,
- error: err => {
- if (err.status == 404) {
- this.router.navigate(['/catalog/company/list'])
- } else {
- this.unknownError = true
- }
- }
- },
- 1
+ this.subscribeEntityById(
+ this.companyService,
+ id,
+ company => this.company = company,
+ '/catalog/company/list'
)
}
submit(values) {
- this.subscribe(
+ this.subscribeAndNavigate(
this.companyService.update(this.company.id, values.name),
- {
- next: () => this.router.navigate(['/catalog/company/list']),
- error: err => {
- if (err.status == 409) {
- this.errorMessage = `Une bannière avec le nom '${values.name}' existe déjà`
- } else {
- this.unknownError = true
- }
- console.log(err)
- }
- }
+ '/catalog/company/list'
)
}
delete() {
- this.subscribe(
+ this.subscribeAndNavigate(
this.companyService.delete(this.company.id),
- {
- next: () => this.router.navigate(['/catalog/company/list']),
- error: err => {
- this.unknownError = true
- console.log(err)
- }
- }
+ '/catalog/company/list'
)
}
}
diff --git a/src/app/modules/company/pages/list/list.component.ts b/src/app/modules/company/pages/list/list.component.ts
index 83c85f0..7f7a88d 100644
--- a/src/app/modules/company/pages/list/list.component.ts
+++ b/src/app/modules/company/pages/list/list.component.ts
@@ -1,16 +1,16 @@
-import {Component} from '@angular/core';
-import {SubscribingComponent} from "../../../shared/components/subscribing.component";
-import {CompanyService} from "../../service/company.service";
-import {EmployeePermission} from "../../../shared/model/employee";
-import {FormBuilder} from "@angular/forms";
-import {ActivatedRoute, Router} from "@angular/router";
+import {Component} from '@angular/core'
+import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
+import {CompanyService} from '../../service/company.service'
+import {EmployeePermission} from '../../../shared/model/employee'
+import {ActivatedRoute, Router} from '@angular/router'
+import {ErrorService} from '../../../shared/service/error.service'
@Component({
selector: 'cre-list',
templateUrl: './list.component.html',
styleUrls: ['./list.component.sass']
})
-export class ListComponent extends SubscribingComponent {
+export class ListComponent extends ErrorHandlingComponent {
companies$ = this.companyService.all
columns = [
{def: 'name', title: 'Nom', valueFn: c => c.name}
@@ -23,9 +23,10 @@ export class ListComponent extends SubscribingComponent {
constructor(
private companyService: CompanyService,
+ errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
- super(activatedRoute, router)
+ super(errorService, activatedRoute, router)
}
}
diff --git a/src/app/modules/employees/pages/add/add.component.html b/src/app/modules/employees/pages/add/add.component.html
index 69f1ebe..951e943 100644
--- a/src/app/modules/employees/pages/add/add.component.html
+++ b/src/app/modules/employees/pages/add/add.component.html
@@ -3,10 +3,6 @@
Création d'un employé
-
-
Une erreur est survenue
-
-
diff --git a/src/app/modules/material/pages/edit/edit.component.ts b/src/app/modules/material/pages/edit/edit.component.ts
index 6a17fc0..0395e5f 100644
--- a/src/app/modules/material/pages/edit/edit.component.ts
+++ b/src/app/modules/material/pages/edit/edit.component.ts
@@ -1,21 +1,21 @@
-import {Component, ViewChild} from '@angular/core';
-import {FormField} from "../../../shared/components/entity-add/entity-add.component";
-import {Validators} from "@angular/forms";
-import {map} from "rxjs/operators";
-import {MaterialTypeService} from "../../../material-type/service/material-type.service";
-import {MaterialService} from "../../service/material.service";
-import {ActivatedRoute, Router} from "@angular/router";
-import {SubscribingComponent} from "../../../shared/components/subscribing.component";
-import {Material} from "../../../shared/model/material.model";
-import {environment} from "../../../../../environments/environment";
-import {FileButtonComponent} from "../../../shared/file-button/file-button.component";
+import {Component, ViewChild} from '@angular/core'
+import {FormField} from '../../../shared/components/entity-add/entity-add.component'
+import {Validators} from '@angular/forms'
+import {map} from 'rxjs/operators'
+import {MaterialTypeService} from '../../../material-type/service/material-type.service'
+import {MaterialService} from '../../service/material.service'
+import {ActivatedRoute, Router} from '@angular/router'
+import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
+import {Material} from '../../../shared/model/material.model'
+import {environment} from '../../../../../environments/environment'
+import {ErrorModel, ErrorService} from '../../../shared/service/error.service'
@Component({
selector: 'cre-edit',
templateUrl: './edit.component.html',
styleUrls: ['./edit.component.sass']
})
-export class EditComponent extends SubscribingComponent {
+export class EditComponent extends ErrorHandlingComponent {
@ViewChild('simdutTemplate', {static: true}) simdutTemplateRef
material: Material | null
@@ -64,79 +64,59 @@ export class EditComponent extends SubscribingComponent {
fileType: 'application/pdf'
}
]
- unknownError = false
- errorMessage: string | null
hasSimdut = false
selectedSimdutFile: File | null
+ handledErrorModels: ErrorModel[] = [{
+ filter: error => error.status === 409,
+ messageProducer: error => `Un produit avec le nom '${error.error.id}' existe déjà`
+ }]
+
constructor(
private materialService: MaterialService,
private materialTypeService: MaterialTypeService,
+ errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
- super(activatedRoute, router)
+ super(errorService, activatedRoute, router)
}
ngOnInit() {
- super.ngOnInit();
+ super.ngOnInit()
this.formFields[3].template = this.simdutTemplateRef
const id = parseInt(this.activatedRoute.snapshot.paramMap.get('id'))
- this.subscribe(
- this.materialService.getById(id),
- {
- next: material => this.material = material,
- error: err => {
- if (err.status === 404) {
- this.router.navigate(['/catalog/material/list'])
- } else {
- this.unknownError = true
- }
- }
- },
- 1
+ this.subscribeEntityById(
+ this.materialService,
+ id,
+ material => this.material = material,
+ '/catalog/material/list'
)
this.subscribe(
this.materialService.hasSimdut(id),
- {next: b => this.hasSimdut = b}
+ b => this.hasSimdut = b
)
}
submit(values) {
- this.subscribe(
+ this.subscribeAndNavigate(
this.materialService.update(this.material.id, values.name, values.inventoryQuantity, values.materialType, this.selectedSimdutFile),
- {
- next: () => this.router.navigate(['/catalog/material/list']),
- error: err => {
- if (err.status == 409) {
- this.errorMessage = `Un produit avec le nom '${values.name}' existe déjà`
- } else {
- this.unknownError = true
- console.error(err)
- }
- }
- }
+ '/catalog/material/list'
)
}
delete() {
- this.subscribe(
+ this.subscribeAndNavigate(
this.materialService.delete(this.material.id),
- {
- next: () => this.router.navigate(['/catalog/material/list']),
- error: err => {
- this.unknownError = true
- console.error(err)
- }
- }
+ '/catalog/material/list'
)
}
openSimdutUrl() {
const simdutUrl = environment.apiUrl + `/material/${this.material.id}/simdut`
- window.open(simdutUrl, "_blank")
+ window.open(simdutUrl, '_blank')
}
}
diff --git a/src/app/modules/material/pages/list/list.component.ts b/src/app/modules/material/pages/list/list.component.ts
index 5fc6e62..7092ac6 100644
--- a/src/app/modules/material/pages/list/list.component.ts
+++ b/src/app/modules/material/pages/list/list.component.ts
@@ -1,17 +1,17 @@
-import {Component} from '@angular/core';
-import {SubscribingComponent} from "../../../shared/components/subscribing.component";
-import {MaterialService} from "../../service/material.service";
-import {EmployeePermission} from "../../../shared/model/employee";
-import {environment} from "../../../../../environments/environment";
-import {FormBuilder} from "@angular/forms";
-import {ActivatedRoute, Router} from "@angular/router";
+import {Component} from '@angular/core'
+import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
+import {MaterialService} from '../../service/material.service'
+import {EmployeePermission} from '../../../shared/model/employee'
+import {environment} from '../../../../../environments/environment'
+import {ActivatedRoute, Router} from '@angular/router'
+import {ErrorService} from '../../../shared/service/error.service'
@Component({
selector: 'cre-list',
templateUrl: './list.component.html',
styleUrls: ['./list.component.sass']
})
-export class ListComponent extends SubscribingComponent {
+export class ListComponent extends ErrorHandlingComponent {
materials$ = this.materialService.allNotMixType
columns = [
{def: 'name', title: 'Code', valueFn: t => t.name},
@@ -42,26 +42,25 @@ export class ListComponent extends SubscribingComponent {
constructor(
private materialService: MaterialService,
+ errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
- super(activatedRoute, router)
+ super(errorService, activatedRoute, router)
}
ngOnInit() {
- super.ngOnInit();
+ super.ngOnInit()
this.subscribe(
this.materials$,
- {
- next: mArray => {
- mArray.forEach(m => {
- this.subscribe(
- this.materialService.hasSimdut(m.id),
- { next: b => this.hasSimdutMap[m.id] = b }
- )
- })
- }
+ mArray => {
+ mArray.forEach(m => {
+ this.subscribe(
+ this.materialService.hasSimdut(m.id),
+ b => this.hasSimdutMap[m.id] = b
+ )
+ })
},
1
)
diff --git a/src/app/modules/shared/components/entity-add/entity-add.component.html b/src/app/modules/shared/components/entity-add/entity-add.component.html
index 86ffa13..9e0876e 100644
--- a/src/app/modules/shared/components/entity-add/entity-add.component.html
+++ b/src/app/modules/shared/components/entity-add/entity-add.component.html
@@ -3,11 +3,6 @@
{{title}}
-
-
Une erreur est survenue
-
{{customError}}
-
-