Skip to content

Commit 9a178de

Browse files
author
Oleksii Korshenko
authored
Merge pull request #5027 from magento-engcom/adobe-stock-integration-fix-1
[Magento Community Engineering] Adobe Stock Integration Bug Fixes
2 parents d52117c + 4c7ff1e commit 9a178de

File tree

8 files changed

+157
-9
lines changed

8 files changed

+157
-9
lines changed

app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ define([
1010

1111
return Column.extend({
1212
defaults: {
13+
bodyTmpl: 'ui/grid/columns/image-preview',
1314
previewImageSelector: '[data-image-preview]',
1415
visibleRecord: null,
1516
height: 0,
1617
displayedRecord: {},
1718
lastOpenedImage: null,
19+
fields: {
20+
previewUrl: 'preview_url',
21+
title: 'title'
22+
},
1823
modules: {
1924
masonry: '${ $.parentName }',
2025
thumbnailComponent: '${ $.parentName }.thumbnail_url'
@@ -154,6 +159,26 @@ define([
154159
return this.visibleRecord() === record._rowIndex || false;
155160
},
156161

162+
/**
163+
* Returns preview image url for a given record.
164+
*
165+
* @param {Object} record
166+
* @return {String}
167+
*/
168+
getUrl: function (record) {
169+
return record[this.fields.previewUrl];
170+
},
171+
172+
/**
173+
* Returns image title for a given record.
174+
*
175+
* @param {Object} record
176+
* @return {String}
177+
*/
178+
getTitle: function (record) {
179+
return record[this.fields.title];
180+
},
181+
157182
/**
158183
* Get styles for preview
159184
*

app/code/Magento/Ui/view/base/web/js/grid/columns/image.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ define([
99

1010
return Column.extend({
1111
defaults: {
12+
bodyTmpl: 'ui/grid/columns/image',
1213
modules: {
1314
previewComponent: '${ $.parentName }.preview'
1415
},

app/code/Magento/Ui/view/base/web/js/grid/columns/overlay.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ define([
88
'use strict';
99

1010
return Column.extend({
11+
defaults: {
12+
bodyTmpl: 'ui/grid/columns/overlay'
13+
},
14+
1115
/**
1216
* If overlay should be visible
1317
*

app/code/Magento/Ui/view/base/web/js/grid/masonry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ define([
1313

1414
return Listing.extend({
1515
defaults: {
16-
template: 'Magento_Ui/grid/masonry',
16+
template: 'ui/grid/masonry',
1717
imports: {
1818
rows: '${ $.provider }:data.items',
1919
errorMessage: '${ $.provider }:data.errorMessage'

app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/_module.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
// */
55

66
@import 'module/_data-grid.less';
7+
@import 'module/_masonry-grid.less';
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// /**
2+
// * Copyright © Magento, Inc. All rights reserved.
3+
// * See COPYING.txt for license details.
4+
// */
5+
@admin__masonry_grid_image__space: 20px;
6+
@admin__masonry_grid_background_color: #fff;
7+
@admin__masonry_overlay_background_color: #507dc8;
8+
9+
& when (@media-common = true) {
10+
.masonry-image {
11+
&-grid {
12+
margin: @admin__masonry_grid_image__space/2 -(@admin__masonry_grid_image__space/2);
13+
overflow: hidden;
14+
position: relative;
15+
16+
.no-data-message-container,
17+
.error-message-container {
18+
font-size: @data-grid__no-records__font-size;
19+
padding: @data-grid__no-records__padding;
20+
text-align: center;
21+
}
22+
}
23+
24+
&-column {
25+
background-color: @admin__masonry_grid_background_color;
26+
float: left;
27+
margin: @admin__masonry_grid_image__space/2;
28+
overflow: hidden;
29+
30+
img {
31+
cursor: pointer;
32+
height: 100%;
33+
width: 100%;
34+
}
35+
}
36+
37+
&-overlay {
38+
background-color: @admin__masonry_overlay_background_color;
39+
color: @admin__masonry_grid_background_color;
40+
opacity: 1;
41+
padding: .5rem;
42+
position: absolute;
43+
text-align: center;
44+
width: 80px;
45+
z-index: 10;
46+
}
47+
48+
&-preview {
49+
background-color: @admin__masonry_grid_background_color;
50+
display: table;
51+
left: 0;
52+
position: absolute;
53+
right: 0;
54+
width: 100%;
55+
56+
.container {
57+
margin: auto;
58+
max-width: 880px;
59+
padding-top: 10px;
60+
61+
.action-buttons {
62+
text-align: right;
63+
64+
.action {
65+
&-close {
66+
padding: 30px;
67+
position: static;
68+
}
69+
70+
&-previous,
71+
&-next {
72+
background: transparent;
73+
border: none;
74+
margin: 0;
75+
white-space: nowrap;
76+
}
77+
78+
&-close,
79+
&-previous,
80+
&-next {
81+
font-size: 2rem;
82+
}
83+
}
84+
}
85+
86+
.preview-row-content {
87+
display: flex;
88+
89+
&:after {
90+
clear: both;
91+
content: '';
92+
display: table;
93+
}
94+
95+
img.preview {
96+
display: block;
97+
flex-basis: 300px;
98+
float: left;
99+
margin-bottom: 20px;
100+
max-height: 500px;
101+
max-width: 60%;
102+
width: auto;
103+
}
104+
}
105+
}
106+
}
107+
}
108+
}

lib/web/mage/adminhtml/browser.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ define([
1111
'Magento_Ui/js/modal/prompt',
1212
'Magento_Ui/js/modal/confirm',
1313
'Magento_Ui/js/modal/alert',
14+
'underscore',
1415
'Magento_Ui/js/modal/modal',
1516
'jquery/ui',
1617
'jquery/jstree/jquery.jstree',
1718
'mage/mage'
18-
], function ($, wysiwyg, prompt, confirm, alert) {
19+
], function ($, wysiwyg, prompt, confirm, alert, _) {
1920
window.MediabrowserUtility = {
2021
windowId: 'modal_dialog_message',
2122
modalLoaded: false,
@@ -52,16 +53,21 @@ define([
5253
content = '<div class="popup-window" id="' + windowId + '"></div>',
5354
self = this;
5455

55-
if (this.modalLoaded === true &&
56-
options &&
56+
if (options &&
5757
self.targetElementId &&
58-
self.targetElementId === options.targetElementId
59-
) {
58+
self.targetElementId === options.targetElementId) {
6059
if (typeof options.closed !== 'undefined') {
6160
this.modal.modal('option', 'closed', options.closed);
6261
}
6362
this.modal.modal('openModal');
6463

64+
return;
65+
} else if (_.isUndefined(options) &&
66+
self.modalLoaded === true &&
67+
self.targetElementId === url
68+
) {
69+
this.modal.modal('openModal');
70+
6571
return;
6672
}
6773

@@ -89,8 +95,11 @@ define([
8995
}).done(function (data) {
9096
self.modal.html(data).trigger('contentUpdated');
9197
self.modalLoaded = true;
92-
self.targetElementId = options.targetElementId;
98+
self.targetElementId = options ?
99+
options.targetElementId
100+
: url;
93101
});
102+
94103
},
95104

96105
/**
@@ -487,7 +496,7 @@ define([
487496
var nodeData = $(element).data('node');
488497

489498
if (index > 0) {
490-
breadcrumbs.append($('<li>\/</li>'));
499+
breadcrumbs.append($('<li>\/</li>')); //eslint-disable-line
491500
}
492501
breadcrumbs.append($('<li />')
493502
.data('node', nodeData).attr('data-row', 'breadcrumb').text(nodeData.text));

lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ define([
375375
*/
376376
openFileBrowser: function (o) {
377377
var typeTitle = this.translate('Select Images'),
378-
storeId = this.config['store_id'] !== null ? this.config['store_id'] : 0,
378+
storeId = this.config['store_id'] ? this.config['store_id'] : 0,
379379
frameDialog = jQuery('div.mce-container[role="dialog"]'),
380380
self = this,
381381
wUrl = this.config['files_browser_window_url'] +

0 commit comments

Comments
 (0)