comparison doc/customizing.txt @ 5185:349bef975367

Make @template support two alternate templates for error and ok cases. Setting @template=oktmpl|errortmpl in a form will display the next page using the oktmpl if the change did not cause an error. If submitting the form caused an error (raised by an auditor or something else), the user is displayed a page using the errortmpl. Docs in customizing.tmpl. Look for modal edit.
author John Rouillard <rouilj@ieee.org>
date Fri, 17 Feb 2017 19:44:15 -0500
parents e1e40674a0bc
children 36630a062fb5
comparison
equal deleted inserted replaced
5184:a40ea636a2ad 5185:349bef975367
1822 1822
1823 you will use the template at: ``test/issue.item.html``. If that 1823 you will use the template at: ``test/issue.item.html``. If that
1824 template doesn't exit it will try to use 1824 template doesn't exit it will try to use
1825 ``test/_generic.item.html``. If that template doesn't exist 1825 ``test/_generic.item.html``. If that template doesn't exist
1826 it will return an error. 1826 it will return an error.
1827
1828 Implementing Modal Editing Using @template
1829 ------------------------------------------
1830
1831 Many item templates allow you to edit the item. They contain
1832 code that renders edit boxes if the user has edit permissions.
1833 Otherwise the template will just display the item information.
1834
1835 In some cases you want to do a modal edit. The user has to take some
1836 action (click a button or follow a link) to shift from display mode to
1837 edit mode. When the changes are submitted, ending the edit mode,
1838 the user is returned to display mode.
1839
1840 Modal workflows usually slow things down and are not implemented by
1841 default templates. However for some workflows a modal edit is useful.
1842 For example a batch edit mode that allows the user to edit a number of
1843 issues all from one form could be implemented as a modal workflow of:
1844
1845 * search for issues to modify
1846 * switch to edit mode and change values
1847 * exit back to the results of the search
1848
1849 To implement the modal edit, assume you have an issue.edit.html
1850 template that implements an edit form. On the display page (a version
1851 of issue.item.html modified to only display information) add a link
1852 that calls the display url, but adds ``@template=edit`` to the link.
1853
1854 This will now display the edit page. On the edit page you want to add
1855 a hidden text field to your form named ``@template`` with the value:
1856 ``item|edit``. When the form is submitted it is validated. If the
1857 form is correct the user will see the item rendered using the item
1858 template. If there is an error (validation failed) the item will be
1859 rendered using the edit template. The edit template that is rendered
1860 will display all the changes that the user made to the form before it
1861 was submitted. The user can correct the error and resubmit the changes
1862 until the form validates.
1863
1864 If the form failed to validate but the ``@template`` field had the
1865 value ``item`` the user would still see the error, but all of the data
1866 the user entered would be discarded. The user would have to redo all
1867 the edits again.
1868
1827 1869
1828 How the templates work 1870 How the templates work
1829 ---------------------- 1871 ----------------------
1830 1872
1831 1873
2217 properties. 2259 properties.
2218 list lists all of the active (not retired) items in the class. 2260 list lists all of the active (not retired) items in the class.
2219 csv return the items of this class as a chunk of CSV text. 2261 csv return the items of this class as a chunk of CSV text.
2220 propnames lists the names of the properties of this class. 2262 propnames lists the names of the properties of this class.
2221 filter lists of items from this class, filtered and sorted. Two 2263 filter lists of items from this class, filtered and sorted. Two
2222 options are avaible for sorting: 2264 options are available for sorting:
2223 2265
2224 1. by the current *request* filterspec/filter/sort/group args 2266 1. by the current *request* filterspec/filter/sort/group args
2225 2. by the "filterspec", "sort" and "group" keyword args. 2267 2. by the "filterspec", "sort" and "group" keyword args.
2226 "filterspec" is ``{propname: value(s)}``. "sort" and 2268 "filterspec" is ``{propname: value(s)}``. "sort" and
2227 "group" are an optionally empty list ``[(dir, prop)]`` 2269 "group" are an optionally empty list ``[(dir, prop)]``

Roundup Issue Tracker: http://roundup-tracker.org/