Skip to content

Commit 1f1e211

Browse files
committed
issue1842687: Keywords: After creating, stay in "Create New" mode.
Added support for __redirect_to form variable to the new action. If set the value should be a url. If __redirect_to is present, the user is directed to the url after the new action has completed successfully. E.G. when creating new keywords you often want to stay on the create new keyword page rather than change to the "Edit keyword" page. Setting __redirect_to to the new keyword creation url lets you keep adding new keywords. This mechanism works for any @action=new. So you could keep the user on an "add new issue" page so they can keep adding issues one after the other. Also change the classic tracker keyword.item.html page to have a checkbox (checked by default) to stay on the "new keyword" page rather than displaying the newly created keyword item.
1 parent ece77ca commit 1f1e211

File tree

5 files changed

+78
-2
lines changed

5 files changed

+78
-2
lines changed

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ Features:
134134
requested the ability to put templates into subdirectories. So
135135
the issue class can accept @template=issues/item to get the
136136
html/issues/issue.item.html template. See ``doc/upgrading.txt``.
137+
- issue1842687: Keywords: After creating, stay in "Create New" mode.
138+
Change to classic tracker template to provide a check box (checked
139+
by default) that keeps the user on the "Add new keyword" page after
140+
submitting a new keyword. Usually after submission, you will see the
141+
the page for the new keyword to allow you to change the name of the
142+
keyword. (John Rouillard)
137143

138144
Fixed:
139145

doc/customizing.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,10 @@ of:
15391539

15401540
**new**
15411541
Add a new item to the database. You may use the same `special form
1542-
variables`_ as in the "edit" action.
1542+
variables`_ as in the "edit" action. Also you can set the
1543+
``__redirect_to`` form variable to the URL that should be displayed after
1544+
the new item is created. This is useful if you want to create another
1545+
item rather than edit the newly created item.
15431546

15441547
**retire**
15451548
Retire the item in the database.
@@ -1605,6 +1608,9 @@ variables and their values. You can:
16051608
- Remove items from a multilink property of the current item.
16061609
- Specify that some properties are required for the edit
16071610
operation to be successful.
1611+
- Redirect to a different page after creating a new item (new action
1612+
only, not edit action). Usually you end up on the page for the
1613+
created item.
16081614
- Set up user interface locale.
16091615

16101616
These operations will only take place if the form action (the
@@ -1712,6 +1718,11 @@ None of the above (ie. just a simple form value)
17121718
Any of the form variables may be prefixed with a classname or
17131719
designator.
17141720

1721+
Setting the form variable: ``__redirect_to=`` to a url when @action=new
1722+
redirects the user to the specified url after successfully creating
1723+
the new item. This is useful if you want the user to create another
1724+
item rather than edit the newly created item.
1725+
17151726
Two special form values are supported for backwards compatibility:
17161727

17171728
@note

doc/upgrading.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,46 @@ or with::
162162
the important part is that the action field **must not** include any query
163163
parameters ('#' includes query params).
164164

165+
Option to make adding multiple keywords more convenient
166+
-------------------------------------------------------
167+
168+
In the classic tracker, after adding a new keyword you are redirected
169+
to the page for the new keyword so you can change the keyword's
170+
name. This is usually not desirable as you usually correctly set the
171+
keyword's name when creating the keyword. The new classic tracker has
172+
a new checkbox (checked by default) that keeps you on the same page so
173+
you can add a new keywords one after the other.
174+
175+
To add this to your own tracker, add the following code (prefixed with
176+
a +) after the entry box for the new keyword::
177+
178+
<tr>
179+
<th i18n:translate="">Keyword</th>
180+
<td tal:content="structure context/name/field">name</td>
181+
+ <td tal:condition="not:context/id">
182+
+ <tal:comment tal:replace="nothing">
183+
+ If we get here and do not have an id, we are creating a new
184+
+ keyword. It would be nice to provide some mechanism to
185+
+ determine the preferred state of the "Continue adding keywords"
186+
+ checkbox. By default it is enabled.
187+
+ </tal:comment>
188+
+ <input type="checkbox" id="continue_new_keyword"
189+
+ name="__redirect_to"
190+
+ tal:attributes="value
191+
+ string:${request/base}${request/env/PATH_INFO}?@template=item;
192+
+ checked python:True" />
193+
+ <label for="continue_new_keyword" i18n:translate="">Continue adding keywords.</label>
194+
+ </td>
195+
</tr>
196+
197+
Note remove the leading '+' when adding this to the templates.
198+
199+
The key component here is support for the '__redirect_to' query
200+
property. It is a url which can be used when creating any new item
201+
(issue, user, keyword ....). It controls the next page displayed after
202+
creating the item. If '__redirect_to' is not set, then you end up on
203+
the page for the newly created item.
204+
165205
html/_generic.404.html in trackers use page template
166206
----------------------------------------------------
167207

roundup/cgi/actions.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,12 @@ def handle(self):
726726
# commit now that all the tricky stuff is done
727727
self.db.commit()
728728

729-
# redirect to the new item's page
729+
# Allow an option to stay on the page to create new things
730+
if '__redirect_to' in self.form:
731+
raise exceptions.Redirect('%s&@ok_message=%s'%(
732+
self.form['__redirect_to'].value, urllib_.quote(messages)))
733+
734+
# otherwise redirect to the new item's page
730735
raise exceptions.Redirect('%s%s%s?@ok_message=%s&@template=%s' % (
731736
self.base, self.classname, self.nodeid, urllib_.quote(messages),
732737
urllib_.quote(self.template)))

share/roundup/templates/classic/html/keyword.item.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@
3636
<tr>
3737
<th i18n:translate="">Keyword</th>
3838
<td tal:content="structure context/name/field">name</td>
39+
<td tal:condition="not:context/id">
40+
<tal:comment tal:replace="nothing">
41+
If we get here and do not have an id, we are creating a new
42+
keyword. It would be nice to provide some mechanism to
43+
determine the preferred state of the "Continue adding keywords"
44+
checkbox. By default I have it enabled.
45+
</tal:comment>
46+
<input type="checkbox" id="continue_new_keyword"
47+
name="__redirect_to"
48+
tal:attributes="value
49+
string:${request/base}${request/env/PATH_INFO}?@template=item;
50+
checked python:True" />
51+
<label for="continue_new_keyword" i18n:translate="">Continue adding keywords.</label>
52+
</td>
3953
</tr>
4054

4155
<tr>

0 commit comments

Comments
 (0)