Probably should wait until #1833684: Need a file widget that gracefully handles lots of hidden files is committed and pushed before working on this, but once we've got a widget, it'd be great if we could configure the columns in the widget table, just like you can in our display formatter table. In particular, I think it'd be useful to see the user that uploaded each file in the attachments table. However, I'd *love* to have an alter hook (could we invoke the same alter hooks as the formatter?) so that project_issue could inject the comment #, and PIFT could even inject testbot results.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jthorson’s picture

Items for consideration
- add author
- PIFT testing status
- timestamps
- 'obsoletes x, y, & z' logic

jthorson’s picture

Project: Attached Files Metadata Table » Extended File Field
dww’s picture

First step is #1964100: Refactor extended_file_field_field_formatter_view() structure so we can reuse a lot of the code.

I think this is going to end up being important for d.o UX. People are going to need to see more metadata about files while they're editing/updating an issue so they can know which files to hide, etc.

dww’s picture

Both #1833684: Need a file widget that gracefully handles lots of hidden files and #1964100: Refactor extended_file_field_field_formatter_view() structure are both done, so this can proceed (assuming we all agree this is a useful UX enhancement to ease the pain of the transition to the D7 issue queue interface).

jthorson’s picture

Going to look at adding the author column while my drupal.org dev site rebuilds, just as a proof of concept for modifying the widget.

At first glance, it looks like adding the logic for this to extended_file_field_preprocess_file_widget_multiple() would work, but this logic would then need to be duplicated in extended_file_field_preprocess_extended_file_field_widget_multiple(). So as a first step, I suspect we need to have both of these redirect to a third (and common) function for the logic.

extended_file_field_modify_widget() perhaps?

dww’s picture

Shared function sounds necessary and good. In fact, those two functions are already almost duplicate with each other.

Not sure about calling it extended_file_field_modify_widget(), but I'm not sure what would be better. Part of me wanted to use "preprocess" in the name, since that's what we're doing, but that might open us up to namespace conflicts. Maybe extended_file_field_modify_widget_preprocess()? Doesn't really matter that much.

Anyway, yeah, knock yourself out. ;) Shouldn't this be assigned to you at this point?

Thanks,
-Derek

jthorson’s picture

Assigned: Unassigned » jthorson

Probably. :)

jthorson’s picture

FileSize
25.52 KB

Here's a work in progress ...

Summary:
- Re-uses the hook_extended_file_field_metadata_types alter() call, allowing 3rd party modules to add metadata types to the field settings select box (which appears in the widget instance settings form).
- New hook_extended_file_field_widget_item_alter() call added, so that modules can add metadata to each file item within the widget. Currently called individually for each item; but we should be able to refactor this into a single call for the entire widget.
- New custom #process callback extended_file_field_widget_process() added to each file element within the widget. Callback is responsible for hosting the alter() call as well as rendering the individual metadata column cells for each file in the widget.
- Now exclusively using the extended_file_field_widget_multiple theme call, so that we can insert additional columns in addition to the 'remove' button tweaks.

Issues:
The act of uploading a file breaks it horribly, due to the loss of per-file uid data in the ajax processing. Will dig into this on Saturday/Sunday.

jthorson’s picture

FileSize
10.05 KB

Forgot the patch. :)

dww’s picture

Cool, thanks! Sounds good so far (and I love the screenie). I won't do a thorough review of the code until you're happy with this.

+1 on consolidating hook_extended_file_field_widget_item_alter() into hook_extended_file_field_widget_items_alter().

One question to ponder: if we're going this far, should we just define our own widget (again)? ;) Might be kinder for admins to opt-in to all these advanced settings, probably better for performance not to trigger any of this code for fields that don't want it (e.g. less form_alter(), less hook invocations, etc), and might make the code cleaner, too. Definitely not a requirement, but seems like we're hitting the limits of what should sanely be altered into the core widget.

Thanks!
-Derek

jthorson’s picture

Status: Needs review » Active
Issue tags: -project
FileSize
15.7 KB

Wow ... that one sure beat me up for a while!

While the initial edit form was easy enough to build the functionality for, it appears that every time you click the 'Upload' button, core throws out your file objects and replaces them with just the minimum form values (filename, weight, description, and display). This works fine for core; but try exposing additional metadata, and suddenly file object values which were there for the initial load disappear in the middle of the AJAX refresh.

I went back and tried a few different approaches ... $element['#pre_render'] was a bust, as even though I could add the metadata I wanted, for some reason it gets stripped out before the theme call. '#value_callback' overrides looked promising, but led to the same dead end ... as did another attempt at '#process' overrides. In the end, I gave up on trying to force core to generate a single item with the metadata I wanted inside of $element['#value'], $element['#default_value'], or $element['#file'] ... and ended up creating a composite of the three. Once I got that working, the next challenge was stripping away all the cruft I had added during my experimentation, and getting back down to the minimum necessary code again.

Key changes from #8:
- Moved the '#process' addition to hook_field_element_info_alter(), instead of form_alter().
- Changed the widget form_alter() to a form_WIDGET_TYPE_alter().
- Removed the 'hide operations column' setting, opting to automatically hide it if it's empty. (After moving to the single theme function, the column doesn't appear even while empty ... and from a UX perspective, having the 'hide operations' setting appear when you *uncheck* the 'show remove' checkbox in the field ui settings form felt awkward.)
- General code cleanups.

I still want to try and sort out a way to consolidate the hook_extended_file_field_widget_item_alter() calls into a single alter(); but wanted to save the 'working' patch before I started messing around with it any more.

jthorson’s picture

Re-adding tag.

jthorson’s picture

Committing to 7.x-1.x to avoid generating commit conflicts next week ... will add the items_alter() as a followup.

http://drupalcode.org/project/extended_file_field.git/commit/13f501fa1b8...

jthorson’s picture

Status: Active » Fixed

Followup opened at http://drupal.org/node/1970322.

jthorson’s picture

Status: Fixed » Needs review

Hmmm ... Back to NR for any required review followups. :)

My motivation behind rushing this in was due to the amount of code that's been touched, and the fact that I'll be less less active during the week than other folks who could be working on this ... it doesn't look like there are any outstanding patches currently under way in the queue, and I'd like to avoid the potential need for rerolls on this or any new work generated in the next week.

dww’s picture

Status: Active » Fixed
Issue tags: +project

Sweet! Just did a thorough review and test. Mostly this was great (other than forgetting the issue nid in your commit message :P), but I pushed a follow-up with some cleanups, including a fix for a PHP notice I was seeing:

http://drupalcode.org/project/extended_file_field.git/commit/809fb0d

Thanks!
-Derek

jthorson’s picture

What? I'm sure I added it there ...

/me gives up on format-patch and goes back to git diff. ;)

klonos’s picture

"Show # hidden files" makes sense, but "Hide # hidden files" does not and in fact sounds really weird. I believe that it should be something like "Hide # obsolete files".

dww’s picture

At this point, I think all such minor wording tweaks to the UI should be handled holistically at #1545952: [META] UI for updating an issue in D7 or #1545922: [META] Issue page redesign, not here.

klonos’s picture

Yeah, sorry Derek, but I though that this was specific to this module and the widget it provides. Both issues you mention are specific to d.o (Project issue tracking actually) and its upgrade to D7. Extended File Field is meant to be used as a generic file upload widget though. Right?

Also, I thought that perhaps parts of #66484: Allow issues to be filed against multiple versions/branches. and #1171958: Allow files to be assigned to branch(es)/version(s) and thus tested against it could fit in this? I'm not saying that these should be handled by this module, but that we should help UI-wise (when uploading .patch files). We already added the hidden/visible functionality, perhaps we could also help this situation where people keep switching back and forth branches simply in order to trigger patch tests against the proper branch. It simply adds noise to the issue.

jthorson’s picture

I can understand the confusion, but the current wording makes sense when you consider the context of the file widget ... you are editing the node, and the files are "Hidden" when the node is displayed; even though they are visible in the widget display itself.

I hesitate to switch to 'obsolete' because it is also use-case specific ... the widget allows you to turn off display of certain files, but it also allows you to turn it back on. The 'hidden' state may be temporary, in which case the file itself may still be relevant instead of obsolete.

I pondered this while writing the module, and the next-best descriptor I could think of is 'non-displayed'; which is virtually equivalent to 'hidden' (but a lot more awkward in practice).

In any case, if you'd like to continue the discussion beyond this, can we do it in a new issue so that it's titled appropriately and easier to find 6 months down the road when the topic comes up again? Thanks! :)

dww’s picture

My point is that we're going to have a lot of UX experts looking at these details as part of a holistic review of the D7 issue UI. If they suggest changes to this wording (or anything else provided by this module), of course we'll fix it here.

I agree with everything jthorson said about why "obsolete" is the wrong word for a generic module like this, but I didn't want to discuss it any further here. ;)

Cheers,
-Derek

dww’s picture

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 809fb0d on 7.x-1.x, empty-file-2150029 by dww:
    [#1962930] by dww: Follow-up fixes to commit 13f501fa1
    
    - UI cleanup for...