Problem/Motivation
Make a smoother workflow for adding and editing issue summaries by allowing the user to insert the issue summary template.
Proposed resolution
Provide a button through dreditor for prepend the template from http://drupal.org/node/1155816 into the Issue node body. See image:

A patch to add this button is available in #51 . To test, save dreditor locally (right-click/save as), apply the patch, and then open the patched copy in your browser. The patch has been tested in both Chrome and Firefox.
Remaining tasks
- Revised patch in #51 needs review.
- Some users may wish to automatically insert the template on node creation, so dreditor could provide that option as well.
- The fetched page is not cached. A cache is done through #1115636: Issue Macros and Templates
User interface changes
An "Insert template" button appears next to the "Description" label on node add and edit forms, including in the issue summary inline editor. Clicking this button inserts the issue summary headers at the top of the issue summary body field.
On node edit forms, the final "original report" header automatically includes the original poster's name and profile link.
On node add forms, the "original report" header is omitted.
| Comment | File | Size | Author |
|---|---|---|---|
| #73 | Screen Shot 2013-08-11 at 12.58.47 AM.png | 37.74 KB | markhalliwell |
| #73 | Screen Shot 2013-08-11 at 1.41.49 AM.png | 51.97 KB | markhalliwell |
| #73 | interdiff.txt | 6.94 KB | markhalliwell |
| #88 | dreditor-button-to-prepend-1277974-88.patch | 3.96 KB | cweagans |
| #88 | interdiff.txt | 2.35 KB | cweagans |
Comments
Comment #1
clemens.tolboomThe patch does two things
1. Inject the template for new Issues
2. Add button to append to existing issues.
Comment #2
clemens.tolboomPlease review the patch and try to make it better on the points mentioned below:
Do we want this auto inject for New Issues?
Can we configure this behaviour through dreditor config somehow?
The button comes below the label which is not nice. How do this better?
Comment #3
clemens.tolboomIt misses the close h3
Comment #3.0
clemens.tolboomUsed the patch to see it in action.
Comment #4
clemens.tolboomFixed #3
Open issues from #4
- auto-inject for new issues: yes or no?
- button for existing issue edit is located ugly. [edit]Use dreditor-button class and wrap with span[/edit]
Others
- there is no cache ... implemented in #1115636: Issue Macros and Templates
- do we have to display an error if the GET fails?
Comment #5
clemens.tolboomI misused the .text(). Now use .val(). This caused weird errs in both FF and Chrome.
Changed to dreditor-button class.
Open issues:
- auto inject for node/add issue.
- there is no cache used for the template
Comment #5.0
clemens.tolboomAdded XREF to template
Comment #6
clemens.tolboomIt is a little annoying indeed to have the template on every _new_ issue. On the other hand deleting is easy.
Adding a template to an existing issue should be placed _before_ the existing text. That makes it easy to remain the original text.
See the current version in action on http://drupal.org/sandbox/clemenstolboom/1125712
Comment #6.0
clemens.tolboomRemoved remaining task 'white lines'
Comment #7
clemens.tolboomI changed append to prepend with is a little smoother workflow.
Comment #7.0
clemens.tolboomUpdated issue summary.
Comment #8
helmo commented* The summary-original-report section is not relevant when creating a new issue.
* I don't really like that the template is automatically added for new issues.
--
just my 2 cents
Comment #9
clemens.tolboomThere is just one template available for the issue summary. I don't want to fiddle with that.
There should be an option the disable the insertion automatic. I'll work on that.
Comment #10
xjmOkay I totally didn't find this issue and hacked it up myself, but here's my version of this functionality. It's probably kinda gross (rather than looking up the template, I just stuck it in an escaped string of barf), but worth a look for comparison? It scrapes for the original poster's username and automatically inserts a profile link; kinda nice.
I don't bother inserting the template in new issues. You can create an issue with a blank body and then just click the edit link. Alternately, could just add the button on the node add form as well.
Comment #11
xjmComment #12
xjmI'll work on incorporating @clemens.tolboom's functionality into my patch, plus adding buttons to the normal add/edit pages, without the final header on add pages.
I think this functionality is pretty important. I started to write up a slideshow about contributing summaries today and realized the current workflow is actually stupid-complicated. I'd rather be able to say "install dreditor." :)
Comment #13
xjmMuch nicer patch parsing from the actual document as in @clemens.tolboom's version. Try it out! The button adds the "original report by" header with a link to the original poster on edit, but on add, it just inputs the other headers. It doesn't do it automatically.
It also doesn't insert the notes in parentheses. If you're using dreditor, you are experienced enough to read the doc or figure it out on your own. :)
I did notice the GET requests are kinda slow sometimes. We might want to cache the template markup somehow. For now, though, I think this is a whole lot better. :)
Edit: aside from the hunk of trailing whitespace. sorry. I'll fix that.
Comment #14
xjmW/o gross whitespace.
Comment #15
xjmIt occurs to me a couple inline comments explaining what's going on here might be helpful, but I'll wait to see what others say about the patch as a whole. :)
how i can computer? why is blue? views? modules? wtf?
Comment #16
xjmWith reasonable code documentation.
Comment #16.0
xjmChanged the injection to prepend instead of append.
Added XRef to sandbox and quick install.
Comment #16.1
xjm(xjm) Described status with current patch in #16.
Comment #17
clemens.tolboom@xjm Darns ... sorry.
I'll update the issue summary ... I have a dreditor sandbox for this :(
http://drupal.org/sandbox/clemenstolboom/1125712
I like your add_form _with argument
Comment #17.0
clemens.tolboomUpdated issue summary.
Comment #17.1
clemens.tolboomUpdated issue summary.
Comment #17.2
xjmUpdated issue summary.
Comment #18
xjmI looked; I don't see my patch in your sandbox? And I'd checked earlier and the last commit was back before your remark in #9. So I added that note to the summary as well... please clarify.
Please give the patch a try; it's fully functional. :)
Comment #19
xjmMmm, just touching up funky indentation. (I think? jQuery indentation gives me brain freeze, and it's not even yummy like ice cream.)
Comment #19.0
xjm#16 is not in the sandbox?
Comment #20
clemens.tolboomThese comments helps me to know what to do.
I don't want to remove these.
I left out the add/edit flag ... when there is no text it's a new issue right?
Committed to my sandbox
Comment #21
clemens.tolboomPatch from sandbox
http://drupalcode.org/sandbox/clemenstolboom/1125712.git/commit/5e596f86...
Comment #22
clemens.tolboom@xjm: your insertion of the user name is very nice :-)
What now remains is the checkbox for not always inject on new issues as requested by helmo. Or did I missed something from you patch (which I applied by hand ... sorry for that)
Comment #23
clemens.tolboomAnd we should add a link to the template page for more instructions I guess.
Comment #23.0
xjmUpdated issue summary.
Comment #24
xjm#22 / #23 -- I removed the feature to automatically insert on new node creation because people above stated that it was annoying, and I'd agree with them; and it takes no additional effort to just click the button. Also, I disagree entirely about the parenthetical instructions, for two reasons:
I guess I did not mean this as a patch against your sandbox, which I gather is something of a feature fork of dreditor; I meant it for inclusion in the main script.
I do think adding a link to the template after the button is a good idea and I will reroll #19 to that end.
Comment #25
xjmPlease test against the main branch of dreditor. Let's wait for a third opinion on whether or not the parenthetical lines are included, etc.
Comment #26
clemens.tolboomPlease reroll against #21 (I'm not doing this for fun ;-)
Comment #27
clemens.tolboomSee #26 for needs work.
Patch #21 is against dreditor master branch :-)
I do agree with removing the the comments when we have the link available.
Comment #28
xjmBut #21 is missing all my comment cleanup and my change to the once() behavior? My patch was already based on your earlier patch.
Edit: I really don't understand; my patch applies cleanly, and is essentially the same thing as #21 but refined. It works without a hitch in my testing and it's easy to read and follow.
What is needs work here? What is not correct about the patch? Do you have any specific patch review? Did you test it?
Comment #29
clemens.tolboom@xjm ... rerolling not against the lastest patch #21 is imho rude. I tried to add your parts from #19 to my work and review #20 so expected the same from you :(
I set status to needs review as your additions are great.
Comment #30
xjmI'm very sorry; I don't intend to be rude... what I don't understand is that #21 discarded all the changes I'd made in #13 through #19, without any explanation as to why they were discarded. I'm not sure how that's different? Like I said, I already started from your patch earlier in the issue.
Comment #31
xjmHad a possible insight a moment ago... Are you just asking for this?
Edit: If you want, I can explain each "change" as well (though all except the insert template link are changes that you discarded from #21). Like I said in the message I left in IRC, I think we're just not quite communicating. Please just explain what you are asking for. :)
Comment #32
clemens.tolboomI like the link to the summary
Comment #33
clemens.tolboomWe could replace this argument by just testing for emptyness of the issue body right?
Or change the name to a boolean isNew
Comment #33.0
clemens.tolboomUpdated issue summary.
Comment #34
xjmHm, well, the issue body could be empty when you are updating it, or could already have things in it when it is new, but we still don't want it to try to load the node page if it doesn't exist yet. So I think the boolean option is better.
Comment #35
xjmThough, I wonder if maybe we should just check the current URL for
node/add/project-issue. It might also be cleaner to parse the issue link from the URL rather than looking for the view tab.Comment #36
xjmAttached patch simply checks the URL for whether we are adding or editing and for the link to the node page. I think this is more robust than relying on the DOM, and probably more performant as well. The code is also a lot simpler.
Comment #37
xjmComment #37.0
xjmUpdated issue summary.
Comment #37.1
xjmUpdated issue summary.
Comment #38
xjmMmm, the image filter is not liking the screeshot for me, so here it is again.
Comment #38.0
xjmAdding screenshot.
Comment #38.1
xjmUpdated issue summary.
Comment #39
amateescu commentedI tried out the patched Dreditor and it works as advertised, in the summary Edit popup and also in node add/edit forms. Great work :)
Unrelated: the Edit popup could use a close button!
Comment #40
cweagansPatched code works as advertised.
Code looks solid (though it'll need to be updated quickly if the issue summary template page ever gets reorganized or something - it might be better to edit that page and add a really unique class name to the code block and find it based on the class).
I'd say that's probably of minimal concern though. I'd also say RTBC :)
Comment #40.0
cweagansUpdated issue summary.
Comment #41
sun1) dreditorIssueSummaryTemplate
2) [and elsewhere] There should be a space after function and before the opening parenthesis for anonymous functions to make clear that it's not a function with the name function.
It's not clear to me why we need to reload the node view page.
Abstraction into private/locally defined anonymous functions like this doesn't really make sense. They are not callable from elsewhere. And since they don't take any arguments, they also don't really provide atomic functionality. At minimum, they should take context as an argument; but to make any sense as separate functions, they should take explicit arguments to act on and also possibly return something useful.
In this current form, these functions are merely wrapping chunks of procedural code into code blocks without any purpose, which actually makes it harder to understand what's going on.
Either we turn them into real functions with proper arguments and possibly return values, or we drop them entirely. Personally, I'd rather go with the latter.
1) [and elsewhere] Variables that are jQuery objects should have a $ prefix; i.e., $link in this case. All other variables without; e.g., $new_link in this case.
2) For the link text, we want to use .html() instead of .text(), because we are inserting the value back into a HTML document.
3) [and elsewhere] The variable names could be a bit more self-descriptive than "link" and "new_link".
4) [and elsewhere] In JavaScript, we use camelCase variable names.
I wonder whether we can prevent jQuery from sending cookies, so we get the cached version of that page?
Would it be possible to have an already prepared issue summary template for pasting on that handbook page or a child page of it?
This is going to clash with the commit message button, no?
Single quotes.
Wondering whether this is really needed? Thought there were generic CSS classes for aligning Dreditor buttons... but not sure.
It's not clear to me why we're adding this link to the instructions... doesn't that exist already?
1) I think we can simply define the attributes and link text in the HTML string instead of working on the object.
2) target=_blank might make sense, as we don't want to lose potentially existing input.
Comment #42
xjmYay, thanks for the review! Couple followups to #41:
This was to scrape the username and profile link for the original poster. This information isn't available on the node edit tab that I could see. Is there a better way to get it?
This is a good point; I'll look into this.
I don't think so? I'm running my patched version currently, and both the template button and the commit message button seem to work fine. Also, one is on the comment form, whereas the other is on the node edit form.
I was wondering that as well. I'll try removing it and see if anything breaks.
It's only available on the normal node edit page (and not in the inline editor). It's also kind of hard to see on the normal node add/edit page; we are moving it to a more obvious/intuitive spot. See screenshot:

I'll reroll the patch with the other cleanups from #41.
Comment #43
sunIIRC, the dreditorIssueSummary "inline editor" behavior explicitly hides the dsm() that contains the link to the issue summary instructions. We might want to reconsider that.
Comment #44
xjmHere is what the node edit tab looks like. The links indicated by red arrows are to the same page:
I don't think we want the whole huge blue box on the inline editor. On the other hand, would it be better to clone the existing link? We're hardcoding the path anyway to fetch the template. I do think the text change to "Issue summary standards" makes more sense here, since the document includes more than just the template itself and it's right next tot the template button.
Comment #45
xjmFor comparison, the inline editor with the current patch:

Comment #46
xjmI created http://drupal.org/node/1326662.
Comment #47
xjmAlright, I think I've got all the feedback from #41 covered here. Attached:
target="_blank".Comment #48
xjmEr. Ignore that last patch; it's against a previous commit rather than the main branch. This one. :)
Comment #49
clemens.tolboomPlease make note of #1287934: The book pages need a prefix to distinguise them from eg the real project. where jhodson want to distinguish user pages versus machine readable d.o pages.
Comment #50
xjm#49: Well, the page is also useful for people not using dreditor who don't want to have to remove the comments each time, so it is human-readable.
I changed the markup of the page to be less ugly. However, at some point in cleaning up the code, I broke the user name insertion. Debugging that now.
Comment #51
xjmAh, this was not actually the case (the link markup is being inserted into the input field).
Attached reverts that change so the link markup is inserted and uses the corrected template markup.
I did a bit of reading to see if it were possible to have
$.get()not send cookies, but the only suggestions I found were server-side solutions. I don't know much about it, though.Comment #52
xjmComment #52.0
xjmRemoved sandbox ref as I cannot follow the speed this patch goes :-) by clemens.tolboom
Comment #53
xjmtim.plunkett reviewed this for me in IRC. The indentation here is off, and this could probably all be chained in one go.
Revised edit: The patch has a bug with a variable that was not renamed properly, and furthermore has an issue due to the refactoring where the [username] token does not get replaced because the GET request finishes too late. Looking into this.
Comment #54
xjmAlso checking to see if it would be better to use
.load().Comment #55
xjmAttached resolves the issues described in #53 and also refactors a little to remove more superfluous variable declarations. I also got rid of the extra markup and
and am just adding a small margin to the button instead. I did check through the dreditor styles available but there didn't seem to be one that fit.Comment #56
das-peter commentedReview of #55:
patch applies, button shows up (Win 7, FF 7), and template is inserted.
Further to me the code looks nice - chaining used, just a few new variables and docs all over the place :)
Comment #57
amateescu commentedSame review as #56 (Win 7, FF 7) and everything looks good, from functionality to code style.
Comment #58
xjmUpdated http://drupal.org/node/1326662 with some suggestions from sun; rolling the changes into a new patch now.
Comment #59
xjm#112805: JSON menu callback for project issues would significantly reduce the overhead of this functionality.
Comment #60
xjmAttached uses the new template.
Once #112805: JSON menu callback for project issues is fixed, I think it would be best to add the issue JSON data to Drupal.dreditor generally. Then we can fix this feature to use that data instead.
Comment #61
clemens.tolboomBetter add a .first() here? Like $(data).find('div#summary-template > div > code').first().text()
This fallback is never happening as the $.get has no failure flow.
Comment #62
xjmAre you sure that isn't just adding overhead? There won't be multiple instances of this.
Eh? This text will be used if the original node cannot be found by matching the path. See:
Comment #63
clemens.tolboomYes it is overhead when using .first() ... but it's a better 'statement' ... give me the first code block. It's np to me when not added.
For the happy flow part. I expected something
According to http://api.jquery.com/jQuery.get/ there is no error flow for $.get so you should either use http://api.jquery.com/jQuery.ajax/ with an error callback or rephrase the documentation into 'Only replace when succesful'. This
fallback is not in the code flow.
Failure on nodePath has no replace action
Failed on $.get has no replace action
This replace is only executed when the nodePath is found and $.get successful.
Comment #64
clemens.tolboomThis could use some love again :)
Comment #65
xjmI don't know how to address the reviews above (which is why I gave up on this and instead just used my patch locally), so if you or anyone who groks JS better wants to fix it that would be awesome. :)
Comment #66
yesct commented#1803622: Add a create follow-up issue link which fills in values (clone an issue) just a little related.
This issue could use some love.
Comment #67
markhalliwellOk the button at least works now. I didn't dig in too deep, so let me know what else needs to get worked on or if this is RTBC.
Comment #68
yesct commentedI tried this, it's really neat.
but it has two lines trying to get who has posted the original description.
---
the instructions link opens in another window superly to https://drupal.org/node/1155816
I wonder if we want to use https://drupal.org/issue-summaries though
Comment #69
star-szrWorking on this a bit to see if I can improve it.
Comment #70
star-szrUpdated based on feedback and review from @YesCT!
<a href="undefined"></a>- I used https://drupal.org/node/1797364 for testing before and after.Comment #71
star-szrTested in Chrome 28 and Firefox 23:
Comment #72
markhalliwellOk. I refactored a lot of this code to utilize jQuery DOM manipulation and targeting tag IDs instead of raw strings. This will allow more flexiblility if the template gets updated in the future. I also added a warning on the bare issue summary template's edit page to inform anyone (that has dreditor) that a new issue window will appear so a proper review can be done. I'll attach screenshots shortly
Comment #73
markhalliwellHere's the interdiff between #70 -> #72. Guess it eaten by the diff monster :-/
edit: removed images since this implementation wasn't committed.
Comment #74
star-szrFirst of all, you made this much faster @Mark Carver! Very nice. When I was testing #70 it took several seconds to fill in and even longer to fetch the username. I reviewed and tested the patch (other than the automatic new issue thing), here are some comments:
Should the warning on editing the template be in a different behavior?
This won't always work (most people won't be able to assign to you) but that's probably okay?
Alignment of the inline comment is a bit off and if they are staying in the same behaviour there should be a blank line between the two sections IMO.
Neither of these handle the case of issues posted by Anonymous, leading to some different cases.
For quick edit, we get this (which is probably fine):
<h3 id="summary-original-report">Original report by </h3>For node edit, we get this (it actually tries to link to Anonymous!):
<h3 id="summary-original-report">Original report by <a href="https://drupal.org/user/1504084">@</a></h3>Alignment on the closing curly brace (second last line in the code sample) looks off, but I could be wrong.
JSHint was not happy with these lines:
"Confusing use of '!'"
And definitely a nitpick but I think it'd be nice not to rely on dgo.to to link to the Dreditor project, just link directly to the project page.
Comment #75
star-szrHmm, maybe d.o or my machine was just being slower last night, not noticing a big difference between #70 and #72 today as far as speed. Still fast though :)
Comment #76
markhalliwellAddressed the concerns in #74:
Drupal.behaviors.dreditorIssueSummarybehavior. They both pertain to the Issue Summary. I went ahead and moved the warning portion to the bottom of the behavior though since it is really just an extra "gate" mechanism to notify us of changes to the template.<a href="#">@username</a>with<a href="#">Anonymous</a>//drupal.org.Comment #77
markhalliwellSigh... here's the interdiff for #72 -> #76 (not sure why my drush_iq isn't auto generating one, maybe because it's on a "master" branch and not a Drupal specific one).
Comment #78
markhalliwellFixed preventing default event per jQuery coding standards (https://drupal.org/node/1720586#event-delegation)
Comment #79
markhalliwellFixed issue with author not being set properly on node edit pages
Comment #80
markhalliwellImproved better detection of various different types of anon users
Comment #81
markhalliwellRemoved warning, I would rather lock down that page if possible so it is only editable by certain people (with a note saying who people should contact).
Comment #82
star-szrGave the latest patch a test and it seems to be working well, found some very minor touch-ups with the code, leaving at CNR so we can get more manual testing.
Need spacing here per https://drupal.org/node/172169#functions.
function (data) {
function (json) {
Double-check indents lining up here please.
Closing indent looks off.
Comment #83
star-szrIt sounds like #82.3 was pretty much the same as #74.5, so don't mind me. I'll get used to reviewing JavaScript eventually :)
Edit: although a blank line in between might help make it clearer :)
Comment #84
jenlamptonzomg, #81 is going to change my world. No more chrome autocomplete on the word "bare"
RTBC from me :)
Comment #85
cweagansI'd like to take a quick look at this before commit, please :)
Comment #86
markhalliwellAddressed issues in #82
Comment #87
markhalliwellFeel free to take a look. Cottser and I have made significant progress on this issue and would like to commit this soon. We have had many reviews and are simply going through some minor coding standards nitpicks now. I doubt we'll have any major changes to actual functionality or logic used here.
edit: a lot of which we've already discussed in the #dreditor irc channel
Comment #88
cweagansI realize the issue summary says caching will be handled elsewhere, but I think it's important to implement it here. There's already a localstorage wrapper in dreditor, so I've just used that. There's no way to modify the Cookie header in an XMLHttpRequest (at least, not in the browser context), so there's no possibility of retrieving the cached version of this page from Drupal.org. This implementation only adds a bit of code, and avoids hammering Drupal.org for something that's easily cached.
interdiff against 86
Comment #89
cweagans(and for the browsers where localStorage is not supported, nothing will happen - we'll just grab the markup from d.o as normal)
Comment #90
markhalliwellThis creates the function after it's called (see the else code block, which isn't asynchronous). It also doesn't timestamp difference these at all, so this would always be cached and the user would never get an updated version if the template were to change.
In all reality and TBCH, I'd really like to make this a whole separate issue. I'm not saying this isn't needed, but it certainly deserves it's own special attention.
FWIW, caching in Dreditor needs to be something more of a "service" so we have better handling of things like this in general (which certainly falls out of the scope of this issue) and before you say "if we don't put it in, then it'll hammer drupal.org" again, everyone already does this... just manually so they can copy and paste it.
Like I said, @Cottser and I have already discussed a lot of this kind of stuff in #dreditor. I suggest following this issue too (which is kinda short ATM) #2061841: [META] Overhaul/New Version
Comment #91
yesct commented#86 manually tested on contrib and core. that looks ready to go. Lets make a new issue for caching.
I gave a quick read through the code and nothing standards wise jumped out at me.
Comment #92
markhalliwellThanks @YesCT! Committed d210e57
Great job everyone! I went ahead and created #2063851: Implement a better service for caching data with expirations as a follow-up.
Comment #93.0
(not verified) commentedUpdated issue summary.