Project

General

Profile

Bug #99934

Updated by Oliver Hader about 1 year ago

It seems that the javascript modules cannot be found when I expand an inline record in the backend. But if I call this inline record directly, then my javascript module works. 
 With TYPO3 11.x and RequireJS it worked but after the migration to 12.x and ES6 it seems to be broken. 

 > I get this error message in the browser-console when I expand the inline-record: 
 > Uncaught (in promise) Error: Unable to resolve specifier '@weisgerber/dog_db/text-open-ai.js' 

 *Steps to reproduce:* 
 Create a model with an inline field to a second model 
 In this second model create a text field and add a custom fieldControl. 

 h2. Here is my configuration:  

 *Model 2: extensions/dog_db/Configuration/TCA/tx_dogdb_domain_model_foodcontent.php:* 
 <pre><code class="php"> 
 'row_description' => [ 
     'exclude' => true, 
     'label' => 'LLL:EXT:dog_db/Resources/Private/Language/locallang_db.xlf:tx_dogdb_domain_model_foodcontent.row_description', 
     'config' => [ 
         'type' => 'text', 
         'cols' => 40, 
         'rows' => 15, 
         'eval' => 'trim', 
         'default' => '', 
         'fieldControl' => [ 
             'textOpenAITranslated' => [ 
                 'renderType' => 'textOpenAITranslatedWizard' 
             ], 
             'textDeepLWritten' => [ 
                 'renderType' => 'textDeepLWrittenWizard' 
             ] 
         ] 
     ] 
 ], 
 </code></pre> 

 *Model 1: extensions/dog_db/Configuration/TCA/tx_dogdb_domain_model_manufacturer.php:* 

 <pre> 
  'products_food' => [ 
             'exclude' => true, 
             'label' => 'LLL:EXT:dog_db/Resources/Private/Language/locallang_db.xlf:tx_dogdb_domain_model_manufacturer.foodcontent', 
             'config' => [ 
                 'type' => 'inline', 
                 'foreign_table' => 'tx_dogdb_domain_model_foodcontent', 
                 'foreign_field' => 'manufacturer', 
                 'maxitems' => 9999, 
                 'appearance' => [ 
                     'collapseAll' => 0, 
                     'levelLinksPosition' => 'top', 
                     'showSynchronizationLink' => 1, 
                     'showPossibleLocalizationRecords' => 1, 
                     'showAllLocalizationLink' => 1 
                 ], 
             ], 
         

         ], 


 *ext_localconf.php:* 
 </pre> 

 *ext_localconf.php:* 

 <pre><code class="php"> 
 $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1673632810] = [ 
     'nodeName' => 'textOpenAITranslatedWizard', 
     'priority' => 33, 
     'class' => \Weisgerber\DogDb\FormEngine\FieldControl\TextOpenAITranslatedWizard::class 
 ]; 
 $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1674761643] = [ 
     'nodeName' => 'textDeepLWrittenWizard', 
     'priority' => 35, 
     'class' => \Weisgerber\DogDb\FormEngine\FieldControl\TextDeepLWrittenWizard::class 
 </code></pre> 

 ]; 
 </code></pre> 


 

 *extensions/dog_db/Classes/FormEngine/FieldControl/TextOpenAITranslatedWizard.php* 
 <pre><code class="php"> 

     public function render(): array 
     { 
         $row = $this->data['databaseRow']; 
         $paramArray = $this->data['parameterArray']; 

         $nameNormal = $paramArray['itemFormElName']; 

         $resultArray = $this->initializeResultArray(); 

         $resultArray['linkAttributes']['class'] = 'textOpenAITranslatedWizard'; 

         $resultArray['iconIdentifier'] = 'text-openai-translated-wizard'; 
         $resultArray['title'] = "Erstellt mit OpenAI ChatGPT"; 

         $resultArray['linkAttributes']['data-name'] = htmlspecialchars($nameNormal); 
         $resultArray['linkAttributes']['data-id'] = $this->data['databaseRow']['uid']; 
         $resultArray['javaScriptModules'][] = JavaScriptModuleInstruction::create( 
             '@weisgerber/dog_db/text-open-ai.js' 
         ); 


         return $resultArray; 
     } 
 </code></pre> 

 *extensions/dog_db/Configuration/JavaScriptModules.php:* 

 <pre> 
 return [ 
     'dependencies' => ['backend'], 
     'imports' => [ 
         '@weisgerber/dog_db/' => 'EXT:dog_db/Resources/Public/JavaScript/', 
     ], 
 ]; 
 </pre> 

 *extensions/dog_db/Resources/Public/JavaScript/text-open-ai.js* 
 <pre><code class="javascript"> 
 import $ from 'jquery'; 
 import FormEngine from '@typo3/backend/form-engine.js'; 

 class TextOpenAi { 
   constructor() { 
     // some stuff 
   } 
 } 

 export default new TextOpenAi(); 
 </code></pre> 

Back