diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index 76d225374..8e40c3f29 100755 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -77,11 +77,15 @@ class Profil extends Auth_Controller $fileVersion = $this->DmsVersionModel->loadWhere(["name"=>$_FILES['files']['name'], "mimetype"=>$_FILES['files']['type']]); $fileVersion = hasData($fileVersion) ? getData($fileVersion)[0]->version : 0; if($fileVersion) $fileVersion++; */ - + if(!count($_FILES)){ + echo json_encode([]); + return; + } $res=[]; $this->load->library('DmsLib'); $this->load->model('DmsVersion_model','DmsVersionModel'); + $files = $_FILES['files']; $file_count = count($files['name']); diff --git a/application/models/person/Profil_change_model.php b/application/models/person/Profil_change_model.php index ea272493c..b207db716 100755 --- a/application/models/person/Profil_change_model.php +++ b/application/models/person/Profil_change_model.php @@ -40,7 +40,7 @@ class Profil_change_model extends DB_Model $this->addSelect(["requested_change"]); $res = $this->load([$profil_update_id]); $res = hasData($res) ? getData($res)[0] : null; - return json_decode($res->requested_change)->files?:null; + return json_decode($res->requested_change)->files?:[]; } /** diff --git a/public/js/apps/Cis/ProfilUpdateRequests.js b/public/js/apps/Cis/ProfilUpdateRequests.js index 6f7fd773b..58287d27f 100755 --- a/public/js/apps/Cis/ProfilUpdateRequests.js +++ b/public/js/apps/Cis/ProfilUpdateRequests.js @@ -1,134 +1,122 @@ import fhcapifactory from "../api/fhcapifactory.js"; -import {CoreFilterCmpt} from "../../components/filter/Filter.js"; +import { CoreFilterCmpt } from "../../components/filter/Filter.js"; import AcceptDenyUpdate from "../../components/Cis/ProfilUpdate/AcceptDenyUpdate.js"; Vue.$fhcapi = fhcapifactory; - - - const app = Vue.createApp({ - components:{ - CoreFilterCmpt, - - }, - data(){ - return{ - - profil_updates_table_options:{ - ajaxURL:FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/Cis/ProfilUpdate/getAllRequests', - height:600, - layout:'fitColumns', - - columns: [ - { - title: "UID", - field: "uid", - minWidth: 200, - resizable:true, - headerFilter: true, - //responsive:0, - }, - { - title: "Name", - field: "name", - minWidth: 200, - resizable:true, - headerFilter: true, - //responsive:0, - }, - { - title: "Topic", - field: "topic", - resizable: true, - minWidth: 200, - headerFilter: true, - //responsive:0, - }, - { - title: "Insert Date", - field: "insertamum", - resizable: true, - headerFilter: true, - minWidth: 200, - //responsive:0, - }, - { - title: "Status", - field: "status", - hozAlign:'center', - headerFilter: true, - formatter: function(cell,para){ - let res =Object.getPrototypeOf(cell); - //console.log(res); - - switch(cell.getValue()){ - case "pending": return " pending"; - case "accepted": return " accepted"; - case "rejected": return " rejected"; - default: return "

default

"; - } - }, - - resizable: true, - minWidth: 200, - //responsive:0, - }, - { - title: "View", - formatter:function(){ return "";}, - resizable: true, - minWidth: 200, - hozAlign: 'center', - cellClick:(e, cell)=>{ - //! function that is called when clicking on a row in the table - - let cellData = cell.getRow().getData(); - - AcceptDenyUpdate.popup({value:cellData}).then(res=>{ - console.log("res of the modal: ",res); - //? refetches the data, if any request was denied or accepted - //* setData will call the ajaxURL again to refresh the data - this.$refs.UpdatesTable.tabulator.setData(); - }).catch(e=>{ - //? catches the rejected Promise if the result of the modal was falsy - console.log("catch of the modal: ",e); - }); - - - }, - //responsive:0, - }, - - - - ], + components: { + CoreFilterCmpt, + }, + data() { + return { + profil_updates_table_options: { + ajaxURL: + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/Cis/ProfilUpdate/getAllRequests", + height: 600, + layout: "fitColumns", + + columns: [ + { + title: "UID", + field: "uid", + minWidth: 200, + resizable: true, + headerFilter: true, + //responsive:0, + }, + { + title: "Name", + field: "name", + minWidth: 200, + resizable: true, + headerFilter: true, + //responsive:0, + }, + { + title: "Topic", + field: "topic", + resizable: true, + minWidth: 200, + headerFilter: true, + //responsive:0, + }, + { + title: "Insert Date", + field: "insertamum", + resizable: true, + headerFilter: true, + minWidth: 200, + //responsive:0, + }, + { + title: "Status", + field: "status", + hozAlign: "center", + headerFilter: true, + formatter: function (cell, para) { + let res = Object.getPrototypeOf(cell); + //console.log(res); + + switch (cell.getValue()) { + case "pending": + return " pending"; + case "accepted": + return " accepted"; + case "rejected": + return " rejected"; + default: + return "

default

"; + } }, - } - }, - computed:{ - - }, - methods:{ - - - }, - created(){ + resizable: true, + minWidth: 200, + //responsive:0, + }, + { + title: "View", + formatter: function () { + return ""; + }, + resizable: true, + minWidth: 200, + hozAlign: "center", + cellClick: (e, cell) => { + //! function that is called when clicking on a row in the table + let cellData = cell.getRow().getData(); - }, - mounted(){ - - - }, - template:` + AcceptDenyUpdate.popup({ value: cellData }) + .then((res) => { + console.log("res of the modal: ", res); + //? refetches the data, if any request was denied or accepted + //* setData will call the ajaxURL again to refresh the data + this.$refs.UpdatesTable.tabulator.setData(); + }) + .catch((e) => { + //? catches the rejected Promise if the result of the modal was falsy + console.log("catch of the modal: ", e); + }); + }, + //responsive:0, + }, + ], + }, + }; + }, + computed: {}, + methods: {}, + created() {}, + mounted() {}, + template: `
`, +}); -}) - -app.mount('#content'); \ No newline at end of file +app.mount("#content"); diff --git a/public/js/apps/api/userdata.js b/public/js/apps/api/userdata.js index 956f78f90..c924d7b10 100755 --- a/public/js/apps/api/userdata.js +++ b/public/js/apps/api/userdata.js @@ -1,80 +1,87 @@ export default { + //! API Calls for Profil Views + insertFile: function (dms) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/Profil/insertFile`; - //! API Calls for Profil Views + return axios.post(url, dms, { + headers: { "Content-Type": "multipart/form-data" }, + }); + }, - insertFile: function(dms) { - const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router+ - `/Cis/Profil/insertFile`; - - return axios.post(url,dms, { - headers: {'Content-Type': 'multipart/form-data'} - }); - }, + getProfilRequestFiles: function (requestID) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/Profil/getProfilRequestFiles`; - getProfilRequestFiles: function(requestID) { - const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router+ - `/Cis/Profil/getProfilRequestFiles`; - - return axios.post(url,requestID); - }, + return axios.post(url, requestID); + }, - selectProfilRequest: function(uid=null,id=null) { - const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router+ - `/Cis/Profil/selectProfilRequest`; - - return axios.get(url,{uid:uid, id:id}); - }, - - insertProfilRequest: function(topic, payload) { - const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router+ - `/Cis/Profil/insertProfilRequest`; - - return axios.post(url,{topic, payload}); - }, + selectProfilRequest: function (uid = null, id = null) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/Profil/selectProfilRequest`; - updateProfilRequest: function(topic, payload, ID) { - const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router+ - `/Cis/Profil/updateProfilRequest`; - - return axios.post(url,{topic, payload, ID}); - }, + return axios.get(url, { uid: uid, id: id }); + }, - deleteProfilRequest: function(requestID){ - const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router+ - `/Cis/Profil/deleteProfilRequest`; + insertProfilRequest: function (topic, payload) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/Profil/insertProfilRequest`; - return axios.post(url,requestID); - }, + return axios.post(url, { topic, payload }); + }, - getEditProfil: function() { - const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router+ - `/Cis/Profil/getEditProfil`; - return axios.get(url); - }, - - isMitarbeiterOrStudent: function(uid) { - const url = FHC_JS_DATA_STORAGE_OBJECT.app_root - + `cis.php/Cis/Profil/isMitarbeiterOrStudent/${uid}`; - return axios.get(url); - }, + updateProfilRequest: function (topic, payload, ID) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/Profil/updateProfilRequest`; - getView: function(uid) { - const url = FHC_JS_DATA_STORAGE_OBJECT.app_root - + `cis.php/Cis/Profil/getView/${uid}`; - return axios.get(url); - }, - - sperre_foto_function: function(value) { - const url = FHC_JS_DATA_STORAGE_OBJECT.app_root - + `cis.php/Cis/Profil/foto_sperre_function/${value}`; - return axios.get(url); - }, + return axios.post(url, { topic, payload, ID }); + }, - - + deleteProfilRequest: function (requestID) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/Profil/deleteProfilRequest`; + return axios.post(url, requestID); + }, - - -}; \ No newline at end of file + getEditProfil: function () { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/Profil/getEditProfil`; + return axios.get(url); + }, + + isMitarbeiterOrStudent: function (uid) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + `cis.php/Cis/Profil/isMitarbeiterOrStudent/${uid}`; + return axios.get(url); + }, + + getView: function (uid) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + `cis.php/Cis/Profil/getView/${uid}`; + return axios.get(url); + }, + + sperre_foto_function: function (value) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + `cis.php/Cis/Profil/foto_sperre_function/${value}`; + return axios.get(url); + }, +}; diff --git a/public/js/components/Cis/Profil/EditProfil.js b/public/js/components/Cis/Profil/EditProfil.js index 40a7caaf4..b8782f5ef 100755 --- a/public/js/components/Cis/Profil/EditProfil.js +++ b/public/js/components/Cis/Profil/EditProfil.js @@ -10,7 +10,6 @@ export default { }, mixins: [BsModal], props: { - value: Object, title: String, /* @@ -27,96 +26,113 @@ export default { }, data() { return { - topic:null, - profilUpdate:null, + topic: null, + profilUpdate: null, editData: this.value, - breadcrumb:null, - + breadcrumb: null, + result: false, info: null, - } + }; }, methods: { - async submitProfilChange(){ - //? when the update contains a file upload - - //TODO: check if the updated value is different from the original value before submitting the request - if(this.topic && this.profilUpdate){ + async submitProfilChange() { + //? when the update contains a file upload - if(this.profilUpdate.files){ - + //TODO: check if the updated value is different from the original value before submitting the request + if (this.topic && this.profilUpdate) { + if (this.profilUpdate.files) { const fileIDs = await this.uploadFiles(this.profilUpdate.files); - - if(fileIDs){ - - this.profilUpdate.files=fileIDs; - console.log("here is the update",this.profilUpdate); - }; - } - //? inserts new row in public.tbl_cis_profil_update - //* calls the update api call if an update field is present in the data that was passed to the modal - const handleApiResponse = (res)=>{ - if(res.data.error == 0){ - this.result= true; - this.hide(); - Alert.popup("Ihre Anfrage wurde erfolgreich gesendet. Bitte warten Sie, während sich das Team um Ihre Anfrage kümmert."); - }else{ - this.result= false; - this.hide(); - Alert.popup("Ein Fehler ist aufgetreten: "+ JSON.stringify(res.data.retval)); + + if (fileIDs) { + this.profilUpdate.files = fileIDs; + console.log("here is the update", this.profilUpdate); } } - - this.editData.updateID? - Vue.$fhcapi.UserData.updateProfilRequest(this.topic,this.profilUpdate,this.editData.updateID).then((res)=>{ - handleApiResponse(res); - }): - Vue.$fhcapi.UserData.insertProfilRequest(this.topic,this.profilUpdate).then((res)=>{ - handleApiResponse(res); - }) - - - } + //? inserts new row in public.tbl_cis_profil_update + //* calls the update api call if an update field is present in the data that was passed to the modal + const handleApiResponse = (res) => { + if (res.data.error == 0) { + this.result = true; + this.hide(); + Alert.popup( + "Ihre Anfrage wurde erfolgreich gesendet. Bitte warten Sie, während sich das Team um Ihre Anfrage kümmert." + ); + } else { + this.result = false; + this.hide(); + Alert.popup( + "Ein Fehler ist aufgetreten: " + JSON.stringify(res.data.retval) + ); + } + }; + + this.editData.updateID + ? Vue.$fhcapi.UserData.updateProfilRequest( + this.topic, + this.profilUpdate, + this.editData.updateID + ).then((res) => { + handleApiResponse(res); + }) + : Vue.$fhcapi.UserData.insertProfilRequest( + this.topic, + this.profilUpdate + ).then((res) => { + handleApiResponse(res); + }); + } }, - //? uploads files to the dms table and returns an array with the ids of the created files - uploadFiles: async function(files){ + uploadFiles: async function (files) { let updatedFiles = []; - if(this.editData.updateID){ //? if we are updating an already existing profilRequest - const existingFiles = await Vue.$fhcapi.UserData.getProfilRequestFiles(this.editData.updateID).then(res => {return res.data}); - updatedFiles = [...existingFiles]; + + if (this.editData.updateID) { + //? if we are updating an already existing profilRequest + const existingFiles = await Vue.$fhcapi.UserData.getProfilRequestFiles( + this.editData.updateID + ).then((res) => { + return res.data; + }); + updatedFiles = [...existingFiles.filter((file) => { + for(let j=0; j { - /* returns file information as + + await Vue.$fhcapi.UserData.insertFile(formData) + .then((res) => { + /* returns file information as [{"name":"example.png", "dms_id":282531}] */ - console.log(res) - updatedFiles = updatedFiles.concat(res.data?.map(file => { return {dms_id:file.dms_id, name:file.client_name}})); - }).catch(err=>{ - console.log(err); - - }) + + updatedFiles = updatedFiles.concat( + res.data?.map((file) => { + return { dms_id: file.dms_id, name: file.client_name }; + }) + ); + }) + .catch((err) => { + console.log(err); + }); return updatedFiles; - - }, - }, - computed: { + }, }, + computed: {}, created() { - - if(this.editData.topic){ + if (this.editData.topic) { //? if the topic was passed through the prop add it to the component this.topic = this.editData.topic; } - - }, mounted() { this.modal = this.$refs.modalContainer.modal; diff --git a/public/js/components/Cis/Profil/EditProfilSelect.js b/public/js/components/Cis/Profil/EditProfilSelect.js index 0d28d47f9..f69ef5a5e 100755 --- a/public/js/components/Cis/Profil/EditProfilSelect.js +++ b/public/js/components/Cis/Profil/EditProfilSelect.js @@ -6,149 +6,133 @@ import Status from "./ProfilComponents/Status.js"; import TextInputDokument from "./ProfilComponents/TextInputDokument.js"; export default { - components: { - Kontakt, - EditKontakt, - Adresse, - EditAdresse, - Status, - TextInputDokument, - }, - props: { + components: { + Kontakt, + EditKontakt, + Adresse, + EditAdresse, + Status, + TextInputDokument, + }, + props: { + list: Object, - - list:Object, - - //? Prop used to determine how many options the select should initially show - size:{ - type:Number, - default: null, - }, - //? Content for the aria label of the select - ariaLabel:{ - type:String, - required:true, - }, - profilUpdate:String, - topic:String, - breadcrumb:String, - - + //? Prop used to determine how many options the select should initially show + size: { + type: Number, + default: null, }, - emits:{ - //? update:modelValue event is needed to notify the v-model when the value has changed - ['update:profilUpdate']:null, - ['update:topic']:null, - ['update:breadcrumb']:null, - submit:null, - select:null, - + //? Content for the aria label of the select + ariaLabel: { + type: String, + required: true, }, - data() { - return { - view:null, - data:null, - breadcrumbItems:[], - topic:null, - properties:null, + profilUpdate: String, + topic: String, + breadcrumb: String, + }, + emits: { + //? update:modelValue event is needed to notify the v-model when the value has changed + ["update:profilUpdate"]: null, + ["update:topic"]: null, + ["update:breadcrumb"]: null, + submit: null, + select: null, + }, + data() { + return { + view: null, + data: null, + breadcrumbItems: [], + topic: null, + properties: null, + }; + }, + + methods: { + addItem: function () { + this.view = + this.topic == "Private Kontakte" ? "EditKontakt" : "EditAdresse"; + + //? updates the topic when a Kontakt or an Address should be added + this.topic = + this.topic == "Private Kontakte" ? "Add Kontakte" : "Add Adressen"; + this.$emit("update:topic", this.topic); + this.breadcrumbItems.push(this.topic); + this.$emit("update:breadcrumb", this.breadcrumbItems); + + this.data = + this.view == "EditAdresse" + ? { + //? add flag + add: true, + adresse_id: null, + strasse: null, + typ: null, + plz: null, + ort: null, + } + : { + //? add flag + add: true, + kontakt_id: null, + kontakttyp: null, + kontakt: null, + anmerkung: null, + zustellung: false, + }; + }, + + deleteItem: function (item) { + //? delete flag + item.data.delete = true; + this.$emit("update:profilUpdate", item.data); + //? updates the topic when a Kontakt or an Address should be deleted + this.topic = item.data.kontakt ? "Delete Kontakte" : "Delete Adressen"; + this.$emit("update:topic", this.topic); + + this.$emit("submit"); + }, + + profilUpdateEmit: function (event) { + //? passes the updated profil information to the parent component + + this.$emit("update:profilUpdate", event); + }, + + updateOptions: function (event, item) { + this.properties = item; + this.data = item.data; + this.view = item.view; + console.log("properties", this.properties); + if (item.title) { + //? emits the selected topic to the parent component + this.topic = item.title; + this.$emit("update:topic", this.topic); + + //? emits the new item for the breadcrumb in the parent component + this.breadcrumbItems.push(item.title); + } else { + if (item.data.kontakttyp) { + this.breadcrumbItems.push(item.data.kontakttyp); + this.breadcrumbItems.push(item.data.kontakt); + } else if (item.data.strasse) { + this.breadcrumbItems.push(item.data.strasse); + } } + this.$emit("update:breadcrumb", this.breadcrumbItems); }, - - methods: { + }, + computed: {}, + created() { + //? JSON parse and stringify are used to deep clone the objects + this.properties = { ...this.list }; + this.data = JSON.parse(JSON.stringify(this.list.data)); + this.view = JSON.parse(JSON.stringify(this.list.view)); + }, + mounted() {}, - addItem: function(){ - - - this.view= this.topic == "Private Kontakte"?"EditKontakt":"EditAdresse" ; - - //? updates the topic when a Kontakt or an Address should be added - this.topic = this.topic == "Private Kontakte"?"Add Kontakte":"Add Adressen" - this.$emit('update:topic',this.topic); - this.breadcrumbItems.push(this.topic); - this.$emit('update:breadcrumb',this.breadcrumbItems); - - this.data= this.view=="EditAdresse"? - { - //? add flag - add:true, - adresse_id: null, - strasse: null, - typ: null, - plz: null, - ort: null - }: { - //? add flag - add:true, - kontakt_id: null, - kontakttyp: null, - kontakt: null, - anmerkung: null, - zustellung: false - } - - - }, - - deleteItem: function(item){ - //? delete flag - item.data.delete = true; - this.$emit('update:profilUpdate',item.data); - //? updates the topic when a Kontakt or an Address should be deleted - this.topic = item.data.kontakt?"Delete Kontakte":"Delete Adressen"; - this.$emit('update:topic',this.topic); - - this.$emit('submit'); - }, - - profilUpdateEmit: function(event){ - - //? passes the updated profil information to the parent component - - this.$emit('update:profilUpdate',event); - }, - - - updateOptions: function(event, item){ - this.properties = item; - this.data=item.data; - this.view=item.view; - console.log("properties",this.properties); - if(item.title){ - //? emits the selected topic to the parent component - this.topic= item.title; - this.$emit('update:topic',this.topic); - - //? emits the new item for the breadcrumb in the parent component - this.breadcrumbItems.push(item.title); - }else{ - if(item.data.kontakttyp){ - this.breadcrumbItems.push(item.data.kontakttyp); - this.breadcrumbItems.push(item.data.kontakt); - }else if(item.data.strasse){ - this.breadcrumbItems.push(item.data.strasse); - } - } - this.$emit('update:breadcrumb',this.breadcrumbItems); - - }, - - }, - computed: { - - - }, - created() { - //? JSON parse and stringify are used to deep clone the objects - this.properties = {...this.list}; - this.data = JSON.parse(JSON.stringify(this.list.data)); - this.view = JSON.parse(JSON.stringify(this.list.view)); - - - }, - mounted() { - }, - - template: ` + template: ` `, - }; - \ No newline at end of file +}; diff --git a/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js b/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js index e32b96897..70f81ec42 100755 --- a/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js +++ b/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js @@ -1,123 +1,117 @@ - import EditProfil from "../EditProfil.js"; //? EditProfil is the modal used to edit the profil updates export default { - props:{ - data:{ - type:Object, - }, + props: { + data: { + type: Object, }, + }, - emits:["fetchUpdates"], - - data(){ - return { - + emits: ["fetchUpdates"], + + data() { + return {}; + }, + methods: { + deleteRequest: function (item) { + Vue.$fhcapi.UserData.deleteProfilRequest(item.profil_update_id).then( + (res) => { + if (res.data.error) { + //? open alert + console.log(res.data); + } else { + this.$emit("fetchUpdates"); + } } + ); }, - methods:{ - - deleteRequest: function(item){ - - Vue.$fhcapi.UserData.deleteProfilRequest(item.profil_update_id).then((res)=>{ - if(res.data.error){ - //? open alert - console.log(res.data); - }else{ - this.$emit('fetchUpdates'); - } - }); - }, - getView: function(topic,status){ - switch(topic){ - case "Private Kontakte" : return status ==='pending'? "EditKontakt": "Status"; break; - case "Private Adressen" : return status ==='pending'? "EditAdresse": "Status"; break; - case "Add Adressen" : return status ==='pending'? "EditAdresse": "Status"; break; - case "Add Kontakte" : return status ==='pending'? "EditKontakt": "Status"; break; - case "Delete Adressen" : return status ==='pending'? "Adresse": "Status" ; break; - case "Delete Kontakte" : return status ==='pending'? "Kontakt": "Status"; break; - default: return status ==='pending'? "TextInputDokument": "Status"; break; - } - }, - openModal(updateRequest) { - - let view = this.getView(updateRequest.topic,updateRequest.status); - let data = null; - let content =null; - let files =null; - let withFiles = false; - - - if(view === "TextInputDokument"){ - - data = { - titel:updateRequest.topic, - value: updateRequest.requested_change.value, - - }; - if(updateRequest.requested_change.files.length){ - const FILE = updateRequest.requested_change.files?.map(file=>{return new File(["files[]"], file.name);}) - const FILELIST = new DataTransfer(); - FILE.forEach(file => { - FILELIST.items.add(file); - }) - files=updateRequest.requested_change.files; - } - withFiles = true; - } - else{ - data = updateRequest.requested_change; - } - - - - - content={ - updateID:updateRequest.profil_update_id, - view:view, - data:data, - withFiles:withFiles, - topic:updateRequest.topic, - files: files, - - } - - - //? adds the status information if the profil update request was rejected or accepted - if(updateRequest.status !== 'pending'){ - content['status']= updateRequest.status; - content['status_message']= updateRequest.status_message; - content['status_timestamp']=updateRequest.status_timestamp; - } - - //? only show the popup if also the right content is available - if(content){ - EditProfil.popup({ - - value:content, - - }).then((res) => { - if(res === true){ - this.$emit('fetchUpdates'); - } - - }).catch(e => { - // Wenn der User das Modal abbricht ohne Änderungen - - }); - - } - - - }, + getView: function (topic, status) { + switch (topic) { + case "Private Kontakte": + return status === "pending" ? "EditKontakt" : "Status"; + break; + case "Private Adressen": + return status === "pending" ? "EditAdresse" : "Status"; + break; + case "Add Adressen": + return status === "pending" ? "EditAdresse" : "Status"; + break; + case "Add Kontakte": + return status === "pending" ? "EditKontakt" : "Status"; + break; + case "Delete Adressen": + return status === "pending" ? "Adresse" : "Status"; + break; + case "Delete Kontakte": + return status === "pending" ? "Kontakt" : "Status"; + break; + default: + return status === "pending" ? "TextInputDokument" : "Status"; + break; + } }, - created(){ - + openModal(updateRequest) { + let view = this.getView(updateRequest.topic, updateRequest.status); + let data = null; + let content = null; + let files = null; + let withFiles = false; + + if (view === "TextInputDokument") { + data = { + titel: updateRequest.topic, + value: updateRequest.requested_change.value, + }; + if (updateRequest.requested_change.files.length) { + const FILE = updateRequest.requested_change.files?.map((file) => { + return new File(["files[]"], file.name); + }); + const FILELIST = new DataTransfer(); + FILE.forEach((file) => { + FILELIST.items.add(file); + }); + files = updateRequest.requested_change.files; + } + withFiles = true; + } else { + data = updateRequest.requested_change; + } + + content = { + updateID: updateRequest.profil_update_id, + view: view, + data: data, + withFiles: withFiles, + topic: updateRequest.topic, + files: files, + }; + + //? adds the status information if the profil update request was rejected or accepted + if (updateRequest.status !== "pending") { + content["status"] = updateRequest.status; + content["status_message"] = updateRequest.status_message; + content["status_timestamp"] = updateRequest.status_timestamp; + } + + //? only show the popup if also the right content is available + if (content) { + EditProfil.popup({ + value: content, + }) + .then((res) => { + if (res === true) { + this.$emit("fetchUpdates"); + } + }) + .catch((e) => { + // Wenn der User das Modal abbricht ohne Änderungen + }); + } }, - computed:{ - - }, - template:` + }, + created() {}, + computed: {}, + template: `
@@ -177,5 +171,5 @@ export default {
- ` -}; \ No newline at end of file + `, +}; diff --git a/public/js/components/Cis/Profil/ProfilComponents/Status.js b/public/js/components/Cis/Profil/ProfilComponents/Status.js index 535252ec2..2eebbf8fa 100755 --- a/public/js/components/Cis/Profil/ProfilComponents/Status.js +++ b/public/js/components/Cis/Profil/ProfilComponents/Status.js @@ -2,42 +2,38 @@ import Adresse from "./Adresse.js"; import Kontakt from "./Kontakt.js"; export default { - components:{ - Adresse, - Kontakt, + components: { + Adresse, + Kontakt, + }, + data() { + return {}; + }, + computed: { + getComponentView: function () { + let title = this.topic.toLowerCase(); + if (title.includes("adressen")) return "Adresse"; + else if (title.includes("kontakte")) return "Kontakt"; + else return "text_input"; }, - data(){ - return { - - } + cardHeader: function () { + let title = this.topic.toLowerCase(); + if (title.includes("delete")) return "Delete"; + else if (title.includes("add")) return "Add"; + else return "Update"; }, - computed:{ - getComponentView: function(){ - let title = this.topic.toLowerCase(); - if(title.includes("adressen")) return "Adresse"; - else if(title.includes("kontakte"))return "Kontakt"; - else return "text_input"; - - }, - cardHeader: function(){ - let title = this.topic.toLowerCase(); - if(title.includes("delete")) return "Delete"; - else if(title.includes("add")) return "Add"; - else return "Update"; - } - }, - props:{ - data:{type:Object}, - view:{type:String}, - status:{type:String}, - status_message:{type:String}, - status_timestamp:{type:String}, - updateID:{type:Number}, - topic:{type:String}, - }, - created(){ - - },template:` + }, + props: { + data: { type: Object }, + view: { type: String }, + status: { type: String }, + status_message: { type: String }, + status_timestamp: { type: String }, + updateID: { type: Number }, + topic: { type: String }, + }, + created() {}, + template: `
@@ -86,5 +82,4 @@ export default {
`, - -} \ No newline at end of file +}; diff --git a/public/js/components/Cis/Profil/ProfilComponents/TextInputDokument.js b/public/js/components/Cis/Profil/ProfilComponents/TextInputDokument.js index 257c4c39f..5f5ca9375 100644 --- a/public/js/components/Cis/Profil/ProfilComponents/TextInputDokument.js +++ b/public/js/components/Cis/Profil/ProfilComponents/TextInputDokument.js @@ -1,89 +1,86 @@ import Dms from "../../../Form/Upload/Dms.js"; - export default { - data(){ - return { - dmsData:[], - originalValue:null, - originalFiles:null, - } + data() { + return { + dmsData: [], + originalValue: null, + originalFiles: null, + }; + }, + components: { + Dms, + }, + props: { + data: { + type: Object, }, - components:{ - Dms, + withFiles: { + type: Boolean, + default: false, }, - props:{ - - data:{ - type:Object, - }, - withFiles:{ - type:Boolean, - default:false, - }, - files:{ - type:FileList, - }, - updateID:{ - type:Boolean, - } + files: { + type: FileList, }, - computed: { - isChanged: function(){ - //? controls whether the user is allowed to send the profil update or not - if(this.withFiles && !this.dmsData.length) {return false;} - return JSON.stringify(this.data) !== Vue.toRaw(this.originalValue); - - } + updateID: { + type: Boolean, + }, + }, + computed: { + isChanged: function () { + //? controls whether the user is allowed to send the profil update or not + if (this.withFiles && !this.dmsData.length) { + return false; + } + return JSON.stringify(this.data) !== Vue.toRaw(this.originalValue); + }, + }, + emits: ["profilUpdate"], + watch: { + //? watcher to trigger the event emit when a file was uploaded or removed + dmsData(value) { + this.emitChanges(); + }, + }, + methods: { + emitChanges: function () { + if (this.updateID || this.isChanged) { + this.$emit( + "profilUpdate", + this.withFiles + ? { value: this.data.value, files: this.dmsData } + : { value: this.data.value } + ); + } else { + this.$emit("profilUpdate", null); + } + }, + }, + mounted() { + this.originalValue = JSON.stringify(this.data); - }, - emits:["profilUpdate"], - watch: { - //? watcher to trigger the event emit when a file was uploaded or removed - dmsData(value) { - this.emitChanges(); - - } - }, - methods:{ - - emitChanges: function(){ - if(this.updateID || this.isChanged){ - - this.$emit('profilUpdate', this.withFiles?{value:this.data.value, files:this.dmsData}:{value:this.data.value}); - }else{ - - this.$emit('profilUpdate',null); - } - }, - - }, - mounted(){ - - this.originalValue = JSON.stringify(this.data); - + if (this.files) { + this.dmsData = this.files; - if(this.files){ - this.dmsData = this.files; + for (let i = 0; i < this.dmsData.length; i++) { + console.log("here", this.dmsData[i]); + } - for(let i=0; i < this.dmsData.length; i++){ - console.log("here",this.dmsData[i]); - } - - this.originalFiles=null; - } - - }, - template:` + this.originalFiles = null; + } + }, + template: ` +

Please update your {{data.titel}} and upload the corresponding Document for proof

+
{{data.titel?data.titel:"titel"}}
- - + +
`, -} \ No newline at end of file +}; diff --git a/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js b/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js index e5e5e59bb..3c808b913 100755 --- a/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js +++ b/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js @@ -3,23 +3,21 @@ import Alert from "../../Bootstrap/Alert.js"; import Kontakt from "../Profil/ProfilComponents/Kontakt.js"; import Adresse from "../Profil/ProfilComponents/Adresse.js"; - export default { components: { BsModal, Alert, Kontakt, Adresse, - }, mixins: [BsModal], props: { - title:{ - type:String, - default:"Profil Update Request" + title: { + type: String, + default: "Profil Update Request", }, value: { - type:Object, + type: Object, }, /* * NOTE(chris): @@ -34,73 +32,71 @@ export default { onShownBsModal: Function, }, data() { - return { + return { data: this.value, //? result is returned from the Promise when the modal is closed result: false, info: null, - } + }; }, methods: { - acceptRequest: function(){ - - Vue.$fhcapi.ProfilUpdate.acceptProfilRequest(this.data).then(res =>{ - console.log("res",res); - console.log("res.data",res.data); + acceptRequest: function () { + Vue.$fhcapi.ProfilUpdate.acceptProfilRequest(this.data).then((res) => { + console.log("res", res); + console.log("res.data", res.data); this.result = true; - }) + }); this.hide(); }, - denyRequest: function(){ + denyRequest: function () { console.log(this.data.profil_update_id); - Vue.$fhcapi.ProfilUpdate.denyProfilRequest(this.data).then(res =>{ - console.log("res",res); - console.log("res.data",res.data); + Vue.$fhcapi.ProfilUpdate.denyProfilRequest(this.data).then((res) => { + console.log("res", res); + console.log("res.data", res.data); this.result = true; - }) + }); this.hide(); }, - - submitProfilChange(){ - //TODO: check if the updated value is different from the original value before submitting the request - if(false){ - //? inserts new row in public.tbl_cis_profil_update + submitProfilChange() { + //TODO: check if the updated value is different from the original value before submitting the request + if (false) { + //? inserts new row in public.tbl_cis_profil_update //* calls the update api call if an update field is present in the data that was passed to the module - Vue.$fhcapi.UserData[this.editData.update?'updateProfilRequest':'insertProfilRequest'](this.topic,this.profilUpdate).then((res)=>{ - - if(res.data.error == 0){ - this.result= true; + Vue.$fhcapi.UserData[ + this.editData.update ? "updateProfilRequest" : "insertProfilRequest" + ](this.topic, this.profilUpdate).then((res) => { + if (res.data.error == 0) { + this.result = true; this.hide(); - Alert.popup("Ihre Anfrage wurde erfolgreich gesendet. Bitte warten Sie, während sich das Team um Ihre Anfrage kümmert."); - }else{ - this.result= false; + Alert.popup( + "Ihre Anfrage wurde erfolgreich gesendet. Bitte warten Sie, während sich das Team um Ihre Anfrage kümmert." + ); + } else { + this.result = false; this.hide(); - Alert.popup("Ein Fehler ist aufgetreten: "+ JSON.stringify(res.data.retval)); - } - + Alert.popup( + "Ein Fehler ist aufgetreten: " + JSON.stringify(res.data.retval) + ); + } }); - } + } }, }, computed: { - getComponentView: function(){ - - if(this.data.topic.toLowerCase().includes("kontakt")){ - return "kontakt"; - }else if (this.data.topic.toLowerCase().includes("adresse")){ - return "adresse"; - }else{ - return "text_input"; - } + getComponentView: function () { + if (this.data.topic.toLowerCase().includes("kontakt")) { + return "kontakt"; + } else if (this.data.topic.toLowerCase().includes("adresse")) { + return "adresse"; + } else { + return "text_input"; + } }, }, - created() { - - - }, + created() {}, mounted() { this.modal = this.$refs.modalContainer.modal; }, diff --git a/public/js/components/Form/Upload/Dms.js b/public/js/components/Form/Upload/Dms.js index 0416436db..3184a7e0b 100755 --- a/public/js/components/Form/Upload/Dms.js +++ b/public/js/components/Form/Upload/Dms.js @@ -73,7 +73,6 @@ export default { }, template: `
-
{{JSON.stringify(Array.from(modelValue).map(item => stringifyFile(item)),null,2)}}