diff --git a/CHANGELOG.md b/CHANGELOG.md
index a57ea7bf..f75b60b6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [UNRELEASED]
+### Changed
+
+- Make the plugin compatible with the Content Security Policy
+
### Fixed
- Fix form submission error when a multiple dropdown field question is left empty
diff --git a/inc/container.class.php b/inc/container.class.php
index a5a78af4..3d2ee7d8 100644
--- a/inc/container.class.php
+++ b/inc/container.class.php
@@ -1471,7 +1471,7 @@ public static function showFormItemtype($params = [])
*/
public static function showFormSubtype($params, $display = false)
{
- $out = "";
+ $out = Html::scriptBlock("jQuery('#tab_tr').hide();");
if (isset($params['type']) && $params['type'] == 'domtab' && class_exists($params['itemtype'])) {
$dbu = new DbUtils();
$item = $dbu->getItemForItemtype($params['itemtype']);
@@ -1509,7 +1509,7 @@ public static function showFormSubtype($params, $display = false)
'display' => false,
],
);
- $out .= "";
+ $out .= Html::scriptBlock("jQuery('#tab_tr').show();");
}
}
}
diff --git a/inc/field.class.php b/inc/field.class.php
index 82817259..b51eb34c 100644
--- a/inc/field.class.php
+++ b/inc/field.class.php
@@ -690,6 +690,10 @@ public function showSummary($container)
'plugin_fields_containers_id' => $cID,
'id' => -1,
];
+ echo "
';
+
echo Html::scriptBlock('
viewAddField' . $cID . $rand . ' = function() {
$("#viewField' . $cID . $rand . '").load(
@@ -697,12 +701,12 @@ public function showSummary($container)
' . json_encode($ajax_params) . '
);
};
+ $("#add_field' . $cID . $rand . '").on("click", function(e) {
+ e.preventDefault();
+ viewAddField' . $cID . $rand . '();
+ });
');
- echo "
';
-
if (count($iterator) === 0) {
echo "";
echo "| " . __('No field for this block', 'fields') . ' |
';
diff --git a/inc/labeltranslation.class.php b/inc/labeltranslation.class.php
index 8b1ff9ac..c966e5e7 100644
--- a/inc/labeltranslation.class.php
+++ b/inc/labeltranslation.class.php
@@ -196,6 +196,10 @@ public static function showTranslations(CommonDBTM $item)
'items_id' => $item->fields['id'],
'id' => -1,
];
+ echo "
';
+
echo Html::scriptBlock('
addTranslation' . $item->getID() . $rand . ' = function() {
$("#viewtranslation' . $item->getID() . $rand . '").load(
@@ -203,11 +207,11 @@ public static function showTranslations(CommonDBTM $item)
' . json_encode($ajax_params) . '
);
};
+ $("#add_translation' . $item->getID() . $rand . '").on("click", function(e) {
+ e.preventDefault();
+ addTranslation' . $item->getID() . $rand . '();
+ });
');
-
- echo "
';
}
$obj = new self();
@@ -238,8 +242,7 @@ public static function showTranslations(CommonDBTM $item)
echo '' . __('Language', 'fields') . ' | ';
echo '' . __('Label', 'fields') . ' | ';
foreach ($found as $data) {
- echo "';
+ echo "
';
if ($canedit) {
echo "| ";
Html::showMassiveActionCheckBox(self::class, $data['id']);
@@ -261,6 +264,9 @@ public static function showTranslations(CommonDBTM $item)
' . json_encode($ajax_params) . '
);
};
+ $("#translation_row' . $data['id'] . $rand . '").on("click", function() {
+ viewEditTranslation' . $data['id'] . $rand . '();
+ });
');
}
diff --git a/setup.php b/setup.php
index 1ed1bebc..a9bdefba 100644
--- a/setup.php
+++ b/setup.php
@@ -238,12 +238,13 @@ function plugin_fields_script_endswith($scriptname)
function plugin_version_fields()
{
return [
- 'name' => __('Additional fields', 'fields'),
- 'version' => PLUGIN_FIELDS_VERSION,
- 'author' => "Teclib', Olivier Moron",
- 'homepage' => 'https://github.com/pluginsGLPI/fields',
- 'license' => 'GPLv2+',
- 'requirements' => [
+ 'name' => __('Additional fields', 'fields'),
+ 'version' => PLUGIN_FIELDS_VERSION,
+ 'author' => "Teclib', Olivier Moron",
+ 'homepage' => 'https://github.com/pluginsGLPI/fields',
+ 'license' => 'GPLv2+',
+ 'csp_compliant' => true,
+ 'requirements' => [
'glpi' => [
'min' => PLUGIN_FIELDS_MIN_GLPI,
'max' => PLUGIN_FIELDS_MAX_GLPI,
|