Archi Forum

Archi Plug-ins => jArchi => Topic started by: Alberto on November 04, 2021, 16:38:43 PM

Title: Finding if a View is embedded in another View?
Post by: Alberto on November 04, 2021, 16:38:43 PM
The advantage of having a View within another View is that it allows the viewer to navigate the model, both within Archi and in within the HTML report.  Now I'm finding myself looking how to trace what Views are embedded into what other Views, so I'm missing the Analysis and Visualizer tools that we have for Elements, but for the View itself.

So, since is not in the Archi UI, I figured I could do it with jArchi, "Find Current View in other Views"
but can't quite figure out how to do it so any help would be appreciated.
Title: Re: Finding if a View is embedded in another View?
Post by: Jean-Baptiste Sarrodie on November 04, 2021, 20:22:39 PM
Hi,

Here's a way to do it:
var currentView = selection.first();
console.log('Looking for view "' + currentView.name + '" with id "' + currentView.id + '"');

$('view').find('diagram-model-reference').each(function(o) {
  if(o.refView.id == currentView.id) {
    console.log('Found in view "' + o.view.name + '"');
  }
})

Regards,

JB
Title: Re: Finding if a View is embedded in another View?
Post by: Phil Beauvoir on November 04, 2021, 20:24:12 PM
Damn JB! I was just typing this when you ninja'd me:

$("view").find("diagram-model-reference").forEach(ref => {
    console.log(ref);
});

 ;D
Title: Re: Finding if a View is embedded in another View?
Post by: Jean-Baptiste Sarrodie on November 04, 2021, 20:30:22 PM
QuoteDamn JB! I was just typing this when you ninja'd me:

$("view").find("diagram-model-reference").forEach(ref => {
    console.log(ref);
});

 ;D

And in the meantime I even figured out to fix some typos on our wiki (https://github.com/archimatetool/archi-scripting-plugin/wiki/jArchi-Object#refView)  ;D
Title: Re: Finding if a View is embedded in another View?
Post by: Alberto on November 04, 2021, 20:52:11 PM
Thank you both!  This is perfect for what I needed it.

BTW, I also noticed that I cannot add Views to the filter in the model tree.