Geb automation - two input field same name - geb

I appreciate if anyone can help me.
I have a form which separated by
*Mailing Address*
*Physical Address*
One has ID and one doesn't have. Example: Street
When I use only Mailing address street field and run script - it also insert on the Physical address street field.
I do not know how to get to the Parent DIV to separate Mailing and Physical address Street field. So it can input only in one street address
Any help appreciate.
$("input", id: "Street").value("780 woodland ave")
Mailing Address:
></fieldset><fieldset id="fieldset-mailing-list"><legend>Mailing List <a id="mailing-list" name="mailing-list"/></legend><div class="row-fluid"><div class="span12"><div class="control-group"><label for="mailName" class="control-label">In Care of Name</label><div class="controls"><input placeholder="" class="mailName span12" ng-model="Application.contactInformation.mailingAddress" id="mailName" type="text"/></div></div></div ></div><div class="row-fluid"><div class="span6"><div class="control-group"><label for="street" class="control-label">Street</label><div class="controls"><input ng-required="isRequired()" placeholder="Street Number and Name" class="required" ng-model="Application.contactInformation.mailingAddress.street" name="street" id="street" type="text"/><br/><span ng-show="application.street.$error.required" style="color:red">***a required field***<br/></span></div></div></div>
Physical Address:
></fieldset><fieldset id="fieldset-physical-mailing-list"><legend>Physical Address <a id="physical-mailing-list" name="physical-mailing-list"/></legend><div class="row-fluid"><div class="span12"><label class="checkbox"><input name="sameAddress" id="sameAddress" type="checkbox"/>
Physical Address same as mailing address.
</label></div></div><div class="row-fluid"><div class="span6"><div class="control-group"><label for="street" class="control-label">Street</label><div class="controls"><input placeholder="Street Number and Name" class="" ng-model="Application.contactInformation.physicalAddress.street" id="street" type="text"/></div></div></div>

To select the street input you can do:
$('input', name: 'street')
To select the error message you can say:
$('input', name: 'street').closest('div').find('span')
or:
$('input', name: 'street').parent().find('span')
or:
$('input', name: 'street').nextAll('span')

Related

vuejs different v-ifs from a previous select

I am trying to display two different divs according to a select options, but I am only getting the first v-if. When I select "de", I do get the first div content, but I also get it when I select fr, instead of the second div.
I can't get my head around this. Any ideas of what I am getting wrong?
This goes on inside a form:
<select v-model="source" :key="source">
<option :value="de">de</option>
<option :value="fr">fr</option>
</select><br><br>
<div class="characters">
<div v-if="source === de" class="deChars" :key="source">
<h5>Special German characters:</h5>
<li v-for="character in deChars" :key="character">{{ character }}</li>
</div>
<div v-else-if="source === fr" class="frChars" :key="source">
<h5>Special French characters:</h5>
<li v-for="character in frChars" :key="character">{{ character }}</li>
</div>
<br>
</div>
on the script section I am using the options api with the data property source=" ", and two arrays for deChars and frChars.
note: those :key="source" I added to make sure it gets read when the source value changes.
The data properties:
data(){
return {
original: "",
translation: "",
source: "",
target: "en",
deChars: ["ä", "Ä", "é", "ö", "Ö", "ü", "Ü", "ß"],
frChars: ["à", "â", "ç", "é", "è", "ê", "ë", "î", "ï", "ô", "û", "ü", "œ"]
}
},
Thank you so much!
Try to remove the binding sign since it seems that de and fr are not declared as properties and they're just raw string :
<select v-model="source" >
<option value="de">de</option>
<option value="fr">fr</option>
</select>
then do v-if="source === 'de'" and v-else-if="source === 'fr'"
It seems that the problem was with the select options. THe binding seemed to mess about. Once I got rid of that, it works perfectly. So thanks for that Boussadjra. However, if on the v-if I change the de and fr to strings, it does not work. WHich is why I am adding this comment as the solution.

ASP.NET Core MVC Group by query with LINQ

I am trying to query the country column from one of my table and trying to group them so that one country name appears only once.
The controller code is
ViewBag.Countries = (from pT in _context.InfoProducts
group pT by new { pT.Country } into g
select new
{
Country = g.Key.Country
}).ToList();
In my view I am trying to show this list of countries in a dropdown like this
<div class=" form-group">
#Html.Label("Country")
<div class="col-md-12 ">
#Html.DropDownList("Country", new SelectList(ViewBag.Countries, "Country"), "Select Country", new { #class = "col-form-label col-md-12 label-align" })
</div>
</div>
The problem I am facing is though it is returning the expected names of the countries, the result is generating as a key, value pair something like
{Country = USA}
{Country = Canada}
The HTML generated copied from inspect element is given below
<select class="col-form-label col-md-12 label-align" id="Country" name="Country">
<option value="">Select Country</option>
<option>{ Country = USA}</option>
<option>{ Country = Canada}</option>
</select>
How can I get only the country name in the dropdown instead of the result I am currently getting.
Rather than using group by, it sounds like distinct would be a better fit:
_context.InfoProducts.Select(x => x.Country).Distinct().ToList();
This will give you back a list of strings to use, which won't give you the key-value pair problem you're currently having.
One more thing, when you use new SelectList(ViewBag.Countries, "Country") this overload of SelectList's constructor will try to set the value of Country as the selected item, but this doesn't exist in your list, so Select Country will always appear as selected. If you want that to select an actual country, then it would have to look something like:
new SelectList(ViewBag.Countries, "Canada")
where you would fetch Canada from the data for the current product.

How do I get the value from sibling of selected option and pass it as value in inputfield autofill (VueJS)

Flow of my app:
user types a city
user select a country code in select
then submit
But the problem is that when someone types 'ams' instead of 'amsterdam' it will also output a list of responding country codes. If someone select one and then click on the submit button. It will give an error that the this.city is undefined. The reason for this is because the url that is fetched consists variables of this.city and this.country_code. Something looks like www.weatherbit.com/${this.city}=country${this.country_code} and that is the reason why it gives an error in this case. So in order to avoid that I want to get the autofill option if the this.city is not a valid city name. When someone clicks on country code 'NL' and the city name is undefined (not matching the entire city name) it will autofill the input field with that. In order to do so it needs to get the 'country.city_name' and pass it to v-model="city". How can I do that.
<select v-model="countryCode" #change="handleChange">
<option v-for="(country, index) in checkCountryName" :key="index" :value="country.country_code" :selected="index === 0">
{{ country.city_name}} // only this value should be output in input /// and should not be in option element
{{ country.country_code }} // only this should be shown in option if this is undefined
</option>
</select>
<input v-model="city" placeholder="Please enter your location...">
data () {
return {
city: '',
cityList: [],
countryCode: null,
errors: []
}
},
mounted () {
axios.get('https://gist.githubusercontent.com/chiholiu/9243c14cd7f310c0866947414496ad99/raw/8f97404080b3812477004793e2318552fc876aa2/cities.json')
.then(response => {
this.cityList = response.data
})
},
computed: {
checkCountryName () {
if(this.city.length < 1) return;
return this.cityList.filter((cityName) => {
return cityName.city_name.toLowerCase().match(this.city.toLowerCase())
})
}
},
There are few options to achieve this scenario.
Option 1: Enter full city name
Instead of match, find the city the user typed is fully matching the city_name. This will give you the full city name when you call the api.
Option 2: Change the input value
Once the user typed the half word like ams and select a country, at handleChange event in select, you can set the city_name to city like
methods: {
handleChange(e) {
this.city = e.target.value.city_name
}
}

Odoo Qweb show for contact

I am currently working on Odoo (v8) template and want to show contact person name only for customer. What currently works is:
<span t-field="o.partner_id.child_ids" t-field-options='{"widget": "contact", "fields": [ "name"], "no_marker": true}' />
the output is:
Cathirine,Tak
My question is: How can I write to show only contact name as:
Tak
You can do
class SaleOrder(models.Model):
_inherit = 'sale.order'
contact_id = fields.Many2one('res.partner', 'Contact',
domain="[('parent_id','=',partner_id)]")
Then call
<strong>Dear: <span t-field="o.contact_id.name"/></strong><br/>

Input form name and surname with first letter uppercase

I have the code:
<input required="required" type="text" class="inp" name="nume" size="30" style="text-align: center" placeholder="Introdu aici numele tău">
The user will introduce his name on a tablet and I want the name and surname introduced in the field to be with first letters Uppercase. Is that possible? I searched but nothing solid so far.
Cheers and thank you!
I am not sure to have understood your question, do you want to force user to introduce names with the first capital uppercase?
const convertName = function (name) {
return name
.split(' ')
.map(
word =>
word.substr(0, 1).toUpperCase() +
word.substr(1, word.length).toLowerCase()
)
.join(' ');
};