Registration Page using Custom module

Jira Code: GD-16

Created a new registration page in SCA Website with url https://sandbox.goodearthdist.com/crossfit using a custom module.

To add a custom module:

  1. Create a custom module directory within your custom directory with the format of ModuleName@version.
  2. Create the sub-directories within the module.We need JavaScript, Sass, SuiteScript, and Templates sub-directories.
  3. Create the necessary files for your module.This is where all of your module’s logic is contained. These files are either JavaScript (.js) or TypeScript (.ts), depending on your implementation of SCA.

Entry point file: RegisterPage.js

define('RegisterPage'
,   [
      'RegisterPage.Router'
   ]
,   function (
      Router
   )
{
   'use strict';

   return   {
      mountToApp: function (application)
      {
         console.log('Hello World!');
         // Initializes the router
         return new Router(application);
      }
   };
});

Router: RegisterPage.Router.js

//MyNewModule.Router.js
define('RegisterPage.Router'
,   [
         'RegisterPage.View'
      ,   'Backbone'
   ]
,   function (
         RegisterPageView
      ,   Backbone
   )
{
   'use strict';

   //@class Address.Router @extend Backbone.Router
   return Backbone.Router.extend({

      routes: {
         'crossfit': 'RegisterPageRouter'
      }

   ,   initialize: function (application)
      {
         this.application = application;
      }

      // list myNewRouter output
    ,   RegisterPageRouter: function ()
      {
           var view = new RegisterPageView({
              application: this.application
           })
           view.showContent();
        }
   });
});

View: RegisterPage.View.js

//MyNewModule.View.js
define(
   'RegisterPage.View', [
      'register_page.tpl', 'Backbone', 'jQuery', 'Backbone.FormView', 'RegisterPage.Model', 'Backbone.CompositeView'
   ],
   function (
      RegisterPageTemplate, Backbone, jQuery, BackboneFormView, RegisterPageModel, BackboneCompositeView
   ) {
      'use strict';

      //@class Address.List.View List profile's addresses @extend Backbone.View
      return Backbone.View.extend({

         template: RegisterPageTemplate

            ,

         initialize: function (options) {
          
            BackboneCompositeView.add(this);
            this.application = options.application;
            this.model = new RegisterPageModel();
            BackboneFormView.add(this);
            

         },

         title: _('Registration').translate(),
         page_header: _('Registration').translate(),
         attributes: {
            'id': 'crossfit-register',
            'class': 'crossfit-register'
         },
         events: {
            'submit form': 'SubmitForm'
         }

         ,
         childViews: {},

         SubmitForm: function (e) {
               var promise = BackboneFormView.saveForm.apply(this, arguments),
                  self = this;
               console.log('promise', promise)
               return promise;

            }

            ,
         getContext: function () {
            return {
               //@property {String} myNewModuleContextVar
               myNewModuleContextVar: 'myVariable'
            };
         }
      });
   });

Leave a comment

Your email address will not be published. Required fields are marked *