lib/forms/camunda-form.js
function CamundaForm(options) {
  if(!options) {
    throw new Error('CamundaForm need to be initialized with options.');
  }

  var done = options.done = options.done || function(err) { if(err) throw err; };

  if (options.client) {
    this.client = options.client;
  }
  else {
    this.client = new CamSDK.Client(options.clientConfig || {});
  }

  if (!options.taskId && !options.processDefinitionId && !options.processDefinitionKey) {
    return done(new Error('Cannot initialize Taskform: either \'taskId\' or \'processDefinitionId\' or \'processDefinitionKey\' must be provided'));
  }

  this.taskId = options.taskId;
  if(this.taskId) {
    this.taskBasePath = this.client.baseUrl + '/task/' + this.taskId;
  }
  this.processDefinitionId = options.processDefinitionId;
  this.processDefinitionKey = options.processDefinitionKey;

  this.formElement = options.formElement;
  this.containerElement = options.containerElement;
  this.formUrl = options.formUrl;

  if(!this.formElement && !this.containerElement) {
    return done(new Error('CamundaForm needs to be initilized with either \'formElement\' or \'containerElement\''));
  }

  if(!this.formElement && !this.formUrl) {
    return done(new Error('Camunda form needs to be intialized with either \'formElement\' or \'formUrl\''));
  }

  /**
   * A VariableManager instance
   * @type {VariableManager}
   */
  this.variableManager = new VariableManager({
    client: this.client
  });

  /**
   * An array of FormFieldHandlers
   * @type {FormFieldHandlers[]}
   */
  this.formFieldHandlers = options.formFieldHandlers || [
    InputFieldHandler,
    ChoicesFieldHandler,
    FileDownloadHandler
  ];

  this.businessKey = null;

  this.fields = [];

  this.scripts = [];

  this.options = options;

  // init event support
  Events.attach(this);

  this.initialize(done);
}
function CamundaForm(options) {
  if(!options) {
    throw new Error('CamundaForm need to be initialized with options.');
  }

  var done = options.done = options.done || function(err) { if(err) throw err; };

  if (options.client) {
    this.client = options.client;
  }
  else {
    this.client = new CamSDK.Client(options.clientConfig || {});
  }

  if (!options.taskId && !options.processDefinitionId && !options.processDefinitionKey) {
    return done(new Error('Cannot initialize Taskform: either \'taskId\' or \'processDefinitionId\' or \'processDefinitionKey\' must be provided'));
  }

  this.taskId = options.taskId;
  if(this.taskId) {
    this.taskBasePath = this.client.baseUrl + '/task/' + this.taskId;
  }
  this.processDefinitionId = options.processDefinitionId;
  this.processDefinitionKey = options.processDefinitionKey;

  this.formElement = options.formElement;
  this.containerElement = options.containerElement;
  this.formUrl = options.formUrl;

  if(!this.formElement && !this.containerElement) {
    return done(new Error('CamundaForm needs to be initilized with either \'formElement\' or \'containerElement\''));
  }

  if(!this.formElement && !this.formUrl) {
    return done(new Error('Camunda form needs to be intialized with either \'formElement\' or \'formUrl\''));
  }

  /**
   * A VariableManager instance
   * @type {VariableManager}
   */
  this.variableManager = new VariableManager({
    client: this.client
  });

  /**
   * An array of FormFieldHandlers
   * @type {FormFieldHandlers[]}
   */
  this.formFieldHandlers = options.formFieldHandlers || [
    InputFieldHandler,
    ChoicesFieldHandler,
    FileDownloadHandler
  ];

  this.businessKey = null;

  this.fields = [];

  this.scripts = [];

  this.options = options;

  // init event support
  Events.attach(this);

  this.initialize(done);
}
function CamundaForm ( options ) { if ( ! options ) { throw new Error ( 'CamundaForm need to be initialized with options.' ) ; } var done = options . done = options . done || function ( err ) { if ( err ) throw err ; } ; if ( options . client ) { this . client = options . client ; } else { this . client = new CamSDK . Client ( options . clientConfig || { } ) ; } if ( ! options . taskId && ! options . processDefinitionId && ! options . processDefinitionKey ) { return done ( new Error ( 'Cannot initialize Taskform: either \'taskId\' or \'processDefinitionId\' or \'processDefinitionKey\' must be provided' ) ) ; } this . taskId = options . taskId ; if ( this . taskId ) { this . taskBasePath = this . client . baseUrl + '/task/' + this . taskId ; } this . processDefinitionId = options . processDefinitionId ; this . processDefinitionKey = options . processDefinitionKey ; this . formElement = options . formElement ; this . containerElement = options . containerElement ; this . formUrl = options . formUrl ; if ( ! this . formElement && ! this . containerElement ) { return done ( new Error ( 'CamundaForm needs to be initilized with either \'formElement\' or \'containerElement\'' ) ) ; } if ( ! this . formElement && ! this . formUrl ) { return done ( new Error ( 'Camunda form needs to be intialized with either \'formElement\' or \'formUrl\'' ) ) ; } /**
   * A VariableManager instance
   * @type {VariableManager}
   */ this . variableManager = new VariableManager ( { client : this . client } ) ; /**
   * An array of FormFieldHandlers
   * @type {FormFieldHandlers[]}
   */ this . formFieldHandlers = options . formFieldHandlers || [ InputFieldHandler , ChoicesFieldHandler , FileDownloadHandler ] ; this . businessKey = null ; this . fields = [ ] ; this . scripts = [ ] ; this . options = options ; // init event support Events . attach ( this ) ; this . initialize ( done ) ; }
A class to help handling embedded forms

@class
@memberof CamSDk.form

@param {Object.<String,*>} options
@param {Cam}               options.client
@param {String}            [options.taskId]
@param {String}            [options.processDefinitionId]
@param {String}            [options.processDefinitionKey]
@param {Element}           [options.formContainer]
@param {Element}           [options.formElement]
@param {Object}            [options.urlParams]
@param {String}            [options.formUrl]
A class to help handling embedded forms