implemented topic tree view
This commit is contained in:
parent
deae2d39e5
commit
9dc9705406
4 changed files with 41 additions and 10 deletions
|
|
@ -6,6 +6,6 @@
|
||||||
box-shadow: 3px 3px 11px 4px rgb(231, 231, 231);
|
box-shadow: 3px 3px 11px 4px rgb(231, 231, 231);
|
||||||
-webkit-box-shadow: 3px 3px 11px 4px rgb(231, 231, 231);
|
-webkit-box-shadow: 3px 3px 11px 4px rgb(231, 231, 231);
|
||||||
-moz-box-shadow: 3px 3px 11px 4px rgb(231, 231, 231);
|
-moz-box-shadow: 3px 3px 11px 4px rgb(231, 231, 231);
|
||||||
padding: 0.5em;
|
padding: 0.5em 0.5em 0.5em 1em;
|
||||||
margin: 0.5em;
|
margin: 0.5em 0.5em 0.5em 0;
|
||||||
}
|
}
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<nav class="top-nav">
|
<nav class="top-nav" style="background-color: #22db90">
|
||||||
<a href="#" data-target="slide-out" class="sidenav-trigger full hide-on-large-only" id="open-sidenav-toggle">
|
<a href="#" data-target="slide-out" class="sidenav-trigger full hide-on-large-only" id="open-sidenav-toggle">
|
||||||
<i class="material-icons">menu</i>
|
<i class="material-icons">menu</i>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,39 @@
|
||||||
<link rel="stylesheet" href="{% static 'order_style.css' %}">
|
<link rel="stylesheet" href="{% static 'order_style.css' %}">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<ul>
|
<div class="col s8 offset-s2">
|
||||||
{% for topic in roottopics %}
|
<ul id="root_list" class="topic_list" ondrop="drop(event)" ondragover="allowDrop(event)"
|
||||||
{% include "blog/tree_view_template.html" %}
|
ondragleave="resetbgColor(event)">
|
||||||
{% endfor %}
|
{% for topic in roottopics %}
|
||||||
</ul>
|
{% include "blog/tree_view_template.html" %}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
function resetbgColor(ev) {
|
||||||
|
ev.preventDefault();
|
||||||
|
ev.target.style.backgroundColor = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function allowDrop(ev) {
|
||||||
|
ev.preventDefault();
|
||||||
|
ev.target.style.backgroundColor = "#37FF3733";
|
||||||
|
Array.from(ev.target.children).forEach(elem => {
|
||||||
|
elem.style.backgroundColor = "white";
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function drag(ev) {
|
||||||
|
ev.dataTransfer.setData("targetObject", ev.target.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function drop(ev) {
|
||||||
|
ev.preventDefault();
|
||||||
|
var targetOject = ev.dataTransfer.getData("targetObject");
|
||||||
|
ev.target.appendChild(document.getElementById(targetOject));
|
||||||
|
ev.target.style.backgroundColor = "";
|
||||||
|
}
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
{% load tree_utils %}
|
{% load tree_utils %}
|
||||||
<li class="topic_list_element"> {{ topic.name }}
|
<li class="topic_list_element" draggable="true" ondragstart="drag(event)"
|
||||||
|
id="list_elem_{{ topic.id }}"> {{ topic.name }}
|
||||||
{% if topic|has_children %}
|
{% if topic|has_children %}
|
||||||
<ul class="topic_list">
|
<ul class="topic_list" ondrop="drop(event)" ondragover="allowDrop(event)" id="list_{{ topic.id }}">
|
||||||
{% for child in topic|all_children %}
|
{% for child in topic|all_children %}
|
||||||
{% with topic=child template_name="blog/tree_view_template.html" %}
|
{% with topic=child template_name="blog/tree_view_template.html" %}
|
||||||
{% include template_name %}
|
{% include template_name %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue