How to select multiple checkboxes in Dusk test - laravel

I am using VueJS with bootstrap-vue, and using Laravel Dusk, I need to test a table inside a modal that uses a checkbox to select each row. In this particular case, there are multiple rows with checkboxes, and I need to select all of the checkboxes in the form and then submit the form. My test works fine with the modal in every way except checking the checkboxes; no matter what I try, I can't get the check() (or click()) method to check more than the first one. I've tried
->check("input[type=checkbox]")
and using the name
->check("input[name='my-custom-name']")
but I still only get the first item checked. Based on this, I tried something like
$checkboxes = $browser->driver->findElements(WebDriverBy::name('my-custom-name[]'));
for ($i = 0; $i <= count($checkboxes); $i++) {
$checkboxes[0]->click();
}
but even that only checks the first checkbox. What do I need to do to select all of the checkboxes in the table?

The answer was to first, add a custom dusk selector to the checkbox using the row index:
<template #cell(selected)="row">
<b-form-checkbox
v-model="row.item.check"
#input="rowCheckboxClick($event, row.index, row.item)"
plain
:dusk="'my-custom-selector-' + row.index"
>
</b-form-checkbox>
</template>
and second, use the selector within the test.
->whenAvailable(new PursuitModelRestoreDeletedModal(), function(Browser $browser) {
$browser->waitForText('Click on the checkbox in the Select column')
->assertSee('My Modal Title')
->check('#my-custom-selector-0')
->check('#my-custom-selector-1')
->check('#my-custom-selector-2')
->check('#my-custom-selector-3')
->click('#ok-button');
})
Yes, the code could probably be a little cleaner with a loop instead of having each selector listed separately, but this works.

Related

How to get selected records under bulk edit functionality

I am working on 2016 on-premise MSCRM, I need to check each record in bulk edit and alert the user if something is wrong, I tried to alert it from my update plugin but only general msg appeared, now I'm trying to get all records selected in bulk edit, I googled and found this code :
var formType = Xrm.Page.ui.getFormType();
if (formType == 6)
{
//Read ids from dialog arguments
var records = window.dialogArguments;
}
}
To use the bulk edit formtype I need to add to event onload or onchange on customizations.xml the attribute : BehaviorInBulkEditForm=“Enabled“ (unfortunately not so safe to edit this file) .
My questions:
which selected rows I'll get in onload and onchange event? ,I'm not sure where to use it in that case and if I'll get all the data I need.
Is there a better way/easy to get the data I need or to get the formtype - bulk edit.
Soon I'll be using MSCRM 365 is there any easier solution to this case in the 9.0 version ?
You can use method window.getDialogArguments(); to get ids.
Here is my example:
I added an onLoad event for my form and enabled the BehaviorInBulkEditForm.
function onLoad(formContext) {
var ids = window.getDialogArguments();
console.log(ids);
}
The ids is an array, every element is a selected record id.
['{335A56B7-C717-ED11-B83F-00224856D931}', '{CBBDEBFB-C717-ED11-B83F-00224856D931}', '{3607EFC7-C717-ED11-B83F-00224856D931}', '{325A56B7-C717-ED11-B83F-00224856D931}']

Bootgrid hide column in jquery

Greeting, I would like to ask a question about the bootgrid jquery.
After I tried to understand the documentation of the bootgrid, I know that hiding a column are able to do in the column setting, <th data-visible="false">sampleID<th>, but I want to do this function inside jquery because I have a condition for displaying some column.
For example, I have three columns which is 'A','B','C'. So when the Listing value is 'A', the column B and column C will be set to data-visible = "false":
$('#Listing'.val()) == "a"
{
$('#B').attr("data-visible","false");
$('#C').attr("data-visible", "false");
}
So I have tried the code above but it not work. Please suggest me a solution or method.
Is it possible if I set the data-visible using the jquery?

Oracle APEX - I need help to setup dynamic search filter on IG report

I have an IG region where I disabled the toolbar and created my custom search item.
I want user to be able to type the first three characters of a name on the search item (named P8_SEARCH) and the IG report will only show the name(s) that starts with those 3 characters.
This should happen without clicking any button. The IG report query is shown below:
select member_id, first_name, last_name , address, dob, home_phone, cell_phone,
email_address from member_profile where first_name like '%'||:P8_SEARCH||'%';
I also created dynamic action with key release event and True action Execute JavaScript Code shown below:
var keyPressCount=0;
$("#P8_SEARCH").on("keypress", () => {
if (keyPressCount < 2) {
keyPressCount++;
} else {
$s("P8_SEARCH", apex.item( "P8_SEARCH" ).getValue());
}
})
How can I achieve this without submitting the page? I will appreciate any suggestion. Example:
Set an static_id for your IG region, in the dynamic action add apex.region("yourStaticId").refresh();to your JS code, this will refresh only the region.
something like this:
var keyPressCount=0;
$("#P8_SEARCH").on("keypress", () => {
if (keyPressCount < 2) {
keyPressCount++;
} else {
$s("P8_SEARCH", apex.item( "P8_SEARCH" ).getValue());
apex.region("yourStaticId").refresh();
}
})
If the search items are stored in an associated table, my idea is that you could associate a PL/SQL expression to execute using a Process. This process could be executed on a custom action.
Another idea is that you associate the dynamic action with a hidden button press, and make the JavaScript code click on the button. Then, you can 'simulate' the existence of a trigger for your dynamic action with key release event
What do you think?

Vuetify v-data-table change a row color for a few seconds

We've just moved over from bootstrap to Vuetify, but i'm struggling with something.
We have some updates sent (over signalR) that update a list of jobs, i'd like to be able to target a job that has been changed and change the row color for that particular job for a few seconds so the operator can see its changed.
Has anyone any pointers on how we can do this on a Vuetify v-data-table
Thanks
I ran into the same problem. This solution is a bit crude and a bit too late, but may help someone else.
In this example I change the colour of the row permanently until the page reloads. The problem with a temporary highlight is that if the table is sorted there is no way to put the row in the visible part of the table - v-data-table will put it where it belongs in the sort, even if it's out of the view.
Collect the list of IDs on initial load.
Store the list inside data of the component.
Use a dynamic :class attribute to highlight rows if the ID is not in the list (added or edited rows)
Solution in detail
1. Use TR in the items template to add a conditional class.
<template slot="items" slot-scope="props">
<tr :class="newRecordClass(props.item.email, 'success')">
<td class="text-xs-center" >{{ props.item.email }}</td>
:class="newRecordClass(props.item.email, 'success')" will call custom method newRecordClass with the email as an ID of the row.
2. Add an additional array to store IDs in your data to store
data: {
hydrated: false,
originalEmails: [], <--- ID = email in my case
3. Populate the list of IDs on initial data load
update(data) {
data.hydrated = true; // data loaded flag
let dataCombined = Object.assign(this.data, data); // copy response data into the instance
if (dataCombined.originalEmails.length == 0 ) {
// collect all emails on the first load
dataCombined.originalEmails = dataCombined.listDeviceUsers.items.map( item => item.email)
}
return dataCombined;
}
Now the instance data.originalEmails has the list of IDs loaded initially. Any new additions won't be there.
4. Add a method to check if the ID is in the list
newRecordClass(email, cssClass) {
// Returns a class name for rows that were added after the initial load of the table
if (email == "" || this.data.originalEmails.length==0) return "" // initial loading of the table - no data yet
if (this.data.originalEmails.indexOf(email) < 0 ) return cssClass
}
:class="newRecordClass(..." binds class attribute on TR to newRecordClass method and is being called every time the table is updated. A better way of doing the check would be via a computed property (https://v2.vuejs.org/v2/guide/computed.html#Computed-Properties). Vue would only call it when the underlying data changed - a method is called every time regardless.
Removing the highlight
You can modify newRecordClass method to update the list of IDs with new IDs after a delay to change the colour to normal.
#bakersoft - Did you find a solution? I suspect there is an easier way to skin this cat.

What is the way to do it with Vuejs

I have a page with 3 combos, 6 dependents inputs text ( if a special value is selected in combo, it will show, otherwise it will hide)
Then, I will have A text fields that is a computed property. Each time an input is changed, it will reevaluate this field value.
So, For instance, My fields are:
GradeIni, GradeFin, Category, AgeCategory, AgeIni, AgeFin , Gender (selects)
isTeam ( Checkbox )
CategoryFullName
So, for example, There is 5 predefines AgeCategory,and the 6th is Custom, when Selected, it show AgeIni and AgeFin
Each time a value is change, CategoryFullName is reevaluated.
My first answered question was how to get values from server.
I knew how to do it with Ajax, but in this case, it was easier to just use Server variable sent by Laravel when pages load.
So, the answer was 2 options:
#foreach ($grades as $grade)
<option ...>{{ $grade }}</option>
#endforeach
Or
<grades :grades="{{ $grades }}"></grades>
So, I would like to use the second one, but it means I have to create a component for each Select Option in my page, which seems a little heavy.
So, I'm a little bit confused about how should I make this page. Is it better by AJAX, is it better to be able to get data from laravel, and o make a component for each list, or is there a better way to do it????
You dont need to use many components. One component and one variable to keep the selected grade are fine.
You can create a component template to display all the grades.
I have created one template with dummy data to show you how you can do it.
<template id="grades-list">
Curently selected: Title {{selected.title}} Value: {{selected.value}}
<select v-model="selected">
<option v-for="grade in grades" :value="grade">{{grade.title}}</option>
</select>
</template>
The component should be registered like this:
Vue.component('grades', {
props: ['grades', 'selected'],
template: '#grades-list'
})
The tricky part is how you will select a default value and keep it synced with the parent. To do so, you can use .sync
<!-- you can use :grades="{{ grades }}" with Blade too-->
<grades :grades="grades" :selected.sync="selectedGrade"></grades>
To set default value you can update the selectedGrade variable when the document is ready, using vm.$set.
new Vue({
el: 'body',
data: {
'selectedGrade': ''
},
ready() {
this.$set('selectedGrade', this.grades[1])
}
})
I have created an example with dummy data here.

Resources