Ionic3-MultiLevelSideMenu icon indicating copy to clipboard operation
Ionic3-MultiLevelSideMenu copied to clipboard

Add new id property to SideMenuOption interface

Open sebaferreras opened this issue 5 years ago • 0 comments

Even though it's easy to use the displayText to decide which option/suboption should be marked as selected, it'd be better if the component allow users to add an id to each option/suboption and then use that id instead of the displayText.

For example:

public enum SideMenuPage {
    AdminDetails,
    UserDetails
}

// ...

const options: Array<SideMenuOption>  = [
    {
        displayText: 'Admin',
        suboptions: [
            {
                id: SideMenuPage.AdminDetails,
                displayText: 'Details',
                component: 'DetailsPage',
                // ...   
            },
            // ...
        ]
    },
    {
        displayText: 'User',
        suboptions: [
            {
                id: SideMenuPage.UserDetails,
                displayText: 'Details',
                component: 'DetailsPage',
                // ...
            },
            // ...
        ]
    }
]

And then:

@Component({
    selector: 'page-details',
    templateUrl: 'details.html'
})
@SideMenuDisplayTextConditions([
    { propertyName: 'userType', matcher: Matcher.ToEqual, value: UserType.Admin, optionId: SideMenuPage.AdminDetails },
    { propertyName: 'userType', matcher: Matcher.ToEqual, value: UserType.User, optionId: SideMenuPage.UserDetails }
])

sebaferreras avatar Oct 12 '18 14:10 sebaferreras