Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions inc/container.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ public static function showFormItemtype($params = [])
*/
public static function showFormSubtype($params, $display = false)
{
$out = "<script type='text/javascript'>jQuery('#tab_tr').hide();</script>";
$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']);
Expand Down Expand Up @@ -1509,7 +1509,7 @@ public static function showFormSubtype($params, $display = false)
'display' => false,
],
);
$out .= "<script type='text/javascript'>jQuery('#tab_tr').show();</script>";
$out .= Html::scriptBlock("jQuery('#tab_tr').show();");
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions inc/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -690,19 +690,23 @@ public function showSummary($container)
'plugin_fields_containers_id' => $cID,
'id' => -1,
];
echo "<div class='center'>"
. sprintf("<a href='#' id='add_field%s%d'>", $cID, $rand);
echo __('Add a new field', 'fields') . '</a></div><br>';

echo Html::scriptBlock('
viewAddField' . $cID . $rand . ' = function() {
$("#viewField' . $cID . $rand . '").load(
"' . $CFG_GLPI['root_doc'] . '/ajax/viewsubitem.php",
' . json_encode($ajax_params) . '
);
};
$("#add_field' . $cID . $rand . '").on("click", function(e) {
e.preventDefault();
viewAddField' . $cID . $rand . '();
});
');

echo "<div class='center'>"
. sprintf("<a href='javascript:viewAddField%s%d();'>", $cID, $rand);
echo __('Add a new field', 'fields') . '</a></div><br>';

if (count($iterator) === 0) {
echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>";
echo "<th class='b'>" . __('No field for this block', 'fields') . '</th></tr></table>';
Expand Down
18 changes: 12 additions & 6 deletions inc/labeltranslation.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,22 @@ public static function showTranslations(CommonDBTM $item)
'items_id' => $item->fields['id'],
'id' => -1,
];
echo "<div class='center'>"
. "<a class='vsubmit' href='#' id='add_translation" . $item->getID() . $rand . "'>"
. __('Add a new translation') . '</a></div><br>';

echo Html::scriptBlock('
addTranslation' . $item->getID() . $rand . ' = function() {
$("#viewtranslation' . $item->getID() . $rand . '").load(
"' . $CFG_GLPI['root_doc'] . '/plugins/fields/ajax/viewtranslations.php",
' . json_encode($ajax_params) . '
);
};
$("#add_translation' . $item->getID() . $rand . '").on("click", function(e) {
e.preventDefault();
addTranslation' . $item->getID() . $rand . '();
});
');

echo "<div class='center'>"
. "<a class='vsubmit' href='javascript:addTranslation" . $item->getID() . ($rand . "();'>")
. __('Add a new translation') . '</a></div><br>';
}

$obj = new self();
Expand Down Expand Up @@ -238,8 +242,7 @@ public static function showTranslations(CommonDBTM $item)
echo '<th>' . __('Language', 'fields') . '</th>';
echo '<th>' . __('Label', 'fields') . '</th>';
foreach ($found as $data) {
echo "<tr class='tab_bg_1' " . ($canedit ? "style='cursor:pointer'
onClick=\"viewEditTranslation" . $data['id'] . ($rand . '();"') : '') . '>';
echo "<tr class='tab_bg_1' " . ($canedit ? "style='cursor:pointer' id='translation_row" . $data['id'] . $rand . "'" : '') . '>';
if ($canedit) {
echo "<td class='center'>";
Html::showMassiveActionCheckBox(self::class, $data['id']);
Expand All @@ -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 . '();
});
');
}

Expand Down
13 changes: 7 additions & 6 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading