Skip to content
Snippets Groups Projects
Commit c9b7b788 authored by PavelBegunkov's avatar PavelBegunkov Committed by Роман Штейнберг
Browse files

#144 fix student transfer interface, unite get groups methods

parent 0852f02c
Branches
Tags
No related merge requests found
Showing
with 113 additions and 176 deletions
...@@ -25,33 +25,20 @@ $(function () { ...@@ -25,33 +25,20 @@ $(function () {
} }
}); });
let groupSelect = getGroupLoader($groupSelect,
() => ({FacultyID: +$facultySelect.val(), 'GradeID': +$gradeSelect.val()})
).setOnChange(OptionLoader.stubFoo);
// Выбор курса // Выбор курса
$gradeSelect.change(function () { $gradeSelect.change(() => {
$searchResults.html(''); $searchResults.html('');
$groupSelect.attr('disabled', 'disabled'); groupSelect.reload();
$groupSelect.html('<option value="0">— Учебная группа —</option>');
if (($gradeSelect.find('option:selected').val() != '0')) {
$.post(URLdir + 'handler/students/getGroups', {
'facultyID': $facultySelect.find('option:selected').val(),
'gradeNum': $gradeSelect.find('option:selected').val()
}, function (data) {
$.each(data, function (i) {
$groupSelect.append('<optgroup label="' + data[i].SpecName + '">');
$.each(data[i].Groups, function (j) {
$groupSelect.append('<option value="' + data[i].Groups[j].ID + '">' + data[i].Groups[j].Num + ' группа</option>');
});
$groupSelect.append('</optgroup>');
});
$groupSelect.removeAttr('disabled');
}, 'json');
}
}); });
// Выбор группы // Выбор группы
$groupSelect.change(function () { $groupSelect.change(function () {
if (($groupSelect.find('option:selected').val() != '0')) { if (($groupSelect.find('option:selected').val() != '0')) {
$inputGroupSubmit.removeAttr('disabled'); $inputGroupSubmit.turnOn();
} }
}); });
......
$(function () { $(function () {
// todo: used in dead url (see office/students/action_profile)
// todo: название переменной не соответствует содержимому - group, grade
var $grade = $("#SelectGroup"); var $grade = $("#SelectGroup");
var $groupSelect = $("#SelectGroup")
$grade.change(function () { let groupSelect = getGroupLoader($groupSelect,
$grade.html(''); () => ({FacultyID: facultyID, 'GradeID': +$grade.find('option:selected').val()})
$grade.attr('disabled', 'disabled'); ).setOnChange(OptionLoader.stubFoo);
$.post(URLdir + 'handler/students/getGroups', {
'facultyID': facultyID, $grade.change(() => groupSelect.reload());
'gradeNum': $grade.find('option:selected').val()
},
function (data) {
$.each(data, function (i) {
var grade = data[i];
$.each(grade.Groups, function (j) {
var group = grade.Groups[j];
var option = '<option value="' + group.ID + '">' + group.Num + ' группа (' + grade.SpecAbbr + ')</option>';
$("#SelectGroup").append(option);
});
});
$grade.removeAttr("disabled");
}, "json"); // fixme what is it?
});
}); });
...@@ -97,3 +97,10 @@ Element.prototype.toggleClass = function (className) { ...@@ -97,3 +97,10 @@ Element.prototype.toggleClass = function (className) {
this.className += ' ' + className; this.className += ' ' + className;
} }
}; };
let getSettings = (() => {
let $hiddenInfo = $('#hidden_div');
let settings = $.parseJSON($hiddenInfo.html());
$hiddenInfo.remove();
return settings;
});
// todo: unused file
// todo: depends on optionLoader.js
// Класс поисковой формы // Класс поисковой формы
function cSearch() { function cSearch() {
this._jSearchResultContainer = $('.SearchResult'); this._jSearchResultContainer = $('.SearchResult');
...@@ -80,28 +83,21 @@ function SearchStudent(jName, jFacultySelect, jGradeSelect, jGroupSelect) { ...@@ -80,28 +83,21 @@ function SearchStudent(jName, jFacultySelect, jGradeSelect, jGroupSelect) {
}); });
}; };
let groupSelect = getGroupLoader(jGroupSelect,
() => ({FacultyID: +jFacultySelect.val(), 'GradeID': +jGradeSelect.val()})
).setOnChange(OptionLoader.stubFoo);
jName.keyup(typeWatcher).bind("paste", typeWatcher); jName.keyup(typeWatcher).bind("paste", typeWatcher);
jFacultySelect.change(function (){ jFacultySelect.change(function (){
jGradeSelect.find('option[value=0]').attr("selected", "selected"); jGradeSelect.find('option[value=0]').attr("selected", "selected");
jGroupSelect.html("").attr("disabled", "disabled").append('<option>-- Фильтр по группе --</option>'); groupSelect.nullify();
self.Search(); self.Search();
}); });
jGradeSelect.change(function () { jGradeSelect.change(function () {
self.Search(); self.Search();
jGroupSelect.html("").attr("disabled", "disabled").append('<option>-- Фильтр по группе --</option>'); groupSelect.reload();
$.post(URLdir + 'handler/students/getGroups',
{
facultyID: jFacultySelect.find('option:selected').val(),
gradeNum: jGradeSelect.find('option:selected').val() // FIXME: хендлеру нужен gadeNum
},
function (response) {
jGroupSelect.removeAttr("disabled");
$.each(response, function (i) {
var option = Mustache.render("<option value='{{ ID }}'>{{ Num }} группа ({{ SpecName }})</option>", response[i]);
jGroupSelect.append(option);
});
},
"json");
}); });
jGroupSelect.change(self.Search); jGroupSelect.change(self.Search);
} }
......
$(function () { $(function () {
let settings = (() => { let settings = getSettings();
let $hiddenInfo = $('#hidden_div');
let settings = $.parseJSON($hiddenInfo.html());
$hiddenInfo.remove();
return settings;
})();
let $semesterSelect = $('#semesterSelect'); let $semesterSelect = $('#semesterSelect');
let $gradeSelect = $('#gradeSelect'); let $gradeSelect = $('#gradeSelect');
......
var $ = jQuery; var $ = jQuery;
var langNotChosen = '– Не выбрана –'; var langNotChosen = '– Не выбрана –';
$(function() { $(function () {
function controlVisualization() { let settings = getSettings();
var disciplineType = $("input[name=DisciplineType]:checked").val();
if (disciplineType === 'exam') { function controlVisualization() {
$("#SelectDisciplineDiv").show(); var disciplineType = $("input[name=DisciplineType]:checked").val();
$("#DownloadStatement").hide(); if (disciplineType === 'exam') {
} else if (disciplineType === 'credit') { $("#SelectDisciplineDiv").show();
$("#SelectDisciplineDiv").hide(); $("#DownloadStatement").hide();
$("#DownloadStatement").show(); } else if (disciplineType === 'credit') {
} $("#SelectDisciplineDiv").hide();
} $("#DownloadStatement").show();
}
}
// on page loaded // on page loaded
controlVisualization(); controlVisualization();
var jDownloadStatement = $("#DownloadStatement"); var jDownloadStatement = $("#DownloadStatement");
var jDownloadExamDocument = $("#DownloadExamDocument"); var jDownloadExamDocument = $("#DownloadExamDocument");
var jSelectGroup = $("#SelectGroup"); var jSelectGroup = $("#SelectGroup");
var jSelectDiscipline = $("#SelectDiscipline"); var jSelectDiscipline = $("#SelectDiscipline");
var jDownloadXML = $("#DownloadXML"); var jDownloadXML = $("#DownloadXML");
let $grade = $("#SelectGrade");
$("#ExamChoice").change(controlVisualization); $("#ExamChoice").change(controlVisualization);
$("#CreditChoice").change(controlVisualization); $("#CreditChoice").change(controlVisualization);
//Получить список групп по ID курса let groupSelect = getGroupLoader(jSelectGroup,
$("#SelectGrade").change(function() { () => ({FacultyID: settings.facultyID, 'GradeID': +$grade.val()})
var gradeID = parseInt($(this).val()) || 0; ).setOnChange(OptionLoader.stubFoo);
if (gradeID > 0) {
$.post(
g_URLdir + "handler/GetData/GetGroups",
{
"GradeID": gradeID
},
function(d){
d = $.parseJSON(d);
if(d.success === true) {
console.log(d.data);
var i = 0;
jSelectGroup.html("<option>" + langNotChosen + "</option>");
jSelectDiscipline.html("<option>" + langNotChosen + "</option>");
for (i in d.data)
{
group = d.data[i];
jSelectGroup.append("<option value='"+ group.ID +"'>Группа "+ group.GroupNum +" ("+ group.SpecAbbr +")</option>");
}
if (i > 0 )
jSelectGroup.removeAttr("disabled");
}
}
);
}
else
{
jSelectGroup.attr("disabled", "disabled");
jSelectGroup.html("<option>" + langNotChosen + "</option>");
jDownloadStatement.attr("disabled", "disabled"); //Получить список групп по ID курса
} $grade.change(function () {
jDownloadExamDocument.attr("disabled", "disabled"); let gradeID = +$grade.val();
jDownloadXML.attr("disabled", "disabled"); if (gradeID > 0)
groupSelect.reload();
else
jDownloadStatement.turnOff();
jDownloadExamDocument.turnOff();
jDownloadXML.turnOff();
}); });
$("#SelectGroup").change(function() { jSelectGroup.change(function () {
var groupID = parseInt($(this).val()) || 0; var groupID = +jSelectGroup.val();
if (groupID > 0) { if (groupID > 0) {
jDownloadStatement.removeAttr("disabled"); jDownloadStatement.removeAttr("disabled");
// Заполнить список дисциплин // Заполнить список дисциплин
...@@ -80,7 +61,6 @@ $(function() { ...@@ -80,7 +61,6 @@ $(function() {
function (d) { function (d) {
d = $.parseJSON(d); d = $.parseJSON(d);
if (d.success === true) { if (d.success === true) {
console.log(d.data);
var i = 0; var i = 0;
jSelectDiscipline.html("<option>" + langNotChosen + "</option>"); jSelectDiscipline.html("<option>" + langNotChosen + "</option>");
for (i in d.data) { for (i in d.data) {
...@@ -95,15 +75,15 @@ $(function() { ...@@ -95,15 +75,15 @@ $(function() {
} }
); );
} }
else jDownloadStatement.attr("disabled", "disabled"); else jDownloadStatement.attr("disabled", "disabled");
jDownloadXML.attr("disabled", "disabled"); jDownloadXML.attr("disabled", "disabled");
jDownloadExamDocument.attr("disabled", "disabled"); jDownloadExamDocument.attr("disabled", "disabled");
}); });
$("#SelectDiscipline").change(function() { jSelectDiscipline.change(function () {
var disciplineID = parseInt($(this).val()) || 0; var disciplineID = parseInt($(this).val()) || 0;
if (disciplineID > 0){ if (disciplineID > 0) {
jDownloadExamDocument.removeAttr("disabled"); jDownloadExamDocument.removeAttr("disabled");
jDownloadXML.removeAttr("disabled"); jDownloadXML.removeAttr("disabled");
} }
...@@ -114,11 +94,10 @@ $(function() { ...@@ -114,11 +94,10 @@ $(function() {
}); });
// Скачать ведомость // Скачать ведомость
$('body').on('click', '#DownloadStatement', function(){ $('body').on('click', '#DownloadStatement', function () {
$.fileDownload( g_URLdir + 'handler/FileCreator/GenerateFinalFormsForGroup', { $.fileDownload(g_URLdir + 'handler/FileCreator/GenerateFinalFormsForGroup', {
httpMethod: "POST", httpMethod: "POST",
data: data: {
{
"GroupID": parseInt($("#SelectGroup").val())//, "GroupID": parseInt($("#SelectGroup").val())//,
//"ExamType": $("input[name=DisciplineType]:checked").val() //"ExamType": $("input[name=DisciplineType]:checked").val()
}, },
...@@ -132,11 +111,10 @@ $(function() { ...@@ -132,11 +111,10 @@ $(function() {
}); });
// Печать ведомости // Печать ведомости
$('body').on('click', '#DownloadExamDocument', function(){ $('body').on('click', '#DownloadExamDocument', function () {
$.fileDownload( g_URLdir + 'handler/FileCreator/GenerateFinalForm', { $.fileDownload(g_URLdir + 'handler/FileCreator/GenerateFinalForm', {
httpMethod: "POST", httpMethod: "POST",
data: data: {
{
"disciplineID": parseInt($("#SelectDiscipline").val()), "disciplineID": parseInt($("#SelectDiscipline").val()),
"studyGroupID": parseInt($("#SelectGroup").val()) "studyGroupID": parseInt($("#SelectGroup").val())
}, },
...@@ -150,11 +128,10 @@ $(function() { ...@@ -150,11 +128,10 @@ $(function() {
}); });
$('body').on('click', '#DownloadXML', function(){ $('body').on('click', '#DownloadXML', function () {
$.fileDownload(g_URLdir + 'handler/XMLCreator/GenerateXMLFile', { $.fileDownload(g_URLdir + 'handler/XMLCreator/GenerateXMLFile', {
httpMethod: "POST", httpMethod: "POST",
data: data: {
{
"disciplineID": parseInt($("#SelectDiscipline").val()), "disciplineID": parseInt($("#SelectDiscipline").val()),
"studyGroupID": parseInt($("#SelectGroup").val()) "studyGroupID": parseInt($("#SelectGroup").val())
}, },
...@@ -165,7 +142,7 @@ $(function() { ...@@ -165,7 +142,7 @@ $(function() {
} }
}); });
}); });
// Блокирование дисциплины // Блокирование дисциплины
......
...@@ -88,7 +88,7 @@ $(function() { ...@@ -88,7 +88,7 @@ $(function() {
let groupSelect = getGroupLoader($groupSelect, let groupSelect = getGroupLoader($groupSelect,
() => ({'FacultyID': g_facultyID, 'GradeID': +$gradeSelect.val()}) () => ({FacultyID, 'GradeID': +$gradeSelect.val()})
).setOnChange(OptionLoader.stubFoo); ).setOnChange(OptionLoader.stubFoo);
$gradeSelect.change(() => groupSelect.reload()); $gradeSelect.change(() => groupSelect.reload());
......
...@@ -45,12 +45,18 @@ class OptionLoader { ...@@ -45,12 +45,18 @@ class OptionLoader {
reload() { reload() {
$.postJSON(this.url, this.genParams(), data => { $.postJSON(this.url, this.genParams(), data => {
let html = this.placeholder + OptionLoader.constructSelectData(data, this.factory); let html = this.placeholder + OptionLoader.constructSelectData(data, this.factory);
this.$select.turnOff();
this.$select.empty(); this.$select.empty();
this.$select.append($(html)); this.$select.append($(html));
this.$select.turnOn();
this.onReload(); this.onReload();
}); });
} }
nullify() {
this.$select.html(this.placeholder);
}
setPlaceholder(placeholder) { setPlaceholder(placeholder) {
this.placeholder = OptionLoader.generatePlaceholderOption(placeholder); this.placeholder = OptionLoader.generatePlaceholderOption(placeholder);
return this; return this;
...@@ -100,7 +106,7 @@ let getGroupLoader = ($select, genParams) => { ...@@ -100,7 +106,7 @@ let getGroupLoader = ($select, genParams) => {
// ============================ // ============================
// groups // grades
// ============================ // ============================
/** /**
......
var settings = {};
function GroupFunction(type) { function GroupFunction(type) {
var jSemesters = $('#semesters' + type); var jSemesters = $('#semesters' + type);
var jGrades = $('#grades' + type); var jGrades = $('#grades' + type);
var jGroupTransfer = $('#groupTransfer' + type); // var jGroupTransfer = $('#groupTransfer' + type);
var jGroupSelect = $('#group' + type); var jGroupSelect = $('#group' + type);
var jItemContainer = $('.TransferListItem'); // var jItemContainer = $('.TransferListItem');
var jList = $("#" + type + "ItemsList"); var jList = $("#" + type + "ItemsList");
jGrades.find('option[value=-1]').attr('selected', 'selected'); jGrades.find('option[value=-1]').attr('selected', 'selected');
...@@ -23,21 +25,17 @@ function GroupFunction(type) { ...@@ -23,21 +25,17 @@ function GroupFunction(type) {
jList.html(''); jList.html('');
}); });
jGrades.change(function () {
var gr_id = jGrades.find('option:selected').val();
if (gr_id) {
jGroupSelect.prop('disabled', false);
$.post(URLdir + 'handler/Transfer/getGroups',
{'gradeID': jGrades.find('option:selected').val()},
function (data) {
jGroupSelect.html(data);
});
} else {
jGroupSelect.prop('disabled', true);
}
// clear list let groupSelect = getGroupLoader(jGroupSelect,
jList.html(''); () => ({FacultyID: settings.facultyID, 'GradeID': +jGrades.val()})
).setOnChange(OptionLoader.stubFoo);
jGrades.change(() => {
let gradeID = jGrades.val();
if (gradeID)
groupSelect.reload();
else
groupSelect.turnOff();
}); });
var jButtonSelect = $('#SelectAll' + type); var jButtonSelect = $('#SelectAll' + type);
...@@ -57,7 +55,9 @@ function GroupFunction(type) { ...@@ -57,7 +55,9 @@ function GroupFunction(type) {
$(this).removeClass('selected') : $(this).addClass('selected'); $(this).removeClass('selected') : $(this).addClass('selected');
}); });
} }
$(function () { $(function () {
settings = getSettings();
GroupFunction('Left'); GroupFunction('Left');
GroupFunction('Right'); GroupFunction('Right');
......
...@@ -9,13 +9,6 @@ class Controller_Handler_GetData extends Controller_Handler ...@@ -9,13 +9,6 @@ class Controller_Handler_GetData extends Controller_Handler
$this->user->checkAccess(User::RIGHTS_AUTHORIZED); // todo: is it? $this->user->checkAccess(User::RIGHTS_AUTHORIZED); // todo: is it?
} }
public function action_GetGroups() {
$res['data'] = $this->user->Faculty->getGroups($this->post['GradeID']);
$res['success'] = true;
$this->response->body(json_encode($res));
}
public function action_GetDisciplinesForGroup() { public function action_GetDisciplinesForGroup() {
$response['data'] = Model_Group::with($_POST['groupID']) $response['data'] = Model_Group::with($_POST['groupID'])
->getDisciplines($lazy = false, $this->post['semesterID']); ->getDisciplines($lazy = false, $this->post['semesterID']);
......
...@@ -44,25 +44,6 @@ class Controller_Handler_Students extends Controller_Handler ...@@ -44,25 +44,6 @@ class Controller_Handler_Students extends Controller_Handler
$this->response->body(json_encode(Model_Students::ofGroup($groupID, $semesterID))); $this->response->body(json_encode(Model_Students::ofGroup($groupID, $semesterID)));
} }
public function action_getGroups() {
$facultyID = $this->post['facultyID'];
$gradeID = $this->post['gradeNum'];
$groupsHandled = [];
if (($facultyID && $gradeID) != 0) {
$groups = Model_Faculty::with($facultyID)->getGroups($gradeID);
foreach ($groups as $row)
$groupsHandled[] = [
'ID' => $row['ID'],
'Num' => $row['GroupNum'],
'SpecName' => is_null($row['SpecName']) ? 'Без специализации' : $row['SpecName'],
'SpecAbbr' => is_null($row['SpecAbbr']) ? '' : $row['SpecAbbr'],
];
}
$this->response->body(json_encode($groupsHandled));
}
private function groupByID($array) private function groupByID($array)
{ {
$result = []; $result = [];
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
{{ HTML.script('static/js/transfer/controller.js')|raw }} {{ HTML.script('static/js/transfer/controller.js')|raw }}
{{ HTML.script('static/js/transfer.js')|raw }} {{ HTML.script('static/js/transfer.js')|raw }}
{{ HTML.style('static/css/controls/transfer.css')|raw }} {{ HTML.style('static/css/controls/transfer.css')|raw }}
{{ HTML.script('static/js/optionLoader.js')|raw }}
{% endmacro %} {% endmacro %}
{% macro TransferList(Type, SemestersList, GradesList, CurrentSemester) %} {% macro TransferList(Type, SemestersList, GradesList, CurrentSemester) %}
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
{{ HTML.script('static/js/libs/jquery.fileDownload.js')|raw }} {{ HTML.script('static/js/libs/jquery.fileDownload.js')|raw }}
{{ HTML.style('static/css/discipline.css')|raw }} {{ HTML.style('static/css/discipline.css')|raw }}
{{ HTML.style('static/css/common/forms.css')|raw }} {{ HTML.style('static/css/common/forms.css')|raw }}
{{ HTML.script('static/js/optionLoader.js')|raw }}
{{ HTML.script('static/js/dean/dean.js')|raw }} {{ HTML.script('static/js/dean/dean.js')|raw }}
{% endblock %} {% endblock %}
...@@ -98,5 +99,6 @@ ...@@ -98,5 +99,6 @@
</div> </div>
</div> </div>
</div> </div>
<div id="hidden_div" style="display: none">{ "facultyID" : {{ User.FacultyID }} }</div>
{% endblock %} {% endblock %}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
{% block office_media %} {% block office_media %}
{{ HTML.style('static/css/admin/inputGroup.css')|raw }} {{ HTML.style('static/css/admin/inputGroup.css')|raw }}
{{ HTML.script('static/js/optionLoader.js')|raw }}
{{ HTML.script('static/js/admin/students/add.js')|raw }} {{ HTML.script('static/js/admin/students/add.js')|raw }}
{% endblock %} {% endblock %}
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
{% block office_media %} {% block office_media %}
{{ HTML.style('static/css/admin/profilePage.css')|raw }} {{ HTML.style('static/css/admin/profilePage.css')|raw }}
{{ HTML.script('static/js/optionLoader.js')|raw }}
{{ HTML.script('static/js/admin/students/profile.js')|raw }} {{ HTML.script('static/js/admin/students/profile.js')|raw }}
<script> <script>
var facultyID = {{ Profile.FacultyID }}; var facultyID = {{ Profile.FacultyID }};
......
...@@ -10,4 +10,5 @@ ...@@ -10,4 +10,5 @@
{% block office_content %} {% block office_content %}
<h2 class="defaultForm marginBetween">Перевод студентов</h2> <h2 class="defaultForm marginBetween">Перевод студентов</h2>
<div class="defaultForm marginBetween">{{ transfer.control(SemestersList, GradesList, CurrentSemester) }}</div> <div class="defaultForm marginBetween">{{ transfer.control(SemestersList, GradesList, CurrentSemester) }}</div>
<div id="hidden_div" style="display: none">{ "facultyID" : {{ User.FacultyID }} }</div>
{% endblock %} {% endblock %}
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