Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 440ab6b

Browse files
committed
MAGETWO-89670: Introduce Product Link type
- fix after review
1 parent 749f0b8 commit 440ab6b

File tree

5 files changed

+58
-27
lines changed

5 files changed

+58
-27
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Search.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public function execute() : \Magento\Framework\Controller\ResultInterface
7676
$productCollection = $this->productCollectionFactory->create();
7777
$productCollection->addAttributeToSelect(ProductInterface::NAME);
7878
$productCollection->setVisibility($this->catalogVisibility->getVisibleInCatalogIds());
79+
$productCollection->setPage($pageNum, $limit);
7980
$this->addFilter($productCollection, 'fulltext', $searchKey);
8081
$totalVaues = $productCollection->getSize();
8182
$productCollection->setPage($pageNum, $limit);

app/code/Magento/Catalog/view/adminhtml/web/js/components/product-ui-select.js

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,20 @@ define([
1212

1313
return Select.extend({
1414
defaults: {
15-
validationUrl: false
15+
validationUrl: false,
16+
loadedOption: [],
17+
validationLoading: true
1618
},
1719

18-
/**
19-
* Get selected element labels
20-
*
21-
* @returns {Array} array labels
22-
*/
23-
getSelected: function () {
24-
var options = this._super();
20+
/** @inheritdoc */
21+
initialize: function () {
22+
this._super();
2523

26-
if (this.validationUrl && _.isEmpty(options)) {
24+
if (this.value()) {
2725
$.ajax({
2826
url: this.validationUrl,
2927
type: 'GET',
3028
dataType: 'json',
31-
async: false,
3229
context: this,
3330
data: {
3431
productId: this.value()
@@ -37,15 +34,35 @@ define([
3734
/** @param {Object} response */
3835
success: function (response) {
3936
if (!_.isEmpty(response)) {
40-
options = [response];
37+
this.options([response]);
38+
this.loadedOption = response;
4139
}
4240
},
4341

4442
/** set empty array if error occurs */
4543
error: function () {
46-
options = [];
44+
this.options([]);
45+
},
46+
47+
/** stop loader */
48+
complete: function () {
49+
this.validationLoading(false);
50+
this.setCaption();
4751
}
4852
});
53+
} else {
54+
this.validationLoading(false);
55+
}
56+
57+
return this;
58+
},
59+
60+
/** @inheritdoc */
61+
getSelected: function () {
62+
var options = this._super();
63+
64+
if (!_.isEmpty(this.loadedOption)) {
65+
return this.value() === this.loadedOption.value ? [this.loadedOption] : options;
4966
}
5067

5168
return options;

app/code/Magento/Catalog/view/frontend/templates/category/widget/link/link_href.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66

77
// @codingStandardsIgnoreFile
88
/** @var Magento\Catalog\Block\Widget\Link $block */
9+
// @codingStandardsIgnoreFile
910
?>
1011
<?= $block->escapeHtml($block->getHref()) ?>

app/code/Magento/Ui/view/base/web/js/form/element/ui-select.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ define([
175175
cachedSearchResults: {},
176176
pageLimit: 50,
177177
deviation: 30,
178+
validationLoading: false,
178179
isRemoveSelectedIcon: true,
179180
missingValuePlaceholder: $t('Entity with ID: %s doesn\'t exist'),
180181
isDisplayMissingValuePlaceholder: false,
@@ -322,7 +323,9 @@ define([
322323
'itemsQuantity',
323324
'filterInputValue',
324325
'filterOptionsFocus',
325-
'loading'
326+
'loading',
327+
'validationLoading',
328+
'isDisplayMissingValuePlaceholder'
326329
]);
327330

328331
this.filterInputValue.extend({

app/code/Magento/Ui/view/base/web/templates/grid/filters/elements/ui-select.html

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,30 @@
4242
}
4343
">
4444
<div class="admin__action-multiselect-text"
45-
data-role="selected-option"
46-
data-bind="
47-
css: {warning: warn().length},
48-
text: setCaption()
49-
">
45+
data-role="selected-option"
46+
ifnot="validationLoading"
47+
data-bind="
48+
css: {warning: warn().length},
49+
text: setCaption()
50+
">
51+
</div>
52+
<button if="isRemoveSelectedIcon && hasData() || !validationLoading"
53+
class="action-close"
54+
type="button"
55+
data-action="remove-selected-item"
56+
tabindex="-1"
57+
click="clear"
58+
>
59+
<span class="action-close-text" translate="'Close'"></span>
60+
</button>
61+
<div data-role="spinner"
62+
class="admin__data-grid-loading-mask"
63+
visible="validationLoading"
64+
if="validationLoading">
65+
<div class="spinner">
66+
<span repeat="8"/>
67+
</div>
5068
</div>
51-
<button if="isRemoveSelectedIcon && hasData()"
52-
class="action-close"
53-
type="button"
54-
data-action="remove-selected-item"
55-
tabindex="-1"
56-
click="clear"
57-
>
58-
<span class="action-close-text" translate="'Close'"></span>
59-
</button>
6069
</div>
6170
<!-- /ko -->
6271
<!-- ko if: chipsEnabled -->

0 commit comments

Comments
 (0)