og icon indicating copy to clipboard operation
og copied to clipboard

331 set membership type for group type

Open joachim-n opened this issue 7 years ago • 9 comments

PR for #331.

joachim-n avatar Oct 27 '17 10:10 joachim-n

Thanks! Can you provide gif/ screenshot(s) as-well - so it's easier to get the context.

amitaibu avatar Oct 27 '17 10:10 amitaibu

This shows the extra form element on the bundle form:

og - pr 333 screen shot

It uses states so it's only shown when the 'Group' checkbox is selected.

Just to be clear, I've not implemented the 2nd thing I suggested on #331, which was to add a setting to the GroupSubscribeFormatter. I'm not sure there's a use case for it now I think about it, as since the group settings are per-bundle, there is a 1-1 correspondence between the group bundle settings and the formatter's settings. Therefore having a setting in the formatter doesn't provide any finer-grained control. So overall, it's best to have this setting somewhere where the API uses it, rather than in the UI.

joachim-n avatar Oct 27 '17 12:10 joachim-n

Fixed the unit test errors that the CI was reporting.

Locally I am getting 1 fail with:

  1. Drupal\Tests\og\Kernel\Console\DrupalConsoleAddFieldTest::testNewGroup Error: Class 'Drupal\Console\Core\Style\DrupalStyle' not found

but I expect that's because my local copy of Drupal Console is out of date.

joachim-n avatar Oct 27 '17 13:10 joachim-n

Fixed the things the codesniffer was complaining about.

joachim-n avatar Oct 27 '17 15:10 joachim-n

This works quite well on our build.

A couple of remarks:

  1. it would be great to limit membership types per group type.
  2. Had to have a "glue" patch for this + #231 + #181 - https://gist.github.com/zerolab/da4899abf6683180e1f07fc859b06707

zerolab avatar Nov 16 '17 10:11 zerolab

it would be great to limit membership types per group type.

Not sure what you mean.

Do you mean that when you create a membership type, eg Membership Foo, you get to say in its form that it's only available for Group bundles X and Y?

That would presumably have to be enforced at the API level, since you can use the API to create a membership in any type, not just the one set for the group bundle.

joachim-n avatar Nov 16 '17 10:11 joachim-n

Do you mean that when you create a membership type, eg Membership Foo, you get to say in its form that it's only available for Group bundles X and Y?

Yes. If I have Group Type A and Group Type B and I need a special Membership Type for just B, I don't want to add a new member to a group in A and see the special membership type that is meant just for B.

zerolab avatar Nov 16 '17 11:11 zerolab

It's not my call, but I'd suggest that's left for a follow-up, as it's a fair bit more work.

This would need:

  • a new property on the Group Membership type entity for the group bundles that it allows
  • that possibly means adding a config dependency to the GM type, as it is referencing a bundle entity
  • limiting the options shown on the group type form to the eligible GM types, and probably adding an API method to get those
  • enforcing this setting in the API methods that create a group membership, so you can't pass in a GM type ID that's not allowed

joachim-n avatar Nov 16 '17 11:11 joachim-n

Drupal 7 backport or module?

staminna avatar Jul 04 '18 11:07 staminna