Re-ordering of children and resources.
- Implement/activate re-ordering in standard children and resources listings - Parent and (for resources) concept default order: ignore 'order' field
This commit is contained in:
parent
b25af04e4c
commit
e74d21bb7a
4 changed files with 50 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -280,7 +280,8 @@ class ConceptView(BaseView):
|
||||||
|
|
||||||
def getChildren(self, topLevelOnly=True, sort=True, noDuplicates=True):
|
def getChildren(self, topLevelOnly=True, sort=True, noDuplicates=True):
|
||||||
form = self.request.form
|
form = self.request.form
|
||||||
if form.get('loops.viewName') == 'index.html' and self.editable:
|
#if form.get('loops.viewName') == 'index.html' and self.editable:
|
||||||
|
if self.editable:
|
||||||
self.registerDojoDnd()
|
self.registerDojoDnd()
|
||||||
if 'children_change_order' in form:
|
if 'children_change_order' in form:
|
||||||
tokens = form.get('child_tokens')
|
tokens = form.get('child_tokens')
|
||||||
|
@ -370,7 +371,24 @@ class ConceptView(BaseView):
|
||||||
for r in rels:
|
for r in rels:
|
||||||
yield self.childViewFactory(r, self.request)
|
yield self.childViewFactory(r, self.request)
|
||||||
|
|
||||||
|
def reorderResources(self, tokens):
|
||||||
|
for r in self.context.getResourceRelations(sort=None):
|
||||||
|
token = ':'.join((util.getUidForObject(r.second),
|
||||||
|
util.getUidForObject(r.predicate)))
|
||||||
|
if token in tokens:
|
||||||
|
pos = tokens.index(token) + 1
|
||||||
|
if r.order != pos:
|
||||||
|
r.order = pos
|
||||||
|
|
||||||
def resources(self):
|
def resources(self):
|
||||||
|
form = self.request.form
|
||||||
|
#if form.get('loops.viewName') == 'index.html' and self.editable:
|
||||||
|
if self.editable:
|
||||||
|
self.registerDojoDnd()
|
||||||
|
if 'resources_change_order' in form:
|
||||||
|
tokens = form.get('resources_tokens')
|
||||||
|
if tokens:
|
||||||
|
self.reorderResources(tokens)
|
||||||
from loops.browser.resource import ResourceRelationView
|
from loops.browser.resource import ResourceRelationView
|
||||||
from loops.organize.personal.browser.filter import FilterView
|
from loops.organize.personal.browser.filter import FilterView
|
||||||
fv = FilterView(self.context, self.request)
|
fv = FilterView(self.context, self.request)
|
||||||
|
|
|
@ -179,6 +179,8 @@
|
||||||
tal:define="resources python: list(item.resources())"
|
tal:define="resources python: list(item.resources())"
|
||||||
tal:condition="resources">
|
tal:condition="resources">
|
||||||
<h2 i18n:translate="">Resources</h2>
|
<h2 i18n:translate="">Resources</h2>
|
||||||
|
<form method="post"
|
||||||
|
tal:omit-tag="not:item/editable">
|
||||||
<table class="listing"
|
<table class="listing"
|
||||||
metal:define-macro="resources">
|
metal:define-macro="resources">
|
||||||
<tr tal:define="sortcol request/resources_sortcol|nothing;
|
<tr tal:define="sortcol request/resources_sortcol|nothing;
|
||||||
|
@ -197,10 +199,13 @@
|
||||||
<th i18n:translate=""
|
<th i18n:translate=""
|
||||||
tal:condition="view/showObjectActions">Info</th>
|
tal:condition="view/showObjectActions">Info</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tbody withHandles="true" id="resources_list"
|
||||||
|
tal:attributes="dojoType python:item.editable and 'dojo.dnd.Source'">
|
||||||
<tal:items repeat="related resources">
|
<tal:items repeat="related resources">
|
||||||
<tal:item define="class python: repeat['related'].odd() and 'even' or 'odd';
|
<tal:item define="class python: repeat['related'].odd() and 'even' or 'odd';
|
||||||
description related/description">
|
description related/description">
|
||||||
<tr tal:attributes="class class">
|
<tr tal:attributes="class string:$class dojoDndItem dojoDndHandle;
|
||||||
|
id related/uniqueId">
|
||||||
<td tal:condition="item/showCheckboxes|nothing"
|
<td tal:condition="item/showCheckboxes|nothing"
|
||||||
tal:define="uid related/uniqueId"
|
tal:define="uid related/uniqueId"
|
||||||
class="checkbox">
|
class="checkbox">
|
||||||
|
@ -242,11 +247,25 @@
|
||||||
style nothing"
|
style nothing"
|
||||||
tal:condition="view/showObjectActions">
|
tal:condition="view/showObjectActions">
|
||||||
<div metal:use-macro="views/node_macros/object_actions" />
|
<div metal:use-macro="views/node_macros/object_actions" />
|
||||||
|
<input type="hidden" name="resources_tokens:list"
|
||||||
|
tal:attributes="value related/uidToken" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tal:item>
|
</tal:item>
|
||||||
</tal:items>
|
</tal:items>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<input type="submit" style="display: none"
|
||||||
|
name="resources_change_order" id="resources_change_order"
|
||||||
|
value="Save Changes"
|
||||||
|
i18n:attributes="value" />
|
||||||
|
<input type="hidden" name="loops.viewName" value="index.html" />
|
||||||
|
<script language="javascript">
|
||||||
|
dojo.subscribe('/dnd/drop', function(data) {
|
||||||
|
if (data.node.id == 'resources_list') {
|
||||||
|
dojo.byId('resources_change_order').style.display = ''}});
|
||||||
|
</script>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</metal:resources>
|
</metal:resources>
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,8 @@ class Concept(Contained, Persistent):
|
||||||
predicates = predicates is None and ['*'] or predicates
|
predicates = predicates is None and ['*'] or predicates
|
||||||
relationships = [ConceptRelation(None, self, p) for p in predicates]
|
relationships = [ConceptRelation(None, self, p) for p in predicates]
|
||||||
if sort == 'default':
|
if sort == 'default':
|
||||||
sort = lambda x: (x.order, x.first.title.lower())
|
#sort = lambda x: (x.order, x.first.title.lower())
|
||||||
|
sort = lambda x: (x.first.title.lower())
|
||||||
rels = (r for r in getRelations(parent, self, relationships=relationships)
|
rels = (r for r in getRelations(parent, self, relationships=relationships)
|
||||||
if canListObject(r.first, noSecurityCheck))
|
if canListObject(r.first, noSecurityCheck))
|
||||||
return sorted(rels, key=sort)
|
return sorted(rels, key=sort)
|
||||||
|
|
|
@ -203,7 +203,8 @@ class Resource(Image, Contained):
|
||||||
obj = getMaster(self)
|
obj = getMaster(self)
|
||||||
relationships = [ResourceRelation(None, obj, p) for p in predicates]
|
relationships = [ResourceRelation(None, obj, p) for p in predicates]
|
||||||
if sort == 'default':
|
if sort == 'default':
|
||||||
sort = lambda x: (x.order, x.first.title.lower())
|
#sort = lambda x: (x.order, x.first.title.lower())
|
||||||
|
sort = lambda x: (x.first.title.lower())
|
||||||
rels = (r for r in getRelations(first=concept, second=obj,
|
rels = (r for r in getRelations(first=concept, second=obj,
|
||||||
relationships=relationships)
|
relationships=relationships)
|
||||||
if canListObject(r.first, noSecurityCheck))
|
if canListObject(r.first, noSecurityCheck))
|
||||||
|
|
Loading…
Add table
Reference in a new issue