From 909db14c75a3cbf9a432dc354a5584a2609e0ce7 Mon Sep 17 00:00:00 2001 From: "holger.trampe" Date: Sat, 18 Jan 2020 17:42:37 +0100 Subject: [PATCH] =?UTF-8?q?Organigramm=20double-id-bug=20bei=20agency=20un?= =?UTF-8?q?d=20user=20gel=C3=B6st?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- orga/templates/orga/orga_main.html | 143 ++++------------------------- 1 file changed, 17 insertions(+), 126 deletions(-) diff --git a/orga/templates/orga/orga_main.html b/orga/templates/orga/orga_main.html index 5605e4c..c056302 100644 --- a/orga/templates/orga/orga_main.html +++ b/orga/templates/orga/orga_main.html @@ -26,29 +26,28 @@ margin-right:auto;"> var data = [ - { 'id' : '{{request.user.profile.agency.pk}}', 'parent' : "", 'role': "", 'name': '{{request.user.profile.agency.name}}', 'color': '#71AF17', "imageUrl": ""}, + { 'id' : '{{request.user.profile.agency.pk}}', 'parent' : "", 'role': "", 'name': '{{request.user.profile.agency.name}}', 'color': '#71AF17', "imageUrl": "", 'children' : []}, {% for u in agencyuser %} {% if u.profile.parent == u %} - { 'id': '{{u.pk}}' , 'name': "{{u.first_name}} {{u.last_name}}",'role': '{{u.profile.get_func_display}}
{{u.profile.compfunc}}', 'parent': "{{request.user.profile.agency.pk}}", 'color': '#1859B7', "imageUrl": "{{u.profile.get_photo_url}}", 'userid' : '{{u.pk}}' }, + { 'id': '{{u.pk}}' , 'name': "{{u.first_name}} {{u.last_name}}",'role': '{{u.profile.get_func_display}}
{{u.profile.compfunc}}', 'parent': "{{request.user.profile.agency.pk}}", 'color': '#1859B7', "imageUrl": "{{u.profile.get_photo_url}}", 'userid' : '{{u.pk}}', 'children' : [] }, {% else %} - { 'id': '{{u.pk}}', 'name': "{{u.first_name}} {{u.last_name}}", 'role': '{{u.profile.get_func_display}}
{{u.profile.compfunc}}', 'parent': '{{u.profile.parent.pk}}', 'color': '#1859B7', "imageUrl": "{{u.profile.get_photo_url }}", 'userid' : '{{u.pk}}'}, + { 'id': '{{u.pk}}', 'name': "{{u.first_name}} {{u.last_name}}", 'role': '{{u.profile.get_func_display}}
{{u.profile.compfunc}}', 'parent': '{{u.profile.parent.pk}}', 'color': '#1859B7', "imageUrl": "{{u.profile.get_photo_url }}", 'userid' : '{{u.pk}}', 'children' : []}, {% endif %} {% endfor %} ]; -/* -var data = [ - {'id' : 11, 'name' : 'AGENCY', 'parent' : "", 'children': []}, - {'id' : 2, 'name' : 'Holger', 'parent' : 11, 'children' : []}, - {'id' : 9, 'name' : 'Felix', 'parent' : 11, 'children' : []}, - {'id' : 1, 'name' : 'Marko', 'parent' : 2, 'children' : []}, - {'id' : 23, 'name' : 'Janina', 'parent' : 1, 'children' : []}, - {'id' : 6, 'name' : 'Franziska', 'parent' : 1, 'children' : []}, - {'id' : 12, 'name' : 'Berthold', 'parent' : 6, 'children' : []}, - {'id' : 7, 'name' : 'Jürgen', 'parent' : 23, 'children' : []} -]; +//Check for Agency and User-IDs - dont touch the userid for URLs! +for(i = 0; i < data.length; i++){ + for(k = 0; k < data.length; k++){ + if(k != i){ + if(data[i]['id'] == data[k]['id']){ + data[k]['id'] = data[k]['id']*10; + } + } + } +} -*/ +//Creates nested array from data function unflatten(arr) { var tree = [], mappedArr = {}, @@ -78,37 +77,9 @@ function unflatten(arr) { return tree; } -function unflattenList(arr) { - var tree = [], - mappedArr = {}, - arrElem, - mappedElem; - - // First map the nodes of the array to an object -> create a hash table. - for(var i = 0, len = arr.length; i < len; i++) { - arrElem = arr[i]; - mappedArr[arrElem.id] = arrElem; - mappedArr[arrElem.id]['children'] = []; - } - - for (var id in mappedArr) { - if (mappedArr.hasOwnProperty(id)) { - mappedElem = mappedArr[id]; - // If the element is not at the root level, add it to its parent array of children. - if (mappedElem.parent) { - mappedArr[mappedElem['parent']]['children'].push(mappedElem); - } - // If the element is at the root level, add it to first level elements array. - else { - tree.push(mappedElem); - } - } - } - return tree; - } - var html = ['