mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
Added JS to create Anrechnungsantrag + Adapted TableWidget.js option
Adapted TableWidgets option 'rowSelectionChanged' to be able to directly define rowSelectionChanged within particular JS file, if needed. Signed-off-by: cris-technikum <hainberg@technikum-wien.at>
This commit is contained in:
@@ -552,9 +552,12 @@ var FHC_TableWidget = {
|
||||
options.movableColumns = true; // allows changing column order
|
||||
options.tooltipsHeader = true; // set header tooltip with column title
|
||||
options.placeholder = _func_placeholder(); // display text when table is empty
|
||||
options.rowSelectionChanged = function(data, rows){
|
||||
_func_rowSelectionChanged(data, rows);
|
||||
};
|
||||
if (options.rowSelectionChanged == 'undefined')
|
||||
{
|
||||
options.rowSelectionChanged = function(data, rows){
|
||||
_func_rowSelectionChanged(data, rows);
|
||||
};
|
||||
}
|
||||
options.columnVisibilityChanged = function(column, visible) {
|
||||
_func_columnVisibilityChanged(column, visible);
|
||||
};
|
||||
|
||||
@@ -24,6 +24,9 @@ $(function(){
|
||||
// Set status alert color
|
||||
approveAnrechnungDetail.setStatusAlertColor();
|
||||
|
||||
// Set Empfehlungstext
|
||||
approveAnrechnungDetail.setEmpfehlungstext();
|
||||
|
||||
// Init tooltips
|
||||
approveAnrechnungDetail.initTooltips();
|
||||
|
||||
@@ -189,8 +192,9 @@ $(function(){
|
||||
if (!data.error && data.retval != null)
|
||||
{
|
||||
approveAnrechnungDetail.formatEmpfehlungIsRequested(
|
||||
data.retval[0].empfehlung_angefordert_am,
|
||||
data.retval[0].status_bezeichnung
|
||||
data.retval[0].status_bezeichnung,
|
||||
data.retval[0].empfehlungsanfrageAm,
|
||||
data.retval[0].empfehlungsanfrageAn
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -339,6 +343,24 @@ var approveAnrechnungDetail = {
|
||||
$('#approveAnrechnungDetail-status_kurzbz').closest('div').addClass('alert-warning');
|
||||
}
|
||||
},
|
||||
setEmpfehlungstext: function () {
|
||||
let empfehlung = $('#approveAnrechnungDetail-empfehlung').data('empfehlung');
|
||||
|
||||
switch (empfehlung) {
|
||||
case true:
|
||||
$('#approveAnrechnungDetail-empfehlungDetail-empfehlung')
|
||||
.addClass('text-success')
|
||||
.html(FHC_PhrasesLib.t("anrechnung", "empfehlungPositivConfirmed"));
|
||||
break;
|
||||
case false:
|
||||
$('#approveAnrechnungDetail-empfehlungDetail-empfehlung')
|
||||
.addClass('text-danger')
|
||||
.html(FHC_PhrasesLib.t("anrechnung", "empfehlungNegativConfirmed"));
|
||||
break;
|
||||
default:
|
||||
$('#approveAnrechnungDetail-empfehlungDetail-empfehlung').html('-');
|
||||
}
|
||||
},
|
||||
initTooltips: function (){
|
||||
$('[data-toggle="tooltip"]').tooltip({
|
||||
delay: { "show": 200, "hide": 200 },
|
||||
@@ -363,10 +385,9 @@ var approveAnrechnungDetail = {
|
||||
textarea.val($.trim($(elem).parent().find('span:first').text()));
|
||||
}
|
||||
},
|
||||
formatEmpfehlungIsRequested: function(empfehlungAngefordertAm, statusBezeichnung) {
|
||||
$('#approveAnrechnungDetail-empfehlungDetail').children().addClass('hidden');
|
||||
$('#approveAnrechnungDetail-empfehlungDetail-empfehlungIsAngefordert').removeClass('hidden');
|
||||
$('#approveAnrechnungDetail-empfehlungDetail-empfehlungAngefordertAm').text(empfehlungAngefordertAm);
|
||||
formatEmpfehlungIsRequested: function(statusBezeichnung, empfehlungsanfrageAm, empfehlungsanfrageAn) {
|
||||
$('#approveAnrechnungDetail-empfehlungDetail-empfehlungsanfrageAm').html(empfehlungsanfrageAm);
|
||||
$('#approveAnrechnungDetail-empfehlungDetail-empfehlungsanfrageAn').html(empfehlungsanfrageAn);
|
||||
$('#approveAnrechnungDetail-status_kurzbz').text(statusBezeichnung);
|
||||
$('#approveAnrechnungDetail-request-recommendation').prop('disabled', true);
|
||||
$('#approveAnrechnungDetail-approve-anrechnung-ask').prop('disabled', true);
|
||||
@@ -429,8 +450,9 @@ var approveAnrechnungDetail = {
|
||||
formatEmpfehlungIsWithdrawed: function (statusBezeichnung){
|
||||
$('#approveAnrechnungDetail-status_kurzbz').text(statusBezeichnung);
|
||||
|
||||
$('#approveAnrechnungDetail-empfehlungDetail-empfehlungIsAngefordert').addClass('hidden');
|
||||
$('#approveAnrechnungDetail-empfehlungDetail-empfehlungIsNull').removeClass('hidden');
|
||||
$('#approveAnrechnungDetail-empfehlungDetail-empfehlungsanfrageAm').html('-');
|
||||
$('#approveAnrechnungDetail-empfehlungDetail-empfehlungsanfrageAn').html('-');
|
||||
|
||||
$('#approveAnrechnungDetail-request-recommendation').prop('disabled', false);
|
||||
$('#approveAnrechnungDetail-approve-anrechnung-ask').prop('disabled', false);
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
$(function () {
|
||||
|
||||
// Disable all form fields by default
|
||||
createAnrechnung.disableFormFields();
|
||||
|
||||
// Create Anrechnung on form submit
|
||||
$('#createAnrechnung-submit').click(function(e){
|
||||
|
||||
// Avoid form redirecting automatically
|
||||
e.preventDefault();
|
||||
|
||||
// Get form data
|
||||
let formData = new FormData($('#createAnrechnung-form')[0]);
|
||||
|
||||
$.ajax({
|
||||
url : "CreateAnrechnung/create",
|
||||
type: "POST",
|
||||
data : formData,
|
||||
processData: false, // needed to pass uploaded file with FormData
|
||||
contentType: false, // needed to pass uploaded file with FormData
|
||||
success:function(data, textStatus, jqXHR){
|
||||
|
||||
if (FHC_AjaxClient.isError(data))
|
||||
{
|
||||
FHC_DialogLib.alertWarning(FHC_AjaxClient.getError(data));
|
||||
}
|
||||
|
||||
if (FHC_AjaxClient.hasData(data))
|
||||
{
|
||||
FHC_DialogLib.alertSuccess(FHC_AjaxClient.getData(data));
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown){
|
||||
|
||||
FHC_DialogLib.alertWarning(FHC_PhrasesLib.t("ui", "systemfehler"));
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
// TABULATOR FUNCTIONS
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Set form fields and populate selectmenu with LVs of student
|
||||
* on row selection.
|
||||
*
|
||||
* @param row
|
||||
*/
|
||||
function func_rowSelected(row){
|
||||
let studiensemester_kurzbz = $('#studiensemester_kurzbz').val();
|
||||
let prestudent_id = row.getData().prestudent_id;
|
||||
let vorname = row.getData().vorname;
|
||||
let nachname = row.getData().nachname;
|
||||
|
||||
// Set hidden form field Prestudent ID
|
||||
$('#prestudent_id').val(prestudent_id);
|
||||
|
||||
// Set field StudentIn
|
||||
$('#student').text(vorname + ' ' + nachname);
|
||||
|
||||
// Populate Select with LVs of student
|
||||
createAnrechnung.populateSelectWithStudentLVs(prestudent_id, studiensemester_kurzbz);
|
||||
|
||||
// Enable all form fields
|
||||
createAnrechnung.enableFormFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty and disable form fields
|
||||
* when none row selected.
|
||||
*
|
||||
* @param data
|
||||
* @param rows
|
||||
*/
|
||||
function func_rowSelectionChanged(data, rows){
|
||||
|
||||
// If no student is selected in the table
|
||||
if (rows.length == 0)
|
||||
{
|
||||
// ...empty form fields
|
||||
createAnrechnung.emptyFormFields();
|
||||
|
||||
// ...disable form fields
|
||||
createAnrechnung.disableFormFields();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
var createAnrechnung = {
|
||||
emptyFormFields: function(){
|
||||
|
||||
// Empty field StudentIn
|
||||
$('#student').text('');
|
||||
|
||||
// Empty form fields (except hidden ones)
|
||||
$('#createAnrechnung-form :input:not([type=hidden])').val('');
|
||||
},
|
||||
disableFormFields: function(){
|
||||
let prestudent_id = $('#prestudent_id').data('prestudent_id');
|
||||
|
||||
if (prestudent_id == '')
|
||||
{
|
||||
// Disable all form elements
|
||||
$("#createAnrechnung-form :input").prop("disabled", true);
|
||||
}
|
||||
},
|
||||
enableFormFields: function(){
|
||||
$("#createAnrechnung-form :input").prop("disabled", false);
|
||||
},
|
||||
populateSelectWithStudentLVs: function(prestudent_id, studiensemester_kurzbz){
|
||||
FHC_AjaxClient.ajaxCallPost(
|
||||
FHC_JS_DATA_STORAGE_OBJECT.called_path + "/getLVsByStudent",
|
||||
{'prestudent_id': prestudent_id, 'studiensemester_kurzbz': studiensemester_kurzbz},
|
||||
{
|
||||
successCallback: function (data, textStatus, jqXHR)
|
||||
{
|
||||
if (FHC_AjaxClient.isError(data))
|
||||
{
|
||||
// Print error message
|
||||
FHC_DialogLib.alertWarning(FHC_AjaxClient.getError(data));
|
||||
}
|
||||
|
||||
if (FHC_AjaxClient.hasData(data))
|
||||
{
|
||||
let lehrveranstaltungen = FHC_AjaxClient.getData(data);
|
||||
|
||||
// Remove previous Lehrveranstaltungen
|
||||
$('#select-lehrveranstaltung option').slice(1).remove(); // Leave first option 'Bitte wählen'
|
||||
|
||||
// Append Lehrveranstaltungen
|
||||
for (let lv of lehrveranstaltungen){
|
||||
$('#select-lehrveranstaltung').append('<option value="'+ lv.lehrveranstaltung_id +'">'+ lv.bezeichnung +'</option>');
|
||||
}
|
||||
}
|
||||
},
|
||||
errorCallback: function (jqXHR, textStatus, errorThrown)
|
||||
{
|
||||
FHC_DialogLib.alertError(FHC_PhrasesLib.t("ui", "systemfehler"));
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user