Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Problem with jstree #1039


User avatar
0
omital created

Hi. I use this code for role permission

(function () {

    var app = angular.module('app');

    var controllerId = 'sts.views.role.edit';
    

    app.controller(controllerId, [
    '$scope', '$uibModal', '$location', '$stateParams', 'abp.services.isirids.role',
    function ($scope, $uibModal, $location, $stateParams, roleService) {
        var vm = this;
        vm.id = $stateParams.id;
        vm.permissionData = [];
        vm.treeData = [];
        $scope.animationsEnabled = false;   


        vm.initialTreeViewDate = function () {
            for (var i = 0; i < vm.role.permissions.length; i++) {
                var _itm = {
                    id: vm.role.permissions[i].name,
                    parent: vm.role.permissions[i].parentName != null ? vm.role.permissions[i].parentName : "#",
                    text: vm.role.permissions[i].displayName,
                    state: { opened: false}
                };

                if (vm.role.grantedPermissions.indexOf(vm.role.permissions[i].name) != -1) {
                    _itm.state.selected = true;
                }
                else
                    _itm.state.selected = false;

                vm.permissionData.push(_itm);
            }
            
            angular.copy(vm.permissionData, vm.treeData);

            vm.treeConfig = {
                core: {
                    multiple: false,
                    animation: true,
                    error: function (error) {
                        $log.error('treeCtrl: error from js tree - ' + angular.toJson(error));
                    },
                    check_callback: true,
                    worker: true
                },
                types: {
                    default: {
                        icon: 'glyphicon glyphicon-chevron-left'
                    },
                    star: {
                        icon: 'glyphicon glyphicon-chevron-left'
                    },
                    cloud: {
                        icon: 'glyphicon glyphicon-chevron-left'
                    }
                },
                version: 1,
                plugins: ['types', 'checkbox']
            };

            this.applyModelChanges = function () {
                return !vm.ignoreChanges;
            };

            this.createCB = function (e, item) {
                $timeout(function () { toaster.pop('success', 'Node Added', 'Added new node with the text ' + item.node.text) });
            };


        };
        
        vm.localize = abp.localization.getSource('ISD');

        if (vm.id > 0) {
            roleService.getRoleForEdit(vm.id)
            .success(function (data) {
                vm.role = data;
                vm.initialTreeViewDate();
            });
        }
        else {
            roleService.getRoleForEdit(-1)
             .success(function (data) {
                 vm.role = data;
                 vm.initialTreeViewDate();
             });
        }

       
        vm.deleteRole = function () {

            swal({
                title: vm.localize("AreYouSure"),
                text: vm.localize("RoleWillBeDeleted", vm.role.name),
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: vm.localize("YesDeleteIt"),
                cancelButtonText:vm.localize("Cancel"),
                closeOnConfirm: false,
                closeOnCancel: true,
            }, function (isConfirm) {
                if (isConfirm) {
                    abp.ui.setBusy(null,
                     roleService.deleteRole({id: vm.role.id }).success(function () {
                         swal(vm.localize("Deleted"), vm.localize("RoleDeleteSuccess"), "success");
                         $location.path('/labsCertificate/list');
                        }
                    ));
                } else { swal(vm.localize("Cancelled"), vm.localize("CancelDescription"), "error"); }
            });
        };
       
        vm.validationErrors = null;


        vm.saveRole = function () {

            //var selectedPermissions = [];


            var checkedItems = $("#jsTreePermission").jstree('get_checked');

            //for (var i = 0; i < checkedItems.length; i++) {
            //        selectedPermissions.push(checkedItems[i]);
            //}

            abp.ui.setBusy(
                null,
                roleService.upsertRole({
                    id: vm.role.id,
                    name: vm.role.name,
                    displayName: vm.role.displayName,
                    isDefault: vm.role.isDefault,
                    selectedPermissions: checkedItems
                    })
                .success(function () {
                    vm.validationErrors = null;
                    abp.notify.info(abp.utils.formatString(vm.localize("RoleEditedMessage"), vm.role.name ));
                    $location.path('/role/list');

                }).
                error(function (data) {

                })
                );
        };
    }]);
})();

most of time I recive thi error message


1 Answer(s)
  • User Avatar
    0
    omital created

    anybody :(