kartik-v / yii2-tree-manager

An advanced tree management module using nested sets for Yii 2.
http://demos.krajee.com/tree-manager
Other
150 stars 107 forks source link

List Icons does not show icons when type ICON_RAW #189

Closed buttflattery closed 6 years ago

buttflattery commented 6 years ago

Steps to reproduce the issue

  1. Init TreeView with the following iconEditSettings
    'iconEditSettings' => [
                        'show' => 'list',
                        'type' => TreeView::ICON_RAW,
                        'listData' => [
                            '<i class="material-icons">widgets</i>' => 'Root',
                            '<i class="material-icons">folder</i>' => 'Sub Campaign',
                        ]
                    ],

    2.Open TreeView and add a new node 3.Select the desired icon and hit save

Expected behavior and actual behavior

It should show me the selected icon in the treeview before the node name

When I follow those steps, I see... There isn't any icon displayed in the treeview before the new node name and when inspected the html it shows the following HTML for the node inside the tree

<div class="kv-node-detail kv-focussed" tabindex="-1">
<span class="text-info kv-node-icon kv-icon-child">
<span class="glyphicon glyphicon-<i class=&quot;material-icons&quot;>folder</i>"></span></span>
<span class="kv-node-label">New child Campaign</span>
</div>

You can see that in case of ICON_RAW it still tries to append it in the class attribute like this class="glyphicon glyphicon-<i class=&quot;material-icons&quot;>folder</i>">

I was expecting...

it should add the provided raw HTML as a separate tag instead of appending into the class name assuming it to be Font awesome icon class name as the docs say

If type = TreeView::ICON_RAW: $key is the icon HTML markup to be stored and $value will be the description of the icon be displayed as selector in the icon list. For example:

[
    '<img src="images/folder.jpg">' => 'Folder',
    '<img src="images/file.jpg">' => 'File',
    '<img src="images/tag.jpg">' => 'Tag',
]

Which means if i provide the same set of name=>value pair above provided in the docs it still papends the img tag inside the class attribute

Environment

Yii 2.0.14.1

Browsers

Operating System

Libraries

Isolating the problem

kartik-v commented 6 years ago

Try to configure it this way as shown below for rendering icons within the list

'iconEditSettings' => [
    'show' => 'list',
    'type' => TreeView::ICON_RAW,
    'listData' => [
         'widgets' => '<i class="material-icons">widgets</i> Root',
         'folder' => '<i class="material-icons">folder</i> Sub Campaign'
    ]
],

However the above setting is only for rendering icons within the LIST data -

for rendering them as markup in the node - I will check back and update.

buttflattery commented 6 years ago

Hmm looks like the name=>value pair has to go the other way around, I think the documentation should also be updated, i will be trying that now thanks for the heads up @kartik-v

kartik-v commented 6 years ago

Yes.. for rendering it in the list... However both values and keys can be same if rendering the node icon