Commit bb53e928 authored by Νίκος Κατσαούνος's avatar Νίκος Κατσαούνος
Browse files

added SchoolOrderSelect component, added ApplicationSubmit component, added...

added SchoolOrderSelect component, added ApplicationSubmit component, added EpalStudntSectorField entity to Drupal Epal module, code review
parent f7f08204
......@@ -23,3 +23,8 @@ entity.epal_users.add_form:
title: 'Add Epal users'
appears_on:
- entity.epal_users.collection
entity.epal_student_sector_field.add_form:
route_name: entity.epal_student_sector_field.add_form
title: 'Add Epal student sector field'
appears_on:
- entity.epal_student_sector_field.collection
......@@ -68,3 +68,17 @@ epal_users.admin.structure.settings:
description: 'Configure Epal users entities'
route_name: epal_users.settings
parent: system.admin_structure
# Epal student sector field menu items definition
entity.epal_student_sector_field.collection:
title: 'Epal student sector field list'
route_name: entity.epal_student_sector_field.collection
description: 'List Epal student sector field entities'
parent: system.admin_structure
weight: 100
epal_student_sector_field.admin.structure.settings:
title: Epal student sector field settings
description: 'Configure Epal student sector field entities'
route_name: epal_student_sector_field.settings
parent: system.admin_structure
......@@ -108,3 +108,25 @@ entity.epal_users.delete_form:
title: Delete
weight: 10
# Epal student sector field routing definition
epal_student_sector_field.settings_tab:
route_name: epal_student_sector_field.settings
title: 'Settings'
base_route: epal_student_sector_field.settings
entity.epal_student_sector_field.canonical:
route_name: entity.epal_student_sector_field.canonical
base_route: entity.epal_student_sector_field.canonical
title: 'View'
entity.epal_student_sector_field.edit_form:
route_name: entity.epal_student_sector_field.edit_form
base_route: entity.epal_student_sector_field.canonical
title: 'Edit'
entity.epal_student_sector_field.delete_form:
route_name: entity.epal_student_sector_field.delete_form
base_route: entity.epal_student_sector_field.canonical
title: Delete
weight: 10
......@@ -108,3 +108,25 @@ view published epal users entities:
view unpublished epal users entities:
title: 'View unpublished Epal users entities'
add epal student sector field entities:
title: 'Create new Epal student sector field entities'
administer epal student sector field entities:
title: 'Administer Epal student sector field entities'
description: 'Allow to access the administration form to configure Epal student sector field entities.'
restrict access: true
delete epal student sector field entities:
title: 'Delete Epal student sector field entities'
edit epal student sector field entities:
title: 'Edit Epal student sector field entities'
access epal student sector field overview:
title: 'Access the Epal student sector field overview page'
view published epal student sector field entities:
title: 'View published Epal student sector field entities'
view unpublished epal student sector field entities:
title: 'View unpublished Epal student sector field entities'
<?php
/**
* @file
* Contains epal_student_sector_field.page.inc.
*
* Page callback for Epal student sector field entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for Epal student sector field templates.
*
* Default template: epal_student_sector_field.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_epal_student_sector_field(array &$variables) {
// Fetch EpalStudentSectorField Entity Object.
$epal_student_sector_field = $variables['elements']['#epal_student_sector_field'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
......@@ -206,26 +206,32 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
return $this;
}
public function getBirthdate() {
return $this->get('birthdate')->value;
}
public function setBirthdate($name) {
$this->set('birthdate', $name);
return $this;
}
/*
public function getGuardianFirstname() {
return $this->get('guardianfirstname')->value;
public function getFatherFirstname() {
return $this->get('fatherfirstname')->value;
}
public function setGuardianFirstname($name) {
$this->set('guardianfirstname', $name);
public function setFatherFirstname($name) {
$this->set('fatherfirstname', $name);
return $this;
}
public function getGuardianSurname() {
return $this->get('guardiansurname')->value;
public function getMotherSurname() {
return $this->get('mothersurname')->value;
}
public function setGuardianSurname($name) {
$this->set('guardiansurname', $name);
public function setMotherSurname($name) {
$this->set('mothersurname', $name);
return $this;
}
*/
/**
* {@inheritdoc}
......@@ -477,7 +483,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
/*
$fields['birthdate'] = BaseFieldDefinition::create('datetime')
->setLabel(t('Ημερομηνία γέννησης μαθητή'))
->setDescription(t('Δώσε την Ημερομηνία γέννησης μαθητή.'))
......@@ -493,7 +499,7 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
*/
/*
$fields['guardianADT'] = BaseFieldDefinition::create('string')
......@@ -517,16 +523,15 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
->setDisplayConfigurable('view', TRUE);
*/
/*
$fields['guardianfirstname'] = BaseFieldDefinition::create('string')
->setLabel(t('Όνομα του κηδεμόνα'))
->setDescription(t('Δώσε το όνομα του κηδεμόνα.'))
$fields['fatherfirstname'] = BaseFieldDefinition::create('string')
->setLabel(t('Όνομα του πατέρα'))
->setDescription(t('Δώσε το όνομα του πατέρα.'))
->setSettings(array(
'max_length' => 50,
'text_processing' => 0,
))
->setRequired(true)
->setRequired(false)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -540,14 +545,14 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['guardiansurname'] = BaseFieldDefinition::create('string')
->setLabel(t('Επώνυμο κηδεμόνα'))
->setDescription(t('Δώσε το επώνυμο του κηδεμόνα.'))
$fields['fathersurname'] = BaseFieldDefinition::create('string')
->setLabel(t('Επώνυμο πατέρα'))
->setDescription(t('Δώσε το επώνυμο του πατέρα.'))
->setSettings(array(
'max_length' => 50,
'text_processing' => 0,
))
->setRequired(true)
->setRequired(false)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -560,7 +565,49 @@ class EpalStudent extends ContentEntityBase implements EpalStudentInterface {
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
*/
$fields['motherfirstname'] = BaseFieldDefinition::create('string')
->setLabel(t('Όνομα μητέρας'))
->setDescription(t('Δώσε το όνομα της μητέρας.'))
->setSettings(array(
'max_length' => 50,
'text_processing' => 0,
))
->setRequired(false)
->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['mothersurname'] = BaseFieldDefinition::create('string')
->setLabel(t('Επώνυμο μητέρας'))
->setDescription(t('Δώσε το επώνυμο της μητέρας.'))
->setSettings(array(
'max_length' => 50,
'text_processing' => 0,
))
->setRequired(false)
->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['studentamka'] = BaseFieldDefinition::create('string')
->setLabel(t('ΑΜΚΑ μαθητή'))
......
......@@ -150,15 +150,15 @@ class EpalStudentCourseField extends ContentEntityBase implements EpalStudentCou
/**
* {@inheritdoc}
*/
public function getCourseField_id() {
return $this->get('courseField_id')->getString();
public function getCoursefield_id() {
return $this->get('coursefield_id')->getString();
}
/**
* {@inheritdoc}
*/
public function setCourseField_id($name) {
$this->set('courseField_id', $name);
public function setCoursefield_id($name) {
$this->set('coursefield_id', $name);
return $this;
}
......@@ -256,7 +256,7 @@ class EpalStudentCourseField extends ContentEntityBase implements EpalStudentCou
->setDisplayConfigurable('view', TRUE);
$fields['courseField_id'] = BaseFieldDefinition::create('entity_reference')
$fields['coursefield_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('ID ειδικότητας'))
->setDescription(t('Δώσε το id ειδικότητας που επέλεξε ο μαθητής.'))
->setSetting('target_type', 'eepal_specialty')
......
......@@ -75,8 +75,8 @@ interface EpalStudentCourseFieldInterface extends ContentEntityInterface, Entit
public function setPublished($published);
//get/set methods for additional fields for configuration properties.
public function getCourseField_id();
public function setCourseField_id($val);
public function getCoursefield_id();
public function setCoursefield_id($val);
public function getStudent_id();
public function setStudent_id($val);
......
......@@ -81,10 +81,12 @@ interface EpalStudentInterface extends ContentEntityInterface, EntityChangedInt
public function setEpaluser_id($val);
public function getStudentSurname();
public function setStudentSurname($val);
//public function getGuardianFirstname();
//public function setGuardianFirstname($val);
//public function getGuardianSurname();
//public function setGuardianSurname($val);
public function getBirthdate();
public function setBirthdate($val);
public function getFatherFirstname();
public function setFatherFirstname($val);
public function getMotherSurname();
public function setMotherSurname($val);
public function getStudentAmka();
public function setStudentAmka($val);
public function getRegionAddress();
......
<?php
namespace Drupal\epal\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 Epal student sector field entity.
*
* @ingroup epal
*
* @ContentEntityType(
* id = "epal_student_sector_field",
* label = @Translation("Epal student sector field"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\epal\EpalStudentSectorFieldListBuilder",
* "views_data" = "Drupal\epal\Entity\EpalStudentSectorFieldViewsData",
* "translation" = "Drupal\epal\EpalStudentSectorFieldTranslationHandler",
*
* "form" = {
* "default" = "Drupal\epal\Form\EpalStudentSectorFieldForm",
* "add" = "Drupal\epal\Form\EpalStudentSectorFieldForm",
* "edit" = "Drupal\epal\Form\EpalStudentSectorFieldForm",
* "delete" = "Drupal\epal\Form\EpalStudentSectorFieldDeleteForm",
* },
* "access" = "Drupal\epal\EpalStudentSectorFieldAccessControlHandler",
* "route_provider" = {
* "html" = "Drupal\epal\EpalStudentSectorFieldHtmlRouteProvider",
* },
* },
* base_table = "epal_student_sector_field",
* data_table = "epal_student_sector_field_field_data",
* translatable = TRUE,
* admin_permission = "administer epal student sector field entities",
* entity_keys = {
* "id" = "id",
* "label" = "name",
* "uuid" = "uuid",
* "uid" = "user_id",
* "langcode" = "langcode",
* "status" = "status",
* },
* links = {
* "canonical" = "/admin/structure/epal_student_sector_field/{epal_student_sector_field}",
* "add-form" = "/admin/structure/epal_student_sector_field/add",
* "edit-form" = "/admin/structure/epal_student_sector_field/{epal_student_sector_field}/edit",
* "delete-form" = "/admin/structure/epal_student_sector_field/{epal_student_sector_field}/delete",
* "collection" = "/admin/structure/epal_student_sector_field",
* },
* field_ui_base_route = "epal_student_sector_field.settings"
* )
*/
class EpalStudentSectorField extends ContentEntityBase implements EpalStudentSectorFieldInterface {
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 function getSectorfield_id() {
return $this->get('sectorfield_id')->getString();
}
/**
* {@inheritdoc}
*/
public function setSectorfield_id($name) {
$this->set('sectorfield_id', $name);
return $this;
}
/**
* {@inheritdoc}
*/
public function getStudent_id() {
return $this->get('student_id')->getString();
}
/**
* {@inheritdoc}
*/
public function setStudent_id($name) {
$this->set('student_id', $name);
return $this;
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Δημιουργός'))
->setDescription(t('Δημιουργός.'))
->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['student_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('ID Μαθητή'))
->setDescription(t('Δώσε το id μαθητή.'))
->setSetting('target_type', 'epal_student')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'author',
'weight' => -4,
))
->setRequired(true)
->setDisplayOptions('form', array(
'type' => 'entity_reference_autocomplete',
'weight' => -4,
'settings' => array(
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
),
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['sectorfield_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('ID τομέα'))
->setDescription(t('Δώσε το id τομέα που επέλεξε ο μαθητής.'))
->setSetting('target_type', 'eepal_sectors')
->setSetting('handler', 'default')
->setRequired(true)
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'author',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'entity_reference_autocomplete',
'weight' => -4,
'settings' => array(
'match_operator' => 'CONTAINS',
'size' => '60',