| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace FluentBoards\App\Services\Intergrations\FluentCRM; |
| 4 | 4 | |
| 5 | 5 | use FluentBoards\App\App; |
| 6 | -use FluentBoards\App\Hooks\Handlers\FluentCrmIntegration; | |
| 6 | +use FluentBoards\App\Vite; | |
| 7 | 7 | use FluentBoards\App\Services\Intergrations\FluentCRM\Automations\ContactAddedBoardTrigger; |
| 8 | 8 | use FluentBoards\App\Services\Intergrations\FluentCRM\Automations\ContactAddedTaskTrigger; |
| 9 | 9 | use FluentBoards\App\Services\Intergrations\FluentCRM\Automations\StageChangedTrigger; |
| 10 | 10 | use FluentBoards\App\Services\Intergrations\FluentCRM\Automations\TaskCreateAction; |
| @@ -17,33 +17,68 @@ | ||
| 17 | 17 | $this->registerToContactSection(); |
| 18 | 18 | |
| 19 | 19 | (new DeepIntegration())->init(); |
| 20 | 20 | $this->registerAutomationFunnels(); |
| 21 | + | |
| 22 | + | |
| 23 | + add_filter('fluent_crm_asset_listed_slugs', function ($lists) { | |
| 24 | + $lists[] = 'fluent-boards'; | |
| 25 | + return $lists; | |
| 26 | + }); | |
| 27 | + | |
| 21 | 28 | } |
| 22 | 29 | |
| 23 | 30 | public function registerToContactSection() |
| 24 | 31 | { |
| 25 | -// (new FluentCrmIntegration())->registerCustomSection(); | |
| 26 | - add_action( 'fluent_crm/global_appjs_loaded', function () { | |
| 27 | - $app = App::getInstance(); | |
| 32 | + add_action('fluent_crm/global_app_boot_loaded', function () { | |
| 33 | + $this->enqueueCrmContactApp3(); | |
| 34 | + }); | |
| 35 | + } | |
| 28 | 36 | |
| 29 | - $assets = $app['url.assets']; | |
| 37 | + /** | |
| 38 | + * Enqueue the FluentCRM contact app bundle. | |
| 39 | + * | |
| 40 | + * @return void | |
| 41 | + */ | |
| 42 | + protected function enqueueCrmContactApp3() | |
| 43 | + { | |
| 44 | + $app = App::getInstance(); | |
| 45 | + $assets = $app['url.assets']; | |
| 46 | + $slug = $app->config->get('app.slug'); | |
| 47 | + $handle = $slug . '_in_crm_contact_app3'; | |
| 48 | + $dependencies = wp_script_is('fluentcrm_admin_app_boot', 'registered') || wp_script_is('fluentcrm_admin_app_boot', 'enqueued') | |
| 49 | + ? ['fluentcrm_admin_app_boot'] | |
| 50 | + : []; | |
| 30 | 51 | |
| 31 | - $slug = $app->config->get('app.slug'); | |
| 32 | - wp_enqueue_script( $slug . '_in_crm', FLUENT_BOARDS_PLUGIN_URL . 'assets/crm-contact-app.js'); | |
| 33 | - wp_enqueue_style($slug . '_in_crm', FLUENT_BOARDS_PLUGIN_URL . 'assets/admin/crm-contact-app.css'); | |
| 34 | - wp_localize_script($slug . '_in_crm', 'fluentAddonVars', [ | |
| 35 | - 'slug' => $slug = $app->config->get('app.slug'), | |
| 36 | - 'nonce' => wp_create_nonce($slug), | |
| 37 | - 'rest' => $this->getRestInfo($app), | |
| 38 | - 'ajaxurl' => admin_url('admin-ajax.php'), | |
| 39 | - 'asset_url' => $assets, | |
| 40 | - 'trans' => TransStrings::getStrings(), | |
| 41 | - 'base_url' => fluent_boards_page_url(), | |
| 42 | - ]); | |
| 52 | + Vite::injectViteClient(); | |
| 43 | 53 | |
| 54 | + Vite::enqueueScript( | |
| 55 | + $handle, | |
| 56 | + 'admin/crm-contact-app3/app.js', | |
| 57 | + $dependencies, | |
| 58 | + FLUENT_BOARDS_PLUGIN_VERSION, | |
| 59 | + true | |
| 60 | + ); | |
| 44 | 61 | |
| 45 | - }); | |
| 62 | + wp_localize_script( | |
| 63 | + $handle, | |
| 64 | + 'fluentBoardsCrmContactApp', | |
| 65 | + [ | |
| 66 | + 'slug' => $slug, | |
| 67 | + 'nonce' => wp_create_nonce($slug), | |
| 68 | + 'rest' => $this->getRestInfo($app), | |
| 69 | + 'ajaxurl' => admin_url('admin-ajax.php'), | |
| 70 | + 'asset_url' => $assets, | |
| 71 | + 'trans' => TransStrings::getStrings(), | |
| 72 | + 'base_url' => fluent_boards_page_url(), | |
| 73 | + 'admin_app_url' => admin_url('admin.php?page=fluent-boards#/'), | |
| 74 | + 'admin_url' => admin_url('admin.php'), | |
| 75 | + 'render_in' => is_admin() ? 'admin' : 'front', | |
| 76 | + 'has_pro' => defined('FLUENT_BOARDS_PRO_VERSION'), | |
| 77 | + 'advanced_modules' => fluent_boards_get_pref_settings(), | |
| 78 | + 'features' => fluent_boards_get_features_config(), | |
| 79 | + ] | |
| 80 | + ); | |
| 46 | 81 | } |
| 47 | 82 | |
| 48 | 83 | public function registerAutomationFunnels() |
| 49 | 84 | { |
| @@ -67,5 +102,5 @@ | ||
| 67 | 102 | 'namespace' => $ns, |
| 68 | 103 | 'version' => $ver, |
| 69 | 104 | ]; |
| 70 | 105 | } |
| 71 | -} | |
| 106 | +} | |