Angular 2 Template Form - angular-ui-router

I have a template-driven Login form and below/outside my form there is a button for "forgot password".
Whenever I click on the "forgot password" button, it first validates my form then at the next click, it navigates.
{{'userNameRequired' | translate}}
{{'userName should between 8-15 letters and contain alphabet, digits and special character like _ , -, . ' | translate}}
{{'passwordRequired' | translate}}
{{'Password must be of a Capital Letter, alphabets and special character like # and _' | translate}}
{{'login' | translate}}
<p style="text-align: center; ">
<a [routerLink]="/forgotpassword">Forgot Password</a>
</p>

Related

Group select options if description is the same

So I have a select that the options are froma laravel Foreach
#foreach($courseMonth as $cm)->groupBy('description');
<optgroup label="{{ nameMonth($cm->month) }}">
#foreach($days as $date)
#if(date('m', strtotime($date['date'])) == $cm->month)
<option value="{{ date('d/m/Y', strtotime($date['date'])) ." - ". $date['hours'] }}">{{ $date['description'] . ' - ' . date('d/m/Y', strtotime($date['date'])) . ' - ' . $date['hours'] . ' ('. $date['total'] . 'h)'}}</option>
#endif
#endforeach
</optgroup>
<?php $i++;?>
#endforeach
This is the options. And I want if $date['description'] is the same in two options, to combine both options. More detailed, if three options have their description as "Work", to combine all of the options.
I've tried a groupby in front of the foreach
#foreach($courseMonth as $cm)->groupBy('description');
But this didn't do anything. The table for the options only has one row (ex: One row has only one description but it can have multiple day options in the select) so I need to group those only when there is the same description in two options.
Table structure:
-----------------------------------------------
| id | description | date | hours | total |
|---------------------------------------------|
| 4 | work |2019-23-4 | 14h | 6h |
| 5 | work |2019-23-5 | 13h | 5h |
| 6 | school |2019-23-5 | 13h | 5h |
-----------------------------------------------
So the first two would appear in the same option and the last one as the second option of the select.

Laravel blade template not rendering table properly

I'm quite new to Laravel, but have recently taken over a project from someone and trying to get the mail blade templates to render but I am having problems.
The code used for the enquiry email template is as follows:
#component('mail::message')
#New customer enquiry
We have received a new customer enquiry.
#component('mail::table')
| **Name** | **Email** | **Telephone** |
| ---------------------------------------------- |:---------------------:| -----------------------:|
| {{$enquiry->firstname}} {{$enquiry->lastname}} | <{{$enquiry->email}}> | {{$enquiry->telephone}} |
#endcomponent
Thanks,<br>
{{ config('app.name') }}
#endcomponent
But the table always renders as raw HTML, here is a screenshot of how the email looks in MailCatcher:
I've checked a couple of other posts that concern this kind of issue but usually it's due to the attempt to render more than one table in a mail template, but this is just a single table. Is there a component I have missed or is it just MailCatcher not rendering correctly?
When using Markdown to render emails, avoid using indents excessively. Your code should look like this
#component('mail::message')
#New customer enquiry
We have received a new customer enquiry.
#component('mail::table')
| **Name** | **Email** | **Telephone** |
| ---------------------------------------------- |:---------------------:| -----------------------:|
| {{$enquiry->firstname}} {{$enquiry->lastname}} | <{{$enquiry->email}}> | {{$enquiry->telephone}} |
#endcomponent
Thanks,<br>
{{ config('app.name') }}
#endcomponent
You didn't show how the html which is not being rendered is being loaded.
But it's possible you need to use {!! !!} instead of {{ }} for the variables that contain html.

How to merge(group) xpath results

I Have following table
<table>
<tbody>
<tr>
<td>First Row | First Column</td>
<td>First Row | Second Column</td>
</tr>
<tr>
<td>Second Row | First Column</td>
<td>Second Row | Second Column</td>
</tr>
<tr>
<td>Third Row | First Column</td>
<td>Third Row | Second Column</td>
</tr>
<tr>
<td>Forth Row | First Column</td>
<td>Forth Row | Second Column</td>
</tr>
<tr>
<td>Fifth Row | First Column</td>
<td>Fifth Row | Second Column</td>
</tr>
<tr>
<td>Sixth Row | First Column</td>
<td>Sixth Row | Second Column</td>
</tr>
</tbody>
I need to use xpath expresion to receive grouped 3 records:
First Row | Second Column, Second Row | Second Column
Third Row | Second Column, Forth Row | Second Column
Fifth Row | Second Column, Sixth Row | Second Column
How I can achive that using only xpath 1.0?
Here you go, xpath expression:
concat(//tr[1]/td[2], ' , ', //tr[2]/td[2], codepoints-to-string(10), //tr[3]/td[2], ' , ', //tr[4]/td[2], codepoints-to-string(10), //tr[5]/td[2], ' , ', //tr[6]/td[2])
The above will return the following string:
First Row | Second Column , Second Row | Second Column
Third Row | Second Column , Forth Row | Second Column
Fifth Row | Second Column , Sixth Row | Second Column

How to prevent CKEditor from changing tag order

CKEditor transforms the following code :
<h3>H3
<ul>
<li>el 1</li>
<li>el 2</li>
</ul></h3>
to
<h3>H3 </h3>
<ul>
<li>el 1</li>
<li>el 2</li>
</ul>
Is there a way to prevent this behavior?
TL;DR; no
CKEditor is an HTML4/xHTML editor and is based on DTD, which gives a complete set of rules regarding which tags are available and where/how they can appear inside the DOM.
If you will check the DTD you can see that H3 is a heading tag (which is a block) that can have only inline tags inside.
<!ENTITY % heading "h1|h2|h3|h4|h5|h6">
....
<!ENTITY % block
"p | %heading; | div | %lists; | %blocktext; | isindex |fieldset | table">
....
<!ELEMENT h3 %Inline;>
<!ATTLIST h3
%attrs;
%TextAlign;
>
The ul tag is also a block tag, so it can't appear inside h3 tag:
<!ENTITY % lists "ul | ol | dl | menu | dir">
....
<!ENTITY % block
"p | %heading; | div | %lists; | %blocktext; | isindex |fieldset | table">

Cucumber capybara fill_in failing

I've been building a rails4 app and running through testing with cucumber and capybara but have hit a snag. I'm doing standard testing for user creation and user edit.
The user create test ran through without any issue but upon running through the test for editing the user I can't get capybara to actually fill in the new values into the fields. The form is the same for new and edit (I am including the same _form partial to both) and again it works fine on new but not edit.
Cucumber New User test:
When I fill in a User with:
| First Name | Rufus |
| Last Name | Firefly |
| Email | rfirefly#fake.com |
| Role(S) | System Admin |
Cucumber Edit User test:
When I fill in a User with:
| First Name | Otis |
| Last Name | Driftwood |
| Email | otis#fake.com |
Corresponding method:
When /^(?:|I) fill in (?:a|an|the) (.+) with:$/ do |obj, fields|
attrs = {}
fields.rows_hash.each do |name, value|
fill_in(name, with: value) unless name =~ /\((?:R|S)\)$/
choose(value) if name =~ /\(R\)$/
select(value) if name =~ /\(S\)$/
end
end
Rendered html form:
<form accept-charset="UTF-8" action="/members/1" class="edit_user" id="edit_user_1" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="_method" type="hidden" value="put" /></div><div class='field'>
<label for="user_first_name">First Name</label>
<input id="user_first_name" name="user[first_name]" type="text" value="Ronald" />
</div>
<div class='field'>
<label for="user_last_name">Last Name</label>
<input id="user_last_name" name="user[last_name]" type="text" value="Kornblow" />
</div>
<div class='field'>
<label for="user_email">Email</label>
<input id="user_email" name="user[email]" type="email" value="kornblow#fake.com" />
</div>
<div class='field'>
<label for="user_password">Password</label>
<input id="user_password" name="user[password]" type="password" />
</div>
... omitted fields (not required) ...
<input name="commit" type="submit" value="Update User" />
</form>
Any help or insight anyone could give me I would greatly appreciate it.
Thanks in advance
In your code you have:
When /^(?:|I) fill in (?:a|an|the) (.+) with:$/ do |obj, fields|
attrs = {}
fields.rows_hash.each do |name, value|
fill_in(name, with: value) unless name =~ /\((?:R|S)\)$/
choose(value) if name =~ /\(R\)$/
select(value) if name =~ /\(S\)$/
end
end
here, the fill_in(name, :value) method normally automatically looks for the ID tag id=name, but here your names don't line up exactly as shown by your rendered HTML form.
<div class='field'>
<label for="user_last_name">Last Name</label>
<input id="user_last_name" name="user[last_name]" type="text" value="Kornblow" />
</div>
Try changing your cucumber test to:
When I fill in a User with:
| user_first_name | Otis |
| user_last_name | Driftwood |
| user_email | otis#fake.com |
Hope this helps
So I did find the issue and I'm not happy about the last hour and a half that I lost due to what I believe was the problem...
I was using a nice little debugging tool for capybara to render the page and show it in the browser and this was not displaying the updated fields like I said above, but when i ran click_button() these values were in fact being saved.
The issue I was really having was that Devise, in all its infinite wisdom, was saving the new email address to unconfirmed_email and keeping the old email until the user gets the email and confirms. Makes sense but it was the first time I apparently ran into this.
So in my test:
Given a "User" was updated with:
| Last Name | Driftwood |
| Email | otis#fake.com |
the email attribute really wasn't 'otis#fake.com' and the test, as it always is (no matter how much I argue with it) was right. This user was not updated in with that email. Changing this to:
Given a "User" was updated with:
| Last Name | Driftwood |
| Email | kornblow#fake.com |
| Unconfirmed Email | otis#fake.com |
Solved the problem. I'm still confused why I was not seeing the fill(ed)_in() values when I rendered the page out tho. Kinda led me barking up the wrong tree.
Oh well...
Thanks for your help and hope this helps others...

Resources