diff --git a/projects/questionset-editor-library/src/lib/components/editor/editor.component.ts b/projects/questionset-editor-library/src/lib/components/editor/editor.component.ts index aea152df..4324a64d 100755 --- a/projects/questionset-editor-library/src/lib/components/editor/editor.component.ts +++ b/projects/questionset-editor-library/src/lib/components/editor/editor.component.ts @@ -113,7 +113,7 @@ export class EditorComponent implements OnInit, OnDestroy, AfterViewInit { this.toolbarConfig = this.editorService.getToolbarConfig(); this.isStatusReviewMode = this.isReviewMode(); - if (this.objectType === 'question') { + if (this.objectType.toLowerCase() === 'question') { this.handleQuestionObjectType(); } else { this.pageId = 'questionset_editor'; @@ -312,7 +312,7 @@ export class EditorComponent implements OnInit, OnDestroy, AfterViewInit { field.options = this.setEcm; } }); - if ( this.objectType === 'questionset' && _.has(formsConfigObj, 'searchConfig')) { + if ( this.objectType.toLowerCase() === 'questionset' && _.has(formsConfigObj, 'searchConfig')) { this.questionlibraryInput.searchFormConfig = _.get(formsConfigObj, 'searchConfig.properties'); this.questionlibraryInput.metadataFormConfig = _.get(formsConfigObj, 'childMetadata') } else { @@ -334,7 +334,7 @@ export class EditorComponent implements OnInit, OnDestroy, AfterViewInit { const requests = []; this.collectionTreeNodes = null; requests.push(this.editorService.fetchCollectionHierarchy(this.collectionId)); - if (this.objectType === 'questionset') { + if (this.objectType.toLowerCase() === 'questionset') { requests.push(this.editorService.readQuestionSet(this.collectionId)); } return forkJoin(requests).pipe(tap(responseList => { @@ -349,7 +349,7 @@ export class EditorComponent implements OnInit, OnDestroy, AfterViewInit { this.toolbarConfig.hasChildren = true; } - if (this.objectType === 'questionset') { + if (this.objectType.toLowerCase() === 'questionset') { const questionSetResponse = _.last(responseList); const data = _.get(questionSetResponse, _.toLower(`result.${this.objectType}`)); this.collectionTreeNodes.data.instructions = data.instructions ? data.instructions : ''; @@ -1129,5 +1129,4 @@ export class EditorComponent implements OnInit, OnDestroy, AfterViewInit { ); return response; } - -} +} \ No newline at end of file diff --git a/projects/questionset-editor-library/src/lib/components/fancy-tree/fancy-tree.component.ts b/projects/questionset-editor-library/src/lib/components/fancy-tree/fancy-tree.component.ts index 90cc1a63..e297d624 100755 --- a/projects/questionset-editor-library/src/lib/components/fancy-tree/fancy-tree.component.ts +++ b/projects/questionset-editor-library/src/lib/components/fancy-tree/fancy-tree.component.ts @@ -78,7 +78,7 @@ export class FancyTreeComponent implements OnInit, AfterViewInit, OnDestroy { const data = this.nodes.data; this.nodeParentDependentMap = this.editorService.getParentDependentMap(this.nodes.data); let treeData; - if (_.get(this.editorService, 'editorConfig.config.renderTaxonomy') === true && _.isEmpty(_.get(this.nodes, 'data.children'))) { + if (_.get(this.editorService, 'editorConfig.config.renderTaxonomy') === true && _.isEmpty(_.get(this.nodes, 'data.children')) || _.get(this.editorService, 'editorConfig.config.renderTaxonomy') === true && !_.isEmpty(_.get(this.nodes, 'data.children')) && this.nodes.data.children[0]?.category) { this.helperService.addDepthToHierarchy(this.nodes.data.children); this.nodes.data.children = this.removeIntermediateLevelsFromFramework(this.nodes.data.children); treeData = this.buildTreeFromFramework(this.nodes.data); @@ -119,24 +119,28 @@ export class FancyTreeComponent implements OnInit, AfterViewInit, OnDestroy { return data; } - buildTreeFromFramework(data, tree?, level?) { + buildTreeFromFramework(data, tree?, primaryCategory?,objectType?) { tree = tree || []; if (data.children) { data.children = _.sortBy(data.children, ['index']); } _.forEach(data.children, (child) => { const childTree = []; - tree.push({ - id: uuidv4(), - title: child.name, - tooltip: child.name, - primaryCategory: child.primaryCategory, - metadata: _.omit(child, ['children', 'collections']), - folder: true, - children: childTree, - root: false, - icon: 'fa fa-folder-o' - }); - if (child.children) { - this.buildTreeFromFramework(child, childTree); + if(child) { + child.mimeType = data.mimeType; + tree.push({ + id: uuidv4(), + title: child.name, + tooltip: child.name, + primaryCategory: primaryCategory ? primaryCategory :data.primaryCategory, + objectType: objectType ? objectType : data.objectType, + metadata: _.omit(child, ['children', 'collections']), + folder: true, + children: childTree, + root: false, + icon: 'fa fa-folder-o' + }); + if (child.children) { + this.buildTreeFromFramework(child, childTree,data.primaryCategory,data.objectType); + } } }); return tree; @@ -246,7 +250,7 @@ export class FancyTreeComponent implements OnInit, AfterViewInit, OnDestroy { this.treeService.nextTreeStatus('loaded'); this.showTree = true; }); - if (_.get(this.editorService, 'editorConfig.config.renderTaxonomy') === true && _.isEmpty(_.get(this.nodes, 'data.children'))) { + if (_.get(this.editorService, 'editorConfig.config.renderTaxonomy') === true && _.isEmpty(_.get(this.nodes, 'data.children')) || _.get(this.editorService, 'editorConfig.config.renderTaxonomy') === true && !_.isEmpty(_.get(this.nodes, 'data.children')) && this.nodes.data.children[0]?.category ) { _.forEach(this.rootNode[0]?.children, (child) => { this.treeService.updateTreeNodeMetadata(child.metadata, child.id, child.primaryCategory, child.objectType); _.forEach(child.children, (el) => { @@ -633,4 +637,4 @@ export class FancyTreeComponent implements OnInit, AfterViewInit, OnDestroy { this.onComponentDestroy$.next(); this.onComponentDestroy$.complete(); } -} +} \ No newline at end of file diff --git a/projects/questionset-editor-library/src/lib/services/tree/tree.service.ts b/projects/questionset-editor-library/src/lib/services/tree/tree.service.ts index fdcee4f8..2be7292d 100755 --- a/projects/questionset-editor-library/src/lib/services/tree/tree.service.ts +++ b/projects/questionset-editor-library/src/lib/services/tree/tree.service.ts @@ -57,7 +57,7 @@ export class TreeService { const node = this.getFirstChild(); const nodeId = node.data.id; node.data.metadata = {...node.data.metadata, [key] : value}; - this.setTreeCache(nodeId, _.merge({}, {[key] : value}, _.pick(node.data.metadata, ['objectType']))); + this.setTreeCache(nodeId, _.merge({}, {[key] : value}, _.pick(node.data.metadata, ['objectType','entityType']))); } updateTreeNodeMetadata(newData: any, nodeToBeUpdated?: any, primaryCategory?: any, objectType?: any) { @@ -239,12 +239,12 @@ export class TreeService { setTreeCache(nodeId, metadata, activeNode?) { if (this.treeCache.nodesModified[nodeId]) { // tslint:disable-next-line:max-line-length - this.treeCache.nodesModified[nodeId].metadata = _.assign(this.treeCache.nodesModified[nodeId].metadata, _.omit(metadata, 'objectType')); + this.treeCache.nodesModified[nodeId].metadata = _.assign(this.treeCache.nodesModified[nodeId].metadata, _.omit(metadata, 'objectType','entityType')); } else { this.treeCache.nodesModified[nodeId] = { root: activeNode?.root ? true : false, objectType: metadata.objectType, - metadata: { ..._.omit(metadata, ['objectType']) }, + metadata: { ..._.omit(metadata, ['objectType','entityType','category']) }, ...(nodeId.includes('do_') ? { isNew: false } : { isNew: true }) }; this.treeCache.nodes.push(nodeId); // To track sequence of modifiation @@ -298,4 +298,4 @@ export class TreeService { this.getTreeObject().reload(nodes); $('span.fancytree-title').attr('style', 'width:15em;text-overflow:ellipsis;white-space:nowrap;overflow:hidden'); } -} +} \ No newline at end of file