Not logged in. · Lost password · Register
Forum: General Help and Support Plugins RSS
Actions based upon Dependencies in Bureaucracy?
Avatar
jkuroda #1
Member since Sep 2011 · 1 post
Group memberships: Members
Show profile · Link to this post
Subject: Actions based upon Dependencies in Bureaucracy?
I'm trying to put together a form to collect PDF files from people along with some metadata (title, authors, night of their presentation, etc) to put into a table and to let people upload updated versions of those PDFs later on.

I thought I'd use the Bureaucracy plugin's Fieldset Dependencies feature to:

  • Only collect metadata and create table entries via pagemod for new submissions
  • Omit metadata collection and table entry addition when just uploading an update PDF file

So far, I'm able to get the following to work:

  • New submissions that require metadata collection and table entry addition work as expected
  • Uploading updated versions of previously uploaded files works (after some work) [0]

But, when just uploading an updated file, the pagemod actions still get triggered which cause entries like these to show up in the table when what I want is no new table entry, just to upload a new version of the already uploaded PDF file

| {{events:event:pdfs:jkuroda.pdf|@@Poster Title@@}} | Jon Kuroda | @@Night@@ |  |

My wiki markup looks like this:

<sortable>
^ Title ^ Author(s) ^ Night ^ Notes ^
<pagemod table output_before>| {{events:event:pdfs:@@Filename@@|@@Title@@}} | @@Authors@@ | @@Night@@ | @@Notes|@@ |</pagemod>
</sortable>

<form>
fieldset  "Add or Update Your PDF"
select    "Adding or Updating" "Adding|Updating"

fieldset  "Add your PDF" "Adding or Updating" "Adding"
action    pagemod _self table
textbox   "Title"
textbox   "Authors" =@NAME@
select    "Night" "Wednesday|Thursday"
textbox   "Notes" !
action    template _ events:event:pdfs:@@Filename@@
file      "Filename" ..:

fieldset  "Update your poster" "Adding or Updating" "Updating"
action    template _ events:event:pdfs:@@Filename@@
file      "Filename" ..:

fieldset  ""
submit
</form>

Or in pseudocode:

if adding a new PDf
   collect metadata
   update table via pagemod
   upload PDf
else // just uploading new version of already uploaded PDF
   // do not collect metadata
   // do not update table via pagemod
   upload PDF // overwrite previously uploaded PDF

This generates a form that appears to behave as expected - it doesn't collect metadata if one selects "updating" - but the table still gets updated using default or placeholder template values. Do Bureaucracy actions in a form always trigger regardless of Fieldset Dependencies? I can do this with two forms - one for new submissions, one for updates, but that's super clunky; or I could figure out the Data or Struct plugins, but I don't have enough time for that for this particular event.

[0] Normally, Bureaucracy is hardcoded to not allow overwriting already uploaded files via forms created using the "file" fieldtype (processUploads() in helper/actiontemplate.php hardcodes media_save()'s $ow argument to false), but for this, I hardcoded it to true to allow media file overwriting.  I've got some code that breaks that out into a parameter that can be turned on via a new constraint to the file fieldtype that will enable file overwriting, but I need to clean it up before submitting it for an RFE.
This post was edited on 2018-05-17, 03:20 by jkuroda.
Avatar
florious #2
User title: Floarea
Member since Jun 2014 · 20 posts
Group memberships: Members
Show profile · Link to this post
I am interested to find a solution too. Did you found some workaround finally?
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-07-17, 12:47:14 (UTC +02:00)