oblique-bit / oblique

An Angular front-end framework Tailored for your swiss branded business web application, Oblique provides a standardized corporate design look and feel as well as a collection of ready-to-use Angular components. Oblique, through its fully customizable master layout, takes care of the application's structure, letting you focus on the content.
https://oblique.bit.admin.ch
MIT License
56 stars 13 forks source link

ObMasterLayoutConfig with hasMaxWidth can't be set in child components. #105

Closed ice-blaze closed 1 year ago

ice-blaze commented 1 year ago

Hello Oblique team,

I tried to change the layout.hasMaxWidth value only on some pages. The only way for me to set it is to set it once in the AppComponent. If I want to change the max width in child components nothing changes. Here some examples of code to reproduce the problem.

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss']
})
export class AppComponent {
    public constructor(private readonly config: ObMasterLayoutConfig) {
        config.layout.hasMaxWidth = !config.layout.hasMaxWidth;
    }
}

@Component({
    selector: 'app-home',
    templateUrl: './home.component.html',
    styleUrls: ['./home.component.scss']
})
export class HomeComponent {
    public constructor(private readonly config: ObMasterLayoutConfig) {
        this.config.layout.hasMaxWidth = true;
    }
}

Or another example which doesn't work neither

export class AppComponent {
    public constructor(private readonly config: ObMasterLayoutConfig) {
        setInterval(() => {
            config.layout.hasMaxWidth = !config.layout.hasMaxWidth;
        }, 3000);
    }
}

I expect that it's a value that we can change dynamically because the demo page seems to work like that.

Thank you for your help.

c-saner commented 1 year ago

Hello ice-blaze,

Could you please try with the ObMasterLayoutService instead of the ObMasterLayoutConfig?

If it's still not working in your project then we will need to open a dedicated support ticket.

Kind regards

ice-blaze commented 1 year ago

Indeed that was the reason. I haven't seen the usage part in the documentation. Just checked where was the hasMaxWidth and tried to use the class directly. Thanks for your help. Maybe this issue will help some people who are like me and read not all the documentation.