diff --git a/src/app/admin-view/menu-new/menu-new.component.ts b/src/app/admin-view/menu-new/menu-new.component.ts
index 41361c0..41a2e49 100644
--- a/src/app/admin-view/menu-new/menu-new.component.ts
+++ b/src/app/admin-view/menu-new/menu-new.component.ts
@@ -101,11 +101,11 @@ export class MenuNewComponent {
}
editSn(id: string) {
- this.ac.menu.editSn(id, this.dataSource.data.find(v => v._id == id)?.sn).subscribe(s => this.refreshIfGood(s))
+ this.ac.menu.editSn(id, this.dataSource.data.find(v => v._id == id)!.sn).subscribe(s => this.refreshIfGood(s))
}
editOb(id: string) {
- this.ac.menu.editOb(id, this.dataSource.data.find(v => v._id == id)?.ob).subscribe(s => this.refreshIfGood(s))
+ this.ac.menu.editOb(id, this.dataSource.data.find(v => v._id == id)!.ob).subscribe(s => this.refreshIfGood(s))
}
editKol(id: string) {
diff --git a/src/app/app-view/menu/menu.component.html b/src/app/app-view/menu/menu.component.html
index 269bcda..8810f42 100644
--- a/src/app/app-view/menu/menu.component.html
+++ b/src/app/app-view/menu/menu.component.html
@@ -13,8 +13,8 @@
- {{i}}
- - {{i.charAt(0).toUpperCase()+i.substring(1)}}
- - {{getsn.second.charAt(0).toUpperCase()+getsn.second.substring(1)}}
+ - {{capitalize(i)}}
+ - {{capitalize(getsn.second)}}
@@ -51,7 +51,7 @@
-
+
Brak danych, wybierz inny dzieĆ.
diff --git a/src/app/app-view/menu/menu.component.ts b/src/app/app-view/menu/menu.component.ts
index d7fa30c..ca0eb09 100644
--- a/src/app/app-view/menu/menu.component.ts
+++ b/src/app/app-view/menu/menu.component.ts
@@ -32,17 +32,34 @@ export class MenuComponent {
}
menu?: Menu;
- get getsn() {return (this.menu && this.menu.sn) ? this.menu.sn : null}
- get getob() {return (this.menu && this.menu.ob) ? this.menu.ob : null}
+ get getsn() {return (this.menu && this.checkIfAnyProperty(this.menu.sn)) ? this.menu.sn : null}
+ get getob() {return (this.menu && this.checkIfAnyProperty(this.menu.ob)) ? this.menu.ob : null}
get getkol() {return (this.menu && this.menu.kol) ? this.menu.kol : null}
get gettitle() {return (this.menu && this.menu.dayTitle && this.menu.dayTitle != "") ? this.menu.dayTitle : null}
+ private checkIfAnyProperty(obj: { [x: string]: string | string[];}) {
+ for (let i in obj) {
+ if (Array.isArray(obj[i])) {
+ if (obj[i].length > 0) return true
+ } else {
+ if (!!obj[i]) return true
+ }
+ }
+ return false
+ }
+
+ capitalize(str: string) {
+ return str.charAt(0).toUpperCase()+str.substring(1)
+ }
+
updateMenu(silent?: boolean) {
this.loading = !silent
if (!silent) this.menu = undefined
this.uc.getMenu(this.day).subscribe(m => {
this.loading = false
this.menu = m
+ console.log(m);
+
})
}
diff --git a/src/app/types/menu.ts b/src/app/types/menu.ts
index 4b79dd3..9cc5c00 100644
--- a/src/app/types/menu.ts
+++ b/src/app/types/menu.ts
@@ -3,11 +3,11 @@ import { Moment } from "moment";
export interface Menu {
_id: string;
day: Moment;
- sn?: {
+ sn: {
fancy: string[];
second: string;
};
- ob?: {
+ ob: {
soup: string;
vege: string;
meal: string;