Added links for creating cases, to person panel
Plus some markup ready for css
This commit is contained in:
parent
65efcb21b4
commit
12ccecdd55
@ -38,7 +38,7 @@ class HatCreator extends BlockBase {
|
|||||||
'#cache' => [
|
'#cache' => [
|
||||||
'max-age' => 0,
|
'max-age' => 0,
|
||||||
],
|
],
|
||||||
'#markup' => "<div>$markup</div>"
|
'#markup' => "<div class='zencrm_creation_links'>$markup</div>"
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ class PersonPanel extends BlockBase {
|
|||||||
->getStorage('contact_details')
|
->getStorage('contact_details')
|
||||||
->loadByProperties(['person' => $person_id]);
|
->loadByProperties(['person' => $person_id]);
|
||||||
if (!reset($contact_details)) {
|
if (!reset($contact_details)) {
|
||||||
$markup .= "<p>This person has no contact details yet. To get started, ";
|
$markup .= "<p class='zencrm_fyi'>This person has no contact details yet. To get started, ";
|
||||||
$markup .= "<a class='use-ajax' data-dialog-type='modal' href = $link_to_add>Add a set of contact details</a>";
|
$markup .= "<a class='use-ajax' data-dialog-type='modal' href = $link_to_add>Add a set of contact details</a>";
|
||||||
$markup .= "</p>";
|
$markup .= "</p>";
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class PersonPanel extends BlockBase {
|
|||||||
->getStorage('hat')
|
->getStorage('hat')
|
||||||
->loadByProperties(['person' => $person_id]);
|
->loadByProperties(['person' => $person_id]);
|
||||||
if (!reset($hats)) {
|
if (!reset($hats)) {
|
||||||
$markup .= "<p>This person has no hats yet. A hat is a role that the person plays in the organisation. To get started, add a hat for this person. </p>";
|
$markup .= "<p class='zencrm_fyi'>This person has no hats yet. A hat is a role that the person plays in the organisation. To get started, add a hat for this person. </p>";
|
||||||
$plugin_manager = \Drupal::service('plugin.manager.block');
|
$plugin_manager = \Drupal::service('plugin.manager.block');
|
||||||
$block = $plugin_manager->createInstance('hat_creator', array());
|
$block = $plugin_manager->createInstance('hat_creator', array());
|
||||||
$markup .= render($block->build());
|
$markup .= render($block->build());
|
||||||
@ -53,7 +53,8 @@ class PersonPanel extends BlockBase {
|
|||||||
|
|
||||||
// they have hats, so display the case view for each hat.
|
// they have hats, so display the case view for each hat.
|
||||||
foreach($hats as $hat) {
|
foreach($hats as $hat) {
|
||||||
$markup .= $this->show_cases_for_hat($hat);
|
$markup .= $this->showCases($hat);
|
||||||
|
$markup .= $this->showCaseCreationLinks($hat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,11 +68,22 @@ class PersonPanel extends BlockBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function show_cases_for_hat($hat) {
|
// Renders a view showing cases that hat is involved in.
|
||||||
|
private function showCases($hat) {
|
||||||
$markup = '';
|
$markup = '';
|
||||||
$markup .= "<p class='zencrm_hat_name'>" . $hat->name->getString() . "</p>";
|
$markup .= "<h2>" . $hat->name->getString() . "</h2>";
|
||||||
$markup .= drupal_render(views_embed_view('this_hat_s_cases', 'block_1', $hat->id()));
|
$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 "<div id='zencrm_hat_cases'>$markup</div>";
|
||||||
return $markup;
|
}
|
||||||
|
|
||||||
|
// Provides links to create different types of cases, passing in the hat id.
|
||||||
|
private function showCaseCreationLinks($hat) {
|
||||||
|
$hat_id = $hat->id();
|
||||||
|
$case_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('case_entity');
|
||||||
|
foreach($case_types as $case_type_id => $type) {
|
||||||
|
$label = $type['label'];
|
||||||
|
$markup .= "<p><a class='use-ajax' data-dialog-type='modal' href='/zencrm/case/$hat_id/add/$case_type_id?destination=/zencrm/hat/$hat_id'>Add a $label Case</a></p>";
|
||||||
|
}
|
||||||
|
return "<div class='zencrm_creationlinks'>$markup</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user