Problem/Motivation

Currently the default weight property could be changed only by editing contact form.

Proposed resolution

Once we decide at #1997692: Create contact form block about weight property (2b or not 2b)
1) Allow to set default category within List UI
2a) Allow sorting on the same list builder
2b) Do not implement sortnig
3) cover with tests

Remaining tasks

cover with tests 1)
depending on state #1997692: Create contact form block extend patch or rtbc

Contributor tasks needed
Task Novice task? Contributor instructions Complete?
Update the issue summary Instructions
Update the issue summary noting if allowed during the beta Instructions
Update the patch to incorporate feedback from reviews. See comment #61 (include an interdiff) Instructions

User interface changes

1) Default category selected at the list
2) (?) Categories are sorted

API changes

ContactFormListBuilder should implement FormInteface or extend DraggableListBuilder class for weight property

Original report by @Dave Reid

For D8 I'd really like to accomplish:
1. Implementing a drag/drop sorting of contact categories. We have a weights field, but we don't currently utilize it or allow people to change it.
2. Change the 'default' contact category to a radio on admin/structure/contact instead of having to edit the category you want to be the default and then saving the category. We should just implement this as a variable 'contact_category_default'

contact_category_list.png

Related issues
#1855402: Add generic weighting (tabledrag) support for config entities (DraggableListController)
#1891690: Use EntityListController for vocabularies
#1803638: Improve default language change process (ui and help text)

CommentFileSizeAuthor
#58 clean_up_the_contact-599770-55.patch849 bytesprajaankit
#54 interdiff.txt8.73 KBalansaviolobo
#54 clean_up_the_contact-599770-54.patch818 bytesalansaviolobo
#45 interdiff.txt1.56 KBandypost
#45 599770-contact-sorting-45.patch8.48 KBandypost
#43 interdiff.txt907 bytesandypost
#43 599770-contact-sorting-43.patch8.52 KBandypost
#42 interdiff.txt4.99 KBandypost
#42 599770-contact-sorting-42.patch8.5 KBandypost
#38 interdiff.txt1.82 KBandypost
#38 599770-contact-sorting-38.patch6.87 KBandypost
#36 interdiff.txt1.83 KBandypost
#36 599770-contact-sorting-36.patch6.98 KBandypost
#34 interdiff.txt878 bytesandypost
#34 599770-contact-sorting-34.patch6.81 KBandypost
#32 interdiff.txt743 bytesandypost
#32 599770-contact-sorting-32.patch5.96 KBandypost
#26 interdiff.txt716 bytesandypost
#26 599770-contact-sorting-26.patch8.21 KBandypost
#24 interdiff.txt617 bytesandypost
#24 599770-contact-sorting-24.patch8.22 KBandypost
#22 interdiff.txt2.01 KBandypost
#22 599770-contact-sorting-22.patch8.14 KBandypost
#19 interdiff.txt3.66 KBandypost
#19 599770-contact-sorting-19.patch6.62 KBandypost
#17 599770-contact-sorting-17.patch6.14 KBandypost
#12 599770-contact-sorting-12.patch6.85 KBandypost
#12 contact_category_list.png34.38 KBandypost
#12 contact_category_list_weight.png35.35 KBandypost
#11 599770-contact-sorting-11.patch6.53 KBandypost
#7 599770-contact-sorting-7.patch6.51 KBandypost
#7 599770-interdiff-7.txt397 bytesandypost
#3 599770-contact-sorting-3.patch6.51 KBandypost
#3 599770-contact-overview.png18.58 KBandypost
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

+1 to both!

> We should just implement this as a variable 'contact_category_default'

I don't think we need to change the data storage, just the UI.

andypost’s picture

andypost’s picture

Status: Active » Needs review
FileSize
18.58 KB
6.51 KB

Initial working patch. Probably we needs tests.
599770-contact-overview.png

joachim’s picture

Status: Needs review » Needs work

Looking good!

Will need some extra help text to explain what dragging them accomplishes.

Also, is 'selected' the one that's selected by default in the contact form? That maybe needs explanation too.

andypost’s picture

Issue tags: +Needs usability review

Suppose fix for contact_help could go in follow-up, I'm not do good in English to write help texts.
Let's get more reviews from usability team

Bojhan’s picture

Looks good, I am not sure we want a "selected" column - maybe it should be labeled "Default".

andypost’s picture

Changed Selected to Default we are already changing this option in #1477704: Replace "Selected" dropdown with checkbox in category edit form to checkbox with text 'Make this the default category.'

EDIT related #1588422: Convert contact categories to configuration system

Bojhan’s picture

Status: Needs work » Needs review
Issue tags: -Needs usability review

Can this get code review, Dave Reid maybe?

andypost’s picture

Issue tags: -#d8ux

#7: 599770-contact-sorting-7.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: -Needs usability review

The last submitted patch, 599770-contact-sorting-7.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
6.53 KB

re-roll

andypost’s picture

Here's a new patch, now ordering is enabled only when there's more then one category on site.
Probably it's possible to move form building into list controller... but not for now.

contact_category_list.png

contact_category_list_weight.png

sun’s picture

Title: Revamp the admin/structure/contact page » Clean up the contact category UI: Allow to set the default category and weights on the listing page
Category: feature » task
Issue tags: +Configurables

I agree this UI badly needs to be cleaned up. Also, better issue title.

But, hm. I agree we should not attempt to do this in a generic/abstract way just yet, but I do think that the new form code should be added to the CategoryListController override class... (?)

To do so, we'll probably have to use drupal_build_form() instead of drupal_get_form(), but that shouldn't be a big deal.

andypost’s picture

I found similar implementation in #1787942-41: Allow assigning layouts to pages but Gabor used drupal_get_form()

sun’s picture

Title: Clean up the contact category UI: Allow to set the default category and weights on the listing page » Clean up the contact category listing UI: Allow to set the default category and weights on the listing page
Assigned: Dave Reid » Unassigned

We've actually started with a generic implementation in #1855402: Add generic weighting (tabledrag) support for config entities (DraggableListController) already.

That patch is still waiting for #80855: Add element #type table and merge tableselect/tabledrag into it to land, but it looks like the generic implementation will boil down to a few lines only. Therefore, it might make sense to do that first?

andypost’s picture

andypost’s picture

Issue summary: View changes

Added screenshot

andypost’s picture

Status: Postponed » Needs review
FileSize
6.14 KB

I don't think we should postpone this patch for #1855402: Add generic weighting (tabledrag) support for config entities (DraggableListController)

This form is not a default case and could be refactored later for default table-drag

geerlingguy’s picture

Following, and noting that it seems that adding non-default categories doesn't actually show them in a selection on the contact form. I added a new category, 'info', but didn't make it default, and no selection showed up on the contact page at all. I deleted the 'website feedback' default category, then the contact page said "You need to add a category" (something like that). I set the new 'info' category as default, and the form showed up again without an error. I don't know if whatever small bug caused this behavior could be fixed with this patch...

andypost’s picture

New patch build on top of FormInterface now this form is alterable by name 'contact_category_list_form'

@geerlingguy selection of contact category was droped but please file new issue to fix message in contact_site_page() or provide a fallback to first category if no category marked as default.

tim.plunkett’s picture

Status: Needs review » Needs work

No, please don't combine FormInterface into EntityFormControllers in these issues. That's what #1913618: Convert EntityFormControllerInterface to extend FormInterface is for.

tim.plunkett’s picture

Status: Needs work » Needs review

I got FormController and ListController confused :) Sorry

andypost’s picture

added route conversion here

Status: Needs review » Needs work

The last submitted patch, 599770-contact-sorting-22.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
8.22 KB
617 bytes

Status: Needs review » Needs work

The last submitted patch, 599770-contact-sorting-24.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
8.21 KB
716 bytes

fix yml

Status: Needs review » Needs work
Issue tags: -#d8ux, -Configurables, -FormInterface, -WSCCI-conversion

The last submitted patch, 599770-contact-sorting-26.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
Issue tags: +#d8ux, +Configurables, +FormInterface, +WSCCI-conversion

#26: 599770-contact-sorting-26.patch queued for re-testing.

podarok’s picture

Status: Needs review » Reviewed & tested by the community

#26 looks pretty nice for me
happy thankspushing )

alexpott’s picture

Status: Reviewed & tested by the community » Postponed

It appears that we've completely lost the ability to select contact categories on the site wide form is missing. This should be postponed on #1997692: Create contact form block as that patch mandates the ability to have the ability to not have a default contact category. This is important functionality if you want to make people choose one!

andypost’s picture

Status: Postponed » Needs review

I think this is a great improvement in UI so let's find a compromise here.
While we can bikeshed about tabs/splitbuttons for UI the administrative sreen really lacks ability to re-order items!!!

So let's leave default as is, because we always have state when default category deleted

andypost’s picture

Do not allow personal category to be selected as default

Status: Needs review » Needs work

The last submitted patch, 599770-contact-sorting-32.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
6.81 KB
878 bytes

Fix test

tstoeckler’s picture

+++ b/core/modules/contact/lib/Drupal/contact/CategoryListController.php
@@ -45,33 +53,140 @@ public function getOperations(EntityInterface $entity) {
+      $row['default'] = array(
...
+        '#disabled' => $entity->id() == 'personal',
+      );

AFAIK #disabled only sets the disabled attribute but does not actually prevent submitting that value. I.e. I think we should conditionally set #value. I mean something like:

if ($entity->id() == 'personal') {
  $row['default']['#value'] = NULL;
}

Otherwise looks great!

andypost’s picture

Better display nothing at all

tstoeckler’s picture

Hmm, how about instead of
'#disabled' => $entity->id() == 'personal'
we just do
'#access' => $entity->id() != 'personal'
??

Anyway, this is super minor and shouldn't hold anything up.
If I would be a little more comfortable with contact.module I would RTBC #36 but I'll leave that to someone else.

EDIT: Fixed inverted condition

andypost’s picture

@tstoeckler thanx #37 much cleaner

tstoeckler’s picture

Coolio, thanks @andypost!

dawehner’s picture

+++ b/core/modules/contact/lib/Drupal/contact/CategoryListController.phpundefined
@@ -45,33 +53,141 @@ public function getOperations(EntityInterface $entity) {
+    $default_category = config('contact.settings')->get('default_category');
...
+    $entities = entity_load_multiple($this->entityType, array_keys($values));
...
+    $contact_config = config('contact.settings');

Can I have some injections?

Bojhan’s picture

Can the default setting, be something that is set on the configuration of the category? It can still be reflected in the table. But using a radio in a table has proven to be quite hard to use in previous testing.

andypost’s picture

Assigned: Unassigned » andypost
FileSize
8.5 KB
4.99 KB

Addressed #40, suppose better to have a factory and default both

Working on implementation of changing a default category via operalins link
@Bojhan we still have a checkbox at the bottom of contact category editing form.

andypost’s picture

right patch

Status: Needs review » Needs work

The last submitted patch, 599770-contact-sorting-43.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
8.48 KB
1.56 KB

There should not be links for config entities
also this should be re-rolled after #1938390: Convert contact_site_page and contact_person_page to a new-style Controller

Status: Needs review » Needs work

The last submitted patch, 599770-contact-sorting-45.patch, failed testing.

dawehner’s picture

This is looking pretty great.

+++ b/core/modules/contact/lib/Drupal/contact/CategoryListController.phpundefined
@@ -1,21 +1,81 @@
+use Drupal\Core\Form\FormInterface;
+use Drupal\Core\Config\ConfigFactory;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\contact\CategoryStorageController;
+use Drupal\Component\Utility\String;

Let's not mix up Symonfy and Drupal here.

+++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.phpundefined
@@ -222,15 +222,7 @@ function testSiteWideContact() {
     // Find out in which row the category we want to add a field to is.
-    $i = 0;
-    foreach($this->xpath('//table/tbody/tr') as $row) {
-      if (((string)$row->td[0]) == $label) {
-        break;
-      }
-      $i++;
-    }
-
-    $this->clickLink(t('Manage fields'), $i);
+    $this->drupalGet('admin/structure/contact/manage/' . $category . '/fields');

This is a really great improvement.

Berdir’s picture

No, that is not an improvement.

That code was added there for a reason. It verifies that the Manage fields link is displayed, that was broken before.

tim.plunkett’s picture

drupalGet only verifies the routes, and doesn't actually test clicking around the UI. clickLink is important here

andypost’s picture

The both needed - to verify that link exists and accessible
Also related #1997692: Create contact form block

andypost’s picture

Issue tags: +Needs reroll
andypost’s picture

Issue summary: View changes

Added related issues

alansaviolobo’s picture

The last submitted patch, 45: 599770-contact-sorting-45.patch, failed testing.

alansaviolobo’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
818 bytes
8.73 KB

re rolled the patch.

andypost’s picture

Status: Needs review » Needs work

The re-roll is wrong, the reason of the patch to add formInterface to list builder!

larowlan’s picture

@andypost are you still interested in working on this?

andypost’s picture

Yes, and this depends on #1997692: Create contact form block

prajaankit’s picture

Status: Needs work » Needs review
FileSize
849 bytes

Status: Needs review » Needs work

The last submitted patch, 58: clean_up_the_contact-599770-55.patch, failed testing.

andypost’s picture

Title: Clean up the contact category listing UI: Allow to set the default category and weights on the listing page » Clean up the contact forms listing UI: Allow to set the default category and weights on the listing page
Issue summary: View changes
Status: Needs work » Postponed

Update IS to current state
#58 shows hat tests are make sense

andypost’s picture

Status: Postponed » Needs work
Issue tags: +Novice

ContactFormListBuilder should implement FormInteface

piyuesh23’s picture

Assigned: andypost » piyuesh23
Issue tags: +#DCM2015
Patrick Storey’s picture

Issue tags: -Needs reroll

I am removing the Needs Reroll tag as the patch in comment 58 applies to head.

The steps I took to check this were to

1.) Make a new directory
2.) in the terminal: $ git clone --branch 8.0.x http://git.drupal.org/project/drupal.git
3.) $ cd drupal
4.) $ curl -O https://www.drupal.org/files/issues/clean_up_the_contact-599770-55.patch
5.) $git apply --check clean_up_the_contact-599770-55.patch

And I received no response so this patch applies to head.

Patrick Storey’s picture

Assigned: piyuesh23 » Unassigned

@piyuesh23 I am unassigning this task from you as I saw you were assigned it in Feb 2015. If you would still like to work on this issue just make another comment. :-)

Patrick Storey’s picture

Issue summary: View changes
Issue tags: -Novice +Needs issue summary update

I updated the remaining tasks to incorporate @andypost feedback in comment #61, there are some tasks in the original issue summary that I'm not sure whether they are relevant any longer. So we will need to update the issue summary.

Also we need a beta evaluation for this task. I'm going to remove the Novice tag until that is done and we're sure this is for the current version of Drupal 8.

andypost’s picture

Last working prototype is #45
it needs to be rebuild on top of DraggableListBuilder
and address comments #47

andypost’s picture

Version: 8.0.x-dev » 8.1.x-dev
joachim’s picture

The languages admin page also has a weights + set default form, so that could do to be abstracted as a new builder class extending DraggableListBuilder.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

drupgirl’s picture

Hi, not sure what patches I should be applying to get the the result of having the category dropdown in the contact form. Does anyone have this currently working on 8.4.3 have some quick pointers?

Berdir’s picture

There is no concept of a contact form category in Drupal 8, this just has a confusing issue title, should say default *form*.

The contact_storage module provides a field type that allows to send a contact form to different recipients based on a select. And webform might provide something similar.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.