Deleted a bunch of stuff to do with report entities

because we are not using them at this stage
This commit is contained in:
Naomi 2018-10-01 10:41:32 +01:00
parent a8c454c509
commit 9f735eb492
20 changed files with 0 additions and 740 deletions

View File

@ -1,16 +0,0 @@
.facet-item label {
display: inline;
padding-left: 5px;
}
li.facet-item {
list-style-type: none;
}
#opencase_reporting_buttons {
margin-bottom: 20px;
}
#opencase_reporting_buttons #download-data{
float: right;
}

View File

@ -1,3 +0,0 @@
jQuery('#opencase_reporting_buttons #download-data').click(function() {
location.href = location.href + "&_format=csv";
});

View File

@ -1,30 +0,0 @@
<?php
/**
* @file
* Contains opencase_report.page.inc.
*
* Page callback for OpenCase Report entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for OpenCase Report templates.
*
* Default template: opencase_report.html.twig.
*
* @param array $variables
* An associative array containing:
* - elements: An associative array containing the user information and any
* - attributes: HTML attributes for the containing element.
*/
function template_preprocess_opencase_report(array &$variables) {
// Fetch OpenCaseReport Entity Object.
$opencase_report = $variables['elements']['#opencase_report'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}

View File

@ -1,7 +0,0 @@
opencase-reporting-lib:
version: 1.x
css:
theme:
css/opencase-reporting.css: {}
js:
js/opencase-reporting.js: {}

View File

@ -1,14 +0,0 @@
# OpenCase Report menu items definition
entity.opencase_report.collection:
title: 'OpenCase Report list'
route_name: entity.opencase_report.collection
description: 'List OpenCase Report entities'
parent: system.admin_structure
weight: 100
opencase_report.admin.structure.settings:
title: 'OpenCase Report settings'
description: 'Configure OpenCase Report entities'
route_name: opencase_report.settings
parent: system.admin_structure

View File

@ -1,22 +0,0 @@
# OpenCase Report routing definition
opencase_report.settings_tab:
route_name: opencase_report.settings
title: 'Settings'
base_route: opencase_report.settings
entity.opencase_report.canonical:
route_name: entity.opencase_report.canonical
base_route: entity.opencase_report.canonical
title: 'View'
entity.opencase_report.edit_form:
route_name: entity.opencase_report.edit_form
base_route: entity.opencase_report.canonical
title: 'Edit'
entity.opencase_report.delete_form:
route_name: entity.opencase_report.delete_form
base_route: entity.opencase_report.canonical
title: Delete
weight: 10

View File

@ -23,14 +23,6 @@ function opencase_reporting_help($route_name, RouteMatchInterface $route_match)
}
}
/**
* Implements hook_page_attachments
*
* Add the opencase library to every page
*/
function opencase_reporting_page_attachments(array &$page) {
$page['#attached']['library'][] = 'opencase_reporting/opencase-reporting-lib';
}
/**
* Implements hook_uninstall().

View File

@ -1,19 +0,0 @@
add opencase report entities:
title: 'Create new OpenCase Report entities'
administer opencase report entities:
title: 'Administer OpenCase Report entities'
description: 'Allow to access the administration form to configure OpenCase Report entities.'
restrict access: true
delete opencase report entities:
title: 'Delete OpenCase Report entities'
edit opencase report entities:
title: 'Edit OpenCase Report entities'
view published opencase report entities:
title: 'View published OpenCase Report entities'
view unpublished opencase report entities:
title: 'View unpublished OpenCase Report entities'

View File

@ -1,197 +0,0 @@
<?php
namespace Drupal\opencase_reporting\Entity;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityChangedTrait;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\user\UserInterface;
/**
* Defines the OpenCase Report entity.
*
* @ingroup opencase_reporting
*
* @ContentEntityType(
* id = "opencase_report",
* label = @Translation("OpenCase Report"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\opencase_reporting\OpenCaseReportListBuilder",
* "views_data" = "Drupal\opencase_reporting\Entity\OpenCaseReportViewsData",
* "translation" = "Drupal\opencase_reporting\OpenCaseReportTranslationHandler",
*
* "form" = {
* "default" = "Drupal\opencase_reporting\Form\OpenCaseReportForm",
* "add" = "Drupal\opencase_reporting\Form\OpenCaseReportForm",
* "edit" = "Drupal\opencase_reporting\Form\OpenCaseReportForm",
* "delete" = "Drupal\opencase_reporting\Form\OpenCaseReportDeleteForm",
* },
* "access" = "Drupal\opencase_reporting\OpenCaseReportAccessControlHandler",
* "route_provider" = {
* "html" = "Drupal\opencase_reporting\OpenCaseReportHtmlRouteProvider",
* },
* },
* base_table = "opencase_report",
* data_table = "opencase_report_field_data",
* translatable = TRUE,
* admin_permission = "administer opencase report entities",
* entity_keys = {
* "id" = "id",
* "label" = "name",
* "uuid" = "uuid",
* "uid" = "user_id",
* "langcode" = "langcode",
* "status" = "status",
* },
* links = {
* "canonical" = "/admin/structure/opencase_report/{opencase_report}",
* "add-form" = "/admin/structure/opencase_report/add",
* "edit-form" = "/admin/structure/opencase_report/{opencase_report}/edit",
* "delete-form" = "/admin/structure/opencase_report/{opencase_report}/delete",
* "collection" = "/admin/structure/opencase_report",
* },
* field_ui_base_route = "opencase_report.settings"
* )
*/
class OpenCaseReport extends ContentEntityBase implements OpenCaseReportInterface {
use EntityChangedTrait;
/**
* {@inheritdoc}
*/
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
$values += [
'user_id' => \Drupal::currentUser()->id(),
];
}
/**
* {@inheritdoc}
*/
public function getName() {
return $this->get('name')->value;
}
/**
* {@inheritdoc}
*/
public function setName($name) {
$this->set('name', $name);
return $this;
}
/**
* {@inheritdoc}
*/
public function getCreatedTime() {
return $this->get('created')->value;
}
/**
* {@inheritdoc}
*/
public function setCreatedTime($timestamp) {
$this->set('created', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function getOwner() {
return $this->get('user_id')->entity;
}
/**
* {@inheritdoc}
*/
public function getOwnerId() {
return $this->get('user_id')->target_id;
}
/**
* {@inheritdoc}
*/
public function setOwnerId($uid) {
$this->set('user_id', $uid);
return $this;
}
/**
* {@inheritdoc}
*/
public function setOwner(UserInterface $account) {
$this->set('user_id', $account->id());
return $this;
}
/**
* {@inheritdoc}
*/
public function isPublished() {
return (bool) $this->getEntityKey('status');
}
/**
* {@inheritdoc}
*/
public function setPublished($published) {
$this->set('status', $published ? TRUE : FALSE);
return $this;
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Authored by'))
->setDescription(t('The user ID of author of the OpenCase Report entity.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of the OpenCase Report entity.'))
->setSettings([
'max_length' => 50,
'text_processing' => 0,
])
->setDefaultValue('')
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -4,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -4,
])
->setRequired(TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the OpenCase Report is published.'))
->setDefaultValue(TRUE);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the entity was created.'));
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time that the entity was last edited.'));
return $fields;
}
}

View File

@ -1,77 +0,0 @@
<?php
namespace Drupal\opencase_reporting\Entity;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\user\EntityOwnerInterface;
/**
* Provides an interface for defining OpenCase Report entities.
*
* @ingroup opencase_reporting
*/
interface OpenCaseReportInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface {
// Add get/set methods for your configuration properties here.
/**
* Gets the OpenCase Report name.
*
* @return string
* Name of the OpenCase Report.
*/
public function getName();
/**
* Sets the OpenCase Report name.
*
* @param string $name
* The OpenCase Report name.
*
* @return \Drupal\opencase_reporting\Entity\OpenCaseReportInterface
* The called OpenCase Report entity.
*/
public function setName($name);
/**
* Gets the OpenCase Report creation timestamp.
*
* @return int
* Creation timestamp of the OpenCase Report.
*/
public function getCreatedTime();
/**
* Sets the OpenCase Report creation timestamp.
*
* @param int $timestamp
* The OpenCase Report creation timestamp.
*
* @return \Drupal\opencase_reporting\Entity\OpenCaseReportInterface
* The called OpenCase Report entity.
*/
public function setCreatedTime($timestamp);
/**
* Returns the OpenCase Report published status indicator.
*
* Unpublished OpenCase Report are only visible to restricted users.
*
* @return bool
* TRUE if the OpenCase Report is published.
*/
public function isPublished();
/**
* Sets the published status of a OpenCase Report.
*
* @param bool $published
* TRUE to set this OpenCase Report to published, FALSE to set it to unpublished.
*
* @return \Drupal\opencase_reporting\Entity\OpenCaseReportInterface
* The called OpenCase Report entity.
*/
public function setPublished($published);
}

View File

@ -1,24 +0,0 @@
<?php
namespace Drupal\opencase_reporting\Entity;
use Drupal\views\EntityViewsData;
/**
* Provides Views data for OpenCase Report entities.
*/
class OpenCaseReportViewsData extends EntityViewsData {
/**
* {@inheritdoc}
*/
public function getViewsData() {
$data = parent::getViewsData();
// Additional information for Views integration, such as table joins, can be
// put here.
return $data;
}
}

View File

@ -1,15 +0,0 @@
<?php
namespace Drupal\opencase_reporting\Form;
use Drupal\Core\Entity\ContentEntityDeleteForm;
/**
* Provides a form for deleting OpenCase Report entities.
*
* @ingroup opencase_reporting
*/
class OpenCaseReportDeleteForm extends ContentEntityDeleteForm {
}

View File

@ -1,50 +0,0 @@
<?php
namespace Drupal\opencase_reporting\Form;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;
/**
* Form controller for OpenCase Report edit forms.
*
* @ingroup opencase_reporting
*/
class OpenCaseReportForm extends ContentEntityForm {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
/* @var $entity \Drupal\opencase_reporting\Entity\OpenCaseReport */
$form = parent::buildForm($form, $form_state);
$entity = $this->entity;
return $form;
}
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
$entity = $this->entity;
$status = parent::save($form, $form_state);
switch ($status) {
case SAVED_NEW:
drupal_set_message($this->t('Created the %label OpenCase Report.', [
'%label' => $entity->label(),
]));
break;
default:
drupal_set_message($this->t('Saved the %label OpenCase Report.', [
'%label' => $entity->label(),
]));
}
$form_state->setRedirect('view.opencase_saved_reports.page_1');
}
}

View File

@ -1,53 +0,0 @@
<?php
namespace Drupal\opencase_reporting\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Class OpenCaseReportSettingsForm.
*
* @ingroup opencase_reporting
*/
class OpenCaseReportSettingsForm extends FormBase {
/**
* Returns a unique string identifying the form.
*
* @return string
* The unique string identifying the form.
*/
public function getFormId() {
return 'opencasereport_settings';
}
/**
* Form submission handler.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// Empty implementation of the abstract submit class.
}
/**
* Defines the settings form for OpenCase Report entities.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @return array
* Form definition array.
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['opencasereport_settings']['#markup'] = 'Settings form for OpenCase Report entities. Manage field settings here.';
return $form;
}
}

View File

@ -1,47 +0,0 @@
<?php
namespace Drupal\opencase_reporting;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
/**
* Access controller for the OpenCase Report entity.
*
* @see \Drupal\opencase_reporting\Entity\OpenCaseReport.
*/
class OpenCaseReportAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\opencase_reporting\Entity\OpenCaseReportInterface $entity */
switch ($operation) {
case 'view':
if (!$entity->isPublished()) {
return AccessResult::allowedIfHasPermission($account, 'view unpublished opencase report entities');
}
return AccessResult::allowedIfHasPermission($account, 'view published opencase report entities');
case 'update':
return AccessResult::allowedIfHasPermission($account, 'edit opencase report entities');
case 'delete':
return AccessResult::allowedIfHasPermission($account, 'delete opencase report entities');
}
// Unknown operation, no opinion.
return AccessResult::neutral();
}
/**
* {@inheritdoc}
*/
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return AccessResult::allowedIfHasPermission($account, 'add opencase report entities');
}
}

View File

@ -1,56 +0,0 @@
<?php
namespace Drupal\opencase_reporting;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
use Symfony\Component\Routing\Route;
/**
* Provides routes for OpenCase Report entities.
*
* @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
* @see \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
*/
class OpenCaseReportHtmlRouteProvider extends AdminHtmlRouteProvider {
/**
* {@inheritdoc}
*/
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = parent::getRoutes($entity_type);
$entity_type_id = $entity_type->id();
if ($settings_form_route = $this->getSettingsFormRoute($entity_type)) {
$collection->add("$entity_type_id.settings", $settings_form_route);
}
return $collection;
}
/**
* Gets the settings form route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getSettingsFormRoute(EntityTypeInterface $entity_type) {
if (!$entity_type->getBundleEntityType()) {
$route = new Route("/admin/structure/{$entity_type->id()}/settings");
$route
->setDefaults([
'_form' => 'Drupal\opencase_reporting\Form\OpenCaseReportSettingsForm',
'_title' => "{$entity_type->getLabel()} settings",
])
->setRequirement('_permission', $entity_type->getAdminPermission())
->setOption('_admin_route', TRUE);
return $route;
}
}
}

View File

@ -1,40 +0,0 @@
<?php
namespace Drupal\opencase_reporting;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Link;
/**
* Defines a class to build a listing of OpenCase Report entities.
*
* @ingroup opencase_reporting
*/
class OpenCaseReportListBuilder extends EntityListBuilder {
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header['id'] = $this->t('OpenCase Report ID');
$header['name'] = $this->t('Name');
return $header + parent::buildHeader();
}
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
/* @var $entity \Drupal\opencase_reporting\Entity\OpenCaseReport */
$row['id'] = $entity->id();
$row['name'] = Link::createFromRoute(
$entity->label(),
'entity.opencase_report.edit_form',
['opencase_report' => $entity->id()]
);
return $row + parent::buildRow($entity);
}
}

View File

@ -1,14 +0,0 @@
<?php
namespace Drupal\opencase_reporting;
use Drupal\content_translation\ContentTranslationHandler;
/**
* Defines the translation handler for opencase_report.
*/
class OpenCaseReportTranslationHandler extends ContentTranslationHandler {
// Override here the needed methods from ContentTranslationHandler.
}

View File

@ -1,26 +0,0 @@
<?php
namespace Drupal\opencase_reporting\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
* Provides a 'ReportForm' block.
*
* @Block(
* id = "opencase_report_form",
* admin_label = @Translation("Report form"),
* )
*/
class ReportForm extends BlockBase {
/**
* {@inheritdoc}
*/
public function build() {
$report = \Drupal::entityManager()->getStorage('opencase_report')->create();
$form = \Drupal::service('entity.form_builder')->getForm($report, 'add');
return $form;
}
}

View File

@ -1,22 +0,0 @@
{#
/**
* @file opencase_report.html.twig
* Default theme implementation to present OpenCase Report data.
*
* This template is used when viewing OpenCase Report pages.
*
*
* Available variables:
* - content: A list of content items. Use 'content' to print all content, or
* - attributes: HTML attributes for the container element.
*
* @see template_preprocess_opencase_report()
*
* @ingroup themeable
*/
#}
<div{{ attributes.addClass('opencase_report') }}>
{% if content %}
{{- content -}}
{% endif %}
</div>