Skip to content

Commit

Permalink
Bug fixes ch38688
Browse files Browse the repository at this point in the history
  • Loading branch information
pendea committed Nov 29, 2024
1 parent 258e311 commit 99769eb
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src_ts/app-shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ export class AppShell extends LoadingMixin(connect(store)(LitElement)) {
:host-context([dir='rtl']) reason-display {
--text-padding: 26px 80px 26px 24px;
}
div[slot='tabs'] {
width: 100%;
}
sl-tab-group {
--indicator-color: var(--primary-color);
max-width: calc(100% - 2px);
Expand Down Expand Up @@ -159,7 +162,7 @@ export class AppShell extends LoadingMixin(connect(store)(LitElement)) {
</div>
</div>
<div slot="tabs">
<sl-tab-group @sl-tab-show="${this.tabChanged}" no-scroll-controls>
<sl-tab-group @sl-tab-show="${this.tabChanged}">
${this.tabs?.map(
(t) =>
html` <sl-tab
Expand Down Expand Up @@ -380,9 +383,11 @@ export class AppShell extends LoadingMixin(connect(store)(LitElement)) {
getAppStaticData() {
this.getCurrentUser().then((user: any) => {
if (user) {
if (!user.is_unicef_user) {
window.location.href = window.location.origin + '/menu/';
}
this.user = user;
this.getCountryDetails();

// Seems to not be used
// this.getSectors();
// this.getDropdownsStaticData();
Expand All @@ -392,9 +397,10 @@ export class AppShell extends LoadingMixin(connect(store)(LitElement)) {
}

getCountryDetails() {
sendRequest({endpoint: Endpoints.userCountry}).then(
(resp) => (this.countryDetails = resp && resp.length ? resp[0] : {})
);
sendRequest({endpoint: Endpoints.userCountry}).then((resp) => {
this.countryDetails = resp && resp.length ? resp[0] : {};
this.requestUpdate();
});
}

// Seems to not be used
Expand Down
2 changes: 1 addition & 1 deletion src_ts/components/appshell/page-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class PageHeader extends LitElement {
}
</style>
<app-toolbar sticky class="layout-horizontal align-items-center" hide-app-menu>
<app-toolbar sticky class="layout-horizontal align-items-center" hide-app-menu .profile=${this.profile}>
<div slot="dropdowns">
<countries-dropdown
id="countries"
Expand Down
11 changes: 11 additions & 0 deletions src_ts/components/pages/view-fam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ export class ViewFam extends LitElement {
this.embedSource = `${famProd}&$filter=business_area/area_code eq '${this.countryCode}'`;
}
}
static get observedAttributes() {
return ['country-code']; // Watch for the `country-code` attribute
}

attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
super.attributeChangedCallback(name, oldValue, newValue);
if (name === 'country-code' && oldValue !== newValue) {
this.countryCode = newValue || ''; // Update property when attribute changes
this.embedSource = `${famProd}&$filter=business_area/area_code eq '${this.countryCode}'`;
}
}

render() {
return html`
Expand Down
11 changes: 11 additions & 0 deletions src_ts/components/pages/view-fmm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ export class ViewFMM extends LitElement {
this.embedSource = `${fmmProd}&$filter=fm_ontrack/Area_x0020_Code eq '${this.countryCode}'`;
}
}
static get observedAttributes() {
return ['country-code']; // Watch for the `country-code` attribute
}

attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
super.attributeChangedCallback(name, oldValue, newValue);
if (name === 'country-code' && oldValue !== newValue) {
this.countryCode = newValue || ''; // Update property when attribute changes
this.embedSource = `${fmmProd}&$filter=fm_ontrack/Area_x0020_Code eq '${this.countryCode}'`;
}
}

render() {
return html`
Expand Down
11 changes: 11 additions & 0 deletions src_ts/components/pages/view-fmp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ export class ViewFMP extends LitElement {
this.embedSource = `${fmpProd}&$filter=fm_ontrack/Area_x0020_Code eq '${this.countryCode}'`;
}
}
static get observedAttributes() {
return ['country-code']; // Watch for the `country-code` attribute
}

attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
super.attributeChangedCallback(name, oldValue, newValue);
if (name === 'country-code' && oldValue !== newValue) {
this.countryCode = newValue || ''; // Update property when attribute changes
this.embedSource = `${fmpProd}&$filter=fm_ontrack/Area_x0020_Code eq '${this.countryCode}'`;
}
}

render() {
return html`
Expand Down
11 changes: 11 additions & 0 deletions src_ts/components/pages/view-partnerships.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ export class ViewPartnerships extends LitElement {
this.setEmbedSource();
}
}
static get observedAttributes() {
return ['country-code']; // Watch for the `country-code` attribute
}

attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
super.attributeChangedCallback(name, oldValue, newValue);
if (name === 'country-code' && oldValue !== newValue) {
this.countryCode = newValue || ''; // Update property when attribute changes
this.setEmbedSource();
}
}

private setEmbedSource(): void {
this.embedSource = `${partnershipsProd}&$filter=business_area/area_code eq '${this.countryCode}'`;
Expand Down

0 comments on commit 99769eb

Please sign in to comment.