Added brand logo image selection
This commit is contained in:
@@ -58,6 +58,7 @@ class Brand extends BaseAction implements EventSubscriberInterface
|
|||||||
|
|
||||||
$brand
|
$brand
|
||||||
->setVisible($event->getVisible())
|
->setVisible($event->getVisible())
|
||||||
|
->setLogoImageId(intval($event->getLogoImageId()) == 0 ? null : $event->getLogoImageId())
|
||||||
->setLocale($event->getLocale())
|
->setLocale($event->getLocale())
|
||||||
->setTitle($event->getTitle())
|
->setTitle($event->getTitle())
|
||||||
->setDescription($event->getDescription())
|
->setDescription($event->getDescription())
|
||||||
|
|||||||
@@ -80,13 +80,14 @@ class BrandController extends AbstractSeoCrudController
|
|||||||
|
|
||||||
// Prepare the data that will hydrate the form
|
// Prepare the data that will hydrate the form
|
||||||
$data = [
|
$data = [
|
||||||
'id' => $object->getId(),
|
'id' => $object->getId(),
|
||||||
'locale' => $object->getLocale(),
|
'locale' => $object->getLocale(),
|
||||||
'title' => $object->getTitle(),
|
'title' => $object->getTitle(),
|
||||||
'chapo' => $object->getChapo(),
|
'chapo' => $object->getChapo(),
|
||||||
'description' => $object->getDescription(),
|
'description' => $object->getDescription(),
|
||||||
'postscriptum' => $object->getPostscriptum(),
|
'postscriptum' => $object->getPostscriptum(),
|
||||||
'visible' => $object->getVisible() ? true : false
|
'visible' => $object->getVisible() ? true : false,
|
||||||
|
'logo_image_id' => $object->getLogoImageId()
|
||||||
];
|
];
|
||||||
|
|
||||||
// Setup the object form
|
// Setup the object form
|
||||||
@@ -123,12 +124,13 @@ class BrandController extends AbstractSeoCrudController
|
|||||||
$brandUpdateEvent = new BrandUpdateEvent($formData['id']);
|
$brandUpdateEvent = new BrandUpdateEvent($formData['id']);
|
||||||
|
|
||||||
$brandUpdateEvent
|
$brandUpdateEvent
|
||||||
|
->setLogoImageId($formData['logo_image_id'])
|
||||||
|
->setVisible($formData['visible'])
|
||||||
->setLocale($formData['locale'])
|
->setLocale($formData['locale'])
|
||||||
->setTitle($formData['title'])
|
->setTitle($formData['title'])
|
||||||
->setChapo($formData['chapo'])
|
->setChapo($formData['chapo'])
|
||||||
->setDescription($formData['description'])
|
->setDescription($formData['description'])
|
||||||
->setPostscriptum($formData['postscriptum'])
|
->setPostscriptum($formData['postscriptum'])
|
||||||
->setVisible($formData['visible'])
|
|
||||||
;
|
;
|
||||||
|
|
||||||
return $brandUpdateEvent;
|
return $brandUpdateEvent;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class BrandUpdateEvent extends BrandCreateEvent
|
|||||||
protected $chapo;
|
protected $chapo;
|
||||||
protected $description;
|
protected $description;
|
||||||
protected $postscriptum;
|
protected $postscriptum;
|
||||||
|
protected $logo_image_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $brandId
|
* @param int $brandId
|
||||||
@@ -112,4 +113,22 @@ class BrandUpdateEvent extends BrandCreateEvent
|
|||||||
{
|
{
|
||||||
return $this->postscriptum;
|
return $this->postscriptum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $logo_image_id
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setLogoImageId($logo_image_id)
|
||||||
|
{
|
||||||
|
$this->logo_image_id = $logo_image_id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getLogoImageId()
|
||||||
|
{
|
||||||
|
return $this->logo_image_id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ class Brand extends BaseI18nLoop implements PropelSearchLoopInterface, SearchLoo
|
|||||||
->set("META_KEYWORDS" , $brand->getVirtualColumn('i18n_META_KEYWORDS'))
|
->set("META_KEYWORDS" , $brand->getVirtualColumn('i18n_META_KEYWORDS'))
|
||||||
->set("POSITION" , $brand->getPosition())
|
->set("POSITION" , $brand->getPosition())
|
||||||
->set("VISIBLE" , $brand->getVisible())
|
->set("VISIBLE" , $brand->getVisible())
|
||||||
|
->set("LOGO_IMAGE_ID" , $brand->getLogoImageId())
|
||||||
;
|
;
|
||||||
|
|
||||||
$loopResult->addRow($loopResultRow);
|
$loopResult->addRow($loopResultRow);
|
||||||
|
|||||||
@@ -159,15 +159,19 @@ class AdminUtilities extends AbstractSmartyPlugin
|
|||||||
|
|
||||||
public function buildFormFieldLabel($params, &$smarty)
|
public function buildFormFieldLabel($params, &$smarty)
|
||||||
{
|
{
|
||||||
$form = $this->getParam($params, 'form', false);
|
$form = $this->getParam($params, 'form', false);
|
||||||
$field_name = $this->getParam($params, 'name', false);
|
$field_name = $this->getParam($params, 'name', false);
|
||||||
$label_attr = $this->getParam($params, 'label_attr', array());
|
$label_attr = $this->getParam($params, 'label_attr', false);
|
||||||
|
|
||||||
return $this->fetchSnippet($smarty, 'forms'.DS.'form-label', array(
|
$args = [
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'field_name' => $field_name,
|
'field_name' => $field_name,
|
||||||
'label_attr' => $label_attr
|
];
|
||||||
));
|
|
||||||
|
if ($label_attr !== false)
|
||||||
|
$args['label_attr'] = $label_attr;
|
||||||
|
|
||||||
|
return $this->fetchSnippet($smarty, 'forms'.DS.'form-label', $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -53,6 +53,15 @@ class BrandModificationForm extends BrandCreationForm
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
->add("logo_image_id", "integer", [
|
||||||
|
'constraints' => [ ],
|
||||||
|
'required' => false,
|
||||||
|
'label' => Translator::getInstance()->trans('Select the brand logo'),
|
||||||
|
'label_attr' => [
|
||||||
|
'for' => 'mode',
|
||||||
|
'help' => Translator::getInstance()->trans("Select the brand logo amongst the brand images")
|
||||||
|
]
|
||||||
|
])
|
||||||
;
|
;
|
||||||
|
|
||||||
// Add standard description fields, excluding title and locale, which are already defined
|
// Add standard description fields, excluding title and locale, which are already defined
|
||||||
|
|||||||
@@ -40,10 +40,8 @@ class ProductModificationForm extends ProductCreationForm
|
|||||||
'label' => Translator::getInstance()->trans('Brand / Supplier'),
|
'label' => Translator::getInstance()->trans('Brand / Supplier'),
|
||||||
'label_attr' => [
|
'label_attr' => [
|
||||||
'for' => 'mode',
|
'for' => 'mode',
|
||||||
],
|
|
||||||
'attr' => [
|
|
||||||
'help' => Translator::getInstance()->trans("Select the product brand, or supplier."),
|
'help' => Translator::getInstance()->trans("Select the product brand, or supplier."),
|
||||||
]
|
],
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
ul.thumbnails.image_picker_selector {
|
||||||
|
overflow: auto;
|
||||||
|
list-style-image: none;
|
||||||
|
list-style-position: outside;
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 0px;
|
||||||
|
margin: 0px; }
|
||||||
|
ul.thumbnails.image_picker_selector ul {
|
||||||
|
overflow: auto;
|
||||||
|
list-style-image: none;
|
||||||
|
list-style-position: outside;
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 0px;
|
||||||
|
margin: 0px; }
|
||||||
|
ul.thumbnails.image_picker_selector li.group_title {
|
||||||
|
float: none; }
|
||||||
|
ul.thumbnails.image_picker_selector li {
|
||||||
|
margin: 0px 12px 12px 0px;
|
||||||
|
float: left; }
|
||||||
|
ul.thumbnails.image_picker_selector li .thumbnail {
|
||||||
|
padding: 6px;
|
||||||
|
border: 1px solid #dddddd;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none; }
|
||||||
|
ul.thumbnails.image_picker_selector li .thumbnail img {
|
||||||
|
-webkit-user-drag: none; }
|
||||||
|
ul.thumbnails.image_picker_selector li .thumbnail.selected {
|
||||||
|
background: #f39922; }
|
||||||
7
templates/backOffice/default/assets/js/image-picker/image-picker.min.js
vendored
Normal file
7
templates/backOffice/default/assets/js/image-picker/image-picker.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -1,5 +1,11 @@
|
|||||||
{extends file="admin-layout.tpl"}
|
{extends file="admin-layout.tpl"}
|
||||||
|
|
||||||
|
{block name="after-admin-css"}
|
||||||
|
{stylesheets file='assets/js/image-picker/image-picker.css'}
|
||||||
|
<link rel="stylesheet" href="{$asset_url}">
|
||||||
|
{/stylesheets}
|
||||||
|
{/block}
|
||||||
|
|
||||||
{block name="no-return-functions"}
|
{block name="no-return-functions"}
|
||||||
{$admin_current_location = 'tools'}
|
{$admin_current_location = 'tools'}
|
||||||
{/block}
|
{/block}
|
||||||
@@ -77,6 +83,26 @@
|
|||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
{admin_form_field form=$form name="visible"}
|
{admin_form_field form=$form name="visible"}
|
||||||
|
|
||||||
|
{form_field form=$form field='logo_image_id'}
|
||||||
|
<div class="form-group {if $error}has-error{/if}">
|
||||||
|
|
||||||
|
{admin_form_field_label form=$form name='logo_image_id'}
|
||||||
|
|
||||||
|
<select id="{$label_attr.for}" {if $required}aria-required="true" required{/if} name="{$name}" class="form-control brand-image-selector">
|
||||||
|
<option value="">{intl l="No logo image"}</option>
|
||||||
|
|
||||||
|
{loop name="brand-images" type="image" brand=$ID width="90" height="90" resize_mode="crop"}
|
||||||
|
<option value="{$ID}" data-img-src="{$IMAGE_URL}" {if $LOGO_IMAGE_ID == $ID}selected="selected"{/if}>{$TITLE}</option>
|
||||||
|
{/loop}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
{if $label_attr.help}
|
||||||
|
<span class="help-block">{$label_attr.help}</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/form_field}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -152,6 +178,9 @@
|
|||||||
{javascripts file='assets/js/jquery-ui-1.10.3.custom.min.js'}
|
{javascripts file='assets/js/jquery-ui-1.10.3.custom.min.js'}
|
||||||
<script src="{$asset_url}"></script>
|
<script src="{$asset_url}"></script>
|
||||||
{/javascripts}
|
{/javascripts}
|
||||||
|
{javascripts file='assets/js/image-picker/image-picker.min.js'}
|
||||||
|
<script src="{$asset_url}"></script>
|
||||||
|
{/javascripts}
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
// Load active tab
|
// Load active tab
|
||||||
@@ -169,6 +198,8 @@
|
|||||||
{if ! empty($current_tab)}
|
{if ! empty($current_tab)}
|
||||||
$('.nav-tabs a[href="#{$current_tab}"]').trigger("click");
|
$('.nav-tabs a[href="#{$current_tab}"]').trigger("click");
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
$('.brand-image-selector').imagepicker();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{/block}
|
{/block}
|
||||||
|
|||||||
Reference in New Issue
Block a user