fix layout editor
This commit is contained in:
parent
67e6ef7136
commit
ce25902c30
3 changed files with 6 additions and 14 deletions
|
@ -171,22 +171,18 @@
|
|||
<script src="https://cdn.staticfile.org/html5sortable/0.13.3/html5sortable.min.js" crossorigin="anonymous"></script>
|
||||
<script src="{% static 'js/sort_layout.js' %}"></script>
|
||||
{% endif %}
|
||||
|
||||
{{ layout|json_script:"layout-data" }}
|
||||
<script>
|
||||
const initialLayoutData = JSON.parse("{{ layout|escapejs }}");
|
||||
const initialLayoutData = JSON.parse(document.getElementById('layout-data').textContent);
|
||||
// initialize sort element visibility and order
|
||||
initialLayoutData.forEach(elem => {
|
||||
// False to false, True to true
|
||||
if (elem.visibility === "False") {
|
||||
elem.visibility = false;
|
||||
} else {
|
||||
elem.visibility = true;
|
||||
}
|
||||
// set visiblity
|
||||
// set visiblity
|
||||
$('#' + elem.id).data('visibility', elem.visibility);
|
||||
if (!elem.visibility) {
|
||||
$('#' + elem.id).hide();
|
||||
}
|
||||
// order
|
||||
// order
|
||||
$('#' + elem.id).appendTo('.main-section-wrapper');
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -584,7 +584,6 @@ def profile(request, user_name):
|
|||
if user != request.user:
|
||||
liked_collections = liked_collections.filter(query_visible(request.user))
|
||||
|
||||
layout = user.get_preference().get_serialized_profile_layout()
|
||||
return render(
|
||||
request,
|
||||
"profile.html",
|
||||
|
@ -599,7 +598,7 @@ def profile(request, user_name):
|
|||
for i in liked_collections.order_by("-edited_time")[:5]
|
||||
],
|
||||
"liked_collections_count": liked_collections.count(),
|
||||
"layout": layout,
|
||||
"layout": user.get_preference().profile_layout,
|
||||
"reports": reports,
|
||||
"unread_announcements": unread_announcements,
|
||||
},
|
||||
|
|
|
@ -226,9 +226,6 @@ class Preference(models.Model):
|
|||
show_last_edit = models.PositiveSmallIntegerField(default=0)
|
||||
no_anonymous_view = models.PositiveSmallIntegerField(default=0)
|
||||
|
||||
def get_serialized_profile_layout(self):
|
||||
return str(self.profile_layout).replace("'", '"')
|
||||
|
||||
def __str__(self):
|
||||
return str(self.user)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue