removed redundant .js files, enabled redux store for amka element, updated...

removed redundant .js files, enabled redux store for amka element, updated region.schools component to populate exclusively schools that offer the selected sector in case of B class students, added EepalSectorsInEpal entity in epalreadydata drupal module
parent 654bb969
<?php
/**
* @file
* Contains eepal_sectors_in_epal.page.inc.
*
* Page callback for Eepal sectors in epal entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for Eepal sectors in epal templates.
*
* Default template: eepal_sectors_in_epal.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_eepal_sectors_in_epal(array &$variables) {
// Fetch EepalSectorsInEpal Entity Object.
$eepal_sectors_in_epal = $variables['elements']['#eepal_sectors_in_epal'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
......@@ -33,3 +33,8 @@ entity.eepal_sectors.add_form:
title: 'Add Eepal sectors'
appears_on:
- entity.eepal_sectors.collection
entity.eepal_sectors_in_epal.add_form:
route_name: entity.eepal_sectors_in_epal.add_form
title: 'Add Eepal sectors in epal'
appears_on:
- entity.eepal_sectors_in_epal.collection
......@@ -96,3 +96,17 @@ eepal_sectors.admin.structure.settings:
description: 'Configure Eepal sectors entities'
route_name: eepal_sectors.settings
parent: system.admin_structure
# Eepal sectors in epal menu items definition
entity.eepal_sectors_in_epal.collection:
title: 'Eepal sectors in epal list'
route_name: entity.eepal_sectors_in_epal.collection
description: 'List Eepal sectors in epal entities'
parent: system.admin_structure
weight: 100
eepal_sectors_in_epal.admin.structure.settings:
title: Eepal sectors in epal settings
description: 'Configure Eepal sectors in epal entities'
route_name: eepal_sectors_in_epal.settings
parent: system.admin_structure
......@@ -152,3 +152,25 @@ entity.eepal_sectors.delete_form:
title: Delete
weight: 10
# Eepal sectors in epal routing definition
eepal_sectors_in_epal.settings_tab:
route_name: eepal_sectors_in_epal.settings
title: 'Settings'
base_route: eepal_sectors_in_epal.settings
entity.eepal_sectors_in_epal.canonical:
route_name: entity.eepal_sectors_in_epal.canonical
base_route: entity.eepal_sectors_in_epal.canonical
title: 'View'
entity.eepal_sectors_in_epal.edit_form:
route_name: entity.eepal_sectors_in_epal.edit_form
base_route: entity.eepal_sectors_in_epal.canonical
title: 'Edit'
entity.eepal_sectors_in_epal.delete_form:
route_name: entity.eepal_sectors_in_epal.delete_form
base_route: entity.eepal_sectors_in_epal.canonical
title: Delete
weight: 10
......@@ -152,3 +152,25 @@ view published eepal sectors entities:
view unpublished eepal sectors entities:
title: 'View unpublished Eepal sectors entities'
add eepal sectors in epal entities:
title: 'Create new Eepal sectors in epal entities'
administer eepal sectors in epal entities:
title: 'Administer Eepal sectors in epal entities'
description: 'Allow to access the administration form to configure Eepal sectors in epal entities.'
restrict access: true
delete eepal sectors in epal entities:
title: 'Delete Eepal sectors in epal entities'
edit eepal sectors in epal entities:
title: 'Edit Eepal sectors in epal entities'
access eepal sectors in epal overview:
title: 'Access the Eepal sectors in epal overview page'
view published eepal sectors in epal entities:
title: 'View published Eepal sectors in epal entities'
view unpublished eepal sectors in epal entities:
title: 'View unpublished Eepal sectors in epal entities'
<?php
namespace Drupal\epalreadydata;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
/**
* Access controller for the Eepal sectors in epal entity.
*
* @see \Drupal\epalreadydata\Entity\EepalSectorsInEpal.
*/
class EepalSectorsInEpalAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\epalreadydata\Entity\EepalSectorsInEpalInterface $entity */
switch ($operation) {
case 'view':
if (!$entity->isPublished()) {
return AccessResult::allowedIfHasPermission($account, 'view unpublished eepal sectors in epal entities');
}
return AccessResult::allowedIfHasPermission($account, 'view published eepal sectors in epal entities');
case 'update':
return AccessResult::allowedIfHasPermission($account, 'edit eepal sectors in epal entities');
case 'delete':
return AccessResult::allowedIfHasPermission($account, 'delete eepal sectors in epal entities');
}
// Unknown operation, no opinion.
return AccessResult::neutral();
}
/**
* {@inheritdoc}
*/
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return AccessResult::allowedIfHasPermission($account, 'add eepal sectors in epal entities');
}
}
<?php
namespace Drupal\epalreadydata;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
use Symfony\Component\Routing\Route;
/**
* Provides routes for Eepal sectors in epal entities.
*
* @see Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
* @see Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
*/
class EepalSectorsInEpalHtmlRouteProvider extends AdminHtmlRouteProvider {
/**
* {@inheritdoc}
*/
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = parent::getRoutes($entity_type);
$entity_type_id = $entity_type->id();
if ($collection_route = $this->getCollectionRoute($entity_type)) {
$collection->add("entity.{$entity_type_id}.collection", $collection_route);
}
if ($settings_form_route = $this->getSettingsFormRoute($entity_type)) {
$collection->add("$entity_type_id.settings", $settings_form_route);
}
return $collection;
}
/**
* Gets the collection route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getCollectionRoute(EntityTypeInterface $entity_type) {
if ($entity_type->hasLinkTemplate('collection') && $entity_type->hasListBuilderClass()) {
$entity_type_id = $entity_type->id();
$route = new Route($entity_type->getLinkTemplate('collection'));
$route
->setDefaults([
'_entity_list' => $entity_type_id,
'_title' => "{$entity_type->getLabel()} list",
])
->setRequirement('_permission', 'access eepal sectors in epal overview')
->setOption('_admin_route', TRUE);
return $route;
}
}
/**
* 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\epalreadydata\Form\EepalSectorsInEpalSettingsForm',
'_title' => "{$entity_type->getLabel()} settings",
])
->setRequirement('_permission', $entity_type->getAdminPermission())
->setOption('_admin_route', TRUE);
return $route;
}
}
}
<?php
namespace Drupal\epalreadydata;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Routing\LinkGeneratorTrait;
use Drupal\Core\Url;
/**
* Defines a class to build a listing of Eepal sectors in epal entities.
*
* @ingroup epalreadydata
*/
class EepalSectorsInEpalListBuilder extends EntityListBuilder {
use LinkGeneratorTrait;
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header['id'] = $this->t('Eepal sectors in epal ID');
$header['name'] = $this->t('Name');
return $header + parent::buildHeader();
}
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
/* @var $entity \Drupal\epalreadydata\Entity\EepalSectorsInEpal */
$row['id'] = $entity->id();
$row['name'] = $this->l(
$entity->label(),
new Url(
'entity.eepal_sectors_in_epal.edit_form', array(
'eepal_sectors_in_epal' => $entity->id(),
)
)
);
return $row + parent::buildRow($entity);
}
}
<?php
namespace Drupal\epalreadydata;
use Drupal\content_translation\ContentTranslationHandler;
/**
* Defines the translation handler for eepal_sectors_in_epal.
*/
class EepalSectorsInEpalTranslationHandler extends ContentTranslationHandler {
// Override here the needed methods from ContentTranslationHandler.
}
......@@ -180,7 +180,7 @@ class EepalSchool extends ContentEntityBase implements EepalSchoolInterface {
->setLabel(t('Name'))
->setDescription(t('The name of the Eepal school entity.'))
->setSettings(array(
'max_length' => 80,
'max_length' => 140,
'text_processing' => 0,
))
->setDefaultValue('')
......
<?php
namespace Drupal\epalreadydata\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 Eepal sectors in epal entity.
*
* @ingroup epalreadydata
*
* @ContentEntityType(
* id = "eepal_sectors_in_epal",
* label = @Translation("Eepal sectors in epal"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\epalreadydata\EepalSectorsInEpalListBuilder",
* "views_data" = "Drupal\epalreadydata\Entity\EepalSectorsInEpalViewsData",
* "translation" = "Drupal\epalreadydata\EepalSectorsInEpalTranslationHandler",
*
* "form" = {
* "default" = "Drupal\epalreadydata\Form\EepalSectorsInEpalForm",
* "add" = "Drupal\epalreadydata\Form\EepalSectorsInEpalForm",
* "edit" = "Drupal\epalreadydata\Form\EepalSectorsInEpalForm",
* "delete" = "Drupal\epalreadydata\Form\EepalSectorsInEpalDeleteForm",
* },
* "access" = "Drupal\epalreadydata\EepalSectorsInEpalAccessControlHandler",
* "route_provider" = {
* "html" = "Drupal\epalreadydata\EepalSectorsInEpalHtmlRouteProvider",
* },
* },
* base_table = "eepal_sectors_in_epal",
* data_table = "eepal_sectors_in_epal_field_data",
* translatable = TRUE,
* admin_permission = "administer eepal sectors in epal entities",
* entity_keys = {
* "id" = "id",
* "label" = "name",
* "uuid" = "uuid",
* "uid" = "user_id",
* "langcode" = "langcode",
* "status" = "status",
* },
* links = {
* "canonical" = "/admin/structure/eepal_sectors_in_epal/{eepal_sectors_in_epal}",
* "add-form" = "/admin/structure/eepal_sectors_in_epal/add",
* "edit-form" = "/admin/structure/eepal_sectors_in_epal/{eepal_sectors_in_epal}/edit",
* "delete-form" = "/admin/structure/eepal_sectors_in_epal/{eepal_sectors_in_epal}/delete",
* "collection" = "/admin/structure/eepal_sectors_in_epal",
* },
* field_ui_base_route = "eepal_sectors_in_epal.settings"
* )
*/
class EepalSectorsInEpal extends ContentEntityBase implements EepalSectorsInEpalInterface {
use EntityChangedTrait;
/**
* {@inheritdoc}
*/
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
$values += array(
'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 Eepal sectors in epal entity.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
))
->setDisplayOptions('form', array(
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => array(
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
),
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Ονομασία'))
->setDescription(t('Ονομασία.'))
->setSettings(array(
'max_length' => 50,
'text_processing' => 0,
))
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['epal_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Σχολείο επιλογής'))
->setDescription(t('Σχολείο επιλογής.'))
->setSetting('target_type', 'eepal_school')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
))
->setDisplayOptions('form', array(
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => array(
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
),
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['sector_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Τομέας επιλογής'))
->setDescription(t('Τομέας επιλογής.'))
->setSetting('target_type', 'eepal_sectors')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
))
->setDisplayOptions('form', array(
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => array(
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
),
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the Eepal sectors in epal 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;
}
}
<?php
namespace Drupal\epalreadydata\Entity;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\user\EntityOwnerInterface;
/**
* Provides an interface for defining Eepal sectors in epal entities.
*
* @ingroup epalreadydata
*/
interface EepalSectorsInEpalInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface {
// Add get/set methods for your configuration properties here.
/**
* Gets the Eepal sectors in epal name.
*
* @return string
* Name of the Eepal sectors in epal.
*/
public function getName();
/**
* Sets the Eepal sectors in epal name.
*
* @param string $name
* The Eepal sectors in epal name.
*
* @return \Drupal\epalreadydata\Entity\EepalSectorsInEpalInterface
* The called Eepal sectors in epal entity.
*/
public function setName($name);
/**
* Gets the Eepal sectors in epal creation timestamp.
*
* @return int