Raphael SVG Map - Add class, id and select individual paths - svg

I've got an SVG map which draws up perfectly and I've got some (average) code that offers a mouseOver, onClick and mouseOut state. In my finished page, I need to be able to click on different countries on the map and display data relating to that country in a table below it. (data table entry omitted, I've got that bit running on a local server already).
http://jsfiddle.net/dE9cK/
I've taken a snippet of my raphael-map code here to show how I get my map up and running, the full code is in the jsfiddle above:
var rsr = Raphael('SVGmap', '679', '350');
var layer1 = rsr.set();
var path6251 = rsr.path("M-289.826-562.781c-2.617-0.95-3.363-1.923-2.737-3.568c0.506-1.331,2.102-1.962,2.102-0.831 c0,0.303,0.547,1.292,1.216,2.197C-286.882-561.785-286.9-561.718-289.826-562.781z").attr({id: 'path6251',fill: '#909155',label: 'Ebene 1',groupmode: 'layer',parent: 'layer1','stroke-width': '0','stroke-opacity': '1'}).transform("t470,892.401").data('id', 'path6251');
var rsrGroups = [layer1];
layer1.push(
path6251
);
What I need help with is to:
Add a unique ID/name to each path once it has been drawn up (to enable me to target each individual path for the data table - would prefer it if this was the current path name to make it easier to reference - I'm tidying up all path names once I've got this up and working).
Each path has a data id in my JS file but I can't seem to get that to pull through with the path.
Group paths together (I've got Alaska & USA as named paths in my fiddle, would like to know how I would group these two to both become selected/active when either is clicked).
Really appreciate any help anybody can give. Thank you.

You can use node property to get the element and set id to it like below
path6251.node.id = 'p6251';
Use set() method to group elements and perform operations on the set.
Sample code
var group1 = rsr.set();
group1.push(path1);
group1.push(path2);
group1.attr({fill: 'red'}); //will change color of both path1 and path2

Related

How can I manipulate the Audit screen (SM205510) through code

I'm trying to manipulate the Audit screen (SM205510) through code, using a graph object. The operation of the screen has processes that seem to work when a screen ID is selected in the header. This is my code to create a new record:
Using PX.Data;
Using PX.Objects.SM;
var am = PXGraph.CreateInstance<AUAuditMaintenance>();
AUAuditSetup auditsetup = new AUAuditSetup();
auditsetup.ScreenID = "GL301000";
auditsetup = am.Audit.Insert(auditsetup);
am.Actions.PressSave();
Now, when I execute the code above, it creates a record in the AUAuditSetup table just fine - but it doesn't automatically create the AUAuditTable records the way they are auto-generated in the screen (I realize that the records aren't in the database yet) - but how can I get the graph object to auto-generate the AUAuditTable records in the cache the way they are in the screen?
I've tried looking at the source code for the Audit screen - but it just shows blank, like there's nothing there. I look in the code repository in Visual Studio and I don't see any file for AUAuditMaintenance either, so I can't see any process that I could run in the graph object that would populate those AUAuditTable records.
Any help would be appreciated.
Thanks...
If I had such a need, to manipulate Audit screen records, I'd rather create my own graph and probably generate DAC class. Also I'd add one more column UsrIsArtificial and set it to false by default. And then manage them as ordinary records, but each time I'll add something, I'd set field UsrIsArtificial to false.
You can hardly find how that records are managed at graph level because that records are created and handled on on Graph level, but on framework level. Also think twice or even more about design, as direct writing into Audit history may cause confusion for users in the system of what was caused by user, and what was caused by your code. From that point of view I would rather add one more additional table, then add confusion to existing one.
Acumatica support provided this solution, which works beautifully (Hat tip!):
var screenID = "GL301000"; //"SO303000";
var g = PXGraph.CreateInstance<AUAuditMaintenance>();
//Set Header Current
g.Audit.Current = g.Audit.Search<AUAuditSetup.screenID>(screenID);
if (g.Audit.Current == null) //If no Current then insert
{
var header = new AUAuditSetup();
header.ScreenID = screenID;
header.Description = "Test Audit";
header = g.Audit.Insert(header);
}
foreach (AUAuditTable table in g.Tables.Select())
{
table.IsActive = true;
//Sets Current for Detail
g.Tables.Current = g.Tables.Update(table);
foreach (AUAuditField field in g.Fields.Select())
{
field.IsActive = false;
g.Fields.Update(field);
}
}
g.Actions.PressSave();

Navigating from Location to Workorder

I need to :
1. Create a single page location application
2. Display all the asset present in the selected location in a table
3. Provide a button from which user can navigate to WOTRACK to view all the workorder(s) created on selected location and its asset(s).
I am facing difficulty in the 3rd one. I have tried Launch in Context and it is working fine except am not able to pass sql query like 'location={location} and assetnum in ({asset.assetnum})'. I need to filter workorders with particular location and all its assets.
I tried to save all the assets in the location to a Non-persistant attribute and passing the values of the attribute in the Launch in context url, Its working as expected but to do so I have written a script on 'Initialize value' which is causing performance issues.
script goes like this:
from psdi.server import MXServer;
from psdi.mbo import MboConstants;
if app == "LOCATION1" :
if mbo.getString("LOCATION") is not None:
Locsite = mbo.getString("SITEID")
desc = mbo.getString("DESCRIPTION")
MaxuserSet = MXServer.getMXServer().getMboSet("MAXUSER", mbo.getUserInfo())
MaxuserSet.setWhere(" userid='"+user+"' ")
MaxuserSet.reset()
UserSite = MaxuserSet.getMbo(0).getString("DEFSITE")
if Locsite == UserSite:
AssetSet = mbo.getMboSet("ASSET")
AssetSet.setFlag(MboConstants.DISCARDABLE, True);
if not AssetSet.isEmpty():
AssetList = ""
AssetMbo = AssetSet.moveFirst()
while AssetMbo is not None:
AssetList = AssetList + str(AssetMbo.getString("ASSETNUM")) + "%2C"
AssetMbo = AssetSet.moveNext()
mbo.setValue("non-persitant",str(AssetList),11L)
and in the LIC url i have given : 'http://xx.x.x.xx/maximo/ui/?event=loadapp&value=wotrack&tabid=List&additionalevent=useqbe&additionaleventvalue=location={LOCATION}|assetnum={non-persistant}'
Is there any other feasible solution to the requirement?
Thanks in Advance
Launch In Context is better used for sending the user to an outside-of-Maximo application and passing along some data from inside-Maximo to provide context in that external app.
What you are doing sounds like a good place to use a workflow process with an Interaction node. The developer tells the Interaction node which app to take the user to and which Relationship to use to find the data the user should work with there.
Why don't you add a table control inside the table details (expanded table row) and show a list of the work orders there. From the WONUM in that table, you could have an app link to take them to WOTRACK, if they want more details about a particular work order. No customization (automation scripting) needed. No workflow needed. Nice and simple.

Add custom id to each path created using freedrawing

I want to know if it is possible to add a custom id to each path created using
canvas.isDrawingMode = true ;
I suppose it should be done if it is possible before the path is created. Is this possible with fabricjs?
thanks
you can use the event "path:created" on canvas.
canvas.on("path:created", function(opt){
opt.path.id = fabric.Object.__uid++
});
this will ensure you a unique id for every path.
fabric.Object.__uid is used to give ids to any element that needs to be referred later (shadows, patterns... )

Masking answer options in Confirmit (jscript)

I'm trying to mask the answer options that show up in a 3DGrid question item in Confirmit, using the value of a background variable.
E.g. when "background1" ==1, display answer category 1. If "background1" ==0, do not display answer category 1. If "background2" ==1, display category 3, otherwise do not. In any case, display answer category 2.
Hopefully this is easy for someone out there (I'm a psychologist, not a coder...so not so much so for me :/)
Thanks!
In order to access the data inside a question/variable we can use the f function of confirmit.
for instance:
f('my_question_id').get();
When masking a question, we need to pass in a Set object so Confirmit knows what Code's to show and not to show.
Often you will mask using a Set from a previous question. So you pass in the question_id and Confirmit does all the other magic.
Here we have the problem of not having a Set, so we will have to create our own.
For this, there are 2 approaches (can be found in the scripting manual under Working with Sets > Methods of the set Object > add and remove and Working with Sets > User defined functions...)
I'm going to stick to the first one because it is easier to use ;)
What we will do first is create a script node (it doesn't matter where you create it, just somewhere in the survey, I often have a folder Functions with all my script nodes in somewhere at the bottom of my survey)
In that script file we will have our function that crates our set:
function CreateMyAwesomeSet()
{
//create an empty Set
var mySet = new Set();
//if background1 equals 1, add 1 to our Set
if ( f('background1').get() == '1' )
{
mySet.add(1);
}
//return the Set of allowed Codes
return mySet;
}
Here we declare a function that we now can use wherever we want to.
So now, If we want to use this Set, we add a Code Mask to your grid:
CreateMyAwesomeSet()
You can ofcourse change the name of the function, and add extra if statements.
hope this helps

How To Obtain All the Nodes and Connections After Launching the GMF Project

After launching the GMF project, I get a new window to make my own model.
After placing some nodes and connections, I should calculate according to their attributes. At first, HOW can I obtain all the information of every node and every connection?
First , let's get the relevant editor:
DomainDiagramEditor d= (DomainDiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
Now, you can either get all the editparts in your diagram , getting the relevant model from them:
final List children = d.getDiagramEditPart().getChildren();
gets you a list of EditParts.
Or, you can get the model objects directly with:
EObject element = d.getDiagram().getElement();
EList<EObject> eContents_ = element.eContents();
That gives you a list of all the model objects in the active editor.
Hope that answers your question

Resources