Giter VIP home page Giter VIP logo

Comments (5)

kevinpapst avatar kevinpapst commented on August 25, 2024 1

Since parent is typed for MenuItemModelInterface we are a bit stuck..

You are the boss, not your tooling 😁

    public function isDisabled(): bool
    {
        /** @var MenuItemModel $parent */
        $parent = $this->getParent();

        return $parent?->isDisabled() ?? $this->disabled; 
    }

or

    public function isDisabled(): bool
    {
        $parent = $this->getParent();
        if ($parent instanceof MenuItemModel) {
            return $parent->isDisabled();
        }

        return $this->disabled; 
    }

from tablerbundle.

kevinpapst avatar kevinpapst commented on August 25, 2024

I don't have an answer, I can just tell you that I am using my own final class MenuItemModel implements MenuItemInterface in my project. Which you could do as well, to support the raw HTML.

You know you can add blocks where it makes sense.
I am just not a fan of adding features, which are not part of Tabler itself.
We should instead push those changes upstream if somehow possible.

I am a contributor of the Tabler repo, so if you send reasonable PRs (instead of discussions) codecalm will likely merge it. Yes, he is not very responsive, which is fine (even though it can be annoying) ... it is still a free open source project. Give it a try and see what happens.

from tablerbundle.

cavasinf avatar cavasinf commented on August 25, 2024

Sorry for the late reply, I have been running after time lately ⏲️ 🏃

(instead of discussions)

Funny part is THEY convert issues into discussions.

I am using my own final class MenuItemModel implements MenuItemInterface in my project

So you have ovewrote the menu.twig.html template?

I am just not a fan of adding features, which are not part of Tabler itself.

Agree for the separator feature that I want.
Can we at least allow raw?

Even today MenuItem has a $divider option but not used for Tabler.
Which I think comes from AdminLTE.

private bool $divider = false;

from tablerbundle.

kevinpapst avatar kevinpapst commented on August 25, 2024

So you have ovewrote the menu.twig.html template?

No, only the model for more features.

Can we at least allow raw?

How? General rule of thumb is: whenever you have to use raw there is something fishy going on 😁
Yes, there are legit use-cases, but not many. That |raw filter produced quite some bugs in the past for me. It is always a (big) risk, when you do not think twice about source of the data...

Make a proposal, I am not against it, if there is a good and safe use-case.

Which I think comes from AdminLTE.

Yes, very likely 🙃

from tablerbundle.

cavasinf avatar cavasinf commented on August 25, 2024

Okay, so I might need an external eye to solve my case then:
How to add disabled member of MenuItemModel AND in the getter, checks if parent is also not already disabled.

Since parent is typed for MenuItemModelInterface we are a bit stuck..

use KevinPapst\TablerBundle\Model\MenuItemModel as TablerMenuItemModel;

class MenuItemModel extends TablerMenuItemModel
{
    private bool $disabled = false;
    
    public function isDisabled(): bool
    {
        // ❌ Polymorphic call => PhpStan will not allow that
        return $this->getParent()?->isDisabled() ?? $this->disabled;
    }

    public function setDisabled(bool $disabled): void
    {
        $this->disabled = $disabled;
    }
}

ATE, I think I need to rewrite the whole MenuItemModel, and menu.html.twig to fit my needs

it is a dev problem and overwriting the template is a good way to go

from tablerbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.