archimatetool / archi-scripting-plugin

jArchi - Scripting for Archi: ArchiMate Modelling Tool
https://www.archimatetool.com
118 stars 33 forks source link

Feature request: find and manipulate existing Notes #90

Closed mwm-cbus closed 3 years ago

mwm-cbus commented 3 years ago

It looks like querying Notes is still a future idea, and I want to vote for it.

Right now (in 4.8.1) , I see Notes are not even part of the Model. I'm not terribly for or against that as a philosophical matter, but it's too bad that part of the jArchi api doesn't do anything as I very much want to be able to read Notes and pull their text or possibly change it. :-)

(Today my use case is that I am marking up Views in a new model with questions in Notes and then it would be very efficient to pull all the Note text to communicate the questions.)

Unless I'm missing something, the only way to query something with jArchi is if it is an item in the Model.

jbsarrodie commented 3 years ago

Hi, you can get notes as children of views, so if you want all notes in your model, simply build a collection with all view and then gets notes: $('archimate-diagram-model').find('diagram-model-note')

Phillipus commented 3 years ago

Unless I'm missing something, the only way to query something with jArchi is if it is an item in the Model.

No, that's not correct. See https://github.com/archimatetool/archi-scripting-plugin/wiki/jArchi-Collection#selectors for selectors including diagram-model-note

Could we either put Notes in the Model, or expose a new way to access them with jArchi?

As JB says, notes are accessible in a jArchi selector, and are child objects of either Views or other View objects, so they already are in the View model.

jbsarrodie commented 3 years ago

Unless I'm missing something, the only way to query something with jArchi is if it is an item in the Model.

I know why can lead to this conclusion: not all objects can be "extracted" with $(selector) (diagram-model-note can't).

That's why, for non ArchiMate concepts, you have to first query the view.

BTW, if you want to get notes, not only in archimate views but also sketch and canvas, then use $('view').find('diagram-model-note')

mwm-cbus commented 3 years ago

Ah, I see. Yes, I do see objects now with the nested selection, such as len = $("archimate-diagram-model").find("diagram-model-note").length; console.log(len); Thank you for taking the time to clarify that! . I might raise another issue/request separately after I look at it more later on today, which is do we have a selector such as "find()" or "children()" that works with a single item, such as a single view. Once we select a single item either by selecting initially with a name or id or by using "get()" or "first()", it seems no further functions are valid on that object.

Phillipus commented 3 years ago

I might raise another issue/request separately after I look at it more later on today, which is do we have a selector such as "find()" or "children()" that works with a single item, such as a single view. Once we select a single item either by selecting initially with a name or id or by using "get()" or "first()", it seems no further functions are valid on that object.

Those functions only work on a collection, so wrap the item in the $() collection wrapper like $(item).children() see https://github.com/archimatetool/archi-scripting-plugin/wiki/jArchi-Collection#selectors