Add submenu
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -46,6 +46,7 @@ def savefile():
|
|||||||
def edit():
|
def edit():
|
||||||
theme = tmp.datas['config']['theme']
|
theme = tmp.datas['config']['theme']
|
||||||
menu = DB.datas['menu']
|
menu = DB.datas['menu']
|
||||||
|
print('edit_menu' + str(menu))
|
||||||
myblocs = tmp.datas['blocs']
|
myblocs = tmp.datas['blocs']
|
||||||
return render_template('/edit.html.tpl',
|
return render_template('/edit.html.tpl',
|
||||||
blocEdit="",
|
blocEdit="",
|
||||||
@@ -170,8 +171,19 @@ def delImage(bloc, image):
|
|||||||
@login_required
|
@login_required
|
||||||
def editMenu():
|
def editMenu():
|
||||||
print (request.form)
|
print (request.form)
|
||||||
for key in request.form.keys():
|
DB.datas['menu']=dict()
|
||||||
print (key)
|
for menu in request.form:
|
||||||
|
if '§§' in menu:
|
||||||
|
submenu = menu.split("§§")
|
||||||
|
if submenu[0] in DB.datas['menu'].keys():
|
||||||
|
DB.datas['menu'][submenu[0]] = DB.datas['menu'][submenu[0]] | {submenu[1]: str(request.form[menu])}
|
||||||
|
else:
|
||||||
|
DB.datas['menu'][submenu[0]] = {submenu[1]: str(request.form[menu])}
|
||||||
|
|
||||||
|
else:
|
||||||
|
DB.datas['menu'][menu] = str(request.form[menu])
|
||||||
|
print (DB.datas['menu'])
|
||||||
|
flash (u'Le menu a bien été modifier', 'succes');
|
||||||
return make_response(('Update menu succesfull', 200))
|
return make_response(('Update menu succesfull', 200))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,11 +28,11 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
</div>
|
||||||
<button class="btn btn-outline-success" onclick="openForm()">+</button>
|
<button class="btn btn-outline-success" onclick="openForm()">+</button>
|
||||||
<hr>
|
<hr>
|
||||||
<button class="btn btn-success" type="submit"> Enregistrer </button>
|
<button class="btn btn-success" type="submit"> Enregistrer </button>
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
<label for="nom"><b>Nom</b></label>
|
<label for="nom"><b>Nom</b></label>
|
||||||
<input type="text" placeholder="Nom" id="newEntry_name" required="">
|
<input type="text" placeholder="Nom" id="newEntry_name" required="">
|
||||||
|
<input type="checkbox" id="submenu" onclick="disableLink()" value="Cette entré est un sous-menu"><br>
|
||||||
<label for="link"><b>Lien</b></label>
|
<label for="link"><b>Lien</b></label>
|
||||||
<input type="text" placeholder="un lien ou nom d'un bloc" id="newEntry_link">
|
<input type="text" placeholder="un lien ou nom d'un bloc" id="newEntry_link">
|
||||||
<button type="button" onclick="addEntry()" class="btn">Ajouter</button>
|
<button type="button" onclick="addEntry()" class="btn">Ajouter</button>
|
||||||
@@ -114,6 +114,8 @@
|
|||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<!-- Add entry to menu-->
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
.entry {
|
.entry {
|
||||||
@@ -180,6 +182,10 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
function disableLink() {
|
||||||
|
document.getElementById("newEntry_link").setAttribute("disabled", true);
|
||||||
|
}
|
||||||
|
|
||||||
function openForm() {
|
function openForm() {
|
||||||
document.getElementById("myForm").style.display = "block";
|
document.getElementById("myForm").style.display = "block";
|
||||||
}
|
}
|
||||||
@@ -193,8 +199,7 @@
|
|||||||
var menu = document.getElementById("Menu");
|
var menu = document.getElementById("Menu");
|
||||||
var entry_name = document.getElementById("newEntry_name").value;
|
var entry_name = document.getElementById("newEntry_name").value;
|
||||||
var entry_link = document.getElementById("newEntry_link").value;
|
var entry_link = document.getElementById("newEntry_link").value;
|
||||||
console.log(entry_name);
|
|
||||||
console.log(entry_link);
|
|
||||||
|
|
||||||
// Create menu button
|
// Create menu button
|
||||||
new_entry_btn = document.createElement("button");
|
new_entry_btn = document.createElement("button");
|
||||||
@@ -202,25 +207,78 @@
|
|||||||
text_button = document.createTextNode(entry_name);
|
text_button = document.createTextNode(entry_name);
|
||||||
new_entry_btn.appendChild(text_button);
|
new_entry_btn.appendChild(text_button);
|
||||||
|
|
||||||
// Create input
|
|
||||||
new_entry_input = document.createElement("input");
|
|
||||||
text_link = document.createTextNode(entry_link);
|
|
||||||
new_entry_input.setAttribute("id", entry_name);
|
|
||||||
new_entry_input.setAttribute("name", entry_name);
|
|
||||||
new_entry_input.setAttribute("class", "input-menu");
|
|
||||||
new_entry_input.setAttribute("value", text_link.textContent);
|
|
||||||
|
|
||||||
// Create menu entry
|
|
||||||
new_menu_entry = document.createElement("div");
|
new_menu_entry = document.createElement("div");
|
||||||
new_menu_entry.setAttribute("class", "entry");
|
new_menu_entry.setAttribute("class", "entry");
|
||||||
new_menu_entry.setAttribute("id", entry_name);
|
new_menu_entry.setAttribute("id", entry_name);
|
||||||
new_menu_entry.appendChild(new_entry_btn);
|
|
||||||
new_menu_entry.appendChild(new_entry_input);
|
|
||||||
|
|
||||||
|
submenu_check = document.getElementById("submenu").checked;
|
||||||
|
|
||||||
|
if ( submenu_check )
|
||||||
|
{
|
||||||
|
new_entry_btn.setAttribute("class", "btn btn-outline-dark");
|
||||||
|
new_menu_entry.setAttribute("class", "entry submenu n1");
|
||||||
|
|
||||||
|
new_submenu = document.createElement("div");
|
||||||
|
new_submenu.setAttribute("class", "list");
|
||||||
|
new_submenu.setAttribute("id", entry_name);
|
||||||
|
|
||||||
|
new Sortable(new_submenu, {
|
||||||
|
group: 'shared',
|
||||||
|
animation: 150,
|
||||||
|
invertSwap: true,
|
||||||
|
fallbackOnBody: true,
|
||||||
|
swapThreshold: 0.65,
|
||||||
|
onAdd: function (evt) {
|
||||||
|
var itemEl = evt.item;
|
||||||
|
console.log(itemEl.parentElement.id);
|
||||||
|
parentid = itemEl.parentElement.id;
|
||||||
|
if ( parentid === "Menu" ){
|
||||||
|
itemEl.setAttribute("id", itemEl.getAttribute("name"));
|
||||||
|
for (child of itemEl.children){
|
||||||
|
nodeName= child.nodeName;
|
||||||
|
if ( nodeName === "INPUT"){
|
||||||
|
child.setAttribute("name", itemEl.getAttribute("name"));
|
||||||
|
child.setAttribute("id", itemEl.getAttribute("name"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
itemEl.setAttribute("id", itemEl.parentElement.id.concat("§§", itemEl.getAttribute("id")) );
|
||||||
|
for (child of itemEl.children){
|
||||||
|
nodeName= child.nodeName;
|
||||||
|
if ( nodeName === "INPUT"){
|
||||||
|
console.log(child.nodeName);
|
||||||
|
child.setAttribute("name", itemEl.id);
|
||||||
|
child.setAttribute("id", itemEl.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
new_menu_entry.appendChild(new_entry_btn);
|
||||||
|
new_menu_entry.appendChild(new_submenu);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Create input
|
||||||
|
new_entry_input = document.createElement("input");
|
||||||
|
text_link = document.createTextNode(entry_link);
|
||||||
|
new_entry_input.setAttribute("id", entry_name);
|
||||||
|
new_entry_input.setAttribute("name", entry_name);
|
||||||
|
new_entry_input.setAttribute("class", "input-menu");
|
||||||
|
new_entry_input.setAttribute("value", text_link.textContent);
|
||||||
|
|
||||||
|
// Create menu entry
|
||||||
|
|
||||||
|
new_menu_entry.appendChild(new_entry_btn);
|
||||||
|
new_menu_entry.appendChild(new_entry_input);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
menu.appendChild(new_menu_entry);
|
menu.appendChild(new_menu_entry);
|
||||||
|
|
||||||
|
|
||||||
document.getElementById("myForm").style.display = "none";
|
document.getElementById("myForm").style.display = "none";
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user