added case view to person panel.
This commit is contained in:
parent
0cc4d50d71
commit
b853704700
@ -51,7 +51,7 @@ use Drupal\user\UserInterface;
|
||||
* links = {
|
||||
* "canonical" = "/admin/structure/case_entity/{case_entity}",
|
||||
* "add-page" = "/admin/structure/case_entity/add",
|
||||
* "add-form" = "/admin/structure/case_entity/add/{case_entity_type}",
|
||||
* "add-form" = "/zencrm/case/add/{case_entity_type}",
|
||||
* "edit-form" = "/admin/structure/case_entity/{case_entity}/edit",
|
||||
* "delete-form" = "/admin/structure/case_entity/{case_entity}/delete",
|
||||
* "collection" = "/admin/structure/case_entity",
|
||||
|
@ -9,6 +9,7 @@ use Drupal\Core\Block\BlockBase;
|
||||
* If the person has no contact details it advises to create them.
|
||||
* Hats cannot be created without contact details.
|
||||
* If they have contact details but no hats, it advises to create a hat.
|
||||
* Otherwise display the case view for each hat, and links to create new cases.
|
||||
*
|
||||
* @Block(
|
||||
* id = "person_panel",
|
||||
@ -25,6 +26,7 @@ class PersonPanel extends BlockBase {
|
||||
$markup = "";
|
||||
$person = \Drupal::entityTypeManager()->getStorage('person')->load($person_id);
|
||||
|
||||
|
||||
// If the person has no contact details, suggest they create some
|
||||
$link_to_add = "/zencrm/contact_details/$person_id/add?destination=/zencrm/person/$person_id";
|
||||
$contact_details = \Drupal::entityTypeManager()
|
||||
@ -47,6 +49,12 @@ class PersonPanel extends BlockBase {
|
||||
$plugin_manager = \Drupal::service('plugin.manager.block');
|
||||
$block = $plugin_manager->createInstance('hat_creator', array());
|
||||
$markup .= render($block->build());
|
||||
} else {
|
||||
|
||||
// they have hats, so display the case view for each hat.
|
||||
foreach($hats as $hat) {
|
||||
$markup .= $this->show_cases_for_hat($hat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,8 +62,16 @@ class PersonPanel extends BlockBase {
|
||||
'#cache' => [
|
||||
'max-age' => 0,
|
||||
],
|
||||
'#markup' => "<div>$markup</div>"
|
||||
'#markup' => "<div id = 'zencrm_personpanel'>$markup</div>"
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
private function show_cases_for_hat($hat) {
|
||||
$markup = '';
|
||||
$markup .= "<p class='zencrm_hat_name'>" . $hat->name->getString() . "</p>";
|
||||
$markup .= drupal_render(views_embed_view('this_hat_s_cases', 'block_1', $hat->id()));
|
||||
error_log(print_r(views_embed_view('this_hat_s_cases', 'block_1', $hat->id()), true));
|
||||
return $markup;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user