Ezio Melotti <[email protected]> added the comment:
FWIW I tried to replace the select/option with checkboxes, but the code was
starting to get a bit too ugly so I gave up for now.
If I replace
<td tal:content="structure
python:context['keywords'].menu(height=5)">keywords</td>
with:
<td><tal:block tal:repeat="key context/keywords">
<input tal:attributes="value python:key._nodeid" name="keywords"
type="checkbox">
<tal:block tal:content="python:str(key._klass.get(key._nodeid, 'name'))" />
</tal:block>
</td>
I can get a check box for each /selected/ keyword, with its name next to it.
Using str(key._klass.get(key._nodeid, 'name')) to get to the name isn't too
pretty already, and getting the list of all the keywords seems even worse.
In templating.py:MultilinkHTMLProperty.menu there's the code that creates the
select/option, and IIUC to get the list of keywords names it does:
for optionid in options:
# get the option value, and if it's None use an empty string
option = linkcl.get(optionid, k) or ''
where options is:
options = [opt
for opt in linkcl.filter(None, conditions, sort_on)
if self._db.security.hasPermission("View", self._client.userid,
linkcl.classname, itemid=opt)]
where linkcl is:
linkcl = self._db.getclass(self._prop.classname)
maybe there's an easy way to do this, but if that's the case I didn't find it.
Putting all this in an extension might avoid some clutter in the template
though.
The current code has a <select name="keywords"> and several <option
value="N">keyname</option>, where N is the id. The post request contains all
the selected options, e.g. &keywords=2&keywords=3, or if "no selection" is
selected, the request should be &keywords=-2,-3 (where 2 and 3 are the ids of
the selected keywords).
Having several <input name="keywords" value="N" type="checkbox"> seems to work
without having to change the server side but it still won't solve the original
problem.
IIUC when you remove the last keyword, no '&keywords=' is sent to the server
and in this case, instead of removing all the keywords, it leaves them
unchanged. Therefore you need to select "no selection" in order to send a
&keywords=-N that explicitly removes the last keyword.
----------
nosy: +eric.araujo, ezio.melotti
_______________________________________________________
PSF Meta Tracker <[email protected]>
<http://psf.upfronthosting.co.za/roundup/meta/issue384>
_______________________________________________________
_______________________________________________
Tracker-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tracker-discuss