Skip to content

Add Grunion Editor View.#7490

Merged
eliorivero merged 18 commits intomasterfrom
contact-form/visual-shortcode-2
Jul 24, 2017
Merged

Add Grunion Editor View.#7490
eliorivero merged 18 commits intomasterfrom
contact-form/visual-shortcode-2

Conversation

@georgestephanis
Copy link
Copy Markdown
Contributor

Closes #6685

Fixes #7063
Fixes #1849
Fixes #1055
Fixes #642
Fixes #604
Fixes #254

This is a redo of #6685 because I seem to have made that ugly by rebasing it. :\

The diff to implement this on wpcom is at D6457

contact-form

This is currently just adding the overrides -- I'm intentionally not removing the old legacy code yet, to ease the transition on any users that prefer the old method. They can just disable the new include line, and the old way will be back again.

Props @MichaelArestad @azaozz and @georgestephanis for building this at the 2016 a8c GM.

Changes proposed in this Pull Request:

  • Add a visual interface for Contact Forms.

Testing instructions:

  • Add a contact form to a post.
  • Edit an existing contact form in a post.
  • Switch to the html editor. Back again!
  • Add a second or third contact form to a post.
  • Open multiple forms to editing mode at the same time.

@georgestephanis georgestephanis added [Feature] Forms Touches WP.com Files [Pri] High [Status] Needs Review This PR is ready for review. Enhancement Changes to an existing feature — removing, adding, or changing parts of it labels Jul 19, 2017
@georgestephanis georgestephanis added this to the 5.2 milestone Jul 19, 2017
@georgestephanis georgestephanis self-assigned this Jul 19, 2017
@georgestephanis
Copy link
Copy Markdown
Contributor Author

Our travis build for 5.2/5.3 kept failing repeatedly, so thinking it was something that may have been fixed in master, I rebased and then made this repeat of the pr.


include dirname( __FILE__ ) . '/contact-form/grunion-contact-form.php';

if ( is_admin() ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about a filter here to disable the new feature. I would specifically note in the inline docs (and maybe in the filter name) that it is a temporary filter. Maybe say we'll keep it in for the next three? six? months or unless there is a security issue in the older code that we opt to remove it before that time, etc etc etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Care to add a commit to introduce it? Maybe change the line to

if ( is_admin() && apply_filters( 'tmp_grunion_allow_editor_view', true ) ) {

For a gentle way to use the older UI to give site owners time to update tutorials, instruct clients, etc. Noting a timeline to remove in six months.
@kraftbj
Copy link
Copy Markdown
Contributor

kraftbj commented Jul 19, 2017

5.2/5.3 is likely due to #7453 . I'm going to merge that one and see if that resolves it. (Merging out of process only since it is a unit test issue, not production code).

@ntwb
Copy link
Copy Markdown
Contributor

ntwb commented Jul 19, 2017

Indeed that is the cause, the 5.2 job is currently running on Trusty, Trusty doesn't have PHP 5.2 or 5.3 available, updating master after #7453 should get this sorted

@georgestephanis
Copy link
Copy Markdown
Contributor Author

Cherry picked them over.

@georgestephanis
Copy link
Copy Markdown
Contributor Author

Updated D6457 to reflect new filter and filter docs. Thanks @kraftbj!

@georgestephanis
Copy link
Copy Markdown
Contributor Author

georgestephanis commented Jul 20, 2017

As we are moving the contact form button into the TinyMCE bar, should we do some sort of tooltip callout pointing out the change to folks? Or maybe just keep the old button as well? It is possible to gloss over.

If this merges, I'll do a second PR to add it back in if we want to keep it.

@georgestephanis
Copy link
Copy Markdown
Contributor Author

I'm doing some last minute RTL testing before we merge this. It's totally functional, but some stuff isn't being mirrored.

@georgestephanis
Copy link
Copy Markdown
Contributor Author

As of this point, the phab diff is still in sync with the PR.

@MichaelArestad
Copy link
Copy Markdown
Contributor

Taking it for a spin.

* Changed edit mode card focus and hover styles
* Changed edit mode background color to grey to better indicate it needs to be saved/exited
* Fixed Required toggle positioning via flex
* Fixed label spacing
* Fixed primary button styling in edit mode
* Removed a bit of unused styles
@MichaelArestad
Copy link
Copy Markdown
Contributor

Pushed several style changes.

Still planning on trying:

  • implementing sticky for buttons
  • updating preview section headers to be pretty
  • separating button groups in edit mode (move cancel/update to the right side)
  • more spacing tweaks
  • removing the pesky space at the bottom of the box in edit-mode

@georgestephanis
Copy link
Copy Markdown
Contributor Author

With the changes in 3cfd8ff implementing flex-grow and such in lieu of floating, this will be bad in IE9 and below. Which is probably fine, just wanted to make that explicit.

@MichaelArestad MichaelArestad added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Jul 20, 2017
@georgestephanis
Copy link
Copy Markdown
Contributor Author

The phabricator diff -- D6457 -- is now up to date with ~.

Copy link
Copy Markdown
Contributor

@zinigor zinigor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-wise everything seems to be OK except for several i18n nitpicks. Plus, the JS could use a style pass - there are spaces missing here and there.
I'm going to do a testing run next.

'checkbox' => __( 'Checkbox', 'jetpack' ),
'checkbox-multiple' => __( 'Checkbox with Multiple Items', 'jetpack' ),
'select' => __( 'Drop down', 'jetpack' ),
'radio' => __( 'Radio', 'jetpack' ),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every one of these translatable strings could really use context. Some of them need it badly, like Drop down can be translated at least three different ways without knowing what it means. If we already have strings like these, I would propose just adding translator comments to avoid creating new strings:

/* translators: label name to choose a dropdown field for a contact form */
'select' => __( 'Drop down', 'jetpack' ),

Also, shouldn't it be Dropdown?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just pulling across via

<option value="checkbox"><?php esc_html_e( 'Checkbox', 'jetpack' ); ?></option>
<option value="checkbox-multiple"><?php esc_html_e( 'Checkbox with Multiple Items', 'jetpack' ); ?></option>
<option value="select"><?php esc_html_e( 'Drop down', 'jetpack' ); ?></option>
<option value="email"><?php esc_html_e( 'Email', 'jetpack' ); ?></option>
<option value="name"><?php esc_html_e( 'Name', 'jetpack' ); ?></option>
<option value="radio"><?php esc_html_e( 'Radio', 'jetpack' ); ?></option>
<option value="text" selected="selected"><?php esc_html_e( 'Text', 'jetpack' ); ?></option>
<option value="textarea"><?php esc_html_e( 'Textarea', 'jetpack' ); ?></option>
<option value="url"><?php esc_html_e( 'Website', 'jetpack' ); ?></option>


<label class="grunion-required">
<input type="checkbox" name="required" value="1" <# if ( data.required ) print( 'checked="checked"' ) #> />
<span><?php esc_html_e( 'Required?', 'jetpack' ); ?></span>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, context needed.

@georgestephanis
Copy link
Copy Markdown
Contributor Author

Just following up to ^^, heard from @zinigor in Slack to just leave the translator notes be as it's just pulling existing strings across.

@georgestephanis georgestephanis dismissed zinigor’s stale review July 21, 2017 15:18

heard from @zinigor in Slack to just leave the translator notes be as it's just pulling existing strings across.

named,
fields = '',
stylesheet_url = ( 1 === window.isRtl )
? grunionEditorView.inline_editing_style_rtl
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zinigor

modules/contact-form/js/editor-view.js
  line 71  col 21  Bad line breaking before '?'.

Build tools are erroring on this saying it's bad on jshint.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarn lint

@georgestephanis georgestephanis requested a review from a team as a code owner July 24, 2017 20:27
@eliorivero
Copy link
Copy Markdown
Contributor

Works great! Merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Feature] Forms [Pri] High Touches WP.com Files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants