mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-05 04:49:28 +00:00
Ferienzeiten list: added possibility to update entries
This commit is contained in:
@@ -35,6 +35,7 @@ class Ferien extends FHCAPI_Controller
|
||||
'getFerien' => 'basis/ferien:r',
|
||||
'getStg' => 'basis/ferien:r',
|
||||
'insert' => 'basis/ferien:w',
|
||||
'update' => 'basis/ferien:w',
|
||||
'delete' => 'basis/ferien:w'
|
||||
]);
|
||||
|
||||
@@ -105,44 +106,52 @@ class Ferien extends FHCAPI_Controller
|
||||
*/
|
||||
public function insert()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$this->_validate();
|
||||
|
||||
$this->form_validation->set_rules('vondatum', 'Von Datum', 'required|is_valid_date');
|
||||
$this->form_validation->set_rules('bisdatum', 'Bis Datum', 'required|is_valid_date');
|
||||
$this->form_validation->set_rules('bezeichnung', 'Bezeichnung', 'required|max_length[128]');
|
||||
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required|numeric');
|
||||
|
||||
//Events::trigger('konto_insert_validation', $this->form_validation);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$allowed = [
|
||||
'vondatum',
|
||||
'bisdatum',
|
||||
'bezeichnung',
|
||||
'studiengang_kz'
|
||||
];
|
||||
|
||||
$data = [];
|
||||
$data = $this->_getData();
|
||||
|
||||
// TODO add insertaum and updateamum?
|
||||
//~ $data = [
|
||||
//~ 'insertamum' => date('c'),
|
||||
//~ 'insertvon' => getAuthUID()
|
||||
//~ ];
|
||||
foreach ($allowed as $field)
|
||||
{
|
||||
if ($this->input->post($field) !== null) $data[$field] = $this->input->post($field);
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
$id = $this->getDataOrTerminateWithError($this->FerienModel->insert($data));
|
||||
|
||||
$this->terminateWithSuccess(hasData($id) ? getData($id) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Ferien
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$id = $this->input->post('ferien_id');
|
||||
|
||||
if (!is_numeric($id))
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Ferien Id']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->_validate();
|
||||
|
||||
$data = $this->_getData();
|
||||
|
||||
if (isEmptyArray($data)) $this->terminateWithSuccess(null);
|
||||
// TODO add insertaum and updateamum?
|
||||
//~ $data = [
|
||||
//~ 'updateamum' => date('c'),
|
||||
//~ 'updatevon' => getAuthUID()
|
||||
//~ ];
|
||||
|
||||
$data['ferien_id'] = $id;
|
||||
|
||||
$result = $this->FerienModel->update($id, $data);
|
||||
|
||||
if (isError($result)) $this->terminateWithError(getError($result));
|
||||
|
||||
$this->terminateWithSuccess($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Ferien
|
||||
*
|
||||
@@ -181,12 +190,51 @@ class Ferien extends FHCAPI_Controller
|
||||
//Events::trigger('konto_delete', $ferien_id);
|
||||
|
||||
$result = $this->getDataOrTerminateWithError($this->FerienModel->delete($ferien_id));
|
||||
//~ if (isError($result)) {
|
||||
//~ if (getCode($result) != 42)
|
||||
//~ $this->terminateWithError(getError($result));
|
||||
//~ $this->terminateWithError($this->p->t('konto', 'error_delete_level'));
|
||||
//~ }
|
||||
|
||||
$this->terminateWithSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ferien post input.
|
||||
* @param
|
||||
* @return object success or error
|
||||
*/
|
||||
private function _validate()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('vondatum', 'Von Datum', 'required|is_valid_date');
|
||||
$this->form_validation->set_rules('bisdatum', 'Bis Datum', 'required|is_valid_date');
|
||||
$this->form_validation->set_rules('bezeichnung', 'Bezeichnung', 'required|max_length[128]');
|
||||
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required|numeric');
|
||||
|
||||
//Events::trigger('konto_insert_validation', $this->form_validation);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Ferien data from post input.
|
||||
* @return array
|
||||
*/
|
||||
private function _getData()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$allowed = [
|
||||
'vondatum',
|
||||
'bisdatum',
|
||||
'bezeichnung',
|
||||
'studiengang_kz'
|
||||
];
|
||||
|
||||
|
||||
foreach ($allowed as $field)
|
||||
{
|
||||
if ($this->input->post($field) !== null) $data[$field] = $this->input->post($field);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
'navigationcomponent' => true,
|
||||
'tabulator6' => true,
|
||||
'primevue3' => true,
|
||||
'vuedatepicker11' => true,
|
||||
//'vuedatepicker11' => true,
|
||||
'customJSModules' => array('public/js/apps/lehre/Ferienverwaltung/Ferienverwaltung.js'),
|
||||
'customCSSs' => array('vendor/vuejs/vuedatepicker_css/main.css')
|
||||
);
|
||||
|
||||
$this->load->view('templates/FHC-Header', $includesArray);
|
||||
|
||||
@@ -38,6 +38,13 @@ export default {
|
||||
params
|
||||
};
|
||||
},
|
||||
update(params) {
|
||||
return {
|
||||
method: 'post',
|
||||
url: 'api/frontend/v1/education/ferien/update',
|
||||
params
|
||||
};
|
||||
},
|
||||
delete(ferien_id) {
|
||||
return {
|
||||
method: 'post',
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {CoreFilterCmpt} from "../filter/Filter.js";
|
||||
import FormInput from "../Form/Input.js";
|
||||
import FerienNew from "./New.js";
|
||||
//import KontoEdit from "./Konto/Edit.js";
|
||||
import FerienModal from "./Modal.js";
|
||||
|
||||
import ApiFerienverwaltung from '../../api/factory/ferienverwaltung/ferienverwaltung.js';
|
||||
|
||||
@@ -10,8 +9,7 @@ export default {
|
||||
components: {
|
||||
CoreFilterCmpt,
|
||||
FormInput,
|
||||
FerienNew
|
||||
//KontoEdit
|
||||
FerienModal
|
||||
},
|
||||
props: {
|
||||
//modelValue: Object,
|
||||
@@ -73,15 +71,16 @@ export default {
|
||||
let container = document.createElement('div');
|
||||
container.className = "d-flex gap-2";
|
||||
|
||||
//~ let button = document.createElement('button');
|
||||
//~ button.className = 'btn btn-outline-secondary btn-action';
|
||||
//~ button.innerHTML = '<i class="fa fa-edit"></i>';
|
||||
//~ button.title = this.$p.t('person', 'adresse_edit');
|
||||
//~ button.addEventListener('click', (event) =>
|
||||
//~ this.actionEditAdress(cell.getData().adresse_id)
|
||||
//~ );
|
||||
//~ container.append(button);
|
||||
let button = document.createElement('button');
|
||||
button.className = 'btn btn-outline-secondary btn-action';
|
||||
button.innerHTML = '<i class="fa fa-edit"></i>';
|
||||
button.title = this.$p.t('person', 'ferien_edit');
|
||||
button.addEventListener('click', (event) =>
|
||||
this.$refs.modal.open(cell.getData())
|
||||
);
|
||||
container.append(button);
|
||||
|
||||
button = document.createElement('button');
|
||||
button.className = 'btn btn-outline-secondary';
|
||||
button.innerHTML = '<i class="fa fa-trash"></i>';
|
||||
button.addEventListener('click', evt => {
|
||||
@@ -144,13 +143,13 @@ export default {
|
||||
reload() {
|
||||
this.$refs.table.reloadTable();
|
||||
},
|
||||
updateData(data) {
|
||||
if (!data)
|
||||
return this.reload();
|
||||
//this.$refs.table.tabulator.updateOrAddData(data);
|
||||
},
|
||||
//~ updateData(data) {
|
||||
//~ if (!data)
|
||||
//~ return this.reload();
|
||||
//~ //this.$refs.table.tabulator.updateOrAddData(data);
|
||||
//~ },
|
||||
actionNew() {
|
||||
this.$refs.new.open();
|
||||
this.$refs.modal.open();
|
||||
},
|
||||
loadByStg() {
|
||||
this.reload();
|
||||
@@ -172,8 +171,8 @@ export default {
|
||||
});
|
||||
},
|
||||
template: `
|
||||
<div class="stv-details-konto h-100 d-flex flex-column">
|
||||
<div class="row justify-content-end">
|
||||
<div class="h-100 d-flex flex-column">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-3">
|
||||
<div class="input-group w-auto">
|
||||
<select class="form-select" v-model="studiengang_kz">
|
||||
@@ -194,20 +193,23 @@ export default {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<core-filter-cmpt
|
||||
ref="table"
|
||||
table-only
|
||||
:side-menu="false"
|
||||
:tabulator-options="tabulatorOptions"
|
||||
:tabulator-events="tabulatorEvents"
|
||||
reload
|
||||
:reload-btn-infotext="this.$p.t('table', 'reload')"
|
||||
new-btn-show
|
||||
:new-btn-label="$p.t('ui/neu')"
|
||||
@click:new="actionNew"
|
||||
>
|
||||
</core-filter-cmpt>
|
||||
<ferien-new ref="new" :studiengang_kz_list="studiengang_kz_list" @saved="updateData"></ferien-new>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<core-filter-cmpt
|
||||
ref="table"
|
||||
table-only
|
||||
:side-menu="false"
|
||||
:tabulator-options="tabulatorOptions"
|
||||
:tabulator-events="tabulatorEvents"
|
||||
reload
|
||||
:reload-btn-infotext="this.$p.t('table', 'reload')"
|
||||
new-btn-show
|
||||
:new-btn-label="$p.t('ui/neu')"
|
||||
@click:new="actionNew"
|
||||
>
|
||||
</core-filter-cmpt>
|
||||
<ferien-modal ref="modal" :studiengang_kz_list="studiengang_kz_list" @saved="reload"></ferien-modal>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
};
|
||||
@@ -1,120 +0,0 @@
|
||||
import BsModal from "../Bootstrap/Modal.js";
|
||||
import BsConfirm from "../Bootstrap/Confirm.js";
|
||||
import CoreForm from "../Form/Form.js";
|
||||
import FormValidation from "../Form/Validation.js";
|
||||
import FormInput from "../Form/Input.js";
|
||||
|
||||
import ApiFerien from '../../api/factory/ferienverwaltung/ferienverwaltung.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
BsModal,
|
||||
CoreForm,
|
||||
FormValidation,
|
||||
FormInput
|
||||
},
|
||||
props: {
|
||||
studiengang_kz_list: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
data: {},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
},
|
||||
methods: {
|
||||
save() {
|
||||
this.$refs.form.clearValidation();
|
||||
this.loading = true;
|
||||
|
||||
this.$refs.form
|
||||
.call(ApiFerien.insert(this.data))
|
||||
.then(result => {
|
||||
this.$emit('saved', result.data);
|
||||
this.loading = false;
|
||||
this.$refs.modal.hide();
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui/gespeichert'));
|
||||
})
|
||||
.catch(error => {
|
||||
if (error)
|
||||
this.$fhcAlert.handleSystemError(error);
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
open() {
|
||||
this.data = {
|
||||
studiengang_kz: null,
|
||||
bezeichnung: '',
|
||||
vondatum: null,
|
||||
bisdatum: null
|
||||
};
|
||||
this.$refs.modal.show();
|
||||
},
|
||||
preventCloseOnLoading(ev) {
|
||||
if (this.loading)
|
||||
ev.returnValue = false;
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<core-form ref="form" class="stv-details-ferien-edit" @submit.prevent="save">
|
||||
<bs-modal ref="modal" @hide-bs-modal="preventCloseOnLoading">
|
||||
<form-validation></form-validation>
|
||||
|
||||
<fieldset :disabled="loading">
|
||||
<form-input
|
||||
type="DatePicker"
|
||||
v-model="data.vondatum"
|
||||
name="vondatum"
|
||||
:label="$p.t('ferien/vondatum')"
|
||||
:enable-time-picker="false"
|
||||
text-input
|
||||
format="dd.MM.yyyy"
|
||||
auto-apply
|
||||
>
|
||||
</form-input>
|
||||
|
||||
<form-input
|
||||
type="DatePicker"
|
||||
v-model="data.bisdatum"
|
||||
name="bisdatum"
|
||||
:label="$p.t('ferien/bisdatum')"
|
||||
:enable-time-picker="false"
|
||||
text-input
|
||||
format="dd.MM.yyyy"
|
||||
auto-apply
|
||||
>
|
||||
</form-input>
|
||||
|
||||
<form-input
|
||||
v-model="data.bezeichnung"
|
||||
name="bezeichnung"
|
||||
:label="$p.t('global/bezeichnung')"
|
||||
>
|
||||
</form-input>
|
||||
|
||||
<form-input
|
||||
type="select"
|
||||
v-model="data.studiengang_kz"
|
||||
name="studiengang_kz"
|
||||
:label="$p.t('lehre/studiengang')"
|
||||
>
|
||||
<option v-for="studiengang in studiengang_kz_list" :key="studiengang.studiengang_kz" :value="studiengang.studiengang_kz">
|
||||
{{ studiengang.kuerzel }}
|
||||
</option>
|
||||
</form-input>
|
||||
</fieldset>
|
||||
|
||||
<template #footer>
|
||||
<button type="submit" class="btn btn-primary" :disabled="loading">
|
||||
<i v-if="loading" class="fa fa-spinner fa-spin"></i>
|
||||
{{ $p.t('ui/speichern') }}
|
||||
</button>
|
||||
</template>
|
||||
</bs-modal>
|
||||
</core-form>`
|
||||
};
|
||||
Reference in New Issue
Block a user