Skip to content

Commit

Permalink
drop rich text for now; will be done later
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Jul 31, 2024
1 parent ebf857e commit db8eb77
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 38 deletions.
1 change: 0 additions & 1 deletion ajax/asset/customfield.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
Session::checkRight(CustomField::$rightname, READ);

if (isset($_POST['action']) && $_POST['action'] === 'get_custom_field') {
$_POST['field_options']['enable_richtext'] = filter_var($_POST['field_options']['enable_richtext'] ?? false, FILTER_VALIDATE_BOOLEAN);
TemplateRenderer::getInstance()->display('components/form/customfield_display.html.twig', $_POST);
} else {
http_response_code(400);
Expand Down
3 changes: 0 additions & 3 deletions src/Glpi/Asset/AssetDefinitionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,6 @@ private function boostrapConcreteClass(AssetDefinition $definition): void
Change_Item::class,
53
);

// Register required JS libraries
$CFG_GLPI['javascript']['assets'][$asset_class_name] = ['tinymce'];
}

/**
Expand Down
4 changes: 0 additions & 4 deletions src/Glpi/Asset/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,6 @@ public function getSearchOption(): ?array
return null;
}

if ($opt['datatype'] === 'text' && ($this->fields['field_options']['enable_richtext'] ?? false)) {
$opt['htmltext'] = true;
}

if ($opt['datatype'] === 'number') {
$opt['min'] = $this->fields['field_options']['min'] ?? 0;
$opt['max'] = $this->fields['field_options']['max'] ?? PHP_INT_MAX;
Expand Down
5 changes: 0 additions & 5 deletions templates/pages/assets/customfield.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@
{{ fields.sliderField('field_options[multiple]', item.fields['field_options']['multiple']|default(false), __('Multiple values'), {
add_field_class: 'd-none'
}) }}
{{ fields.sliderField('field_options[enable_richtext]', item.fields['field_options']['enable_richtext']|default(false), __('Rich text'), {
add_field_class: 'd-none'
}) }}
{{ fields.numberField('field_options[min]', item.fields['field_options']['min']|default(0), __('Minimum'), {
add_field_class: 'd-none'
}) }}
Expand Down Expand Up @@ -104,7 +101,6 @@
min: $('input[type="number"][name="field_options[min]"]').val(),
max: $('input[type="number"][name="field_options[max]"]').val(),
step: $('input[type="number"][name="field_options[step]"]').val(),
enable_richtext: $('input[type="checkbox"][name="field_options[enable_richtext]"]').is(':checked'),
values: $('select[name="field_options[values][]"]').val(),
};
if ($('input[type="checkbox"][name="field_options[multiple]"]').is(':checked')) {
Expand Down Expand Up @@ -150,7 +146,6 @@
$('input[type="number"][name="field_options[min]"]').closest('.form-field').toggleClass('d-none', selected_type !== 'number');
$('input[type="number"][name="field_options[max]"]').closest('.form-field').toggleClass('d-none', selected_type !== 'number');
$('input[type="number"][name="field_options[step]"]').closest('.form-field').toggleClass('d-none', selected_type !== 'number');
$('input[type="checkbox"][name="field_options[enable_richtext]"]').closest('.form-field').toggleClass('d-none', selected_type !== 'text');
$('select[name="itemtype"]').closest('.form-field').toggleClass('d-none', selected_type !== 'dropdown');
updateDefaultValueField();
Expand Down
9 changes: 0 additions & 9 deletions tests/cypress/e2e/Asset/custom_fields.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ describe("Custom Assets - Custom Fields", () => {
cy.findByRole('button', {name: 'Add'}).click();
});
cy.findByRole('tab', {name: 'Custom fields'}).click();
cy.findByRole('button', {name: 'Add a new field'}).parents('.tab-pane').should('have.class', 'active').first().within(() => {
cy.findByRole('button', {name: 'Add a new field'}).click();
cy.findByLabelText('Label').type('Test Richtext');
cy.findByLabelText('Type').select('Text', { force: true });
cy.findByLabelText('Rich text').check();
cy.findByRole('button', {name: 'Add'}).click();
});
cy.findByRole('tab', {name: 'Custom fields'}).click();
cy.findByRole('button', {name: 'Add a new field'}).parents('.tab-pane').should('have.class', 'active').first().within(() => {
cy.findByRole('button', {name: 'Add a new field'}).click();
cy.findByLabelText('Label').type('Test Number');
Expand Down Expand Up @@ -142,7 +134,6 @@ describe("Custom Assets - Custom Fields", () => {
.should('have.attr', 'type', 'text')
.should('have.attr', 'maxlength', '255');
cy.findByLabelText('Test Text').should('be.visible');
cy.findByLabelText('Test Richtext').awaitTinyMCE();
cy.findByLabelText('Test Number')
.should('have.attr', 'type', 'number')
.should('have.attr', 'min', '10')
Expand Down
16 changes: 0 additions & 16 deletions tests/functional/Glpi/Asset/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,22 +278,6 @@ public function testGetSearchOption()
$this->string($opt['datatype'])->isEqualTo('text');
$this->array($opt)->notHasKey('htmltext');

$custom_field_definition_3 = $this->createItem(\Glpi\Asset\CustomField::class, [
'assets_assetdefinitions_id' => $asset_definition->getID(),
'name' => 'test_richtext',
'label' => 'Test richtext',
'type' => 'text',
'default_value' => 'default richtext',
'field_options' => ['enable_richtext' => 1],
], ['field_options']);
$field_id = $custom_field_definition_3->getID();
$opt = $custom_field_definition_3->getSearchOption();
$this->integer($opt['id'])->isEqualTo($opt_id_offset + $field_id);
$this->string($opt['name'])->isEqualTo('Test richtext');
$this->string((string) $opt['computation'])->isEqualTo("COALESCE(JSON_UNQUOTE(JSON_EXTRACT(`glpi_assets_assets`.`custom_fields`, '$.\\\"{$field_id}\\\"')), 'default richtext')");
$this->string($opt['datatype'])->isEqualTo('text');
$this->boolean($opt['htmltext'])->isTrue();

$custom_field_definition_4 = $this->createItem(\Glpi\Asset\CustomField::class, [
'assets_assetdefinitions_id' => $asset_definition->getID(),
'name' => 'test_number',
Expand Down

0 comments on commit db8eb77

Please sign in to comment.