Reset igx-select - drop-down-menu

Since I could not find any information, I am writing here.
How can I reset a selected value of igx-select using typescript:
Here is my HTML-Code:
<igx-select #selectDepartment
placeholder="Wähle Abteilung"
[overlaySettings]="overlaySettings"
[ngClass]="[cell.row.deleted?'upfont' : 'drop-down-grid']"
[(ngModel)]="cell.value">
<igx-select-item style="font-size: 12px;" *ngFor="let item of arrayDepartments" [value]="item">
{{ item }}
</igx-select-item>
</igx-select>
Is there any way to delete the value of the cell and show the placeholder when for example a button is clicked?

You can use the clearSelection method exposed by the IgxSelectComponent.
<igx-select #selectDepartment
placeholder="Wähle Abteilung"
[overlaySettings]="overlaySettings"
[ngClass]="[cell.row.deleted?'upfont' : 'drop-down-grid']"
[(ngModel)]="cell.value">
<igx-select-item style="font-size: 12px;" *ngFor="let item of arrayDepartments" [value]="item">
{{ item }}
</igx-select-item>
</igx-select>
<button igxButton (click)="reset(selectDepartment)">Reset</button>
public reset(select: IgxSelectComponent) {
select.clearSelection();
}
Here's a stackblitz example.

Related

how to get filtered collection backpack laravel

I have a button that needs to pass a filtered collection from a table. Now when I click on the button, I get the entire collection
my button
$this->crud->addButtonFromView('top', 'withdrawDebtCompany', 'withdraw_debt', 'end');
button view
<form action="{{ url($crud->route.'/withdrawAllCompanyDebt') }}" method="POST">
<button class="btn btn-warning" data-style="zoom-in">
<span class="ladda-label">
{{ trans('columns.debt.allwithdraw') }}
</span>
</button>
{{ csrf_field() }}
</form>
method
public function withdrawDebtCompany()
{
$bills = $this->crud->query->get();
Bill::tryWithdrawalsIncrement($bills);
$res['success'] = 0;
$res['err'] = 0;
$bills->each(function($bill) use(&$res){
$paym = new PaymentsController();
$result = $paym->payDebt(new Request([
'bill_id'=>$bill->id,
]));
if($result['code'] == 0) {
$res['success'] += 1;
} else {
$res['err'] += 1;
}
});
\Alert::add('warning', 'Успешно списано: '.$res['success'].' | Неуспешно списано: '. $res['err'])->flash();
return redirect()->back();
}
I tried tracking the filtered collection in the button method, but that doesn't work. This is where the whole collection comes in. Filtered collection only comes after page reload
Hope to find you well.
In your <form> element you don't have any input to be POSTed, so I am wondering, why using a form there and not an <a> or similar.
I would advise you to have a look at the ListOperation https://github.com/Laravel-Backpack/CRUD/blob/main/src/app/Http/Controllers/Operations/ListOperation.php
There you will find the search endpoint that is used by datatables to get it's data.
You can apply a similar solution in your button endpoint to get the filtered results like in table.
Cheers

Quasar2 Vue3 Cypress slide toggle status mismatch with what is shown on Cypress browser

My vue template:
<template>
<q-item tag="label" v-ripple>
<q-item-section>
<q-item-label class="text-mono">
{{ name }}
</q-item-label>
<q-item-label caption>{{ description }}</q-item-label>
<q-item-label
caption
class="text-red"
v-show="warning"
:key="warning"
v-for="warning in warnings"
>
{{ warning }}
</q-item-label>
<q-item-label caption class="text-red" v-show="warningMsg">
{{ warningMsg }}
</q-item-label>
</q-item-section>
<q-item-section avatar>
<q-toggle
color="indigo"
v-model="model"
:disable="isToggleDisabled"
#triggerFunc="btnToggleTrigger"
/>
</q-item-section>
</q-item>
</template>
I have the following cypress E2E test code snippet:
it('Verify Toggle Button from auto-generated page', () => {
cy.get('[data-test="toggle-setting-0"]').should("not.be.checked");
cy.get('[data-test="toggle-setting-0"]').click();
cy.get('[data-test="toggle-setting-0"]').should("be.checked"); // XXX
});
The status validation fails AFTER the click(). However, cypress browser UI shows that the slider button is clicked. The error message:
Timed out retrying after 4000ms: expected '<label.q-item.q-item-type.row.no-wrap.q-item--clickable.q-link.cursor-pointer.q-focusable.q-hoverable>' to be 'checked'
What do I miss?
The <input> is within the element that has the data-test attribute.
You can verify the state by one of the inner element's class.
Does not seem ideal to me, but it works.
cy.get('[data-test="toggle-setting-0"]')
.find('.q-toggle__inner')
.should('have.class', 'q-toggle__inner--falsy')
cy.get('[data-test="toggle-setting-0"]')
.find('input')
.check({force: true});
cy.get('[data-test="toggle-setting-0"]')
.find('.q-toggle__inner')
.should('have.class', 'q-toggle__inner--truthy')
Ideally, you would check the value of the v-model variable.
I can see that the value of aria-checked is changing for the toggle. So you can so like this:
//For toggle off
cy.get('[data-test="toggle-setting-0"]').should(
'have.attr',
'aria-checked',
'false'
)
//For toggle on
cy.get('[data-test="toggle-setting-0"]').should(
'have.attr',
'aria-checked',
'true'
)

Laravel dynamic routing for search

I would like to generate dynamic route when user clicks on Search button.
I know it can be done with following GET method
https://laravel.dev/search?q=parameter
https://laravel.dev/search?state=XYZ&category=Automobile
But instead I would like to do following
https://laravel.dev/search/state/XYZ/category/Automobile
So if I add an extra parameter in search form it will just add onto the URL.
The parameters may be optional so can not add a fix route in routes. User may supply state or search through all states.
https://laravel.dev/search/category/Automobile
Following is my search form code
<div class="jumbotron">
<!--Search Bar-->
{{ html()->form('GET',route('frontend.search'))->class('form-inline justify-content-center')->open() }}
{{ html()->select('category',$categories)->class('form-control mr-sm-2') }}
{{ html()->select('state',$states)->class('form-control mr-sm-2') }}
<!--More filter to add later-->
<button class="btn btn-outline-primary my-2 my-sm-0" type="submit">Search</button>
{{ html()->form()->close() }}
</div>
How can I achieve that?
Thank you
You can handle the logic with a catch-all route with regular expressions
https://laravel.com/docs/7.x/routing#parameters-regular-expression-constraints
//routes.php
Route::get('search/{search?}', 'SearchController#search')
->where('search', '(.*)');
//controller
class SearchController extends BaseController {
public function search($search = null)
{
if ($search != null){
dd($search);
}
}
}
Try to use Regex:
Route::get('search/{searchParams}', 'SearchController#search')
->where('searchParams', '[a-zA-Z0-9\/]+');
You can put anything on searchParams but you need to parse it.

Multiple select dropdown in laravel

Here is my code in the view, I want to display a dropdown that contains the selected data in an edit view.
{{Form::select('Select_targets[]', $_targets,Input::old('Select_target', $profile->Target_idTarget-1), array('multiple' => true))}}
I tried this code but it just displays one selected value. Please I need your help!
Thanks in advance
I think you have an error around your old input and default values for the dropdown. Here is a stripped down example that does work:
Controller:
//current selected
$target = 3;
/array with options
$targets[1] = 'target 1';
$targets[2] = 'target 2';
$targets[3] = 'target 3';
return View::make('form')->with('targets',$targets)->with('target',$target);
View:
{{ Form::open() }}
{{ Form::select('targets[]', $targets, Request::old('targets') ? Request::old('targets') : $target, array('multiple' => true)); }}
{{ Form::submit('send') }}
{{ Form::close() }}
use wherein method of laravel incase you want to take all the option as query from request

Dropdownlist in a edit.blade.php form

please how can I put dropdown list in an edit form with the old selected value on default?
here is my example:
<div class="form-group">
{{ Form::label('Container', 'Container:') }}
{{ Form::select('Select_cont', $containers) }}
</div>
I don´t know where to put the code of the old new value selected in my view and what should it be.
Please don´t forget that when directing to edit.blade.php I wrote thisin the function of my controller
return View::make('audio.edit',array($container))
->with('containers', $containers)
thanks a lot for your help :)
Selected value is the 3rd param of Form::select, so:
{{ Form::select('Select_cont', $containers, $selectedPreviouslyKey) }}
How to get that key depends on your code and what's in the dropdown
Pass it to the view like this
return View::make('audio.edit',array('containers' => $containers, 'selectedPreviouslyKey' => $selectedKey));
or use compact() / with etc
The View::make call isn't entirely right. It should be:
return View::make('audio.edit')->with('containers', $containers);
or
return View::make('audio.edit')->withContainers($containers);
or
return View::make('audio.edit', array('containers' => $containers));
or
return View::make('audio.edit', compact('containers'));
Also: make sure $containers exists.
The documentation on the select tag. http://laravel.com/docs/html#drop-down-lists

Resources