index.js

import 'whatwg-fetch';
import 'promise-polyfill/src/polyfill';

import PopupManager from './newPopupManager';
import {
    init,
    Login,
    Forgot,
    ChangePassword,
    ResetPassword,
    ChangeMail,
    Smartstatus,
    UserRegistration,
    Profile,
    Social,
    Signup,
    PtAddPassword,
    PtChangePassword
} from './methods';
import { manageError } from './errorManager';

/**
 * @class Useris
 * @description
 * **Useris** is a Js library to be used in B! web applications
 * and must be used together with the NewtonAdapter module.
 * It features a simple way to manage and validate all the forms,
 * inputs and buttons to manage the user actions.
 * You can use **Useris** when you need to implement one of those features:
 *  - [Login]{@link Useris.login}
 *  - [Forgot]{@link Useris.forgot}
 *  - [Change Password]{@link Useris.changePassword}
 *  - [Reset Password]{@link Useris.resetPassword}
 *  - [Manage the smartstatus actions]{@link Useris.smartstatus}
 *  - [Add Identity]{@link Useris.userRegistration}
 *  - [Show an error message]{@link Useris.triggerError}
 *
 *
 * Remember that **Useris** doesn't manage a full login flow.
 * It only manages the html content to add click action and validation features.
 * The real login flow has to be passed as callback.
 * You will find the object to pass to the newton adapter as response in the callback
 * and in most of the cases you should use it without manipulation.
 *
 * In all the methods you will see an options object with an element params.
 * This element params is optional.
 * If you have yet injected the tmpl inside the html,
 * **Useris** will not call any template and will not populate any html
 * but it will start to attach events and validation features to the forms.
 *
 * **Useris** is based on a simple **MVC** model.
 * In fact, the UserView module is the referent to the view.
 * When you have to manage event or hide, show, get or add an element,
 * you have to use the UserView module.
 * The controller is not necessary because we don't have to mantain or manipulate any type of datas.
 *
 * To use **Useris**
 * you have (before calling any other function) to initialize it with the init method.
 */
export default {
    init,
    login: (new Login()).handle,
    forgot: (new Forgot()).handle,
    changePassword: (new ChangePassword()).handle,
    resetPassword: (new ResetPassword()).handle,
    changeMail: (new ChangeMail()).handle,
    smartstatus: (new Smartstatus()).handle,
    userRegistration: (new UserRegistration()).handle,
    profile: (new Profile()).handle,
    social: (new Social()).handle,
    signup: (new Signup()).handle,
    ptAddPassword: (new PtAddPassword()).handle,
    ptChangePassword: (new PtChangePassword()).handle,

    triggerError: manageError,
    PopupManager: new PopupManager()
};