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 () {
}
});
let groupSelect = getGroupLoader($groupSelect,
() => ({FacultyID: +$facultySelect.val(), 'GradeID': +$gradeSelect.val()})
).setOnChange(OptionLoader.stubFoo);
// Выбор курса
$gradeSelect.change(function () {
$gradeSelect.change(() => {
$searchResults.html('');
$groupSelect.attr('disabled', 'disabled');
$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.reload();
});
// Выбор группы
$groupSelect.change(function () {
if (($groupSelect.find('option:selected').val() != '0')) {
$inputGroupSubmit.removeAttr('disabled');
$inputGroupSubmit.turnOn();
}
});
......
$(function () {
// todo: used in dead url (see office/students/action_profile)
// todo: название переменной не соответствует содержимому - group, grade
var $grade = $("#SelectGroup");
var $groupSelect = $("#SelectGroup")
$grade.change(function () {
$grade.html('');
$grade.attr('disabled', 'disabled');
$.post(URLdir + 'handler/students/getGroups', {
'facultyID': facultyID,
'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?
});
let groupSelect = getGroupLoader($groupSelect,
() => ({FacultyID: facultyID, 'GradeID': +$grade.find('option:selected').val()})
).setOnChange(OptionLoader.stubFoo);
$grade.change(() => groupSelect.reload());
});
......@@ -97,3 +97,10 @@ Element.prototype.toggleClass = function (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() {
this._jSearchResultContainer = $('.SearchResult');
......@@ -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);
jFacultySelect.change(function (){
jGradeSelect.find('option[value=0]').attr("selected", "selected");
jGroupSelect.html("").attr("disabled", "disabled").append('<option>-- Фильтр по группе --</option>');
groupSelect.nullify();
self.Search();
});
jGradeSelect.change(function () {
self.Search();
jGroupSelect.html("").attr("disabled", "disabled").append('<option>-- Фильтр по группе --</option>');
$.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");
groupSelect.reload();
});
jGroupSelect.change(self.Search);
}
......
$(function () {
let settings = (() => {
let $hiddenInfo = $('#hidden_div');
let settings = $.parseJSON($hiddenInfo.html());
$hiddenInfo.remove();
return settings;
})();
let settings = getSettings();
let $semesterSelect = $('#semesterSelect');
let $gradeSelect = $('#gradeSelect');
......
var $ = jQuery;
var langNotChosen = '– Не выбрана –';
$(function() {
function controlVisualization() {
var disciplineType = $("input[name=DisciplineType]:checked").val();
if (disciplineType === 'exam') {
$("#SelectDisciplineDiv").show();
$("#DownloadStatement").hide();
} else if (disciplineType === 'credit') {
$("#SelectDisciplineDiv").hide();
$("#DownloadStatement").show();
}
}
$(function () {
let settings = getSettings();
function controlVisualization() {
var disciplineType = $("input[name=DisciplineType]:checked").val();
if (disciplineType === 'exam') {
$("#SelectDisciplineDiv").show();
$("#DownloadStatement").hide();
} else if (disciplineType === 'credit') {
$("#SelectDisciplineDiv").hide();
$("#DownloadStatement").show();
}
}
// on page loaded
controlVisualization();
var jDownloadStatement = $("#DownloadStatement");
var jDownloadExamDocument = $("#DownloadExamDocument");
var jSelectGroup = $("#SelectGroup");
var jSelectDiscipline = $("#SelectDiscipline");
var jSelectGroup = $("#SelectGroup");
var jSelectDiscipline = $("#SelectDiscipline");
var jDownloadXML = $("#DownloadXML");
let $grade = $("#SelectGrade");
$("#ExamChoice").change(controlVisualization);
$("#CreditChoice").change(controlVisualization);
//Получить список групп по ID курса
$("#SelectGrade").change(function() {
var gradeID = parseInt($(this).val()) || 0;
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>");
let groupSelect = getGroupLoader(jSelectGroup,
() => ({FacultyID: settings.facultyID, 'GradeID': +$grade.val()})
).setOnChange(OptionLoader.stubFoo);
jDownloadStatement.attr("disabled", "disabled");
}
jDownloadExamDocument.attr("disabled", "disabled");
jDownloadXML.attr("disabled", "disabled");
//Получить список групп по ID курса
$grade.change(function () {
let gradeID = +$grade.val();
if (gradeID > 0)
groupSelect.reload();
else
jDownloadStatement.turnOff();
jDownloadExamDocument.turnOff();
jDownloadXML.turnOff();
});
$("#SelectGroup").change(function() {
var groupID = parseInt($(this).val()) || 0;
if (groupID > 0) {
jSelectGroup.change(function () {
var groupID = +jSelectGroup.val();
if (groupID > 0) {
jDownloadStatement.removeAttr("disabled");
// Заполнить список дисциплин
......@@ -80,7 +61,6 @@ $(function() {
function (d) {
d = $.parseJSON(d);
if (d.success === true) {
console.log(d.data);
var i = 0;
jSelectDiscipline.html("<option>" + langNotChosen + "</option>");
for (i in d.data) {
......@@ -95,15 +75,15 @@ $(function() {
}
);
}
else jDownloadStatement.attr("disabled", "disabled");
else jDownloadStatement.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;
if (disciplineID > 0){
if (disciplineID > 0) {
jDownloadExamDocument.removeAttr("disabled");
jDownloadXML.removeAttr("disabled");
}
......@@ -114,11 +94,10 @@ $(function() {
});
// Скачать ведомость
$('body').on('click', '#DownloadStatement', function(){
$.fileDownload( g_URLdir + 'handler/FileCreator/GenerateFinalFormsForGroup', {
$('body').on('click', '#DownloadStatement', function () {
$.fileDownload(g_URLdir + 'handler/FileCreator/GenerateFinalFormsForGroup', {
httpMethod: "POST",
data:
{
data: {
"GroupID": parseInt($("#SelectGroup").val())//,
//"ExamType": $("input[name=DisciplineType]:checked").val()
},
......@@ -132,11 +111,10 @@ $(function() {
});
// Печать ведомости
$('body').on('click', '#DownloadExamDocument', function(){
$.fileDownload( g_URLdir + 'handler/FileCreator/GenerateFinalForm', {
$('body').on('click', '#DownloadExamDocument', function () {
$.fileDownload(g_URLdir + 'handler/FileCreator/GenerateFinalForm', {
httpMethod: "POST",
data:
{
data: {
"disciplineID": parseInt($("#SelectDiscipline").val()),
"studyGroupID": parseInt($("#SelectGroup").val())
},
......@@ -150,11 +128,10 @@ $(function() {
});
$('body').on('click', '#DownloadXML', function(){
$('body').on('click', '#DownloadXML', function () {
$.fileDownload(g_URLdir + 'handler/XMLCreator/GenerateXMLFile', {
httpMethod: "POST",
data:
{
data: {
"disciplineID": parseInt($("#SelectDiscipline").val()),
"studyGroupID": parseInt($("#SelectGroup").val())
},
......@@ -165,7 +142,7 @@ $(function() {
}
});
});
});
// Блокирование дисциплины
......
......@@ -88,7 +88,7 @@ $(function() {
let groupSelect = getGroupLoader($groupSelect,
() => ({'FacultyID': g_facultyID, 'GradeID': +$gradeSelect.val()})
() => ({FacultyID, 'GradeID': +$gradeSelect.val()})
).setOnChange(OptionLoader.stubFoo);
$gradeSelect.change(() => groupSelect.reload());
......
......@@ -45,12 +45,18 @@ class OptionLoader {
reload() {
$.postJSON(this.url, this.genParams(), data => {
let html = this.placeholder + OptionLoader.constructSelectData(data, this.factory);
this.$select.turnOff();
this.$select.empty();
this.$select.append($(html));
this.$select.turnOn();
this.onReload();
});
}
nullify() {
this.$select.html(this.placeholder);
}
setPlaceholder(placeholder) {
this.placeholder = OptionLoader.generatePlaceholderOption(placeholder);
return this;
......@@ -100,7 +106,7 @@ let getGroupLoader = ($select, genParams) => {
// ============================
// groups
// grades
// ============================
/**
......
var settings = {};
function GroupFunction(type) {
var jSemesters = $('#semesters' + type);
var jGrades = $('#grades' + type);
var jGroupTransfer = $('#groupTransfer' + type);
// var jGroupTransfer = $('#groupTransfer' + type);
var jGroupSelect = $('#group' + type);
var jItemContainer = $('.TransferListItem');
// var jItemContainer = $('.TransferListItem');
var jList = $("#" + type + "ItemsList");
jGrades.find('option[value=-1]').attr('selected', 'selected');
......@@ -23,21 +25,17 @@ function GroupFunction(type) {
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
jList.html('');
let groupSelect = getGroupLoader(jGroupSelect,
() => ({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);
......@@ -57,7 +55,9 @@ function GroupFunction(type) {
$(this).removeClass('selected') : $(this).addClass('selected');
});
}
$(function () {
settings = getSettings();
GroupFunction('Left');
GroupFunction('Right');
......
......@@ -9,13 +9,6 @@ class Controller_Handler_GetData extends Controller_Handler
$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() {
$response['data'] = Model_Group::with($_POST['groupID'])
->getDisciplines($lazy = false, $this->post['semesterID']);
......
......@@ -44,25 +44,6 @@ class Controller_Handler_Students extends Controller_Handler
$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)
{
$result = [];
......
......@@ -5,6 +5,7 @@
{{ HTML.script('static/js/transfer/controller.js')|raw }}
{{ HTML.script('static/js/transfer.js')|raw }}
{{ HTML.style('static/css/controls/transfer.css')|raw }}
{{ HTML.script('static/js/optionLoader.js')|raw }}
{% endmacro %}
{% macro TransferList(Type, SemestersList, GradesList, CurrentSemester) %}
......
......@@ -7,6 +7,7 @@
{{ HTML.script('static/js/libs/jquery.fileDownload.js')|raw }}
{{ HTML.style('static/css/discipline.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 }}
{% endblock %}
......@@ -98,5 +99,6 @@
</div>
</div>
</div>
<div id="hidden_div" style="display: none">{ "facultyID" : {{ User.FacultyID }} }</div>
{% endblock %}
......@@ -2,6 +2,7 @@
{% block office_media %}
{{ HTML.style('static/css/admin/inputGroup.css')|raw }}
{{ HTML.script('static/js/optionLoader.js')|raw }}
{{ HTML.script('static/js/admin/students/add.js')|raw }}
{% endblock %}
......
......@@ -4,6 +4,7 @@
{% block office_media %}
{{ HTML.style('static/css/admin/profilePage.css')|raw }}
{{ HTML.script('static/js/optionLoader.js')|raw }}
{{ HTML.script('static/js/admin/students/profile.js')|raw }}
<script>
var facultyID = {{ Profile.FacultyID }};
......
......@@ -10,4 +10,5 @@
{% block office_content %}
<h2 class="defaultForm marginBetween">Перевод студентов</h2>
<div class="defaultForm marginBetween">{{ transfer.control(SemestersList, GradesList, CurrentSemester) }}</div>
<div id="hidden_div" style="display: none">{ "facultyID" : {{ User.FacultyID }} }</div>
{% 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