Comments

sumitmadan’s picture

Assigned: Unassigned » sumitmadan

Working on it.. almost completed.

sumitmadan’s picture

Status: Active » Needs review
StatusFileSize
new11.61 KB

Created a patch that works fine on webform node pages. But the only issue is I am not able to see the tab on the pages.

sumitmadan’s picture

StatusFileSize
new11.59 KB

Oops. Forgot to remove a change.

fenstrat’s picture

Status: Needs review » Needs work

Nice work!

Just a quick code review at the moment, I'll try testing the actual patch later:

  1. +++ b/src/Form/WebformComponentsForm.php
    @@ -31,10 +31,10 @@ class WebformComponentsForm extends FormBase {
    -  public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $node = NULL) {
    +  public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $webform_node = NULL) {
         $form = [
           '#tree' => TRUE,
    -      '#node' => $node,
    +      '#node' => $webform_node,
    

    Somewhat tempting to create a local variable $node (i.e. $node = $webform_node) rather than using $webform_node. However given $webform_node is what the ParamConvert expects/returns then I guess leaving it as that is ok.

  2. +++ b/src/ParamConverter/WebformParamConverter.php
    @@ -0,0 +1,40 @@
    + * Parameter converter for upcasting entity ids to full objects.
    

    Comment needs to be updated.

  3. +++ b/webform.module
    @@ -1732,7 +1732,7 @@ function webform_user_role_delete($role) {
    -  if (isset($form['#node']->type) && $form_id == $form['#node']->type . '_node_form' && \Drupal::config('webform.settings')->get('node_' . $form['#node']->type)) {
    +  if (isset($form['#node']) && $form['#node']->bundle() && $form_id == $form['#node']->bundle() . '_node_form' && \Drupal::config('webform.settings')->get('node_' . $form['#node']->bundle())) {
    

    Good catch with $node->type => $node->bundle(). There are a few other instances throughout the module, can you split this change off into another issue and we can get it fixed quickly.

  4. +++ b/webform.routing.yml
    @@ -13,14 +13,16 @@ webform.settings:
    -    # @todo This needs to call/replicate webform_node_update_access().
         _permission: 'edit webform components'
    +    _entity_access: 'webform_node.update'
    

    We're not creating our own custom entity type here so unless I'm mistaken this is not correct. Also webform_node_update_access() does quite a few additional checks. I think for simplicity lets remov this and keep this patch focused on showing the webform tab on webform enabled content types.

As for not seeing the tab on webform nodes, again I haven't tested the path, but I'd look to something being amiss in webform.links.task.yml

sumitmadan’s picture

StatusFileSize
new11.55 KB

updated the comments and routing.yml file.

Good catch with $node->type => $node->bundle(). There are a few other instances throughout the module, can you split this change off into another issue and we can get it fixed quickly.

We can create a separate issue for that. Or we can change it page by page I mean while converting menu to route.

sumitmadan’s picture

Status: Needs work » Needs review
fenstrat’s picture

Status: Needs review » Needs work

Thanks.

  1. I've gone ahead and fixed ->bundle() in #2504477: Use $node->bundle() instead of $node->type so it'll need to be removed here.
  2. +++ b/src/Form/WebformComponentsForm.php
    @@ -218,7 +218,7 @@ class WebformComponentsForm extends FormBase {
    @@ -226,7 +226,6 @@ class WebformComponentsForm extends FormBase {
    
    @@ -226,7 +226,6 @@ class WebformComponentsForm extends FormBase {
           '#weight' => -1,
         ];
         webform_input_vars_check($form, $form_state, 'components', 'warning');
    -
         return $form;
       }
     
    

    Unrelated change, please remove.

  3. +++ b/src/ParamConverter/WebformParamConverter.php
    @@ -0,0 +1,40 @@
    + * Parameter converter for to access the webform enabled node only.
    

    Grammar is off. How about: "Parameter converter for upcasting webform node ids to full objects."

  4. +++ b/webform.routing.yml
    @@ -13,14 +13,15 @@ webform.settings:
    -    # @todo This needs to call/replicate webform_node_update_access().
    

    This comment needs to stay.

  5. I've still not tested the patch, how'd you go getting the tab to display?
sumitmadan’s picture

Status: Needs work » Needs review
StatusFileSize
new10.11 KB

Thanks. Updated the changes.

For tab, I will look at it. I didn't find a way yet, to add tab only on webform enabled node.

fenstrat’s picture

Status: Needs review » Needs work

Needs work for showing the tab.

Also #7 4. still needs to be addressed.

Thanks for your work here @sumitmadan

sumitmadan’s picture

StatusFileSize
new10.08 KB

My bad (removed wrong comment).

sumitmadan’s picture

Status: Needs work » Needs review
StatusFileSize
new2.44 KB

I have removed the ParamConverter class and added access_check_token. Please review its working now. :)

sumitmadan’s picture

StatusFileSize
new2.44 KB

Oops used my test key. Update now.

safetypin’s picture

I'm still seeing the webform tab on node types that aren't webform-enabled. I'm not 100% certain I'm testing correctly:

1) Downloaded Drupal-beta14 (drush)
2) Performed fresh install, standard profile
3) Cloned the webform repository, and checked out the 8.x-4.x branch
4) Downloaded the patch from #12
5) Applied it using git
6) Ran drush cache-rebuild

safetypin’s picture

StatusFileSize
new2.44 KB

It looks to me like there was a misplaced ! on the check for the node setting: WebformNodeAccessCheck.php:42. Removing the ! from the second condition of that if statement seems to have the desired result for me.

sumitmadan’s picture

Issue summary: View changes
StatusFileSize
new694 bytes
new2.44 KB
fenstrat’s picture

Issue summary: View changes
Status: Needs review » Fixed

Committed and pushed to 8.x-4.x. Thanks!

In the interest of forward progress I've gone ahead and committed #15 with minor changes. Thanks for your work here @sumitmadan.

  1. I restored the @todo from #7 4.
  2. Can already see that this will need refactoring to allow other paths to use this (like node/{node}/webform/conditionals). That will also then need to access checking in webform_node_update_access().

  • fenstrat committed a3faee3 on 8.x-4.x authored by sumitmadan
    Issue #2503105 by sumitmadan: Display webform tab only on webform...

Status: Fixed » Closed (fixed)

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