abpframework / abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.54k stars 3.37k forks source link

request tree taghelper component #17122

Open blackWins opened 1 year ago

blackWins commented 1 year ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe the problem.

No response

Describe the solution you'd like

Request that jstree be made into a taghelper component

Additional context

0afac34ff144f509ba8d8cafd84a331 example js


    var l = abp.localization.getResource('BookStore');

    var service = acme.bookStore.identityServer.organizationUnit;

    //import jstree.js

    var map = {
        id: 'id', parent: 'parentId', text: 'displayName'
    }

    $('#jstree').jstree({
        core: {
            check_callback: true,
            data: function (node, callback) {
                var map = this.settings.map;
                service.getChildren({ id: node.id === '#' ? '' : node.id }).done((res) => {
                    if (map) {
                        res.map(x => {
                            x.parent = x[map.parent] || '#';
                            x.text = x[map.text];
                            x.id = x[map.id];
                            x.children = true;
                            return x;
                        });
                    }
                    callback(res)
                })
            }
        },
        map,
        contextmenu: {
            items: function (node) {
                var items = $.jstree.defaults.contextmenu.items();
                delete items.ccp;
                items.create.text = l(items.create.text)
                items.rename.text = l(items.rename.text)
                items.remove.text = l(items.remove.text)
                if (!abp.auth.isGranted('acme.BookStore.OrganizationUnit.Create')) delete items.create
                if (!abp.auth.isGranted('acme.BookStore.OrganizationUnit.Update')) delete items.rename
                if (!abp.auth.isGranted('acme.BookStore.OrganizationUnit.Delete')) delete items.remove
                return items
            }
        },
        plugins: ['wholerow', 'state', 'contextmenu', 'dnd']
    }).on('delete_node.jstree', function (e, data) {
        abp.message.confirm(l('DeletionConfirmationMessage', data.node.text))
            .then(function (confirmed) {
                if (confirmed) {
                    service.delete(data.node.id)
                        .then(function () {
                            abp.notify.info(l('SuccessfullyDeleted'));
                            data.instance.refresh();
                        });
                }
            });
        data.instance.refresh();
    }).on('create_node.jstree', function (p, n) {
        var input = {}; 
        input[map['parent']] = n.parent; 
        input[map['text']] = n.node.text;
        service.create(input)
            .done((res) => { n.instance.set_id(n.node, res.id) })
            .catch(() => { n.instance.refresh() });
    }).on('rename_node.jstree', function (p, n) {
        if (n.old == n.text) return
        var input = {}; input[map['text']] = n.text;
        service.update(n.node.id, input)
            .catch(() => { n.instance.refresh() });
    }).on('move_node.jstree', function (p, n) {
        var input = {id:n.node.id}; 
        input[map['parent']] = n.node.parent;
        service.move(input)
            .then(() => { n.instance.refresh() })
            .catch(() => { n.instance.refresh() });
    }).on('changed.jstree', function (p, n) {
    });
stale[bot] commented 10 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.