Select,Unselect,Intermediate Checkbox treeview in *ngFor - angular5

As I mentioned above code i want category is my parent and when I'm select category checkbox it will select all it's child checkbox(items) .And when I select particular one child then category checkbox is intermediate. Same for the child and subchild is sizes.
Any solution for that?
<ul>
<li *ngFor="let category of menuitem">
<span><input type="checkbox
(change)="OnCheckboxSelect(category,$event)">
</span>
<span><a href="#{{category._id}}" data-toggle="collapse" >
{{category.category_name}}</a>
</span>
<ul id="{{category._id}}" class="collapse">
<li *ngFor="let item of category?.category_item">
<span><input type="checkbox"
(change)="OnItemSelect(item, $event)">
</span>
<span><a href="#{{item._id}}" data-toggle="collapse">
{{item.item_name}}</a>
</span>
<ul id="{{item._id}}" class="collapse">
<li *ngFor="let size of item?.item_size">
<span><input type="checkbox" name="">
</span>
<span>{{size.size_name}}
</span>
</li>
</ul>
</li>
</ul>
</li>
</ul>

Related

How do I toggle (hide/unhide) child elements of dynamically added components with v-for

The following renders a header text and some child elements.
What I would like to accomplish is that the child elements toggle (hide/unhide) when the header is clicked. So in below example, when Spanish01 is clicked, all its children should be hidden and when its clicked again the should reappear.
I tried to find a similar case on the internet but could not find any. All help is welcome
<div id="dashboard">
<ul class="collection with-header">
<li class="collection-header"><h4>Cards</h4></li>
<li v-for="card in cards" v-bind:key="card.id" class="collection-item">
<div class="chip">{{card.group_name}}</div>
<ul class="collection with-header">
<li v-for="(value, index) in card.group" v-bind:key="index" class="collection-item">
<ul>
<li>
front: {{value.front}}
</li>
<li>
back: {{value.back}}
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
You can simply put an extra variable on each of your cards. Then you can do something like this:
<div id="dashboard">
<ul class="collection with-header">
<li class="collection-header"><h4>Cards</h4></li>
<li v-for="card in cards" v-bind:key="card.id" class="collection-item">
<div class="chip" #click="card.shown = !card.shown>{{card.group_name}}</div>
<ul class="collection with-header" v-show="card.shown">
<li v-for="(value, index) in card.group" v-bind:key="index" class="collection-item">
<ul>
<li>
front: {{value.front}}
</li>
<li>
back: {{value.back}}
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
Obviously, you have to alter your variable cards so it contains the shown attribute by default. As an alternative, you can set up a different variable that contains the shown status and use some unique id to look up the value instead.

Bootstrap 3 nav menu is showing first 2 list items when responsive

I have searched high and low for the answer but to no avail. I have a sandbox website www.bluestackbrewing.com
When you resize it to mobile, the first two lists in the menu item are showing. Does anyone know how to fix this? Thank you for any response.
<div class="row nav-menu">
<div class="col-sm-3 col-md-2 columns">
</div>
<div class="col-sm-9 col-md-10 columns">
<ul class="menu navbar-collapse">
<li>Home
</li>
<li class="has-dropdown">Pronorm German Kitchens
<ul class="subnav">
<li>Y-LINE</li>
<li>X-LINE</li>
<li>PROLINE</li>
<li>CLASSICLINE</li>
</ul>
</li>
<li>BESPOKE KITCHENS
</li>
<li>STORAGE SOLUTIONS & ACCESSORIES
</li>
<li>Contact
</li>
</ul>
<ul class="social-icons text-right">
<li>
<a href="#">
<i class="icon social_twitter"></i>
</a>
</li>
<li>
<a href="#">
<i class="icon social_facebook"></i>
</a>
</li>
<li>
<a href="#">
<i class="icon social_instagram"></i>
</a>
</li>
</ul>
</div>

How do I conditionally add a class in aurelia template

I am looking at a way to add a class dynamically to aurelia template. I have to add an active class if the particular li is visible.
Example
<section id="jobsCategoryContainer" class="jobsCategoryContainer">
<h1>{{title}}</h1>
<div *ngFor = "#slide of jobCategorySlides; #i = index" id="job-category-slide_{{i}}" class="job-category-slide" [ngClass]="{active: initialCarouselIndex == i}">
<ul *ngFor = "#item of slide">
<li class="jobDetails" *ngFor="#job of item; #i = index">
<div>
<span id="{{job.name}}" class="jobName">{{ job.name }}</span>
</div>
<div>
<span>{{job.noOfJobs}}</span>
</div>
</li>
</ul>
</div>
<div>
Previous
Next
</div>
</section>
I want to add the active class on below code
<div class="phs-widget-body">
<div class="phs-carousel-inner">
<ul repeat.for = "slide of nearByJobSlides" class="phs-item phs-grid-row" >
<li repeat.for = "item of slide" class="phs-small-6">
<a href="javascript:void(0)">
<div class="phs-job-title">${item.title}</div>
<div class="phs-job-info">
<span class="phs-job-loacation">${item.location}</span>
<span class="phs-job-category">${item.category}</span>
</div>
</a>
</li>
</ul>
</div>
</div>
<div class="phs-widget-footer">
<a class="left" href="#phsNearbyJobs" role="button" data-slide="prev">
<i class="fa fa-angle-left"></i> Move to Previous
</a>
<ol class="phs-carousel-indicators">
<li repeat.for = "slide of nearByJobSlides" data-target="#phsNearbyJobs" data-slide-to="${$index}" class="" click.trigger="changeActiveClass()"></li>
</ol>
<a class="right" href="#phsNearbyJobs" role="button" data-slide="next">
Move to Next <i class="fa fa-angle-right"></i>
</a>
</div>
As well how do I pass an event Object on aurelia?
Just use interpolation
<div class="${ applyMyClass ? 'my-class' : '' }">
E.g.
<div class="${ carouselIndex == $index ? 'active' : '' }">
You don't need to do this with a click event, it's the same as ng2 (only less code!)

Protractor - Element is not clickable at point (968, 23)

I am writing testcase on logout functionality. When the code is executed it show element is notclickable at point.
element.all(by.css('.dropdown-user a')).then(function(items) {
items[0].click();
ptor.sleep(500);
});
view.html
<li class="dropdown dropdown-user">
<a href="#" class="dropdown-toggle" id="logout" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
<img alt="" class="img-circle" src="../../assets/admin/layout/img/avatar3_small.jpg"/>
<span class="username username-hide-on-mobile">
</span>
<i class="fa fa-angle-down"></i>
</a>
<ul class="dropdown-menu">
<li>
<i class="icon-user"></i> My Profile
</li>
<li>
<i class="icon-calendar"></i> My Calendar
</li>
<li>
<i class="icon-envelope-open"></i> My Inbox <span class="badge badge-danger">3 </span>
</li>
<li>
<i class="icon-rocket"></i> My Tasks <span class="badge badge-success">7 </span>
</li>
<li class="divider">
</li>
<li>
<i class="icon-lock"></i> Lock Screen
</li>
<li ng-click="logout()">
<i class="icon-key"></i> Log Out
</li>
</ul>
</li>
Is there any way to oprn this dropdown? Could you please let me know how to write the code to test it?
You can try the xpath way
//li[contains(#class, 'dropdown')]/ul[contains(#class, 'dropdown')].
I am not sure if this is what you are looking for

Finding element by ID is not working in protractor

When I use the find element by ID it is not working in my code.
--This is the HTML where the 4 tabs appears. Under each option there is nav option which has the id. Each of the 4 tabs also has ids. But identifying using those are not working.
HTML:
<nav id="monitoring-tab" class="pure-menu pure-menu-open pure-menu-horizontal ng-scope">
<ul>
<li id="now-tab" ui-sref-active="pure-menu-selected" ng-hide="hideTab.now" class="ng-hide">
<a ui-sref="app.monitoring.real-time" href="#/monitoring/real-time">
Now</a>
</li>
<li id="day-tab" ui-sref-active="pure-menu-selected" class="pure-menu-selected">
<a ui-sref="app.monitoring.historical.day" href="#/monitoring/historical/day">
Day</a>
</li>
<li id="month-tab" ui-sref-active="pure-menu-selected">
<a ui-sref="app.monitoring.historical.month" href="#/monitoring/historical/month">
Month</a>
</li>
<li id="year-tab" ui-sref-active="pure-menu-selected">
<a ui-sref="app.monitoring.historical.year" href="#/monitoring/historical/year">
Year</a>
</li>
<li id="lifetime-tab" ui-sref-active="pure-menu-selected">
<a ui-sref="app.monitoring.historical.lifetime" href="#/monitoring/historical/lifetime">
Lifetime</a>
</li>
</ul>
</nav>
<div id="date-range" ng-hide="stateName =='app.monitoring.historical.lifetime'" class="ng-scope">
<span>
<a id="historical-nav-prev" ui-sref="app.monitoring.historical.day({date:'2014-10-16'})" href="#/monitoring/historical/day?date=2014-10-16">
<i class="fa fa-chevron-left"></i>
</a>
</span>
<span class="ng-binding">Fri, Oct 17, 2014</span>
<span ng-show="historicalNav.nextDateBtnShown" class="ng-hide">
<a id="historical-nav-next" ui-sref="app.monitoring.historical.day({date:''})" href="#/monitoring/historical/day?date=">
<i class="fa fa-chevron-right"></i>
</a>
</span>
</div>
MyCode:
it('Should click on the previous day', function() {
element(by.id('historical-nav-prev')).click();
});
Error:
NoSuchElementError: No element found using locator: By.id("historical-nav-p
rev")
What is wrong here? Most of the id's I am using are not working.