Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {
Expand All @@ -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 => {
Expand All @@ -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 : '';
Expand Down Expand Up @@ -1129,5 +1129,4 @@ export class EditorComponent implements OnInit, OnDestroy, AfterViewInit {
);
return response;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -633,4 +637,4 @@ export class FancyTreeComponent implements OnInit, AfterViewInit, OnDestroy {
this.onComponentDestroy$.next();
this.onComponentDestroy$.complete();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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');
}
}
}