/*!
    Copyright (C) 2016 Google Inc.
    Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
*/

(function (GGRC, can) {
  'use strict';

  var baseWidgetsConfig = {
    AccessGroup: 'Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor Snapshot',
    Audit: 'AccessGroup Clause Contract Control Assessment AssessmentTemplate DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor',
    Clause: 'AccessGroup Audit Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor Snapshot',
    Contract: 'AccessGroup Audit Clause Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Process Product Program Project Request Section System Vendor Snapshot',
    Control: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Request Section Standard System Vendor Snapshot',
    Assessment: 'AccessGroup Audit Clause Contract Control DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Request Section Standard System Vendor',
    DataAsset: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor',
    Facility: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor',
    Issue: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor',
    Market: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor',
    Objective: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor',
    OrgGroup: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor',
    Person: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Policy Process Product Program Project Regulation Request Request Section Standard System Vendor',
    Policy: 'AccessGroup Audit Clause Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Process Product Program Project Request Section System Vendor',
    Process: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor',
    Product: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor',
    Program: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Project Regulation Request Section Standard System Vendor',
    Project: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor',
    Regulation: 'AccessGroup Audit Clause Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Process Product Program Project Request Section System Vendor',
    Request: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor',
    Section: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor',
    Standard: 'AccessGroup Audit Clause Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Process Product Program Project Request Section System Vendor',
    System: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor',
    Vendor: 'AccessGroup Audit Clause Contract Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor'
  };
  var baseWidgets = {};

  Object.keys(baseWidgetsConfig)
    .forEach(function (key) {
      baseWidgets[key] = baseWidgetsConfig[key].split(' ').sort();
    });
  GGRC.tree_view = GGRC.tree_view || new can.Map();
  GGRC.tree_view.attr('base_widgets_by_type', baseWidgets);
})(window.GGRC, window.can);

@@ -1,15 +1,12 @@
 /*!%0A
-   
  Copyrig
@@ -29,19 +29,16 @@
 le Inc.%0A
-   
  License
@@ -111,12 +111,12 @@
 le%3E%0A
+ 
 */%0A
-%0A
 (fun
@@ -151,27 +151,303 @@
 trict';%0A
-%0A  var base
+  /**%0A   * Tree View Widgets Configuration module%0A   * NOTE: should replaced with some back-end configuration JSON%0A   */%0A  // Items allowed for mapping via snapshot.%0A  // NOTE: 'Risk' and 'Threat' Models has no mapping configuration with Audit!!! Need to be double checked%0A  var snapshot
 WidgetsC
@@ -454,22 +454,23 @@
 onfig = 
-%7B
+%5B
 %0A    
+'
 AccessGr
@@ -476,32 +476,34 @@
 roup
-: 'Audit 
+',%0A    '
 Clause
- 
+', '
 Contract
  Con
@@ -502,198 +502,615 @@
 ract
- Control Assessment DataAsset Facility Issue Market Objective OrgGroup Person Policy Process Product Program Project Regulation Request Section Standard System Vendor Snapshot',%0A    Audit: '
+',%0A    'Control',%0A    'DataAsset',%0A    'Facility', 'Market',%0A    'Objective',%0A    'OrgGroup',%0A    'Policy',%0A    'Process',%0A    'Product',%0A    'Regulation',%0A    'Section',%0A    'Standard',%0A    'System',%0A    'Vendor',%0A    'Risk',%0A    'Threat'%5D;%0A  // Items allowed for relationship mapping%0A  var directMappingConfig = %5B%0A    'Assessment',%0A    'AssessmentTemplate',%0A    'Issue',%0A    'Request'%0A  %5D;%0A  // Extra Tree View Widgets require to be rendered on Audit View%0A  var auditInclusion = %5B%0A    'Person',%0A    'Program'%0A  %5D;%0A  // Audit is excluded and created a separate logic for it%0A  var baseWidgetsConfig = %7B%0A    
 Acce
@@ -1116,16 +1116,24 @@
 essGroup
+: 'Audit
  Clause 
@@ -1164,27 +1164,8 @@
 ent 
-AssessmentTemplate 
 Data
@@ -1302,24 +1302,33 @@
 ystem Vendor
+ Snapshot
 ',%0A    Claus
@@ -5977,16 +5977,162 @@
 ts = %7B%7D;
+%0A  // Should be replaced in a future%0A  baseWidgets.Audit = %5B%5D%0A    .concat(snapshotWidgetsConfig, directMappingConfig, auditInclusion)%0A    .sort();
 %0A%0A  Obje

Update base widgets to make it more generic and configurable for Audit