Add events in form builder manager module
authorMatthias Schmidt <gravatronics@live.com>
Mon, 7 Oct 2019 16:10:05 +0000 (18:10 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 7 Oct 2019 16:10:05 +0000 (18:10 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Manager.js

index 9bdcc79e79ce2f61f8eb42bf133599aa2bea3dba..2bd57c2eba15bfb4e529a378e2bc3a4123e5632e 100644 (file)
 define([
        'Core',
        'Dictionary',
+       'EventHandler',
        './Field/Dependency/Manager',
        './Field/Field'
 ], function(
        Core,
        Dictionary,
+       EventHandler,
        FormBuilderFieldDependencyManager,
        FormBuilderField
 ) {
@@ -141,6 +143,10 @@ define([
                        
                        _forms.set(formId, form);
                        _fields.set(formId, new Dictionary());
+                       
+                       EventHandler.fire('WoltLabSuite/Core/Form/Builder/Manager', 'registerForm', {
+                               formId: formId
+                       });
                },
                
                /**
@@ -153,6 +159,10 @@ define([
                                throw new Error("Unknown form with id '" + formId + "'.");
                        }
                        
+                       EventHandler.fire('WoltLabSuite/Core/Form/Builder/Manager', 'beforeUnregisterForm', {
+                               formId: formId
+                       });
+                       
                        _forms.delete(formId);
                        
                        _fields.get(formId).forEach(function(field) {
@@ -162,6 +172,10 @@ define([
                        _fields.delete(formId);
                        
                        FormBuilderFieldDependencyManager.unregister(formId);
+                       
+                       EventHandler.fire('WoltLabSuite/Core/Form/Builder/Manager', 'afterUnregisterForm', {
+                               formId: formId
+                       });
                }
        };
 });