[x] Feature request
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Documentation issue or request
https://redhat.invisionapp.com/share/VQ8UZ7PCE#/318752828_Template_Step_V3-1_9-6_3
@michael-coker @phantomjinx
cc: @syndesisio/uxd
@phantomjinx - is this something we hope to get in for 7.2? I'm asking because it's not required from the user story https://github.com/syndesisio/syndesis/issues/3047.
Do you have screenshots of what these validation errors may look like? How are they different from just the validation happening in the text editor?
@dongniwang
Screenshot of error as it appears in console log. It does actually do this now so you should be able to view it yourself. This is the full stacktrace while the error message is '_Error: Unclosed tag at 81_' (note. syndesis code prefixes the error with '_Failed to parse template_')

To your broader question, we should be able to get this in before the end of the sprint. A simple error message that appears underneath the editor box, updates on each keypress and disappears if parsing is fine should not be a problem, I think.
There is a slight wrinkle that may need looking at. A further parsing check is required; to explain:
Therefore, an extra parsing function needs to be included to enhance mustache's parsing.
@gaughan @michael-coker
Design decisions from follow-up meeting:
@dongniwang @michael-coker - review please.
Use CodeMirror's own DnD functionality for adding text from file. However, enhance it to retain an icon of the file upon drop;
If that's possible, sounds great. But I would be fine with the browser default behaviors for dragging a file. That would also match our current DnD UI in the integration importer and API client connector upload.
Retain the 'Drop file here to upload' message. Maybe gets displayed while user drags? (@michael-coker can you just clarify that?);
Yep, I can handle that by manipulating a class on the main element on the dragover, dragleave, and drop events.
@phantomjinx @michael-coker - looks good to me, thanks so much for capturing the decisions! I'll upload the design file to the UX design tracker as well.
@phantomjinx fyi, came across this, not sure if you've seen it - https://codemirror.net/demo/lint.html
that looks like a good way to show code errors.
On 02/10/18 22:09, Michael Coker wrote:
@phantomjinx https://github.com/phantomjinx fyi, came across this, not sure if you've seen it -
https://codemirror.net/demo/lint.htmlthat looks like a good way to show code errors.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/syndesisio/syndesis/issues/3662#issuecomment-426431298, or mute the thread
https://github.com/notifications/unsubscribe-auth/ABjvhAVLMyakecZaYxVde6ExJ_iv74KHks5ug9YNgaJpZM4W3UPx.
Hi Michael,
Thanks, looked into it, run with it and will push a commit for your review, by hopefully, end of
(my) day.
Dongni: Are you ok with varying the design to include this?
Cheers
PGR
--
Paul Richardson
"There is no operating system on the planet that can withstand a determined assault from a clueless
user."
"I know exactly who reads the papers ...
Jim Hacker, Yes Minister
@phantomjinx - yes! That's totally fine with me. Thank you!
@michael-coker
Ok.... here is the 2 commits for the new and improved editor ... my-branch
It should be good to test but let me know any problems, including if you need a PR instead?
cc @dongniwang @gaughan
@phantomjinx great, thanks! I'll work from your branch.
@phantomjinx the validation stuff looks great!! @dongniwang now that we have that inline validation in place in the editor itself, do we need to show the validation errors below the template editor? When you hover over the validation errors in the template editor, you get the details about the validation error.

@michael-coker thanks. So I left the validation-under-editor in just because its per the design (and took a couple of hours last night to get right!). However, it is now redundant given mostly everything it displays in now inline.
I say mostly because the MustacheMode class does not delegate to the Mustache library's own parse function, whereas the onChange() function of templateComponent.ts does. The purpose of calling this is to get Mustache to break up the text into symbols and text which then form the specification of the OutputDataShape. However, it does also spit out an errors if the text doesn't parse. The downside of this error is that it does not do it by line/column but by character number so doesn't fit with the inline error messages.
Therefore, probably put a pin in this one and revisit maybe at later stage.
Yeah, I think the inline validation looks pretty awesome! Thank you @phantomjinx and @michael-coker for working on this!
I agreed that the error message below the editor is not providing additional useful and helpful information and we can remove that for the template step. However, I think it's still a good functionality to keep in our back pocket and it could be very useful if we have other types of error messages we want to display or to complement the editor in the future. Thank you so much @phantomjinx for spending hours on this and I really appreciate you took the effort to match UI implementation with the UX design!
Hey @phantomjinx, I made some minor updates to the UI and got the placeholder/hover overlay text working except that the dragenter event only fires when you hover over the border of the codemirror editor. As soon as the mouse enters, the dragleave event is fired and the hover overlay text disappears. Looks like it's possibly due to hovering a child element in the codemirror element. I added (and commented out) some SCSS that sets pointer-events: none; on all of the codemirror element's children once you've moused over the element, and if you uncomment that, you can see the hover state/overlay works as intended, but the file drop doesn't work. That's just to demonstrate the issue.
Do you have any ideas? Those events seem to work fine in this example - http://jsfiddle.net/3pvvLote/69/
Also a small thing, but I noticed you can drop non .tmpl files in the editor. Dropping a .txt file will upload the file's contents to the editor.
And I removed the validation output from the HTML/CSS templates but left the typescript in there for you to remove in case it's used in a way I don't understand.
Also a small thing, but I noticed you can drop non .tmpl files in the editor. Dropping a .txt file will upload the file's contents to the editor.
So, by default, codemirror will let any file be dropped. This can be limited by included allowDropFileTypes in the configuration. The problem is specifying what the file-types are that can be included since it requires the MIME type of the file rather than the extension. A standard .tmpl text file has no MIME type and therefore is rejected. It is possible to get the $event during the drop and interrogate the DataTransfer object but that could be browser/OS specific and a real can-o-worms.
@michael-coker
@michael-coker
As regards the DnD issue, I am stumped.
I'll go ahead and create a PR just to get the rest of it in as I don't think this the issues are detrimental to the whole.
@dongniwang @phantomjinx Just wanted to touch base about this and see if we can re-visit the 2 remaining issues from this. Not sure if I should open another issue or want to keep track of these here?
My initial thought about being able to drop any kind of file in the codemirror editor is, from what I tested, codemirror allows files with text in them (txt, json, css, html, hbs, etc), but not files that aren't just text (PDF, jpg, etc). What if we changed the "allowed file types" text to match whatever codemirror's restrictions are?
Also, if you try to drop a PDF in the codemirror editor, there is no error message. Can we display one?
And I'm not sure about the hover overlay dragleave event firing unexpectedly. Seems like a bug we can probably work out if we spend some time on it.
@michael-coker @phantomjinx - Assuming with the latest work from https://github.com/syndesisio/syndesis/issues/3763, we can close this issue now?
@dongniwang I think so, all of my original issues have been addressed.
Awesome, closing now. Will open new issues if needed. Thank you!