fix issues #36, #37

parent 6d502102
......@@ -64,9 +64,9 @@
</div>
{% endmacro %}
{% import _self as macros %}
{% block content %}
{% import _self as macros %}
<div id="app-form">
<h1>
{% block title %}
......
{% extends "layout.twig" %}
{% macro input(name, label, value, type, attributes) %}
<div class="form-group">
<label class="control-label hidden-xs hidden-sm col-md-3" for="el-{{ name }}">{{ label|raw }}</label>
<div class="col-xs-12 col-sm-12 col-md-9">
<input placeholder="{{ label|striptags }}" class="form-control input-sm"
type="{{ type|default('text') }}" name="{{ name }}"
id="el-{{ name }}" value="{{ value|default('')|raw }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}>
</div>
</div>
{% endmacro %}
{% macro checkbox(name, label, checked, attributes) %}
<div class="form-group">
<div class="col-xs-12 col-sm-12 col-md-9 col-md-offset-3">
<div class="checkbox">
<label for="el-{{ name }}">
<input type="checkbox" name="{{ name }}" id="el-{{ name }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}
{% if checked %} checked{% endif %} value="asdasdasd">
{{ label|raw }}
</label>
</div>
</div>
</div>
{% endmacro %}
{% macro file(name, label, value, attributes) %}
<div class="form-group">
<label class="control-label hidden-xs hidden-sm col-md-3" for="el-{{ name }}">{{ label|raw }}</label>
<div class="col-xs-12 col-sm-12 col-md-9">
<div class="input-group">
<span class="input-group-btn">
<span class="btn btn-default btn-file">
Επιλέξτε&hellip; <input type="file" multiple name="{{ name }}" id="el-{{ name }}">
</span>
</span>
<input type="text" class="form-control" readonly placeholder="{{ label|striptags }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}>
<span class="input-group-btn">
<span class="btn btn-default btn-file-remove">
<i class="fa fa-remove"></i>
</span>
</span>
</div>
{% if value %}
<div class="pull-right uploaded btn-group btn-group-sm" data-href="{{ value }}">
<a href="#" target="_blank" class="btn-download btn bnt-link btn-sm">
<i class="fa fa-download"></i> Λήψη</a>
<a href="#" class="btn-remove btn bnt-link btn-sm text-danger">
<i class="fa fa-remove"></i> Διαγραφή</a>
</div>
{% endif %}
</div>
</div>
{% endmacro %}
{% macro select(name, label, options, selected, attributes) %}
<div class="form-group">
<label class="control-label hidden-xs hidden-sm col-md-3" for="el-{{ name }}">{{ label|raw }}</label>
<div class="col-xs-12 col-sm-12 col-md-9">
<select class="form-control input-sm" name="{{ name }}" id="el-{{ name }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}>
{% set multi = attributes.multiple is defined %}
{% if multi %}
<optgroup label="{{ label|striptags }}">
{% endif %}
{% if not multi %}
<option value="" disabled{% if selected is empty %} selected{% endif %}>{{ label|striptags }}</option>
{% endif %}
{% for option in options %}
<option value="{{ option.value|e }}"{% if selected == option.value %} selected{% endif %}>
{{ option.label }}
</option>
{% endfor %}
{% if multi %}
</optgroup>
{% endif %}
</select>
</div>
</div>
{% endmacro %}
{% macro select_year(name, label, selected, start, attributes) %}
<div class="form-group">
<label class="control-label hidden-xs hidden-sm col-md-3" for="el-{{ name }}">{{ label|raw }}</label>
<div class="col-xs-12 col-sm-12 col-md-9">
<select class="form-control input-sm" name="{{ name }}" id="el-{{ name }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}>
<option value="" disabled{% if selected is empty %} selected{% endif %}>{{ label|striptags }}</option>
{% for option in range("now"|date("Y"), start|default(1980)) %}
<option value="{{ option|e }}"{% if selected == option %} selected{% endif %}>
{{ option }}
</option>
{% endfor %}
</select>
</div>
</div>
{% endmacro %}
{% macro text(name, label, value, attributes) %}
<div class="form-group">
<label for="el-{{ name }}" class="col-xs-12 pull-left">
{{ label|e }}
</label>
<div class="col-xs-12">
<textarea id="el-{{ name }}" name="{{ name }}" class="form-control" placeholder="{{ label|striptags }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}>
{{ value|striptags }}
</textarea>
</div>
</div>
{% endmacro %}
{% block content %}
<div id="school">
<h1>
......@@ -151,13 +23,13 @@
{% block schoolContent %}
<div id="school-info">
<p class="col-md-12">
Σε αυτή την καρτέλα θα καταχωρήσετε πληροφορίες που
αφορούν στο σχολείο σας, όπως τους εκπαιδευτικούς
που θα ασχοληθούν με την υλοποίηση του έργου,
τους χώρους που χρησιμοποιείτε για χρήση ΤΠΕ ή
τους επιπλέον χώρους που θα επιθυμούσατε να
χρησιμοποιήσετε για χρήση ΤΠΕ, τον εξοπλισμό
ΤΠΕ που διαθέτει το σχολείο και τον τρόπο που τον
Σε αυτή την καρτέλα θα καταχωρήσετε πληροφορίες που
αφορούν στο σχολείο σας, όπως τους εκπαιδευτικούς
που θα ασχοληθούν με την υλοποίηση του έργου,
τους χώρους που χρησιμοποιείτε για χρήση ΤΠΕ ή
τους επιπλέον χώρους που θα επιθυμούσατε να
χρησιμοποιήσετε για χρήση ΤΠΕ, τον εξοπλισμό
ΤΠΕ που διαθέτει το σχολείο και τον τρόπο που τον
χρησιμοποιείτε κλπ.
</p>
<div class="col-md-4">
......@@ -241,16 +113,27 @@
<dt>Σχόλια/Παρατηρήσεις</dt>
<dd>{{ appForm.comments }}</dd>
</dl>
</div>
<h5>Αιτούμενος εξοπλισμός</h5>
<dl class="dl-horizontal">
{% for item in appForm.items %}
<dt>{{ item.category }}</dt>
<dd>{{ item.count }}<dd>
{% endfor %}
</dl>
{% else %}
<div class="table-responsive">
<table class="table table-condensed table-striped">
<thead>
<tr>
<th>Είδος/Τύπος</th>
<th>Ποσότητα</th>
</tr>
</thead>
<tbody>
{% for item in appForm.items %}
<tr>
<th>{{ item.category }}</th>
<td>{{ item.count }}<td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p>Δεν έχετε υποβάλει αίτηση ακόμα.</p>
{% endif %}
</div>
......
......@@ -86,6 +86,7 @@
form: null,
lab: null,
attachment: null,
uploadedLabel: null,
url: null,
events: {
'submit': 'persistLab',
......@@ -107,6 +108,7 @@
url = $(evt.target).closest('a').attr('href');
that.removeAttachment(url);
});
this.uploadedLabel = _.template(that.attachment.find('.uploaded-label').html().replace(':', ' <%= filename %>:'));
},
render: function (labId) {
var labAttributes;
......@@ -131,13 +133,14 @@
if ('checkbox' === element.attr('type')) {
element.prop('checked', utils.parseInt(labAttributes[name]));
} else {
element.val(labAttributes[name] || '');
element.val(labAttributes[name] || '');
}
});
if (!this.lab || !this.lab.get('attachment')) {
this.attachment.find('a').attr('href', '#');
this.attachment.hide();
} else {
this.attachment.find('.uploaded-label').html(this.uploadedLabel({filename: this.lab.get('attachment')}));
this.attachment.find('a').attr('href', this.attachment.data('href').replace('__lab_id__', this.lab.get('id')));
this.attachment.show();
}
......
......@@ -33,7 +33,9 @@ class PersistLab
$params = $req->getParams();
$id = $params['id'];
$params['school_id'] = $school->id;
if (isset($params['lessons']) && !is_array($params['lessons'])) {
$params['lessons'] = explode(',', $params['lessons']);
}
unset($params['id']);
try {
if ($id) {
......
......@@ -118,7 +118,10 @@ class LabService implements LabServiceInterface
$responsible = sprintf("%s %s", $responsible->name, $responsible->surname);
}
return array_merge($bean->export(), [
$lab = $bean->export();
$lab['attachment'] = basename($lab['attachment']);
return array_merge($lab, [
'labtype' => $bean->labtype->name,
'responsible' => $responsible,
'lessons' => array_reduce($bean->sharedLesson, function ($ids, $lesson) {
......@@ -126,7 +129,6 @@ class LabService implements LabServiceInterface
return $ids;
}, []),
]);
}
......
{% extends "schools/index.twig" %}
{% import "schools/index.twig" as macros %}
{% import "schools/form.twig" as macros %}
{% block schoolTitle %}
{{ parent() }} <small>Εξοπλισμός</small>
......@@ -54,7 +54,7 @@
</tfoot>
</table>
</div>
<div class="modal fade" id="asset-form-modal" tabindex="-1" role="dialog" aria-labelledby="asset-from">
<div class="modal fade" id="asset-form-modal" role="dialog" aria-labelledby="asset-from">
<form class="form-horizontal" data-url="{{ path_for('school.assets') }}">
<div class="modal-dialog" role="form">
<div class="modal-content">
......
{% macro input(name, label, value, type, attributes) %}
<div class="form-group">
<label class="control-label hidden-xs hidden-sm col-md-3" for="el-{{ name }}">{{ label|raw }}</label>
<div class="col-xs-12 col-sm-12 col-md-9">
<input placeholder="{{ label|striptags }}" class="form-control input-sm"
type="{{ type|default('text') }}" name="{{ name }}"
id="el-{{ name }}" value="{{ value|default('')|raw }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}>
</div>
</div>
{% endmacro %}
{% macro checkbox(name, label, checked, attributes) %}
<div class="form-group">
<div class="col-xs-12 col-sm-12 col-md-9 col-md-offset-3">
<div class="checkbox">
<label for="el-{{ name }}">
<input type="checkbox" name="{{ name }}" id="el-{{ name }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}
{% if checked %} checked{% endif %} value="asdasdasd">
{{ label|raw }}
</label>
</div>
</div>
</div>
{% endmacro %}
{% macro file(name, label, value, attributes) %}
<div class="form-group">
<label class="control-label hidden-xs hidden-sm col-md-3" for="el-{{ name }}">{{ label|raw }}</label>
<div class="col-xs-12 col-sm-12 col-md-9">
<div class="input-group">
<span class="input-group-btn">
<span class="btn btn-default btn-file">
Επιλέξτε&hellip; <input type="file" multiple name="{{ name }}" id="el-{{ name }}">
</span>
</span>
<input type="text" class="form-control" readonly placeholder="{{ label|striptags }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}>
<span class="input-group-btn">
<span class="btn btn-default btn-file-remove">
<i class="fa fa-remove"></i>
</span>
</span>
</div>
</div>
</div>
{% if value %}
<div class="uploaded help-block pull-right" data-href="{{ value }}">
<small class="uploaded-label">Υπάρχει ήδη καταχωρημένο αρχείο:</small>
<div class="btn-group btn-group-sm">
<a href="#" target="_blank" class="btn-download btn bnt-link btn-sm">
<i class="fa fa-download"></i> Λήψη</a>
<a href="#" class="btn-remove btn bnt-link btn-sm text-danger">
<i class="fa fa-remove"></i> Διαγραφή</a>
</div>
</div>
{% endif %}
{% endmacro %}
{% macro select(name, label, options, selected, attributes) %}
<div class="form-group">
<label class="control-label hidden-xs hidden-sm col-md-3" for="el-{{ name }}">{{ label|raw }}</label>
<div class="col-xs-12 col-sm-12 col-md-9">
<select class="form-control input-sm" name="{{ name }}" id="el-{{ name }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %} data-placeholder="{{ label|striptags }}">
{% set multi = attributes.multiple is defined %}
{% if multi %}
<optgroup label="{{ label|striptags }}">
{% endif %}
{% if not multi %}
<option value="" disabled{% if selected is empty %} selected{% endif %}>{{ label|striptags }}</option>
{% endif %}
{% for option in options %}
<option value="{{ option.value|e }}"{% if selected == option.value %} selected{% endif %}>
{{ option.label }}
</option>
{% endfor %}
{% if multi %}
</optgroup>
{% endif %}
</select>
</div>
</div>
{% endmacro %}
{% macro select_year(name, label, selected, start, attributes) %}
<div class="form-group">
<label class="control-label hidden-xs hidden-sm col-md-3" for="el-{{ name }}">{{ label|raw }}</label>
<div class="col-xs-12 col-sm-12 col-md-9">
<select class="form-control input-sm" name="{{ name }}" id="el-{{ name }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}>
<option value="" disabled{% if selected is empty %} selected{% endif %}>{{ label|striptags }}</option>
{% for option in range("now"|date("Y"), start|default(1980)) %}
<option value="{{ option|e }}"{% if selected == option %} selected{% endif %}>
{{ option }}
</option>
{% endfor %}
</select>
</div>
</div>
{% endmacro %}
{% macro text(name, label, value, attributes) %}
<div class="form-group">
<label for="el-{{ name }}" class="col-xs-12 pull-left">
{{ label|e }}
</label>
<div class="col-xs-12">
<textarea id="el-{{ name }}" name="{{ name }}" class="form-control" placeholder="{{ label|striptags }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}>
{{ value|striptags }}
</textarea>
</div>
</div>
{% endmacro %}
\ No newline at end of file
{% extends "layout.twig" %}
{% macro input(name, label, value, type, attributes) %}
<div class="form-group">
<label class="control-label hidden-xs hidden-sm col-md-3" for="el-{{ name }}">{{ label|raw }}</label>
<div class="col-xs-12 col-sm-12 col-md-9">
<input placeholder="{{ label|striptags }}" class="form-control input-sm"
type="{{ type|default('text') }}" name="{{ name }}"
id="el-{{ name }}" value="{{ value|default('')|raw }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}>
</div>
</div>
{% endmacro %}
{% macro checkbox(name, label, checked, attributes) %}
<div class="form-group">
<div class="col-xs-12 col-sm-12 col-md-9 col-md-offset-3">
<div class="checkbox">
<label for="el-{{ name }}">
<input type="checkbox" name="{{ name }}" id="el-{{ name }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}
{% if checked %} checked{% endif %} value="asdasdasd">
{{ label|raw }}
</label>
</div>
</div>
</div>
{% endmacro %}
{% macro file(name, label, value, attributes) %}
<div class="form-group">
<label class="control-label hidden-xs hidden-sm col-md-3" for="el-{{ name }}">{{ label|raw }}</label>
<div class="col-xs-12 col-sm-12 col-md-9">
<div class="input-group">
<span class="input-group-btn">
<span class="btn btn-default btn-file">
Επιλέξτε&hellip; <input type="file" multiple name="{{ name }}" id="el-{{ name }}">
</span>
</span>
<input type="text" class="form-control" readonly placeholder="{{ label|striptags }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}>
<span class="input-group-btn">
<span class="btn btn-default btn-file-remove">
<i class="fa fa-remove"></i>
</span>
</span>
</div>
{% if value %}
<div class="pull-right uploaded btn-group btn-group-sm" data-href="{{ value }}">
<a href="#" target="_blank" class="btn-download btn bnt-link btn-sm">
<i class="fa fa-download"></i> Λήψη</a>
<a href="#" class="btn-remove btn bnt-link btn-sm text-danger">
<i class="fa fa-remove"></i> Διαγραφή</a>
</div>
{% endif %}
</div>
</div>
{% endmacro %}
{% macro select(name, label, options, selected, attributes) %}
<div class="form-group">
<label class="control-label hidden-xs hidden-sm col-md-3" for="el-{{ name }}">{{ label|raw }}</label>
<div class="col-xs-12 col-sm-12 col-md-9">
<select class="form-control input-sm" name="{{ name }}" id="el-{{ name }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}>
{% set multi = attributes.multiple is defined %}
{% if multi %}
<optgroup label="{{ label|striptags }}">
{% endif %}
{% if not multi %}
<option value="" disabled{% if selected is empty %} selected{% endif %}>{{ label|striptags }}</option>
{% endif %}
{% for option in options %}
<option value="{{ option.value|e }}"{% if selected == option.value %} selected{% endif %}>
{{ option.label }}
</option>
{% endfor %}
{% if multi %}
</optgroup>
{% endif %}
</select>
</div>
</div>
{% endmacro %}
{% macro select_year(name, label, selected, start, attributes) %}
<div class="form-group">
<label class="control-label hidden-xs hidden-sm col-md-3" for="el-{{ name }}">{{ label|raw }}</label>
<div class="col-xs-12 col-sm-12 col-md-9">
<select class="form-control input-sm" name="{{ name }}" id="el-{{ name }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}>
<option value="" disabled{% if selected is empty %} selected{% endif %}>{{ label|striptags }}</option>
{% for option in range("now"|date("Y"), start|default(1980)) %}
<option value="{{ option|e }}"{% if selected == option %} selected{% endif %}>
{{ option }}
</option>
{% endfor %}
</select>
</div>
</div>
{% endmacro %}
{% macro text(name, label, value, attributes) %}
<div class="form-group">
<label for="el-{{ name }}" class="col-xs-12 pull-left">
{{ label|e }}
</label>
<div class="col-xs-12">
<textarea id="el-{{ name }}" name="{{ name }}" class="form-control" placeholder="{{ label|striptags }}"
{% for attr_name, attr_value in attributes|default({}) %}
{{ attr_name }}="{{ attr_value }}"
{% endfor %}>
{{ value|striptags }}
</textarea>
</div>
</div>
{% endmacro %}
{% block content %}
<div id="school">
<h1>
......
{% extends "schools/index.twig" %}
{% import "schools/index.twig" as macros %}
{% import "schools/form.twig" as macros %}
{% block schoolTitle %}
{{ parent() }} <small>Χώροι</small>
......@@ -67,7 +67,7 @@
</tfoot>
</table>
</div>
<div class="modal fade" id="lab-form-modal" tabindex="-1" role="dialog" aria-labelledby="lab-from">
<div class="modal fade" id="lab-form-modal" role="dialog" aria-labelledby="lab-from">
<form class="form-horizontal" method="post" action="{{ path_for('school.labs') }}"
data-url="{{ path_for('school.labs') }}" enctype="multipart/form-data">
<div class="modal-dialog" role="form">
......@@ -87,6 +87,7 @@
{{ macros.input('area', 'Επιφάνεια (m<sup>2</sup>)', '', 'number', {'required': '', 'min': 0, 'max': 500}) }}
{{ macros.file('attachment', 'Αρχείο κάτοψης ή φωτογραφία', path_for('school.labs.attachment', {}, {'lab_id': '__lab_id__'})) }}
{{ macros.select('lessons', 'Μαθήματα', lessons_options, '', {'multiple': ''}) }}
<small class="help-block pull-right">Κρατήστε πατημένο το Ctrl για να επιλέξετε περισσότερα από ένα μαθήματα</small>
{{ macros.text('use_in_program', 'Χρήση στα πλαίσια μαθημάτων') }}
{{ macros.text('use_ext_program', 'Χρήση για δραστηριότητες εκτός εκπαιδευτικού προγράμματος') }}
<input type="hidden" name="id" value="">
......
{% extends "schools/index.twig" %}
{% import "schools/index.twig" as macros %}
{% import "schools/form.twig" as macros %}
{% block schoolTitle %}
{{ parent() }} <small>Λογισμικό</small>
......@@ -56,7 +56,7 @@
</tfoot>
</table>
</div>
<div class="modal fade" id="software-form-modal" tabindex="-1" role="dialog" aria-labelledby="software-from">
<div class="modal fade" id="software-form-modal" role="dialog" aria-labelledby="software-from">
<form class="form-horizontal" data-url="{{ path_for('school.software') }}">
<div class="modal-dialog" role="form">
<div class="modal-content">
......
{% extends "schools/index.twig" %}
{% import "schools/index.twig" as macros %}
{% import "schools/form.twig" as macros %}
{% block schoolTitle %}
{{ parent() }} <small>Εκπαιδευτικοί</small>
......@@ -69,7 +69,7 @@
</tfoot>
</table>
</div>
<div class="modal fade" id="teacher-form-modal" tabindex="-1" role="dialog" aria-labelledby="teacher-from">
<div class="modal fade" id="teacher-form-modal" role="dialog" aria-labelledby="teacher-from">
<form class="form-horizontal" data-url="{{ path_for('school.staff') }}">
<div class="modal-dialog" role="form">
<div class="modal-content">
......
{% extends "schools/index.twig" %}
{% import "schools/index.twig" as macros %}