Quantcast

How to choose a template on submission error

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to choose a template on submission error

John P. Rouillard
Hi all:

I have implemented a form of

  http://roundup-tracker.org/cgi-bin/moin.cgi/ProjectManagerBatchEditing

in my tracker. If I display a search (index) using the batch
template I get an index page where the table is inside a form and
(almost) every item in the table is editable.

When the form is submitted, my code returns to the index template
displaying the same issues that were editable in the batch
template.

This works fine and does what I want except when the backend
determines there is an error. In this case normal index page is
used and an error is reported.

However all the data (both valid and invalid) that was in the
original form is lost. There is no way for the user to recover it.

When there is an error, I want the page to use the batch
template. Given some recent changes to the roundup core code, I
think rebuilding the batch edit page should preserve all of the
user's changes and then they can fix them and submit the page
again.

Is there any native support (e.g. @errortemplate) for specifying a
template that should be used if the back end discovers an error in
the submission?

If not does anybody have any bright ideas on how to specify an
error template?

I don't think the core roundup code knows what template was used to
generate the submission, but if it did, would it be a good idea to
reuse that template automatically on error?

--
                                -- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Roundup-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/roundup-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to choose a template on submission error

Ralf Schlatterbeck-3
On Sun, Feb 05, 2017 at 02:08:37PM -0500, John P. Rouillard wrote:

> Hi all:
>
> I have implemented a form of
>
>   http://roundup-tracker.org/cgi-bin/moin.cgi/ProjectManagerBatchEditing
>
> in my tracker. If I display a search (index) using the batch
> template I get an index page where the table is inside a form and
> (almost) every item in the table is editable.
>
> When the form is submitted, my code returns to the index template
> displaying the same issues that were editable in the batch
> template.

I think you have to set the form that is reloaded after submission as
the batch template again. Otherwise the error redirect won't work.

I recently did this in a project where my edit form also had a different
namen (not item) and found out how to return to the correct page, I'll
have a look how I did this.

That said: You can probably define a new action that does almost the
same as the normal edit action but redirects to some other page in case
of success.

> When there is an error, I want the page to use the batch
> template. Given some recent changes to the roundup core code, I
> think rebuilding the batch edit page should preserve all of the
> user's changes and then they can fix them and submit the page
> again.
>
> Is there any native support (e.g. @errortemplate) for specifying a
> template that should be used if the back end discovers an error in
> the submission?

I think there is a mechanism of generally returning to the correct form
after editing (if successful or not), see above. I don't think we
currently support different forms for sucessful and unsuccessful submit.

> If not does anybody have any bright ideas on how to specify an
> error template?

Defining a new edit-action.

Ralf
--
Dr. Ralf Schlatterbeck                  Tel:   +43/2243/26465-16
Open Source Consulting                  www:   http://www.runtux.com
Reichergasse 131, A-3411 Weidling       email: [hidden email]

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Roundup-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/roundup-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to choose a template on submission error

Ralf Schlatterbeck-3
On Mon, Feb 06, 2017 at 10:51:19AM +0100, Ralf Schlatterbeck wrote:
>
> I think you have to set the form that is reloaded after submission as
> the batch template again. Otherwise the error redirect won't work.
>
> I recently did this in a project where my edit form also had a different
> namen (not item) and found out how to return to the correct page, I'll
> have a look how I did this.

Ok I've looked into this you simply set a hidden variable named
@template to the value of your template name, this is normally set to
'issue' and in your case probably should be set to 'batch'.

--
Dr. Ralf Schlatterbeck                  Tel:   +43/2243/26465-16
Open Source Consulting                  www:   http://www.runtux.com
Reichergasse 131, A-3411 Weidling       email: [hidden email]

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Roundup-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/roundup-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to choose a template on submission error

John P. Rouillard
In reply to this post by Ralf Schlatterbeck-3

Hi Ralf:

In message <[hidden email]>,
Ralf Schlatterbeck writes:

>On Sun, Feb 05, 2017 at 02:08:37PM -0500, John P. Rouillard wrote:
>> I have implemented a form of
>>
>>   http://roundup-tracker.org/cgi-bin/moin.cgi/ProjectManagerBatchEditing
>>
>> in my tracker. If I display a search (index) using the batch
>> template I get an index page where the table is inside a form and
>> (almost) every item in the table is editable.
>>
>> When the form is submitted, my code returns to the index template
>> displaying the same issues that were editable in the batch
>> template.
>
>I think you have to set the form that is reloaded after submission as
>the batch template again. Otherwise the error redirect won't work.

Yeah that's what it looks like. I would really like this particular
workflow to be modal however. I want both "save and continue" and
"save" workflows (still have to work out how that will work).

If I set @template=batch, when an error occurs, I get all the
values preserved, so thanks for your work on that.  I do loose the
indication that the fields were changed, but that nicety is done by
javascript so I don't expect it to survive reloads.

>I recently did this in a project where my edit form also had a different
>namen (not item) and found out how to return to the correct page, I'll
>have a look how I did this.

Probably set @template.

>That said: You can probably define a new action that does almost the
>same as the normal edit action but redirects to some other page in case
>of success.

Hmm, yeah that could work. I create a BatchEdit action and call the
underlying EditItemAction.handle(self) action. Then I guess I can
do something like:

  class BatchEdit(EditItemAction):
       def handle(self):
          EditItemAction.handle(self)
          if self.client._error_message:
             self.client.template = batch

Does that look sane?

>> When there is an error, I want the page to use the batch
>> template. Given some recent changes to the roundup core code, I
>> think rebuilding the batch edit page should preserve all of the
>> user's changes and then they can fix them and submit the page
>> again.
>>
>> Is there any native support (e.g. @errortemplate) for specifying a
>> template that should be used if the back end discovers an error in
>> the submission?
>
>I think there is a mechanism of generally returning to the correct form

By "correct" you mean the same form used for submitting the edit.

>after editing (if successful or not), see above. I don't think we
>currently support different forms for sucessful and unsuccessful submit.

Yeah that's what I am seeing.

However if the change is as simple as it seems above, would you oppose
changing the default edit code to support ok and error templates?

Maybe by setting @template=oktemplate|errortemplate in the html
code. So the code would look like:

  if (self.client.template.find('|') != -1 ):
     if self.client._error_message:
        self.client.template = self.client.template.split(
                   self.client.template, "|", 2)[1]
     else:      
        self.client.template = self.client.template.split(
           self.client.template, "|", 2)[0]

Overloading template would be easier to code, but would adding a new
special variable (e.g.  @errortemplate) be a better way to go?

The reason I am considering this is because any modal workflow would
need this feature otherwise data would get lost on an error.

I could just add something like the following to the core though:

  class ModalEdit(EditItemAction):
       def handle(self):
          EditItemAction.handle(self)
          if (self.client.template.find('|') != -1 ):
       if self.client._error_message:
                 self.client.template = self.client.template.split(
                   self.client.template, "|", 2)[1]
              else:      
                 self.client.template = self.client.template.split(
               self.client.template, "|", 2)[0]

and define a new "modaledit" action alongside the edit action. This
would allow you to select an "edit" link. Go into edit mode and then
if the save is successful you go back to read mode. If the save was
unsuccessful you would stay in edit mode.

Thoughts?

--
                                -- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Roundup-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/roundup-devel
Loading...