diff --git a/application/core/Tag_Controller.php b/application/core/Tag_Controller.php index 0600200c8..cb7deda82 100644 --- a/application/core/Tag_Controller.php +++ b/application/core/Tag_Controller.php @@ -344,16 +344,27 @@ class Tag_Controller extends FHCAPI_Controller public function rebuildTagsForTypeId() { - $id = $this->input->post('id'); + $ids = $this->input->post('ids'); $typeId = $this->input->post('typeId'); $semester = $this->input->post('sem'); - $result = $this->taglib->rebuildTagsForTypeId($typeId, $id, $semester); + $idsSuccess = []; + $idsError = []; + $outputResult = []; - if (isError($result)) - return error ('Error occurred during updateAutomatedTags'); + foreach ($ids as $id) + { + $result = $this->taglib->rebuildTagsForTypeId($typeId, $id, $semester); - $this->terminateWithSuccess($result); + if (isError($result)) + $idsError[] = $id; + else + $idsSuccess[] = $id; + + $outputResult[] = $result; + } + + $this->terminateWithSuccess([$outputResult, $idsSuccess, $idsError]); } private function _setAuthUID() diff --git a/public/js/components/DetailHeader/DetailHeader.js b/public/js/components/DetailHeader/DetailHeader.js index 84e462df3..8bf1fe2be 100644 --- a/public/js/components/DetailHeader/DetailHeader.js +++ b/public/js/components/DetailHeader/DetailHeader.js @@ -315,8 +315,10 @@ export default { this.reload(); }, rebuildPrestudentTags(){ + const id = [this.headerData[0].prestudent_id]; + const params = { - id : this.headerData[0].prestudent_id, + ids: id, typeId: 'prestudent_id', sem: this.currentSemester }; diff --git a/public/js/components/Stv/Studentenverwaltung/List.js b/public/js/components/Stv/Studentenverwaltung/List.js index 56a6a5334..f9abb3558 100644 --- a/public/js/components/Stv/Studentenverwaltung/List.js +++ b/public/js/components/Stv/Studentenverwaltung/List.js @@ -4,6 +4,7 @@ import CoreTag from '../../Tag/Tag.js'; import { tagHeaderFilter } from "../../../tabulator/filters/extendedHeaderFilter.js"; import { addTagInTable, deleteTagInTable, updateTagInTable } from "../../../../js/helpers/TagHelper.js"; import { tagFormatter } from "../../../../js/tabulator/formatter/tags.js"; +import ModalLoading from "./List/ModalLoading.js"; import ApiTag from "../../../api/factory/stv/tag.js"; import ListFilter from './List/Filter.js'; @@ -18,7 +19,8 @@ export default { CoreFilterCmpt, ListNew, CoreTag, - ListFilter + ListFilter, + ModalLoading }, directives: { draggable @@ -246,7 +248,9 @@ export default { oldScrollUrl: '', oldScrollLeft: 0, oldScrollTop: 0, - allPrestudents: [] + allPrestudents: [], + rebuildData: [], + isLoading: false } }, computed: { @@ -646,11 +650,55 @@ export default { this.oldScrollUrl = this.$refs.table.tabulator.getAjaxUrl(); } }, + rebuild(selected){ + this.isLoading = true; + let prestudentIds = []; + this.showModal(); + if(!selected.length) + prestudentIds = this.$refs.table.tabulator + .getData() + .map(row => row.prestudent_id); + else + prestudentIds = selected.map(item => item.prestudent_id); + + const params = { + ids: prestudentIds, + typeId: 'prestudent_id', + sem: this.studiensemesterKurzbz + }; + + return this.$api + .call(ApiTag.rebuildTagsforTypeId(params)) + .then(result => { + this.rebuildData = result.data; + this.isLoading = false; + console.log("Rebuild manually triggered"); + if(this.rebuildData[1].length > 0) + { + this.$fhcAlert.alertSuccess(this.$p.t('tag', 'alertSuccessRebuild', { count: this.rebuildData[1].length })); + } + if(this.rebuildData[2].length > 0) + { + this.$fhcAlert.alertError(this.$p.t('tag', 'alertErrorRebuild') + this.rebuildData[2].toString()); + } + }) + .catch(this.$fhcAlert.handleSystemError); + }, + showModal(){ + this.$refs.modalLocked.open(); + }, }, // TODO(chris): focusin, focusout, keydown and tabindex should be in the filter component // TODO(chris): filter component column chooser has no accessibilty features template: `
diff --git a/public/js/components/Stv/Studentenverwaltung/List/ModalLoading.js b/public/js/components/Stv/Studentenverwaltung/List/ModalLoading.js
new file mode 100644
index 000000000..252002c4b
--- /dev/null
+++ b/public/js/components/Stv/Studentenverwaltung/List/ModalLoading.js
@@ -0,0 +1,69 @@
+import BsModal from "../../../Bootstrap/Modal.js";
+import FormForm from "../../../Form/Form.js";
+
+export default {
+ name: "modalLoading",
+ components: {
+ BsModal,
+ FormForm
+ },
+ props: {
+ isLoading: {
+ type: Boolean,
+ required: true
+ },
+ message: {
+ type: String,
+ required: true
+ }
+ },
+ data(){
+ return{}
+ },
+ methods:{
+ open(){
+ this.$refs.modalLoading.show();
+ },
+ closeModal(){
+ this.$refs.modalLoading.hide();
+ }
+ },
+ template: `
+