Skip to content

Commit

Permalink
fix: minor code issues
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryT-CG committed Jan 22, 2024
1 parent 0ac5eb2 commit 0ccb8c0
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component } from '@angular/core'

@Component({
selector: 'ps-root',
templateUrl: './app.component.html'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ocx-page-header>
<ocx-page-content>
<div *ngIf="!loading && !product && changeMode !== 'CREATE'" class="card px-3 align-items-center">
<p-message severity="error" styleClass="p-2" [text]="'VALIDATION.PRODUCT.NOT_EXISTS' | translate"></p-message>
<p-message severity="error" styleClass="p-2" [text]="'ACTIONS.SEARCH.PRODUCT.NOT_EXISTS' | translate"></p-message>
</div>
<p-tabView *ngIf="(product && !loading) || changeMode === 'CREATE'">
<p-tabPanel id="product_detail_panel_props" [header]="'DIALOG.TABS.PROPERTIES' | translate">
Expand Down
11 changes: 7 additions & 4 deletions src/app/product-store/product-detail/product-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export class ProductDetailComponent implements OnInit {
}

ngOnInit(): void {
console.log('product detail ngOnInit()')
if (this.productName !== '') {
this.changeMode = 'VIEW'
this.loadProduct()
Expand Down Expand Up @@ -75,9 +74,10 @@ export class ProductDetailComponent implements OnInit {
this.prepareTranslations()
},
error: (err: any) => {
console.error('search: ', err)
this.msgService.error({
summaryKey: 'DIALOG.LOAD_ERROR'
// detailKey: err.error.indexOf('was not found') > 1 ? 'DIALOG.NOT_FOUND' : err.error
summaryKey: 'ACTIONS.SEARCH.PRODUCT.LOAD_ERROR'
// detailKey: err.error.indexOf('was not found') > 1 ? 'SEARCH.NOT_FOUND' : err.error
})
this.close()
}
Expand Down Expand Up @@ -196,6 +196,7 @@ export class ProductDetailComponent implements OnInit {
public onClose() {
this.close()
}

public onEdit() {
this.getProduct()
this.changeMode = 'EDIT'
Expand All @@ -214,13 +215,14 @@ export class ProductDetailComponent implements OnInit {
public onSave() {
this.productPropsComponent.onSubmit()
}

public onCreate(data: any) {
this.product = data
this.changeMode = 'VIEW'
this.router.navigate(['./../', this.product?.name], { relativeTo: this.route })
}

public onChange(nameChanged: boolean) {
console.log('detail.onChange ')
if (nameChanged) {
this.close()
} else {
Expand All @@ -229,6 +231,7 @@ export class ProductDetailComponent implements OnInit {
this.prepareTranslations()
}
}

public onDelete(ev: MouseEvent, item: Product): void {
ev.stopPropagation()
this.product = item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('ProductDetailComponent', () => {
component.ngOnInit()

expect(msgServiceSpy.error).toHaveBeenCalledWith({
summaryKey: 'DIALOG.LOAD_ERROR'
summaryKey: 'ACTIONS.SEARCH.PRODUCT.LOAD_ERROR'
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<ocx-page-content>
<div *ngIf="!product$" class="card px-3 align-items-center">
<p-message severity="error" styleClass="p-2" [text]="'VALIDATION.PRODUCT.NOT_EXISTS' | translate"></p-message>
<p-message severity="error" styleClass="p-2" [text]="'ACTIONS.SEARCH.PRODUCT.NOT_EXISTS' | translate"></p-message>
</div>
<ng-container *ngIf="product$ | async as products">
<p-dataView
Expand All @@ -31,6 +31,7 @@
[rowsPerPageOptions]="[10, 20, 50]"
[rows]="viewMode === 'grid' ? 12 : 10"
[layout]="viewMode"
[emptyMessage]="'ACTIONS.SEARCH.NOT_FOUND' | translate"
filterBy="name,displayName"
[sortField]="sortField"
[sortOrder]="sortOrder"
Expand Down
16 changes: 13 additions & 3 deletions src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@
"VIEW_MODE_LIST": "Listenansicht",
"VIEW_MODE_TABLE": "Tabellenansicht"
},
"SEARCH": {
"NOT_FOUND": "Keine Daten gefunden",
"APP": {
"NOT_EXISTS": "Eine App mit diesem Namen konnte nicht gefunden werden.",
"LOAD_ERROR": "App konnte nicht geladen werden",
"NOT_FOUND": "App nicht gefunden"
},
"PRODUCT": {
"NOT_EXISTS": "Ein Produkt mit diesem Namen konnte nicht gefunden werden.",
"LOAD_ERROR": "Produkt konnte nicht geladen werden",
"NOT_FOUND": "Produkt nicht gefunden"
}
},
"CANCEL": "Abbrechen",
"CHOOSE": "Auswählen",
"SAVE": "Speichern",
Expand Down Expand Up @@ -115,8 +128,6 @@
"SEARCH.HEADER": "Product Store",
"SEARCH.SUBHEADER": "Produkte und deren Apps verwalten",
"DETAIL.SUBHEADER": "Produkt Details",
"LOAD_ERROR": "Produkt konnte nicht geladen werden",
"NOT_FOUND": "Produkt nicht gefunden",
"TABS": {
"APPS": "Apps",
"INTERN": "Intern",
Expand Down Expand Up @@ -172,7 +183,6 @@
"VALIDATION": {
"FORM_INVALID": "Die Daten sind nicht bereit zum Speichern.",
"PRODUCT.UNIQUE_CONSTRAINT": "Ein Produkt mit diesem Namen existiert bereits.",
"PRODUCT.NOT_EXISTS": "Ein Produkt mit diesem Namen konnte nicht gefunden werden.",
"PRODUCT.INVALID_NAME": "Dieser Namen kann nicht verwendet werden.",
"ERRORS": {
"PARSE_ERROR": "Parserfehler: Die enthaltene Struktur entspricht nicht dem erwarteten Format.",
Expand Down
16 changes: 13 additions & 3 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@
"VIEW_MODE_LIST": "List view",
"VIEW_MODE_TABLE": "Table view"
},
"SEARCH": {
"NOT_FOUND": "No data found",
"APP": {
"PRODUCT.NOT_EXISTS": "An App with this name could not be found.",
"LOAD_ERROR": "Failed to load App",
"NOT_FOUND": "App was not found"
},
"PRODUCT": {
"PRODUCT.NOT_EXISTS": "A Product with this name could not be found.",
"LOAD_ERROR": "Failed to load Product",
"NOT_FOUND": "Product was not found"
}
},
"CANCEL": "Cancel",
"CHOOSE": "Choose",
"SAVE": "Save",
Expand Down Expand Up @@ -119,8 +132,6 @@
"SEARCH.HEADER": "Product Store",
"SEARCH.SUBHEADER": "Viewing and Managing Products and their Apps",
"DETAIL.SUBHEADER": "Product Details",
"LOAD_ERROR": "Failed to load Product",
"NOT_FOUND": "Product was not found",
"TABS": {
"APPS": "Apps",
"INTERN": "Internal",
Expand Down Expand Up @@ -176,7 +187,6 @@
"VALIDATION": {
"FORM_INVALID": "The data are not ready to store.",
"PRODUCT.UNIQUE_CONSTRAINT": "A Product with this name exists already.",
"PRODUCT.NOT_EXISTS": "A product with this name could not be found.",
"PRODUCT.INVALID_NAME": "This name is a reserved term and cannot be used.",
"ERRORS": {
"PARSE_ERROR": "Parse error: The contained structure does not match the expected format.",
Expand Down

0 comments on commit 0ccb8c0

Please sign in to comment.