Commit 63c6f2ed authored by Αχιλλέας Κατσαρός's avatar Αχιλλέας Κατσαρός

Merge branch 'new_feature8' into 'develop'

changes maincustoform

See merge request !10
parents b614e4b3 1d3908d3
.progressbar-wrapper{padding:25px;background:#fff;border-radius:4px;text-align:center}.f1-steps{overflow:hidden;position:relative;margin-top:20px}.f1-progress{position:absolute;top:24px;left:0;width:100%;height:1px;background:#ddd}.f1-progress-line{position:absolute;top:0;left:0;height:1px;background:#466bc8}.f1-step{position:relative;float:left;width:33.3333%;padding:0 5px}.f1-step-icon{display:inline-block;width:40px;height:40px;margin-top:4px;background:#ddd;font-size:16px;color:#fff;line-height:40px;border-radius:50%}.f1-step.activated .f1-step-icon{background:#fff;border:1px solid #466bc8;color:#466bc8;line-height:38px}.f1-step.active .f1-step-icon{width:48px;height:48px;margin-top:0;background:#466bc8;font-size:22px;line-height:48px}.f1-step p{color:#ccc}.f1-step.activated p{color:#466bc8}.f1-step.active p{color:#466bc8}form.multistep-two-form h2.form-title{padding:15px}form.multistep-two-form .form-group{margin-bottom:1.2em;overflow:hidden}form.multistep-two-form .form-group label{float:left;width:28%;padding-right:10px;padding-top:8px;text-align:left}form.multistep-two-form .form-group .form-control{font-size:16px;padding:4px 8px;height:36px;width:72%;float:left;border-radius:4px !important}form.multistep-two-form .form-group .form-control[disabled]{background-color:grey;opacity:0.55;color:white;font-weight:bold}form.multistep-two-form .less-p label{padding-top:0}form.multistep-two-form #edit-sex--wrapper{padding-bottom:15px}form.multistep-two-form #edit-sex--wrapper legend{float:left;width:25%;font-size:18px;font-weight:bold;border-style:none}form.multistep-two-form #edit-sex--wrapper .fieldset-wrapper{float:left;width:75%}form.multistep-two-form #edit-sex--wrapper .fieldset-wrapper #edit-sex label{font-size:16px;font-weight:bold}
.progressbar-wrapper{padding:25px;background:#fff;border-radius:4px;text-align:center}.f1-steps{overflow:hidden;position:relative;margin-top:20px}.f1-progress{position:absolute;top:24px;left:0;width:100%;height:1px;background:#ddd}.f1-progress-line{position:absolute;top:0;left:0;height:1px;background:#466bc8}.f1-step{position:relative;float:left;width:33.3333%;padding:0 5px}.f1-step-icon{display:inline-block;width:40px;height:40px;margin-top:4px;background:#ddd;font-size:16px;color:#fff;line-height:40px;border-radius:50%}.f1-step.activated .f1-step-icon{background:#fff;border:1px solid #466bc8;color:#466bc8;line-height:38px}.f1-step.active .f1-step-icon{width:48px;height:48px;margin-top:0;background:#466bc8;font-size:22px;line-height:48px}.f1-step p{color:#ccc}.f1-step.activated p{color:#466bc8}.f1-step.active p{color:#466bc8}form.multistep-two-form h2.form-title{padding:15px}form.multistep-two-form .form-group{margin-bottom:1.2em;overflow:hidden}form.multistep-two-form .form-group label{float:left;width:28%;padding-right:10px;padding-top:8px;text-align:left}form.multistep-two-form .form-group .form-control{font-size:16px;padding:4px 8px;height:36px;width:72%;float:left;border-radius:4px !important}form.multistep-two-form .form-group .form-control[disabled]{background-color:grey;opacity:0.55;color:white;font-weight:bold}form.multistep-two-form .less-p label{padding-top:0}form.multistep-two-form #edit-sex--wrapper{padding-bottom:15px}form.multistep-two-form #edit-sex--wrapper legend{float:left;width:25%;font-size:18px;font-weight:bold;border-style:none}form.multistep-two-form #edit-sex--wrapper .fieldset-wrapper{float:left;width:75%}form.multistep-two-form #edit-sex--wrapper .fieldset-wrapper #edit-sex label{font-size:16px;font-weight:bold}form.multistep-three-form a#edit-back{text-decoration:none}
/*# sourceMappingURL=maincustomform.css.map */
\ No newline at end of file
/*# sourceMappingURL=maincustomform.css.map */
......@@ -4,56 +4,7 @@
Drupal.behaviors.logInForm = {
attach: function (context, settings) {
//get all available regions
jQuery.ajax({
url: Drupal.url('/jsonapi/region_entity/region_entity?_format=api_json&fields[region_entity--region_entity]=id,name'),
method: 'GET',
success: function(data, status, xhr) {
var arrObjects = data["data"];
var sel = $("#edit-region-select");
sel.empty();
arrObjects.forEach( function (arrayItem)
{
var attributes = arrayItem['attributes'];
sel.append('<option value="' + attributes['id'] + '">' + attributes['name'] + '</option>');
})
}
});
//select iek
jQuery.ajax({
url: Drupal.url('/jsonapi/school_entity/school_entity?_format=api_json&fields[school_entity--school_entity]=id,name'),
method: 'GET',
success: function(data, status, xhr) {
var arrObjects = data["data"];
var sel = $("#edit-iek-select");
sel.empty();
arrObjects.forEach( function (arrayItem)
{
var attributes = arrayItem['attributes'];
sel.append('<option value="' + attributes['id'] + '">' + attributes['name'] + '</option>');
})
}
});
//select eidikotita
jQuery.ajax({
url: Drupal.url('/jsonapi/eidikotita_entity/eidikotita_entity?_format=api_json&fields[eidikotita_entity--eidikotita_entity]=id,name'),
method: 'GET',
success: function(data, status, xhr) {
var arrObjects = data["data"];
var sel = $("#edit-eidikotita-select");
sel.empty();
arrObjects.forEach( function (arrayItem)
{
var attributes = arrayItem['attributes'];
sel.append('<option value="' + attributes['id'] + '">' + attributes['name'] + '</option>');
})
}
});
......
......@@ -5,9 +5,24 @@
attach: function (context, settings) {
//alert('loaded 2');
var next_step = true;
// navigation steps / progress steps
//.once('myCustomBehavior').
var current_active_step = $(context).find('.f1-step.active');
var progress_line = $(context).find('.f1-progress-line');
if( next_step ) {
// change icons
current_active_step.once('progressline').removeClass('active').addClass('activated').next().addClass('active');
// progress bar
bar_progress(progress_line, 'right');
}
// var parent_fieldset = $(this).parents('fieldset');
var next_step = true;
/*var next_step = true;
// navigation steps / progress steps
var current_active_step = $('.multistep-two-form').find('.f1-step.active');
var progress_line = $('.multistep-two-form').find('.f1-progress-line');
......@@ -17,7 +32,7 @@
current_active_step.removeClass('active').addClass('activated').next().addClass('active');
// progress bar
bar_progress(progress_line, 'right');
}
}*/
// previous step
/*
......
......@@ -5,17 +5,72 @@
attach: function (context, settings) {
//get all available regions
jQuery.ajax({
url: Drupal.url('/jsonapi/region_entity/region_entity?_format=api_json&fields[region_entity--region_entity]=id,name'),
method: 'GET',
success: function(data, status, xhr) {
var arrObjects = data["data"];
var sel = $("#edit-region-select");
sel.empty();
sel.append('<option value="0">---Επιλέξτε ---</option>');
arrObjects.forEach( function (arrayItem)
{
var attributes = arrayItem['attributes'];
sel.append('<option value="' + attributes['id'] + '">' + attributes['name'] + '</option>');
})
}
});
//select iek
jQuery.ajax({
url: Drupal.url('/jsonapi/school_entity/school_entity?_format=api_json&fields[school_entity--school_entity]=id,name'),
method: 'GET',
success: function(data, status, xhr) {
var arrObjects = data["data"];
var sel = $("#edit-iek-select");
sel.empty();
sel.append('<option value="0">---Επιλέξτε ---</option>');
arrObjects.forEach( function (arrayItem)
{
var attributes = arrayItem['attributes'];
sel.append('<option value="' + attributes['id'] + '">' + attributes['name'] + '</option>');
})
}
});
//select eidikotita
jQuery.ajax({
url: Drupal.url('/jsonapi/eidikotita_entity/eidikotita_entity?_format=api_json&fields[eidikotita_entity--eidikotita_entity]=id,name'),
method: 'GET',
success: function(data, status, xhr) {
var arrObjects = data["data"];
var sel = $("#edit-eidikotita-select");
sel.empty();
sel.append('<option value="0">---Επιλέξτε ---</option>');
arrObjects.forEach( function (arrayItem)
{
var attributes = arrayItem['attributes'];
sel.append('<option value="' + attributes['id'] + '">' + attributes['name'] + '</option>');
})
}
});
// var parent_fieldset = $(this).parents('fieldset');
var next_step = true;
// navigation steps / progress steps
var current_active_step = $('form.multistep-three-form').find('.f1-step.active');
var current_active_step = $(context).find('.f1-step.active');
var progress_line = $('form.multistep-three-form').find('.f1-progress-line');
var progress_line = $(context).find('.f1-progress-line');
if( next_step ) {
// alert(progress_line);
// change icons
current_active_step.removeClass('active').addClass('activated').next().addClass('active');
current_active_step.once('progresslinelast').removeClass('active').addClass('activated').next().addClass('active');
// progress bar
bar_progress(progress_line, 'right');
}
......
......@@ -38,5 +38,27 @@ function maincustomform_theme() {
'common_part' => [
'render element' => 'children',
],
'maincustomform_block' => [
'variables' => [
'url_out' => null,
'url_in' => null,
'name' => null,
'role' => null,
// define defaults for any variables you want in the twig file
'attributes' => [
'class' => ['my-module-class'],
], //etc
],
],
];
}
function maincustomform_preprocess_region(array &$variables) {
$block_manager = \Drupal::service('plugin.manager.block');
$block_config = [];
$block_plugin = $block_manager->createInstance('main_form_block', $block_config);
$block_build = $block_plugin->build();
$block_content = render($block_build);
$variables['my_custom_user_info_block'] = $block_content;
}
......@@ -30,4 +30,3 @@ maincustomform.multistep_three_form:
_form: '\Drupal\maincustomform\Form\MultistepThreeForm'
requirements:
_access: 'TRUE'
......@@ -160,6 +160,7 @@ abstract class MultistepFormBase extends FormBase {
'student_id'=> $created_student_id,
'iek_id'=> $this->store->get('iek_select'),
'region_id'=> $this->store->get('region_select'),
'pedio' => $this->store->get('pedio'),
'state' => 'DRAFT'
);
......
......@@ -204,8 +204,8 @@ class MultistepOneForm extends MultistepFormBase {
$this->store->set('mname', 'ΕΥΓΕΝΙΑ');
$this->store->set('idno', 'ΧΧ455676');
$this->store->set('sex', 1);
$this->store->set('birth_date', '1976-12-10' );
$this->store->set('birth_place', 'ΑΘΗΝΑ');
$this->store->set('birthdate', '1976-12-10' );
$this->store->set('birthplace', 'ΑΘΗΝΑ');
$this->store->set('afm', '057339456');
}//validation end
......
......@@ -78,9 +78,9 @@ class MultistepThreeForm extends MultistepFormBase {
'#type' => 'select',
'#title' => 'Τύπος Εξέτασης',
'#options' => [
'practical' => $this->t('Πρακτικό μέρος'),
'theoretical' => $this->t('Θεωρητικό μέρος'),
'both' => $this->t('Και τα δύο'),
'practical' => t('Πρακτικό μέρος'),
'theoretical' => t('Θεωρητικό μέρος'),
'both' => t('Και τα δύο'),
],
);
......@@ -102,7 +102,7 @@ class MultistepThreeForm extends MultistepFormBase {
'#type' => 'link',
'#title' => $this->t('Προηγούμενο'),
'#attributes' => array(
'class' => array('button'),
'class' => array('btn'),
),
'#weight' => 0,
'#url' => Url::fromRoute('maincustomform.multistep_two_form'),
......@@ -110,7 +110,7 @@ class MultistepThreeForm extends MultistepFormBase {
$form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Submit'),
'#value' => $this->t('Καταχώρηση'),
];
return $form;
......@@ -121,6 +121,21 @@ class MultistepThreeForm extends MultistepFormBase {
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
// parent::validateForm($form, $form_state);
if($form_state->getValue('region_select') == 0) {
$form_state->setErrorByName('region_select', t('Δεν έχει γίνει επιλογή'));
return;
}
if($form_state->getValue('eidikotita_select') == 0) {
$form_state->setErrorByName('eidikotita_select', t('Δεν έχει γίνει επιλογή'));
return;
}
if($form_state->getValue('iek_select') == 0) {
$form_state->setErrorByName('iek_select', t('Δεν έχει γίνει επιλογή'));
return;
}
$this->store->set('prabek', $form_state->getValue('prabek'));
$this->store->set('numbek', $form_state->getValue('numbek'));
$this->store->set('regno', $form_state->getValue('regno'));
......
......@@ -112,29 +112,29 @@ class MultistepTwoForm extends MultistepFormBase {
),
);
$form['birth_date'] = array(
$form['birthdate'] = array(
'#type' => 'date',
'#title' => t('Ημερομηνία Γέννησης'),
'#default_value' => $this->store->get('birth_date') ? $this->store->get('birth_date') : '',
'#default_value' => $this->store->get('birthdate') ? $this->store->get('birthdate') : '',
'#states' => array(
'disabled' => array(
'input[name="birth_date"]' => array('filled' => TRUE),
'input[name="birthdate"]' => array('filled' => TRUE),
),
//'#default_value' => array('year' => 2020, 'month' => 2, 'day' => 15,)
// '#default_value' => '2016-01-27'
),
);
$form['birth_place'] = array(
$form['birthplace'] = array(
'#type' => 'textfield',
'#title' => t('Τοποθεσία Γέννησης'),
'#size' => 60,
'#maxlength' => 120,
'#required' => TRUE,
'#default_value' => $this->store->get('birth_place') ? $this->store->get('birth_place') : '',
'#default_value' => $this->store->get('birthplace') ? $this->store->get('birthplace') : '',
'#states' => array(
'disabled' => array(
'input[name="birth_place"]' => array('filled' => TRUE),
'input[name="birthplace"]' => array('filled' => TRUE),
),
),
);
......@@ -212,8 +212,8 @@ class MultistepTwoForm extends MultistepFormBase {
$this->store->set('mname', $form_state->getValue('mname'));
$this->store->set('idno', $form_state->getValue('idno'));
$this->store->set('sex', $form_state->getValue('sex'));
$this->store->set('birth_date', $form_state->getValue('birth_date'));
$this->store->set('birth_place', $form_state->getValue('birth_place'));
$this->store->set('birthdate', $form_state->getValue('birthdate'));
$this->store->set('birthplace', $form_state->getValue('birthplace'));
$this->store->set('email', $form_state->getValue('email'));
$this->store->set('telephone', $form_state->getValue('telephone'));
$this->store->set('afm', $form_state->getValue('afm'));
......
......@@ -3,6 +3,11 @@
namespace Drupal\maincustomform\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Url;
use Drupal\Core\Link;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Entity\EntityManagerInterface;
/**
* Provides a 'MainFormBlock' block.
......@@ -12,20 +17,88 @@ use Drupal\Core\Block\BlockBase;
* admin_label = @Translation("Main form block"),
* )
*/
class MainFormBlock extends BlockBase {
class MainFormBlock extends BlockBase implements ContainerFactoryPluginInterface {
protected $entity_manager;
/**
* @param array $configuration
* @param string $plugin_id
* @param mixed $plugin_definition
* @param \Drupal\Core\Session\AccountProxyInterface $account
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager) {
$this->entity_manager = $entity_manager;
}
/**
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* @param array $configuration
* @param string $plugin_id
* @param mixed $plugin_definition
*
* @return static
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('entity.manager')
);
}
/**
* {@inheritdoc}
*/
public function build() {
//$build = [];
//$build['main_form_block']['#markup'] = 'Implement MainFormBlock.';
$userCurrent = \Drupal::currentUser();
$user_id = $userCurrent->id();
$user = \Drupal\user\Entity\User::load($userCurrent->id());
$userRoles = $userCurrent->getRoles();
$url_out = \Drupal::url('user.logout');
$url_in = \Drupal::url('user.login');
$studentUsers = $this->entity_manager->getStorage('student_entity')->loadByProperties(array('user_id' => $user_id));
$studentUser = reset($studentUsers);
if(in_array("administrator", $userRoles)) {
$role = "Διαχειριστής Συστήματος";
$name = $user->getUsername();
} else if(in_array("aiton", $userRoles)) {
$role = "Αιτών";
if($studentUser)
$name = $studentUser->getLast().' '.$studentUser->getFirst();
else
$name = 'Αρχικό';
} else if(in_array("diaxeiristis_iek", $userRoles)) {
$role = "Διαχειριστής ΙΕΚ";
$name = $user->getUsername();
} else if(in_array("diaxeiristis_eoppep", $userRoles)) {
$role = "Διαχειριστής ΕΟΠΠΕΠ";
$name = $user->getUsername();
}
$builtForm = \Drupal::formBuilder()->getForm('Drupal\maincustomform\Form\MultistepFormBase');
$renderArray['form'] = $builtForm;
return array(
'#url_out' => $url_out,
'#url_in' => $url_in,
'#name' => $name,
'#role' => $role,
'#theme' => 'maincustomform_block'
);
return $renderArray;
//return $renderArray;
}
}
{#
/**
* @file
* Default theme implementation to display a bare minimum block.
*
* Available variables:
* - $block->subject: Block title.
* - $content: Block content.
* - $block->module: Module that generated the block.
* - $block->delta: An ID for the block, unique within each module.
* - $block->region: The block region embedding the current block.
* - $classes: String of classes that can be used to style contextually through
* CSS. It can be manipulated through the variable $classes_array from
* preprocess functions. The default values can be one or more of the
* following:
* - block: The current template type, i.e., "theming hook".
* - block-[module]: The module generating the block. For example, the user
* module is responsible for handling the default user navigation block. In
* that case the class would be 'block-user'.
* - $title_prefix (array): An array containing additional output populated by
* modules, intended to be displayed in front of the main title tag that
* appears in the template.
* - $title_suffix (array): An array containing additional output populated by
* modules, intended to be displayed after the main title tag that appears in
* the template.
*
* Helper variables:
* - $classes_array: Array of html class attribute values. It is flattened
* into a string within the variable $classes.
* - $block_zebra: Outputs 'odd' and 'even' dependent on each block region.
* - $zebra: Same output as $block_zebra but independent of any block region.
* - $block_id: Counter dependent on each block region.
* - $id: Same output as $block_id but independent of any block region.
* - $is_front: Flags true when presented in the front page.
* - $logged_in: Flags true when the current user is a logged-in member.
* - $is_admin: Flags true when the current user is an administrator.
* - $block_html_id: A valid HTML ID and guaranteed unique.
*
* @ingroup templates
*
* @see bootstrap_preprocess_block()
* @see template_preprocess()
* @see template_preprocess_block()
* @see bootstrap_process_block()
* @see template_process()
*/
#}
{% if logged_in %}
<div class="col-sm-4 col-md-3">
<p class="ver"><i class="fa fa-user"></i> {{ name }}</p>
<span class="ver">{{ role }}<a class="lg-link" href='{{ url_out }}' >Έξοδος</a></span>
{% else %}
<div class="col-sm-4 col-md-2">
<p class="ver"><i class="fa fa-user"></i> Guest <span class="ver"><a class="lg-link" href='{{ url_in }}' >Είσοδος</a></span></p>
{% endif %}
</div>
\ No newline at end of file
......@@ -30,10 +30,10 @@
</div>
<div class="row">
<div class="col-md-6">
{{ form.birth_date }}
{{ form.birthdate }}
</div>
<div class="col-md-6">
{{ form.birth_place }}
{{ form.birthplace }}
</div>
</div>
<div class="row">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment