mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 02:12:17 +00:00
issue configuration: enabled deletion of single configuration values, updated fehlermonitoring phrases
This commit is contained in:
@@ -18,7 +18,8 @@ class IssuesKonfiguration extends Auth_Controller
|
||||
'getApps' => 'admin:r',
|
||||
'getFehlerKonfigurationByApp' => 'admin:r',
|
||||
'saveFehlerKonfiguration' => 'admin:rw',
|
||||
'deleteKonfiguration' => 'admin:rw'
|
||||
'deleteKonfiguration' => 'admin:rw',
|
||||
'deleteKonfigurationsWerte' => 'admin:rw'
|
||||
)
|
||||
);
|
||||
|
||||
@@ -204,6 +205,73 @@ class IssuesKonfiguration extends Auth_Controller
|
||||
$this->outputJson($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes values of a Konfiguration.
|
||||
*/
|
||||
public function deleteKonfigurationsWerte()
|
||||
{
|
||||
$konfigurationstyp_kurzbz = $this->input->post('konfigurationstyp_kurzbz');
|
||||
$fehlercode = $this->input->post('fehlercode');
|
||||
$konfigurationsWert = $this->input->post('konfigurationsWert');
|
||||
|
||||
// check if Konfigurationstyp correctly passed
|
||||
if (isEmptyString($konfigurationstyp_kurzbz)) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'ungueltigerKonfigurationstyp'));
|
||||
|
||||
// check if fehlercode correctly passed
|
||||
if (isEmptyString($fehlercode)) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'fehlercodeFehlt'));
|
||||
|
||||
// separate by semicolon if multiple values passed
|
||||
$konfigurationsWert = explode(';', $konfigurationsWert);
|
||||
|
||||
// check if konfiguration already set for the fehlercode
|
||||
$this->FehlerkonfigurationModel->addSelect('konfiguration');
|
||||
$fehlerkonfigurationRes = $this->FehlerkonfigurationModel->loadWhere(
|
||||
array(
|
||||
'konfigurationstyp_kurzbz' => $konfigurationstyp_kurzbz,
|
||||
'fehlercode' => $fehlercode
|
||||
)
|
||||
);
|
||||
|
||||
if (!hasData($fehlerkonfigurationRes)) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'fehlerFehlerKonfigurationLaden'));
|
||||
|
||||
// if konfiguration exists, update values
|
||||
if (hasData($fehlerkonfigurationRes))
|
||||
{
|
||||
$fehlerkonfiguration = getData($fehlerkonfigurationRes);
|
||||
|
||||
$existingKonf = json_decode($fehlerkonfiguration[0]->konfiguration);
|
||||
|
||||
if (!$existingKonf) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'fehlerJsonDekodierung'));
|
||||
|
||||
if (!is_array($existingKonf)) $existingKonf = array($existingKonf);
|
||||
|
||||
$newKonfArr = array_values(array_diff($existingKonf, $konfigurationsWert));
|
||||
|
||||
// if no konfiguration values left, delete whole entry
|
||||
if (isEmptyArray($newKonfArr))
|
||||
{
|
||||
$this->outputJson(
|
||||
$this->FehlerkonfigurationModel->delete(
|
||||
array('konfigurationstyp_kurzbz' => $konfigurationstyp_kurzbz, 'fehlercode' => $fehlercode)
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$newKonf = json_encode($newKonfArr);
|
||||
if (!$newKonf) $this->terminateWithJsonError("error when encoding JSON");
|
||||
|
||||
// if there are still values, delete only part of the konfiguration
|
||||
$this->outputJson(
|
||||
$this->FehlerkonfigurationModel->update(
|
||||
array('konfigurationstyp_kurzbz' => $konfigurationstyp_kurzbz, 'fehlercode' => $fehlercode),
|
||||
array('konfiguration' => $newKonf, 'updateamum' => 'NOW()', 'updatevon' => $this->_uid)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a Konfiguration.
|
||||
*/
|
||||
|
||||
@@ -82,6 +82,9 @@ $this->load->view(
|
||||
<button class="btn btn-default" id="assignKonfiguration">
|
||||
<?php echo $this->p->t('fehlermonitoring', 'konfigurationswertZuweisen') ?>
|
||||
</button>
|
||||
<button class="btn btn-default" id="deleteKonfiguration">
|
||||
<?php echo $this->p->t('fehlermonitoring', 'konfigurationswertLoeschen') ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -144,6 +144,34 @@ var IssuesKonfiguration = {
|
||||
}
|
||||
);
|
||||
},
|
||||
deleteKonfigurationsWerte: function(konfigurationstyp_kurzbz, fehlercode, konfigurationsWert)
|
||||
{
|
||||
FHC_AjaxClient.ajaxCallPost(
|
||||
'system/issues/IssuesKonfiguration/deleteKonfigurationsWerte',
|
||||
{
|
||||
konfigurationstyp_kurzbz: konfigurationstyp_kurzbz,
|
||||
fehlercode: fehlercode,
|
||||
konfigurationsWert: konfigurationsWert
|
||||
},
|
||||
{
|
||||
successCallback: function(data, textStatus, jqXHR) {
|
||||
if (FHC_AjaxClient.hasData(data))
|
||||
{
|
||||
FHC_DialogLib.alertSuccess(FHC_PhrasesLib.t('fehlermonitoring', 'konfigurationGeloescht'))
|
||||
// reload dataset to see change
|
||||
IssuesKonfiguration._reloadKonfigurationOverview();
|
||||
}
|
||||
else
|
||||
{
|
||||
FHC_DialogLib.alertError(FHC_PhrasesLib.t('fehlermonitoring', 'konfigurationGeloeschtFehler'));
|
||||
}
|
||||
},
|
||||
errorCallback: function(jqXHR, textStatus, errorThrown) {
|
||||
FHC_DialogLib.alertError(textStatus);
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
deleteKonfiguration: function(konfigurationstyp_kurzbz, fehlercode)
|
||||
{
|
||||
FHC_AjaxClient.ajaxCallPost(
|
||||
@@ -229,7 +257,7 @@ $(document).ready(function() {
|
||||
}
|
||||
);
|
||||
|
||||
// get new fehlercodes each time app is changed
|
||||
// set assign configuration event
|
||||
$("#assignKonfiguration").click(
|
||||
function()
|
||||
{
|
||||
@@ -241,6 +269,18 @@ $(document).ready(function() {
|
||||
}
|
||||
);
|
||||
|
||||
// set delete configuration event
|
||||
$("#deleteKonfiguration").click(
|
||||
function()
|
||||
{
|
||||
IssuesKonfiguration.deleteKonfigurationsWerte(
|
||||
$("#"+FEHLERKONFIGURATIONSTYP_DROPDOWN_ID).val(),
|
||||
$("#"+FEHLERCODE_DROPDOWN_ID).val(),
|
||||
$("#konfigurationsWert").val()
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
// set events for showing info modals
|
||||
$("#fehlercodeInfoIcon").click(
|
||||
function()
|
||||
|
||||
@@ -17897,7 +17897,7 @@ array(
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'Invalid configuration value for data type {1}, special characters not allowed',
|
||||
'text' => 'Invalid configuration value for data type {0}, special characters not allowed',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
@@ -18123,6 +18123,26 @@ array(
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'fehlermonitoring',
|
||||
'phrase' => 'konfigurationswertLoeschen',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Konfigurationswert(e) löschen',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'Delete configuration value(s)',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user