Hi,
admin pages like this
http://../admin/config/search/facetapi/search_api%40product/block/title/edit
have a suboptimal navigation.

Nice would be:

Tabs to "sibling" pages
http://../admin/config/search/facetapi/search_api%40product/block/title/edit
http://../admin/config/search/facetapi/search_api%40product/block/title/dependencies
http://../admin/config/search/facetapi/search_api%40product/block/title/filters

Breadcrumb parent should be
http://../admin/config/search/search_api/index/product/facets

Solution:

Tabs:
I'm not sure if local actions go well together with local tasks? I am totally inexperienced with local actions..

Breadcrumbs:
If the path were not admin/config/search/facetapi/.. but admin/config/search/search_api/facetapi/.., this would solve the problem, or not?

CommentFileSizeAuthor
#11 facetapiuifix.zip1.59 KBdonquixote

Comments

cpliakas’s picture

Hi donquixote.

I'm not completely clear on what the problem is. My gut tells me things are suboptimal, but it would be good to really spell it out in this issue. One thing to keep in mind is that we had to do some funky things to support contextual links, so that might be why local actions we added is seemingly inappropriate places. Review #1147588: Improve code for contextual links for more info.

Chris

donquixote’s picture

it would be good to really spell it out in this issue.

oh yes.. my issue summary really sucks :)

E.g. I get this breadcrumb

Home » Administration » Configuration » Search and metadata (» Configure facet display for Price » Amount)
and no tabs

Instead, breadcrumb should be
Home » Administration » Configuration » Search and metadata » Search API » Products index » Facets( » Price: Amount)

Tabs for the page should be
[Display] [Dependencies] [Filters] ...

cpliakas’s picture

Great info. Thanks!

Yeah this seems wrong. It might be difficult to make breadcrumbs work correctly in Facet API since it works with multiple modules, but I am open for suggestions. If you search the monolog.admin.inc file for "drupal_set_breadcrumb", you will see that I had to do a ton of manipulation of breadcrumbs to make them work correctly. I suspect we will have to do that here as well.

Chris

donquixote’s picture

You could write a Crumbs plugin :)
Then you only need to specify a few parent-child relationships that are not obvious from the path, and you are done.

donquixote’s picture

This said, it might be better to restructure the paths in a way that they reflect the natural hierarchy. This will also improve the admin menu.

donquixote’s picture

Issue summary: View changes

The following, combined with Crumbs, will give a nice breadcrumb on the facet config pages.
E.g. Home » Administration » Configuration » Search and metadata » Search API » Index: Products index » Facets »

/**
 * Implements hook_crumbs_plugins()
 *
 * @param crumbs_InjectedAPI_hookCrumbsPlugins $api
 */
function facetapi_crumbs_plugins($api) {

  foreach (array(
    'dependencies',
    'edit',
    'export',
    'filters',
    'revert',
  ) as $key) {
    $api->routeParentCallback(
      'admin/config/search/facetapi/%/%/%/' . $key,
      $key,
      function($path, $item) {
        list(,,,,$adapter, $realm, $facet) = $item['map'];
        if (!$adapter instanceof FacetapiAdapter || empty($realm['name'])) {
          return NULL;
        }
        return $adapter->getPath($realm['name']);
      }
    );
  }
}

Although, to get the "Index: Products index" to show up instead of just "View index", another implementation is necessary. This time it's search_api.

/**
 * Implements hook_crumbs_plugins()
 *
 * @param crumbs_InjectedAPI_hookCrumbsPlugins $api
 */
function search_api_crumbs_plugins($api) {
  $api->routeTitleCallback(
    'admin/config/search/search_api/index/%',
    'index',
    function($path, $item) {
      $searchApiIndex = $item['map'][5];
      if ($searchApiIndex instanceof SearchApiIndex) {
        return t('Index: @index', array('@index' => $searchApiIndex->name));
      }
      return NULL;
    }
  );
}
donquixote’s picture

Actually the second part is not needed, if search api would fix this issue:
#2700879: Move search_api_admin_item_title() to main *.module file

The first part still totally works, and it would be nice if it could be added somewhere.

donquixote’s picture

Maybe it would be nice if the "admin/config/search/facetapi/%/%/%/edit" would be a "default local task", and "admin/config/search/facetapi/%/%/%" would be the tab root. This would allow jumping between the admin sub-pages of one facet.

donquixote’s picture

If you want to support older PHP versions where closures are not possible, just register a regular callback function. Or create a class.

All the stuff can reside in the main facetapi.module file.

donquixote’s picture

donquixote’s picture

StatusFileSize
new1.59 KB

I don't have time to write a patch atm.
But here is a module that I use myself to improve the UI of facetapi.
Should be not too hard to turn this into a patch..

donquixote’s picture

See https://www.drupal.org/project/facetapiuifix

I think it is ok for now to have this as a distinct module, because it depends on Crumbs.