How to get count from repeater inside repeater in protractor? - protractor

I want to count the repeater that is nested into another repeater in protractor
var t2 = element.all(by.css('.footable.table.table-stripped.default.footable-loaded > tbody tr')).each(function(element, index){
element.all(by.repeater("el in punchApproval| filter : filterEmpSearch | orderBy:'Emp_Code' track by $index ")).each(function(element, text){
element.all(by.repeater("yl in el.PunchReq_sub")).count().then(function(cnt){
console.log("Count rw:" +index +"rw desc"+text+"count"+cnt) ;
});
});

Store the list identified by the repeater attribute.It must have a unique name then
print it using console.log(list) .where list contains the elements in the repeater you're having .
let list = element.all(by.repeater('.items li'));

Related

Flutter how to add a List with keys and values to another (Master) list with keys and values where the keys "id" are same in the 2 lists

I have small issues combining 2 Lists:
Here is a snippet -
List booked = []; has 5 elements with 5 keys and values. This is the list of only booked rooms.
List combinedList = []; has 10 elements with 42 keys and values. The is the master list of all rooms.
Not all elements of combinedList are inside booked. But all elements of booked are inside combinedList. This is where it gets tricky.
I am trying to add the content of List booked = [] into List combinedList = [] so that I can use EndDate and checkOutTime from the List booked = [].
When I use the method below, the length of the List fetchRooms is 5 and not 10.
Any idea how I can achieve this results?
I tried this code:
if (booked.isNotEmpty) {
combinedList.forEach((e) {
booked.forEach((ele) {
if (e["roomNumber"] == ele["roomNumber"]) {
// if (e["id"] == ele["id"]) {
fetchRooms.add(getExtendedlist(
e["buildingEntranceUrl"].toString(),
e["roomUrl"].toString(),
e["description"].toString(),
e["address"].toString(),
e["Name"].toString(),
e["averageRating"].toString(),
e["roomNumber"].toString(),
e["endDateAndTime"].toString(),
e["startDateAndTime"].toString(),
e["Monthly"].toString(),
e["RegisteredDate"].toString(),
e["accessType"].toString(),
e["geopointlat"],
e["geopointlng"],
e["id"],
ele["EndDate"].toString(),
ele["checkOutTime"].toString(),
));
}
});
});
}
but it gives me only length of booked. I want to have length of combinedList with the fields ele["EndDate"].toString() and ele["checkOutTime"].toString() added where the ids are same and blank where they are not.

Repeat the columns using data-sly-repeat based on the number entered in the cq dialog. Columns are not repeating

I want to repeat the parsys in the columns based on the number of columns added in cq dialog. I can only get one column and the numbers of columns as entered
<div class="items">
<div data-sly-repeat="${grid.cols}" class="col col-lg-4 col-md-2 pt-2 pb-2">
<div data-sly-resource="${'content-{0}' # format=[colList.index], resourceType='wcm/foundation/components/parsys'}"></div>
</div>
</div>
</div>
carousel.js:
"use strict";
use(function() {
var properties = granite.properties,
colCount = properties.numberofcolumns ? properties.numberofcolumns : 3,
cols = '';
return {
"cols" : colCount
};
});
data-sly-repeat expects a list, not a number. You're only returning the number of columns. If you return an n-element list, data-sly-repeat will render an element for each item in the list.
It's a bit of a hack but in your carousel.js, you'd have to return an array with a list of values. The primary use case of data-sly-repeat (and data-sly-list) is to iterate over the elements of a collection returned by the underlying Java/JS code and output the properties of each item in the list. In your case, the only difference between the repeated div elements is the index.
use(function() {
var properties = granite.properties,
colCount = properties.numberofcolumns ? properties.numberofcolumns : 3;
var resultList = [];
for (var i = 0 ; i < colCount ; i++) {
resultList.push(i);
}
return {
"cols" : resultList // data-sly-repeat expects a collection
};
});
On a more general note, it seems what you're aiming to do is to include a bunch of paragraph systems by name to achieve some sort of column layout. Before attempting this, I would consider using the OOTB Layout Container component, which can be resized in Edit mode to fit any number of columns without any new development.

How to find an item [array] in a dart list

I have a list with with an array of Objects added with this code:
_selectedItems.add([color, size, type]);
Each time I update the quantity of an item I have to call a method to verify if the list already have that item (if yes, update the quantity. if not, add the item and the quantity). So I tried this code:
print(_selectedItems.contains([color, size, type])); // searching if this product is in the list
But it always return false. I tried too verify the id's of each Object, but it returns false too. What I have to do to be able to reach the goal?
You can use .indexWhere() to find an object in a list and return the index:
Item _objectToInsert = Item();
int index = _selectedItems.indexWhere((item) => item.color.contains(_objectToInsert.color));
If index is -1, the object isn't in the list, else index will be the position of the obect in the list. So you can do:
if (index == -1) // add
_selectedItems.add(_objectToInsert);
else // update
_objectToInsert[index].color = _objectToInsert.color;

How to add item or value in assigned list to var?

I tried many ways but couldn't get the solution.
// linq query to getting 3 fields from table
var listData = (from row in db.table
orderby row.No ascending
select new {
row.Id,
row.No,
row.Type
}).ToList();
I want to add item or value to listData.
try Code:
var listData = (from row in db.table
select new
{
Id= row.Id,
No= row.No,
Type= row.Type
}
).OrderBy(c=>c.No).ToList();

How to fetch a list inside a list using LINQ to Entities

I have a requirement where i need to display a list in jquery DATATABLE. one of the column in a row will have multiple items (list).
So, in Busines Logic while fetching the DB details i'm trying to fetch a list which has another list in a row.
listTest =
(from TestA in context.Business
join Status in context.BStatus
on TestA. BStatus_Id equals Status.ID
join Prior in context.Priority
on TestA.Prior_ID equals Prior.ID into PriorityDetails
from PrtryDT in PriorityDetails.DefaultIfEmpty()
select new PModel
{
Id = TestA.ID,
Name = TestA.NM,
PriorityEvaluatedOnTS = TestA.PRI_EVAL_ON_TS,
//RequestPriority = i need to write a linq here to fetch a list for RequestPriority
}).ToList();