allow fixed ordering of concept children in standard listing via drag and drop
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@4189 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
551351d59c
commit
fdaf31bd79
3 changed files with 49 additions and 10 deletions
|
@ -690,6 +690,11 @@ class BaseView(GenericView, I18NView):
|
|||
#cm.register('css', identifier='dojo.css', position=1,
|
||||
# resourceName='ajax.dojo/dojo/resources/dojo.css', media='all')
|
||||
|
||||
def registerDojoDnd(self):
|
||||
self.registerDojo()
|
||||
jsCall = 'dojo.require("dojo.dnd.Source")'
|
||||
self.controller.macros.register('js-execute', jsCall, jsCall=jsCall)
|
||||
|
||||
def registerDojoDialog(self):
|
||||
self.registerDojo()
|
||||
jsCall = 'dojo.require("dijit.Dialog")'
|
||||
|
|
|
@ -269,7 +269,23 @@ class ConceptView(BaseView):
|
|||
instance.view = self
|
||||
return instance
|
||||
|
||||
def reorderChildren(self, tokens):
|
||||
for r in self.context.getChildRelations(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 getChildren(self, topLevelOnly=True, sort=True, noDuplicates=True):
|
||||
form = self.request.form
|
||||
if form.get('loops.viewName') == 'index.html' and self.editable:
|
||||
self.registerDojoDnd()
|
||||
if 'children_change_order' in form:
|
||||
tokens = form.get('child_tokens')
|
||||
if tokens:
|
||||
self.reorderChildren(tokens)
|
||||
cm = self.loopsRoot.getConceptManager()
|
||||
hasType = cm.getTypePredicate()
|
||||
params = self.params
|
||||
|
|
|
@ -97,12 +97,14 @@
|
|||
|
||||
|
||||
<metal:children define-macro="conceptchildren">
|
||||
<div tal:attributes="class string:content-$level;
|
||||
ondblclick python: item.openEditWindow('configure.html')"
|
||||
tal:define="children python: list(item.unique(item.children()))"
|
||||
tal:condition="children">
|
||||
<h2 i18n:translate=""
|
||||
tal:condition="show_headline|python:True">Children</h2>
|
||||
<div tal:attributes="class string:content-$level;
|
||||
ondblclick python: item.openEditWindow('configure.html')"
|
||||
tal:define="children python: list(item.unique(item.children()))"
|
||||
tal:condition="children">
|
||||
<h2 i18n:translate=""
|
||||
tal:condition="show_headline|python:True">Children</h2>
|
||||
<form method="post"
|
||||
tal:omit-tag="not:item/editable">
|
||||
<table class="listing">
|
||||
<tr>
|
||||
<th i18n:translate="">Title</th>
|
||||
|
@ -112,16 +114,18 @@
|
|||
<th i18n:translate=""
|
||||
tal:condition="view/showObjectActions">Info</th>
|
||||
</tr>
|
||||
<tbody withHandles="true" id="children_list"
|
||||
tal:attributes="dojoType python:item.editable and 'dojo.dnd.Source'">
|
||||
<tal:items repeat="related children">
|
||||
<tal:item define="class python: repeat['related'].odd() and 'even' or 'odd';
|
||||
description related/description;
|
||||
predicate related/predicateTitle;
|
||||
info python: ' | '.join(
|
||||
t for t in (description, predicate) if t)">
|
||||
<tr tal:attributes="class class">
|
||||
<tr tal:attributes="class string:$class dojoDndItem dojoDndHandle;
|
||||
id related/uniqueId">
|
||||
<td valign="top">
|
||||
<a href="#"
|
||||
tal:attributes="href python: view.getUrlForTarget(related);
|
||||
<a tal:attributes="href python: view.getUrlForTarget(related);
|
||||
title info">
|
||||
<span tal:replace="related/title">Resource Title</span>
|
||||
</a>
|
||||
|
@ -136,12 +140,26 @@
|
|||
style nothing"
|
||||
tal:condition="view/showObjectActions">
|
||||
<div metal:use-macro="views/node_macros/object_actions" />
|
||||
<input type="hidden" name="child_tokens:list"
|
||||
tal:attributes="value related/uidToken" />
|
||||
</td>
|
||||
</tr>
|
||||
</tal:item>
|
||||
</tal:items>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<input type="submit" style="display: none"
|
||||
name="children_change_order" id="children_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 == 'children_list') {
|
||||
dojo.byId('children_change_order').style.display = ''}});
|
||||
</script>
|
||||
</form>
|
||||
</div>
|
||||
</metal:children>
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue