-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#1515: Add keywords field to the edit image description slide panel #1605
Merged
sivaschenko
merged 23 commits into
magento:2.0-develop
from
joweecaquicla:1515-add-keywords-field-to-edit-image
Aug 2, 2020
Merged
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
84de736
magento/adobe-stock-integration#1515: Add keywords field to the edit …
507f503
magento/adobe-stock-integration#1515: Add keywords field to the edit …
b3baefd
magento/adobe-stock-integration#1515: Add keywords field to the edit …
69ebfbb
Merge branch '2.0-develop' of github.com:magento/adobe-stock-integrat…
sivaschenko e91c4be
magento/adobe-stock-integration#1605: Using the default ui-select com…
sivaschenko 9bf8ac6
Merge branch '2.0-develop' into 1515-add-keywords-field-to-edit-image
sivaschenko 4b670d9
Merge branch '2.0-develop' into 1515-add-keywords-field-to-edit-image
sivaschenko 837ded8
magento/adobe-stock-integration#1605: Added keywords to submit form data
sivaschenko daa221f
magento/adobe-stock-integration#1515: MFTF test coverage
sivaschenko 23b5a79
Merge branch '2.0-develop' into 1515-add-keywords-field-to-edit-image
sivaschenko f41bee6
Merge branch '2.0-develop' into 1515-add-keywords-field-to-edit-image
sivaschenko 75940bb
Fixed static tests
sivaschenko dcd8913
magento/adobe-stock-integration#1605: Added validation
sivaschenko 8282e1e
magento/adobe-stock-integration#1605: Moved generic config to compone…
sivaschenko 2b9f86b
Merge branch '2.0-develop' into 1515-add-keywords-field-to-edit-image
sivaschenko 5307a5d
Fixed static tests
sivaschenko 50f5d8c
Merge branch '2.0-develop' of github.com:magento/adobe-stock-integrat…
sivaschenko b9aa0c1
Updated bindings
sivaschenko 2eca30e
Fixed static tests
sivaschenko 2fe992c
Merge branch '2.0-develop' into 1515-add-keywords-field-to-edit-image
sivaschenko 8c4c01e
Fixed static tests
sivaschenko d27bfd5
Fixed tests for embedded media gallery
sivaschenko 90c7bec
Merge branch '2.0-develop' into 1515-add-keywords-field-to-edit-image
sivaschenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
MediaGalleryUi/view/adminhtml/web/js/image/edit/keyword-ui-select.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
define([ | ||
'Magento_Ui/js/form/element/ui-select', | ||
'jquery', | ||
'underscore' | ||
], function (Select, $, _) { | ||
'use strict'; | ||
|
||
return Select.extend({ | ||
defaults: { | ||
template: 'Magento_MediaGalleryUi/image/edit/keyword-ui-select', | ||
label: 'Keywords', | ||
image: {} | ||
}, | ||
|
||
/** @inheritdoc */ | ||
initialize: function () { | ||
this._super(); | ||
return this; | ||
}, | ||
|
||
getKeywordsOp: function () { | ||
var imageTags = this.image.tags, | ||
option = []; | ||
|
||
imageTags.forEach(function (tag) { | ||
option.push({ | ||
label: tag, | ||
value: tag | ||
}); | ||
}); | ||
|
||
this.options(option); | ||
}, | ||
|
||
addLastElement: function (data) { | ||
|
||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,9 @@ define([ | |
'jquery', | ||
'underscore', | ||
'uiComponent', | ||
'uiLayout', | ||
'Magento_MediaGalleryUi/js/action/getDetails' | ||
], function ($, _, Component, getDetails) { | ||
], function ($, _, Component, layout, getDetails) { | ||
'use strict'; | ||
|
||
return Component.extend({ | ||
|
@@ -20,10 +21,42 @@ define([ | |
images: [], | ||
image: null, | ||
modules: { | ||
mediaGridMessages: '${ $.mediaGridMessages }' | ||
mediaGridMessages: '${ $.mediaGridMessages }', | ||
select: '${ $.name }_select' | ||
}, | ||
viewConfig: [ | ||
{ | ||
component: 'Magento_MediaGalleryUi/js/image/edit/keyword-ui-select', | ||
name: '${ $.name }_select' | ||
} | ||
], | ||
exports: { | ||
image: '${ $.name }_select:image' | ||
} | ||
}, | ||
|
||
/** | ||
* Initialize the component | ||
* | ||
* @returns {Object} | ||
*/ | ||
initialize: function () { | ||
this._super().initView(); | ||
|
||
return this; | ||
}, | ||
|
||
/** | ||
* Initialize child components | ||
* | ||
* @returns {Object} | ||
*/ | ||
initView: function () { | ||
layout(this.viewConfig); | ||
|
||
return this; | ||
}, | ||
|
||
/** | ||
* Init observable variables | ||
* | ||
|
@@ -49,6 +82,7 @@ define([ | |
this.images[imageId] = imageDetails[imageId]; | ||
this.image(this.images[imageId]); | ||
this.openEditImageDetailsModal(); | ||
this.getKeywordsOp(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid this call, simply make sure the keywords component is rendering options based on the imported image |
||
}.bind(this)).fail(function (message) { | ||
this.addMediaGridMessage('error', message); | ||
}.bind(this)); | ||
|
@@ -91,6 +125,10 @@ define([ | |
modalElement.modal('closeModal'); | ||
}, | ||
|
||
getKeywordsOp: function() { | ||
this.select().getKeywordsOp(); | ||
}, | ||
|
||
/** | ||
* Add media grid message | ||
* | ||
|
216 changes: 216 additions & 0 deletions
216
MediaGalleryUi/view/adminhtml/web/template/image/edit/keyword-ui-select.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<!-- ko ifnot: disableLabel --> | ||
<label | ||
class="admin__form-field-label" | ||
data-bind="attr: {for: uid} | ||
"> | ||
<span translate="label"></span> | ||
</label> | ||
<!-- /ko --> | ||
<div | ||
class="admin__action-multiselect-wrap action-select-wrap" | ||
tabindex="0" | ||
data-bind=" | ||
attr: { | ||
id: uid | ||
}, | ||
css: { | ||
_active: listVisible, | ||
'admin__action-multiselect-tree': isTree() | ||
}, | ||
event: { | ||
focusin: onFocusIn, | ||
focusout: onFocusOut, | ||
keydown: keydownSwitcher | ||
}, | ||
outerClick: outerClick.bind($data) | ||
"> | ||
<!-- ko ifnot: chipsEnabled --> | ||
<div | ||
class="action-select admin__action-multiselect" | ||
data-role="advanced-select" | ||
data-bind=" | ||
css: {_active: listVisible}, | ||
click: function(data, event) { | ||
toggleListVisible(data, event) | ||
} | ||
"> | ||
<div class="admin__action-multiselect-text" | ||
data-role="selected-option" | ||
ifnot="validationLoading" | ||
data-bind=" | ||
css: {warning: warn().length}, | ||
text: setCaption() | ||
"> | ||
</div> | ||
<button if="isRemoveSelectedIcon && hasData() || !validationLoading" | ||
class="action-close" | ||
type="button" | ||
data-action="remove-selected-item" | ||
tabindex="-1" | ||
click="clear" | ||
> | ||
<span class="action-close-text" translate="'Close'"></span> | ||
</button> | ||
<div data-role="spinner" | ||
class="admin__data-grid-loading-mask" | ||
visible="validationLoading" | ||
if="validationLoading"> | ||
<div class="spinner"> | ||
<span repeat="8"/> | ||
</div> | ||
</div> | ||
</div> | ||
<!-- /ko --> | ||
<!-- ko if: chipsEnabled --> | ||
<div | ||
class="action-select admin__action-multiselect" | ||
data-role="advanced-select" | ||
data-bind=" | ||
css: {_active: listVisible}, | ||
click: function(data, event) { | ||
toggleListVisible(data, event) | ||
} | ||
"> | ||
<div class="admin__action-multiselect-text" | ||
data-bind=" | ||
visible: !hasData(), | ||
i18n: selectedPlaceholders.defaultPlaceholder | ||
"> | ||
</div> | ||
<!-- ko foreach: { data: getSelected(), as: 'option'} --> | ||
<span class="admin__action-multiselect-crumb"> | ||
<span data-bind="text: label"> | ||
</span> | ||
<button | ||
class="action-close" | ||
type="button" | ||
data-action="remove-selected-item" | ||
tabindex="-1" | ||
data-bind="click: $parent.removeSelected.bind($parent, value) | ||
"> | ||
<span class="action-close-text" translate="'Close'"></span> | ||
</button> | ||
</span> | ||
<!-- /ko --> | ||
</div> | ||
<!-- /ko --> | ||
<div class="action-menu" css="{ _active: listVisible}"> | ||
<div data-role="spinner" | ||
class="admin__data-grid-loading-mask" | ||
visible="loading" | ||
if="loading"> | ||
<div class="spinner"> | ||
<span repeat="8"/> | ||
</div> | ||
</div> | ||
<!-- ko if: filterOptions --> | ||
<div class="admin__action-multiselect-search-wrap"> | ||
<input | ||
class="admin__control-text admin__action-multiselect-search" | ||
data-role="advanced-select-text" | ||
type="text" | ||
data-bind=" | ||
event: { | ||
keydown: filterOptionsKeydown | ||
}, | ||
attr: { | ||
id: uid+2, | ||
placeholder: filterPlaceholder | ||
}, | ||
valueUpdate: 'afterkeydown', | ||
value: filterInputValue, | ||
hasFocus: filterOptionsFocus | ||
"> | ||
<label | ||
class="admin__action-multiselect-search-label" | ||
data-action="advanced-select-search" | ||
data-bind="attr: {for: uid+2} | ||
"> | ||
</label> | ||
<div if="itemsQuantity" | ||
data-bind="text: itemsQuantity" | ||
class="admin__action-multiselect-search-count"> | ||
</div> | ||
</div> | ||
<div ifnot="options().length" | ||
class="admin__action-multiselect-empty-area"> | ||
<ul data-bind="html: emptyOptionsHtml"/> | ||
</div> | ||
<!-- /ko --> | ||
<ul class="admin__action-multiselect-menu-inner _root" | ||
data-bind=" | ||
event: { | ||
mousemove: function(data, event){onMousemove($data, $index(), event)}, | ||
scroll: function(data, event){onScrollDown(data, event)} | ||
} | ||
"> | ||
<!-- ko foreach: { data: options, as: 'option'} --> | ||
<li class="admin__action-multiselect-menu-inner-item _root" | ||
data-bind="css: { _parent: $data.optgroup }" | ||
data-role="option-group"> | ||
<div class="action-menu-item" | ||
data-bind=" | ||
css: { | ||
_selected: $parent.isSelectedValue(option), | ||
_hover: $parent.isHovered(option, $element), | ||
_expended: $parent.getLevelVisibility($data) && $parent.showLevels($data), | ||
_unclickable: $parent.isLabelDecoration($data), | ||
_last: $parent.addLastElement($data), | ||
'_with-checkbox': $parent.showCheckbox | ||
}, | ||
click: function(data, event){ | ||
$parent.toggleOptionSelected($data, $index(), event); | ||
}, | ||
clickBubble: false | ||
"> | ||
<!-- ko if: $data.optgroup && $parent.showOpenLevelsActionIcon--> | ||
<div class="admin__action-multiselect-dropdown" | ||
data-bind=" | ||
click: function(event){ | ||
$parent.showLevels($data); | ||
$parent.openChildLevel($data, $element, event); | ||
}, | ||
clickBubble: false | ||
"> | ||
</div> | ||
<!-- /ko--> | ||
<!--ko if: $parent.showCheckbox--> | ||
<input | ||
class="admin__control-checkbox" | ||
type="checkbox" | ||
tabindex="-1" | ||
data-bind="attr: { 'checked': $parent.isSelected(option.value) }"> | ||
<!-- /ko--> | ||
<label class="admin__action-multiselect-label"> | ||
<span data-bind="text: option.label"></span> | ||
<span | ||
if="$parent.getPath(option)" | ||
class="admin__action-multiselect-item-path" | ||
data-bind="text: $parent.getPath(option)"></span> | ||
</label> | ||
</div> | ||
<!-- ko if: $data.optgroup --> | ||
<!-- ko template: {name: $parent.optgroupTmpl, data: {root: $parent, current: $data}} --> | ||
<!-- /ko --> | ||
<!-- /ko--> | ||
</li> | ||
<!-- /ko --> | ||
</ul> | ||
<!-- ko if: $data.closeBtn --> | ||
<div class="admin__action-multiselect-actions-wrap"> | ||
<button class="action-default" | ||
data-action="close-advanced-select" | ||
type="button" | ||
data-bind="click: outerClick"> | ||
<span translate="closeBtnLabel"></span> | ||
</button> | ||
</div> | ||
<!-- /ko --> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use a more specific name for the keywords field/select