This is somewhat related to http://drupal.org/node/117381 (adding time fields to issues), but it deals with adding due dates.
We are using project and project_issue for internal issue tracking, and it's been working great. One of the requests we had was for due dates, so I decided to test out how date + calendar could handle it. I installed both modules (and their dependencies) and added a date field to issue nodes. Then I enabled the calendar, adjusting it to use the due date instead of the date created.
While the date field worked fine in the add and edit screens for the issue, it didn't show up in the follow up screen, requiring users to edit the issue for some data and follow up for others. This is something that our account people would have freaked out about, so I decided to see what it would take to get CCK fields into that form.
I started with a form alter module, but found there was really no way to handle the CCK fields. Intead I rolled up this small patch that adds the CCK fields to the form in issue.inc's project_issue_form() and saves the CCK field in comment.inc's project_comment_save(). So far, this works great. I figured I'd post this patch for review. Not sure if it is something that should be in the module or not, but someone might find it useful.
Note that currently this has not been extensively tested with all the options between project_issue and cck. Here are some things to watch for:
- Minimal testing with more than one CCK field.
- The CCK fields show up on page one of the form (when no projects is selected).
- Required CCK fields will probably break the multi-page form and need to have their required status removed on page one, then added again in the pre_render function.
- Changing a CCK field is not accounted for in the validation, so you get the "You must either specify a description or change something" message if you only change the CCK field. At some point, the patch should add an additional check in project_issue_comment_validate() inside the "make sure this followup changes something" check.
If anyone sees anything that is wrong, please let me know. if this is something that is useful for project_issue as a whole, then cool. Otherwise, maybe someone else out there might find it useful.
Thanks again for the great module!
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | project_issue_cck_v3.patch | 2.2 KB | dww |
| #8 | project_issue_cck_v2.patch | 2.11 KB | seanbfuller |
| project_issue_cck_v1.patch | 2.36 KB | seanbfuller |
Comments
Comment #1
dwwcan you re-roll this with "-up" as diff arguments? -p adds function context to the patch, making it easier for me to see what's going on without having to apply it. also, there are some whitespace problems in there. see http://drupal.org/patch for more.
i'm still not quite sure why form_alter() isn't enough for you. i'd rather fix this problem by those means, if at all possible. i know that issue follow-ups are very weird FAPI mojo, and that something evil might be going wrong that's causing the trouble. but, if anything, i'd rather try to fix that instead of putting this code directly into project_issue. also, i suspect you'd have an easier time once followups were real comments... see http://drupal.org/node/18920 for more on that.
Comment #2
seanbfuller commentedSorry about the missing -p in the patch. I wasn't aware that -up this was the preferred switch. Thanks for pointing that out. I'm using PHPEclipse and as far as I can tell there is no -p option. I'll have to adjust my procedure for creating patches.
Hook form_alter did a good job of adding the CCK elements in the follow up form, but then I found that there was no way to save the CCK data. In the current code for Beta2, the function project_comment_save() copies each element of issue information from the edit object into the node object, then passes that to node_save. The extra CCK data doesn't get copied from $edit to $node, so that's where I found I had to alter the code.
Looking at the code from http://drupal.org/node/74995, it seems like the $arg parameter should contain the CCK data?
From there, it looks like project_issue_update() gets called. This is different form the code I was looking at, because you won't go through node_save(), meaning you won't invoke hook_update(). This will result in the CCK data never getting to content.module. (This may also mean you loose out on other nodeapi update calls as well, but I'm not sure.) Not having invested too much time in the code, it looks like if you want to support CCK in the follow-up form, you'll want to either go back to node_save, or add some CCK handling code in the function project_issue_comment().
Then the only other thing to watch for is the call to _content_widget_invoke('process form values', $node); I found I had to include this call because the node_save() call doesn't invoke submit, so the CCK data for date wasn't ready to be saved.
Hope that helps. I understand if you are hesitant to add CCK handling code in there, but it does seem like it should be a pretty easy add for a lot of bang, and won't affect functionality if CCK isn't enabled. Someone with more experience in CCK might have more to add.
Thanks again!
Comment #3
seanbfuller commentedI've run into another issue where the CCK cache information gets set with the CCK field being null when inserting an issue. This is happening in the project_issue node form, not the follow up form. This appears to be independent of this issue, but I thought I'd mention it here just in case. I've created an issue over on CCK, but because other node types work fine, I'm wondering if there could be something different in the node work flow that might be causing this.
The issue can be found here: http://drupal.org/node/137435
Comment #4
seanbfuller commentedI've updated the issue above with some information that I've found in regards to the due dates not saving when creating a new issue. It seems that the issue is the call to node_load() in project_mail_notify().
Here's the quick for reference: http://drupal.org/node/137435#comment-236528
@dww, please let me know what you think. I realize that this is a low priority right now, so let me know what I can do to help. Thanks!
Comment #5
dwwsean, thanks for keeping this moving...
this final point doesn't have to hold up this patch. but if we're going to commit changes to allow CCK fields on issues that can be modified via comments (which i absolutely support), we should go the whole mile, so users can see those changes via the default project_issue UI. those UI elements are the only way people can track the history of these values by looking at the trail of issue follow-ups, which is a critical feature for project_issue to provide. otherwise, someone might follow-up and change something, but no one would know that (unless they also mentioned it in the text of their reply). this is also related to the validation problem you mention in your original post.
in fact, see http://drupal.org/node/140473 ;)
thanks again for working on this... CCK-ifying issues is definitely a killer feature, and something i'm very soon going to want for other sites beyond drupal.org that i'm working on. one of my next major project* development efforts will be views-enabling project_issue, which fits right into this...
cheers,
-derek
Comment #6
seanbfuller commentedSounds good.
Just as an aside, I didn't create that patch against head, so that's probably the problem. My bad. (It was more an exploration of the problem at that point, and I was trying to keep from confusing myself by mixing the new code.)
I didn't re-read this last comment before posting my other issue: http://drupal.org/node/140940
This is a feature request to pass the $body of the emails through the theme. If we take the approach you outlined, then this is not needed for CCK fields, but this still might be a nice feature that is easy to implement.
As for not holding the patch up, I've got it working enough for my purposes now, so we might as well do it right, I supposed. The comments in http://drupal.org/node/140473 seem to be the right way to go.
Additionally, I also have need of project issue data in views, so I'm willing to lend a hand there. This is off topic, but here are the things I'm hoping it will let me do:
Again, off topic, but fun. Let me know where you will be pursuing this and I'll do whatever I can to help.
Comment #7
dww- the issue for views support for project_issue.module is here: http://drupal.org/node/76725
- i just added another comment (with potentially more complication) to http://drupal.org/node/140473
i'll probably be working on #76725 in the *very* near future for some sites at my day job. there's not much to it, i just have to sit down and crank it out (and i'm very familiar with this process after views-enabling signup.module). once there's a patch, i'd very much appreciate your review and testing. if you want to help with #140473, that needs more thought and discussion before the patch can be generated, so that'd be useful, too.
thanks,
-derek
Comment #8
seanbfuller commentedHere's a cleaned up version of this patch against HEAD. If you still see problems, just yell at me and I'll redo it.
It seems that http://drupal.org/node/140473 might be the place to handle the viewing of the og and cck differences, so I didn't try to take a crack at that part.
Comment #9
dwwalmost there. ;) you've still got some tabs, not spaces...
Comment #10
dwwlike so.
Comment #11
seanbfuller commentedDoh! Sorry about that.
Code seems pretty good to me, but someone else might want to weigh in. The only thing I wasn't 100% sure about where I placed the cck fields in the logic of project_issue_form. I think I got it right, but that was the only spot where I wasn't 100%.
Comment #12
skor commentedApplied #10 to project_issue-5.x-0.x-dev (from 05/15/2007).
All seems well with 2 CCK fields. Nice work.
Comment #13
dwwcommitted to HEAD. thanks, folks.
Comment #14
(not verified) commentedComment #15
dwwBump: this introduced a bug. See http://drupal.org/node/167838.
Comment #16
dww#167838 is now fixed, forget it. ;)