Update .gitignore
|  | @ -50,7 +50,7 @@ return [ | |||
|         ] | ||||
|     ], | ||||
|     'x-frame-options' => 'SAMEORIGIN', | ||||
|     'MAGE_MODE' => 'default', | ||||
|     'MAGE_MODE' => 'developer', | ||||
|     'session' => [ | ||||
|         'save' => 'files' | ||||
|     ], | ||||
|  |  | |||
|  | @ -1 +0,0 @@ | |||
| @import url("https://use.typekit.net/onr8tbr.css");@media (prefers-color-scheme:dark){table{border-collapse:collapse;margin:0 auto}a,a:visited{color:#1473e6;text-decoration:none}.legal a{text-decoration:underline}a[x-apple-data-detectors]{color:inherit !important;font-family:inherit !important;font-size:inherit !important;font-weight:inherit !important;line-height:inherit !important;text-decoration:none !important}}@media only screen and (max-width:480px){u~div{min-width:100vw}div>u~div{min-width:100%}.email-width,.email-width-400{width:84% !important}.full-width{width:100% !important}}.full-width{width:600px}.email-width{width:500px}.email-width-400{width:400px}.width-100{width:100%}.background-grey{background-color:#e4e4e4}.background-light{background-color:#f5f5f5}.padding-top-0{padding-top:0 !important}.padding-top-25{padding-top:25px}.padding-top-40{padding-top:40px}.padding-top-50{padding-top:40px}.email-body{-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:none;background-color:#e4e4e4;margin:0;padding:0;width:100% !important}.email-preview{color:#e4e4e4;display:none;font-size:1px;overflow:hidden;visibility:hidden}.email-header-container{background-color:#fff;border-top:4px solid #eb1000;padding-bottom:60px}.email-logo{color:#eb1000;font-family:adobe-clean,Helvetica Neue,Helvetica,Verdana,Arial,sans-serif;font-size:12px;line-height:18px}.email-logo img{color:#eb1000;display:block;font-family:adobe-clean,Helvetica Neue,Helvetica,Verdana,Arial,sans-serif;font-size:12px;height:50px;line-height:18px;vertical-align:top}.email-footer-legal{color:#959595;font-family:adobe-clean,Helvetica Neue,Helvetica,Verdana,Arial,sans-serif;font-size:16px;line-height:32px;padding-top:60px}.email-footer-legal a{color:#959595;text-decoration:underline}.email-footer-copyright{color:#959595;font-family:adobe-clean,Helvetica Neue,Helvetica,Verdana,Arial,sans-serif;font-size:11px;line-height:18px;padding-bottom:50px;padding-top:50px}.email-subject{color:#000;font-family:adobe-clean,Helvetica Neue,Helvetica,Verdana,Arial,sans-serif;font-size:23px;line-height:30px;padding-top:50px}.email-text{color:#2c2c2c;font-family:adobe-clean,Helvetica Neue,Helvetica,Verdana,Arial,sans-serif;font-size:18px;line-height:26px;padding-top:25px}.cta-button-container{color:#1473e6;font-family:adobe-clean,Helvetica Neue,Helvetica,Verdana,Arial,sans-serif;font-size:16px;line-height:20px;padding-bottom:40px;padding-top:40px}.cta-button{-webkit-text-size-adjust:none;background-color:#1473e6;border-radius:20px;color:#fff;display:inline-block;font-size:16px;line-height:40px;text-align:center;text-decoration:none;width:200px}.cta-button-mso{font-size:0;line-height:0;margin:0}.email-information-link{color:#1473e6;text-decoration:none} | ||||
| Before Width: | Height: | Size: 1.8 MiB | 
| Before Width: | Height: | Size: 5.7 MiB | 
| Before Width: | Height: | Size: 5.2 KiB | 
| Before Width: | Height: | Size: 7.1 KiB | 
| Before Width: | Height: | Size: 22 KiB | 
| Before Width: | Height: | Size: 954 KiB | 
|  | @ -1,16 +0,0 @@ | |||
| @import 'node_modules/@spectrum-css/vars/dist/spectrum-global.css'; | ||||
| @import 'node_modules/@spectrum-css/vars/dist/spectrum-medium.css'; | ||||
| @import 'node_modules/@spectrum-css/vars/dist/spectrum-large.css'; | ||||
| @import 'node_modules/@spectrum-css/vars/dist/spectrum-light.css'; | ||||
| @import 'node_modules/@spectrum-css/vars/dist/spectrum-lightest.css'; | ||||
| @import 'node_modules/@spectrum-css/vars/dist/spectrum-dark.css'; | ||||
| @import 'node_modules/@spectrum-css/vars/dist/spectrum-darkest.css'; | ||||
| @import 'node_modules/@spectrum-css/page/dist/index-vars.css'; | ||||
| @import 'node_modules/@spectrum-css/icon/dist/index-vars.css'; | ||||
| @import 'node_modules/@spectrum-css/button/dist/index-vars.css'; | ||||
| @import 'node_modules/@spectrum-css/dialog/dist/index-vars.css'; | ||||
| @import 'node_modules/@spectrum-css/link/dist/index-vars.css'; | ||||
| @import 'node_modules/@spectrum-css/modal/dist/index-vars.css'; | ||||
| @import 'node_modules/@spectrum-css/card/dist/index-vars.css'; | ||||
| @import 'node_modules/@spectrum-css/typography/dist/index-vars.css'; | ||||
| @import 'node_modules/@spectrum-css/inlinealert/dist/index-vars.css'; | ||||
|  | @ -1,38 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| /** | ||||
|  * @api | ||||
|  */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'underscore', | ||||
|     'Magento_AdminAdobeIms/js/loadicons' | ||||
| ], function ($, _, loadicons) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     var icons = {}, | ||||
| 
 | ||||
|     loadIcons = { | ||||
|         /** | ||||
|          * loadicons initialization | ||||
|          */ | ||||
|         init: function () { | ||||
|             loadicons(icons.spectrumCssIcons); | ||||
|             loadicons(icons.spectrumIcons); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @param {Object} iconUrls | ||||
|          * @constructor | ||||
|          */ | ||||
|         'Magento_AdminAdobeIms/js/admin_adobe_ims_load_icons': function (iconUrls) { | ||||
|             icons = iconUrls; | ||||
|             loadIcons.init(); | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     return loadIcons; | ||||
| }); | ||||
|  | @ -1,67 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'uiComponent', | ||||
|     'jquery', | ||||
|     'Magento_AdobeIms/js/action/authorization' | ||||
| ], function (Component, $, login) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Component.extend({ | ||||
|         defaults: { | ||||
|             loginConfig: { | ||||
|                 url: 'https://ims-na1-stg.adobelogin.com/ims/authorize', | ||||
|                 callbackParsingParams: { | ||||
|                     regexpPattern: /auth\[code=(success|error);message=(.+)\]/, | ||||
|                     codeIndex: 1, | ||||
|                     messageIndex: 2, | ||||
|                     nameIndex: 3, | ||||
|                     successCode: 'success', | ||||
|                     errorCode: 'error' | ||||
|                 }, | ||||
|                 popupWindowParams: { | ||||
|                     width: 500, | ||||
|                     height: 600, | ||||
|                     top: 100, | ||||
|                     left: 300 | ||||
|                 }, | ||||
|                 popupWindowTimeout: 60000 | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @override | ||||
|          */ | ||||
|         initialize: function () { | ||||
|             this._super(); | ||||
|             this.login(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Open popup for Adobe reauth | ||||
|          * | ||||
|          * @return {window.Promise} | ||||
|          */ | ||||
|         login: function () { | ||||
|             var deferred = $.Deferred(), | ||||
|                 loginConfig = this.loginConfig; | ||||
| 
 | ||||
|             $('input.ims_verification').on('click', function () { | ||||
|                 login(loginConfig) | ||||
|                     .then(function (response) { | ||||
|                         if (response.isAuthorized === true) { | ||||
|                             $('input.ims_verified').val(true); | ||||
|                         } | ||||
|                         deferred.resolve(response); | ||||
|                     }) | ||||
|                     .fail(function (error) { | ||||
|                         deferred.reject(error); | ||||
|                     }); | ||||
|             }); | ||||
| 
 | ||||
|             return deferred.promise(); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,90 +0,0 @@ | |||
| /* | ||||
| Copyright 2018 Adobe. All rights reserved. | ||||
| This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||||
| you may not use this file except in compliance with the License. You may obtain a copy | ||||
| of the License at http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| 
 | ||||
| Unless required by applicable law or agreed to in writing, software distributed under | ||||
| the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||||
| OF ANY KIND, either express or implied. See the License for the specific language | ||||
| governing permissions and limitations under the License. | ||||
| */ | ||||
| 
 | ||||
| // UMD pattern via umdjs
 | ||||
| (function (root, factory) { | ||||
|   if (typeof define === 'function' && define.amd) { | ||||
|     // AMD
 | ||||
|     define([], factory); | ||||
|   } | ||||
|   else if (typeof module === 'object' && module.exports) { | ||||
|     // CommonJS-like
 | ||||
|     module.exports = factory(); | ||||
|   } | ||||
|   else { | ||||
|     // Browser
 | ||||
|     root.loadIcons = factory(); | ||||
|   } | ||||
| }(typeof self !== 'undefined' ? self : this, function() { | ||||
|   function handleError(string) { | ||||
|     string = 'loadIcons: '+string; | ||||
|     var error = new Error(string); | ||||
| 
 | ||||
|     console.error(error.toString()); | ||||
| 
 | ||||
|     if (typeof callback === 'function') { | ||||
|       callback(error); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   function injectSVG(svgURL, callback) { | ||||
|     var error; | ||||
|     // 200 for web servers, 0 for CEP panels
 | ||||
|     if (this.status !== 200 && this.status !== 0) { | ||||
|       handleError('Failed to fetch icons, server returned ' + this.status); | ||||
|       return; | ||||
|     } | ||||
| 
 | ||||
|     // Parse the SVG
 | ||||
|     var parser = new DOMParser(); | ||||
|     try { | ||||
|       var doc = parser.parseFromString(this.responseText, 'image/svg+xml'); | ||||
|       var svg = doc.firstChild; | ||||
|     } | ||||
|     catch (err) { | ||||
|       handleError('Error parsing SVG: ' + err); | ||||
|       return; | ||||
|     } | ||||
| 
 | ||||
|     // Make sure a real SVG was returned
 | ||||
|     if (svg && svg.tagName === 'svg') { | ||||
|       // Hide the element
 | ||||
|       svg.style.display = 'none'; | ||||
| 
 | ||||
|       svg.setAttribute('data-url', svgURL); | ||||
| 
 | ||||
|       // Insert it into the head
 | ||||
|       document.head.insertBefore(svg, null); | ||||
| 
 | ||||
|       // Pass the SVG to the callback
 | ||||
|       if (typeof callback === 'function') { | ||||
|         callback(null, svg); | ||||
|       } | ||||
|     } | ||||
|     else { | ||||
|       handleError('Parsed SVG document contained something other than an SVG'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   function loadIcons(svgURL, callback) { | ||||
|     // Request the SVG sprite
 | ||||
|     var req = new XMLHttpRequest(); | ||||
|     req.open('GET', svgURL, true); | ||||
|     req.addEventListener('load', injectSVG.bind(req, svgURL, callback)); | ||||
|     req.addEventListener('error', function(event) { | ||||
|       handleError('Request failed'); | ||||
|     }); | ||||
|     req.send(); | ||||
|   } | ||||
| 
 | ||||
|   return loadIcons; | ||||
| })); | ||||
|  | @ -1,41 +0,0 @@ | |||
| { | ||||
|   "name": "magento_adminadobeims", | ||||
|   "version": "1.0.0", | ||||
|   "description": "", | ||||
|   "main": "index.js", | ||||
|   "scripts": { | ||||
|     "test": "echo \"Error: no test specified\" && exit 1" | ||||
|   }, | ||||
|   "author": "", | ||||
|   "license": "ISC", | ||||
|   "dependencies": { | ||||
|     "@adobe/spectrum-css-workflow-icons": "^1.2.1", | ||||
|     "@spectrum-css/actionbutton": "^1.1.5", | ||||
|     "@spectrum-css/asset": "^3.0.13", | ||||
|     "@spectrum-css/button": "^6.0.3", | ||||
|     "@spectrum-css/buttongroup": "^5.0.3", | ||||
|     "@spectrum-css/card": "^4.0.12", | ||||
|     "@spectrum-css/checkbox": "^3.0.14", | ||||
|     "@spectrum-css/closebutton": "^1.2.2", | ||||
|     "@spectrum-css/dialog": "^6.0.2", | ||||
|     "@spectrum-css/divider": "^1.0.16", | ||||
|     "@spectrum-css/icon": "^3.0.14", | ||||
|     "@spectrum-css/inlinealert": "^4.0.3", | ||||
|     "@spectrum-css/link": "^3.1.17", | ||||
|     "@spectrum-css/modal": "^3.0.13", | ||||
|     "@spectrum-css/page": "^5.0.2", | ||||
|     "@spectrum-css/quickaction": "^3.0.16", | ||||
|     "@spectrum-css/typography": "^4.0.11", | ||||
|     "@spectrum-css/underlay": "^2.0.22", | ||||
|     "@spectrum-css/vars": "^6.1.1", | ||||
|     "loadicons": "^1.0.0" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "cssnano": "^5.0.17", | ||||
|     "postcss": "^8.4.7", | ||||
|     "postcss-cli": "^9.1.0", | ||||
|     "postcss-dropunusedvars": "^1.2.1", | ||||
|     "postcss-import": "^14.0.2", | ||||
|     "postcss-varfallback": "^1.1.1" | ||||
|   } | ||||
| } | ||||
|  | @ -1,8 +0,0 @@ | |||
| module.exports = { | ||||
|     plugins: [ | ||||
|         require('postcss-import'), | ||||
|         require('postcss-varfallback'), | ||||
|         require('postcss-dropunusedvars'), | ||||
|         require('cssnano') | ||||
|     ] | ||||
| }; | ||||
|  | @ -1,14 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <button | ||||
|     class="adobe-sign-in-button" | ||||
|     id="adobeImsSignIn" | ||||
|     data-role="signInBtn" | ||||
|     data-bind="click: login" | ||||
|     type="button"> | ||||
|     <span>Sign In</span> | ||||
| </button> | ||||
|  | @ -1,187 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define([ | ||||
|     'underscore', | ||||
|     'jquery', | ||||
|     'Magento_Ui/js/modal/modal-component', | ||||
|     'uiRegistry', | ||||
|     'analyticsPopupConfig' | ||||
| ], | ||||
|     function (_, $, Modal, registry, analyticsPopupConfig) { | ||||
|         'use strict'; | ||||
| 
 | ||||
|         return Modal.extend( | ||||
|             { | ||||
|                 defaults: { | ||||
|                     imports: { | ||||
|                         enableLogAction: '${ $.provider }:data.enableLogAction', | ||||
|                         disableLogAction: '${ $.provider }:data.disableLogAction' | ||||
|                     }, | ||||
|                     options: {}, | ||||
|                     notificationWindow: null | ||||
|                 }, | ||||
| 
 | ||||
|                 /** | ||||
|                  * Initializes modal on opened function | ||||
|                  */ | ||||
|                 initModal: function () { | ||||
|                     this.options.opened = this.onOpened.bind(this); | ||||
|                     this._super(); | ||||
|                 }, | ||||
| 
 | ||||
|                 /** | ||||
|                  * Configure ESC and TAB so user can't leave modal | ||||
|                  * without selecting an option | ||||
|                  * | ||||
|                  * @returns {Object} Chainable. | ||||
|                  */ | ||||
|                 initModalEvents: function () { | ||||
|                     this._super(); | ||||
|                     //Don't allow ESC key to close modal
 | ||||
|                     this.options.keyEventHandlers.escapeKey = this.handleEscKey.bind(this); | ||||
|                     //Restrict tab action to the modal
 | ||||
|                     this.options.keyEventHandlers.tabKey = this.handleTabKey.bind(this); | ||||
| 
 | ||||
|                     return this; | ||||
|                 }, | ||||
| 
 | ||||
|                 /** | ||||
|                  * Once the modal is opened it hides the X | ||||
|                  */ | ||||
|                 onOpened: function () { | ||||
|                     $('.modal-header button.action-close').attr('disabled', true).hide(); | ||||
| 
 | ||||
|                     this.focusableElements = $(this.rootSelector).find('a[href], button:enabled'); | ||||
|                     this.firstFocusableElement = this.focusableElements[0]; | ||||
|                     this.lastFocusableElement = this.focusableElements[this.focusableElements.length - 1]; | ||||
|                     this.firstFocusableElement.focus(); | ||||
|                 }, | ||||
| 
 | ||||
|                 /** | ||||
|                  * Changes admin usage setting to yes | ||||
|                  */ | ||||
|                 enableAdminUsage: function () { | ||||
|                     var data = { | ||||
|                         'form_key': window.FORM_KEY | ||||
|                     }; | ||||
| 
 | ||||
|                     $.ajax( | ||||
|                         { | ||||
|                             type: 'POST', | ||||
|                             url: this.enableLogAction, | ||||
|                             data: data, | ||||
|                             showLoader: true | ||||
|                         } | ||||
|                     ).done( | ||||
|                         function (xhr) { | ||||
|                             if (xhr.error) { | ||||
|                                 self.onError(xhr); | ||||
|                             } | ||||
|                         } | ||||
|                     ).fail(this.onError); | ||||
|                     this.openReleasePopup(); | ||||
|                     this.closeModal(); | ||||
|                 }, | ||||
| 
 | ||||
|                 /** | ||||
|                  * Changes admin usage setting to no | ||||
|                  */ | ||||
|                 disableAdminUsage: function () { | ||||
|                     var data = { | ||||
|                         'form_key': window.FORM_KEY | ||||
|                     }; | ||||
| 
 | ||||
|                     $.ajax( | ||||
|                         { | ||||
|                             type: 'POST', | ||||
|                             url: this.disableLogAction, | ||||
|                             data: data, | ||||
|                             showLoader: true | ||||
|                         } | ||||
|                     ).done( | ||||
|                         function (xhr) { | ||||
|                             if (xhr.error) { | ||||
|                                 self.onError(xhr); | ||||
|                             } | ||||
|                         } | ||||
|                     ).fail(this.onError); | ||||
|                     this.openReleasePopup(); | ||||
|                     this.closeModal(); | ||||
|                 }, | ||||
| 
 | ||||
|                 /** | ||||
|                  * Allows admin usage popup to be shown first and then new release notification | ||||
|                  */ | ||||
|                 openReleasePopup: function () { | ||||
|                     var notificationModalSelector = 'release_notification.release_notification.notification_modal_1'; | ||||
| 
 | ||||
|                     if (analyticsPopupConfig.releaseVisible) { | ||||
|                         registry.get(notificationModalSelector).initializeContentAfterAnalytics(); | ||||
|                     } | ||||
|                 }, | ||||
| 
 | ||||
|                 /** | ||||
|                  * Handle Tab and Shift+Tab key event | ||||
|                  * | ||||
|                  * Keep the tab actions restricted to the popup modal | ||||
|                  * so the user must select an option to dismiss the modal | ||||
|                  */ | ||||
|                 handleTabKey: function (event) { | ||||
|                     var modal = this, | ||||
|                         KEY_TAB = 9; | ||||
| 
 | ||||
|                     /** | ||||
|                      * Handle Shift+Tab to tab backwards | ||||
|                      */ | ||||
|                     function handleBackwardTab() { | ||||
|                         if (document.activeElement === modal.firstFocusableElement || | ||||
|                             document.activeElement === $(modal.rootSelector)[0] | ||||
|                         ) { | ||||
|                             event.preventDefault(); | ||||
|                             modal.lastFocusableElement.focus(); | ||||
|                         } | ||||
|                     } | ||||
| 
 | ||||
|                     /** | ||||
|                      * Handle Tab forward | ||||
|                      */ | ||||
|                     function handleForwardTab() { | ||||
|                         if (document.activeElement === modal.lastFocusableElement) { | ||||
|                             event.preventDefault(); | ||||
|                             modal.firstFocusableElement.focus(); | ||||
|                         } | ||||
|                     } | ||||
| 
 | ||||
|                     switch (event.keyCode) { | ||||
|                         case KEY_TAB: | ||||
|                             if (modal.focusableElements.length === 1) { | ||||
|                                 event.preventDefault(); | ||||
|                                 break; | ||||
|                             } | ||||
| 
 | ||||
|                             if (event.shiftKey) { | ||||
|                                 handleBackwardTab(); | ||||
|                                 break; | ||||
|                             } | ||||
|                             handleForwardTab(); | ||||
|                             break; | ||||
|                         default: | ||||
|                             break; | ||||
|                     } | ||||
|                 }, | ||||
| 
 | ||||
|                 /** | ||||
|                  * Handle Esc key | ||||
|                  * | ||||
|                  * Esc key should not close modal | ||||
|                  */ | ||||
|                 handleEscKey: function (event) { | ||||
|                     event.preventDefault(); | ||||
|                 } | ||||
|             } | ||||
|         ); | ||||
|     } | ||||
| ); | ||||
|  | @ -1,39 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define(['jquery', 'analyticsPopupConfig'], function ($, analyticsPopupConfig) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     var deferred = $.Deferred(), | ||||
| 
 | ||||
|         mixin = { | ||||
|         /** | ||||
|          * Initializes content only if its visible | ||||
|          */ | ||||
|         initializeContent: function () { | ||||
|             var initializeContent = this._super.bind(this); | ||||
| 
 | ||||
|             if (!analyticsPopupConfig.analyticsVisible) { | ||||
|                 initializeContent(); | ||||
|             } else { | ||||
|                 deferred.then(function () { | ||||
|                     initializeContent(); | ||||
|                 }); | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Initializes release notification content after admin analytics | ||||
|          */ | ||||
|         initializeContentAfterAnalytics: function () { | ||||
|             deferred.resolve(); | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     return function (target) { | ||||
|         return target.extend(mixin); | ||||
|     }; | ||||
| }); | ||||
| 
 | ||||
|  | @ -1,60 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| /** | ||||
|  * @api | ||||
|  */ | ||||
| define([ | ||||
|     'Magento_Ui/js/grid/columns/column', | ||||
|     'underscore' | ||||
| ], function (Column, _) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Column.extend({ | ||||
|         defaults: { | ||||
|             bodyTmpl: 'Magento_AdminNotification/grid/cells/message', | ||||
|             messageIndex: 'text', | ||||
|             fieldClass: { | ||||
|                 message: true, | ||||
|                 'message-warning': false, | ||||
|                 'message-progress': false, | ||||
|                 'message-success': false, | ||||
|                 'message-error': false | ||||
|             }, | ||||
|             statusMap: { | ||||
|                 0: 'info', | ||||
|                 1: 'progress', | ||||
|                 2: 'success', | ||||
|                 3: 'error' | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** @inheritdoc */ | ||||
|         getLabel: function (record) { | ||||
|             return record[this.messageIndex]; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Proxy to getLabel function with UnsanitizedHtml suffix | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          * @returns {String} | ||||
|          */ | ||||
|         getLabelUnsanitizedHtml: function (record) { | ||||
|             return this.getLabel(record); | ||||
|         }, | ||||
| 
 | ||||
|         /** @inheritdoc */ | ||||
|         getFieldClass: function ($row) { | ||||
|             var status = this.statusMap[$row.status] || 'warning', | ||||
|                 result = {}; | ||||
| 
 | ||||
|             result['message-' + status] = true; | ||||
|             result = _.extend({}, this.fieldClass, result); | ||||
| 
 | ||||
|             return result; | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,66 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| /** | ||||
|  * @api | ||||
|  */ | ||||
| define([ | ||||
|     'Magento_Ui/js/grid/listing', | ||||
|     'Magento_Ui/js/lib/spinner', | ||||
|     'jquery' | ||||
| ], function (Listing, loader, $) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Listing.extend({ | ||||
|         defaults: { | ||||
|             imports: { | ||||
|                 totalRecords: '${ $.provider }:data.totalRecords' | ||||
|             }, | ||||
|             selectors: { | ||||
|                 collapsible: '.message-system-collapsible', | ||||
|                 messages: '.message-system' | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** @inheritdoc */ | ||||
|         initObservable: function () { | ||||
|             this._super() | ||||
|                 .track({ | ||||
|                     totalRecords: 0 | ||||
|                 }); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** @inheritdoc */ | ||||
|         showLoader: function () { | ||||
|             if (!this.source.firstLoad) { | ||||
|                 this.fixLoaderHeight(); | ||||
|                 this._super(); | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Calculates loader height | ||||
|          * | ||||
|          * @param {Boolean} [closed] | ||||
|          */ | ||||
|         fixLoaderHeight: function (closed) { | ||||
|             var $messagesBlock = $(this.selectors.messages), | ||||
|                 $collapsibleBlock = $(this.selectors.collapsible), | ||||
|                 resultHeight = 0; | ||||
| 
 | ||||
|             if ($messagesBlock.length) { | ||||
|                 resultHeight += $messagesBlock.outerHeight(); | ||||
|             } | ||||
| 
 | ||||
|             if ($collapsibleBlock.length && $collapsibleBlock.is(':visible') && !closed) { | ||||
|                 resultHeight += $collapsibleBlock.outerHeight(); | ||||
|             } | ||||
| 
 | ||||
|             loader.get(this.name).height(resultHeight); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,26 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define([ | ||||
|     'jquery', | ||||
|     'Magento_Ui/js/modal/modal' | ||||
| ], function ($, modal) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return function (data, element) { | ||||
| 
 | ||||
|         if (modal.modal) { | ||||
|             modal.modal.html($(element).html()); | ||||
|         } else { | ||||
|             modal.modal = $(element).modal({ | ||||
|                 modalClass: data.class, | ||||
|                 type: 'popup', | ||||
|                 buttons: [] | ||||
|             }); | ||||
|         } | ||||
| 
 | ||||
|         modal.modal.modal('openModal'); | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,83 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| /** | ||||
|  * @api | ||||
|  */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'mage/template', | ||||
|     'jquery/ui', | ||||
|     'Magento_Ui/js/modal/modal' | ||||
| ], function ($, mageTemplate) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     $.widget('mage.systemMessageDialog', $.mage.modal, { | ||||
|         options: { | ||||
|             modalClass: 'modal-system-messages', | ||||
|             systemMessageTemplate: | ||||
|                 '<% _.each(data.items, function(item) { %>' + | ||||
|                     '<li class="message message-warning' + | ||||
|                         '<% if (item.severity == 1) { %>error<% } else { %>warning<% } %>">' + | ||||
|                         '<%= item.text %>' + | ||||
|                     '</li>' + | ||||
|                 '<% }); %>' | ||||
|         }, | ||||
| 
 | ||||
|         /** @inheritdoc */ | ||||
|         _create: function () { | ||||
|             this.options.title = $('#message-system-all').attr('title'); | ||||
|             this._super(); | ||||
|         }, | ||||
| 
 | ||||
|         /** @inheritdoc */ | ||||
|         openModal: function (severity) { | ||||
|             var superMethod = $.proxy(this._super, this); | ||||
| 
 | ||||
|             $.ajax({ | ||||
|                 url: this.options.ajaxUrl, | ||||
|                 type: 'GET', | ||||
|                 data: { | ||||
|                     severity: severity | ||||
|                 } | ||||
|             }).done($.proxy(function (data) { | ||||
|                 var tmpl = mageTemplate(this.options.systemMessageTemplate, { | ||||
|                     data: { | ||||
|                         items: data | ||||
|                     } | ||||
|                 }); | ||||
| 
 | ||||
|                 tmpl = $(tmpl); | ||||
| 
 | ||||
|                 this.element.html( | ||||
|                     $('<ul></ul>', { | ||||
|                         'class': 'message-system-list' | ||||
|                     }).append(tmpl) | ||||
|                 ).trigger('contentUpdated'); | ||||
| 
 | ||||
|                 superMethod(); | ||||
|             }, this)); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** @inheritdoc */ | ||||
|         closeModal: function () { | ||||
|             this._super(); | ||||
|         } | ||||
|     }); | ||||
| 
 | ||||
|     $(function () { | ||||
|         $('#system_messages .message-system-short .error').on('click', function () { | ||||
|             $('#message-system-all').systemMessageDialog('openModal', 1); | ||||
|         }); | ||||
| 
 | ||||
|         $('#system_messages .message-system-short .warning').on('click', function () { | ||||
|             $('#message-system-all').systemMessageDialog('openModal', 2); | ||||
|         }); | ||||
|     }); | ||||
| 
 | ||||
|     return $.mage.systemMessageDialog; | ||||
| }); | ||||
|  | @ -1,8 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <div css="$col.getFieldClass($row())" | ||||
|      html="$col.getLabelUnsanitizedHtml($row())"></div> | ||||
|  | @ -1,32 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <div id="system_messages" class="message-system" collapsible visible="totalRecords"> | ||||
|     <div class="message-system-inner" outerClick="fixLoaderHeight.bind($data, true)"> | ||||
|         <div class="message-system-short"> | ||||
|             <button class="message-system-action-dropdown" toggleCollapsible> | ||||
|                 <span> | ||||
|                     <translate args="'System Messages'"></translate>: | ||||
|                     <text args="totalRecords"></text> | ||||
|                 </span> | ||||
|             </button> | ||||
|             <div class="message-system-short-wrapper" if="rows[0]" repeat="foreach: [rows[0]], item: '$row'" visible="!$collapsible.opened()"> | ||||
|                 <fastForEach args="data: getVisible(), as: '$col'" > | ||||
|                     <render args="$col.getBody()"></render> | ||||
|                 </fastForEach> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="message-system-collapsible"> | ||||
|             <ul class="message-system-list"> | ||||
|                 <li repeat="foreach: rows, item: '$row'"> | ||||
|                     <fastForEach args="data: getVisible(), as: '$col'" > | ||||
|                         <render args="$col.getBody()"></render> | ||||
|                     </fastForEach> | ||||
|                 </li> | ||||
|             </ul> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
|  | @ -1,121 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| /** | ||||
|  * @api | ||||
|  */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'jquery/ui', | ||||
|     'domReady!' | ||||
| ], function ($) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     /** | ||||
|      * Mark notification as read via AJAX call. | ||||
|      * | ||||
|      * @param {String} notificationId | ||||
|      */ | ||||
|     var markNotificationAsRead = function (notificationId) { | ||||
|             var requestUrl = $('.notifications-wrapper .admin__action-dropdown-menu').attr('data-mark-as-read-url'); | ||||
| 
 | ||||
|             $.ajax({ | ||||
|                 url: requestUrl, | ||||
|                 type: 'POST', | ||||
|                 dataType: 'json', | ||||
|                 data: { | ||||
|                     id: notificationId | ||||
|                 }, | ||||
|                 showLoader: false | ||||
|             }); | ||||
|         }, | ||||
|         notificationCount = $('.notifications-wrapper').attr('data-notification-count'), | ||||
| 
 | ||||
|         /** | ||||
|          * Remove notification from the list. | ||||
|          * | ||||
|          * @param {jQuery} notificationEntry | ||||
|          */ | ||||
|         removeNotificationFromList = function (notificationEntry) { | ||||
|             var notificationIcon, actionElement; | ||||
| 
 | ||||
|             notificationEntry.remove(); | ||||
|             notificationCount--; | ||||
|             $('.notifications-wrapper').attr('data-notification-count', notificationCount); | ||||
| 
 | ||||
|             if (notificationCount == 0) {// eslint-disable-line eqeqeq
 | ||||
|                 // Change appearance of the bubble and its behavior when the last notification is removed
 | ||||
|                 $('.notifications-wrapper .admin__action-dropdown-menu').remove(); | ||||
|                 notificationIcon = $('.notifications-wrapper .notifications-icon'); | ||||
|                 notificationIcon.removeAttr('data-toggle'); | ||||
|                 notificationIcon.off('click.dropdown'); | ||||
|                 $('.notifications-action .notifications-counter').text('').hide(); | ||||
|             } else { | ||||
|                 // Change top counter only for allowable range
 | ||||
|                 if (notificationCount <= 99) { | ||||
|                     $('.notifications-action .notifications-counter').text(notificationCount); | ||||
|                 } | ||||
|                 $('.notifications-entry-last .notifications-counter').text(notificationCount); | ||||
|                 // Modify caption of the 'See All' link
 | ||||
|                 actionElement = $('.notifications-wrapper .admin__action-dropdown-menu .last .action-more'); | ||||
|                 actionElement.text(actionElement.text().replace(/\d+/, notificationCount)); | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Show notification details. | ||||
|          * | ||||
|          * @param {jQuery} notificationEntry | ||||
|          */ | ||||
|         showNotificationDetails = function (notificationEntry) { | ||||
|             var notificationDescription = notificationEntry.find('.notifications-entry-description'), | ||||
|                 notificationDescriptionEnd = notificationEntry.find('.notifications-entry-description-end'); | ||||
| 
 | ||||
|             if (notificationDescriptionEnd.length > 0) { | ||||
|                 notificationDescriptionEnd.addClass('_show'); | ||||
|             } | ||||
| 
 | ||||
|             if (notificationDescription.hasClass('_cutted')) { | ||||
|                 notificationDescription.removeClass('_cutted'); | ||||
|             } | ||||
|         }; | ||||
| 
 | ||||
|     // Show notification description when corresponding item is clicked
 | ||||
|     $('.notifications-wrapper .admin__action-dropdown-menu .notifications-entry').on( | ||||
|         'click.showNotification', | ||||
|         function (event) { | ||||
|             // hide notification dropdown
 | ||||
|             $('.notifications-wrapper .notifications-icon').trigger('click.dropdown'); | ||||
| 
 | ||||
|             showNotificationDetails($(this)); | ||||
|             event.stopPropagation(); | ||||
|         } | ||||
|     ); | ||||
| 
 | ||||
|     // Remove corresponding notification from the list and mark it as read
 | ||||
|     $('.notifications-close').on('click.removeNotification', function (event) { | ||||
|         var notificationEntry = $(this).closest('.notifications-entry'), | ||||
|             notificationId = notificationEntry.attr('data-notification-id'); | ||||
| 
 | ||||
|         markNotificationAsRead(notificationId); | ||||
|         removeNotificationFromList(notificationEntry); | ||||
| 
 | ||||
|         // Checking for last unread notification to hide dropdown
 | ||||
|         if (notificationCount == 0) {// eslint-disable-line eqeqeq
 | ||||
|             $('.notifications-wrapper').removeClass('active') | ||||
|                 .find('.notifications-action') | ||||
|                 .removeAttr('data-toggle') | ||||
|                 .off('click.dropdown'); | ||||
|         } | ||||
|         event.stopPropagation(); | ||||
|     }); | ||||
| 
 | ||||
|     // Hide notifications bubble
 | ||||
|     if (notificationCount == 0) {// eslint-disable-line eqeqeq
 | ||||
|         $('.notifications-action .notifications-counter').hide(); | ||||
|     } else { | ||||
|         $('.notifications-action .notifications-counter').show(); | ||||
|     } | ||||
| }); | ||||
|  | @ -1,132 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define([ | ||||
|     'jquery' | ||||
| ], function ($) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     /** | ||||
|      * Build window params | ||||
|      * @param {Object} windowParams | ||||
|      * @returns {String} | ||||
|      */ | ||||
|     function buildWindowParams(windowParams) { | ||||
|         var output = '', | ||||
|             coma = '', | ||||
|             paramName, | ||||
|             paramValue; | ||||
| 
 | ||||
|         for (paramName in windowParams) { | ||||
|             if (windowParams[paramName]) { | ||||
|                 paramValue = windowParams[paramName]; | ||||
|                 output += coma + paramName + '=' + paramValue; | ||||
|                 coma = ','; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         return output; | ||||
|     } | ||||
| 
 | ||||
|     return function (config) { | ||||
|         var authWindow, | ||||
|             deferred = $.Deferred(), | ||||
|             watcherId, | ||||
|             stopWatcherId; | ||||
| 
 | ||||
|         /** | ||||
|          * Close authorization window if already opened | ||||
|          */ | ||||
|         if (window.adobeIMSAuthWindow) { | ||||
|             window.adobeIMSAuthWindow.close(); | ||||
|         } | ||||
| 
 | ||||
|         /** | ||||
|          * Opens authorization window with special parameters | ||||
|          */ | ||||
|         authWindow = window.adobeIMSAuthWindow = window.open( | ||||
|             config.url, | ||||
|             'authorization_widnow', | ||||
|             buildWindowParams( | ||||
|                 config.popupWindowParams || { | ||||
|                     width: 500, | ||||
|                     height: 300 | ||||
|                 } | ||||
|             ) | ||||
|         ); | ||||
| 
 | ||||
|         /** | ||||
|          * Stop handle | ||||
|          */ | ||||
|         function stopHandle() { | ||||
|             // Clear timers
 | ||||
|             clearTimeout(stopWatcherId); | ||||
|             clearInterval(watcherId); | ||||
| 
 | ||||
|             // Close window
 | ||||
|             authWindow.close(); | ||||
|         } | ||||
| 
 | ||||
|         /** | ||||
|          * Start handle | ||||
|          */ | ||||
|         function startHandle() { | ||||
|             var responseData; | ||||
| 
 | ||||
|             try { | ||||
| 
 | ||||
|                 if (authWindow.document.domain !== document.domain || | ||||
|                     authWindow.document.readyState !== 'complete') { | ||||
|                     return; | ||||
|                 } | ||||
| 
 | ||||
|                 /** | ||||
|                  * If within 10 seconds the result is not received, then reject the request | ||||
|                  */ | ||||
|                 stopWatcherId = setTimeout(function () { | ||||
|                     stopHandle(); | ||||
|                     deferred.reject(new Error('Time\'s up.')); | ||||
|                 }, config.popupWindowTimeout || 60000); | ||||
| 
 | ||||
|                 responseData = authWindow.document.body.innerHTML.match( | ||||
|                     config.callbackParsingParams.regexpPattern | ||||
|                 ); | ||||
| 
 | ||||
|                 if (!responseData) { | ||||
|                     return; | ||||
|                 } | ||||
| 
 | ||||
|                 stopHandle(); | ||||
| 
 | ||||
|                 if (responseData[config.callbackParsingParams.codeIndex] === | ||||
|                     config.callbackParsingParams.successCode) { | ||||
|                     deferred.resolve({ | ||||
|                         isAuthorized: true, | ||||
|                         lastAuthSuccessMessage: responseData[config.callbackParsingParams.messageIndex] | ||||
|                     }); | ||||
|                 } else { | ||||
|                     deferred.reject(responseData[config.callbackParsingParams.messageIndex]); | ||||
|                 } | ||||
|             } catch (e) { | ||||
|                 if (authWindow.closed) { | ||||
|                     clearTimeout(stopWatcherId); | ||||
|                     clearInterval(watcherId); | ||||
| 
 | ||||
|                     // eslint-disable-next-line max-depth
 | ||||
|                     if (window.adobeIMSAuthWindow && window.adobeIMSAuthWindow.closed) { | ||||
|                         deferred.reject(new Error('Authentication window was closed.')); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /** | ||||
|          * Watch a result 1 time per second | ||||
|          */ | ||||
|         watcherId = setInterval(startHandle, 1000); | ||||
| 
 | ||||
|         return deferred.promise(); | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,32 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([], function () { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return { | ||||
|         loginUrl: 'https://ims-na1.adobelogin.com/ims/authorize', | ||||
|         profileUrl: 'adobe_ims/user/profile', | ||||
|         logoutUrl: 'adobe_ims/user/logout', | ||||
|         manageAccountLink: 'https://account.adobe.com/', | ||||
|         login: { | ||||
|             callbackParsingParams: { | ||||
|                 regexpPattern: /auth\[code=(success|error);message=(.+)\]/, | ||||
|                 codeIndex: 1, | ||||
|                 messageIndex: 2, | ||||
|                 nameIndex: 3, | ||||
|                 successCode: 'success', | ||||
|                 errorCode: 'error' | ||||
|             }, | ||||
|             popupWindowParams: { | ||||
|                 width: 500, | ||||
|                 height: 600, | ||||
|                 top: 100, | ||||
|                 left: 300 | ||||
|             }, | ||||
|             popupWindowTimeout: 10000 | ||||
|         } | ||||
|     }; | ||||
| }); | ||||
| 
 | ||||
|  | @ -1,143 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'uiComponent', | ||||
|     'jquery', | ||||
|     'Magento_AdobeIms/js/action/authorization' | ||||
| ], function (Component, $, login) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Component.extend({ | ||||
| 
 | ||||
|         defaults: { | ||||
|             profileUrl: 'adobe_ims/user/profile', | ||||
|             logoutUrl: 'adobe_ims/user/logout', | ||||
|             user: { | ||||
|                 isAuthorized: false, | ||||
|                 name: '', | ||||
|                 email: '', | ||||
|                 image: '' | ||||
|             }, | ||||
|             loginConfig: { | ||||
|                 url: 'https://ims-na1.adobelogin.com/ims/authorize', | ||||
|                 callbackParsingParams: { | ||||
|                     regexpPattern: /auth\[code=(success|error);message=(.+)\]/, | ||||
|                     codeIndex: 1, | ||||
|                     messageIndex: 2, | ||||
|                     nameIndex: 3, | ||||
|                     successCode: 'success', | ||||
|                     errorCode: 'error' | ||||
|                 }, | ||||
|                 popupWindowParams: { | ||||
|                     width: 500, | ||||
|                     height: 600, | ||||
|                     top: 100, | ||||
|                     left: 300 | ||||
|                 }, | ||||
|                 popupWindowTimeout: 60000 | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @inheritdoc | ||||
|          */ | ||||
|         initObservable: function () { | ||||
|             this._super().observe(['user']); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Login to Adobe | ||||
|          * | ||||
|          * @return {window.Promise} | ||||
|          */ | ||||
|         login: function () { | ||||
|             var deferred = $.Deferred(); | ||||
| 
 | ||||
|             if (this.user().isAuthorized) { | ||||
|                 deferred.resolve(); | ||||
|             } | ||||
|             login(this.loginConfig) | ||||
|                 .then(function (response) { | ||||
|                     this.loadUserProfile(); | ||||
|                     deferred.resolve(response); | ||||
|                 }.bind(this)) | ||||
|                 .fail(function (error) { | ||||
|                     deferred.reject(error); | ||||
|                 }); | ||||
| 
 | ||||
|             return deferred.promise(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Retrieve data to authorized user. | ||||
|          * | ||||
|          * @return array | ||||
|          */ | ||||
|         loadUserProfile: function () { | ||||
|             $.ajax({ | ||||
|                 type: 'GET', | ||||
|                 url: this.profileUrl, | ||||
|                 showLoader: true, | ||||
|                 dataType: 'json', | ||||
|                 context: this, | ||||
| 
 | ||||
|                 /** | ||||
|                  * @param {Object} response | ||||
|                  * @returns void | ||||
|                  */ | ||||
|                 success: function (response) { | ||||
|                     this.user({ | ||||
|                         isAuthorized: true, | ||||
|                         name: response.result.name, | ||||
|                         email: response.result.email, | ||||
|                         image: response.result.image | ||||
|                     }); | ||||
|                 }, | ||||
| 
 | ||||
|                 /** | ||||
|                  * @param {Object} response | ||||
|                  * @returns {String} | ||||
|                  */ | ||||
|                 error: function (response) { | ||||
|                     return response.message; | ||||
|                 } | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Logout from adobe account | ||||
|          */ | ||||
|         logout: function () { | ||||
|             $.ajax({ | ||||
|                 type: 'POST', | ||||
|                 url: this.logoutUrl, | ||||
|                 data: { | ||||
|                     'form_key': window.FORM_KEY | ||||
|                 }, | ||||
|                 dataType: 'json', | ||||
|                 context: this, | ||||
|                 showLoader: true, | ||||
|                 success: function () { | ||||
|                     this.user({ | ||||
|                         isAuthorized: false, | ||||
|                         name: '', | ||||
|                         email: '', | ||||
|                         image: '' | ||||
|                     }); | ||||
|                 }.bind(this), | ||||
| 
 | ||||
|                 /** | ||||
|                  * @param {Object} response | ||||
|                  * @returns {String} | ||||
|                  */ | ||||
|                 error: function (response) { | ||||
|                     return response.message; | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,13 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define(['ko'], function (ko) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return { | ||||
|         isAuthorized: ko.observable(false), | ||||
|         name: ko.observable(''), | ||||
|         email: ko.observable('') | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,50 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <button | ||||
|     class="adobe-sign-in-button" | ||||
|     id="adobeImsSignIn" | ||||
|     data-role="signInBtn" | ||||
|     data-bind="click: login, visible: !user().isAuthorized" | ||||
|     type="button"> | ||||
|     <span>Sign In</span> | ||||
| </button> | ||||
| <div class="adobe-user-information"> | ||||
|     <div class="admin__action-dropdown-wrap" data-bind="collapsible"> | ||||
|         <img class="adobe-profile-image-small" | ||||
|              attr="src: user().image" | ||||
|              data-bind="visible: user().isAuthorized"/> | ||||
|         <button | ||||
|             type="button" | ||||
|             data-toggle="dropdown" | ||||
|             class="adobe-user-name admin__action-dropdown" | ||||
|             data-bind="visible: user().isAuthorized, toggleCollapsible"> | ||||
|             <span><!--ko text: user().name--><!--/ko--></span> | ||||
|         </button> | ||||
|         <ul class="admin__action-dropdown-menu adobe-user-popup" data-bind="visible: user().isAuthorized"> | ||||
|             <li> | ||||
|                 <img class="adobe-profile-image-large" attr="src: user().image"> | ||||
|             </li> | ||||
|             <li class="adobe-user-info"> | ||||
|                 <ul> | ||||
|                     <li><!--ko text: user().name--><!--/ko--></li> | ||||
|                     <li><!--ko text: user().email--><!--/ko--></li> | ||||
|                     <li><a target="_blank" href="https://account.adobe.com/profile">Manage Account</a></li> | ||||
|                 </ul> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <button | ||||
|                         class="adobe-sign-out-button" | ||||
|                         id="adobeImsSignOut" | ||||
|                         data-bind="click: logout" | ||||
|                         data-role="signOutBtn" | ||||
|                         type="button"> | ||||
|                     <span>Sign Out</span> | ||||
|                 </button> | ||||
|             </li> | ||||
|         </ul> | ||||
|     </div> | ||||
| </div> | ||||
|  | @ -1,93 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'ko', | ||||
|     'uiComponent', | ||||
|     'jquery' | ||||
| ], function (ko, Component, $) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Component.extend({ | ||||
|         defaults: { | ||||
|             template: 'Magento_AdobeStockAdminUi/connection', | ||||
|             connectionFailedMessage: 'Connection test failed.', | ||||
|             emptyApiKeyMessage: 'Please fill the "API Key (Client ID)" field for a connection test', | ||||
|             apiKeyInputId: 'system_adobe_stock_integration_api_key', | ||||
|             url: '', | ||||
|             success: false, | ||||
|             message: '', | ||||
|             visible: false | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Init observable variables | ||||
|          * @return {Object} | ||||
|          */ | ||||
|         initObservable: function () { | ||||
|             this._super() | ||||
|                 .observe([ | ||||
|                     'success', | ||||
|                     'message', | ||||
|                     'visible' | ||||
|                 ]); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @override | ||||
|          */ | ||||
|         initialize: function () { | ||||
|             this._super(); | ||||
|             this.messageClass = ko.computed(function () { | ||||
|                 return 'message-validation message message-' + (this.success() ? 'success' : 'error'); | ||||
|             }, this); | ||||
| 
 | ||||
|             if (!this.success()) { | ||||
|                 this.showMessage(false, this.connectionFailedMessage); | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @param {bool} success | ||||
|          * @param {String} message | ||||
|          */ | ||||
|         showMessage: function (success, message) { | ||||
|             this.message(message); | ||||
|             this.success(success); | ||||
|             this.visible(true); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Send request to server to test connection to Adobe Stock API and display the result | ||||
|          */ | ||||
|         testConnection: function () { | ||||
|             var apiKey = document.getElementById(this.apiKeyInputId).value; | ||||
| 
 | ||||
|             if (apiKey.length === 0) { | ||||
|                 this.showMessage(false, this.emptyApiKeyMessage); | ||||
| 
 | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             this.visible(false); | ||||
| 
 | ||||
|             $.ajax({ | ||||
|                 type: 'POST', | ||||
|                 url: this.url, | ||||
|                 dataType: 'json', | ||||
|                 data: { | ||||
|                     'api_key': apiKey | ||||
|                 }, | ||||
|                 success: function (response) { | ||||
|                     this.showMessage(response.success === true, response.message); | ||||
|                 }.bind(this), | ||||
|                 error: function () { | ||||
|                     this.showMessage(false, this.connectionFailedMessage); | ||||
|                 }.bind(this) | ||||
|             }); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,10 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <div if="visible" attr="class: messageClass" translate="message"></div> | ||||
| <button class="scalable" type="button" click="testConnection" data-ui-id="adobe-stock-integration-buttons-test-connection"> | ||||
|     <span text="buttonLabel"></span> | ||||
| </button> | ||||
|  | @ -1,53 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'jquery' | ||||
| ], function ($) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return function (requestUrl, adobeAssetId) { | ||||
|         var deferred = $.Deferred(); | ||||
| 
 | ||||
|         $.ajax({ | ||||
|             type: 'GET', | ||||
|             url: requestUrl, | ||||
|             dataType: 'json', | ||||
|             data: { | ||||
|                 'media_id': adobeAssetId | ||||
|             }, | ||||
|             showLoader: true, | ||||
| 
 | ||||
|             /** | ||||
|              * Extract the data from the response and resolve | ||||
|              * | ||||
|              * @param {Object} response | ||||
|              */ | ||||
|             success: function (response) { | ||||
|                 deferred.resolve({ | ||||
|                     canLicense: response.result.canLicense, | ||||
|                     message: response.result.message | ||||
|                 }); | ||||
|             }, | ||||
| 
 | ||||
|             /** | ||||
|              * Extract the error message and reject | ||||
|              * | ||||
|              * @param {Object} response | ||||
|              */ | ||||
|             error: function (response) { | ||||
|                 var message = response.JSON ? response.JSON.message | ||||
|                     : $.mage.__('Could not fetch licensing information.'); | ||||
| 
 | ||||
|                 if (response.status === 403) { | ||||
|                     message = $.mage.__('Your admin role does not have permissions to license an image'); | ||||
|                 } | ||||
| 
 | ||||
|                 deferred.reject(message); | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         return deferred.promise(); | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,49 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'jquery' | ||||
| ], function ($) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return function (requestUrl, ids) { | ||||
|         var deferred = $.Deferred(); | ||||
| 
 | ||||
|         $.ajax({ | ||||
|             type: 'GET', | ||||
|             url: requestUrl + '?ids=' + ids.join(','), | ||||
|             data: { | ||||
|                 'form_key': window.FORM_KEY | ||||
|             }, | ||||
|             showLoader: true, | ||||
|             dataType: 'json', | ||||
| 
 | ||||
|             /** | ||||
|              * Resolve with the response result | ||||
|              * | ||||
|              * @param {Object} response | ||||
|              */ | ||||
|             success: function (response) { | ||||
|                 deferred.resolve(response.result); | ||||
|             }, | ||||
| 
 | ||||
|             /** | ||||
|              * Reject with the message from response | ||||
|              * | ||||
|              * @param {Object} response | ||||
|              */ | ||||
|             error: function (response) { | ||||
|                 var message = response.message; | ||||
| 
 | ||||
|                 if (response.status === 403) { | ||||
|                     message = $.mage.__('Your admin role does not have permissions to license an image'); | ||||
|                 } | ||||
| 
 | ||||
|                 deferred.reject(message); | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         return deferred.promise(); | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,55 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'Magento_AdobeStockImageAdminUi/js/action/save', | ||||
|     'Magento_AdobeStockImageAdminUi/js/confirmation/license', | ||||
|     'Magento_AdobeStockImageAdminUi/js/path-utility' | ||||
| ], function ($, saveAction, licenseConfirmation, pathUtility) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return function ( | ||||
|         requestUrl, | ||||
|         id, | ||||
|         title, | ||||
|         path, | ||||
|         contentType, | ||||
|         isDownloaded, | ||||
|         quotaMessage, | ||||
|         directoryPath | ||||
|     ) { | ||||
|         var deferred = $.Deferred(), | ||||
|             destinationPath; | ||||
| 
 | ||||
|         licenseConfirmation( | ||||
|                 title, | ||||
|                 quotaMessage, | ||||
|                 isDownloaded, | ||||
|                 pathUtility.generateImageName(title, id), | ||||
|                 pathUtility.getImageExtension(contentType) | ||||
|             ).then(function (fileName) { | ||||
| 
 | ||||
|                 if (typeof fileName === 'undefined') { | ||||
|                     fileName = pathUtility.getImageNameFromPath(path); | ||||
|                 } | ||||
| 
 | ||||
|                 destinationPath = pathUtility.buildPath(directoryPath, fileName, contentType); | ||||
| 
 | ||||
|                 saveAction( | ||||
|                     requestUrl, | ||||
|                     id, | ||||
|                     destinationPath | ||||
|                 ).then(function () { | ||||
|                     deferred.resolve(destinationPath); | ||||
|                 }).fail(function (message) { | ||||
|                     deferred.reject(message); | ||||
|                 }); | ||||
|             }).fail(function (error) { | ||||
|                 deferred.reject(error); | ||||
|             }); | ||||
| 
 | ||||
|         return deferred.promise(); | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,51 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'jquery' | ||||
| ], function ($) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return function (requestUrl, adobeAssetId, destinationPath) { | ||||
|         var deferred = $.Deferred(); | ||||
| 
 | ||||
|         $.ajax({ | ||||
|             type: 'POST', | ||||
|             url: requestUrl, | ||||
|             dataType: 'json', | ||||
|             showLoader: true, | ||||
|             data: { | ||||
|                 'media_id': adobeAssetId, | ||||
|                 'destination_path': destinationPath | ||||
|             }, | ||||
| 
 | ||||
|             /** | ||||
|              * Resolve on success | ||||
|              */ | ||||
|             success: function () { | ||||
|                 deferred.resolve(); | ||||
|             }, | ||||
| 
 | ||||
|             /** | ||||
|              * Extract the error message and reject | ||||
|              * | ||||
|              * @param {Object} response | ||||
|              */ | ||||
|             error: function (response) { | ||||
|                 var message; | ||||
| 
 | ||||
|                 if (typeof response.responseJSON === 'undefined' || | ||||
|                     typeof response.responseJSON.message === 'undefined' | ||||
|                 ) { | ||||
|                     message = 'Could not save the asset!'; | ||||
|                 } else { | ||||
|                     message = response.responseJSON.message; | ||||
|                 } | ||||
|                 deferred.reject(message); | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         return deferred.promise(); | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,54 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'Magento_AdobeStockImageAdminUi/js/action/save', | ||||
|     'Magento_AdobeStockImageAdminUi/js/confirmation/saveLicensed', | ||||
|     'Magento_AdobeStockImageAdminUi/js/path-utility' | ||||
| ], function ($, saveAction, saveLicensedConfirmation, pathUtility) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return function (requestUrl, id, title, path, contentType, directoryPath) { | ||||
|         var imageName = '', | ||||
|             destinationPath, | ||||
|             deferred = $.Deferred(); | ||||
| 
 | ||||
|         if (path !== '') { | ||||
|             imageName = pathUtility.getImageNameFromPath(path); | ||||
|             destinationPath = pathUtility.buildPath(directoryPath, imageName, contentType); | ||||
|             saveAction( | ||||
|                 requestUrl, | ||||
|                 id, | ||||
|                 destinationPath | ||||
|             ).then(function () { | ||||
|                 deferred.resolve(destinationPath); | ||||
|             }).fail(function (message) { | ||||
|                 deferred.reject(message); | ||||
|             }); | ||||
| 
 | ||||
|             return deferred.promise(); | ||||
|         } | ||||
| 
 | ||||
|         saveLicensedConfirmation( | ||||
|             pathUtility.generateImageName(title, id), | ||||
|             pathUtility.getImageExtension(contentType) | ||||
|         ).then(function (fileName) { | ||||
|             destinationPath = pathUtility.buildPath(directoryPath, fileName, contentType); | ||||
|             saveAction( | ||||
|                 requestUrl, | ||||
|                 id, | ||||
|                 destinationPath | ||||
|             ).then(function () { | ||||
|                 deferred.resolve(destinationPath); | ||||
|             }).fail(function (message) { | ||||
|                 deferred.reject(message); | ||||
|             }); | ||||
|         }).fail(function (error) { | ||||
|             deferred.reject(error); | ||||
|         }); | ||||
| 
 | ||||
|         return deferred.promise(); | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,38 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'Magento_AdobeStockImageAdminUi/js/action/save', | ||||
|     'Magento_AdobeStockImageAdminUi/js/confirmation/save', | ||||
|     'Magento_AdobeStockImageAdminUi/js/path-utility' | ||||
| ], function ($, saveAction, saveConfirmation, pathUtility) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return function (requestUrl, id, title, contentType, directoryPath) { | ||||
|         var deferred = $.Deferred(), | ||||
|             destinationPath; | ||||
| 
 | ||||
|         saveConfirmation( | ||||
|             pathUtility.generateImageName(title, id), | ||||
|             pathUtility.getImageExtension(contentType) | ||||
|         ).then(function (fileName) { | ||||
|             destinationPath = pathUtility.buildPath(directoryPath, fileName, contentType); | ||||
| 
 | ||||
|             saveAction( | ||||
|                 requestUrl, | ||||
|                 id, | ||||
|                 destinationPath | ||||
|             ).then(function () { | ||||
|                 deferred.resolve(destinationPath); | ||||
|             }).fail(function (error) { | ||||
|                 deferred.reject(error); | ||||
|             }); | ||||
|         }).fail(function (error) { | ||||
|             deferred.reject(error); | ||||
|         }); | ||||
| 
 | ||||
|         return deferred.promise(); | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,197 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'uiLayout', | ||||
|     'Magento_Ui/js/grid/columns/image-preview' | ||||
| ], function ($, layout, imagePreview) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return imagePreview.extend({ | ||||
|         defaults: { | ||||
|             downloadImagePreviewUrl: 'adobe_stock/preview/download', | ||||
|             licenseAndDownloadUrl: 'adobe_stock/license/license', | ||||
|             saveLicensedAndDownloadUrl: 'adobe_stock/license/saveLicensed', | ||||
|             confirmationUrl: 'adobe_stock/license/confirmation', | ||||
|             relatedImagesUrl: 'adobe_stock/preview/relatedimages', | ||||
|             buyCreditsUrl: 'https://stock.adobe.com/', | ||||
|             mediaGallerySelector: '.media-gallery-modal:has(#search_adobe_stock)', | ||||
|             adobeStockModalSelector: '.adobe-search-images-modal', | ||||
|             activeMediaGallerySelector: 'aside.modal-slide.adobe-stock-modal._show', | ||||
|             modules: { | ||||
|                 keywords: '${ $.name }_keywords', | ||||
|                 related: '${ $.name }_related', | ||||
|                 actions: '${ $.name }_actions' | ||||
|             }, | ||||
|             viewConfig: [ | ||||
|                 { | ||||
|                     component: 'Magento_AdobeStockImageAdminUi/js/components/grid/column/preview/keywords', | ||||
|                     name: '${ $.name }_keywords' | ||||
|                 }, | ||||
|                 { | ||||
|                     component: 'Magento_AdobeStockImageAdminUi/js/components/grid/column/preview/related', | ||||
|                     name: '${ $.name }_related' | ||||
|                 }, | ||||
|                 { | ||||
|                     component: 'Magento_AdobeStockImageAdminUi/js/components/grid/column/preview/actions', | ||||
|                     name: '${ $.name }_actions', | ||||
|                     provider: '${ $.provider }', | ||||
|                     mediaGallery: '${ $.mediaGalleryComponent }', | ||||
|                     mediaGalleryName: '${ $.mediaGalleryName }', | ||||
|                     mediaGalleryProvider: '${ $.mediaGalleryProvider }', | ||||
|                     mediaGallerySortBy: '${ $.mediaGallerySortBy }', | ||||
|                     mediaGallerySearchInput: '${ $.mediaGallerySearchInput }', | ||||
|                     mediaGalleryListingFilters: '${ $.mediaGalleryListingFilters }', | ||||
|                     getMediaGalleryAsset: '${ $.getMediaGalleryAsset }', | ||||
|                     imageEditDetailsUrl: '${ $.imageEditDetailsUrl }', | ||||
|                     listingPaging: '${ $.listingPaging }' | ||||
|                 } | ||||
|             ], | ||||
|             listens: { | ||||
|                 '${ $.sortByComponentName }:applied': 'hide' | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Initialize the component | ||||
|          * | ||||
|          * @returns {Object} | ||||
|          */ | ||||
|         initialize: function () { | ||||
|             this._super().initView(); | ||||
|             $(window).on('fileDeleted.enhancedMediaGallery', this.reloadAdobeGrid.bind(this)); | ||||
|             $(window).on('folderDeleted.enhancedMediaGallery', this.reloadAdobeGrid.bind(this)); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Initialize child components | ||||
|          * | ||||
|          * @returns {Object} | ||||
|          */ | ||||
|         initView: function () { | ||||
|             layout(this.viewConfig); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Get previous button disabled | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          * | ||||
|          * @return {Boolean} | ||||
|          */ | ||||
|         cannotViewPrevious: function (record) { | ||||
|             return this.related().cannotViewPrevious(record); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Get next button disabled | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          * | ||||
|          * @return {Boolean} | ||||
|          */ | ||||
|         cannotViewNext: function (record) { | ||||
|             return this.related().cannotViewNext(record); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Return active adobe gallery selector. | ||||
|          */ | ||||
|         getAdobeModal: function () { | ||||
|             return $(this.activeMediaGallerySelector).find(this.adobeStockModalSelector); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @inheritdoc | ||||
|          */ | ||||
|         next: function (record) { | ||||
|             if (this.related().selectedTab()) { | ||||
|                 this.related().nextRelated(record); | ||||
| 
 | ||||
|                 return; | ||||
|             } | ||||
|             this.keywords().hideAllKeywords(); | ||||
|             this._super(record); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @inheritdoc | ||||
|          */ | ||||
|         prev: function (record) { | ||||
|             if (this.related().selectedTab()) { | ||||
|                 this.related().prevRelated(record); | ||||
| 
 | ||||
|                 return; | ||||
|             } | ||||
|             this.keywords().hideAllKeywords(); | ||||
|             this._super(record); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @inheritdoc | ||||
|          */ | ||||
|         show: function (record) { | ||||
|             this.related().selectedTab(null); | ||||
|             this.keywords().hideAllKeywords(); | ||||
|             this.displayedRecord(record); | ||||
|             this._super(record); | ||||
|             this.related().loadRelatedImages(record); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Show related image data in the preview section | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          */ | ||||
|         showRelated: function (record) { | ||||
|             this.keywords().hideAllKeywords(); | ||||
|             this.displayedRecord(record); | ||||
|             this.updateHeight(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Returns attributes to display under the preview image | ||||
|          * | ||||
|          * @returns {*[]} | ||||
|          */ | ||||
|         getDisplayAttributes: function () { | ||||
|             if (!this.displayedRecord()) { | ||||
|                 return []; | ||||
|             } | ||||
| 
 | ||||
|             return [ | ||||
|                 { | ||||
|                     name: 'Dimensions', | ||||
|                     value: this.displayedRecord().width + ' x ' + this.displayedRecord().height + ' px' | ||||
|                 }, | ||||
|                 { | ||||
|                     name: 'File type', | ||||
|                     value: this.displayedRecord()['content_type'].toUpperCase() | ||||
|                 }, | ||||
|                 { | ||||
|                     name: 'Category', | ||||
|                     value: this.displayedRecord().category.name || 'None' | ||||
|                 }, | ||||
|                 { | ||||
|                     name: 'File #', | ||||
|                     value: this.displayedRecord().id | ||||
|                 } | ||||
|             ]; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Reload Adobe grid after deleting image | ||||
|          */ | ||||
|         reloadAdobeGrid: function () { | ||||
|             this.actions().source().reload({ | ||||
|                 refresh: true | ||||
|             }); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,141 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'underscore', | ||||
|     'Magento_Ui/js/grid/columns/overlay', | ||||
|     'Magento_AdobeStockImageAdminUi/js/action/getLicenseStatus' | ||||
| ], function ($, _, overlay, getLicenseStatus) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return overlay.extend({ | ||||
|         defaults: { | ||||
|             // eslint-disable-next-line max-len
 | ||||
|             provider: 'name = adobe_stock_images_listing.adobe_stock_images_listing_data_source, ns = adobe_stock_images_listing', | ||||
|             loginProvider: 'name = adobe-login, ns = adobe-login', | ||||
|             getImagesUrl: 'adobe_stock/license/getlist', | ||||
|             licensed: {}, | ||||
|             modules: { | ||||
|                 login: '${ $.loginProvider }' | ||||
|             }, | ||||
|             listens: { | ||||
|                 '${ $.provider }:data.items': 'handleItemsUpdate', | ||||
|                 '${ $.loginProvider }:user': 'handleUserUpdate' | ||||
|             }, | ||||
|             imports: { | ||||
|                 rows: '${ $.provider }:data.items' | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Init observable variables | ||||
|          * @return {Object} | ||||
|          */ | ||||
|         initObservable: function () { | ||||
|             this._super() | ||||
|                 .observe([ | ||||
|                     'licensed' | ||||
|                 ]); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Updates the licensed data when items data is updated. | ||||
|          * | ||||
|          * @param {Array} items | ||||
|          */ | ||||
|         handleItemsUpdate: function (items) { | ||||
|             var ids = this.getIds(items); | ||||
| 
 | ||||
|             this.updateLicensed(ids); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Updates the licensed data when user data is updated. | ||||
|          */ | ||||
|         handleUserUpdate: function () { | ||||
|             var ids = this.getIds(this.rows); | ||||
| 
 | ||||
|             this.updateLicensed(ids); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Set Licensed images data. | ||||
|          * | ||||
|          * @param {Array} ids | ||||
|          */ | ||||
|         updateLicensed: function (ids) { | ||||
|             if (!this.isUserAuthorized() || ids.length === 0) { | ||||
|                 this.licensed({}); | ||||
| 
 | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             getLicenseStatus(this.getImagesUrl, ids).then(function (licensed) { | ||||
|                 this.licensed(licensed); | ||||
|             }.bind(this)); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Checks if user is logged in and authorized | ||||
|          * | ||||
|          * @returns {Boolean} | ||||
|          */ | ||||
|         isUserAuthorized: function () { | ||||
|             return !_.isUndefined(this.login()) && this.login().user().isAuthorized; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Get all ids from items array | ||||
|          * | ||||
|          * @param {Array} items | ||||
|          * @returns {Number[]} | ||||
|          */ | ||||
|         getIds: function (items) { | ||||
|             var ids = []; | ||||
| 
 | ||||
|             items.forEach(function (record) { | ||||
|                 ids.push(record.id); | ||||
|             }); | ||||
| 
 | ||||
|             return ids; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Returns top displacement of overlay according to image height | ||||
|          * | ||||
|          * @param {Object} record - Data to be preprocessed. | ||||
|          * @returns {Object} | ||||
|          */ | ||||
|         getStyles: function (record) { | ||||
|             var height = record.styles().height.replace('px', '') - 40; | ||||
| 
 | ||||
|             return { | ||||
|                 top: height + 'px' | ||||
|             }; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * If overlay should be visible | ||||
|          * | ||||
|          * @param {Object} row | ||||
|          * @returns {Boolean} | ||||
|          */ | ||||
|         isVisible: function (row) { | ||||
|             return this.licensed()[row.id]; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Get overlay label | ||||
|          * | ||||
|          * @param {Object} row | ||||
|          * @returns {String} | ||||
|          */ | ||||
|         getLabel: function (row) { | ||||
|             return this.licensed()[row.id] ? 'Licensed' : ''; | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,590 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'uiComponent', | ||||
|     'uiRegistry', | ||||
|     'jquery', | ||||
|     'underscore', | ||||
|     'Magento_AdobeStockImageAdminUi/js/action/save', | ||||
|     'Magento_AdobeStockImageAdminUi/js/action/savePreview', | ||||
|     'Magento_AdobeStockImageAdminUi/js/action/saveLicensed', | ||||
|     'Magento_AdobeStockImageAdminUi/js/action/licenseAndSave', | ||||
|     'Magento_AdobeStockImageAdminUi/js/action/confirmQuota', | ||||
|     'Magento_AdobeStockImageAdminUi/js/media-gallery', | ||||
|     'Magento_AdobeStockImageAdminUi/js/confirmation/buyCredits', | ||||
|     'Magento_AdobeStockImageAdminUi/js/action/getLicenseStatus', | ||||
|     'Magento_Ui/js/modal/alert' | ||||
| ], function ( | ||||
|     Component, | ||||
|     uiRegistry, | ||||
|     $, | ||||
|     _, | ||||
|     saveAction, | ||||
|     savePreviewAction, | ||||
|     saveLicensedAction, | ||||
|     licenseAndSaveAction, | ||||
|     confirmQuotaAction, | ||||
|     mediaGallery, | ||||
|     buyCreditsConfirmation, | ||||
|     getLicenseStatus, | ||||
|     uiAlert | ||||
| ) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Component.extend({ | ||||
|         defaults: { | ||||
|             template: 'Magento_AdobeStockImageAdminUi/grid/column/preview/actions', | ||||
|             loginProvider: 'name = adobe-login, ns = adobe-login', | ||||
|             mediaGallerySelector: '.media-gallery-modal:has(#search_adobe_stock)', | ||||
|             adobeStockModalSelector: '.adobe-search-images-modal', | ||||
|             downloadImagePreviewUrl: 'adobe_stock/preview/download', | ||||
|             licenseAndDownloadUrl: 'adobe_stock/license/license', | ||||
|             saveLicensedAndDownloadUrl: 'adobe_stock/license/saveLicensed', | ||||
|             buyCreditsUrl: 'https://stock.adobe.com/', | ||||
|             messageDelay: 5, | ||||
|             mediaGallery: '', | ||||
|             imageItems: [], | ||||
|             messages: [], | ||||
|             listens: { | ||||
|                 '${ $.provider }:data.items': 'updateActions' | ||||
|             }, | ||||
|             modules: { | ||||
|                 login: '${ $.loginProvider }', | ||||
|                 preview: '${ $.parentName }.preview', | ||||
|                 overlay: '${ $.parentName }.overlay', | ||||
|                 source: '${ $.provider }', | ||||
|                 imageDirectory: '${ $.mediaGalleryName }', | ||||
|                 mediaGallerySortBy: '${ $.mediaGallerySortBy }', | ||||
|                 mediaGallerySearchInput: '${ $.mediaGallerySearchInput }', | ||||
|                 mediaGalleryListingFilters: '${ $.mediaGalleryListingFilters }', | ||||
|                 listingPaging: '${ $.listingPaging }' | ||||
|             }, | ||||
|             imports: { | ||||
|                 imageItems: '${ $.mediaGalleryProvider }:data.items' | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Init observable variables | ||||
|          * | ||||
|          * @return {Object} | ||||
|          */ | ||||
|         initObservable: function () { | ||||
|             this._super() | ||||
|                 .observe([ | ||||
|                     'imageItems', | ||||
|                     'messages' | ||||
|                 ]); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Update displayed record data on data source update | ||||
|          */ | ||||
|         updateActions: function () { | ||||
|             var displayedRecord = this.preview().displayedRecord(), | ||||
|                 updatedDisplayedRecord = this.preview().displayedRecord(), | ||||
|                 records = this.source().data.items, | ||||
|                 index; | ||||
| 
 | ||||
|             if (typeof displayedRecord.id === 'undefined') { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             for (index = 0; index < records.length; index++) { | ||||
|                 if (records[index].id === displayedRecord.id) { | ||||
|                     updatedDisplayedRecord = records[index]; | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             this.preview().displayedRecord(updatedDisplayedRecord); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Returns is_downloaded flag as observable for given record | ||||
|          * | ||||
|          * @returns {observable} | ||||
|          */ | ||||
|         isDownloaded: function () { | ||||
|             return this.preview().displayedRecord()['is_downloaded']; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Is asset licensed in adobe stock in context of currently logged in account | ||||
|          * | ||||
|          * @returns {observable} | ||||
|          */ | ||||
|         isLicensed: function () { | ||||
|             return this.overlay().licensed()[this.preview().displayedRecord().id] && !this.isLicensedLocally(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Is licensed version of asset saved locally | ||||
|          * | ||||
|          * @returns {observable} | ||||
|          */ | ||||
|         isLicensedLocally: function () { | ||||
|             return this.preview().displayedRecord()['is_licensed_locally']; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Locate downloaded image in media browser | ||||
|          */ | ||||
|         openInMediaGalleryClick: function () { | ||||
|             this.preview().getAdobeModal().trigger('closeModal'); | ||||
| 
 | ||||
|             if (!this.isMediaBrowser()) { | ||||
|                 this.selectImageInNewMediaGalleryBySearch(this.preview().displayedRecord().id); | ||||
|             } else { | ||||
|                 this.selectDisplayedImageForOldMediaGallery(this.preview().displayedRecord().path); | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Return adobe stock asset by adobe id | ||||
|          * | ||||
|          * @param {String} adobeId | ||||
|          */ | ||||
|         getAssetDetails: function (adobeId) { | ||||
|             return $.ajax({ | ||||
|                 url: this.getMediaGalleryAsset, | ||||
|                 data: { | ||||
|                     'adobe_id': adobeId | ||||
|                 }, | ||||
|                 context: this, | ||||
|                 showLoader: true | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Select image in new media gallery via search input | ||||
|          * | ||||
|          * @param {String} imageId | ||||
|          */ | ||||
|         selectImageInNewMediaGalleryBySearch: function (imageId) { | ||||
|             var path; | ||||
| 
 | ||||
|             this.mediaGalleryListingFilters().clear(); | ||||
|             this.getAssetDetails(imageId).then(function (assetDetails) { | ||||
|                 if (assetDetails.length === 0) { | ||||
|                     return; | ||||
|                 } | ||||
|                 this.mediaGallerySearchInput().apply(assetDetails.title); | ||||
|                 path = assetDetails.path; | ||||
|                 path = path.substring(0, path.lastIndexOf('/')); | ||||
| 
 | ||||
|                 if (path !== '') { | ||||
|                     this.imageDirectory().locateNode(path); | ||||
|                 } | ||||
|                 this.selectRecordFromMediaGalleryProvider(assetDetails.path); | ||||
|             }.bind(this)); | ||||
| 
 | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Open recently saved image and go to first page | ||||
|          */ | ||||
|         openNewestImage: function () { | ||||
|             this.listingPaging().goFirst(); | ||||
|             this.mediaGallerySortBy().selectDefaultOption(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Selects displayed image in media gallery for old gallery | ||||
|          */ | ||||
|         selectDisplayedImageForOldMediaGallery: function (path) { | ||||
|             var image = mediaGallery.locate(path); | ||||
| 
 | ||||
|             image ? image.trigger('click') : mediaGallery.notLocated(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Select record by image file name | ||||
|          * | ||||
|          * @param {String} path | ||||
|          */ | ||||
|         selectRecordFromMediaGalleryProvider: function (path) { | ||||
|             var subscription; | ||||
| 
 | ||||
|             subscription = this.imageItems.subscribe(function (items) { | ||||
|                 subscription.dispose(); | ||||
|                 items.each(function (item) { | ||||
|                     if (item.path === path) { | ||||
|                         this.selectRecord(item); | ||||
| 
 | ||||
|                         return false; | ||||
|                     } | ||||
|                 }.bind(this)); | ||||
|             }.bind(this)); | ||||
| 
 | ||||
|             setTimeout(function () { | ||||
|                 subscription.dispose(); | ||||
|             }, 1500); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Set the record as selected | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          */ | ||||
|         selectRecord: function (record) { | ||||
|             uiRegistry.get('name =' + this.mediaGallery).select(record); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Save preview click handler | ||||
|          */ | ||||
|         savePreviewClick: function () { | ||||
|             var record = this.preview().displayedRecord(); | ||||
| 
 | ||||
|             savePreviewAction( | ||||
|                 this.preview().downloadImagePreviewUrl, | ||||
|                 record.id, | ||||
|                 record.title, | ||||
|                 record['content_type'], | ||||
|                 this.getDestinationDirectoryPath() | ||||
|             ).then(function (destinationPath) { | ||||
|                 this.updateDownloadedDisplayedRecord(destinationPath); | ||||
|                 this.reloadGrid().done(function () { | ||||
|                     this.openInMediaGalleryClick(); | ||||
|                 }.bind(this)); | ||||
|             }.bind(this)).fail(function (error) { | ||||
|                 if (error) { | ||||
|                     this.showErrorMessage(error); | ||||
|                 } | ||||
|             }.bind(this)); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Update displayed record after downloading | ||||
|          * | ||||
|          * @param {String} path | ||||
|          */ | ||||
|         updateDownloadedDisplayedRecord: function (path) { | ||||
|             var record = this.preview().displayedRecord(); | ||||
| 
 | ||||
|             record['is_downloaded'] = 1; | ||||
| 
 | ||||
|             if (record.path === '') { | ||||
|                 record.path = path; | ||||
|             } | ||||
| 
 | ||||
|             this.preview().displayedRecord(record); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Update displayed record after licensing | ||||
|          * | ||||
|          * @param {String} path | ||||
|          */ | ||||
|         updateLicensedDisplayedRecord: function (path) { | ||||
|             var record = this.preview().displayedRecord(); | ||||
| 
 | ||||
|             record['is_downloaded'] = 1; | ||||
| 
 | ||||
|             if (record.path === '') { | ||||
|                 record.path = path; | ||||
|             } | ||||
| 
 | ||||
|             record['is_licensed'] = 1; | ||||
|             record['is_licensed_locally'] = 1; | ||||
| 
 | ||||
|             this.preview().displayedRecord(record); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Get image destination path | ||||
|          * | ||||
|          * @param {String} fileName | ||||
|          * @param {String} contentType | ||||
|          * @returns {String} | ||||
|          */ | ||||
|         getDestinationPath: function (fileName, contentType) { | ||||
|             return this.getDestinationDirectoryPath() + '/' + fileName + '.' + this.getImageExtension(contentType); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Get destination directory path | ||||
|          * | ||||
|          * @returns {String} | ||||
|          */ | ||||
|         getDestinationDirectoryPath: function () { | ||||
|             var activeNodePath, | ||||
|                 activeNode; | ||||
| 
 | ||||
|             if (this.isMediaBrowser()) { | ||||
|                 activeNode = this.getMageMediaBrowserData().activeNode; | ||||
| 
 | ||||
|                 activeNodePath = _.isUndefined(activeNode.original.path) ? '' : activeNode.original.path; | ||||
|             } else { | ||||
|                 activeNodePath = this.imageDirectory().activeNode() || ''; | ||||
|             } | ||||
| 
 | ||||
|             return activeNodePath; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Reload grid | ||||
|          * | ||||
|          * @returns {*} | ||||
|          */ | ||||
|         reloadGrid: function () { | ||||
|             var provider, | ||||
|                 dataStorage; | ||||
| 
 | ||||
|             if (this.isMediaBrowser()) { | ||||
|                 return this.getMageMediaBrowserData().reload(); | ||||
|             } | ||||
| 
 | ||||
|             provider = uiRegistry.get('index = media_gallery_listing_data_source'), | ||||
|                 dataStorage = provider.storage(); | ||||
| 
 | ||||
|             dataStorage.clearRequests(); | ||||
| 
 | ||||
|             return provider.reload(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Get data for media browser | ||||
|          * | ||||
|          * @returns {Undefined|Object} | ||||
|          */ | ||||
|         getMageMediaBrowserData: function () { | ||||
|             return $(this.preview().mediaGallerySelector).data('mageMediabrowser'); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Is the media browser used in the content of the grid | ||||
|          * | ||||
|          * @returns {Boolean} | ||||
|          */ | ||||
|         isMediaBrowser: function () { | ||||
|             return typeof this.getMageMediaBrowserData() !== 'undefined'; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Generate meaningful name image file, | ||||
|          * allow only alphanumerics, dashes, and underscores | ||||
|          * | ||||
|          * @param {String} title | ||||
|          * @param {Number} id | ||||
|          * @return string | ||||
|          */ | ||||
|         generateImageName: function (title, id) { | ||||
|             var fileName = title.substring(0, 32) | ||||
|                 .replace(/[^a-zA-Z0-9_]/g, '-') | ||||
|                 .replace(/-{2,}/g, '-') | ||||
|                 .toLowerCase(); | ||||
| 
 | ||||
|             /* If the filename does not contain latin chars, use ID as a filename */ | ||||
|             return fileName === '-' ? id : fileName; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Get image file extension | ||||
|          * | ||||
|          * @param {String} contentType | ||||
|          * @return string | ||||
|          */ | ||||
|         getImageExtension: function (contentType) { | ||||
|             return contentType.match(/[^/]{1,4}$/); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Get messages | ||||
|          * | ||||
|          * @return {Array} | ||||
|          */ | ||||
|         getMessages: function () { | ||||
|             return this.messages(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * License click handler | ||||
|          */ | ||||
|         licenseClick: function () { | ||||
|             var record = this.preview().displayedRecord(); | ||||
| 
 | ||||
|             this.licenseProcess( | ||||
|                 record.id, | ||||
|                 record.title, | ||||
|                 record.path, | ||||
|                 record['content_type'], | ||||
|                 this.isDownloaded() | ||||
|             ).then(function (destinationPath) { | ||||
|                 this.updateLicensedDisplayedRecord(destinationPath); | ||||
|                 this.login().getUserQuota(); | ||||
|                 this.reloadGrid().done(function () { | ||||
|                     this.openInMediaGalleryClick(); | ||||
|                 }.bind(this)); | ||||
|             }.bind(this)).fail(function (error) { | ||||
|                 if (error) { | ||||
|                     uiAlert({ | ||||
|                         content: error | ||||
|                     }); | ||||
|                 } | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Process of license | ||||
|          * | ||||
|          * @param {Number} id | ||||
|          * @param {String} title | ||||
|          * @param {String} path | ||||
|          * @param {String} contentType | ||||
|          * @param {Boolean} isDownloaded | ||||
|          * @return {window.Promise} | ||||
|          */ | ||||
|         licenseProcess: function (id, title, path, contentType, isDownloaded) { | ||||
|             var deferred = $.Deferred(); | ||||
| 
 | ||||
|             this.login().login() | ||||
|                 .then(function () { | ||||
|                     getLicenseStatus( | ||||
|                         this.overlay().getImagesUrl, | ||||
|                         [id] | ||||
|                     ).then(function (licensedInfo) { | ||||
|                         var isLicensed = licensedInfo[id] || false; | ||||
| 
 | ||||
|                         if (isLicensed) { | ||||
|                             saveLicensedAction( | ||||
|                                 this.preview().saveLicensedAndDownloadUrl, | ||||
|                                 id, | ||||
|                                 title, | ||||
|                                 path, | ||||
|                                 contentType, | ||||
|                                 this.getDestinationDirectoryPath() | ||||
|                             ).then(function (destinationPath) { | ||||
|                                 deferred.resolve(destinationPath); | ||||
|                             }).fail(function (error) { | ||||
|                                 deferred.reject(error); | ||||
|                             }); | ||||
|                         } else { | ||||
|                             confirmQuotaAction(this.preview().confirmationUrl, id).then(function (data) { | ||||
|                                 if (data.canLicense === false) { | ||||
|                                     buyCreditsConfirmation( | ||||
|                                         this.preview().buyCreditsUrl, | ||||
|                                         title, | ||||
|                                         data.message | ||||
|                                     ); | ||||
|                                 } else { | ||||
|                                     licenseAndSaveAction( | ||||
|                                         this.preview().licenseAndDownloadUrl, | ||||
|                                         id, | ||||
|                                         title, | ||||
|                                         path, | ||||
|                                         contentType, | ||||
|                                         isDownloaded, | ||||
|                                         data.message, | ||||
|                                         this.getDestinationDirectoryPath() | ||||
|                                     ).then(function (destinationPath) { | ||||
|                                         deferred.resolve(destinationPath); | ||||
|                                     }).fail(function (error) { | ||||
|                                         deferred.reject(error); | ||||
|                                     }); | ||||
|                                 } | ||||
|                             }.bind(this)).fail(function (error) { | ||||
|                                 deferred.reject(error); | ||||
|                             }); | ||||
|                         } | ||||
|                     }.bind(this)).fail(function (error) { | ||||
|                         deferred.reject(error); | ||||
|                     }); | ||||
|                 }.bind(this)).fail(function (error) { | ||||
|                 deferred.reject(error); | ||||
|             }); | ||||
| 
 | ||||
|             return deferred.promise(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Save licensed click handler | ||||
|          */ | ||||
|         saveLicensedClick: function () { | ||||
|             var record = this.preview().displayedRecord(); | ||||
| 
 | ||||
|             if (!this.login().user().isAuthorized) { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             if (!this.isLicensed()) { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             saveLicensedAction( | ||||
|                 this.preview().saveLicensedAndDownloadUrl, | ||||
|                 record.id, | ||||
|                 record.title, | ||||
|                 record.path, | ||||
|                 record['content_type'], | ||||
|                 this.getDestinationDirectoryPath() | ||||
|             ).then(function (destinationPath) { | ||||
|                 this.updateLicensedDisplayedRecord(destinationPath); | ||||
|                 this.login().getUserQuota(); | ||||
|                 this.reloadGrid().done(function () { | ||||
|                     this.openInMediaGalleryClick(); | ||||
|                 }.bind(this)); | ||||
|             }.bind(this)).fail(function (error) { | ||||
|                 if (error) { | ||||
|                     uiAlert({ | ||||
|                         content: error | ||||
|                     }); | ||||
|                 } | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Returns license button title depending on the existing saved preview | ||||
|          * | ||||
|          * @returns {String} | ||||
|          */ | ||||
|         getLicenseButtonTitle: function () { | ||||
|             return this.isDownloaded() ? $.mage.__('License') : $.mage.__('License and Save'); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Extracts image name from its path | ||||
|          * | ||||
|          * @param {String} path | ||||
|          * @returns {String} | ||||
|          */ | ||||
|         getImageNameFromPath: function (path) { | ||||
|             var filePathArray = path.split('/'), | ||||
|                 imageIndex = filePathArray.length - 1; | ||||
| 
 | ||||
|             return filePathArray[imageIndex].substring(0, filePathArray[imageIndex].lastIndexOf('.')); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Show error message and schedule cleanup | ||||
|          * | ||||
|          * @param {String} message | ||||
|          */ | ||||
|         showErrorMessage: function (message) { | ||||
|             this.messages.push({ | ||||
|                 code: 'error', | ||||
|                 messageUnsanitizedHtml: message | ||||
|             }); | ||||
|             this.messagesCleanup(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Messages cleanup | ||||
|          */ | ||||
|         messagesCleanup: function () { | ||||
|             // eslint-disable-next-line no-unused-vars
 | ||||
|             var timerId; | ||||
| 
 | ||||
|             // eslint-disable-next-line no-unused-vars
 | ||||
|             timerId = setTimeout(function () { | ||||
|                 clearTimeout(timerId); | ||||
|                 this.messages.removeAll(); | ||||
|             }.bind(this), Number(this.messageDelay) * 1000); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,80 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'uiComponent', | ||||
|     'underscore' | ||||
| ], function (Component, _) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Component.extend({ | ||||
|         defaults: { | ||||
|             template: 'Magento_AdobeStockImageAdminUi/grid/column/preview/keywords', | ||||
|             chipsProvider: 'componentType = filtersChips, ns = ${ $.ns }', | ||||
|             defaultKeywordsLimit: 5, | ||||
|             keywordsLimit: 5, | ||||
|             canViewMoreKeywords: true, | ||||
|             modules: { | ||||
|                 chips: '${ $.chipsProvider }', | ||||
|                 preview: '${ $.parentName }.preview' | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Init observable variables | ||||
|          * @return {Object} | ||||
|          */ | ||||
|         initObservable: function () { | ||||
|             this._super() | ||||
|                 .observe([ | ||||
|                     'keywordsLimit', | ||||
|                     'canViewMoreKeywords' | ||||
|                 ]); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Returns keywords to display under the attributes image | ||||
|          * | ||||
|          * @returns {*[]} | ||||
|          */ | ||||
|         getKeywords: function (record) { | ||||
|             return record.keywords; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Returns keywords limit to show no of keywords | ||||
|          */ | ||||
|         getKeywordsLimit: function () { | ||||
|             return this.keywordsLimit(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Show all the related keywords | ||||
|          */ | ||||
|         viewAllKeywords: function (record) { | ||||
|             this.keywordsLimit(record.keywords.length); | ||||
|             this.canViewMoreKeywords(false); | ||||
|             this.preview().updateHeight(); | ||||
|             this.preview().scrollToPreview(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Hide all the related keywords | ||||
|          */ | ||||
|         hideAllKeywords: function () { | ||||
|             this.keywordsLimit(this.defaultKeywordsLimit); | ||||
|             this.canViewMoreKeywords(true); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Drop all filters and initiate search on keyword click event | ||||
|          */ | ||||
|         searchByKeyWord: function (keyword) { | ||||
|             _.invoke(this.chips().elems(), 'clear'); | ||||
|             _.invoke(this.chips().elems(), 'apply', keyword); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,410 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'uiComponent', | ||||
|     'underscore', | ||||
|     'jquery' | ||||
| ], function (Component, _, $) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Component.extend({ | ||||
|         defaults: { | ||||
|             template: 'Magento_AdobeStockImageAdminUi/grid/column/preview/related', | ||||
|             filterChipsProvider: 'componentType = filters, ns = ${ $.ns }', | ||||
|             filterBookmarksSelector: '.admin__data-grid-action-bookmarks', | ||||
|             tabImagesLimit: 4, | ||||
|             tabsContainerId: '#adobe-stock-tabs', | ||||
|             serieFilterValue: '', | ||||
|             modelFilterValue: '', | ||||
|             selectedTab: null, | ||||
|             loader: false, | ||||
|             relatedImages: { | ||||
|                 series: {}, | ||||
|                 model: {} | ||||
|             }, | ||||
|             statefull: { | ||||
|                 serieFilterValue: true, | ||||
|                 modelFilterValue: true | ||||
|             }, | ||||
|             modules: { | ||||
|                 chips: '${ $.chipsProvider }', | ||||
|                 filterChips: '${ $.filterChipsProvider }', | ||||
|                 preview: '${ $.parentName }.preview' | ||||
|             }, | ||||
|             exports: { | ||||
|                 serieFilterValue: '${ $.provider }:params.filters.serie_id', | ||||
|                 modelFilterValue: '${ $.provider }:params.filters.model_id' | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Initializes related component. | ||||
|          */ | ||||
|         initialize: function () { | ||||
|             this._super(); | ||||
| 
 | ||||
|             this.filterChips().updateActive(); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Disable keydown event for related content tabs | ||||
|          */ | ||||
|         disableTabsKeyDownEvent: function () { | ||||
|             if ($(this.tabsContainerId + ' li[role=tab]').length === 0) { | ||||
|                 setTimeout(function () { | ||||
|                     this.disableTabsKeyDownEvent(); | ||||
|                 }.bind(this), 100); | ||||
|             } else { | ||||
|                 $(this.tabsContainerId + ' li[role=tab]').off('keydown'); | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Init observable variables | ||||
|          * @return {Object} | ||||
|          */ | ||||
|         initObservable: function () { | ||||
|             this._super() | ||||
|                 .observe([ | ||||
|                     'serieFilterValue', | ||||
|                     'modelFilterValue', | ||||
|                     'selectedTab', | ||||
|                     'relatedImages', | ||||
|                     'loader' | ||||
|                 ]); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Check if visible container | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          * @returns boolean | ||||
|          */ | ||||
|         isVisible: function (record) { | ||||
|             return this.showSeriesTab(record) && this.showModelTab(record); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Get image related image series.s | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          */ | ||||
|         loadRelatedImages: function (record) { | ||||
|             var series = this.getSeries(record), | ||||
|                 model = this.getModel(record); | ||||
| 
 | ||||
|             if (series && series.length || | ||||
|                 model && model.length | ||||
|             ) { | ||||
|                 return; | ||||
|             } | ||||
|             $.ajax({ | ||||
|                 type: 'GET', | ||||
|                 url: this.preview().relatedImagesUrl, | ||||
|                 dataType: 'json', | ||||
|                 beforeSend: function () { | ||||
|                     this.loader(true); | ||||
|                 }.bind(this), | ||||
|                 data: { | ||||
|                     'image_id': record.id, | ||||
|                     'limit': this.tabImagesLimit | ||||
|                 } | ||||
|             }).done(function (data) { | ||||
|                 var relatedImages = this.relatedImages(); | ||||
| 
 | ||||
|                 this.loader(false); | ||||
|                 relatedImages.series[record.id] = data.result['same_series']; | ||||
|                 relatedImages.model[record.id] = data.result['same_model']; | ||||
| 
 | ||||
|                 this.relatedImages(relatedImages); | ||||
|                 this.preview().updateHeight(); | ||||
| 
 | ||||
|                 /* Switch to the model tab if the series tab is hidden */ | ||||
|                 if (relatedImages.series[record.id].length === 0 && relatedImages.model[record.id].length > 0) { | ||||
|                     // eslint-disable-next-line jquery-no-input-event-shorthand
 | ||||
|                     $('#adobe-stock-tabs').data().mageTabs.select(1); | ||||
|                 } | ||||
|             }.bind(this)); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Returns true if the series tab should be show, false otherwise | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          * @returns boolean | ||||
|          */ | ||||
|         showSeriesTab: function (record) { | ||||
|             return typeof this.relatedImages().series[record.id] === 'undefined' || | ||||
|                 this.relatedImages().series[record.id].length !== 0; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Returns true if the model tab should be show, false otherwise | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          * @returns boolean | ||||
|          */ | ||||
|         showModelTab: function (record) { | ||||
|             return typeof this.relatedImages().model[record.id] === 'undefined' || | ||||
|                 this.relatedImages().model[record.id].length !== 0; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Returns series to display under the image | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          * @returns {*[]} | ||||
|          */ | ||||
|         getSeries: function (record) { | ||||
|             return this.relatedImages().series[record.id] || []; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Check if the number of related series image is greater than 4 or not | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          * @returns boolean | ||||
|          */ | ||||
|         canShowMoreSeriesImages: function (record) { | ||||
|             return this.getSeries(record).length >= this.tabImagesLimit; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Returns model to display under the image | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          * @returns {*[]} | ||||
|          */ | ||||
|         getModel: function (record) { | ||||
|             return this.relatedImages().model[record.id] || []; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Check if the number of related model image is greater than 4 or not | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          * @returns boolean | ||||
|          */ | ||||
|         canShowMoreModelImages: function (record) { | ||||
|             return this.getModel(record).length >= this.tabImagesLimit; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Filter images from serie_id | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          */ | ||||
|         seeMoreFromSeries: function (record) { | ||||
|             if (this.isSerieFilterApplied(record)) { | ||||
|                 this.scrollToFilter(); | ||||
| 
 | ||||
|                 return; | ||||
|             } | ||||
|             this.serieFilterValue(record.id); | ||||
|             this.applyFilter('serie_id', record.id.toString()); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Filter images from serie_id | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          */ | ||||
|         seeMoreFromModel: function (record) { | ||||
|             if (this.isModelFilterApplied(record)) { | ||||
|                 this.scrollToFilter(); | ||||
| 
 | ||||
|                 return; | ||||
|             } | ||||
|             this.modelFilterValue(record.id); | ||||
|             this.applyFilter('model_id', record.id.toString()); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Apply series or model id filter and scroll to top of the page | ||||
|          * | ||||
|          * @param {String} typeId | ||||
|          * @param {String} recordId | ||||
|          */ | ||||
|         applyFilter: function (typeId, recordId) { | ||||
|             var data = {}; | ||||
| 
 | ||||
|             data[typeId] = recordId; | ||||
| 
 | ||||
|             this.filterChips().clear(); | ||||
|             this.filterChips().setData(data, true); | ||||
|             this.filterChips().apply(); | ||||
| 
 | ||||
|             this.scrollToFilter(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Checks if the filter is applied | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          * @returns {Boolean} | ||||
|          */ | ||||
|         isSerieFilterApplied: function (record) { | ||||
|             return this.filterChips().get('applied')['serie_id'] === record.id.toString(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Checks if the filter is applied | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          * @returns {Boolean} | ||||
|          */ | ||||
|         isModelFilterApplied: function (record) { | ||||
|             return this.filterChips().get('applied')['model_id'] === record.id.toString(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Scrolls user window to the filter bookmarks | ||||
|          */ | ||||
|         scrollToFilter: function () { | ||||
|             $(this.preview().adobeStockModalSelector + ' ' + this.filterBookmarksSelector).get(0).scrollIntoView({ | ||||
|                 behavior: 'smooth', | ||||
|                 block: 'center', | ||||
|                 inline: 'nearest' | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Next related image preview | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          */ | ||||
|         nextRelated: function (record) { | ||||
|             var relatedList = this.selectedTab() === 'series' ? this.getSeries(record) : this.getModel(record), | ||||
|                 nextRelatedIndex = _.findLastIndex( | ||||
|                     relatedList, | ||||
|                     { | ||||
|                         id: this.preview().displayedRecord().id | ||||
|                     } | ||||
|                 ) + 1, | ||||
|                 nextRelated = relatedList[nextRelatedIndex]; | ||||
| 
 | ||||
|             if (typeof nextRelated === 'undefined') { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             this.switchImagePreviewToRelatedImage(nextRelated); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Previous related preview | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          */ | ||||
|         prevRelated: function (record) { | ||||
|             var relatedList = this.selectedTab() === 'series' ? this.getSeries(record) : this.getModel(record), | ||||
|                 prevRelatedIndex = _.findLastIndex( | ||||
|                     relatedList, | ||||
|                     { | ||||
|                         id: this.preview().displayedRecord().id | ||||
|                     } | ||||
|                 ) - 1, | ||||
|                 prevRelated = relatedList[prevRelatedIndex]; | ||||
| 
 | ||||
|             if (typeof prevRelated === 'undefined') { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             this.switchImagePreviewToRelatedImage(prevRelated); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Get previous button disabled | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          * | ||||
|          * @return {Boolean} | ||||
|          */ | ||||
|         cannotViewPrevious: function (record) { | ||||
|             var relatedList, prevRelatedIndex, prevRelated; | ||||
| 
 | ||||
|             if (!this.selectedTab()) { | ||||
|                 return false; | ||||
|             } | ||||
|             relatedList = this.selectedTab() === 'series' ? this.getSeries(record) : this.getModel(record); | ||||
|             prevRelatedIndex = _.findLastIndex( | ||||
|                 relatedList, | ||||
|                 { | ||||
|                     id: this.preview().displayedRecord().id | ||||
|                 } | ||||
|             ) - 1; | ||||
|             prevRelated = relatedList[prevRelatedIndex]; | ||||
| 
 | ||||
|             return typeof prevRelated === 'undefined'; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Get next button disabled | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          * | ||||
|          * @return {Boolean} | ||||
|          */ | ||||
|         cannotViewNext: function (record) { | ||||
|             var relatedList, nextRelatedIndex, nextRelated; | ||||
| 
 | ||||
|             if (!this.selectedTab()) { | ||||
|                 return false; | ||||
|             } | ||||
|             relatedList = this.selectedTab() === 'series' ? this.getSeries(record) : this.getModel(record); | ||||
|             nextRelatedIndex = _.findLastIndex( | ||||
|                 relatedList, | ||||
|                 { | ||||
|                     id: this.preview().displayedRecord().id | ||||
|                 } | ||||
|             ) + 1; | ||||
|             nextRelated = relatedList[nextRelatedIndex]; | ||||
| 
 | ||||
|             return typeof nextRelated === 'undefined'; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Switch image preview to related image | ||||
|          * | ||||
|          * @param {Object|null} relatedImage | ||||
|          */ | ||||
|         switchImagePreviewToRelatedImage: function (relatedImage) { | ||||
|             if (!relatedImage) { | ||||
|                 this.selectedTab(null); | ||||
| 
 | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             if (this.preview().displayedRecord().id === relatedImage.id) { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             this.preview().showRelated(relatedImage); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Switch image preview to series image | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          */ | ||||
|         switchImagePreviewToSeriesImage: function (record) { | ||||
|             this.selectedTab('series'); | ||||
|             this.switchImagePreviewToRelatedImage(record); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Switch image preview to model image | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          */ | ||||
|         switchImagePreviewToModelImage: function (record) { | ||||
|             this.selectedTab('model'); | ||||
|             this.switchImagePreviewToRelatedImage(record); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,49 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'Magento_Ui/js/grid/paging/sizes', | ||||
|     'underscore' | ||||
| ], function (Sizes, _) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Sizes.extend({ | ||||
|         defaults: { | ||||
|             value: 32, | ||||
|             minSize: 1, | ||||
|             maxSize: 64 | ||||
|         }, | ||||
| 
 | ||||
|         exports: { | ||||
|             value: '${ $.provider }:params.paging.page', | ||||
|             options: '${ $.provider }:params.paging.options' | ||||
|         }, | ||||
| 
 | ||||
|         sizes: { | ||||
|             '32': { | ||||
|                 value: 32, | ||||
|                 label: 32 | ||||
|             }, | ||||
|             '48': { | ||||
|                 value: 48, | ||||
|                 label: 48 | ||||
|             }, | ||||
|             '64': { | ||||
|                 value: 64, | ||||
|                 label: 64 | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @inheritdoc | ||||
|          */ | ||||
|         updateArray: function () { | ||||
|             if (_.isUndefined(this.options)) { | ||||
|                 this.options = this.sizes; | ||||
|             } | ||||
| 
 | ||||
|             return this._super(); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,43 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define([ | ||||
|     'jquery', | ||||
|     'Magento_Ui/js/modal/confirm' | ||||
| ], function ($, confirm) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return function (buyCreditsUrl, recordTitle, quotaMessage) { | ||||
|         var confirmationContent = $.mage.__('License "' + recordTitle + '"'), | ||||
|             content = '<p>' + confirmationContent + '</p><p><b>' + quotaMessage + '</b></p><br>'; | ||||
| 
 | ||||
|         confirm({ | ||||
|             title: $.mage.__('License Adobe Stock Images?'), | ||||
|             content: content, | ||||
|             buttons: [{ | ||||
|                 text: $.mage.__('Cancel'), | ||||
|                 class: 'action-secondary action-dismiss', | ||||
| 
 | ||||
|                 /** | ||||
|                  * Close modal | ||||
|                  */ | ||||
|                 click: function () { | ||||
|                     this.closeModal(); | ||||
|                 } | ||||
|             },{ | ||||
|                 text: $.mage.__('Buy Credits'), | ||||
|                 class: 'action-primary action-accept', | ||||
| 
 | ||||
|                 /** | ||||
|                  * Close modal | ||||
|                  */ | ||||
|                 click: function () { | ||||
|                     window.open(buyCreditsUrl); | ||||
|                     this.closeModal(); | ||||
|                 } | ||||
|             }] | ||||
|         }); | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,82 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define([ | ||||
|     'jquery', | ||||
|     'Magento_Ui/js/modal/prompt', | ||||
|     'text!Magento_AdobeStockImageAdminUi/template/modal/adobe-modal-prompt-content.html' | ||||
| ], function ($, prompt, adobePromptContentTmpl) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return function (recordTitle, quotaMessage, isPreviewDownloaded, proposedfileName, fileExtension) { | ||||
|         var confirmationContent = $.mage.__('License "' + recordTitle + '"'), | ||||
|             deferred = $.Deferred(), | ||||
|             displayFieldName = !isPreviewDownloaded ? '<b>' + $.mage.__('File Name') + '</b>' : '', | ||||
|             content = '<p>' + confirmationContent + '</p><p><b>' + quotaMessage + '</b></p><br>' + displayFieldName, | ||||
|             data = { | ||||
|                 'title': $.mage.__('License Adobe Stock Images?'), | ||||
|                 'content': content, | ||||
|                 'visible': !isPreviewDownloaded, | ||||
|                 'actions': { | ||||
|                     /** | ||||
|                      * Confirm action | ||||
|                      * | ||||
|                      * @param {String} fileName | ||||
|                      */ | ||||
|                     confirm: function (fileName) { | ||||
|                         deferred.resolve(fileName); | ||||
|                     } | ||||
|                 }, | ||||
|                 'buttons': [{ | ||||
|                     text: $.mage.__('Cancel'), | ||||
|                     class: 'action-secondary action-dismiss', | ||||
| 
 | ||||
|                     /** | ||||
|                      * Close modal | ||||
|                      */ | ||||
|                     click: function () { | ||||
|                         this.closeModal(); | ||||
|                         deferred.reject(); | ||||
|                     } | ||||
|                 }, { | ||||
|                     text: $.mage.__('Confirm'), | ||||
|                     class: 'action-primary action-accept' | ||||
|                 }] | ||||
| 
 | ||||
|             }; | ||||
| 
 | ||||
|         prompt({ | ||||
|             title: data.title, | ||||
|             content:  data.content, | ||||
|             value: proposedfileName, | ||||
|             imageExtension: fileExtension, | ||||
|             visible: data.visible, | ||||
|             promptContentTmpl: adobePromptContentTmpl, | ||||
|             modalClass: 'adobe-stock-save-preview-prompt', | ||||
|             validation: true, | ||||
|             promptField: '[data-role="adobe-stock-image-name-field"]', | ||||
|             validationRules: ['required-entry', 'validate-image-name'], | ||||
|             attributesForm: { | ||||
|                 novalidate: 'novalidate', | ||||
|                 action: '', | ||||
|                 onkeydown: 'return event.key != \'Enter\';' | ||||
|             }, | ||||
|             attributesField: { | ||||
|                 name: 'name', | ||||
|                 'data-validate': '{required:true}', | ||||
|                 maxlength: '128' | ||||
|             }, | ||||
|             context: this, | ||||
|             actions: data.actions, | ||||
|             buttons: data.buttons | ||||
|         }); | ||||
| 
 | ||||
|         if (!data.visible) { | ||||
|             $('.adobe-stock-save-preview-prompt').trigger('focus'); | ||||
|         } | ||||
| 
 | ||||
|         return deferred.promise(); | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,75 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define([ | ||||
|     'jquery', | ||||
|     'Magento_Ui/js/modal/prompt', | ||||
|     'text!Magento_AdobeStockImageAdminUi/template/modal/adobe-modal-prompt-content.html' | ||||
| ], function ($, prompt, adobePromptContentTmpl) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return function (proposedfileName, fileExtension) { | ||||
|         var deferred = $.Deferred(), | ||||
|             data = { | ||||
|                 'title': $.mage.__('Save Preview'), | ||||
|                 'content': $.mage.__('File Name'), | ||||
|                 'visible': true, | ||||
|                 'actions': { | ||||
|                     /** | ||||
|                      * Resolve with the specified file name | ||||
|                      * | ||||
|                      * @param {String} specifiedFileName | ||||
|                      */ | ||||
|                     confirm: function (specifiedFileName) { | ||||
|                         deferred.resolve(specifiedFileName); | ||||
|                     } | ||||
|                 }, | ||||
|                 'buttons': [{ | ||||
|                     text: $.mage.__('Cancel'), | ||||
|                     class: 'action-secondary action-dismiss', | ||||
| 
 | ||||
|                     /** | ||||
|                      * Close modal on button click | ||||
|                      */ | ||||
|                     click: function () { | ||||
|                         this.closeModal(); | ||||
|                         deferred.reject(); | ||||
|                     } | ||||
|                 }, { | ||||
|                     text: $.mage.__('Confirm'), | ||||
|                     class: 'action-primary action-accept' | ||||
|                 }] | ||||
| 
 | ||||
|             }; | ||||
| 
 | ||||
|         prompt({ | ||||
|             title: data.title, | ||||
|             content:  data.content, | ||||
|             value: proposedfileName, | ||||
|             imageExtension: fileExtension, | ||||
|             visible: data.visible, | ||||
|             promptContentTmpl: adobePromptContentTmpl, | ||||
|             modalClass: 'adobe-stock-save-preview-prompt', | ||||
|             validation: true, | ||||
|             promptField: '[data-role="adobe-stock-image-name-field"]', | ||||
|             validationRules: ['required-entry', 'validate-image-name'], | ||||
|             attributesForm: { | ||||
|                 novalidate: 'novalidate', | ||||
|                 action: '', | ||||
|                 onkeydown: 'return event.key != \'Enter\';' | ||||
|             }, | ||||
|             attributesField: { | ||||
|                 name: 'name', | ||||
|                 'data-validate': '{required:true}', | ||||
|                 maxlength: '128' | ||||
|             }, | ||||
|             context: this, | ||||
|             actions: data.actions, | ||||
|             buttons: data.buttons | ||||
|         }); | ||||
| 
 | ||||
|         return deferred.promise(); | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,77 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define([ | ||||
|     'jquery', | ||||
|     'Magento_Ui/js/modal/prompt', | ||||
|     'text!Magento_AdobeStockImageAdminUi/template/modal/adobe-modal-prompt-content.html' | ||||
| ], function ($, prompt, adobePromptContentTmpl) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return function (proposedfileName, fileExtension) { | ||||
|         var deferred = $.Deferred(), | ||||
|             data = { | ||||
|                 'title': $.mage.__('Save'), | ||||
|                 'content': $.mage.__('File Name'), | ||||
|                 'visible': true, | ||||
|                 'actions': { | ||||
|                     /** | ||||
|                      * Resolve with the specified file name | ||||
|                      * | ||||
|                      * @param {String} fileName | ||||
|                      */ | ||||
|                     confirm: function (fileName) { | ||||
|                         deferred.resolve(fileName); | ||||
|                     } | ||||
|                 }, | ||||
|                 'buttons': [ | ||||
|                     { | ||||
|                         text: $.mage.__('Cancel'), | ||||
|                         class: 'action-secondary action-dismiss', | ||||
| 
 | ||||
|                         /** | ||||
|                          * Close modal on button click | ||||
|                          */ | ||||
|                         click: function () { | ||||
|                             this.closeModal(); | ||||
|                             deferred.reject(); | ||||
|                         } | ||||
|                     }, | ||||
|                     { | ||||
|                         text: $.mage.__('Confirm'), | ||||
|                         class: 'action-primary action-accept' | ||||
|                     } | ||||
|                 ] | ||||
|             }; | ||||
| 
 | ||||
|         prompt({ | ||||
|             title: data.title, | ||||
|             content:  data.content, | ||||
|             value: proposedfileName, | ||||
|             imageExtension: fileExtension, | ||||
|             visible: data.visible, | ||||
|             promptContentTmpl: adobePromptContentTmpl, | ||||
|             modalClass: 'adobe-stock-save-preview-prompt', | ||||
|             validation: true, | ||||
|             promptField: '[data-role="adobe-stock-image-name-field"]', | ||||
|             validationRules: ['required-entry', 'validate-image-name'], | ||||
|             attributesForm: { | ||||
|                 novalidate: 'novalidate', | ||||
|                 action: '', | ||||
|                 onkeydown: 'return event.key != \'Enter\';' | ||||
|             }, | ||||
|             attributesField: { | ||||
|                 name: 'name', | ||||
|                 'data-validate': '{required:true}', | ||||
|                 maxlength: '128' | ||||
|             }, | ||||
|             context: this, | ||||
|             actions: data.actions, | ||||
|             buttons: data.buttons | ||||
|         }); | ||||
| 
 | ||||
|         return deferred.promise(); | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,120 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| /* global Base64 */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'Magento_Ui/js/modal/confirm' | ||||
| ], function ($, confirm) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return { | ||||
|         jsTreeRootFolderId: 'root', | ||||
|         jsTreeFolderNameMaxLength: 20, | ||||
| 
 | ||||
|         /** | ||||
|          * Locate downloaded image in media browser | ||||
|          * | ||||
|          * @param {String} path | ||||
|          */ | ||||
|         locate: function (path) { | ||||
|             var imageFolder = this.selectFolder(path), | ||||
|                 imageFilename = path.substring(path.lastIndexOf('/') + 1), | ||||
|                 locatedImage; | ||||
| 
 | ||||
|             if (imageFolder.length) { | ||||
|                 locatedImage = $('div[data-row="file"]:has(img[alt=\"' + imageFilename + '\"])'); | ||||
| 
 | ||||
|                 return locatedImage.length ? locatedImage : false; | ||||
|             } | ||||
| 
 | ||||
|             $.ajaxSetup({ | ||||
|                 async: true | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Select folder | ||||
|          * | ||||
|          * @param {String} path | ||||
|          */ | ||||
|         selectFolder: function (path) { | ||||
|             var imageFolder, | ||||
|                 pathId, | ||||
|                 imagePath = path.replace(/^\/+/, ''), | ||||
|                 folderPathParts = imagePath.split('/').slice(0, -1); | ||||
| 
 | ||||
|             $.ajaxSetup({ | ||||
|                 async: false | ||||
|             }); | ||||
| 
 | ||||
|             if (folderPathParts.length > 1) { | ||||
|                 this.openFolderTree(folderPathParts); | ||||
|             } | ||||
| 
 | ||||
|             pathId = Base64.idEncode(folderPathParts.join('/')); | ||||
|             imageFolder = $('.jstree li[data-id="' + pathId + '"]').children('a'); | ||||
| 
 | ||||
|             if (!imageFolder.length) { | ||||
|                 imageFolder = $('.jstree li[data-id="' + this.jsTreeRootFolderId + '"]') | ||||
|                     .children('a'); | ||||
|             } | ||||
| 
 | ||||
|             if (imageFolder.length) { | ||||
|                 imageFolder[0].click(); | ||||
|             } | ||||
| 
 | ||||
|             return imageFolder; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Show popup that image cannot be located | ||||
|          */ | ||||
|         notLocated: function () { | ||||
|             confirm({ | ||||
|                 title: $.mage.__('The image cannot be located'), | ||||
|                 content: $.mage.__('We cannot find this image in the media gallery.'), | ||||
|                 buttons: [{ | ||||
|                     text: $.mage.__('Ok'), | ||||
|                     class: 'action-primary', | ||||
|                     attr: {}, | ||||
| 
 | ||||
|                     /** | ||||
|                      * Close modal on button click | ||||
|                      */ | ||||
|                     click: function (event) { | ||||
|                         this.closeModal(event); | ||||
|                     } | ||||
|                 }] | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Open folder Tree | ||||
|          * | ||||
|          * @param {Array} folderPathParts | ||||
|          */ | ||||
|         openFolderTree: function (folderPathParts) { | ||||
|             var i, | ||||
|                 pathId, | ||||
|                 openFolderButton, | ||||
|                 folderPath = ''; | ||||
| 
 | ||||
|             for (i = 0; i < folderPathParts.length - 1; i++) { | ||||
|                 if (folderPath === '') { | ||||
|                     folderPath = folderPathParts[i]; | ||||
|                 } else { | ||||
|                     folderPath = folderPath + '/' + folderPathParts[i]; | ||||
|                 } | ||||
|                 pathId = Base64.idEncode(folderPath); | ||||
|                 openFolderButton = $('.jstree li[data-id="' + pathId + '"].jstree-closed').children('.jstree-icon'); | ||||
| 
 | ||||
|                 if (openFolderButton.length) { | ||||
|                     openFolderButton.click(); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,109 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'underscore', | ||||
|     'Magento_MediaGalleryUi/js/grid/columns/image/actions', | ||||
|     'Magento_MediaGalleryUi/js/action/getDetails', | ||||
|     'mage/translate' | ||||
| ], function ($, _, Action, getDetails) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Action.extend({ | ||||
|         defaults: { | ||||
|             template: 'Magento_AdobeStockImageAdminUi/mediaGallery/grid/columns/image/licenseActions', | ||||
|             licenseAction: { | ||||
|                 name: 'license', | ||||
|                 title: $.mage.__('License'), | ||||
|                 handler: 'licenseImageAction' | ||||
|             }, | ||||
|             modules: { | ||||
|                 image: '${ $.imageComponent }' | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Initialize the component | ||||
|          * | ||||
|          * @returns {Object} | ||||
|          */ | ||||
|         initialize: function () { | ||||
|             this._super(); | ||||
|             this.actionsList.push(this.licenseAction); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Init observable variables | ||||
|          * | ||||
|          * @return {Object} | ||||
|          */ | ||||
|         initObservable: function () { | ||||
|             this._super() | ||||
|                 .observe([ | ||||
|                     'visible' | ||||
|                 ]); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * License image | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          */ | ||||
|         licenseImageAction: function (record) { | ||||
|             this.getImageRecord(record.id); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Check if image licensed | ||||
|          * | ||||
|          * @param {Object} record | ||||
|          * @param {Object} name | ||||
|          */ | ||||
|         isVisible: function (record, name) { | ||||
|             if (name === this.licenseAction.name) { | ||||
|                 if (_.isUndefined(record.overlay) || record.overlay === '') { | ||||
|                     return false; | ||||
|                 } | ||||
| 
 | ||||
|                 return true; | ||||
|             } | ||||
| 
 | ||||
|             return true; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Get image record and start license process | ||||
|          * | ||||
|          * @param {Number} imageId | ||||
|          */ | ||||
|         getImageRecord: function (imageId) { | ||||
|             getDetails(this.imageDetailsUrl, [imageId]).then(function (imageDetails) { | ||||
|                 var id = imageDetails[imageId]['adobe_stock'][0].value; | ||||
| 
 | ||||
|                 this.image().actions().licenseProcess( | ||||
|                     id, | ||||
|                     imageDetails[imageId].title, | ||||
|                     imageDetails[imageId].path, | ||||
|                     imageDetails[imageId]['content_type'], | ||||
|                     true | ||||
|                 ).then(function () { | ||||
|                     this.image().actions().login().getUserQuota(); | ||||
|                     this.imageModel().reloadGrid(); | ||||
|                     this.imageModel().addMessage('success', $.mage.__('The image has been licensed.')); | ||||
|                 }.bind(this)).fail(function (error) { | ||||
|                     if (error) { | ||||
|                         this.imageModel().addMessage('error', error); | ||||
|                     } | ||||
|                 }.bind(this)); | ||||
|             }.bind(this)).fail(function (message) { | ||||
|                 this.imageModel().addMessage('error', message); | ||||
|             }.bind(this)); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,23 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'Magento_MediaGalleryUi/js/grid/columns/image' | ||||
| ], function (Image) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Image.extend({ | ||||
|         defaults: { | ||||
|             viewConfig: [ | ||||
|                 { | ||||
|                     component: 'Magento_AdobeStockImageAdminUi/js/mediaGallery/grid/columns/image/licenseActions', | ||||
|                     name: '${ $.name }_actions', | ||||
|                     imageModelName: '${ $.name }', | ||||
|                     imageDetailsUrl: '${ $.imageDetailsurl }', | ||||
|                     imageComponent: '${ $.imageComponent }' | ||||
|                 } | ||||
|             ] | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,59 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define([ | ||||
|     'uiElement', | ||||
|     'jquery', | ||||
|     'mage/translate' | ||||
| ], function (Element, $, $t) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Element.extend({ | ||||
|         defaults: { | ||||
|             containerId: '#adobe-stock-images-search-modal', | ||||
|             masonryComponentPath: 'adobe_stock_images_listing.adobe_stock_images_listing.adobe_stock_images_columns', | ||||
|             dataSourcePath: 'adobe_stock_images_listing.adobe_stock_images_listing_data_source', | ||||
|             modules: { | ||||
|                 masonry: '${ $.masonryComponentPath }', | ||||
|                 source: '${ $.dataSourcePath }' | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Init component | ||||
|          * | ||||
|          * @return {exports} | ||||
|          */ | ||||
|         initialize: function () { | ||||
|             this._super(); | ||||
| 
 | ||||
|             $(this.containerId).modal({ | ||||
|                 type: 'slide', | ||||
|                 buttons: [], | ||||
|                 modalClass: 'adobe-stock-modal', | ||||
|                 title: $t('Adobe Stock') | ||||
|             }).on('openModal', function () { | ||||
|                 this.masonry().setLayoutStylesWhenLoaded(); | ||||
|             }.bind(this)); | ||||
| 
 | ||||
|             try { | ||||
|                 $(this.containerId).applyBindings(); | ||||
|             } catch (e) { | ||||
|                 //already bounded
 | ||||
|             } | ||||
| 
 | ||||
|             $(window).on('fileDeleted.mediabrowser', this.reloadGrid.bind(this)); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Update listing data | ||||
|          */ | ||||
|         reloadGrid: function () { | ||||
|             this.source().set('params.t', Date.now()); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,62 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([], function () { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return { | ||||
|         /** | ||||
|          * Extracts image name from its path | ||||
|          * | ||||
|          * @param {String} path | ||||
|          * @returns {String} | ||||
|          */ | ||||
|         getImageNameFromPath: function (path) { | ||||
|             var filePathArray = path.split('/'), | ||||
|                 imageIndex = filePathArray.length - 1; | ||||
| 
 | ||||
|             return filePathArray[imageIndex].substring(0, filePathArray[imageIndex].lastIndexOf('.')); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Generate meaningful name image file, | ||||
|          * allow only alphanumerics, dashes, and underscores | ||||
|          * | ||||
|          * @param {String} title | ||||
|          * @param {Number} id | ||||
|          * @return string | ||||
|          */ | ||||
|         generateImageName: function (title, id) { | ||||
|             var fileName = title.substring(0, 32) | ||||
|                 .replace(/[^a-zA-Z0-9_]/g, '-') | ||||
|                 .replace(/-{2,}/g, '-') | ||||
|                 .toLowerCase(); | ||||
| 
 | ||||
|             /* If the filename does not contain latin chars, use ID as a filename */ | ||||
|             return fileName === '-' ? id : fileName; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Get image file extension | ||||
|          * | ||||
|          * @param {String} contentType | ||||
|          * @return string | ||||
|          */ | ||||
|         getImageExtension: function (contentType) { | ||||
|             return contentType.match(/[^/]{1,4}$/); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Create path | ||||
|          * | ||||
|          * @param {String} directoryPath | ||||
|          * @param {String} fileName | ||||
|          * @param {String} contentType | ||||
|          * @returns {String} | ||||
|          */ | ||||
|         buildPath: function (directoryPath, fileName, contentType) { | ||||
|             return directoryPath + '/' + fileName + '.' + this.getImageExtension(contentType); | ||||
|         } | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,186 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'Magento_AdobeIms/js/signIn', | ||||
|     'Magento_AdobeIms/js/action/authorization', | ||||
|     'Magento_Ui/js/modal/confirm' | ||||
| ], function ($, signIn, auth, confirm) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return signIn.extend({ | ||||
| 
 | ||||
|         defaults: { | ||||
|             userQuota: {}, | ||||
|             // eslint-disable-next-line max-len
 | ||||
|             dataProvider: 'name = adobe_stock_images_listing.adobe_stock_images_listing_data_source, ns = adobe_stock_images_listing', | ||||
|             // eslint-disable-next-line max-len
 | ||||
|             previewProvider: 'name = adobe_stock_images_listing.adobe_stock_images_listing.adobe_stock_images_columns.preview, ns = adobe_stock_images_listing', | ||||
|             quotaUrl: 'adobe_stock/license/quota', | ||||
|             modules: { | ||||
|                 source: '${ $.dataProvider }', | ||||
|                 preview: '${ $.previewProvider }' | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @inheritdoc | ||||
|          */ | ||||
|         initObservable: function () { | ||||
|             this._super().observe(['userQuota']); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Login to Adobe | ||||
|          * | ||||
|          * @return {*} | ||||
|          */ | ||||
|         login: function () { | ||||
|             var deferred = $.Deferred(); | ||||
| 
 | ||||
|             if (this.user().isAuthorized) { | ||||
|                 return deferred.resolve(); | ||||
|             } | ||||
|             auth(this.loginConfig) | ||||
|                 .then(function (response) { | ||||
|                     this.loadUserProfile(); | ||||
|                     deferred.resolve(response); | ||||
|                 }.bind(this)) | ||||
|                 .fail(function (error) { | ||||
|                     deferred.reject(error); | ||||
|                 }); | ||||
| 
 | ||||
|             return deferred.promise(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Login action with popup on error.. | ||||
|          */ | ||||
|         loginClick: function () { | ||||
|             this.login().fail(function (error) { | ||||
|                 this.showLoginErrorPopup(error); | ||||
|             }.bind(this)); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Show popup that user failed to login. | ||||
|          */ | ||||
|         showLoginErrorPopup: function (error) { | ||||
|             confirm({ | ||||
|                 title: $.mage.__('Couldn\'t log you in'), | ||||
|                 content: error, | ||||
|                 buttons: [{ | ||||
|                     text: $.mage.__('Ok'), | ||||
|                     class: 'action-primary action-accept' | ||||
|                 }], | ||||
|                 actions: { | ||||
| 
 | ||||
|                     /** | ||||
|                        * Close modal | ||||
|                        */ | ||||
|                     confirm: function (event) { | ||||
|                         this.closeModal(event); | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Logout from adobe account | ||||
|          */ | ||||
|         logout: function () { | ||||
|             $.ajax({ | ||||
|                 type: 'POST', | ||||
|                 url: this.logoutUrl, | ||||
|                 data: { | ||||
|                     'form_key': window.FORM_KEY | ||||
|                 }, | ||||
|                 dataType: 'json', | ||||
|                 context: this, | ||||
|                 showLoader: true, | ||||
|                 success: function () { | ||||
|                     this.user({ | ||||
|                         isAuthorized: false, | ||||
|                         name: '', | ||||
|                         email: '', | ||||
|                         image: this.defaultProfileImage | ||||
|                     }); | ||||
|                 }.bind(this), | ||||
| 
 | ||||
|                 /** | ||||
|                  * @param {Object} response | ||||
|                  * @returns {String} | ||||
|                  */ | ||||
|                 error: function (response) { | ||||
|                     return response.message; | ||||
|                 } | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Retrieves full user quota. | ||||
|          */ | ||||
|         getUserQuota: function () { | ||||
|             $.ajax({ | ||||
|                 type: 'GET', | ||||
|                 url: this.quotaUrl, | ||||
|                 dataType: 'json', | ||||
|                 context: this, | ||||
| 
 | ||||
|                 /** | ||||
|                  * @param {Object} response | ||||
|                  * @returns void | ||||
|                  */ | ||||
|                 success: function (response) { | ||||
|                     this.userQuota(response.result); | ||||
|                 }, | ||||
| 
 | ||||
|                 /** | ||||
|                  * @param {Object} response | ||||
|                  * @returns {String} | ||||
|                  */ | ||||
|                 error: function (response) { | ||||
|                     return response.message; | ||||
|                 } | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @inheritdoc | ||||
|          */ | ||||
|         loadUserProfile: function () { | ||||
|             $.ajax({ | ||||
|                 type: 'GET', | ||||
|                 url: this.profileUrl, | ||||
|                 dataType: 'json', | ||||
|                 context: this, | ||||
| 
 | ||||
|                 /** | ||||
|                  * @param {Object} response | ||||
|                  * @returns void | ||||
|                  */ | ||||
|                 success: function (response) { | ||||
|                     this.user({ | ||||
|                         isAuthorized: true, | ||||
|                         name: response.result.name, | ||||
|                         email: response.result.email, | ||||
|                         image: response.result.image | ||||
|                     }); | ||||
|                     this.getUserQuota(); | ||||
|                 }, | ||||
| 
 | ||||
|                 /** | ||||
|                  * @param {Object} response | ||||
|                  * @returns {String} | ||||
|                  */ | ||||
|                 error: function (response) { | ||||
|                     return response.message; | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,18 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define([ | ||||
|     'jquery', | ||||
|     'mage/translate', | ||||
|     'jquery/validate' | ||||
| ], function ($, $t) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     $.validator.addMethod( | ||||
|         'validate-image-name', function (value) { | ||||
|             return /^[a-zA-Z0-9\-\_]+$/i.test(value); | ||||
| 
 | ||||
|         }, $t('Please name the file using only letters, numbers, underscores and dashes')); | ||||
| }); | ||||
|  | @ -1,56 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <div class="masonry-image-preview" if="$col.isVisible($row())" data-image-preview ko-style="$col.getStyles()"> | ||||
|     <div class="container"> | ||||
|         <div class="action-buttons preview-buttons"> | ||||
|             <button class="action-previous" type="button" disable="$col.cannotViewPrevious($row())" click="$col.prev.bind($col, $row())"> | ||||
|                 <span translate="'Previous'"></span> | ||||
|             </button> | ||||
|             <button class="action-next" type="button" disable="$col.cannotViewNext($row())" click="$col.next.bind($col, $row())"> | ||||
|                 <span translate="'Next'"></span> | ||||
|             </button> | ||||
|             <button class="action-close" type="button" click="$col.hide.bind($col)"> | ||||
|                 <span translate="'Close'"></span> | ||||
|             </button> | ||||
|         </div> | ||||
| 
 | ||||
|         <div class="preview-row-content"> | ||||
|             <img class="preview" attr="src: $col.displayedRecord().thumbnail_500_url, alt: $col.displayedRecord().title"> | ||||
|             <div class="info"> | ||||
|                 <h3 class="title" text="$col.displayedRecord().title" if="$col.displayedRecord().title"></h3> | ||||
|                 <div class="author" if="$col.displayedRecord().creator_name"> | ||||
|                     <span translate="'By'"></span><span text="' ' + $col.displayedRecord().creator_name" ></span> | ||||
|                 </div> | ||||
| 
 | ||||
|                 <div class="actions"> | ||||
|                     <scope args="actions"> | ||||
|                         <render args="getTemplate()" ></render> | ||||
|                     </scope> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
| 
 | ||||
|         <div class="attributes" data-role="image-attributes-value"> | ||||
|             <each args="$col.getDisplayAttributes()"> | ||||
|                 <div class="attribute"> | ||||
|                     <span class="title" translate="name"></span> | ||||
|                     <div class="value"> | ||||
|                         <span text="value"></span> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </each> | ||||
|         </div> | ||||
| 
 | ||||
|         <scope args="related"> | ||||
|             <render args="getTemplate()"></render> | ||||
|         </scope> | ||||
| 
 | ||||
|         <div class="keywords-container" ko-scope="keywords"> | ||||
|             <render args="getTemplate()"></render> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
|  | @ -1,9 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <div if="$col.isVisible($row())" ko-style="$col.getStyles($row())" class="masonry-image-overlay"> | ||||
|     <span text="$col.getLabel($row())"></span> | ||||
| </div> | ||||
|  | @ -1,33 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <ul class="messages" if="getMessages().length > 0"> | ||||
|     <each args="getMessages()"> | ||||
|         <div class="messages"> | ||||
|             <div attr="class: 'message message-'+code"> | ||||
|                 <div data-ui-id="messages-message-error"> | ||||
|                     <span html="messageUnsanitizedHtml"></span> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </each> | ||||
| </ul> | ||||
| <button class="action-secondary" type="button" visible="!isDownloaded() && !isLicensed()" click="function(){ savePreviewClick() }"> | ||||
|     <span translate="'Save Preview'"></span> | ||||
| </button> | ||||
| <button class="action-secondary" type="button" visible="isDownloaded()" click="function(){ openInMediaGalleryClick() }"> | ||||
|     <span translate="'Open in Media Gallery'"></span> | ||||
| </button> | ||||
| <button class="action-default primary" | ||||
|         type="button" | ||||
|         attr="title: getLicenseButtonTitle()" | ||||
|         visible="!isLicensedLocally() && !isLicensed()" click="function () { licenseClick(); }"> | ||||
|     <span text="getLicenseButtonTitle()"></span> | ||||
| </button> | ||||
| <button class="action-default primary" type="button" visible="isLicensed()" click="function () { saveLicensedClick(); }"> | ||||
|     <span translate="'Save Licensed'"></span> | ||||
| </button> | ||||
| 
 | ||||
|  | @ -1,19 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <div class="keywords"> | ||||
|     <div class="title" translate="'Similar Keywords'"></div> | ||||
|     <each args="getKeywords($col.displayedRecord())"> | ||||
|         <div class="keyword" css="{ 'hide': $index() >= $parent.getKeywordsLimit()}"> | ||||
|             <a href="" class="value" click="function(){ $parent.searchByKeyWord(name) }"> | ||||
|                 <span text="name"></span> | ||||
|             </a> | ||||
|         </div> | ||||
|     </each> | ||||
|     <button visible="canViewMoreKeywords" click="function(){ viewAllKeywords($col.displayedRecord()) }"> | ||||
|         <span translate="'View all'"></span> | ||||
|     </button> | ||||
| </div> | ||||
|  | @ -1,76 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <div if="isVisible($row())" | ||||
|      class="related-container"> | ||||
|     <div id="adobe-stock-tabs" | ||||
|          class="adobe-stock-tabs" | ||||
|          data-bind="mageInit: { | ||||
|                     'mage/backend/tabs': { | ||||
|                     destination: '#adobe-stock-tabs-content', | ||||
|                     shadowTabs: [], | ||||
|                 } | ||||
|             }" afterRender="disableTabsKeyDownEvent()"> | ||||
|         <ul class="tabs-horiz"> | ||||
|             <li if="showSeriesTab($row())"> | ||||
|                 <a id="series_tab" attr="'href': '#series_content_' + $row().id"> | ||||
|                     <span class="title" translate="'More from this series'"></span> | ||||
|                 </a> | ||||
|             </li> | ||||
|             <li if="showModelTab($row())"> | ||||
|                 <a id="model_tab" attr="'href': '#model_content_' + $row().id"> | ||||
|                     <span class="title" translate="'More from this model'"></span> | ||||
|                 </a> | ||||
|             </li> | ||||
|         </ul> | ||||
|     </div> | ||||
| 
 | ||||
|     <div id="adobe-stock-tabs-content" | ||||
|          class="adobe-stock-related-images-tab-content"> | ||||
|         <div class="spinner related-loader" visible="loader"> | ||||
|             <span></span><span></span><span></span><span></span> | ||||
|             <span></span><span></span><span></span><span></span> | ||||
|         </div> | ||||
|         <div if="showSeriesTab($row())" attr="'id': 'series_content_' + $row().id"> | ||||
|             <each args="getSeries($row())"> | ||||
|                 <div class="thumbnail" click="function(){ $parent.switchImagePreviewToSeriesImage($data) }"> | ||||
|                     <img attr="src: thumbnail_url, alt: title"> | ||||
|                 </div> | ||||
|             </each> | ||||
|             <if args="canShowMoreSeriesImages($row())"> | ||||
|                 <div class="see-more-wrapper" click="function(){ seeMoreFromSeries($row()) }"> | ||||
|                     <div class="see-more-content"> | ||||
|                         <div class="three-dots"> | ||||
|                             <span class="dots"></span> | ||||
|                             <span class="dots"></span> | ||||
|                             <span class="dots"></span> | ||||
|                         </div> | ||||
|                         <a href="" class="see-more">See more</a> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </if> | ||||
|         </div> | ||||
|         <div if="showModelTab($row())" attr="'id': 'model_content_' + $row().id"> | ||||
|             <each args="getModel($row())"> | ||||
|                 <div class="thumbnail" click="function(){ $parent.switchImagePreviewToModelImage($data) }"> | ||||
|                     <img attr="src: thumbnail_url, alt: title"> | ||||
|                 </div> | ||||
|             </each> | ||||
|             <if args="canShowMoreModelImages($row())"> | ||||
|                 <div class="see-more-wrapper" click="function(){ seeMoreFromModel($row()) }"> | ||||
|                     <div class="see-more-content"> | ||||
|                         <div class="three-dots"> | ||||
|                             <span class="dots"></span> | ||||
|                             <span class="dots"></span> | ||||
|                             <span class="dots"></span> | ||||
|                         </div> | ||||
|                         <a href="" class="see-more">See more</a> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </if> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
|  | @ -1,26 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <div class="admin__field admin__adobe-stock-image-checkbox" visible="visible" css="$data.additionalClasses"> | ||||
|     <div class="admin__field-control" | ||||
|          css="'_with-tooltip': $data.tooltip"> | ||||
|         <label class="admin__form-field-label" if="$data.label" attr="for: uid"> | ||||
|             <span translate="label" attr="'data-config-scope': $data.scopeLabel"></span> | ||||
|         </label> | ||||
|         <render args="tooltipTpl" if="$data.tooltip"></render> | ||||
|     </div> | ||||
|     <div class="admin__field admin__field-option"> | ||||
|         <input type="checkbox" | ||||
|                class="admin__control-checkbox" | ||||
|                ko-checked="$data.checked" | ||||
|                disable="disabled" | ||||
|                ko-value="value" | ||||
|                hasFocus="focused" | ||||
|                attr="id: uid, name: inputName"/> | ||||
| 
 | ||||
|         <label class="admin__field-label" text="description" attr="for: uid"></label> | ||||
|     </div> | ||||
| </div> | ||||
|  | @ -1,34 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <div class="admin__data-grid-filters-current" css="_show: hasPreviews()"> | ||||
|     <div class="admin__current-filters-title-wrap"> | ||||
|         <span class="admin__current-filters-title" translate="'Active filters\\:'"></span> | ||||
|     </div> | ||||
|     <div class="admin__current-filters-list-wrap"> | ||||
|         <ul class="admin__current-filters-list" data-role="filter-list"> | ||||
|             <each args="elems"> | ||||
|                 <li outereach="previews"> | ||||
|                     <span text="label + '\\:'"></span> | ||||
|                     <span if="typeof preview ==='string' && label === 'Color'" class="color-rectangle" ko-style="{ 'background-color' :  preview }"></span> | ||||
|                     <span if="typeof preview === 'string'" text="preview"></span> | ||||
|                     <span if="typeof preview === 'object'"> | ||||
|                         <text args="preview[0] || '...'"></text> - <text args="preview[1] || '...'"></text> | ||||
|                     </span> | ||||
|                     <button class="action-remove" type="button" | ||||
|                         data-action="grid-filter-remove-chip" | ||||
|                         click="$parent.clear.bind($parent, elem)"> | ||||
|                         <span translate="'Remove'"></span> | ||||
|                     </button> | ||||
|                 </li> | ||||
|             </each> | ||||
|         </ul> | ||||
|     </div> | ||||
|     <div class="admin__current-filters-actions-wrap"> | ||||
|         <button class="action-tertiary action-clear" type="button" click="clear" translate="'Clear all'" | ||||
|             attr="'data-action': hasPreviews() ? 'grid-filter-reset' : ''"></button> | ||||
|     </div> | ||||
| </div> | ||||
|  | @ -1,17 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <label class="admin__form-field-label" if="$data.label" attr="for: uid"> | ||||
|     <span translate="label" attr="'data-config-scope': $data.scopeLabel"></span> | ||||
| </label> | ||||
| <div class="admin__field-control" | ||||
|      visible="visible" | ||||
|      css="$data.additionalClasses"> | ||||
|     <input type="hidden" class="colorpicker-spectrum" colorPicker="colorPickerConfig" disable="disabled" /> | ||||
|     <input type="text" class="admin__control-text colorpicker-input" | ||||
|            ko-value="value" hasFocus="focused" disable="disabled" | ||||
|            attr="name: inputName, id: uid, placeholder: placeholder"/> | ||||
| </div> | ||||
|  | @ -1,32 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <div class="admin__data-grid-header" data-role="masonry-main-toolbar" afterRender="$data.setToolbarNode"> | ||||
|     <div class="admin__data-grid-header-row"> | ||||
|         <div class="admin__data-grid-actions-wrap" each="getRegion('dataGridActions')" render=""></div> | ||||
|         <each args="getRegion('dataGridFilters')" render=""></each> | ||||
|     </div> | ||||
|     <div class="admin__data-grid-header-row row row-gutter"> | ||||
|         <div class="col-xs-2" if="hasChild('listing_massaction')" ko-scope="requestChild('listing_massaction')" render=""></div> | ||||
|         <div css=" | ||||
|             'col-xs-10': hasChild('listing_massaction'), | ||||
|             'col-xs-12': !hasChild('listing_massaction')"> | ||||
|             <div class="row"> | ||||
|                 <div class="col-xs-4"> | ||||
|                     <div class="masonry-results-number" ko-scope="requestChild('listing_paging')"> | ||||
|                         <render args="totalTmpl"></render> | ||||
|                     </div> | ||||
|                     <each args="getRegion('sorting')" render=""></each> | ||||
|                 </div> | ||||
|                 <div class="col-xs-8" ko-scope="requestChild('listing_paging')"> | ||||
|                     <div render=""></div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
| 
 | ||||
| <render args="stickyTmpl" if="$data.sticky"></render> | ||||
|  | @ -1,17 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <div class="adobe-stock-image-details image-details-section" if="$parent.image().adobe_stock"> | ||||
|     <h3 translate="'Adobe Stock'"></h3> | ||||
|     <div class="attributes"> | ||||
|         <each args="$parent.image().adobe_stock"> | ||||
|             <div class="attribute"  if="value"> | ||||
|                 <span class="title" translate="title"></span> | ||||
|                 <div class="value" text="value"></div> | ||||
|             </div> | ||||
|         </each> | ||||
|     </div> | ||||
| </div> | ||||
|  | @ -1,14 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <each args="{ data: actionsList, as: 'action' }"> | ||||
|     <li> | ||||
|         <a class="action-menu-item" href="" if="$parent.isVisible($row(), action.name)" | ||||
|            text="action.title" click="$parent[action.handler].bind($parent, $row())" | ||||
|            attr="{'data-ui-id': 'action-' + action.name}"> | ||||
|         </a> | ||||
|     </li> | ||||
| </each> | ||||
|  | @ -1,23 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <% if (data.visible) { %> | ||||
| <form <%= formAttr %>> | ||||
|     <fieldset class="admin__fieldset"> | ||||
|         <div class="admin__field admin__field-wide"> | ||||
|             <% if(data.label){ %> | ||||
|             <label for="prompt-field-<%- data.id %>" class="admin__field-label"> | ||||
|                 <span><%= data.label %></span> | ||||
|             </label> | ||||
|             <% } %> | ||||
|             <div class="admin__field-control admin__field-with-image-ext"> | ||||
|                 <input type="text" data-role="adobe-stock-image-name-field" id="prompt-field-<%- data.id %>" placeholder="Enter the filename (no special characters)" class="admin__control-text" <%= inputAttr %>/> | ||||
|                 <span class="image-ext">.<%= data.imageExtension %></span> | ||||
|             </div> | ||||
|         </div> | ||||
|     </fieldset> | ||||
| </form> | ||||
| <% } %> | ||||
|  | @ -1,58 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <button | ||||
|     class="adobe-sign-in-button" | ||||
|     id="adobeImsSignIn" | ||||
|     data-role="signInBtn" | ||||
|     click="loginClick" | ||||
|     visible="!user().isAuthorized" | ||||
|     type="button"> | ||||
|     <span>Sign In</span> | ||||
| </button> | ||||
| <div class="adobe-user-information"> | ||||
|     <div class="admin__action-dropdown-wrap" data-bind="collapsible"> | ||||
|         <img class="adobe-profile-image-small" | ||||
|              attr="src: user().image" | ||||
|              visible="user().isAuthorized"/> | ||||
|         <button | ||||
|             type="button" | ||||
|             data-toggle="dropdown" | ||||
|             class="adobe-user-name admin__action-dropdown" | ||||
|             visible="user().isAuthorized" | ||||
|             data-bind="toggleCollapsible"> | ||||
|             <span text="user().name"></span> | ||||
|         </button> | ||||
|         <ul class="admin__action-dropdown-menu adobe-user-popup" visible="user().isAuthorized"> | ||||
|             <li> | ||||
|                 <img class="adobe-profile-image-large" attr="src: user().image"> | ||||
|             </li> | ||||
|             <li class="adobe-user-info"> | ||||
|                 <ul> | ||||
|                     <li><!--ko text: user().name--><!--/ko--></li> | ||||
|                     <li><!--ko text: user().email--><!--/ko--></li> | ||||
|                     <li><a target="_blank" href="https://account.adobe.com/profile">Manage Account</a></li> | ||||
|                 </ul> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <div class="adobe-user-info"> | ||||
|                     <span>AVAILABLE</span> | ||||
|                     <p><b><!--ko text: userQuota().images--><!--/ko--></b> Images | <b><!--ko text: userQuota().credits --> | ||||
|                         <!--/ko--></b> Credits</p> | ||||
|                 </div> | ||||
|                 <button | ||||
|                         class="adobe-sign-out-button" | ||||
|                         id="adobeImsSignOut" | ||||
|                         click="logout" | ||||
|                         data-bind="visible: !isGlobalSignInEnabled" | ||||
|                         data-role="signOutBtn" | ||||
|                         type="button"> | ||||
|                     <span>Sign Out</span> | ||||
|                 </button> | ||||
|             </li> | ||||
|         </ul> | ||||
|     </div> | ||||
| </div> | ||||
|  | @ -1,15 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <div class="masonry-sorting"> | ||||
|     <b><translate args="'Sort by'"></translate>:</b> | ||||
|     <select class="admin__control-select" | ||||
|             options="options" | ||||
|             optionsValue="'value'" | ||||
|             optionsText="'label'" | ||||
|             ko-value="selectedOption"> | ||||
|     </select> | ||||
| </div> | ||||
|  | @ -1,75 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| /** | ||||
|  * @api | ||||
|  */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'Magento_Ui/js/modal/alert', | ||||
|     'jquery/ui' | ||||
| ], function ($, alert) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     $.widget('mage.testConnection', { | ||||
|         options: { | ||||
|             url: '', | ||||
|             elementId: '', | ||||
|             successText: '', | ||||
|             failedText: '', | ||||
|             fieldMapping: '' | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Bind handlers to events | ||||
|          */ | ||||
|         _create: function () { | ||||
|             this._on({ | ||||
|                 'click': $.proxy(this._connect, this) | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Method triggers an AJAX request to check search engine connection | ||||
|          * @private | ||||
|          */ | ||||
|         _connect: function () { | ||||
|             var result = this.options.failedText, | ||||
|                 element =  $('#' + this.options.elementId), | ||||
|                 self = this, | ||||
|                 params = {}, | ||||
|                 msg = '', | ||||
|                 fieldToCheck = this.options.fieldToCheck || 'success'; | ||||
| 
 | ||||
|             element.removeClass('success').addClass('fail'); | ||||
|             $.each(JSON.parse(this.options.fieldMapping), function (key, el) { | ||||
|                 params[key] = $('#' + el).val(); | ||||
|             }); | ||||
|             $.ajax({ | ||||
|                 url: this.options.url, | ||||
|                 showLoader: true, | ||||
|                 data: params, | ||||
|                 headers: this.options.headers || {} | ||||
|             }).done(function (response) { | ||||
|                 if (response[fieldToCheck]) { | ||||
|                     element.removeClass('fail').addClass('success'); | ||||
|                     result = self.options.successText; | ||||
|                 } else { | ||||
|                     msg = response.errorMessage; | ||||
| 
 | ||||
|                     if (msg) { | ||||
|                         alert({ | ||||
|                             content: msg | ||||
|                         }); | ||||
|                     } | ||||
|                 } | ||||
|             }).always(function () { | ||||
|                 $('#' + self.options.elementId + '_result').text(result); | ||||
|             }); | ||||
|         } | ||||
|     }); | ||||
| 
 | ||||
|     return $.mage.testConnection; | ||||
| }); | ||||
|  | @ -1,84 +0,0 @@ | |||
| <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="120px" | ||||
| 	 height="105px" viewBox="0 0 120 105" enable-background="new 0 0 120 105" xml:space="preserve"> | ||||
| <g id="Layer_1" display="none"> | ||||
| 	<rect x="2.904" y="27.946" display="inline" fill="#F06524" width="113.745" height="12.408"/> | ||||
| 	<path display="inline" fill="#636667" d="M95.811,85.511c-0.753-2.551-1.775-5.013-3.059-7.344 | ||||
| 		c-0.207-0.387-0.134-0.884,0.191-1.208c2.857-2.869,2.857-7.489,0.013-10.346l-3.649-3.686c-2.873-2.86-7.493-2.86-10.348-0.016 | ||||
| 		c-0.334,0.336-0.828,0.409-1.228,0.193c-2.321-1.271-4.785-2.295-7.337-3.047c-0.419-0.126-0.714-0.525-0.712-0.979 | ||||
| 		c0.004-1.947-0.766-3.812-2.139-5.187c-1.37-1.377-3.233-2.148-5.176-2.148h-5.184c-4.039,0-7.312,3.274-7.312,7.314 | ||||
| 		c0.001,0.464-0.294,0.863-0.728,0.993c-2.537,0.747-5.002,1.771-7.335,3.051c-0.391,0.213-0.882,0.143-1.199-0.178 | ||||
| 		c-1.377-1.381-3.236-2.15-5.176-2.15c-1.938,0-3.799,0.77-5.168,2.143l-3.688,3.744c-2.833,2.845-2.833,7.465,0.011,10.321 | ||||
| 		c0.336,0.336,0.41,0.835,0.191,1.24c-1.269,2.312-2.294,4.772-3.045,7.324c-0.487,1.657,0.46,3.396,2.117,3.885 | ||||
| 		c1.658,0.487,3.396-0.46,3.884-2.117c0.624-2.12,1.475-4.164,2.538-6.101c1.544-2.863,1.027-6.375-1.262-8.653 | ||||
| 		c-0.405-0.407-0.405-1.082,0.009-1.497l3.686-3.742c0.181-0.182,0.449-0.291,0.727-0.291c0.279,0,0.545,0.109,0.743,0.307 | ||||
| 		c2.271,2.289,5.794,2.805,8.634,1.253c1.944-1.065,3.993-1.918,6.115-2.541c3.105-0.933,5.213-3.781,5.2-7.005 | ||||
| 		C56.126,58.473,56.6,58,57.184,58h5.184c0.281,0,0.55,0.112,0.75,0.31c0.199,0.2,0.309,0.471,0.309,0.752 | ||||
| 		c-0.012,3.217,2.098,6.065,5.185,6.992c2.138,0.631,4.187,1.482,6.129,2.545c2.854,1.546,6.369,1.026,8.646-1.269 | ||||
| 		c0.403-0.401,1.075-0.401,1.492,0.015l3.639,3.675c0.42,0.424,0.42,1.098,0.007,1.515c-2.283,2.265-2.802,5.783-1.261,8.628 | ||||
| 		c1.071,1.952,1.922,3.997,2.545,6.116c0.489,1.657,2.228,2.604,3.886,2.116C95.351,88.907,96.297,87.169,95.811,85.511z"/> | ||||
| 	<path display="inline" fill="#636667" d="M118.29,1.486C117.337,0.536,116.046,0,114.7,0H4.843 | ||||
| 		C2.035,0.014-0.224,2.283-0.224,5.076v89.103c-0.006,1.334,0.524,2.629,1.475,3.584c0.951,0.955,2.244,1.492,3.592,1.492h109.851 | ||||
| 		c1.35,0.005,2.645-0.529,3.6-1.484c0.955-0.954,1.49-2.254,1.482-3.605V5.076C119.776,3.73,119.243,2.439,118.29,1.486z | ||||
| 		 M113.521,6.255v18.564H6.032V6.255H113.521z M41.2,93c1.493-8.922,9.23-15.729,18.576-15.729c9.348,0,17.083,6.808,18.576,15.729 | ||||
| 		H41.2z M84.673,93c-1.542-12.39-12.089-21.984-24.896-21.984C46.97,71.016,36.422,80.61,34.879,93H6.032V31.074h107.49V93H84.673z" | ||||
| 		/> | ||||
| 	<path display="inline" fill="#636667" d="M21.661,19.955c-1.204,1.203-2.836,1.879-4.539,1.879c-3.545,0-6.419-2.873-6.419-6.418 | ||||
| 		s2.874-6.418,6.419-6.418s6.418,2.873,6.418,6.418C23.541,17.118,22.865,18.751,21.661,19.955z"/> | ||||
| 	<circle display="inline" fill="#636667" cx="31.611" cy="15.416" r="6.418"/> | ||||
| 	<path display="inline" fill="#636667" d="M52.518,15.416c-0.009,3.545-2.873,6.408-6.418,6.418c-3.545,0-6.419-2.873-6.419-6.418 | ||||
| 		s2.874-6.418,6.419-6.418C49.645,8.998,52.518,11.871,52.518,15.416z"/> | ||||
| </g> | ||||
| <g id="Layer_2" display="none"> | ||||
| 	<g display="inline"> | ||||
| 		<path fill="#F06725" d="M99.814,64.673V46.052h13.125v18.621H99.814z M120,64.673v43.361H92.758V64.673H120z"/> | ||||
| 		<rect y="50.855" fill="#F06725" width="9.017" height="57.181"/> | ||||
| 		<path fill="#F06725" d="M53.04,108.034V55.046h16.718v52.988H53.04z M58.535,55.046V44.188h5.724v10.858H58.535z"/> | ||||
| 		<rect x="18.373" y="30.743" fill="#646767" width="3.105" height="4.451"/> | ||||
| 		<rect x="29.501" y="30.743" fill="#646767" width="3.105" height="4.451"/> | ||||
| 		<rect x="40.586" y="30.743" fill="#646767" width="3.104" height="4.451"/> | ||||
| 		<rect x="18.373" y="43.411" fill="#646767" width="3.105" height="4.503"/> | ||||
| 		<rect x="29.501" y="43.411" fill="#646767" width="3.105" height="4.503"/> | ||||
| 		<rect x="40.609" y="43.411" fill="#646767" width="3.104" height="4.503"/> | ||||
| 		<rect x="18.373" y="56.082" fill="#646767" width="3.105" height="4.5"/> | ||||
| 		<rect x="29.501" y="56.082" fill="#646767" width="3.105" height="4.5"/> | ||||
| 		<rect x="40.609" y="56.082" fill="#646767" width="3.104" height="4.5"/> | ||||
| 		<rect x="18.373" y="68.752" fill="#646767" width="3.105" height="4.501"/> | ||||
| 		<rect x="29.501" y="68.752" fill="#646767" width="3.105" height="4.501"/> | ||||
| 		<rect x="40.609" y="68.752" fill="#646767" width="3.104" height="4.501"/> | ||||
| 		<rect x="18.373" y="81.422" fill="#646767" width="3.105" height="4.491"/> | ||||
| 		<rect x="29.501" y="81.422" fill="#646767" width="3.105" height="4.491"/> | ||||
| 		<rect x="40.586" y="81.422" fill="#646767" width="3.104" height="4.491"/> | ||||
| 		<rect x="18.373" y="94.091" fill="#646767" width="3.105" height="4.504"/> | ||||
| 		<rect x="29.501" y="94.091" fill="#646767" width="3.105" height="4.504"/> | ||||
| 		<rect x="40.609" y="94.091" fill="#646767" width="3.104" height="4.504"/> | ||||
| 		<path fill="#646767" d="M94.309,106.481V55.761h-4.378V33.247h-7.132V16.168h-3.105v17.079h-7.112v22.514h-4.378v50.721h-13.61 | ||||
| 			V19.75h-8.655V9.006h-8.859V0H24.977v9.006h-8.859V19.75H7.483v86.731H0v3.104h7.483h47.109h13.61h26.105H120v-3.104H94.309z | ||||
| 			 M75.687,36.353h11.139V55.74H75.687V36.353z M28.082,3.105h5.892v5.9h-5.892V3.105z M19.221,12.11h5.756h12.102h5.754v7.64 | ||||
| 			H19.221V12.11z M10.588,106.481V22.854h5.53h29.82h5.548v83.627H10.588z M71.309,106.481V58.868h19.896v47.613H71.309z"/> | ||||
| 	</g> | ||||
| </g> | ||||
| <g id="Layer_3"> | ||||
| 	<path fill="#636768" d="M2.66,104.889h112.106c1.47,0,2.66-1.194,2.66-2.662c0-1.473-1.19-2.663-2.66-2.663H2.66 | ||||
| 		c-1.471,0-2.661,1.19-2.661,2.663C0,103.694,1.189,104.889,2.66,104.889z"/> | ||||
| 	<rect x="2.66" y="52.421" fill="#F06725" width="12.314" height="39.343"/> | ||||
| 	<rect x="102.453" y="31.996" fill="#F06725" width="12.313" height="59.768"/> | ||||
| 	<rect x="35.928" y="31.25" fill="#F06725" width="12.315" height="60.514"/> | ||||
| 	<rect x="69.187" y="50.168" fill="#F06725" width="12.323" height="41.596"/> | ||||
| 	<circle fill="#F06725" cx="42.038" cy="11.39" r="3.76"/> | ||||
| 	<circle fill="#F06725" cx="108.608" cy="12.135" r="3.76"/> | ||||
| 	<path fill="#656668" d="M108.61,0.744c-6.28,0-11.387,5.11-11.387,11.389c0,0.877,0.107,1.729,0.293,2.55l-16.983,9.726 | ||||
| 		c-1.392-1.221-3.194-1.988-5.187-1.988c-1.931,0-3.681,0.728-5.054,1.882L53.252,13.614c0.145-0.722,0.222-1.464,0.222-2.227 | ||||
| 		C53.474,5.109,48.364,0,42.085,0c-6.281,0-11.39,5.109-11.39,11.391c0,1.168,0.178,2.296,0.508,3.36l-18.246,11.1 | ||||
| 		c-1.208-0.748-2.617-1.202-4.138-1.202c-4.363,0-7.913,3.549-7.913,7.911c0,4.361,3.549,7.911,7.913,7.911 | ||||
| 		c2.113,0,4.101-0.823,5.593-2.317c1.492-1.493,2.315-3.48,2.315-5.593c0-0.881-0.177-1.712-0.444-2.504l17.646-10.733 | ||||
| 		c2.07,2.129,4.959,3.457,8.156,3.457c3.601,0,6.81-1.684,8.9-4.301l16.61,10.419c-0.086,0.463-0.146,0.938-0.146,1.422 | ||||
| 		c-0.003,4.353,3.534,7.899,7.889,7.908h0.004c4.361,0,7.913-3.55,7.913-7.917c-0.003-0.43-0.063-0.841-0.128-1.251l16.774-9.605 | ||||
| 		c2.085,2.485,5.217,4.069,8.71,4.069c6.28,0,11.388-5.11,11.388-11.39C119.998,5.855,114.889,0.744,108.61,0.744z M10.648,34.389 | ||||
| 		c-0.488,0.49-1.139,0.758-1.83,0.758c-1.427,0-2.587-1.161-2.587-2.587c0-1.427,1.16-2.588,2.587-2.588 | ||||
| 		c1.426,0,2.587,1.161,2.587,2.588C11.405,33.25,11.137,33.901,10.648,34.389z M42.085,17.456c-3.345,0-6.065-2.721-6.065-6.065 | ||||
| 		c0-3.345,2.723-6.068,6.065-6.068c3.343,0,6.066,2.723,6.066,6.068C48.151,14.733,45.43,17.456,42.085,17.456z M75.347,32.903 | ||||
| 		c-1.418-0.001-2.571-1.16-2.571-2.58c0-1.419,1.157-2.576,2.578-2.578c1.421,0,2.578,1.155,2.578,2.569 | ||||
| 		C77.928,31.742,76.771,32.902,75.347,32.903z M108.61,18.2c-3.345,0-6.066-2.723-6.066-6.065c0-3.344,2.722-6.066,6.066-6.066 | ||||
| 		c3.344,0,6.066,2.723,6.066,6.066C114.677,15.478,111.954,18.2,108.61,18.2z"/> | ||||
| </g> | ||||
| </svg> | ||||
| Before Width: | Height: | Size: 7.3 KiB | 
|  | @ -1,17 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define([ | ||||
|     'Magento_Ui/js/form/element/abstract' | ||||
| ], function (Abstract) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Abstract.extend({ | ||||
|         /** @inheritdoc */ | ||||
|         onUpdate: function () { | ||||
|             this.bubble('update', this.hasChanged()); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,88 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define([ | ||||
|     'Magento_AdminNotification/js/grid/listing', | ||||
|     'Magento_Ui/js/modal/alert', | ||||
|     'mage/translate', | ||||
|     'underscore', | ||||
|     'jquery' | ||||
| ], function (Listing, uiAlert, $t, _, $) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Listing.extend({ | ||||
|         defaults: { | ||||
|             isAllowed: true, | ||||
|             ajaxSettings: { | ||||
|                 method: 'POST', | ||||
|                 data: {}, | ||||
|                 url: '${ $.dismissUrl }' | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** @inheritdoc */ | ||||
|         initialize: function () { | ||||
|             _.bindAll(this, 'reload', 'onError'); | ||||
| 
 | ||||
|             return this._super(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Dismiss all items. | ||||
|          */ | ||||
|         dismissAll: function () { | ||||
|             var toDismiss = []; | ||||
| 
 | ||||
|             _.each(this.rows, function (row) { | ||||
|                 if (row.dismiss) { | ||||
|                     toDismiss.push(row.uuid); | ||||
|                 } | ||||
|             }); | ||||
|             toDismiss.length && this.dismiss(toDismiss); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Dismiss action. | ||||
|          * | ||||
|          * @param {Array} items | ||||
|          */ | ||||
|         dismiss: function (items) { | ||||
|             var config = _.extend({}, this.ajaxSettings); | ||||
| 
 | ||||
|             config.data.uuid = items; | ||||
|             this.showLoader(); | ||||
| 
 | ||||
|             $.ajax(config) | ||||
|                 .done(this.reload) | ||||
|                 .fail(this.onError); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Success callback for dismiss request. | ||||
|          */ | ||||
|         reload: function () { | ||||
|             this.source.reload({ | ||||
|                 refresh: true | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Error callback for dismiss request. | ||||
|          * | ||||
|          * @param {Object} xhr | ||||
|          */ | ||||
|         onError: function (xhr) { | ||||
|             this.hideLoader(); | ||||
| 
 | ||||
|             if (xhr.statusText === 'abort') { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             uiAlert({ | ||||
|                 content: $t('Something went wrong.') | ||||
|             }); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,65 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define([ | ||||
|     'Magento_Ui/js/form/components/insert-form', | ||||
|     'uiRegistry' | ||||
| ], function (Insert, registry) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Insert.extend({ | ||||
|         defaults: { | ||||
|             modalProvider: '${ $.parentName }', | ||||
|             titlePrefix: '', | ||||
|             imports: { | ||||
|                 changeModalTitle: '${ $.modalProvider }:state' | ||||
|             }, | ||||
|             listens: { | ||||
|                 responseData: 'afterRetry' | ||||
|             }, | ||||
|             modules: { | ||||
|                 modal: '${ $.modalProvider }', | ||||
|                 notificationListing: '${ $.columnsProvider }' | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** @inheritdoc */ | ||||
|         initConfig: function () { | ||||
|             var modalTitleProvider; | ||||
| 
 | ||||
|             this._super(); | ||||
|             modalTitleProvider = this.modalTitleProvider.split(':'); | ||||
|             this.modalTitleTarget = modalTitleProvider[0]; | ||||
|             this.modalTitlePath = modalTitleProvider[1]; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Change modal title. | ||||
|          * | ||||
|          * @param {Boolean} change | ||||
|          */ | ||||
|         changeModalTitle: function (change) { | ||||
|             if (change) { | ||||
|                 registry.get(this.modalTitleTarget, function (target) { | ||||
|                     this.modal().setTitle(this.titlePrefix + target.get(this.modalTitlePath)); | ||||
|                 }.bind(this)); | ||||
|             } else { | ||||
|                 this.modal().setTitle(''); | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Action after retry operation. | ||||
|          * | ||||
|          * @param {Object} data | ||||
|          */ | ||||
|         afterRetry: function (data) { | ||||
|             if (!data.error) { | ||||
|                 this.modal().closeModal(); | ||||
|                 this.notificationListing().reload(); | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | @ -1,9 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <div css="$data.additionalClasses" | ||||
|      if="error" | ||||
|      text="error"></div> | ||||
|  | @ -1,15 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <div class="action-menu-item action-close-wrapper"> | ||||
|     <button class="action-close" | ||||
|             repeat="foreach: $col.getVisibleActions($row()._rowIndex), item: '$action'" | ||||
|             click="$col.getActionHandler($action())" | ||||
|             attr="{ | ||||
|                 title: $action().label | ||||
|             }" | ||||
|     ></button> | ||||
| </div> | ||||
|  | @ -1,43 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <div id="system_messages" class="message-system" collapsible visible="totalRecords"> | ||||
|     <div class="message-system-inner" outerClick="fixLoaderHeight.bind($data, true)"> | ||||
|         <div class="message-system-short"> | ||||
|             <button class="message-system-action-dropdown" toggleCollapsible> | ||||
|                 <span> | ||||
|                     <translate args="'System Messages'"></translate>: | ||||
|                     <text args="totalRecords"></text> | ||||
|                 </span> | ||||
|             </button> | ||||
|             <div class="message-system-short-wrapper" if="rows[0]" repeat="foreach: [rows[0]], item: '$row'" visible="!$collapsible.opened()"> | ||||
|                 <fastForEach args="data: getVisible(), as: '$col'" > | ||||
|                     <render args="$col.getBody()"></render> | ||||
|                 </fastForEach> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="message-system-collapsible"> | ||||
|             <ul class="message-system-list"> | ||||
|                 <li repeat="foreach: rows, item: '$row'"> | ||||
|                     <fastForEach args="data: getVisible(), as: '$col'" > | ||||
|                         <render args="$col.getBody()"></render> | ||||
|                     </fastForEach> | ||||
|                 </li> | ||||
|             </ul> | ||||
|             <div class="message-system-summary" if="isAllowed"> | ||||
|                 <a class="action__message-log" | ||||
|                    href="#" | ||||
|                    click="dismissAll" | ||||
|                    text="dismissAllText"></a> | ||||
|                 <a class="action__message-log" | ||||
|                     attr="{ | ||||
|                         href: link | ||||
|                     }" | ||||
|                     text="linkText"></a> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
| Before Width: | Height: | Size: 100 B | 
| Before Width: | Height: | Size: 85 B | 
| Before Width: | Height: | Size: 368 B | 
| Before Width: | Height: | Size: 253 B | 
| Before Width: | Height: | Size: 679 B | 
| Before Width: | Height: | Size: 11 KiB | 
|  | @ -1,10 +0,0 @@ | |||
| /** | ||||
|  * | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| require([ | ||||
|     'Magento_Variable/variables', | ||||
|     'mage/adminhtml/browser' | ||||
| ]); | ||||
|  | @ -1,134 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| /*global FORM_KEY*/ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'chartJs', | ||||
|     'jquery-ui-modules/widget', | ||||
|     'chartjs/chartjs-adapter-moment', | ||||
|     'chartjs/es6-shim.min', | ||||
|     'moment' | ||||
| ], function ($, Chart) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     $.widget('mage.dashboardChart', { | ||||
|         options: { | ||||
|             updateUrl: '', | ||||
|             periodSelect: null, | ||||
|             periodUnits: [], | ||||
|             precision: 0, | ||||
|             type: '' | ||||
|         }, | ||||
|         chart: null, | ||||
| 
 | ||||
|         /** | ||||
|          * @private | ||||
|          */ | ||||
|         _create: function () { | ||||
|             this.createChart(); | ||||
| 
 | ||||
|             if (this.options.periodSelect) { | ||||
|                 $(document).on('change', this.options.periodSelect, this.refreshChartData.bind(this)); | ||||
| 
 | ||||
|                 this.period = $(this.options.periodSelect).val(); | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @public | ||||
|          */ | ||||
|         createChart: function () { | ||||
|             this.chart = new Chart(this.element, this.getChartSettings()); | ||||
|             this.refreshChartData(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @public | ||||
|          */ | ||||
|         refreshChartData: function () { | ||||
|             var data = { | ||||
|                 'form_key': FORM_KEY | ||||
|             }; | ||||
| 
 | ||||
|             if (this.options.periodSelect) { | ||||
|                 this.period = data.period = $(this.options.periodSelect).val(); | ||||
|             } | ||||
| 
 | ||||
|             $.ajax({ | ||||
|                 url: this.options.updateUrl, | ||||
|                 showLoader: true, | ||||
|                 data: data, | ||||
|                 dataType: 'json', | ||||
|                 type: 'POST', | ||||
|                 success: this.updateChart.bind(this) | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @public | ||||
|          * @param {Object} response | ||||
|          */ | ||||
|         updateChart: function (response) { | ||||
|             $(this.element).toggle(response.data.length > 0); | ||||
|             $(this.element).next('.dashboard-diagram-nodata').toggle(response.data.length === 0); | ||||
| 
 | ||||
|             this.chart.options.scales.xAxis.time.unit = this.options.periodUnits[this.period] ? | ||||
|                 this.options.periodUnits[this.period] : 'hour'; | ||||
|             this.chart.data.datasets[0].data = response.data; | ||||
|             this.chart.data.datasets[0].label = response.label; | ||||
|             this.chart.update(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @returns {Object} chart object configuration | ||||
|          */ | ||||
|         getChartSettings: function () { | ||||
|             return { | ||||
|                 type: 'bar', | ||||
|                 data: { | ||||
|                     datasets: [{ | ||||
|                         yAxisID: 'yAxis', | ||||
|                         xAxisID: 'xAxis', | ||||
|                         data: [], | ||||
|                         backgroundColor: '#f1d4b3', | ||||
|                         borderColor: '#eb5202', | ||||
|                         borderWidth: 1 | ||||
|                     }] | ||||
|                 }, | ||||
|                 options: { | ||||
|                     legend: { | ||||
|                         onClick: this.handleChartLegendClick, | ||||
|                         position: 'bottom' | ||||
|                     }, | ||||
|                     scales: { | ||||
|                         xAxis: { | ||||
|                             offset: true, | ||||
|                             type: 'time', | ||||
|                             ticks: { | ||||
|                                 source: 'data' | ||||
|                             } | ||||
|                         }, | ||||
|                         yAxis: { | ||||
|                             ticks: { | ||||
|                                 beginAtZero: true, | ||||
|                                 precision: this.options.precision | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             }; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @public | ||||
|          */ | ||||
|         handleChartLegendClick: function () { | ||||
|             // don't hide dataset on clicking into legend item
 | ||||
|         } | ||||
|     }); | ||||
| 
 | ||||
|     return $.mage.dashboardChart; | ||||
| }); | ||||
|  | @ -1,59 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| /*global FORM_KEY*/ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'jquery-ui-modules/widget' | ||||
| ], function ($) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     $.widget('mage.dashboardTotals', { | ||||
|         options: { | ||||
|             updateUrl: '', | ||||
|             periodSelect: null | ||||
|         }, | ||||
|         elementId: null, | ||||
| 
 | ||||
|         /** | ||||
|          * @private | ||||
|          */ | ||||
|         _create: function () { | ||||
|             this.elementId = $(this.element).attr('id'); | ||||
| 
 | ||||
|             if (this.options.periodSelect) { | ||||
|                 $(document).on('change', this.options.periodSelect, $.proxy(function () { | ||||
|                     this.refreshTotals(); | ||||
|                 }, this)); | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @public | ||||
|          */ | ||||
|         refreshTotals: function () { | ||||
|             var periodParam = ''; | ||||
| 
 | ||||
|             if (this.options.periodSelect && $(this.options.periodSelect).val()) { | ||||
|                 periodParam = 'period/' + $(this.options.periodSelect).val() + '/'; | ||||
|             } | ||||
| 
 | ||||
|             $.ajax({ | ||||
|                 url: this.options.updateUrl + periodParam, | ||||
|                 showLoader: true, | ||||
|                 data: { | ||||
|                     'form_key': FORM_KEY | ||||
|                 }, | ||||
|                 dataType: 'html', | ||||
|                 type: 'POST', | ||||
|                 success: $.proxy(function (response) { | ||||
|                     $('#' + this.elementId).replaceWith(response); | ||||
|                 }, this) | ||||
|             }); | ||||
|         } | ||||
|     }); | ||||
| 
 | ||||
|     return $.mage.dashboardTotals; | ||||
| }); | ||||
|  | @ -1,15 +0,0 @@ | |||
| /** | ||||
|  * | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'Magento_Backend/js/validate-store' | ||||
| ], function ($, validateStore) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     $.widget('mage.deleteWithConfirm', validateStore, {}); | ||||
| 
 | ||||
|     return $.mage.deleteWithConfirm; | ||||
| }); | ||||
|  | @ -1,147 +0,0 @@ | |||
| /** | ||||
|  * | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| /** | ||||
|  * @api | ||||
|  */ | ||||
| 
 | ||||
| /*global byteConvert*/ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'mage/template', | ||||
|     'Magento_Ui/js/modal/alert', | ||||
|     'Magento_Ui/js/form/element/file-uploader', | ||||
|     'mage/translate', | ||||
|     'jquery/file-uploader' | ||||
| ], function ($, mageTemplate, alert, FileUploader) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     var fileUploader = new FileUploader({ | ||||
|         dataScope: '', | ||||
|         isMultipleFiles: true | ||||
|     }); | ||||
| 
 | ||||
|     fileUploader.initUploader(); | ||||
| 
 | ||||
|     $.widget('mage.mediaUploader', { | ||||
| 
 | ||||
|         /** | ||||
|          * | ||||
|          * @private | ||||
|          */ | ||||
|         _create: function () { | ||||
|             var self = this, | ||||
|                 progressTmpl = mageTemplate('[data-template="uploader"]'), | ||||
|                 isResizeEnabled = this.options.isResizeEnabled, | ||||
|                 resizeConfiguration = { | ||||
|                     action: 'resizeImage', | ||||
|                     maxWidth: this.options.maxWidth, | ||||
|                     maxHeight: this.options.maxHeight | ||||
|                 }; | ||||
| 
 | ||||
|             if (!isResizeEnabled) { | ||||
|                 resizeConfiguration = { | ||||
|                     action: 'resizeImage' | ||||
|                 }; | ||||
|             } | ||||
| 
 | ||||
|             this.element.find('input[type=file]').fileupload({ | ||||
|                 dataType: 'json', | ||||
|                 formData: { | ||||
|                     'form_key': window.FORM_KEY | ||||
|                 }, | ||||
|                 dropZone: this.element.find('input[type=file]').closest('[role="dialog"]'), | ||||
|                 sequentialUploads: true, | ||||
|                 acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i, | ||||
|                 maxFileSize: this.options.maxFileSize, | ||||
| 
 | ||||
|                 /** | ||||
|                  * @param {Object} e | ||||
|                  * @param {Object} data | ||||
|                  */ | ||||
|                 add: function (e, data) { | ||||
|                     var fileSize, | ||||
|                         tmpl; | ||||
| 
 | ||||
|                     $.each(data.files, function (index, file) { | ||||
|                         fileSize = typeof file.size == 'undefined' ? | ||||
|                             $.mage.__('We could not detect a size.') : | ||||
|                             byteConvert(file.size); | ||||
| 
 | ||||
|                         data.fileId = Math.random().toString(33).substr(2, 18); | ||||
| 
 | ||||
|                         tmpl = progressTmpl({ | ||||
|                             data: { | ||||
|                                 name: file.name, | ||||
|                                 size: fileSize, | ||||
|                                 id: data.fileId | ||||
|                             } | ||||
|                         }); | ||||
| 
 | ||||
|                         $(tmpl).appendTo(self.element); | ||||
|                     }); | ||||
| 
 | ||||
|                     $(this).fileupload('process', data).done(function () { | ||||
|                         data.submit(); | ||||
|                     }); | ||||
|                 }, | ||||
| 
 | ||||
|                 /** | ||||
|                  * @param {Object} e | ||||
|                  * @param {Object} data | ||||
|                  */ | ||||
|                 done: function (e, data) { | ||||
|                     if (data.result && !data.result.error) { | ||||
|                         self.element.trigger('addItem', data.result); | ||||
|                     } else { | ||||
|                         fileUploader.aggregateError(data.files[0].name, data.result.error); | ||||
|                     } | ||||
| 
 | ||||
|                     self.element.find('#' + data.fileId).remove(); | ||||
|                 }, | ||||
| 
 | ||||
|                 /** | ||||
|                  * @param {Object} e | ||||
|                  * @param {Object} data | ||||
|                  */ | ||||
|                 progress: function (e, data) { | ||||
|                     var progress = parseInt(data.loaded / data.total * 100, 10), | ||||
|                         progressSelector = '#' + data.fileId + ' .progressbar-container .progressbar'; | ||||
| 
 | ||||
|                     self.element.find(progressSelector).css('width', progress + '%'); | ||||
|                 }, | ||||
| 
 | ||||
|                 /** | ||||
|                  * @param {Object} e | ||||
|                  * @param {Object} data | ||||
|                  */ | ||||
|                 fail: function (e, data) { | ||||
|                     var progressSelector = '#' + data.fileId; | ||||
| 
 | ||||
|                     self.element.find(progressSelector).removeClass('upload-progress').addClass('upload-failure') | ||||
|                         .delay(2000) | ||||
|                         .hide('highlight') | ||||
|                         .remove(); | ||||
|                 }, | ||||
| 
 | ||||
|                 stop: fileUploader.uploaderConfig.stop | ||||
|             }); | ||||
| 
 | ||||
|             this.element.find('input[type=file]').fileupload('option', { | ||||
|                 processQueue: [{ | ||||
|                     action: 'loadImage', | ||||
|                     fileTypes: /^image\/(gif|jpeg|png)$/ | ||||
|                 }, | ||||
|                 resizeConfiguration, | ||||
|                 { | ||||
|                     action: 'saveImage' | ||||
|                 }] | ||||
|             }); | ||||
|         } | ||||
|     }); | ||||
| 
 | ||||
|     return $.mage.mediaUploader; | ||||
| }); | ||||
|  | @ -1,50 +0,0 @@ | |||
| /** | ||||
|  * | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'Magento_Backend/js/validate-store' | ||||
| ], function ($, validateStore) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     $.widget('mage.saveWithConfirm', validateStore, { | ||||
| 
 | ||||
|         /** | ||||
|          * Check is it need to show confirmation popup | ||||
|          * | ||||
|          * @returns {Boolean} | ||||
|          */ | ||||
|         _needConfirm: function () { | ||||
| 
 | ||||
|             var storeData = this.settings.storeData, | ||||
| 
 | ||||
|             /* edit store view*/ | ||||
|                 storeViewEdit = $('[name="store[store_id]"]').length, | ||||
|                 groupId = $('[name="store[group_id]"]').val(), | ||||
|                 isNewStoreView = !$('[name="store[store_id]"]').val(), | ||||
| 
 | ||||
|             /* edit store */ | ||||
|                 storeEdit = $('[name="group[group_id]"]').length, | ||||
|                 storeId = $('[name="group[group_id]"]').val(), | ||||
|                 rootCategoryId = $('[name="group[root_category_id]"]').val(), | ||||
|                 defaultStoreView = $('[name="group[default_store_id]"]').val(), | ||||
| 
 | ||||
|             /* edit website */ | ||||
|                 websiteEdit = $('[name="website[website_id]"]').length, | ||||
|                 defaultStore = $('[name="website[default_group_id]"]').val(), | ||||
| 
 | ||||
|             /* conditions */ | ||||
|                 storeViewUpdated = storeViewEdit && (isNewStoreView || storeData['group_id'] !== groupId), | ||||
|                 storeUpdated = storeEdit && storeId && | ||||
|                     (rootCategoryId !== null  && storeData['root_category_id'] !== rootCategoryId || | ||||
|                     defaultStoreView !== null && storeData['default_store_id'] !== defaultStoreView), | ||||
|                 websiteUpdated = websiteEdit && defaultStore !== null && storeData['default_group_id'] !== defaultStore; | ||||
| 
 | ||||
|             return storeViewUpdated || storeUpdated || websiteUpdated; | ||||
|         } | ||||
|     }); | ||||
| 
 | ||||
|     return $.mage.saveWithConfirm; | ||||
| }); | ||||
|  | @ -1,127 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define([ | ||||
|     'jquery' | ||||
| ], function ($) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     /** | ||||
|      * @param {Object} storeSwitchConfig | ||||
|      */ | ||||
|     return function (storeSwitchConfig) { | ||||
|         var scopeSwitcherHandler; | ||||
| 
 | ||||
|         (function () { | ||||
|             var storesList = $('[data-role=stores-list]'); | ||||
| 
 | ||||
|             storesList.on('click', '[data-value]', function (event) { | ||||
|                 var val = $(event.target).data('value'), | ||||
|                     role = $(event.target).data('role'), | ||||
|                     switcher = $('[data-role=' + role + ']'); | ||||
| 
 | ||||
|                 event.preventDefault(); | ||||
| 
 | ||||
|                 if (!switcher.val() || val !== switcher.val()) { | ||||
| 
 | ||||
|                     /* Set the value & trigger event */ | ||||
|                     switcher.val(val).trigger('change'); | ||||
|                 } | ||||
|             }); | ||||
|         })($); | ||||
| 
 | ||||
|         /** | ||||
|          * Switch store scope | ||||
|          * | ||||
|          * @param {Object} obj | ||||
|          * @return void | ||||
|          */ | ||||
|         function switchScope(obj) { | ||||
|             var switcher = $(obj), | ||||
|                 scopeId = switcher.val(), | ||||
|                 scopeParams = '', | ||||
|                 switcherParams = {}; | ||||
| 
 | ||||
|             if (scopeId) { | ||||
|                 scopeParams = switcher.data('param') + '/' + scopeId + '/'; | ||||
|             } | ||||
| 
 | ||||
|             if (obj.switchParams) { | ||||
|                 scopeParams += obj.switchParams; | ||||
|             } | ||||
| 
 | ||||
|             /** | ||||
|              * Reload function for switcher | ||||
|              */ | ||||
|             function reload() { | ||||
|                 var url; | ||||
| 
 | ||||
|                 if (!storeSwitchConfig.isUsingIframe) { | ||||
| 
 | ||||
|                     if (storeSwitchConfig.switchUrl && storeSwitchConfig.switchUrl.length > 0) { | ||||
|                         url = storeSwitchConfig.switchUrl + scopeParams; | ||||
| 
 | ||||
|                         /* eslint-disable no-undef */ | ||||
|                         setLocation(url); | ||||
|                     } | ||||
| 
 | ||||
|                 } else { | ||||
|                     $('#preview_selected_store').val(scopeId); | ||||
|                     $('#preview_form').trigger('submit'); | ||||
| 
 | ||||
|                     $('.store-switcher .dropdown-menu li a').each(function () { | ||||
|                         var $this = $(this); | ||||
| 
 | ||||
|                         if ($this.data('role') === 'store-view-id' && $this.data('value') === scopeId) { | ||||
|                             $('#store-change-button').html($this.text()); | ||||
|                         } | ||||
|                     }); | ||||
| 
 | ||||
|                     $('#store-change-button').trigger('click'); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             if (typeof scopeSwitcherHandler !== 'undefined') { | ||||
|                 switcherParams = { | ||||
|                     scopeId: scopeId, | ||||
|                     scopeParams: scopeParams, | ||||
|                     useConfirm: storeSwitchConfig.useConfirm | ||||
|                 }; | ||||
| 
 | ||||
|                 scopeSwitcherHandler(switcherParams); | ||||
|             } else if (storeSwitchConfig.useConfirm) { | ||||
|                 require([ | ||||
|                     'Magento_Ui/js/modal/confirm', | ||||
|                     'mage/translate' | ||||
|                 ], function (confirm, $t) { | ||||
|                     confirm({ | ||||
|                         content: $t('Please confirm scope switching. All data that hasn\'t been saved will be lost.'), | ||||
|                         actions: { | ||||
| 
 | ||||
|                             /** | ||||
|                              * Confirm action | ||||
|                              */ | ||||
|                             confirm: function () { | ||||
|                                 reload(); | ||||
|                             }, | ||||
| 
 | ||||
|                             /** | ||||
|                              * Cancel action | ||||
|                              */ | ||||
|                             cancel: function () { | ||||
|                                 obj.value = storeSwitchConfig.storeId ? storeSwitchConfig.storeId : ''; | ||||
|                             } | ||||
|                         } | ||||
|                     }); | ||||
|                 }); | ||||
|             } else { | ||||
|                 reload(); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         window.scopeSwitcherHandler = scopeSwitcherHandler; | ||||
|         window.switchScope = switchScope; | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,48 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| /* eslint-disable strict */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'mage/mage' | ||||
| ], function ($) { | ||||
|     $.extend(true, $, { | ||||
|         mage: { | ||||
|             translate: (function () { | ||||
|                 /** | ||||
|                  * Key-value translations storage | ||||
|                  * @type {Object} | ||||
|                  * @private | ||||
|                  */ | ||||
|                 var _data = {}; | ||||
| 
 | ||||
|                 /** | ||||
|                  * Add new translation (two string parameters) or several translations (object) | ||||
|                  */ | ||||
|                 this.add = function () { | ||||
|                     if (arguments.length > 1) { | ||||
|                         _data[arguments[0]] = arguments[1]; | ||||
|                     } else if (typeof arguments[0] === 'object') { | ||||
|                         $.extend(_data, arguments[0]); | ||||
|                     } | ||||
|                 }; | ||||
| 
 | ||||
|                 /** | ||||
|                  * Make a translation with parsing (to handle case when _data represents tuple) | ||||
|                  * @param {String} text | ||||
|                  * @return {String} | ||||
|                  */ | ||||
|                 this.translate = function (text) { | ||||
|                     return typeof _data[text] === 'string' ? _data[text] : text; | ||||
|                 }; | ||||
| 
 | ||||
|                 return this; | ||||
|             }()) | ||||
|         } | ||||
|     }); | ||||
|     $.mage.__ = $.proxy($.mage.translate.translate, $.mage.translate); | ||||
| 
 | ||||
|     return $.mage.__; | ||||
| }); | ||||
|  | @ -1,83 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'jquery/ui', | ||||
|     'mage/dataPost', | ||||
|     'mage/backend/validation', | ||||
|     'Magento_Ui/js/modal/confirm' | ||||
| ], function ($, jqueryUi, dataPost, validation, modalConfirm) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     $.widget('mage.storeValidation', { | ||||
| 
 | ||||
|         /** | ||||
|          * Validation creation | ||||
|          * @protected | ||||
|          */ | ||||
|         _create: function () { | ||||
|             var form = this.element[0], | ||||
|                 validator = $.data(form, 'validator'); | ||||
| 
 | ||||
|             if (validator && validator.settings) { | ||||
|                 validator.settings.submitHandler = this._saveHandler; | ||||
|                 validator.settings.confirmCallback = this._needConfirm; | ||||
|                 $.extend(validator.settings, this.options); | ||||
|                 $.data(form, 'validator', validator); | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Check is it need to show confirmation popup | ||||
|          * | ||||
|          * @returns {Boolean} | ||||
|          */ | ||||
|         _needConfirm: function () { | ||||
|             return true; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Save form with confirmation if needed | ||||
|          * | ||||
|          * @param {Object} form | ||||
|          * @private | ||||
|          */ | ||||
|         _saveHandler: function (form) { | ||||
|             var formData = {}, | ||||
|                 requestData = {}, | ||||
|                 options = $.data(form, 'validator').settings; | ||||
| 
 | ||||
|             if ($(form).validation('isValid')) { | ||||
|                 $.each($(form).serializeArray(), function () { | ||||
|                     formData[this.name] = this.value || ''; | ||||
|                 }); | ||||
|                 requestData = { | ||||
|                     action: $(form).attr('action'), | ||||
|                     data: formData | ||||
|                 }; | ||||
| 
 | ||||
|                 if (options.confirmCallback.call(this)) { | ||||
|                     modalConfirm({ | ||||
|                         title: $.mage.__('Warning message'), | ||||
|                         content: $.mage.__('This operation can take a long time'), | ||||
|                         actions: { | ||||
|                             /** | ||||
|                              * 'Confirm' action handler. | ||||
|                              */ | ||||
|                             confirm: function () { | ||||
|                                 $('body').trigger('processStart'); | ||||
|                                 dataPost().postData(requestData); | ||||
|                             } | ||||
|                         } | ||||
|                     }); | ||||
|                 } else { | ||||
|                     dataPost().postData(requestData); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| 
 | ||||
|     return $.mage.storeValidation; | ||||
| }); | ||||
|  | @ -1,15 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <button class="action-delete" | ||||
|         data-bind=" | ||||
|             click: function(){ $parent.processingDeleteRecord($record().index, $record().recordId); }, | ||||
|             attr: { | ||||
|                 title: $parent.deleteButtonLabel | ||||
|             } | ||||
|         "> | ||||
|     <span translate="$parent.deleteButtonLabel"></span> | ||||
| </button> | ||||
|  | @ -1,94 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| 
 | ||||
| <div class="admin__field-complex" if="$data.addButton"> | ||||
|     <div class="admin__field-complex-title"> | ||||
|         <span class="label" translate="'User Agent Rules'"></span> | ||||
|     </div> | ||||
| 
 | ||||
|     <div class="admin__field-complex-elements"> | ||||
|         <render args="fallbackResetTpl" if="$data.showFallbackReset && $data.isDifferedFromDefault"></render> | ||||
|         <button attr="{disabled: disabled}" | ||||
|                 class="action-secondary" | ||||
|                 type="button" | ||||
|                 click="processingAddChild.bind($data, false, false, false)"> | ||||
|             <span translate="addButtonLabel"></span> | ||||
|         </button> | ||||
|     </div> | ||||
| 
 | ||||
|     <div class="admin__field-complex-content" | ||||
|          translate="'User agent exceptions override product and CMS pages rules.'"></div> | ||||
| </div> | ||||
| 
 | ||||
| <div class="admin__field admin__field-wide" | ||||
|      visible="visible" | ||||
|      disabled="disabled" | ||||
|      css="$data.setClasses($data)" | ||||
|      attr="'data-index': index"> | ||||
|     <label if="$data.label" class="admin__field-label" attr="for: $data.uid"> | ||||
|         <span translate="$data.label"></span> | ||||
|     </label> | ||||
| 
 | ||||
|     <div class="admin__field-control" data-role="grid-wrapper"> | ||||
|         <div class="admin__control-table-pagination" visible="!!element.getRecordCount()"> | ||||
|             <div class="admin__data-grid-pager"> | ||||
|                 <button class="action-previous" type="button" data-bind="attr: {title: $t('Previous Page')}, click: previousPage, disable: isFirst()"></button> | ||||
|                 <input class="admin__control-text" type="number" data-bind="attr: {id: ++ko.uid}, value: currentPage"/> | ||||
|                 <label class="admin__control-support-text" data-bind="attr: {for: ko.uid}, text: 'of ' + pages()"></label> | ||||
|                 <button class="action-next" type="button" data-bind="attr: {title: $t('Next Page')}, click: nextPage, disable: isLast()"></button> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="admin__control-table-wrapper"> | ||||
|             <table class="admin__dynamic-rows data-grid" data-role="grid"> | ||||
|                 <thead if="element.columnsHeader"> | ||||
|                     <tr> | ||||
|                         <th if="$data.dndConfig.enabled" | ||||
|                             class="data-grid-draggable-row-cell"></th> | ||||
| 
 | ||||
|                         <th repeat="foreach: labels, item: '$label'" | ||||
|                             class="data-grid-th" | ||||
|                             visible="$label().visible" | ||||
|                             disable="$label().disabled" | ||||
|                             css="setClasses($label())"> | ||||
|                             <span translate="$label().label"></span> | ||||
|                         </th> | ||||
|                     </tr> | ||||
|                 </thead> | ||||
| 
 | ||||
|                 <tbody> | ||||
|                     <tr repeat="foreach: elems, item: '$record'" | ||||
|                         class="data-row" | ||||
|                         css="'_odd-row': $index % 2"> | ||||
|                         <td if="dndConfig.enabled" | ||||
|                             class="data-grid-draggable-row-cell" | ||||
|                             template="name: dndConfig.template, data: dnd"></td> | ||||
| 
 | ||||
|                         <!-- ko foreach: { data: $record().elems(), as: 'elem'}  --> | ||||
|                         <td if="elem.template" | ||||
|                             visible="elem.visible() && elem.formElement !== 'hidden'" | ||||
|                             disable="elem.disabled" | ||||
|                             css="$parent.setClasses(elem)" | ||||
|                             template="elem.template" | ||||
|                             attr="'data-index': index"></td> | ||||
|                         <!-- /ko --> | ||||
|                     </tr> | ||||
|                 </tbody> | ||||
|             </table> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
| 
 | ||||
| <div class="messages"> | ||||
|     <div class="message message-notice notice"> | ||||
|         <span | ||||
|             translate="'Search strings are either normal strings or regular expressions (PCRE). They are matched in the same order as entered.'"></span> | ||||
|         <br/> | ||||
|         <span | ||||
|             translate="'Examples'"></span>: | ||||
|         <span class="code-sample">Firefox: /^mozilla/i</span> | ||||
|     </div> | ||||
| </div> | ||||
|  | @ -1,10 +0,0 @@ | |||
| <!-- | ||||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| --> | ||||
| <button class="action-tertiary" | ||||
|         click="element.restoreToDefault"> | ||||
|     <span translate="'Use Default Value'"></span> | ||||
| </button> | ||||
|  | @ -1,101 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| #bundle_product_container .tier { | ||||
|     margin-bottom: 13px; | ||||
| } | ||||
| 
 | ||||
| #bundle_product_container .col-qty > input[type='text'] { | ||||
|     text-align: right; | ||||
| } | ||||
| 
 | ||||
| #bundle_product_container .col-name { | ||||
|     max-width: 250px; | ||||
|     overflow: hidden; | ||||
|     text-overflow: ellipsis; | ||||
| } | ||||
| 
 | ||||
| #bundle_product_container .col-sku { | ||||
|     max-width: 170px; | ||||
|     overflow: hidden; | ||||
|     text-overflow: ellipsis; | ||||
| } | ||||
| 
 | ||||
| #bundle_product_container .col-draggable { | ||||
|     width: 10px; | ||||
| } | ||||
| 
 | ||||
| #bundle_product_container .col-actions { | ||||
|     width: 40px; | ||||
| } | ||||
| 
 | ||||
| #bundle_product_container .col-qty, | ||||
| #bundle_product_container .col-uqty, | ||||
| #bundle_product_container .col-default { | ||||
|     width: 70px; | ||||
| } | ||||
| 
 | ||||
| #bundle_product_container .field-option-req .control { | ||||
|     top: 39px; | ||||
| } | ||||
| 
 | ||||
| .selection-search .massaction { | ||||
|     display: none; | ||||
| } | ||||
| 
 | ||||
| /* Sku, Price, Weight Fields */ | ||||
| .field-sku .control .sku { | ||||
|     display: inline-block; | ||||
|     width: 140px; | ||||
|     margin-right: 11px; | ||||
| } | ||||
| 
 | ||||
| .field-sku .control .sku > input[type='text'] { | ||||
|     width: 100%; | ||||
| } | ||||
| 
 | ||||
| .field-price .addon > .price { | ||||
|     display: table; | ||||
|     direction: rtl; | ||||
|     float: left; | ||||
|     width: 140px; | ||||
|     margin-right: 15px; | ||||
| } | ||||
| 
 | ||||
| .field-price .addon > .price > * { | ||||
|     direction: ltr; | ||||
| } | ||||
| 
 | ||||
| .field-price .addon > .price + .select { | ||||
|     float: left; | ||||
| } | ||||
| 
 | ||||
| .field-weight .weight { | ||||
|     display: inline-block; | ||||
|     margin-right: 15px; | ||||
|     vertical-align: top; | ||||
|     width: 140px; | ||||
| } | ||||
| 
 | ||||
| .field-weight .weight .admin__control-addon .input-text { | ||||
|     min-width: 10rem; | ||||
| } | ||||
| 
 | ||||
| .field-weight .weight .admin__control-addon .input-text, | ||||
| .field-weight .weight .admin__control-addon .admin__addon-suffix { | ||||
|     flex-basis: 10rem; | ||||
| } | ||||
| 
 | ||||
| .ie9 .field-weight .weight .admin__control-addon .input-text { | ||||
|     width: 100px; | ||||
| } | ||||
| 
 | ||||
| .weight-switcher .admin__control-addon { | ||||
|     width: 100%; | ||||
| } | ||||
| 
 | ||||
| .field-weight .weight .field:first-child { | ||||
|     width: 100%; | ||||
| } | ||||
|  | @ -1,297 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| /*global FORM_KEY*/ | ||||
| /*global bSelection*/ | ||||
| /** | ||||
|  * @api | ||||
|  */ | ||||
| define([ | ||||
|     'jquery', | ||||
|     'Magento_Catalog/js/product/weight-handler', | ||||
|     'Magento_Ui/js/modal/modal', | ||||
|     'jquery/ui', | ||||
|     'mage/translate', | ||||
|     'Magento_Theme/js/sortable', | ||||
|     'prototype' | ||||
| ], function ($, weightHandler) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     $.widget('mage.bundleProduct', { | ||||
|         /** @inheritdoc */ | ||||
|         _create: function () { | ||||
|             this._initOptionBoxes() | ||||
|                 ._initSortableSelections() | ||||
|                 ._bindCheckboxHandlers() | ||||
|                 ._initCheckboxState() | ||||
|                 ._bindAddSelectionDialog() | ||||
|                 ._hideProductTypeSwitcher(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @return {Object} | ||||
|          * @private | ||||
|          */ | ||||
|         _initOptionBoxes: function () { | ||||
|             var syncOptionTitle; | ||||
| 
 | ||||
|             this.element.sortable({ | ||||
|                 axis: 'y', | ||||
|                 handle: '[data-role=draggable-handle]', | ||||
|                 items: '.option-box', | ||||
|                 update: this._updateOptionBoxPositions, | ||||
|                 tolerance: 'pointer' | ||||
|             }); | ||||
| 
 | ||||
|             /** | ||||
|              * @param {jQuery.Event} event | ||||
|              */ | ||||
|             syncOptionTitle = function (event) { | ||||
|                 var originalValue = $(event.target).attr('data-original-value'), | ||||
|                     currentValue = $(event.target).val(), | ||||
|                     optionBoxTitle = $('.title > span', $(event.target).closest('.option-box')), | ||||
|                     newOptionTitle = $.mage.__('New Option'); | ||||
| 
 | ||||
|                 optionBoxTitle.text(currentValue === '' && !originalValue.length ? newOptionTitle : currentValue); | ||||
|             }; | ||||
|             this._on({ | ||||
|                 'change .field-option-title input[name$="[title]"]': syncOptionTitle, | ||||
|                 'keyup .field-option-title input[name$="[title]"]': syncOptionTitle, | ||||
|                 'paste .field-option-title input[name$="[title]"]': syncOptionTitle | ||||
|             }); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @return {Object} | ||||
|          * @private | ||||
|          */ | ||||
|         _initSortableSelections: function () { | ||||
|             this.element.find('.option-box .form-list tbody').sortable({ | ||||
|                 axis: 'y', | ||||
|                 handle: '[data-role=draggable-handle]', | ||||
| 
 | ||||
|                 /** | ||||
|                  * @param {jQuery.Event} event | ||||
|                  * @param {jQuery} ui | ||||
|                  * @return {jQuery} | ||||
|                  */ | ||||
|                 helper: function (event, ui) { | ||||
|                     ui.children().each(function () { | ||||
|                         $(this).width($(this).width()); | ||||
|                     }); | ||||
| 
 | ||||
|                     return ui; | ||||
|                 }, | ||||
|                 update: this._updateSelectionsPositions, | ||||
|                 tolerance: 'pointer' | ||||
|             }); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @return {Object} | ||||
|          * @private | ||||
|          */ | ||||
|         _initCheckboxState: function () { | ||||
|             this.element.find('.is-required').each(function () { | ||||
|                 $(this).prop('checked', $(this).closest('.option-box').find('[name$="[required]"]').val() > 0); | ||||
|             }); | ||||
| 
 | ||||
|             this.element.find('.is-user-defined-qty').each(function () { | ||||
|                 $(this).prop('checked', $(this).closest('.qty-box').find('.select').val() > 0); | ||||
|             }); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @return {Object} | ||||
|          * @private | ||||
|          */ | ||||
|         _bindAddSelectionDialog: function () { | ||||
|             var widget = this; | ||||
| 
 | ||||
|             this._on({ | ||||
|                 /** | ||||
|                  * @param {jQuery.Event} event | ||||
|                  */ | ||||
|                 'click .add-selection': function (event) { | ||||
|                     var $optionBox = $(event.target).closest('.option-box'), | ||||
|                         $selectionGrid = $optionBox.find('.selection-search').clone(), | ||||
|                         optionIndex = $optionBox.attr('id').replace('bundle_option_', ''), | ||||
|                         productIds = [], | ||||
|                         productSkus = [], | ||||
|                         selectedProductList = {}; | ||||
| 
 | ||||
|                     $optionBox.find('[name$="[product_id]"]').each(function () { | ||||
|                         if (!$(this).closest('tr').find('[name$="[delete]"]').val()) { | ||||
|                             productIds.push($(this).val()); | ||||
|                             productSkus.push($(this).closest('tr').find('.col-sku').text()); | ||||
|                         } | ||||
|                     }); | ||||
| 
 | ||||
|                     bSelection.gridSelection.set(optionIndex, $H({})); | ||||
|                     bSelection.gridRemoval = $H({}); | ||||
|                     bSelection.gridSelectedProductSkus = productSkus; | ||||
| 
 | ||||
|                     $selectionGrid.on('contentUpdated', bSelection.gridUpdateCallback); | ||||
|                     $selectionGrid.on('change', '.col-id input', function () { | ||||
|                         var tr = $(this).closest('tr'); | ||||
| 
 | ||||
|                         if ($(this).is(':checked')) { | ||||
|                             selectedProductList[$(this).val()] = { | ||||
|                                 name: tr.find('.col-name').html().trim(), | ||||
|                                 sku: tr.find('.col-sku').html().trim(), | ||||
|                                 'product_id': $(this).val(), | ||||
|                                 'option_id': $('bundle_selection_id_' + optionIndex).val(), | ||||
|                                 'selection_price_value': 0, | ||||
|                                 'selection_qty': 1 | ||||
|                             }; | ||||
|                         } else { | ||||
|                             delete selectedProductList[$(this).val()]; | ||||
|                         } | ||||
|                     }); | ||||
| 
 | ||||
|                     $selectionGrid.modal({ | ||||
|                         title: $optionBox.find('input[name$="[title]"]').val() === '' ? | ||||
|                             $.mage.__('Add Products to New Option') : | ||||
|                             $.mage.__('Add Products to Option "%1"').replace( | ||||
|                                 '%1', | ||||
|                                 $('<div>').text($optionBox.find('input[name$="[title]"]').val()).html() | ||||
|                             ), | ||||
|                         modalClass: 'bundle', | ||||
|                         type: 'slide', | ||||
| 
 | ||||
|                         /** | ||||
|                          * @param {jQuery.Event} e | ||||
|                          * @param {Object} modalWindow | ||||
|                          */ | ||||
|                         closed: function (e, modalWindow) { | ||||
|                             modalWindow.modal.remove(); | ||||
|                         }, | ||||
|                         buttons: [{ | ||||
|                             text: $.mage.__('Add Selected Products'), | ||||
|                             'class': 'action-primary action-add', | ||||
| 
 | ||||
|                             /** Click action. */ | ||||
|                             click: function () { | ||||
|                                 $.each(selectedProductList, function () { | ||||
|                                     window.bSelection.addRow(optionIndex, this); | ||||
|                                 }); | ||||
|                                 bSelection.gridRemoval.each(function (pair) { | ||||
|                                     $optionBox.find('.col-sku').filter(function () { | ||||
|                                         let text = $(this).text(); | ||||
| 
 | ||||
|                                         return text.trim() === pair.key; // find row by SKU
 | ||||
|                                     }).closest('tr').find('button.delete').trigger('click'); | ||||
|                                 }); | ||||
|                                 widget.refreshSortableElements(); | ||||
|                                 widget._updateSelectionsPositions.apply(widget.element); | ||||
|                                 $selectionGrid.modal('closeModal'); | ||||
|                             } | ||||
|                         }] | ||||
|                     }); | ||||
|                     $.ajax({ | ||||
|                         url: bSelection.selectionSearchUrl, | ||||
|                         dataType: 'html', | ||||
|                         data: { | ||||
|                             index: optionIndex, | ||||
|                             products: productIds, | ||||
|                             'selected_products': productIds, | ||||
|                             'form_key': FORM_KEY | ||||
|                         }, | ||||
| 
 | ||||
|                         /** | ||||
|                          * @param {*} data | ||||
|                          */ | ||||
|                         success: function (data) { | ||||
|                             $selectionGrid.html(data).modal('openModal'); | ||||
|                         }, | ||||
|                         context: $('body'), | ||||
|                         showLoader: true | ||||
|                     }); | ||||
|                 } | ||||
|             }); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @private | ||||
|          */ | ||||
|         _hideProductTypeSwitcher: function () { | ||||
|             weightHandler.hideWeightSwitcher(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @return {Object} | ||||
|          * @private | ||||
|          */ | ||||
|         _bindCheckboxHandlers: function () { | ||||
|             this._on({ | ||||
|                 /** | ||||
|                  * @param {jQuery.Event} event | ||||
|                  */ | ||||
|                 'change .is-required': function (event) { | ||||
|                     var $this = $(event.target); | ||||
| 
 | ||||
|                     $this.closest('.option-box').find('[name$="[required]"]').val($this.is(':checked') ? 1 : 0); | ||||
|                 }, | ||||
| 
 | ||||
|                 /** | ||||
|                  * @param {jQuery.Event} event | ||||
|                  */ | ||||
|                 'change .is-user-defined-qty': function (event) { | ||||
|                     var $this = $(event.target); | ||||
| 
 | ||||
|                     $this.closest('.qty-box').find('.select').val($this.is(':checked') ? 1 : 0); | ||||
|                 } | ||||
|             }); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @return {Object} | ||||
|          * @private | ||||
|          */ | ||||
|         _updateOptionBoxPositions: function () { | ||||
|             $(this).find('[name^=bundle_options][name$="[position]"]').each(function (index) { | ||||
|                 $(this).val(index); | ||||
|             }); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @return {Object} | ||||
|          * @private | ||||
|          */ | ||||
|         _updateSelectionsPositions: function () { | ||||
|             $(this).find('[name^=bundle_selections][name$="[position]"]').each(function (index) { | ||||
|                 $(this).val(index); | ||||
|             }); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * | ||||
|          * @return {Object} | ||||
|          */ | ||||
|         refreshSortableElements: function () { | ||||
|             this.element.sortable('refresh'); | ||||
|             this._updateOptionBoxPositions.apply(this.element); | ||||
|             this._initSortableSelections(); | ||||
|             this._initCheckboxState(); | ||||
| 
 | ||||
|             return this; | ||||
|         } | ||||
|     }); | ||||
| 
 | ||||
| }); | ||||
|  | @ -1,44 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define([ | ||||
|     'jquery', | ||||
|     'Magento_Catalog/catalog/type-events', | ||||
|     'Magento_Catalog/js/product/weight-handler' | ||||
| ], function ($, productType, weight) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return { | ||||
| 
 | ||||
|         /** | ||||
|          * Constructor component | ||||
|          */ | ||||
|         'Magento_Bundle/js/bundle-type-handler': function () { | ||||
|             this.bindAll(); | ||||
|             this._initType(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Bind all | ||||
|          */ | ||||
|         bindAll: function () { | ||||
|             $(document).on('changeTypeProduct', this._initType.bind(this)); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Init type | ||||
|          * @private | ||||
|          */ | ||||
|         _initType: function () { | ||||
|             if ( | ||||
|                 productType.type.init === 'bundle' && | ||||
|                 productType.type.current !== 'bundle' && | ||||
|                 !weight.isLocked() | ||||
|             ) { | ||||
|                 weight.switchWeight(); | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
| }); | ||||
|  | @ -1,95 +0,0 @@ | |||
| /** | ||||
|  * Copyright © Magento, Inc. All rights reserved. | ||||
|  * See COPYING.txt for license details. | ||||
|  */ | ||||
| 
 | ||||
| define([ | ||||
|     'Magento_Ui/js/form/element/single-checkbox', | ||||
|     'uiRegistry' | ||||
| ], function (Checkbox, registry) { | ||||
|     'use strict'; | ||||
| 
 | ||||
|     return Checkbox.extend({ | ||||
|         defaults: { | ||||
|             clearing: false, | ||||
|             parentContainer: '', | ||||
|             parentSelections: '', | ||||
|             changer: '', | ||||
|             exports: { | ||||
|                 value: '${$.parentName}:isDefaultValue' | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @inheritdoc | ||||
|          */ | ||||
|         initObservable: function () { | ||||
|             this._super(). | ||||
|                 observe('elementTmpl'); | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @inheritdoc | ||||
|          */ | ||||
|         initConfig: function () { | ||||
|             this._super(); | ||||
|             this.imports.changeType = this.retrieveParentName(this.parentContainer) + '.' + this.changer + ':value'; | ||||
| 
 | ||||
|             return this; | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * @inheritdoc | ||||
|          */ | ||||
|         onUpdate: function () { | ||||
|             if (this.prefer === 'radio' && this.checked() && !this.clearing) { | ||||
|                 this.clearValues(); | ||||
|             } | ||||
| 
 | ||||
|             this._super(); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Checkbox to radio type changer. | ||||
|          * | ||||
|          * @param {String} type - type to change. | ||||
|          */ | ||||
|         changeType: function (type) { | ||||
|             var typeMap = registry.get(this.retrieveParentName(this.parentContainer) + '.' + this.changer).typeMap; | ||||
| 
 | ||||
|             this.prefer = typeMap[type]; | ||||
|             this.elementTmpl(this.templates[typeMap[type]]); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Clears values in components like this. | ||||
|          */ | ||||
|         clearValues: function () { | ||||
|             var records = registry.get(this.retrieveParentName(this.parentSelections)), | ||||
|                 index = this.index, | ||||
|                 uid = this.uid; | ||||
| 
 | ||||
|             records.elems.each(function (record) { | ||||
|                 record.elems.filter(function (comp) { | ||||
|                     return comp.index === index && comp.uid !== uid; | ||||
|                 }).each(function (comp) { | ||||
|                     comp.clearing = true; | ||||
|                     comp.clear(); | ||||
|                     comp.clearing = false; | ||||
|                 }); | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         /** | ||||
|          * Retrieve name for the most global parent with provided index. | ||||
|          * | ||||
|          * @param {String} parent - parent name. | ||||
|          * @returns {String} | ||||
|          */ | ||||
|         retrieveParentName: function (parent) { | ||||
|             return this.name.replace(new RegExp('^(.+?\\.)?' + parent + '\\..+'), '$1' + parent); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||