Skip to content

Commit a6e17ed

Browse files
author
Vilchynskyi, Dmytro(dvilchynskyi)
committed
Merge pull request #194 from magento-webdev/UI
[UI] Bug fixes
2 parents 94e6406 + 3f04077 commit a6e17ed

File tree

18 files changed

+845
-157
lines changed

18 files changed

+845
-157
lines changed

app/code/Magento/Catalog/Model/Observer.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Catalog\Model;
77

8+
/**
9+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
10+
*/
811
class Observer
912
{
1013
/**
@@ -62,16 +65,23 @@ class Observer
6265
protected $_productResourceFactory;
6366

6467
/**
65-
* @param \Magento\Catalog\Model\Resource\Category $categoryResource
66-
* @param \Magento\Catalog\Model\Resource\Product $catalogProduct
68+
* @var \Magento\Framework\Registry
69+
*/
70+
protected $_registry;
71+
72+
/**
73+
* @param \Magento\Framework\Registry $registry
74+
* @param Resource\Category $categoryResource
75+
* @param Resource\Product $catalogProduct
6776
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
68-
* @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
77+
* @param Layer\Resolver $layerResolver
6978
* @param \Magento\Catalog\Helper\Category $catalogCategory
7079
* @param \Magento\Catalog\Helper\Data $catalogData
7180
* @param Indexer\Category\Flat\State $categoryFlatState
72-
* @param \Magento\Catalog\Model\Resource\ProductFactory $productResourceFactory
81+
* @param Resource\ProductFactory $productResourceFactory
7382
*/
7483
public function __construct(
84+
\Magento\Framework\Registry $registry,
7585
\Magento\Catalog\Model\Resource\Category $categoryResource,
7686
\Magento\Catalog\Model\Resource\Product $catalogProduct,
7787
\Magento\Store\Model\StoreManagerInterface $storeManager,
@@ -81,6 +91,7 @@ public function __construct(
8191
\Magento\Catalog\Model\Indexer\Category\Flat\State $categoryFlatState,
8292
\Magento\Catalog\Model\Resource\ProductFactory $productResourceFactory
8393
) {
94+
$this->_registry = $registry;
8495
$this->_categoryResource = $categoryResource;
8596
$this->_catalogProduct = $catalogProduct;
8697
$this->_storeManager = $storeManager;
@@ -137,11 +148,20 @@ protected function _addCategoriesToMenu($categories, $parentCategoryNode, $block
137148
$block->addIdentity(\Magento\Catalog\Model\Category::CACHE_TAG . '_' . $category->getId());
138149

139150
$tree = $parentCategoryNode->getTree();
151+
152+
$isActiveCategory = false;
153+
/** @var \Magento\Catalog\Model\Category $currentCategory */
154+
$currentCategory = $this->_registry->registry('current_category');
155+
if ($currentCategory && $currentCategory->getId() == $category->getId()) {
156+
$isActiveCategory = true;
157+
}
158+
140159
$categoryData = [
141160
'name' => $category->getName(),
142161
'id' => $nodeId,
143162
'url' => $this->_catalogCategory->getCategoryUrl($category),
144-
'is_active' => $this->_isActiveMenuCategory($category),
163+
'has_active' => $this->hasActive($category),
164+
'is_active' => $isActiveCategory
145165
];
146166
$categoryNode = new \Magento\Framework\Data\Tree\Node($categoryData, 'id', $tree, $parentCategoryNode);
147167
$parentCategoryNode->addChild($categoryNode);
@@ -162,7 +182,7 @@ protected function _addCategoriesToMenu($categories, $parentCategoryNode, $block
162182
* @param \Magento\Framework\Data\Tree\Node $category
163183
* @return bool
164184
*/
165-
protected function _isActiveMenuCategory($category)
185+
protected function hasActive($category)
166186
{
167187
if (!$this->_catalogLayer) {
168188
return false;

app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ require([
2626
var uploaderTemplate = '<div class="no-display" id="[[idName]]-template">' +
2727
'<div id="<%- data.id %>" class="file-row file-row-narrow">' +
2828
'<span class="file-info">' +
29-
'<span class="file-info-name"><%- data.name %></span>' +
29+
'<span class="file-info-name"><%= data.name %></span>' +
3030
' ' +
3131
'<span class="file-info-size">(<%- data.size %>)</span>' +
3232
'</span>' +
@@ -41,7 +41,7 @@ var uploaderTemplate = '<div class="no-display" id="[[idName]]-template">' +
4141
'</div>';
4242

4343
var fileListTemplate = '<span class="file-info">' +
44-
'<span class="file-info-name"><%- data.name %></span>' +
44+
'<span class="file-info-name"><%= data.name %></span>' +
4545
' ' +
4646
'<span class="file-info-size">(<%- data.size %>)</span>' +
4747
'</span>';

app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/links.phtml

Lines changed: 66 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -15,58 +15,61 @@
1515
?>
1616
<?php $_product = $block->getProduct()?>
1717
<?php $block->getConfigJson() ?>
18-
<div class="form-inline">
19-
<div class="field">
20-
<label class="label" for="name"><span><?php echo __('Title')?></span></label>
21-
<div class="control">
22-
<input type="text" class="input-text" id="downloadable_links_title" name="product[links_title]" value="<?php echo $block->getLinksTitle() ?>" <?php echo($_product->getStoreId() && $block->getUsedDefault()) ? 'disabled="disabled"' : '' ?>>
23-
<?php if ($_product->getStoreId()): ?>
24-
<input id="link_title_default" type="checkbox" name="use_default[]" value="links_title" onclick="toggleValueElements(this, this.parentNode.parentNode)" <?php echo $block->getUsedDefault() ? 'checked="checked"' : '' ?> />
25-
<label class="normal" for="link_title_default"><?php echo __('Use Default Value'); ?></label>
26-
<?php endif; ?>
27-
</div>
28-
<div class="field-service">
29-
<?php echo !$block->isSingleStoreMode() ? __('[STORE VIEW]') : ''; ?>
18+
<div class="admin__scope">
19+
<fieldset class="admin__fieldset downloadable-form">
20+
21+
<div class="admin__field" <?php echo !$block->isSingleStoreMode() ? ' data-config-scope="' . __('[STORE VIEW]') . '"' : ''; ?>>
22+
<label class="admin__field-label" for="downloadable_links_title"><span><?php echo __('Title')?></span></label>
23+
<div class="admin__field-control">
24+
<input type="text" class="admin__control-text" id="downloadable_links_title" name="product[links_title]" value="<?php echo $block->getLinksTitle() ?>" <?php echo($_product->getStoreId() && $block->getUsedDefault()) ? 'disabled="disabled"' : '' ?>>
25+
<?php if ($_product->getStoreId()): ?>
26+
<div class="admin__field admin__field-option">
27+
<input id="link_title_default" class="admin__control-checkbox" type="checkbox" name="use_default[]" value="links_title" onclick="toggleValueElements(this, this.parentNode.parentNode)" <?php echo $block->getUsedDefault() ? 'checked="checked"' : '' ?> />
28+
<label class="admin__field-label" for="link_title_default"><span><?php echo __('Use Default Value'); ?></span></label>
29+
</div>
30+
<?php endif; ?>
31+
</div>
3032
</div>
31-
</div>
3233

33-
<div class="field">
34-
<label class="label" for="name"><span><?php echo __('Links can be purchased separately')?></span></label>
35-
<div class="control">
36-
<?php echo $block->getPurchasedSeparatelySelect()?>
34+
<div class="admin__field" <?php echo !$block->isSingleStoreMode() ? ' data-config-scope="' . __('[GLOBAL]') . '"' : ''; ?>>
35+
<label class="admin__field-label" for="downloadable_link_purchase_type"><span><?php echo __('Links can be purchased separately')?></span></label>
36+
<div class="admin__field-control">
37+
<?php echo $block->getPurchasedSeparatelySelect()?>
38+
</div>
3739
</div>
38-
<div class="field-service">
39-
<?php echo !$block->isSingleStoreMode() ? __('[GLOBAL]') : ''; ?>
40+
<div class="admin__field admin__field-wide">
41+
<div class="admin__field-control">
42+
<div class="admin__control-table-wrapper">
43+
<table cellspacing="0" class="admin__control-table">
44+
<thead>
45+
<tr>
46+
<th class="col-title _required"><span><?php echo __('Title') ?></span></th>
47+
<?php if ($block->getCanReadPrice() !== false) : ?>
48+
<th class="col-price"><span><?php echo __('Price') ?></span></th>
49+
<?php endif; ?>
50+
<th class="col-limit"><span><?php echo __('Max. Downloads') ?></span></th>
51+
<th class="col-option"><span><?php echo __('Shareable') ?></span></th>
52+
<th class="col-sample"><span><?php echo __('Sample') ?></span></th>
53+
<th class="col-file"><span><?php echo __('File') ?></span></th>
54+
<th class="col-sort"><span><?php echo __('Sort Order') ?></span></th>
55+
<th class="col-actions">&nbsp;</th>
56+
</tr>
57+
</thead>
58+
<tfoot>
59+
<tr>
60+
<td class="col-actions-add" colspan="8"><?php echo $block->getAddButtonHtml() ?></td>
61+
</tr>
62+
</tfoot>
63+
<tbody id="link_items_body">
64+
</tbody>
65+
</table>
66+
</div>
67+
<div class="admin__field-note">
68+
<span><?php echo __('Alphanumeric, dash and underscore characters are recommended for filenames. Improper characters are replaced with \'_\'.')?></span>
69+
</div>
70+
</div>
4071
</div>
41-
</div>
42-
43-
<table cellspacing="0" class="data-table">
44-
<thead>
45-
<tr>
46-
<th><?php echo __('Title')?> <span class="required">*</span></th>
47-
<?php if ($block->getCanReadPrice() !== false) : ?>
48-
<th><?php echo __('Price')?></th>
49-
<?php endif; ?>
50-
<th><?php echo __('Max. Downloads')?></th>
51-
<th><?php echo __('Shareable')?></th>
52-
<th><?php echo __('Sample')?></th>
53-
<th><?php echo __('File')?></th>
54-
<th><?php echo __('Sort Order')?></th>
55-
<th class="col-delete">&nbsp;</th>
56-
</tr>
57-
</thead>
58-
<tfoot>
59-
<tr>
60-
<td colspan="8" class="col-actions-add"><?php echo $block->getAddButtonHtml()?></td>
61-
</tr>
62-
</tfoot>
63-
<tbody id="link_items_body">
64-
</tbody>
65-
</table>
66-
67-
<div><small><?php echo __('Alphanumeric, dash and underscore characters are recommended for filenames. Improper characters are replaced with \'_\'.')?></small></div>
68-
69-
72+
</fieldset>
7073
</div>
7174
<script>
7275
require([
@@ -79,15 +82,15 @@ require([
7982
], function(jQuery, registry, mageTemplate){
8083
registry.get('downloadable', function (Downloadable) {
8184
var linkTemplate = '<tr>'+
82-
'<td>'+
85+
'<td class="col-title">'+
8386
'<input type="hidden" class="__delete__" name="downloadable[link][<%- data.id %>][is_delete]" value="" />'+
8487
'<input type="hidden" name="downloadable[link][<%- data.id %>][link_id]" value="<%- data.link_id %>" />'+
85-
'<input type="text" class="required-entry input-text" name="downloadable[link][<%- data.id %>][title]" value="<%- data.title %>" />'+
88+
'<input type="text" class="required-entry input-text admin__control-text" name="downloadable[link][<%- data.id %>][title]" value="<%- data.title %>" />'+
8689
'<?php echo $_product->getStoreId() ? '<input type="checkbox" id="downloadable_link_<%- data.id %>_title" name="downloadable[link][<%- data.id %>][use_default_title]" value="1" /><label class="normal" for="downloadable_link_<%- data.id %>_title">Use Default Value</label>' : '' ?>'+
8790
'</td>'+
8891
<?php if ($block->getCanReadPrice() !== false) : ?>
89-
'<td class="input-price">'+
90-
'<input type="text" id="downloadable_link_<%- data.id %>_price_value" class="input-text validate-number link-prices<?php if ($block->getCanEditPrice() === false) : ?> disabled<?php endif; ?>" name="downloadable[link][<%- data.id %>][price]" value="<%- data.price %>"<?php if ($block->getCanEditPrice() === false) : ?> disabled="disabled"<?php endif; ?> /> ' +
92+
'<td class="input-price col-price">'+
93+
'<input type="text" id="downloadable_link_<%- data.id %>_price_value" class="input-text admin__control-text validate-number link-prices<?php if ($block->getCanEditPrice() === false) : ?> disabled<?php endif; ?>" name="downloadable[link][<%- data.id %>][price]" value="<%- data.price %>"<?php if ($block->getCanEditPrice() === false) : ?> disabled="disabled"<?php endif; ?> /> ' +
9194
'<label>[<?php echo $block->getBaseCurrencyCode($_product->getStoreId()) ?>]</label>' +
9295
<?php if ($_product->getStoreId() && $block->getIsPriceWebsiteScope()) : ?>
9396
'<br /><input type="checkbox" id="downloadable_link_<%- data.id %>_price" name="downloadable[link][<%- data.id %>][use_default_price]" value="1"<?php if ($block->getCanEditPrice() === false) : ?> disabled="disabled"<?php endif; ?> /> <label for="downloadable_link_<%- data.id %>_price">Use Default Value</label>' +
@@ -99,16 +102,16 @@ require([
99102
'<input type="hidden" id="downloadable_link_<%- data.id %>_price" name="downloadable[link][<%- data.id %>][use_default_price]" value="1" />' +
100103
<?php endif; ?>
101104
<?php endif; ?>
102-
'<td><input type="text" id="downloadable_link_<%- data.id %>_downloads" name="downloadable[link][<%- data.id %>][number_of_downloads]" class="input-text downloads" value="<%- data.number_of_downloads %>" />'+
105+
'<td class="col-limit"><input type="text" id="downloadable_link_<%- data.id %>_downloads" name="downloadable[link][<%- data.id %>][number_of_downloads]" class="input-text admin__control-text downloads" value="<%- data.number_of_downloads %>" />'+
103106
'<p><input type="checkbox" class="checkbox" id="downloadable_link_<%- data.id %>_is_unlimited" name="downloadable[link][<%- data.id %>][is_unlimited]" value="1" <%- data.is_unlimited %> /> <label for="downloadable_link_<%- data.id %>_is_unlimited">Unlimited</label></p></td>'+
104-
'<td>'+
107+
'<td class="col-share">'+
105108
'<select id="downloadable_link _<%- data.id %>_shareable" name="downloadable[link][<%- data.id %>][is_shareable]">'+
106109
'<option value="1">Yes</option>'+
107110
'<option value="0">No</option>'+
108111
'<option value="2" selected="selected">Use config</option>'+
109112
'</select>'+
110113
'</td>'+
111-
'<td>'+
114+
'<td class="col-file">'+
112115
'<div class="files">'+
113116
'<div class="row">'+
114117
'<label for="downloadable_link_<%- data.id %>_sample_file_type"><input type="radio" class="radio" id="downloadable_link_<%- data.id %>_sample_file_type" name="downloadable[link][<%- data.id %>][sample][type]" value="file"<%- data.sample_file_checked %> /> File:</label>'+
@@ -127,14 +130,14 @@ require([
127130
'</div>'+
128131
'</div>'+
129132
'<div class="row">'+
130-
'<label for="downloadable_link_<%- data.id %>_sample_url_type"><input type="radio" class="radio" id="downloadable_link_<%- data.id %>_sample_url_type" name="downloadable[link][<%- data.id %>][sample][type]" value="url"<%- data.sample_url_checked %> /> URL:</label><input type="text" class="input-text validate-downloadable-url validate-url" name="downloadable[link][<%- data.id %>][sample][url]" value="<%- data.sample_url %>" />'+
133+
'<label for="downloadable_link_<%- data.id %>_sample_url_type"><input type="radio" class="radio" id="downloadable_link_<%- data.id %>_sample_url_type" name="downloadable[link][<%- data.id %>][sample][type]" value="url"<%- data.sample_url_checked %> /> URL:</label><input type="text" class="input-text admin__control-text validate-downloadable-url validate-url" name="downloadable[link][<%- data.id %>][sample][url]" value="<%- data.sample_url %>" />'+
131134
'</div>'+
132135
'<div>'+
133136
'<span id="downloadable_link_<%- data.id %>_sample_container"></span>'+
134137
'</div>'+
135138
'</div>'+
136139
'</td>'+
137-
'<td>'+
140+
'<td class="col-file">'+
138141
'<div class="files">'+
139142
'<div class="row">'+
140143
'<label for="downloadable_link_<%- data.id %>_file_type"><input type="radio" class="radio validate-one-required-by-name" id="downloadable_link_<%- data.id %>_file_type" name="downloadable[link][<%- data.id %>][type]" value="file"<%- data.file_checked %> /> File:</label>'+
@@ -153,16 +156,16 @@ require([
153156
'</div>'+
154157
'</div>'+
155158
'<div class="row">'+
156-
'<label for="downloadable_link_<%- data.id %>_url_type"><input type="radio" class="radio validate-one-required-by-name" id="downloadable_link_<%- data.id %>_url_type" name="downloadable[link][<%- data.id %>][type]" value="url"<%- data.url_checked %> /> URL:</label><input type="text" class="validate-downloadable-url validate-url input-text" name="downloadable[link][<%- data.id %>][link_url]" value="<%- data.link_url %>" />'+
159+
'<label for="downloadable_link_<%- data.id %>_url_type"><input type="radio" class="radio validate-one-required-by-name" id="downloadable_link_<%- data.id %>_url_type" name="downloadable[link][<%- data.id %>][type]" value="url"<%- data.url_checked %> /> URL:</label><input type="text" class="validate-downloadable-url validate-url input-text admin__control-text" name="downloadable[link][<%- data.id %>][link_url]" value="<%- data.link_url %>" />'+
157160
'</div>'+
158161
'<div>'+
159162
'<span id="downloadable_link_<%- data.id %>_link_container"></span>'+
160163
'</div>'+
161164
'</div>'+
162165
'</td>'+
163-
'<td><input type="text" name="downloadable[link][<%- data.id %>][sort_order]" value="<%- data.sort_order %>" class="input-text sort" /></td>'+
164-
'<td class="col-delete">'+
165-
'<button id="downloadable_link_<%- data.id %>_delete_button" type="button" class="action- scalable delete delete-link-item"><span><span><span><?php echo __('Delete'); ?></span></span></span></button>'+
166+
'<td class="col-sort"><input type="text" name="downloadable[link][<%- data.id %>][sort_order]" value="<%- data.sort_order %>" class="input-text admin__control-text sort" /></td>'+
167+
'<td class="col-action">'+
168+
'<button id="downloadable_link_<%- data.id %>_delete_button" type="button" class="action-remove"><span><?php echo __('Delete'); ?></span></button>'+
166169
'</td>'+
167170
'</tr>';
168171

@@ -309,7 +312,7 @@ require([
309312
}
310313
},
311314
bindRemoveButtons : function(){
312-
var buttons = $$('tbody#link_items_body .delete-link-item');
315+
var buttons = $$('tbody#link_items_body .action-remove');
313316
for(var i=0;i<buttons.length;i++){
314317
if(!$(buttons[i]).binded && !$(buttons[i]).hasClassName('disabled')){
315318
$(buttons[i]).binded = true;
@@ -351,7 +354,7 @@ require([
351354
if ($(id + ' .progressbar-container').length) {
352355
$(id + ' .progressbar-container').parent().remove();
353356
}
354-
357+
355358
fileSize = typeof file.size == "undefined" ?
356359
$.mage.__('We could not detect a size.') :
357360
byteConvert(file.size);

0 commit comments

Comments
 (0)