auditTableGenerate: function()

in dashboardv3/public/js/views/audit/CreateAuditTableLayoutView.js [108:206]


            auditTableGenerate: function() {
                var that = this,
                    table = "";
                var detailObj = this.entityModel.get('details');
                if (detailObj) {
                    if (detailObj.search(':') >= 0) {
                        var parseDetailsObject = detailObj.split(':'),
                            type = "",
                            auditData = "";
                        if (parseDetailsObject.length > 1) {
                            type = parseDetailsObject[0];
                            parseDetailsObject.shift();
                            auditData = parseDetailsObject.join(":");
                        }
                        if (auditData.search('{') === -1) {
                            if (type.trim() === "Added labels" || type.trim() === "Deleted labels") {
                                this.updateName(auditData.trim().split(" ").join(","));
                            } else {
                                this.updateName(auditData);
                            }
                        } else {
                            try {
                                parseDetailsObject = JSON.parse(auditData);
                                var skipAttribute = parseDetailsObject.typeName ? "guid" : null,
                                    name = Utils.getName(parseDetailsObject, null, skipAttribute);
                                if (name == "-") {
                                    name = _.escape(parseDetailsObject.typeName);
                                }
                                var name = ((name ? name : this.entityName));
                                that.updateName(name);
                                if (parseDetailsObject) {
                                    var attributesDetails = $.extend(true, {}, parseDetailsObject.attributes),
                                        customAttr = parseDetailsObject.customAttributes,
                                        labelsDetails = parseDetailsObject.labels,
                                        relationshipAttributes = parseDetailsObject.relationshipAttributes,
                                        bmAttributesDeails = that.entity.businessAttributes ? that.entity.businessAttributes[parseDetailsObject.typeName] : null;
                                    if (attributesDetails) {
                                        if (bmAttributesDeails) {
                                            _.each(Object.keys(attributesDetails), function(key) {
                                                if (bmAttributesDeails[key].typeName.toLowerCase().indexOf("array<date>") > -1) {
                                                    if (attributesDetails[key].length) { // multiple date values
                                                        attributesDetails[key] = _.map(attributesDetails[key], function(dateValue) {
                                                            return Utils.formatDate({ date: dateValue })
                                                        });
                                                    } else {
                                                        attributesDetails[key] = Utils.formatDate({ date: attributesDetails[key] });
                                                    }
                                                }
                                            })
                                        }
                                        that.ui.attributeDetails.removeClass('hide');
                                        that.action.indexOf("Classification") === -1 ? that.ui.panelAttrHeading.html("Technical properties ") : that.ui.panelAttrHeading.html("Properties ");
                                        var attrTable = that.createTableWithValues(attributesDetails);
                                        that.ui.attributeCard.html(
                                            attrTable);
                                    }
                                    if (!_.isEmpty(customAttr)) {
                                        that.ui.customAttributeDetails.removeClass('hide');
                                        var customAttrTable = that.createTableWithValues(customAttr);
                                        that.ui.customAttrCard.html(
                                            customAttrTable);
                                    }
                                    if (!_.isEmpty(labelsDetails)) {
                                        this.ui.labelsDetailsTable.removeClass('hide');
                                        var labelsTable = '';
                                        _.each(labelsDetails, function(value, key, list) {
                                            labelsTable += "<label class='label badge-default'>" + value + "</label>";
                                        });
                                        that.ui.labelCard.html(
                                            labelsTable);
                                    }
                                    if (!_.isEmpty(relationshipAttributes)) {
                                        that.ui.relationShipAttributeDetails.removeClass('hide');
                                        var relationshipAttrTable = that.createTableWithValues(relationshipAttributes);
                                        that.ui.relationshipAttrCard.html(
                                            relationshipAttrTable);
                                    }
                                    if (!attributesDetails && !customAttr && !labelsDetails && !relationshipAttributes) {
                                        that.ui.detailsAttribute.removeClass('hide');
                                        var attrDetailTable = that.createTableWithValues(parseDetailsObject);
                                        that.ui.attributeDetailCard.html(
                                            attrDetailTable);
                                    }
                                } else {
                                    that.noDetailsShow();
                                }
                            } catch (err) {
                                if (_.isArray(parseDetailsObject)) {
                                    var name = _.escape(parseDetailsObject[0]);
                                }
                                that.updateName(name);
                                that.noDetailsShow();
                            }
                        }
                    } else if (detailObj == "Deleted entity" || detailObj == "Purged entity") {
                        this.entityName ? this.updateName(this.entityName) : (this.ui.name.hide() && this.ui.noData.removeClass("hide"));
                    }
                }
            }