Clarity Tree View - Programatically Routing to Nodes - vmware-clarity

I have a Tree View that is build dynamically based on a REST call. The full taxonomy is delivered initially, though we may implement lazy loading later.
Does anyone have an example of the following or at least a suggestion on where to begin for the following use cases:
I need to route into the tree for a specific node. If the url is .../node2/child3/child5, I need the tree to open to those 3 levels and automatically select that Child5 node item.
If opening the tree without routing, have the tree auto-expand the first level and select the first root node.
The Tree that I have build thus far looks like this:
<clr-tree-node *ngIf="taxonomy">
<ng-template #recursiveTree let-taxonomy>
<clr-tree-node *ngFor="let child of taxonomy">
<button (click)="openFile(child, null)" class="clr-treenode-link">
{{child.en_name}}
</button>
<ng-template [clrIfExpanded]="false" *ngIf="child.children?.length > 0">
<ng-container *ngTemplateOutlet="recursiveTree; context:{ $implicit: child.children }"></ng-container>
</ng-template>
</clr-tree-node>
</ng-template>
<ng-container *ngTemplateOutlet="recursiveTree; context:{ $implicit: taxonomy }"></ng-container>
</clr-tree-node>

This is very specialized to your dataset, so in general the issue you need to resolve is knowing which of the clrIfExpanded directives should be set to true. You've got it hard coded to false in the example above. I'd suggest you use a property on the tree itself (like node.expanded) to store the expanded state, set to false by default.
Then, you'd have to inspect the route and params, load your data, parse the tree yourself and change the node.expanded property to true to expand. So to update your example:
<clr-tree-node *ngIf="taxonomy">
<ng-template #recursiveTree let-taxonomy>
<clr-tree-node *ngFor="let child of taxonomy">
<button (click)="openFile(child, null)" class="clr-treenode-link">
{{child.en_name}}
</button>
<ng-template [clrIfExpanded]="child.expanded" *ngIf="child.children?.length > 0">
<ng-container *ngTemplateOutlet="recursiveTree; context:{ $implicit: child.children }"></ng-container>
</ng-template>
</clr-tree-node>
</ng-template>
<ng-container *ngTemplateOutlet="recursiveTree; context:{ $implicit: taxonomy }"></ng-container>
</clr-tree-node>
Then you would have to parse the data structure after it loads from the API, compare the route params against it, and toggle the child.expanded properties for any parts of the route.

Related

How do you select this text above the HTML table using XPath?

Below is the HTML I'm working with. I've removed some lines that aren't relevant to this question, such as the content within the table.
My objective is to capture the names, and the corresponding information found within the table. Each Name/Table combination would be one row.
<div class="row">
<div class="col-sm-4 col-md-4">
<span class="LIST_TITLE">
Contact Person
</span>
</div>
<div class="col-sm-6-left" style="display: table-cell;">
Name A
<table>
</table>
Name B
<table>
</table>
</div>
</div>
I currently have this XPath '//div[#class="row"]/div/span[#class="LIST_TITLE"][contains(text(),"Contact Person")]/ancestor::div/div[#class="col-sm-6-left"]/table', which I am able to loop over to extract out the information in the table.
My issue is how to capture the name for each table, which I am finding difficult as they're both contained within the same tag.
I have tried using './ancestor::div[1]/text()', though this will capture both names.
Any help is greatly appreciated
preceding-sibling::text()[1] will return the text node prior to the context node. If the table elements are used as the context node, that will return you the following text nodes:
Name A
and
Name B
NB I don't know what web scraping tool you are using, but I know that some of them have XPath APIs that won't return text nodes; only elements. If that's the case for you, you might need to switch to a different XPath API that is capable of returning text nodes, e.g. lxml https://lxml.de/xpathxslt.html#xpath

Hide Forget Password button on Amplify Authenticator

I've successfully disabled the signup form setting this piece of code
<amplify-authenticator [hideSignUp]="true">
<ng-template amplifySlot="authenticated" let-user="user" let-signOut="signOut">
<router-outlet></router-outlet>
</ng-template>
</amplify-authenticator>
But now I wish to hide the Forgot Password button... is there a simple way?
You can add an empty slot for the sign-in-footer to hide the forgot password button.
<amplify-authenticator [hideSignUp]="true">
<ng-template amplifySlot="sign-in-footer">
<div></div>
</ng-template>
<ng-template amplifySlot="authenticated" let-user="user" let-signOut="signOut">
<router-outlet></router-outlet>
</ng-template>
</amplify-authenticator>
Basically, you can customize the header and footer of each form. You can read more about it here.

accessing index of items in list using robot framework on react components

I have some experience with the robot framework but none with react however I have a react component that I need to test.
I would like to access the index of items in a list but cannot seem to see all of the items.
<div class="Select-value">
<span class="Select-value-label" role="option" aria-selected="true" id="react-select-10--
value-
item">Item1</span>
</div>
<div class="Select-input">
<input aria-activedescendant="react-select-10--value" aria-
expanded="false" aria-haspopup="false" aria-owns="" class="Select-input" role="combobox"
value="">
</div>
How can obtain the index of each item from the input list? Usually in non react I see a very straight forward list with the chosen item identified.
Looking inside the element I can see the index of each item by hovering over it:
<input aria-activedescendant="react-select-22--option-5" aria-
expanded="true" aria-haspopup="true" aria-owns="react-select-22--list"
class="Select-input" role="combobox" value="">
I plan to create a for loop that starts on the 1st item and cycles through them all.
You can try to use Get Web Elements with selector //input[#class='Select-input'] and then iterate on them.
Here is an example:
#{my_list}= Get Web Elements xpath=//input[#class='Select-input']
FOR ${element} IN #{my_list}
Log to Console ${element}
END
the react component has has a hidden element that was only accessible once the dropdown menu was open:
[#class="Select-menu-outer"] was revealed after submitting a click to the dropdown menu itself.

My *ngIf statement has problems

I am trying to list all data from my firebase database where the logged in facebook user's email address is the same as the email found in the database:
The following code is not working, lots of formatting issues, no idea how should i rewrite this
<ng-container *ngFor="let item of fogasadatok; let i = index">
<ion-card *ngIf="{{item.useremail}}=={{navParams.data.facebookemail}}">
<img src="{{item.keplink}}"/>
<ion-card-content>
<ion-card-title>
{{item.datum}} - Ponty
</ion-card-title>
<p>
Egyéb:
</p>
</ion-card-content>
</ion-card>
You do not need interpolation ({{}}) for structural directives like *ngFor or *ngIf. Interpolation is only needed when you want to bind to a value that needs to be stringified for rendering in the DOM (like item.keplink). The expression for your *ngIf should look as follows:
*ngIf="item.useremail === navParams.data.facebookemail"

Handlebars block helper "if" doesn't work

I'm making a movie search based on data I'm getting from rotten tomatoes api. I'm using handlebars.js. So far I've got this template and it works just fine.
<div class="info">
<h3>{{title}}</h3>
<span> Year: {{year}} </span>
<span> Studio:{{studio}} </span>
<span> Synopsis:{{synopsis}} <span>
</div>
However, some of of movies don't have a studio provided so I'd like to make that in this case no "Studio:" would be printed. This is my code to do so:
{{#if studio}}
<span> Studio:{{studio}} </span>
{{/if}}
I've copied it from example provided on handebars.js page. Still it doesn't work. Could anyone explain me what I'm missing? I suppose there is no need to use Handlebars.registerHelper since I'm using this simple if statement. Or is it?
see this jsFiddle. You should not have any issue with that.
From documentation.
You can use the if helper to conditionally render a block. If its
argument returns false, undefined, null, "" or [] (a "falsy" value),
Handlebars will not render the block.
So check your 'studio' value.
Code that i have fiddled.
HTML:
<p>{{name1}}</p>
{{#if name2}}
<p>{{name2}}</p>
{{/if}}
<p>End</p>
js:
this.$el.html(temp({name1: 'stack'}));

Resources