From 7f6fe61e434e8244f18521562b22d7f481ef6716 Mon Sep 17 00:00:00 2001 From: Didier Lafforgue Date: Sat, 12 Oct 2024 23:41:42 +0200 Subject: [PATCH] fix: fix bugs when developing a custom setting type --- app/frontend/editor/misc/dynamic-inputs.js | 2 +- .../maglev/templates/plugin/packages/%table_name%/index.js.tt | 2 +- lib/maglev.rb | 4 ++++ lib/maglev/plugins.rb | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/frontend/editor/misc/dynamic-inputs.js b/app/frontend/editor/misc/dynamic-inputs.js index 7e39263..6f1900f 100644 --- a/app/frontend/editor/misc/dynamic-inputs.js +++ b/app/frontend/editor/misc/dynamic-inputs.js @@ -12,7 +12,7 @@ export const registerInput = function(name, component, transformProps = null) { export const getInput = function(name) { const input = dynamicInputs[name] - if (!input) console.log(`⚠️ Unable to find the ${name} type input. Are you sure you registered it correctly?`) + if (!input) console.log(`🚨 [Maglev ERROR] Unable to find the ${name} type input. Are you sure you registered it correctly?`) return dynamicInputs[name] } diff --git a/lib/generators/maglev/templates/plugin/packages/%table_name%/index.js.tt b/lib/generators/maglev/templates/plugin/packages/%table_name%/index.js.tt index 22b2051..9ef6a53 100644 --- a/lib/generators/maglev/templates/plugin/packages/%table_name%/index.js.tt +++ b/lib/generators/maglev/templates/plugin/packages/%table_name%/index.js.tt @@ -1,7 +1,7 @@ // import { registerInput } from '@/misc/dynamic-inputs' export default function() { - console.log('Hello from the <%= human_name %> plugin 👋 v4.5') + console.log('Hello from the <%= human_name %> plugin 👋 v0.0.1') // registerInput('text', MyOwnTextInputComponent) } \ No newline at end of file diff --git a/lib/maglev.rb b/lib/maglev.rb index b1956ca..a8cecd5 100644 --- a/lib/maglev.rb +++ b/lib/maglev.rb @@ -78,5 +78,9 @@ def plugins def register_plugin(id:, root_path:, name: nil, version: nil) plugins.register(id:, name:, root_path:, version:) end + + def register_setting_type(id:, klass: nil) + ::Maglev::SettingTypeRegistry.register(id:, klass:) + end end end diff --git a/lib/maglev/plugins.rb b/lib/maglev/plugins.rb index a58ce94..2d316ab 100644 --- a/lib/maglev/plugins.rb +++ b/lib/maglev/plugins.rb @@ -104,7 +104,7 @@ def write_frontend_setup_file File.open(frontend_plugin_path, 'w+') do |f| f.write( <<-JAVASCRIPT - import setup from 'dummy_plugin' + import setup from "#{id}.js" setup() JAVASCRIPT )