From f1d402e2b790d675b7e79bde8d654a1e9d6d673a Mon Sep 17 00:00:00 2001 From: rsnrk Date: Thu, 25 Jun 2026 11:42:51 +0200 Subject: [PATCH] lightmode hides unnecessary fields --- src/Form/DFG3dViewerConfigForm.php | 40 ++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/src/Form/DFG3dViewerConfigForm.php b/src/Form/DFG3dViewerConfigForm.php index b52fbae..b2f4a4c 100644 --- a/src/Form/DFG3dViewerConfigForm.php +++ b/src/Form/DFG3dViewerConfigForm.php @@ -67,6 +67,19 @@ class DFG3dViewerConfigForm extends FormBase { $form['#attached']['library'][] = 'dfg_3dviewer/dfg_3dviewer.config_form'; + $full_mode_states = [ + 'visible' => [ + ':input[name="dfg_3dviewer_lightweight"]' => ['checked' => FALSE], + ], + ]; + + $form['dfg_3dviewer_lightweight'] = [ + '#default_value' => $default_settings['lightweight'], + '#type' => 'checkbox', + '#title' => $this->t('Lightweight version. If checked, 3D Viewer will provide only basic operations.'), + '#required' => false, + ]; + $form['dfg_3dviewer_main_url'] = [ '#default_value' => $default_settings['main_url'], '#type' => 'textfield', @@ -86,14 +99,16 @@ class DFG3dViewerConfigForm extends FormBase { '#default_value' => $default_settings['metadata_url'], '#type' => 'textfield', '#title' => $this->t('Metadata URL'), - '#description' => 'URL of the instance that serves metadata content' + '#description' => 'URL of the instance that serves metadata content', + '#states' => $full_mode_states, ]; $form['dfg_3dviewer_json_export_base_url'] = [ '#default_value' => $default_settings['json_export_base_url'], '#type' => 'textfield', '#title' => $this->t('JSON Export Base URL'), - '#description' => 'Base URL of the instance that serves JSON export, e.g. https://repository.covher.eu' + '#description' => 'Base URL of the instance that serves JSON export, e.g. https://repository.covher.eu', + '#states' => $full_mode_states, ]; $form['dfg_3dviewer_container'] = [ @@ -133,21 +148,24 @@ class DFG3dViewerConfigForm extends FormBase { '#type' => 'textfield', '#title' => $this->t('API 3D File Field'), '#required' => false, - '#description' => 'ID or machine name of the field that should populate API `3D_file`' + '#description' => 'ID or machine name of the field that should populate API `3D_file`', + '#states' => $full_mode_states, ]; $form['dfg_3dviewer_image_generation'] = [ '#default_value' => $default_settings['image_generation'], '#type' => 'textfield', '#title' => $this->t('Image Generation'), - '#description' => 'ID of the bundle for the entity given in wisski pathbuilder for image_generation field' + '#description' => 'ID of the bundle for the entity given in wisski pathbuilder for image_generation field', + '#states' => $full_mode_states, ]; $form['dfg_3dviewer_field_df'] = [ '#default_value' => $default_settings['field_df'], '#type' => 'textfield', '#title' => $this->t('Field DF'), - '#description' => 'Name of the field given for field_df' + '#description' => 'Name of the field given for field_df', + '#states' => $full_mode_states, ]; $form['dfg_3dviewer_export_viewer'] = [ @@ -155,6 +173,7 @@ class DFG3dViewerConfigForm extends FormBase { '#type' => 'textfield', '#title' => $this->t('Export Viewer Field'), '#description' => 'Name of the field given for export_viewer', + '#states' => $full_mode_states, ]; $form['dfg_3dviewer_export_viewer_url'] = [ @@ -162,6 +181,7 @@ class DFG3dViewerConfigForm extends FormBase { '#type' => 'textfield', '#title' => $this->t('Export Viewer URL'), '#description' => 'URL for the export viewer', + '#states' => $full_mode_states, ]; $form['scale_wrapper'] = [ @@ -197,7 +217,8 @@ class DFG3dViewerConfigForm extends FormBase { '#type' => 'container', '#attributes' => [ 'class' => ['gallery-fields-wrapper', 'gallery-container'], - ] + ], + '#states' => $full_mode_states, ]; $form['gallery_wrapper']['dfg_3dviewer_gallery_container'] = [ @@ -256,13 +277,6 @@ class DFG3dViewerConfigForm extends FormBase { '#description' => 'ID that allows get more specific data from WissKI', ]; - $form['dfg_3dviewer_lightweight'] = [ - '#default_value' => $default_settings['lightweight'], - '#type' => 'checkbox', - '#title' => $this->t('Lightweight version. If checked, 3D Viewer will provide only basic operations.'), - '#required' => false - ]; - $form['submit'] = [ '#type' => 'submit', '#value' => $this->t('Submit'),