Merge branch 'feature-34543/UX_Template' of https://github.com/FH-Complete/FHC-Core into feature-34543/UX_Template

This commit is contained in:
Cris
2024-02-22 11:17:38 +01:00
6 changed files with 142 additions and 13 deletions
+32 -1
View File
@@ -89,6 +89,10 @@ class FHCAPI_Controller extends FHC_Controller
// For JSON Requests (as opposed to multipart/form-data) get the $_POST variable from the input stream instead
if ($this->input->get_request_header('Content-Type', true) == 'application/json')
$_POST = json_decode($this->security->xss_clean($this->input->raw_input_stream), true);
elseif (isset($_POST['_jsondata'])) {
$_POST = array_merge($_POST, json_decode($_POST['_jsondata'], true));
unset($_POST['_jsondata']);
}
}
@@ -98,7 +102,7 @@ class FHCAPI_Controller extends FHC_Controller
/**
* @param array $data
* @param string (optional) $type
* @param string $type (optional)
* @return void
*/
public function addError($data, $type = null)
@@ -171,6 +175,33 @@ class FHCAPI_Controller extends FHC_Controller
exit;
}
/**
* @param array $error
* @param string $type (optional)
* @return void
*/
protected function terminateWithError($error, $type = null)
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
$this->addError($error, $type);
$this->setStatus(self::STATUS_ERROR);
exit;
}
/**
* @param stdclass $result
* @param string $errortype
* @return void
*/
protected function checkForErrors($result, $errortype = self::ERROR_TYPE_GENERAL)
{
// TODO(chris): IMPLEMENT!
if (isError($result)) {
$this->terminateWithError(getError($result), $errortype);
}
return $result->retval;
}
// TODO(chris): complete list
+58
View File
@@ -0,0 +1,58 @@
export default {
//! API Calls for Profil Views
getGemeinden: function(nation,zip=null){
const url =
FHC_JS_DATA_STORAGE_OBJECT.app_root +
`cis.php/Cis/Profil/getGemeinden`;
return axios.get(url,{params:{nation:nation,zip:zip}});
},
getAllNationen:function(){
const url =
FHC_JS_DATA_STORAGE_OBJECT.app_root +
`cis.php/Cis/Profil/getAllNationen`;
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);
},
isStudent: function (uid) {
const url =
FHC_JS_DATA_STORAGE_OBJECT.app_root +
`cis.php/Cis/Profil/isStudent/${uid}`;
return axios.get(url);
},
isMitarbeiter: function (uid) {
const url =
FHC_JS_DATA_STORAGE_OBJECT.app_root +
`cis.php/Cis/Profil/isMitarbeiter/${uid}`;
return axios.get(url);
},
getZustellAdresse: function () {
const url =
FHC_JS_DATA_STORAGE_OBJECT.app_root +
`cis.php/Cis/Profil/getZustellAdresse`;
return axios.get(url);
},
getZustellKontakt: function () {
const url =
FHC_JS_DATA_STORAGE_OBJECT.app_root +
`cis.php/Cis/Profil/getZustellKontakt`;
return axios.get(url);
},
};
+12 -10
View File
@@ -120,13 +120,19 @@ export default {
if (!c.includes('form-check-input') && !c.includes('btn-check'))
classes.push('form-check-input');
break;
case 'color':
if (!c.includes('form-control-color'))
classes.push('form-control-color');
if (!c.includes('form-control'))
classes.push('form-control');
break;
case 'autocomplete':
case 'datepicker':
classes.push('p-0');
classes.push('border-0');
case 'color':
if (!c.includes('form-control-color'))
classes.push('form-control-color');
if (!c.includes('form-control'))
classes.push('form-control');
break;
case 'text':
case 'number':
case 'password':
@@ -200,13 +206,9 @@ export default {
this.valid = valid;
// NOTE(chris): On a list of radios/checkboxes only add the feedback message to the last item
if (this.name && (this.lcType == 'radio' || this.lcType == 'checkbox')) {
let n = this.$el.nextSibling;
for (; n; n = n.nextSibling)
if (n.nodeType == 1
&& n.__vueParentComponent?.ctx?.lcType == this.lcType
&& n.__vueParentComponent?.ctx?.name == this.name
)
return;
const selector = 'input[type="' + this.lcType + '"][name="' + this.name + '"]';
if ([...this.$el.parentNode.querySelectorAll(selector)].pop() != this.$refs.input)
return;
}
this.feedback = feedback;
},
+1 -1
View File
@@ -75,7 +75,7 @@ export default {
<div class="form-upload-dms">
<input ref="upload" class="form-control" :class="inputClass" :id="id" :name="name" :multiple="multiple" type="file" @change="addFiles">
<ul v-if="modelValue.length && multiple && !noList" class="list-unstyled m-0">
<li v-for="(file, index) in modelValue" :key="index" class="d-flex mx-1 mt-1">
<li v-for="(file, index) in modelValue" :key="index" class="d-flex mx-1 mt-1 align-items-start">
<span class="col-auto"><i class="fa fa-file me-1"></i></span>
<span class="col">{{ file.name }}</span>
<button class="col-auto btn btn-outline-secondary btn-p-0" @click="removeFile(index)">
-1
View File
@@ -11,7 +11,6 @@ export default {
'changed'
],
props: {
// TODO(chris): rename to config?
config: {
type: [String, Object],
required: true
+39
View File
@@ -52,6 +52,45 @@ export default {
baseURL: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/"
});
fhcApiAxios.interceptors.request.use(config => {
if (config.method != 'post' || !config.data)
return config;
if (config.data instanceof FormData)
return config;
if (!Object.values(config.data).every(item => {
if (item instanceof FileList)
return false;
if (Array.isArray(item))
return item.every(i => !(i instanceof File));
return true;
})) {
const newData = Object.entries(config.data).reduce((nd, [key, item]) => {
if (item instanceof FileList) {
for (const file of item)
nd.FormData.append(key + (item.length > 1 ? '[]' : ''), file);
} else if (Array.isArray(item)) {
if (item.every(i => !(i instanceof File))) {
nd.jsondata[key] = item;
} else {
item.forEach(file => nd.FormData.append(key + (item.length > 1 ? '[]' : ''), file));
}
} else {
nd.jsondata[key] = item;
}
return nd;
}, {
FormData: new FormData(),
jsondata: {}
});
newData.FormData.append('_jsondata', JSON.stringify(newData.jsondata));
config.data = newData.FormData;
}
return config;
});
fhcApiAxios.interceptors.response.use(response => {
if (response.config?.errorHandling == 'off'
|| response.config?.errorHandling === false