I been working on wizard . I been stuck in a tricky situation i.e
By default i am getting PREVIOUS , NEXT , FINISH . But i want to customize my wizard which having 4 stages .
on stage 1 & 2 : next & save button
stage 3 : send for approval
stage 4 : approve or reject
So for 4 stages i created 4 DIV's like this similarly
#using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
<div id="step-1">
<h2 class="StepTitle">Step 1: Account Details</h2>
<table cellspacing="3" cellpadding="3" align="center">
<td align="center" colspan="3"> </td>
<tr>
<td align="right"> #Html.LabelFor(m=>m.Lead_Id) </td>
<td align="left">
: #Html.TextBoxFor(model=>model.Lead_Id , new { #readonly="readonly" } )
</td>
</tr>
<tr>
<td align="right"> #Html.LabelFor(m=>m.Contact_Name) </td>
<td align="left">
: #Html.TextBoxFor(model=>model.Contact_Name )
</td>
</tr>
<tr>
<td align="right"> #Html.LabelFor(m=>m.Contact_Address</td>
<td align="left">
: #Html.TextBoxFor(model => model.Contact_Address)
</td>
</tr>
<tr>
<td align="right"> #Html.LabelFor(m=>m.Lead_Source)</td>
<td align="left">
: #Html.DropDownListFor(c=>c.Lead_Source, Model.lead_sources)
</td>
</tr>
<tr>
<td> <input type="submit" value="SAVE" id="btnsave" /></td> // on click it does postback call to controller which saves my data accordingly . fine with that
<td><input type="button" onclick="donno()" value="NEXT STAGE" id="btnNext"</td> // Issue is here and what i need is onclick of button need to move to second stage of wizard so i been thinking to write a logic on click method of button ?
</tr>
</table>
</div>
}
I donno HOW ? Is it possible to call the next stage i.e next DIV of stage-2 to show up on-click.
Is there is any work around to bind DIV to the button . so on click of button that section of DIV should load in step2 of wizard .
Any better ideas are welcome and efforts are always appreciated .
Thanks & Regards
If you are trying to go through the steps of your wizard, you need some mechanism to do this. You have two options:
Use a jQuery wizard to handle everything client-side (you are talking about your <div>, so jQuery could "step" through each one"). Check this link out for a popular example: jQuery Wizard.
Although in the above you would use an MVC controller (or two if you use a partial view to display the "confirmation" or "submitted" page), another way to do this is using multiple controllers, one for each step, and then using TempData to keep user input data through the steps until you get to the end. Check this link out for an example: TempData Wizard.
You might get heated opinions about the use of TempData. I used the jQuery example before, but found it to be too cumbersome. I went the TempData route for simplicity (I hate LONG view or code pages, they tend to be hard to maintain).
Your mileage may vary, and ultimately it is up to you to decide what works best in your situation. Good luck.
Edit
Just also found a new (MVC5) link for using Session: Session Wizard. TempData is a form of Session, however, TempData is used for redirects in controllers, and unless you specifically "Keep" the TempData it is destroyed after the redirect. Both are not very secure, so just be aware of that (I believe in a secure application you can certainly use authentication (user or role based).
Related
I am a developer but new to Prestashop (not really familiar with template because i am not a web developer but getting there..) but just helping my friend manage his website.
I checked the current version is 1.5.6 and am trying to add a new fieled in Product table and add another description input area in the following page.
I had a look at Product.php (classes > product.php), AdminProductsController.php (controllers > admin > adminproductscontroller.php) and Products.tpl (themes > uhu023v15 > products.tpl) but none of them seemed relevant to me. Not sure which files I need to modify. Please help.
You need go to
adminXXXX/themes/default/template/controllers/products/informations.tpl
because this is backend template (product.tpl is frontend template and what customer see when view product)
there You will find
<tr>
<td class="col-left">
{include file="controllers/products/multishop/checkbox.tpl" field="description_short" type="tinymce" multilang="true"}
<label>{l s='Short description:'}<br /></label>
<p class="product_description">({l s='Appears in the product list(s), and on the top of the product page.'})</p>
</td>
<td style="padding-bottom:5px;">
{include file="controllers/products/textarea_lang.tpl"
languages=$languages
input_name='description_short'
input_value=$product->description_short
max=$PS_PRODUCT_SHORT_DESC_LIMIT}
<p class="clear"></p>
</td>
</tr>
<tr>
<td>
**Your HERE** ;)
</td>
</tr>
<tr>
<td class="col-left">
{include file="controllers/products/multishop/checkbox.tpl" field="description" type="tinymce" multilang="true"}
<label>{l s='Description:'}<br /></label>
<p class="product_description">({l s='Appears in the body of the product page'})</p>
</td>
<td style="padding-bottom:5px;">
{include file="controllers/products/textarea_lang.tpl" languages=$languages
input_name='description'
input_value=$product->description
}
<p class="clear"></p>
</td>
</tr>
From there You need to duplicate whole textarea block and find and duplicate according functions (not sure where)
I'm using the scaffold generator of phalcon
it generates table, below is an example of the generated code:
<table>
<tr>
<td align="right">
<label for="id_media">Id Of Media</label>
</td>
<td align="left">
{{ text_field("id_media", "type" : "numeric") }}
</td>
</tr>
<tr>
...
</table>
My question is how to customize the generating process to have a form, with divs instead of a table.
That's possible by modifying the following, depending on your need
Modify the views' files in phalcon-tools/templates/scaffold/no-forms/views
Modify the scaffold.php in /phalcon-tools/scripts/Phalcon/Builder/Scaffold.php
Regards
Im having difficulties parameterizing (data driven) checkboxes using Selenium IDE. When I record selecting a checkbox using Selenium i get the following action:
<tr>
<td>click</td>
<td>id=_ctl0_MainContentPlaceHolder_UseCaseBesturing__ctl1_dgOndersteundeChannels__ctl2_chkbxChannel</td>
<td></td>
In order to parameterize this action and pointing to my test data (XML) file I need a value which I can set as a variable. But in this action there is no value, only a target which is the ID.
Any ideas how to parameterize this action or how to check the checkbox using a value instead of using only the target (ID)?
P.S. Text fields work fine by putting "${Parametername}" in value field in Selenium for an action. The Parametername will then be my column name in my test data file.
Html code of the checkboxes:
<table class="detailgrid" cellspacing="0" border="0" id="_ctl0_MainContentPlaceHolder_UseCaseBesturing__ctl1_dgOndersteundeChannels" style="border-style:None;border-collapse:collapse;">
<tbody><tr>
<td style="width:20px;">
<span disabled="disabled"><input id="_ctl0_MainContentPlaceHolder_UseCaseBesturing__ctl1_dgOndersteundeChannels__ctl2_chkbxChannel" type="checkbox" name="_ctl0:MainContentPlaceHolder:UseCaseBesturing:_ctl1:dgOndersteundeChannels:_ctl2:chkbxChannel" checked="checked" disabled="disabled"></span>
</td><td>
<span id="_ctl0_MainContentPlaceHolder_UseCaseBesturing__ctl1_dgOndersteundeChannels__ctl2_lblChannelNaam">POS</span>
</td>
</tr><tr>
<td style="width:20px;">
<input id="_ctl0_MainContentPlaceHolder_UseCaseBesturing__ctl1_dgOndersteundeChannels__ctl3_chkbxChannel" type="checkbox" name="_ctl0:MainContentPlaceHolder:UseCaseBesturing:_ctl1:dgOndersteundeChannels:_ctl3:chkbxChannel">
</td><td>
<span id="_ctl0_MainContentPlaceHolder_UseCaseBesturing__ctl1_dgOndersteundeChannels__ctl3_lblChannelNaam">eCommerce</span>
</td>
</tr><tr>
<td>
<br>
<span type="checkbox"><input id="_ctl0_MainContentPlaceHolder_UseCaseBesturing__ctl1_dgOndersteundeChannels__ctl4_chkalles1" type="checkbox" name="_ctl0:MainContentPlaceHolder:UseCaseBesturing:_ctl1:dgOndersteundeChannels:_ctl4:chkalles1" onclick="CheckAll('chkbxChannel', this.checked);"></span>
</td><td>
<br>
Alles Aan
</td>
</tr>
</tbody></table>
Still use a click but change how you find the target by using xpath.
It would look something like this:
Target:
xpath=//td/span[text()='POS']
Hope this helps!
After going through the question, I tried using parameter for Target in the test step( as it was not possible to parameterize Action(Command) after various attempts) in Selenium IDE.
To select a checkbox the Xpath should point to the input tag and can be checked using click command.
IMO, as per the HTML, the correct Xpath for checking the checkbox corresponding to eCommerce should be :
//span[text()='eCommerce']/ancestor::td/preceding-sibling::td/input
<div class="row">
<div class="row">
<table>
<tbody>
<tr>
<td class="list-text">
<div style="background-color: transparent;">Testing this function</div>
</td>
<td class="list-buttons" rowspan="2">
Config
<a class="edit-button" href="javascript:;">Edit</a>
<a class="save-button" href="javascript:;" style="display:none;">Save</a>
Delete
</td>
</tr>
<tr>
</tbody>
</table>
</div>
I need to find the element which contains the text "Testing this function" and click to link "Config".
Can't find a way to do it.
Edited: Found a way to do it:
By.xpath("//div[#class='row']/table/tbody/tr[td/div[contains(.,'Testing')]]/td[2]/a[contains(.,'Config')]")
But maybe someone has a better solution for this?
If you have to use text, my preference would be;
By.xpath("//div[contains(text(),'Testing')]]//a[contains(text(),'Config')]") .
I prefer using "text()" to "." just for readability. Apologies if "." is actually a better approach which I wasn't aware of.
Also unless you have a specific reason, I would avoid using tightly coupled xpath. E.g. I have not used " td[2]", instead I have said the"a" can be anywhere within in the "div"
tl;dr Displaying a view in MVC with lots of records and 4 rendered links per record takes a long time to load while running in debug mode in VS2012.
I have an ASP.NET MVC4 web application and one of the views displays a table of 300 records. Whenever I run the application in debug mode in VS2012, it takes nearly 2 minutes to load this view. The table has 4 unique links being generated either by HTML.ActionLink or URL.Action. From testing, I know the generation of these links is the offending code.
Example of slow code:
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
#foreach (var item in Model) {
<tr>
<td>Bob</td>
<td>
Tony
<div style="margin-top: 5px;">
<i class="icon-edit"></i>
<i class="icon-file"></i>
<i class="icon-trash"></i>
</div>
<div style="margin-top: 5px;">
#Html.ActionLink("Do Something", "SomeAction", "SomeController", new { id = item.Id }, new { #class = "btn btn-success btn-mini", data_pe_type = "auto" })
</div>
</td>
</tr>
}
</tbody>
If I modify the code and build the base part of the links outside the foreach, the time to load reduces to 15 seconds.
Example of faster code:
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
#{
var editLink = Url.Action("Edit", "Home") + "/";
var detailsLink = Url.Action("Details", "Home") + "/";
var deleteLink = Url.Action("Delete", "Home") + "/";
var saLink = Url.Action("SomeAction", "SomeController") + "/";
}
#foreach (var item in Model) {
<tr>
<td>Bob</td>
<td>
Tony
<div style="margin-top: 5px;">
<i class="icon-edit"></i>
<i class="icon-file"></i>
<i class="icon-trash"></i>
</div>
<div style="margin-top: 5px;">
Do Something
</div>
</td>
</tr>
}
</tbody>
I'm using IIS Express and have tested this in both IE10 and Chrome 27 on Windows 7. In Chrome I have IPv6 disabled. This only happens during debug. I also had a co-worker test the same code on their machine and they encounter the same problem.
I've solved the performance problem by moving the base link generation outside the foreach, but now would like to know why Debugging caused my original code to render so slowly.
Caching is disabled with Debug=true. That will cause performance issues on many levels including route/action resolution, view/partial-view location resolution and parsing etc. Overall deploying application in Release mode (Debug=false) will improve performance up to 10 times, especially for large loops used in views.