Skip to content

Commit

Permalink
Strip away library name from Canvas element in MetaEditor when librar…
Browse files Browse the repository at this point in the history
…y viewed (#1793)

Co-authored-by: Patrik Meijer <patrik.meijer@vanderbilt.edu>
  • Loading branch information
pmeijer and Patrik Meijer committed Mar 20, 2024
1 parent 8af9c31 commit 1d2b748
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,13 @@ define([
newName = '';

if (nodeObj) {
// newName = nodeObj.getAttribute(nodePropertyNames.Attributes.name) || '';
newName = nodeObj.getFullyQualifiedName();

if (this._metaInfo.selectedLibrary) {
// Trim selected library plus additional dot.
newName = newName.substring(this._metaInfo.selectedLibrary.length + 1);
}

if (this.name !== newName) {
this.name = newName;
this._refreshName();
Expand Down
9 changes: 7 additions & 2 deletions src/client/js/Panels/MetaEditor/MetaEditorControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ define(['js/logger',

objDesc.decoratorClass = decClass;
objDesc.control = this;
objDesc.metaInfo = {};
objDesc.metaInfo = { selectedLibrary: this._selectedLibrary };
objDesc.metaInfo[CONSTANTS.GME_ID] = gmeID;
//each meta specific registry customization will be stored in the MetaContainer node's main META SET
// (MetaEditorConstants.META_ASPECT_SET_NAME)
Expand Down Expand Up @@ -2105,8 +2105,13 @@ define(['js/logger',
len = metaAspectSheetsRegistry.length;
for (i = 0; i < len; i += 1) {
setName = metaAspectSheetsRegistry[i].SetID;
const { title } = metaAspectSheetsRegistry[i];
const tabInfo = {
title,
backgroundText: this._selectedLibrary ? `${this._selectedLibrary }.${title}` : title
};

sheetID = this.diagramDesigner.addTab(metaAspectSheetsRegistry[i].title, true, true);
sheetID = this.diagramDesigner.addTab(tabInfo, true, true);

this._sheets[sheetID] = setName;
this._tabIdxToTitle[sheetID] = metaAspectSheetsRegistry[i].title;
Expand Down
7 changes: 6 additions & 1 deletion src/client/js/Panels/ModelEditor/ModelEditorControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,12 @@ define(['js/logger',
this.designerCanvas.addMultipleTabsBegin();

for (i = 0; i < aspects.length; i += 1) {
tabID = this.designerCanvas.addTab(aspects[i]);
const tabInfo = {
title: aspects[i],
backgroundText: this._selectedLibrary ? `${this._selectedLibrary}.${aspects[i]}` : aspects[i]
};

tabID = this.designerCanvas.addTab(tabInfo);

this._aspects[tabID] = aspects[i];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,26 @@ define([
li.find('a').append(deleteBtn);
};

DiagramDesignerWidgetTabs.prototype.addTab = function (title, deletable, renamable) {
DiagramDesignerWidgetTabs.prototype.addTab = function (titleOrDesc, deletable, renamable) {
var self = this,
li = TAB_LI_BASE.clone();

let title = '';
let backgroundText = '';

if (typeof titleOrDesc === 'string') {
title = titleOrDesc;
} else {
title = titleOrDesc.title;
backgroundText = titleOrDesc.backgroundText;
}

li.find('.tab-title').attr('title', title).text(title);

if (backgroundText) {
li.find('.tab-title').data('backgroundText', backgroundText);
}

li.data(TAB_ID, this._tabCounter + '');
this._tabCounter += 1;

Expand Down Expand Up @@ -268,9 +283,10 @@ define([
liToSelect.addClass('active');
liToSelect.find('.delete-tab-btn').removeClass('hidden');
this._selectedTab = liToSelect.data(TAB_ID);
const activeTabTitleEl = this.$ulTabTab.find('li.active').first().find('.tab-title');
const backgroundText = activeTabTitleEl.data('backgroundText') || activeTabTitleEl.text();

this.setBackgroundText(this.$ulTabTab.find('li.active').first().find('.tab-title').text()
.toUpperCase());
this.setBackgroundText(backgroundText.toUpperCase());
}

//select in DropDown
Expand Down

0 comments on commit 1d2b748

Please sign in to comment.