Merge pull request #532 from bibich/improvements

small corrections and improvements, especially on the backoffice template.
This commit is contained in:
Julien
2014-07-16 20:33:24 +02:00
11 changed files with 167 additions and 32 deletions

View File

@@ -103,6 +103,8 @@ class AttributeCombination extends BaseI18nLoop implements PropelSearchLoopInter
$loopResultRow = new LoopResultRow($attributeCombination); $loopResultRow = new LoopResultRow($attributeCombination);
$loopResultRow $loopResultRow
->set("ATTRIBUTE_ID", $attributeCombination->getAttributeId())
->set("ATTRIBUTE_AVAILABILITY_ID", $attributeCombination->getAttributeAvId())
->set("LOCALE",$this->locale) ->set("LOCALE",$this->locale)
->set("ATTRIBUTE_TITLE", $attributeCombination->getVirtualColumn(AttributeTableMap::TABLE_NAME . '_i18n_TITLE')) ->set("ATTRIBUTE_TITLE", $attributeCombination->getVirtualColumn(AttributeTableMap::TABLE_NAME . '_i18n_TITLE'))
->set("ATTRIBUTE_CHAPO", $attributeCombination->getVirtualColumn(AttributeTableMap::TABLE_NAME . '_i18n_CHAPO')) ->set("ATTRIBUTE_CHAPO", $attributeCombination->getVirtualColumn(AttributeTableMap::TABLE_NAME . '_i18n_CHAPO'))

View File

@@ -155,6 +155,8 @@ class BrandTest extends TestCaseWithURLToolSetup
public function testUpdatePositionUp() public function testUpdatePositionUp()
{ {
$this->resetBrandPosition();
$brand = BrandQuery::create() $brand = BrandQuery::create()
->filterByPosition(1, Criteria::GREATER_THAN) ->filterByPosition(1, Criteria::GREATER_THAN)
->findOne(); ->findOne();
@@ -178,6 +180,8 @@ class BrandTest extends TestCaseWithURLToolSetup
public function testUpdatePositionDown() public function testUpdatePositionDown()
{ {
$this->resetBrandPosition();
$brand = BrandQuery::create() $brand = BrandQuery::create()
->filterByPosition(1) ->filterByPosition(1)
->findOne(); ->findOne();
@@ -201,6 +205,8 @@ class BrandTest extends TestCaseWithURLToolSetup
public function testUpdatePositionWithSpecificPosition() public function testUpdatePositionWithSpecificPosition()
{ {
$this->resetBrandPosition();
$brand = BrandQuery::create() $brand = BrandQuery::create()
->filterByPosition(1, Criteria::GREATER_THAN) ->filterByPosition(1, Criteria::GREATER_THAN)
->findOne(); ->findOne();
@@ -219,6 +225,23 @@ class BrandTest extends TestCaseWithURLToolSetup
$this->assertEquals(1, $updatedBrand->getPosition(),sprintf("new position is 1, new position expected is %d for brand %d", $updatedBrand->getPosition(), $updatedBrand->getId())); $this->assertEquals(1, $updatedBrand->getPosition(),sprintf("new position is 1, new position expected is %d for brand %d", $updatedBrand->getPosition(), $updatedBrand->getId()));
} }
/**
* Reorder brand to have proper position
*/
protected function resetBrandPosition()
{
$brands = BrandQuery::create()->find();
$counter = 1;
/** @var \Thelia\Model\Brand $brand */
foreach ($brands as $brand) {
$brand->setPosition($counter);
$brand->save();
$counter++;
}
}
/** /**
* @return \Thelia\Model\Brand * @return \Thelia\Model\Brand
*/ */

View File

@@ -154,6 +154,7 @@ class URL
$base = $path; $base = $path;
$queryString = ''; $queryString = '';
$anchor = '';
if (! is_null($parameters)) { if (! is_null($parameters)) {
foreach ($parameters as $name => $value) { foreach ($parameters as $name => $value) {
@@ -167,6 +168,14 @@ class URL
if ('' !== $queryString = rtrim($queryString, "&")) { if ('' !== $queryString = rtrim($queryString, "&")) {
// url could contain anchor
$pos = strrpos($base, '#');
if($pos !== false) {
$anchor = substr($base, $pos);
$base = substr($base, 0, $pos);
}
$base = rtrim($base, "?&"); $base = rtrim($base, "?&");
$sepChar = strstr($base, '?') === false ? '?' : '&'; $sepChar = strstr($base, '?') === false ? '?' : '&';
@@ -174,7 +183,7 @@ class URL
$queryString = $sepChar . $queryString; $queryString = $sepChar . $queryString;
} }
return $base . $queryString; return $base . $queryString . $anchor;
} }
/** /**

View File

@@ -13,6 +13,7 @@
namespace Thelia\Type; namespace Thelia\Type;
use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveQuery\ModelCriteria;
use Thelia\Core\Translation\Translator;
use Thelia\Exception\TypeException; use Thelia\Exception\TypeException;
/** /**
@@ -67,8 +68,16 @@ class ModelValidIdType extends BaseType
{ {
$queryClass = $this->expectedModelActiveRecordQuery; $queryClass = $this->expectedModelActiveRecordQuery;
$query = $queryClass::create();
if (method_exists($query, "joinWithI18n")) {
if (null !== $locale = Translator::getInstance()->getLocale()) {
$query->joinWithI18n($locale);
}
}
$choices = array(); $choices = array();
foreach ($queryClass::create()->find() as $item) { foreach ($query->find() as $item) {
$choices[$item->getId()] = method_exists($item, "getTitle") ? $item->getTitle() : $item->getId(); $choices[$item->getId()] = method_exists($item, "getTitle") ? $item->getTitle() : $item->getId();
} }

View File

@@ -250,9 +250,13 @@ CREATE TABLE `brand_image_i18n`
-- Add brand field to product table, and related constraint. -- Add brand field to product table, and related constraint.
-- --------------------------------------------------------- -- ---------------------------------------------------------
ALTER TABLE `product` ADD `brand_id` INTEGER DEFAULT 0 AFTER `template_id`; ALTER TABLE `product` ADD `brand_id` INTEGER AFTER `template_id`;
ALTER TABLE `product` ADD CONSTRAINT `fk_product_brand` FOREIGN KEY (`brand_id`) REFERENCES `brand` (`id`) ON DELETE SET NULL; ALTER TABLE `product` ADD CONSTRAINT `fk_product_brand` FOREIGN KEY (`brand_id`) REFERENCES `brand` (`id`) ON DELETE SET NULL;
ALTER TABLE `product_version` ADD `brand_id` INTEGER AFTER `template_id`;
ALTER TABLE `product_version` ADD CONSTRAINT `fk_product_version_brand` FOREIGN KEY (`brand_id`) REFERENCES `brand` (`id`) ON DELETE SET NULL;
# Add html_output_trim_level config variable # Add html_output_trim_level config variable
# ------------------------------------------ # ------------------------------------------

View File

@@ -232,6 +232,16 @@
</div> </div>
</div> </div>
</div> </div>
{include
file = "includes/inner-form-toolbar.html"
hide_submit_buttons = false
hide_flags = true
page_url = "{url path='/admin/products/update' product_id=$ID}"
close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}"
}
</form> </form>
</div> </div>
</div> </div>

View File

@@ -50,7 +50,7 @@
current_order=$category_order current_order=$category_order
order='id' order='id'
reverse_order='id_reverse' reverse_order='id_reverse'
path={url path='/admin/categories' id_category=$category_id} path={url path='/admin/catalog' category_id=$category_id}
request_parameter_name='category_order' request_parameter_name='category_order'
label="{intl l='ID'}" label="{intl l='ID'}"
} }
@@ -63,7 +63,7 @@
current_order=$category_order current_order=$category_order
order='alpha' order='alpha'
reverse_order='alpha_reverse' reverse_order='alpha_reverse'
path={url path='/admin/categories' id_category=$category_id} path={url path='/admin/catalog' category_id=$category_id}
request_parameter_name='category_order' request_parameter_name='category_order'
label="{intl l='Category title'}" label="{intl l='Category title'}"
} }
@@ -76,7 +76,7 @@
current_order=$category_order current_order=$category_order
order='visible' order='visible'
reverse_order='visible_reverse' reverse_order='visible_reverse'
path={url path='/admin/categories' id_category=$category_id} path={url path='/admin/catalog' category_id=$category_id}
request_parameter_name='category_order' request_parameter_name='category_order'
label="{intl l='Online'}" label="{intl l='Online'}"
} }
@@ -87,7 +87,7 @@
current_order=$category_order current_order=$category_order
order='manual' order='manual'
reverse_order='manual_reverse' reverse_order='manual_reverse'
path={url path='/admin/categories' id_category=$category_id} path={url path='/admin/catalog' category_id=$category_id}
request_parameter_name='category_order' request_parameter_name='category_order'
label="{intl l='Position'}" label="{intl l='Position'}"
} }
@@ -187,6 +187,10 @@
{* No product on toplevel category, e.g. id_category = 0 *} {* No product on toplevel category, e.g. id_category = 0 *}
{loop type="currency" name="product-currency" id=$edit_currency_id backend_context="1"}
{$currency_symbol = $SYMBOL}
{/loop}
{if $category_id > 0} {if $category_id > 0}
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
@@ -218,7 +222,8 @@
current_order=$product_order current_order=$product_order
order='id' order='id'
reverse_order='id_reverse' reverse_order='id_reverse'
path={url path='/admin/categories' id_category=$category_id target='products'} path={url path='/admin/catalog' category_id=$category_id target='products'}
request_parameter_name='product_order'
label="{intl l='ID'}" label="{intl l='ID'}"
} }
@@ -229,7 +234,8 @@
current_order=$product_order current_order=$product_order
order='ref' order='ref'
reverse_order='ref_reverse' reverse_order='ref_reverse'
path={url path='/admin/categories' id_category=$category_id target='products'} path={url path='/admin/catalog' category_id=$category_id target='products'}
request_parameter_name='product_order'
label="{intl l='Reference'}" label="{intl l='Reference'}"
} }
</th> </th>
@@ -239,28 +245,42 @@
current_order=$product_order current_order=$product_order
order='alpha' order='alpha'
reverse_order='alpha_reverse' reverse_order='alpha_reverse'
path={url path='/admin/categories' id_category=$category_id target='products'} path={url path='/admin/catalog' category_id=$category_id target='products'}
request_parameter_name='product_order'
label="{intl l='Product title'}" label="{intl l='Product title'}"
} }
{module_include location='product_list_header'} {module_include location='product_list_header'}
<th> <th class="text-right">
{admin_sortable_header {admin_sortable_header
current_order=$product_order current_order=$product_order
order='visible' order='min_price'
reverse_order='visible_reverse' reverse_order='max_price'
path={url path='/admin/categories' id_category=$category_id target='products'} path={url path='/admin/catalog' category_id=$category_id target='products'}
label="{intl l='Online'}" request_parameter_name='product_order'
} label="{intl l='Price'}"
}
</th> </th>
<th> <th class="text-center">
{admin_sortable_header
current_order=$product_order
order='visible'
reverse_order='visible_reverse'
path={url path='/admin/catalog' category_id=$category_id target='products'}
request_parameter_name='product_order'
label="{intl l='Online'}"
}
</th>
<th class="text-center">
{admin_sortable_header {admin_sortable_header
current_order=$product_order current_order=$product_order
order='manual' order='manual'
reverse_order='manual_reverse' reverse_order='manual_reverse'
path={url path='/admin/categories' id_category=$category_id target='products'} path={url path='/admin/catalog' category_id=$category_id target='products'}
request_parameter_name='product_order'
label="{intl l='Position'}" label="{intl l='Position'}"
} }
</th> </th>
@@ -280,6 +300,7 @@
<img src="{$IMAGE_URL}" alt="{$TITLE}" /> <img src="{$IMAGE_URL}" alt="{$TITLE}" />
</a> </a>
{/loop} {/loop}
</td>
<td class="object-title"><a href="{url path='/admin/products/update' product_id=$ID page=$page}" title="{intl l='Edit this product'}">{$REF}</a></td> <td class="object-title"><a href="{url path='/admin/products/update' product_id=$ID page=$page}" title="{intl l='Edit this product'}">{$REF}</a></td>
@@ -287,7 +308,9 @@
{module_include location='product_list_row'} {module_include location='product_list_row'}
<td> <td class="text-right"><a href="{url path='/admin/products/update' product_id=$ID page=$page current_tab='prices'}" title="{intl l='Edit Prices'}">{format_money number=$BEST_PRICE symbol=$currency_symbol}</a></td>
<td class="text-center">
{loop type="auth" name="can_change" role="ADMIN" resource="admin.product" access="UPDATE"} {loop type="auth" name="can_change" role="ADMIN" resource="admin.product" access="UPDATE"}
<div class="make-switch switch-small productVisibleToggle" data-id="{$ID}" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>"> <div class="make-switch switch-small productVisibleToggle" data-id="{$ID}" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input type="checkbox" class="productVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}> <input type="checkbox" class="productVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
@@ -301,7 +324,7 @@
{/elseloop} {/elseloop}
</td> </td>
<td> <td class="text-center">
{admin_position_block {admin_position_block
resource="admin.product" resource="admin.product"
access="UPDATE" access="UPDATE"
@@ -329,13 +352,13 @@
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>
<td colspan="6"> <td colspan="9">
{include {include
file = "includes/pagination.html" file = "includes/pagination.html"
loop_ref = "product_list" loop_ref = "product_list"
max_page_count = 10 max_page_count = 10
page_url = "{url path="/admin/categories" category_id=$category_id product_order=$product_order}" page_url = "{url path="/admin/catalog" category_id=$category_id product_order=$product_order}"
} }
</td> </td>
@@ -794,10 +817,16 @@
captureLength: 1, captureLength: 1,
wait : 300, wait : 300,
callback : function () { callback : function () {
var price = $(this).val();
$(this).val(sanitizeFloat(price));
update_price($(this).val(), $(this).data('price-type'), $(this).data('rel-price')); update_price($(this).val(), $(this).data('price-type'), $(this).data('rel-price'));
} }
}); });
function sanitizeFloat(numVal) {
return numVal.replace(",", ".");
};
}); });
</script> </script>
{/block} {/block}

View File

@@ -242,9 +242,9 @@
{module_include location='product_details_promotion_form'} {module_include location='product_details_promotion_form'}
</div> </div>
</div> </div>
</div> </div>
</form> </form>
{/form} {/form}
{/if} {/if}
@@ -454,6 +454,16 @@
</table> </table>
{module_include location='product_after_combinations'} {module_include location='product_after_combinations'}
{include
file = "includes/inner-form-toolbar.html"
hide_submit_buttons = false
hide_flags = true
page_url = "{url path='/admin/products/update' product_id=$ID}"
close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}"
}
</div> </div>
</div> </div>

View File

@@ -99,9 +99,15 @@
{/if} {/if}
<tr> <tr>
<td> <td>
{loop type="product" name="my_product_loop" visible="*" ref="$REF"} {ifloop rel="my_product_loop"}
<a href="{url path='/admin/products/update' product_id=$ID}">{$TITLE}</a> {loop type="product" name="my_product_loop" visible="*" ref="$REF"}
{/loop} <a href="{url path='/admin/products/update' product_id=$ID}">{$TITLE}</a>
{/loop}
{/ifloop}
{elseloop rel="my_product_loop"}
{* The product doesn't exist anymore *}
{$TITLE}
{/elseloop}
{ifloop rel="combinations"} {ifloop rel="combinations"}
<dl class="dl-horizontal"> <dl class="dl-horizontal">
{loop type="order_product_attribute_combination" name="combinations" order_product=$ID} {loop type="order_product_attribute_combination" name="combinations" order_product=$ID}
@@ -162,6 +168,32 @@
</table> </table>
</div> </div>
{loop type="order_address" name="order-invoice-address" id=$INVOICE_ADDRESS}
{assign "orderInvoiceFirstName" $FIRSTNAME}
{assign "orderInvoiceLastName" $LASTNAME}
{assign "orderInvoiceCompany" $COMPANY}
{/loop}
<div class="table-responsive">
<table class="table table-striped table-condensed table-left-aligned">
<caption class="clearfix">
{intl l='Customer information'}
</caption>
<tbody>
<tr>
<th>{intl l="Customer"}</th>
<td><a href="{url path='/admin/customer/update' customer_id=$CUSTOMER}">{$orderInvoiceFirstName|ucwords} {$orderInvoiceLastName|upper}</a></td>
</tr>
{if $orderInvoiceCompany}
<tr>
<th>{intl l="Company"}</th>
<td>{$orderInvoiceCompany}</td>
</tr>
{/if}
</tbody>
</table>
</div>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-condensed table-left-aligned"> <table class="table table-striped table-condensed table-left-aligned">
<caption class="clearfix"> <caption class="clearfix">

View File

@@ -26,7 +26,7 @@
<div class="col-md-12 general-block-decorator"> <div class="col-md-12 general-block-decorator">
<div class="row"> <div class="row">
<div class="col-md-7 title"> <div class="col-md-7 title">
{intl l='Edit product %title' title={$TITLE}} {intl l='Edit product %title' title={$TITLE}}{if $REF} ({intl l='ref.:'} {$REF}){/if}
</div> </div>
<div class="col-md-5 actions"> <div class="col-md-5 actions">
@@ -363,10 +363,16 @@ $(function() {
captureLength: 1, captureLength: 1,
wait : 300, wait : 300,
callback : function () { callback : function () {
update_price($(this).val(), $(this).data('price-type'), $(this).data('rel-price')); var price = $(this).val();
$(this).val(sanitizeFloat(price));
update_price($(this).val(), $(this).data('price-type'), $(this).data('rel-price'));
} }
}); });
function sanitizeFloat(numVal) {
return numVal.replace(",", ".");
};
// Count generated combinations in real time // Count generated combinations in real time
function countGeneratedCombinations() { function countGeneratedCombinations() {

View File

@@ -223,7 +223,8 @@
<li> <li>
<strong>{$TITLE}</strong> : <strong>{$TITLE}</strong> :
{loop name="feature_value_info" type="feature_value" feature="{$ID}" product="{product attr="id"}"} {loop name="feature_value_info" type="feature_value" feature="{$ID}" product="{product attr="id"}"}
{$TITLE} {if $LOOP_COUNT > 1}, {else} {/if}
<span>{if $IS_FREE_TEXT == 1}{$FREE_TEXT_VALUE}{else}{$TITLE}{/if}</span>
{/loop} {/loop}
</li> </li>
{/ifloop} {/ifloop}