This repository was archived by the owner on Apr 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +58
-27
lines changed
Controller/Adminhtml/Product
adminhtml/web/js/components
frontend/templates/category/widget/link
templates/grid/filters/elements Expand file tree Collapse file tree 5 files changed +58
-27
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ public function execute() : \Magento\Framework\Controller\ResultInterface
76
76
$ productCollection = $ this ->productCollectionFactory ->create ();
77
77
$ productCollection ->addAttributeToSelect (ProductInterface::NAME );
78
78
$ productCollection ->setVisibility ($ this ->catalogVisibility ->getVisibleInCatalogIds ());
79
+ $ productCollection ->setPage ($ pageNum , $ limit );
79
80
$ this ->addFilter ($ productCollection , 'fulltext ' , $ searchKey );
80
81
$ totalVaues = $ productCollection ->getSize ();
81
82
$ productCollection ->setPage ($ pageNum , $ limit );
Original file line number Diff line number Diff line change @@ -12,23 +12,20 @@ define([
12
12
13
13
return Select . extend ( {
14
14
defaults : {
15
- validationUrl : false
15
+ validationUrl : false ,
16
+ loadedOption : [ ] ,
17
+ validationLoading : true
16
18
} ,
17
19
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 ( ) ;
25
23
26
- if ( this . validationUrl && _ . isEmpty ( options ) ) {
24
+ if ( this . value ( ) ) {
27
25
$ . ajax ( {
28
26
url : this . validationUrl ,
29
27
type : 'GET' ,
30
28
dataType : 'json' ,
31
- async : false ,
32
29
context : this ,
33
30
data : {
34
31
productId : this . value ( )
@@ -37,15 +34,35 @@ define([
37
34
/** @param {Object } response */
38
35
success : function ( response ) {
39
36
if ( ! _ . isEmpty ( response ) ) {
40
- options = [ response ] ;
37
+ this . options ( [ response ] ) ;
38
+ this . loadedOption = response ;
41
39
}
42
40
} ,
43
41
44
42
/** set empty array if error occurs */
45
43
error : function ( ) {
46
- options = [ ] ;
44
+ this . options ( [ ] ) ;
45
+ } ,
46
+
47
+ /** stop loader */
48
+ complete : function ( ) {
49
+ this . validationLoading ( false ) ;
50
+ this . setCaption ( ) ;
47
51
}
48
52
} ) ;
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 ;
49
66
}
50
67
51
68
return options ;
Original file line number Diff line number Diff line change 6
6
7
7
// @codingStandardsIgnoreFile
8
8
/** @var Magento\Catalog\Block\Widget\Link $block */
9
+ // @codingStandardsIgnoreFile
9
10
?>
10
11
<?= $ block ->escapeHtml ($ block ->getHref ()) ?>
Original file line number Diff line number Diff line change @@ -175,6 +175,7 @@ define([
175
175
cachedSearchResults : { } ,
176
176
pageLimit : 50 ,
177
177
deviation : 30 ,
178
+ validationLoading : false ,
178
179
isRemoveSelectedIcon : true ,
179
180
missingValuePlaceholder : $t ( 'Entity with ID: %s doesn\'t exist' ) ,
180
181
isDisplayMissingValuePlaceholder : false ,
@@ -322,7 +323,9 @@ define([
322
323
'itemsQuantity' ,
323
324
'filterInputValue' ,
324
325
'filterOptionsFocus' ,
325
- 'loading'
326
+ 'loading' ,
327
+ 'validationLoading' ,
328
+ 'isDisplayMissingValuePlaceholder'
326
329
] ) ;
327
330
328
331
this . filterInputValue . extend ( {
Original file line number Diff line number Diff line change 42
42
}
43
43
">
44
44
< 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 >
50
68
</ 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 >
60
69
</ div >
61
70
<!-- /ko -->
62
71
<!-- ko if: chipsEnabled -->
You can’t perform that action at this time.
0 commit comments