2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2021 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 import React, { Component } from 'react';
22 import { Link } from 'react-router-dom';
23 import Label from 'react-bootstrap/lib/Label';
24 import Panel from 'react-bootstrap/lib/Panel';
25 import {GlobalExtConstants} from 'utils/GlobalExtConstants.js';
26 import {ExportExcel} from 'utils/ExportExcel.js';
27 let buildAttrList = ExportExcel.buildAttrList;
29 let INVLIST = GlobalExtConstants.INVLIST;
31 class ModelRelationships extends Component {
39 console.log('[ModelRelationships.jsx] props : ', this.props);
40 let relationships = null;
41 let navigateByoq = null;
42 let relativesArray = [];
43 this.nodeDisplay = this.props.relatives.nodeType + ' : ' + (this.props.relatives.nodeUrl).split(this.props.relatives.nodeType + '\/').pop();
44 this.historyClick = () => {
45 this.props.openHistoryModal(this.nodeDisplay, this.props.relatives.nodeUrl,this.props.relatives.nodeType);
48 if (this.props.relatives.nodeRelatives && this.props.relatives.nodeRelatives.length > 0) {
49 relationships = this.props.relatives.nodeRelatives.sort(function(a, b) {
50 var compareA = (a['node-type'] + (a.url).split(a['node-type']+'\/').pop()).toLowerCase();
51 var compareB = (b['node-type'] + (b.url).split(a['node-type']+'\/').pop()).toLowerCase();
52 if(compareA < compareB) return -1;
53 if(compareA > compareB) return 1;
55 }).map((relative, idx) => {
56 if (relativesArray.includes(relative['node-type']) === false) relativesArray.push(relative['node-type']);
62 pathname: '/model/' + relative['node-type'] + '/' + relative.id + '/'+ this.props.relatives.enableRealTime,
64 historyStackString: this.props.historyStackString
66 {relative['node-type']}: {(decodeURI((relative.url).split(relative['node-type']+'\/').pop())).replace(/%2F/g,'/')}</Link> <Label bsStyle='default'>{relative['relationship-label'].slice(33)}</Label>
71 relativesArray = relativesArray.join('&');
73 var requiredParams = buildAttrList(this.props.relatives.nodeType,[],'mandatory');
74 var aliasColumnFilters = (this.props.relatives.aliasColumnList && this.props.relatives.aliasColumnList[this.props.relatives.nodeType])?this.props.relatives.aliasColumnList[this.props.relatives.nodeType][0]:[];
75 console.log('requiredParams>>>>>>>>>>>>',requiredParams);
76 Object.keys(this.props.relatives.nodeProps).map((prop, idx) => {
77 for(var a in requiredParams){
79 if(aliasColumnFilters && aliasColumnFilters[requiredParams[a].value]){
80 alias=requiredParams[a].value;
81 requiredParams[a].value=aliasColumnFilters[requiredParams[a].value];
83 if(requiredParams[a].value === prop){
84 let tag= (alias!='')? alias: prop;
86 propKey = tag + ':' + btoa('<pre>' + this.props.relatives.nodeProps[prop].toString() + '</pre>');
88 propKey = propKey + ';' + tag + ':' + btoa('<pre>' + this.props.relatives.nodeProps[prop].toString() + '</pre>');
93 let pathNameStr = (relativesArray.length>0) ? '/customDsl/' + this.props.relatives.nodeType + '/' + propKey + '/' + relativesArray : '/customDsl/' + this.props.relatives.nodeType + '/' + propKey;
98 <button type='button' className='btn btn-primary pull-right'>>>BYOQ</button>
100 if (this.props.relatives.nodeRelatives && this.props.relatives.nodeRelatives.length > 0) {
105 <button type='button' className='btn btn-outline-primary'>
109 { INVLIST.isHistoryEnabled && (<button type='button' className='btn btn-outline-primary' onClick={this.historyClick}>
115 <Panel.Body className='cardwrap'>
124 <button type='button' className='btn btn-outline-disabled'>
127 { INVLIST.isHistoryEnabled && (<button type='button' className='btn btn-outline-primary' onClick={this.historyClick}>
137 export default ModelRelationships;