how to use ngif with values chosen from the drop down list above? - material-design

What I want to achieve is that, if the user select the roles (multiselect) then the roles array includes superadmin, then I want to hide the element. The code I might use is
*ngIf="roles.include(x.name !=='superadmin')" but it doesn't work!.
What might be the solution for that?
<div
class="col-lg-6 kt-margin-bottom-20-mobile"
>
<mat-form-field
class="mat-form-field-fluid"
>
<mat-select
placeholder="Role"
formControlName="roles"
multiple
[(ngModel)]="checkedRoles"
>
<mat-option
*ngFor="
let role of userRoles"
[value]="role"
>
{{role.name}}
</mat-option>
</mat-select>
<mat-error
*ngIf="
isControlHasError(
'roles',
'required'
)
"
>
<strong>{{
"AUTH.VALIDATION.REQUIRED_FIELD"
| translate
}}</strong>
</mat-error>
</mat-form-field>
</div>
<!-- clientele starts -->
<div
class="col-lg-6 kt-margin-bottom-20-mobile"
*ngIf="roles.include(x.name !=='superadmin')"
>
<mat-form-field
class="mat-form-field-fluid"
>
<mat-select
matTooltip="if you are creating a user for admin or superadmin, leave it empty"
placeholder="Clientele"
formControlName="clientele"
[(ngModel)]="checkedClientele"
>
<mat-option
*ngFor="
let clientele of clienteles"
[value]="clientele"
>
{{ clientele.Name }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>

Related

display all the corresponding item values in dropdown based on another text field dropdown in django

Here In the modal pop up when i enter the Order number as 1307 it need to display the all the items of that order number
Here I am attaching the screenshot of my Items list that need to be displayed in my drop down when i enter the order number
Here in dropdown i need to see items(laptops, Note books,Samsung Note 3) When i give this order number
Here is my html code
<div class="modal-body">
<form class="form-horizontal" id="adhoc-form" method="GET">
{% csrf_token %}
<fieldset>
<div class="control-group">
<label class="control-label pull-left" for="capacity">Date</label>
<div class="controls">
<input name="date_manual" type="date">
</div>
</div>
<div class="control-group">
<label class="control-label pull-left" for="capacity">Process</label>
<div class="controls">
<select name="p_process">
<option value="">----------</option>
{% for process in production_process %}
<option value="{{process.id}}">{{process.name}}</option>
{% endfor %}
</select>
</div>
</div>
<div class="control-group">
<label class="control-label pull-left" for="capacity">Sales order</label>
<div class="controls">
<input name="order_number" type="text">
</div>
</div>
<div class="control-group">
<label class="control-label pull-left" for="capacity">Items</label>
<div class="controls">
<select name="item_part">
<option value="">-----</option>
</select>
</div>
</div>
</fieldset>
<div id="form-buttons-container" class="form-actions" style="padding-left: 0px;">
<div class="controls">
<input type="submit" class="btn btn-primary btn-medium" value="Submit">
</div>
</div>
</form>
</div>
In the above code i need to display those 3 items of this order in label - Items
Please help me out to write view and script

Trouble trying to store an image and store the information in the database table

I have set up a new form to allow someone to add a profile for who a user will manage.
Its a pretty simple form with 4 fields, name, avatar, sport and description
<form method="POST" action="{{ route('add') }}">
#csrf
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control #error('name') is-invalid #enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
#error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label class="col-md-4 col-form-label text-md-right"
for="avatar"
>
Avatar
</label>
<div class="col-md-6">
<input class="form-control #error('name') is-invalid #enderror" value="{{ old('name') }}"
type="file"
name="avatar"
id="avatar"
>
</div>
</div>
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Sport') }}</label>
<div class="col-md-6">
<select name="sport" id="sport" class="form-control #error('name') is-invalid #enderror" name="name" value="{{ old('name') }}">
<option value="Football">Football</option>
<option value="Cricket">Cricket</option>
<option value="Hockey">Hockey</option>
<option value="Basketball">Basketball</option>
</select>
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="description" class="col-md-4 col-form-label text-md-right">{{ __('Description') }}</label>
<div class="col-md-6">
<input id="description" type="textarea" class="form-control #error('description') is-invalid #enderror" name="description" required>
#error('description')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Save') }}
</button>
</div>
</div>
</form>
</div>
The controller I have added is as follows
public function create()
{
//dd(request());
$attributes = request()->validate([
'name' => 'required',
'avatar' => ['file'],
'sport' => 'required',
'description' => 'required'
]);
if (request('avatar'))
{
$attributes['avatar'] = request('avatar')->store('avatars');
}
Players::create([
'user_id' => auth()->id(),
'name' => $attributes['name'],
'avatar' => $attributes['avatar'],
'sport' => $attributes['sport'],
'description' => $attributes['description']
]);
return redirect('/home');
}
Every time I go to submit the form I get a 302 and it returns back to the add form.
If I hardcode a value for 'avatar' => $attributes['avatar'] it adds the record to the table fine, except for the file will not upload into the director.
I am working on my local machine.
Any help would be appreciated
As you can see from here, you need first to get the file form the request:
$attributes['avatar'] = $request->file('avatar')->store('avatars');
// ^^^^^^^^^^^^^^^^^ -- missing
It looks as if I hadnt set the right things up on the form.
Still have issues with storing the files but would like to try and resolve that myself so that I can learn by doing.
I appreciate everyone's help

Selenium with Angular - XPath how to get to elements when $index present?

Using Python 3.7 with Selenium on pages that include Angular, please advise how to best locate an element such as this:
<input type="radio" ng-model="section3.data.generalSection3.container[$index].lseCatTy" value="FEDERAL" ng-disabled="!section3.data.generalSection3.container[$index].editable" ng-class="classes('lseCatTy')" ng-change="section3.updateLseCatTy($index, section3.data.generalSection3.container[$index].lseCatTy)" class="ng-valid ng-not-empty ng-dirty ng-touched ng-valid-parse" name="759" style="">
or this
<button type="button" uib-tooltip="Edit" tooltip-placement="right" class="btn btn-primary" ng-click="section3.data.editContainer($index);" ng-disabled="editingDrilling1 || submissionTypeSR">
when it exists in blocks such as the following. What's tripping me up is the $index... The page has multiple fieldset tags and that number is DYNAMIC... For example, a user can add more of one type of the fieldset while editing the page- but only this one type.
<div ng-if="section3.data.generalSection3.srvyTyId != null && section3.data.generalSection3.srvyTyId != ''" class="ng-scope" style="">
<!-- ngRepeat: wellFeature in section3.data.generalSection3.container track by $index -->
<div ng-repeat="wellFeature in section3.data.generalSection3.container track by $index" class="ng-scope">
<!-- ngIf: section3.data.generalSection3.container[$index].deleteSegmentLocation == null -->
<fieldset class="legend-border ng-scope" ng-if="section3.data.generalSection3.container[$index].deleteSegmentLocation == null">
<legend/>
<div class="col-lg-12 panel panel-default">
<div class="row panel-heading ng-binding">
SHL <br>
<!-- ngIf: section3.data.generalSection3.container[$index].legBHLAttr == 'PPP' -->
<!-- ngIf: section3.data.generalSection3.container[$index].legBHLAttr != 'PPP' && section3.data.generalSection3.container[$index].legBHLAttr != 'SHL' -->
<!-- ngIf: section3.data.generalSection3.container[$index].legBHLAttr == 'SHL' -->
<div ng-if="section3.data.generalSection3.container[$index].legBHLAttr == 'SHL'" class="ng-scope"/>
<!-- end ngIf: section3.data.generalSection3.container[$index].legBHLAttr == 'SHL' -->
</div>
</div>
<div class="row">
<div class="col-lg-11">
<!-- ngIf: section3.data.generalSection3.srvyTyId=='1'|| section3.data.generalSection3.srvyTyId=='3' || section3.data.generalSection3.srvyTyId=='2' || section3.data.generalSection3.srvyTyId=='4' -->
<div ng-if="section3.data.generalSection3.srvyTyId=='1'|| section3.data.generalSection3.srvyTyId=='3' || section3.data.generalSection3.srvyTyId=='2' || section3.data.generalSection3.srvyTyId=='4'" style="padding-left: 15px; padding-right: 15px;" class="ng-scope">
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label class="required-field">Lease Type</label>
<br>
<div ng-class="classes('lseCatTy'+','+$index.toString(), [])">
<label class="radio-inline">
<input type="radio" ng-model="section3.data.generalSection3.container[$index].lseCatTy" value="FEDERAL" ng-disabled="!section3.data.generalSection3.container[$index].editable" ng-class="classes('lseCatTy')" ng-change="section3.updateLseCatTy($index, section3.data.generalSection3.container[$index].lseCatTy)" class="ng-valid ng-not-empty ng-dirty ng-touched ng-valid-parse" name="759" style=""> Federal
</label>
<label class="radio-inline">
What I have working is:
self.wait.until(EC.presence_of_element_located((By.XPATH, "//button[#ng-click='section3.data.editContainer($index);']"))).click()
And this gets the first instance of that button (in the top fieldset), but I don't know how to get an arbitrary instance of it.
driver.find_elements_by_css_selector('[ng-model*="$index"],[ng-click*="$index"]')
I learned to navigate the DOM using parent elements and finding elements within parent elements --
This became a matter of finding a unique parent (lines 1 and 2), then finding the edit button for that section (line 3), and finding the desired element (line 4).
shl_div = self.wait.until(EC.presence_of_element_located((By.XPATH, "//div[#class='row panel-heading ng-binding' and contains(text(),'SHL')]")))
shl_par = shl_div.find_element_by_xpath("..")
shl_par.find_element_by_xpath(".//button[#ng-click='section3.data.editContainer($index);']").click()
shl_par.find_element_by_xpath(".//input[#value='FEDERAL']").click()

Angular Material autocomplete with refresh button next to it

I have the following angular html component:
<div fxLayout fxLayout.xs="row" fxLayoutAlign="left" fxLayoutGap="5px" fxLayoutGap.xs="0">
<div flex class="item item-1" fxFlex="95%">
<mat-form-field class="large-field">
<input matInput placeholder="Full Name" aria-label="Full Name" [matAutocomplete]="auto" [formControl]="FullNameCtrl">
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="onSelected($event.option.value)">
<mat-option *ngFor="let data of filteredCompanyFullName | async" [value]="data">
<span>{{ data.FullName }}</span>
</mat-option>
</mat-autocomplete>
</mat-form-field>
</div>
<div flex class="item item-2" fxFlex="4%">
<button matTooltip="Refresh" mat-icon-button (click)="refresh()">
<mat-icon>refresh</mat-icon>
</button>
</div>
</div>
What above does is showing an auto complete drop-down plus a refresh button. I am struggling to style above html to show something like the following picture:
However it looks like the following which is not the desired output:
What should I change to achieve the first image? I want the input field to take 95% width of the row and a small refresh button right next to it aligned to the right.

Reveal modal failed to open Fondation 6

I'm trying to make a modal reveal for every Edit button just when i clicked onto the Edit button it doesnt open i did as mentionned onto the documentation for Foundation 6 .Here is my code.Please any help.
<ul class="button-group">
i give to every reveal modal an id based on the field id with that i would have
different ids and linked every Edit button with its modal
<li>
<a class="button tiny" data-open="editModal<?php echo $contact->id ;?>"
data-contact-id="<?php echo $contact->id;?>">Edit</a>
<!-- the modal edit start here -->
<div class="reveal large editmodal" id="editModal<?php echo $contact->id ;?>"
data-cid="<?php echo $contact->id ;?>" data-reveal>
<div class="grid-x grid-margin-x">
<div class="cell large-12"><h1>Edit Contact</h1></div>
</div>
form of the edit modal
<form action="#" id="editadress" method="post">
<div class="grid-x grid-margin-x">
<div class="cell large-6">
first name input field
<label>First Name
<input type="text" name="first_name" placeholder="Enter Your First Name"
value="<?php echo $contact->first_name; ?>">
</label>
</div>
<div class="cell large-6">
last name input field
<label>Last Name
<input type="text" name="last_name" value="<?php echo $contact->last_name; ?>"
placeholder="Enter Your Last Name">
</label>
</div>
</div>
submit button of the form
<div class="grid-x grid-margin-x">
<div class="cell large-12">
<input class="button big abutton right small" name="submit" type="submit" value="Submit"/>
</div>
</div>
</form>
close button of the modal
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<!--The modal edit ends here-->
</li>
<li>
<a class="button alert tiny">Delete</a>
</li>
</ul>

Resources