extend TargetAction, provide CreateConceptPage for page-based add forms; allow suppressing of assignment part on forms
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3160 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
7c09dec614
commit
f3b30498e0
4 changed files with 78 additions and 59 deletions
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2009 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# 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
|
||||
|
@ -33,9 +33,14 @@ from loops.util import _
|
|||
|
||||
class TargetAction(Action):
|
||||
|
||||
@Lazy
|
||||
page = None
|
||||
qualifier = typeToken = None
|
||||
fixedType = False
|
||||
viewTitle = ''
|
||||
addParams = {}
|
||||
|
||||
#@Lazy
|
||||
def url(self):
|
||||
#return self.getActionUrl(self.page.getUrlForTarget(self.view))
|
||||
if self.page is None: # how could this happen?
|
||||
baseUrl = self.view.virtualTargetUrl
|
||||
else:
|
||||
|
@ -43,7 +48,17 @@ class TargetAction(Action):
|
|||
baseUrl = self.page.getUrlForTarget(self.target)
|
||||
else:
|
||||
baseUrl = self.page.virtualTargetUrl
|
||||
return self.getActionUrl(baseUrl)
|
||||
paramString = ''
|
||||
urlParams = {}
|
||||
if self.typeToken:
|
||||
urlParams['form.type'] = self.typeToken
|
||||
if self.fixedType:
|
||||
urlParams['fixed_type'] = 'yes'
|
||||
urlParams.update(self.addParams)
|
||||
if urlParams:
|
||||
paramString = '?' + urlencode(urlParams)
|
||||
url = self.getActionUrl(baseUrl)
|
||||
return url + paramString
|
||||
|
||||
|
||||
class DialogAction(Action):
|
||||
|
|
|
@ -74,6 +74,7 @@ class ObjectForm(NodeView):
|
|||
formState = FormState() # dummy, don't update!
|
||||
isInnerHtml = True
|
||||
isPopup = False
|
||||
showAssignments = True
|
||||
|
||||
def __init__(self, context, request):
|
||||
super(ObjectForm, self).__init__(context, request)
|
||||
|
@ -375,6 +376,19 @@ class CreateConceptForm(CreateObjectForm):
|
|||
return ()
|
||||
|
||||
|
||||
class CreateConceptPage(CreateConceptForm):
|
||||
|
||||
isInnerHtml = False
|
||||
|
||||
def setupController(self):
|
||||
super(CreateConceptPage, self).setupController()
|
||||
self.registerDojoFormAll()
|
||||
|
||||
@Lazy
|
||||
def nextUrl(self):
|
||||
return self.nodeView.getUrlForTarget(self.context)
|
||||
|
||||
|
||||
class InnerForm(CreateObjectForm):
|
||||
|
||||
@property
|
||||
|
|
|
@ -46,12 +46,7 @@
|
|||
</td></tr></tbody>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="5" class="headline"
|
||||
i18n:translate="">Assign Parent Concepts</td>
|
||||
</tr>
|
||||
<tr metal:use-macro="view/template/macros/assignments" />
|
||||
<tr metal:use-macro="view/template/macros/search_concepts" />
|
||||
<tal:custom define="customMacro view/customMacro"
|
||||
condition="customMacro">
|
||||
<tr metal:use-macro="customMacro" />
|
||||
|
@ -75,6 +70,8 @@
|
|||
fixedType request/fixed_type | nothing">
|
||||
<input type="hidden" name="form.action" value="create"
|
||||
tal:attributes="value view/form_action" />
|
||||
<input type="hidden" name="fixed_type"
|
||||
tal:attributes="value fixedType" />
|
||||
<table cellpadding="3" class="form">
|
||||
<tbody><tr><th colspan="5" class="headline">
|
||||
<span tal:content="request/view_title|view/title"
|
||||
|
@ -108,12 +105,7 @@
|
|||
</td></tr></tbody>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="5" class="headline"
|
||||
i18n:translate="">Assign Parent Concepts</td>
|
||||
</tr>
|
||||
<tr metal:use-macro="view/template/macros/assignments" />
|
||||
<tr metal:use-macro="view/template/macros/search_concepts" />
|
||||
<tal:custom define="customMacro view/customMacro"
|
||||
condition="customMacro">
|
||||
<tr metal:use-macro="customMacro" />
|
||||
|
@ -125,7 +117,12 @@
|
|||
</metal:block>
|
||||
|
||||
|
||||
<metal:assignments define-macro="assignments">
|
||||
<metal:assignments define-macro="assignments"
|
||||
tal:condition="view/showAssignments">
|
||||
<tr>
|
||||
<td colspan="5" class="headline"
|
||||
i18n:translate="">Assign Parent Concepts</td>
|
||||
</tr>
|
||||
<tbody id="form.assignments">
|
||||
<tr tal:repeat="type view/presetTypesForAssignment">
|
||||
<td><span i18n:translate="">Type</span>: </td>
|
||||
|
@ -153,42 +150,46 @@
|
|||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr metal:define-macro="search_concepts">
|
||||
<td>
|
||||
<label for="concept.search.type">
|
||||
<span i18n:translate="">Type</span>:</label></td>
|
||||
<td>
|
||||
<select id="concept.search.type"
|
||||
onChange="setConceptTypeForComboBox('concept.search.type', 'concept.search.text')">
|
||||
<tal:types repeat="type view/conceptTypesForSearch">
|
||||
<option value="loops:*"
|
||||
i18n:translate=""
|
||||
tal:attributes="value type/token"
|
||||
tal:content="type/title">Topic</option>
|
||||
</tal:types>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<label for="concept.search.text">
|
||||
<span i18n:translate="">Concept</span>:</label></td>
|
||||
<td>
|
||||
<input type="hidden"
|
||||
id="concept.search.predicate"
|
||||
tal:attributes="value view/defaultPredicateUid" />
|
||||
<div dojoType="dojox.data.QueryReadStore" jsId="conceptSearch"
|
||||
url="listConceptsForComboBox.js?searchType=" >
|
||||
</div>
|
||||
<input dojoType="dijit.form.FilteringSelect" store="conceptSearch"
|
||||
autoComplete="False" labelAttr="label"
|
||||
name="concept.search.text" id="concept.search.text" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="button" value="Select"
|
||||
i18n:attributes="value"
|
||||
onClick="addConceptAssignment('concept', 'assignments')" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</metal:assignments>
|
||||
|
||||
|
||||
<tr metal:define-macro="search_concepts">
|
||||
<td><label for="concept.search.type"><span i18n:translate="">Type</span>:</label></td>
|
||||
<td>
|
||||
<select id="concept.search.type"
|
||||
onChange="setConceptTypeForComboBox('concept.search.type', 'concept.search.text')">
|
||||
<tal:types repeat="type view/conceptTypesForSearch">
|
||||
<option value="loops:*"
|
||||
i18n:translate=""
|
||||
tal:attributes="value type/token"
|
||||
tal:content="type/title">Topic</option>
|
||||
</tal:types>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<label for="concept.search.text">
|
||||
<span i18n:translate="">Concept</span>:</label></td>
|
||||
<td>
|
||||
<input type="hidden"
|
||||
id="concept.search.predicate"
|
||||
tal:attributes="value view/defaultPredicateUid" />
|
||||
<div dojoType="dojox.data.QueryReadStore" jsId="conceptSearch"
|
||||
url="listConceptsForComboBox.js?searchType=" >
|
||||
</div>
|
||||
<input dojoType="dijit.form.FilteringSelect" store="conceptSearch"
|
||||
autoComplete="False" labelAttr="label"
|
||||
name="concept.search.text" id="concept.search.text" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="button" value="Select"
|
||||
i18n:attributes="value"
|
||||
onClick="addConceptAssignment('concept', 'assignments')" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<metal:versioning define-macro="versioning"
|
||||
|
|
|
@ -48,14 +48,3 @@ class TaskView(ConceptView):
|
|||
|
||||
pass
|
||||
|
||||
def xx_getActions(self, category='object', page=None, target=None):
|
||||
actions = []
|
||||
if category == 'portlet':
|
||||
actions.append(DialogAction(self, title=_(u'Edit Task...'),
|
||||
description=_(u'Modify task.'),
|
||||
viewName='edit_concept.html',
|
||||
dialogName='editTask',
|
||||
page=page,
|
||||
target=target))
|
||||
self.registerDojoDateWidget()
|
||||
return actions
|
||||
|
|
Loading…
Add table
Reference in a new issue