New activity gets its case from the url
This commit is contained in:
parent
59964e653e
commit
7cf4ee557b
@ -74,6 +74,13 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
|
|||||||
|
|
||||||
use EntityChangedTrait;
|
use EntityChangedTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When creating an activity, it sets the case id from the URL.
|
||||||
|
*/
|
||||||
|
public static function defaultVal() {
|
||||||
|
return \Drupal::request()->query->get('case_id');;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -267,6 +274,7 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
|
|||||||
'placeholder' => '',
|
'placeholder' => '',
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
|
->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCActivity::defaultVal')
|
||||||
->setRequired(TRUE);
|
->setRequired(TRUE);
|
||||||
|
|
||||||
$fields['status'] = BaseFieldDefinition::create('boolean')
|
$fields['status'] = BaseFieldDefinition::create('boolean')
|
||||||
|
@ -72,6 +72,7 @@ use Drupal\user\UserInterface;
|
|||||||
*/
|
*/
|
||||||
class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
||||||
|
|
||||||
|
use EntityChangedTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When creating a case, it sets the first involved party to the actor
|
* When creating a case, it sets the first involved party to the actor
|
||||||
@ -81,8 +82,6 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
|||||||
return \Drupal::request()->query->get('actor_id');;
|
return \Drupal::request()->query->get('actor_id');;
|
||||||
}
|
}
|
||||||
|
|
||||||
use EntityChangedTrait;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -30,6 +30,12 @@ class ContextualMenu extends BlockBase {
|
|||||||
case 'view.cases.page_1':
|
case 'view.cases.page_1':
|
||||||
$markup = $this->caseListPage();
|
$markup = $this->caseListPage();
|
||||||
break;
|
break;
|
||||||
|
case 'entity.oc_case.canonical':
|
||||||
|
$markup = $this->casePage();
|
||||||
|
break;
|
||||||
|
case 'view.activities.page_1':
|
||||||
|
$markup = $this->activityListPage();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$build = [];
|
$build = [];
|
||||||
@ -68,15 +74,26 @@ class ContextualMenu extends BlockBase {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Contextual menu for Case page
|
* Contextual menu for Case page
|
||||||
|
* - Link to Activity list
|
||||||
*/
|
*/
|
||||||
private function casePage($case_id) {
|
private function casePage() {
|
||||||
|
$case = \Drupal::routeMatch()->getParameter('oc_case');
|
||||||
|
$url = Url::fromRoute('view.activities.page_1', array('case_id' => $case->id()));
|
||||||
|
$link = Link::fromTextAndUrl(t("Activity List"), $url)->toString();
|
||||||
|
return "<div class='opencase_nav_links'><p>$link</p></div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contextual menu for Activity list page
|
* Contextual menu for Activity list page
|
||||||
|
* - Link to case
|
||||||
|
* - Links to add activities of various types
|
||||||
*/
|
*/
|
||||||
private function activityListPage($case_id) {
|
private function activityListPage() {
|
||||||
|
$case_id = \Drupal::routeMatch()->getParameter('case_id');
|
||||||
|
$case = \Drupal::entityTypeManager()->getStorage('oc_case')->load($case_id);
|
||||||
|
$link = $case->toLink()->toString();
|
||||||
|
$markup = "<div class='opencase_nav_links'><p>$link</p></div>";
|
||||||
|
$markup .= Utils::generateAddLinks('oc_activity', ['case_id' => $case_id]);
|
||||||
|
return $markup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user