diff --git a/app/code/Magento/AdminNotification/Block/System/Messages.php b/app/code/Magento/AdminNotification/Block/System/Messages.php index 45614b1d1e22bcd8bf76f9568091964fa8ebf707..994d767e0d56f00a56d3b74d17b993eea8c99051 100644 --- a/app/code/Magento/AdminNotification/Block/System/Messages.php +++ b/app/code/Magento/AdminNotification/Block/System/Messages.php @@ -120,11 +120,8 @@ class Messages extends \Magento\Backend\Block\Template return $this->jsonHelper->jsonEncode( [ 'systemMessageDialog' => [ - 'autoOpen' => false, - 'width' => '75%', - 'modal' => true, - 'minHeight' => '0', - 'dialogClass' => 'ui-dialog-active ui-popup-message', + 'buttons' => [], + 'modalClass' => 'ui-dialog-active ui-popup-message modal-system-messages', 'ajaxUrl' => $this->_getMessagesUrl() ], ] diff --git a/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml b/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml index 74b52dd3ce92c72dbea8f19d8909d62c6f796292..5df9af8b4cce5ea1e900014e15c03a1b733c5506 100644 --- a/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml +++ b/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml @@ -9,8 +9,8 @@ ?> <?php /** @var $block \Magento\AdminNotification\Block\System\Messages\UnreadMessagePopup */ ?> -<div style="display:none" id="system_messages_list" title="<?php echo $block->escapeHtml($block->getPopupTitle()); ?>"> - <ul class="message-system-list"> +<div style="display:none" id="system_messages_list" data-role="system_messages_list" title="<?php echo $block->escapeHtml($block->getPopupTitle()); ?>"> + <ul class="message-system-list messages"> <?php foreach ($block->getUnreadMessages() as $message): ?> <li class="message message-warning <?php /* @escapeNotVerified */ echo $block->getItemClass($message);?>"> <?php /* @escapeNotVerified */ echo $message->getText();?> @@ -22,29 +22,17 @@ <script> require([ "jquery", - "jquery/ui" + "Magento_Ui/js/modal/modal" ], function($){ - - $(function() { - $("#system_messages_list").dialog({ - autoOpen: true, - resizable: false, - width: '75%', - modal: true, - minHeight: '0', - dialogClass: 'ui-popup-message', - position: { - my: 'left+12.5% top', - at: 'center top', - of: 'body' - }, - open: function() { - $(this).closest('.ui-dialog').addClass('ui-dialog-active'); - - var topMargin = $(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 10; - $(this).closest('.ui-dialog').css('margin-top', topMargin); - } + if (this.modal) { + this.modal.html($('[data-role="system_messages_list"]').html()); + } else { + this.modal = $('[data-role="system_messages_list"]').modal({ + modalClass: 'modal-system-messages ui-popup-message', + type: 'popup', + buttons: [] }); - }); + } + this.modal.modal('openModal'); }); </script> diff --git a/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js b/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js index 95a228c6fa99c671f144664535cc076d6923ff4b..8b5cf5b0476c6b006bf384aa5891c33d3fc40e6a 100644 --- a/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js +++ b/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js @@ -5,12 +5,14 @@ define([ 'jquery', 'mage/template', - 'jquery/ui' + 'jquery/ui', + 'Magento_Ui/js/modal/modal' ], function ($, mageTemplate) { 'use strict'; - $.widget('mage.systemMessageDialog', $.ui.dialog, { + $.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<% } %>">' + @@ -19,8 +21,14 @@ define([ '<% }); %>' }, - open: function (severity) { + _create: function() { + this.options.title = $('#message-system-all').attr('title'); + this._super(); + }, + + openModal: function (severity) { var superMethod = $.proxy(this._super, this); + //this.modal.options $.ajax({ url: this.options.ajaxUrl, @@ -47,16 +55,19 @@ define([ }, this)); return this; + }, + closeModal: function () { + this._super(); } }); $(document).ready(function () { $('#system_messages .message-system-short .error').on('click', function () { - $('#message-system-all').systemMessageDialog('open', 1); + $('#message-system-all').systemMessageDialog('openModal', 1); }); $('#system_messages .message-system-short .warning').on('click', function () { - $('#message-system-all').systemMessageDialog('open', 2); + $('#message-system-all').systemMessageDialog('openModal', 2); }); }); diff --git a/app/code/Magento/Authorizenet/view/adminhtml/templates/directpost/info.phtml b/app/code/Magento/Authorizenet/view/adminhtml/templates/directpost/info.phtml index c6dd0ce00e6be2f18ee5d5385a43c7de54a83016..6c02076b5a7dbe55d9a81b7114599221c6c9f14e 100644 --- a/app/code/Magento/Authorizenet/view/adminhtml/templates/directpost/info.phtml +++ b/app/code/Magento/Authorizenet/view/adminhtml/templates/directpost/info.phtml @@ -5,7 +5,6 @@ */ // @codingStandardsIgnoreFile - /** * @var \Magento\Authorizenet\Block\Transparent\Iframe $block * @see \Magento\Authorizenet\Block\Transparent\Iframe @@ -24,10 +23,12 @@ $ccExpYear = $block->getInfoData('cc_exp_year'); src="<?php /* @noEscape */ echo $block->getViewFileUrl('blank.html'); ?>"> </iframe> <!-- IFRAME for request to Authorize.net --> -<iframe id="directpost-iframe" allowtransparency="true" frameborder="0" name="iframeDirectPost" style="display:none;width:100%;background-color:transparent" +<iframe id="directpost-iframe" allowtransparency="true" frameborder="0" name="iframeDirectPost" + style="display:none;width:100%;background-color:transparent" src="<?php /* @noEscape */ echo $block->getViewFileUrl('blank.html'); ?>"> </iframe> -<fieldset class="admin__fieldset payment-method" id="payment_form_<?php /* @noEscape */ echo $code; ?>" style="display:none;"> +<fieldset class="admin__fieldset payment-method" id="payment_form_<?php /* @noEscape */ echo $code; ?>" + style="display:none;"> <div class="admin__field _required"> <label for="<?php /* @noEscape */ echo $code; ?>_cc_type" class="admin__field-label"> <span><?php echo $block->escapeHtml(__('Credit Card Type')); ?></span> @@ -81,11 +82,11 @@ $ccExpYear = $block->getInfoData('cc_exp_year'); <?php if ($k == $ccExpYear): ?>selected="selected"<?php endif; ?>> <?php echo $block->escapeHtml($v); ?> </option> - <?php endforeach ?> + <?php endforeach; ?> </select> </div> </div> - <?php if ($_form->hasVerification()): ?> + <?php if ($block->hasVerification()): ?> <div class="admin__field _required"> <label for="<?php /* @noEscape */ echo $code; ?>_cc_cid"> <span><?php echo $block->escapeHtml(__('Card Verification Number')); ?></span> @@ -123,7 +124,9 @@ $ccExpYear = $block->getInfoData('cc_exp_year'); '<?php /* @noEscape */ echo $controller; ?>', '<?php /* @noEscape */ echo $orderUrl; ?>', '<?php echo $block->escapeUrl($method->getCgiUrl()); ?>', - '<?php /* @noEscape */ echo $block->getUrl('*/*/save', ['_secure' => $block->getRequest()->isSecure()]) ?>'); + '<?php /* @noEscape */ echo $block->getUrl('*/*/save', [ + '_secure' => $block->getRequest()->isSecure() + ]);?>'); <?php if (!$block->isAjaxRequest()): ?> }); diff --git a/app/code/Magento/Authorizenet/view/frontend/web/js/view/payment/method-renderer/authorizenet-directpost.js b/app/code/Magento/Authorizenet/view/frontend/web/js/view/payment/method-renderer/authorizenet-directpost.js index cb58db6d1d5a00283a2d87461dbac55272121dad..bf6978cfa365c38700830a02dcff602881af509d 100644 --- a/app/code/Magento/Authorizenet/view/frontend/web/js/view/payment/method-renderer/authorizenet-directpost.js +++ b/app/code/Magento/Authorizenet/view/frontend/web/js/view/payment/method-renderer/authorizenet-directpost.js @@ -50,9 +50,8 @@ define( placeOrder: function () { var self = this; - fullScreenLoader.startLoader(); - if (this.validateHandler() && additionalValidators.validate()) { + fullScreenLoader.startLoader(); this.isPlaceOrderActionAllowed(false); $.when(setPaymentInformationAction(this.messageContainer, { 'method': self.getCode() diff --git a/app/code/Magento/Backend/view/adminhtml/templates/dashboard/index.phtml b/app/code/Magento/Backend/view/adminhtml/templates/dashboard/index.phtml index 5c9cf626e37f11d07b10cc5a3713308a8e33e06e..bd97edfa35b179c0e2b802932f9e42cba4882a15 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/dashboard/index.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/dashboard/index.phtml @@ -10,7 +10,10 @@ <?php if (is_array($block->getChildBlock('diagrams')->getTabsIds())) : ?> <script> -require(['prototype'], function(){ +require([ + 'Magento_Ui/js/modal/alert', + 'prototype' +], function(alert){ window.changeDiagramsPeriod = function(periodObj) { periodParam = periodObj.value ? 'period/' + periodObj.value + '/' : ''; @@ -25,7 +28,9 @@ window.changeDiagramsPeriod = function(periodObj) { if (transport.responseText.isJSON()) { var response = transport.responseText.evalJSON() if (response.error) { - alert(response.message); + alert({ + content: response.message + }); } if(response.ajaxExpired && response.ajaxRedirect) { setLocation(response.ajaxRedirect); @@ -47,9 +52,11 @@ window.changeDiagramsPeriod = function(periodObj) { tabContentElementId = 'dashboard_diagram_totals'; try { if (transport.responseText.isJSON()) { - var response = transport.responseText.evalJSON() + var response = transport.responseText.evalJSON(); if (response.error) { - alert(response.message); + alert({ + content: response.message + }); } if(response.ajaxExpired && response.ajaxRedirect) { setLocation(response.ajaxRedirect); diff --git a/app/code/Magento/Backend/view/adminhtml/templates/media/uploader.phtml b/app/code/Magento/Backend/view/adminhtml/templates/media/uploader.phtml index d6bd7de2f1c0c5df116a271b504e356aa1e5da0c..a876ad6c6e59911a96ba92f860b0b43fb7155f94 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/media/uploader.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/media/uploader.phtml @@ -31,9 +31,10 @@ require([ "jquery", 'mage/template', + 'Magento_Ui/js/modal/alert', "mage/translate", "jquery/file-uploader" -], function ($, mageTemplate) { +], function ($, mageTemplate, alert) { $('#fileupload').fileupload({ dataType: 'json', @@ -75,7 +76,9 @@ require([ $('#' + data.fileId) .delay(2000) .hide('highlight'); - alert($.mage.__('We don\'t recognize or support this file extension type.')); + alert({ + content: $.mage.__('We don\'t recognize or support this file extension type.') + }); } $('#' + data.fileId).remove(); }, diff --git a/app/code/Magento/Backend/view/adminhtml/templates/page/locale.phtml b/app/code/Magento/Backend/view/adminhtml/templates/page/locale.phtml index fd4ac471185b88563e994bb12c3da1d3c1e6e8e4..03347fbcbe6953245b1b14cc3534c1894d173049 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/page/locale.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/page/locale.phtml @@ -11,16 +11,21 @@ <label class="label" for="footer_interface_locale"><span><?php /* @escapeNotVerified */ echo __('Interface Locale'); ?></span></label> <?php /* @escapeNotVerified */ echo $block->getLocaleSelect(); ?> <script> - (function () { - 'use strict'; + require([ + 'mage/validation/url' + ], + function (urlValidator) { + 'use strict'; - var elem = document.getElementById('footer_interface_locale'); + var elem = document.getElementById('footer_interface_locale'); - function onChange() { - window.location.href = '<?php /* @escapeNotVerified */ echo $block->getChangeLocaleUrl() ?>locale/' + elem.value + '/<?php /* @escapeNotVerified */ echo $block->getUrlForReferer() ?>'; - } + function onChange() { + urlValidator.redirect('<?php /* @escapeNotVerified */ echo $block->getChangeLocaleUrl() ?>locale/' + + elem.value + + '/<?php /* @escapeNotVerified */ echo $block->getUrlForReferer() ?>'); + } - elem.addEventListener('change', onChange); - })(); + elem.addEventListener('change', onChange); + }); </script> </div> diff --git a/app/code/Magento/Backend/view/adminhtml/templates/store/switcher.phtml b/app/code/Magento/Backend/view/adminhtml/templates/store/switcher.phtml index ad46dbeec25be6141c38a7bdba3503792fbb1df8..293733ae9d74e3390bb236fe5fc7189fcf77bdf6 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/store/switcher.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/store/switcher.phtml @@ -130,7 +130,10 @@ </div> <script> -require(['jquery'], function(jQuery){ +require([ + 'jquery', + 'Magento_Ui/js/modal/confirm' +], function(jQuery, confirm){ (function($) { var $storesList = $('[data-role=stores-list]'); @@ -171,11 +174,19 @@ require(['jquery'], function(jQuery){ } else { <?php if ($block->getUseConfirm()): ?> - if (confirm("<?php /* @escapeNotVerified */ echo __('Please confirm scope switching. All data that hasn\'t been saved will be lost.') ?>")) { - reload(); - } else { - obj.value = '<?php echo $block->escapeHtml($block->getStoreId()) ?>'; - } + + confirm({ + content: "<?php /* @escapeNotVerified */ echo __('Please confirm scope switching. All data that hasn\'t been saved will be lost.') ?>", + actions: { + confirm: function() { + reload(); + }, + cancel: function() { + obj.value = '<?php echo $block->escapeHtml($block->getStoreId()) ?>'; + } + } + }); + <?php else: ?> reload(); <?php endif; ?> diff --git a/app/code/Magento/Backend/view/adminhtml/templates/widget/form/renderer/fieldset/element.phtml b/app/code/Magento/Backend/view/adminhtml/templates/widget/form/renderer/fieldset/element.phtml index c11293d6ae71c578ecfc3f6b907e4f8b2e88395e..392f9378beb519ab225a9cab5db71fb0dfc2f804 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/widget/form/renderer/fieldset/element.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/widget/form/renderer/fieldset/element.phtml @@ -38,7 +38,7 @@ $fieldAttributes = $fieldId . ' class="' . $fieldClass . '" ' <?php else: ?> <?php echo $element->getLabelHtml() ?> <div class="admin__field-control control"> - <?php /* @escapeNotVerified */ echo($addOn) ? '<div class="admin__field admin__field-option">' . $element->getElementHtml() . '</div>' : $element->getElementHtml(); ?> + <?php /* @escapeNotVerified */ echo($addOn) ? '<div class="admin__field">' . $element->getElementHtml() . '</div>' : $element->getElementHtml(); ?> <?php /* @escapeNotVerified */ echo $note ?> </div> <?php endif; ?> diff --git a/app/code/Magento/Backup/view/adminhtml/templates/backup/dialogs.phtml b/app/code/Magento/Backup/view/adminhtml/templates/backup/dialogs.phtml index b8e7ba06b8b9ee28b96feef769df14b3e6eaac7e..dc04861bece01c82873359970b919a2f78647b08 100644 --- a/app/code/Magento/Backup/view/adminhtml/templates/backup/dialogs.phtml +++ b/app/code/Magento/Backup/view/adminhtml/templates/backup/dialogs.phtml @@ -62,42 +62,45 @@ <div class="popup-content"> <div class="backup-messages" style="display: none;"><div class="messages"></div></div> <div class="messages"> - <div class="message message-warning"><?php /* @escapeNotVerified */ echo __('Please specify backup creation option.')?></div> + <div class="message message-warning"> + <?php /* @escapeNotVerified */ echo __('This may take a few moments.')?> + <?php /* @escapeNotVerified */ echo __('Be sure your store is in maintenance mode during backup.')?></div> </div> <form action="" method="post" id="backup-form" class="form-inline"> - <fieldset class="fieldset form-list question"> - <div class="field"> - <label for="backup_name" class="label"><span><?php /* @escapeNotVerified */ echo __('Backup Name')?></span></label> - <div class="control"> + <fieldset class="admin__fieldset form-list question"> + <div class="admin__field field _required"> + <label for="backup_name" class="admin__field-label"><span><?php /* @escapeNotVerified */ echo __('Backup Name')?></span></label> + <div class="admin__field-control"> <input type="text" name="backup_name" id="backup_name" - class="required-entry validate-alphanum-with-spaces validate-length maximum-length-50" + class="admin__control-text required-entry validate-alphanum-with-spaces validate-length maximum-length-50" maxlength="50" /> - <div class="note"> + <div class="admin__field-note"> <?php /* @escapeNotVerified */ echo __('Please use only letters (a-z or A-Z), numbers (0-9) or spaces in this field.'); ?> </div> </div> </div> - <div class="field maintenance-checkbox-container"> - <div class="control"> - <input type="checkbox" name="maintenance_mode" value="1" id="backup_maintenance_mode"/> - <label for="backup_maintenance_mode"><?php /* @escapeNotVerified */ echo __('Please put your store into maintenance mode during backup.')?></label> + <div class="admin__field field maintenance-checkbox-container"> + <label for="backup_maintenance_mode" class="admin__field-label"><span><?php /* @escapeNotVerified */ echo __('Maintenance mode')?></span></label> + <div class="admin__field-control"> + <div class="admin__field-option"> + <input class="admin__control-checkbox" type="checkbox" name="maintenance_mode" value="1" id="backup_maintenance_mode"/> + <label class="admin__field-label" for="backup_maintenance_mode"><?php /* @escapeNotVerified */ echo __('Please put your store into maintenance mode during backup.')?></label> + </div> </div> </div> - <div class="field maintenance-checkbox-container" id="exclude-media-checkbox-container" style="display: none;"> - <div class="control"> - <input type="checkbox" name="exclude_media" value="1" id="exclude_media"/> - <label for="exclude_media"><?php /* @escapeNotVerified */ echo __('Exclude media folder from backup') ?></label> + <div class="admin__field field maintenance-checkbox-container" id="exclude-media-checkbox-container" style="display: none;"> + <label for="exclude_media" class="admin__field-label"><span><?php /* @escapeNotVerified */ echo __('Exclude')?></span></label> + <div class="admin__field-control"> + <div class="admin__field-option"> + <input class="admin__control-checkbox" type="checkbox" name="exclude_media" value="1" id="exclude_media"/> + <label class="admin__field-label" for="exclude_media"><?php /* @escapeNotVerified */ echo __('Exclude media folder from backup') ?></label> + </div> </div> </div> </fieldset> </form> - - <div class="actions"> - <button type="button" class="action primary" data-mage-init='{"button":{"event":"submit","target":"#backup-form"}}'><?php /* @escapeNotVerified */ echo __('OK')?></button> - <button type="button" class="action cancel" onclick="backup.hidePopups()"><?php /* @escapeNotVerified */ echo __('Cancel')?></button> - </div> </div> </div> </div> @@ -158,11 +161,6 @@ </fieldset> </div> </form> - - <div class="actions"> - <button type="button" class="action primary" data-mage-init='{"button":{"event":"submit","target":"#rollback-form"}}'><?php /* @escapeNotVerified */ echo __('OK')?></button> - <button type="button" class="action cancel" onclick="backup.hidePopups()"><?php /* @escapeNotVerified */ echo __('Cancel')?></button> - </div> </div> </div> </div> diff --git a/app/code/Magento/Braintree/etc/frontend/di.xml b/app/code/Magento/Braintree/etc/frontend/di.xml index ddc18722e8df532bf34fb3e30b4122e24e4e8445..83dc6607ed3160f5719646521ffcb74b8a822c34 100644 --- a/app/code/Magento/Braintree/etc/frontend/di.xml +++ b/app/code/Magento/Braintree/etc/frontend/di.xml @@ -21,4 +21,11 @@ </argument> </arguments> </type> + <type name="Magento\Framework\Url\SecurityInfo"> + <arguments> + <argument name="secureUrlList" xsi:type="array"> + <item name="braintree" xsi:type="string">/braintree/</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Braintree/view/adminhtml/templates/data_js.phtml b/app/code/Magento/Braintree/view/adminhtml/templates/data_js.phtml index cbfe3dcda5f9f52c183a7382e9cf4c33d5a50811..70634e81b0992114ed262c1781c46dd5c4f1fb07 100644 --- a/app/code/Magento/Braintree/view/adminhtml/templates/data_js.phtml +++ b/app/code/Magento/Braintree/view/adminhtml/templates/data_js.phtml @@ -7,21 +7,20 @@ /** * @var $block \Magento\Braintree\Block\Datajs */ -?> -<?php + $arrayData = [ "kountId" => $this->helper('Magento\Braintree\Helper\Data')->getKountId() ? $this->helper('Magento\Braintree\Helper\Data')->getKountId() : false, "formId" =>$block->getFormId(), "merchantId" => $block->getMerchantId(), - "braintreeDataJs" => $block->getJsSrc(), + "braintreeDataJs" => $block->escapeUrl($block->getJsSrc()), ]; $serializedFormData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($arrayData); ?> <script type="text/x-magento-init"> { "body": { - "braintreeDataJs": <?php /* @escapeNotVerified */ echo $serializedFormData ?> + "braintreeDataJs": <?php /* @noEscape */ echo $serializedFormData ?> } } </script> diff --git a/app/code/Magento/Braintree/view/adminhtml/templates/form.phtml b/app/code/Magento/Braintree/view/adminhtml/templates/form.phtml index f13f2d77b1c086e288bf87d21556e231f379c0b8..c27901cd4e8704fc7fdf044e47b8cc40db1a7e40 100644 --- a/app/code/Magento/Braintree/view/adminhtml/templates/form.phtml +++ b/app/code/Magento/Braintree/view/adminhtml/templates/form.phtml @@ -7,110 +7,143 @@ // @codingStandardsIgnoreFile /** @var \Magento\Braintree\Block\Form $block */ -$_form = $block; -$_code = $_form->getMethodCode(); -$_storedCards = $this->helper('\Magento\Braintree\Helper\Createorder')->getLoggedInCustomerCards(); -$_useVault = $block->useVault(); -$_useCvv = $block->useCvv(); -$clientToken = $block->getClientToken(); +$code = $block->getMethodCode(); +$storedCards = $this->helper('\Magento\Braintree\Helper\Createorder')->getLoggedInCustomerCards(); +$useVault = $block->useVault(); +$useCvv = $block->useCvv(); +$clientToken = $block->escapeHtml($block->getClientToken()); $isFraudDetectionEnabled = $block->isFraudDetectionEnabled(); $braintreeDataJs = $block->getBraintreeDataJs(); $formData = [ - "useVault" => $_useVault, - "useCvv" => $_useCvv, + "useVault" => $useVault, + "useCvv" => $useCvv, "clientToken" => $clientToken, - "code" => $_code, + "code" => $code, "isFraudDetectionEnabled" => $isFraudDetectionEnabled, "braintreeDataJs"=> $braintreeDataJs, ]; $serializedFormData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($formData); +$ccType = $block->getInfoData('cc_type'); +$ccExpMonth = $block->getInfoData('cc_exp_month'); +$ccExpYear = $block->getInfoData('cc_exp_year'); ?> -<input id="<?php /* @escapeNotVerified */ echo $_code ?>_payment_method" type="hidden" name="payment[method]" value="<?php /* @escapeNotVerified */ echo $_code ?>" /> -<div id="payment_form_<?php /* @escapeNotVerified */ echo $_code ?>" class="admin__page-section-item" style="display:none;" - data-mage-init='{"braintreeCcForm":<?php /* @escapeNotVerified */ echo $serializedFormData ?>}' +<input id="<?php /* @noEscape */ echo $code; ?>_payment_method" type="hidden" name="payment[method]" + value="<?php /* @noEscape */ echo $code; ?>" /> +<div id="payment_form_<?php /* @noEscape */ echo $code; ?>" class="admin__page-section-item" style="display:none;" + data-mage-init='{"braintreeCcForm":<?php /* @noEscape */ echo $serializedFormData; ?>}' > <input type="hidden" name="payment[payment_method_nonce]" id="braintree_nonce" value="" /> <input type="hidden" name="payment[cc_last4]" id="cc_last4" value="" /> <?php if ($isFraudDetectionEnabled): ?> - <input type="hidden" name="payment[device_data]" id="braintree_device_id" value="" /> + <input type="hidden" name="payment[device_data]" id="braintree_device_id" value="" /> <?php endif; ?> - <?php if ($_storedCards): ?> - <fieldset class="admin__fieldset"> - <div class="admin__field" id="<?php /* @escapeNotVerified */ echo $_code ?>_token_selector"> - <label class="admin__field-label" for="<?php /* @escapeNotVerified */ echo $_code ?>_cc_token"><?php /* @escapeNotVerified */ echo __('Payment Information') ?></label> - <div class="admin__field-control control"> - <select id="<?php /* @escapeNotVerified */ echo $_code ?>_cc_token" name="payment[cc_token]" class="select admin__control-select"> - <?php foreach ($_storedCards as $creditCard): ?> - <option value="<?php /* @escapeNotVerified */ echo $creditCard->token?>" <?php echo $creditCard->default ? 'selected="selected"' : '' ?>> - <?php /* @escapeNotVerified */ echo $creditCard->maskedNumber . ' - ' . $creditCard->cardType ?> - </option> - <?php endforeach; ?> - <option value=''><?php /* @escapeNotVerified */ echo __('Add new card') ?></option> - </select> + <?php if ($storedCards): ?> + <fieldset class="admin__fieldset"> + <div class="admin__field" id="<?php /* @noEscape */ echo $code; ?>_token_selector"> + <label class="admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_cc_token"> + <?php echo $block->escapeHtml(__('Payment Information')); ?> + </label> + <div class="admin__field-control control"> + <select id="<?php /* @noEscape */ echo $code; ?>_cc_token" name="payment[cc_token]" + class="select admin__control-select"> + <?php foreach ($storedCards as $creditCard): ?> + <option value="<?php echo $block->escapeHtml($creditCard->token); ?>" + <?php /* @noEscape */ echo $creditCard->default ? ' selected="selected"' : ''; ?>> + <?php echo $block->escapeHtml($creditCard->maskedNumber); ?> - <?php echo $block->escapeHtml($creditCard->cardType); ?> + </option> + <?php endforeach; ?> + <option value=''><?php echo $block->escapeHtml(__('Add new card')); ?></option> + </select> + </div> </div> - </div> - </fieldset> + </fieldset> <?php endif; ?> <fieldset class="admin__fieldset hide_if_token_selected"> <div class="admin__field"> - <label class="label admin__field-label" for="<?php /* @escapeNotVerified */ echo $_code ?>_cc_type" ><?php /* @escapeNotVerified */ echo __('Credit Card Type') ?><span class="required">*</span></label> + <label class="label admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_cc_type" > + <?php echo $block->escapeHtml(__('Credit Card Type')); ?><span class="required">*</span> + </label> <div class="admin__field-control control"> - <select id="<?php /* @escapeNotVerified */ echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry _required select admin__control-select validate-cc-type-select"> - <option value="">--<?php /* @escapeNotVerified */ echo __('Please Select')?>--</option> - <?php $_ccType = $_form->getInfoData('cc_type') ?> - <?php foreach ($_form->getCcAvailableTypes() as $_typeCode => $_typeName): ?> - <option value="<?php /* @escapeNotVerified */ echo $_typeCode ?>"<?php if($_typeCode==$_ccType): ?> selected="selected"<?php endif ?>><?php /* @escapeNotVerified */ echo $_typeName ?></option> - <?php endforeach ?> + <select id="<?php /* @noEscape */ echo $code; ?>_cc_type" name="payment[cc_type]" + class="required-entry _required select admin__control-select validate-cc-type-select"> + <option value="">--<?php echo $block->escapeHtml(__('Please Select')); ?>--</option> + <?php foreach ($block->getCcAvailableTypes() as $typeCode => $typeName): ?> + <option value="<?php echo $block->escapeHtml($typeCode); ?>" + <?php if($typeCode == $ccType): ?> selected="selected"<?php endif; ?>> + <?php echo $block->escapeHtml($typeName); ?> + </option> + <?php endforeach; ?> </select> </div> </div> </fieldset> <fieldset class="admin__fieldset hide_if_token_selected"> <div class="admin__field"> - <label class="label admin__field-label" for="<?php /* @escapeNotVerified */ echo $_code ?>_cc_number"><?php /* @escapeNotVerified */ echo __('Credit Card Number') ?><span class="required">*</span></label> + <label class="label admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_cc_number"> + <?php echo $block->escapeHtml(__('Credit Card Number')); ?><span class="required">*</span> + </label> <div class="admin__field-control control"> - <input type="text" id="<?php /* @escapeNotVerified */ echo $_code ?>_cc_number" data-encrypted-name="payment[cc_number]" title="<?php /* @escapeNotVerified */ echo __('Credit Card Number') ?>" class="input-text admin__control-text validate-cc-number validate-cc-type" value="" /> + <input type="text" id="<?php /* @noEscape */ echo $code; ?>_cc_number" data-encrypted-name="payment[cc_number]" + title="<?php echo $block->escapeHtml(__('Credit Card Number')); ?>" + class="input-text admin__control-text validate-cc-number validate-cc-type" value="" /> </div> </div> </fieldset> <fieldset class="admin__fieldset hide_if_token_selected"> - <div id="<?php /* @escapeNotVerified */ echo $_code ?>_cc_type_exp_div" class="admin__field"> - <label class="label admin__field-label" for="<?php /* @escapeNotVerified */ echo $_code ?>_expiration" ><?php /* @escapeNotVerified */ echo __('Expiration Date') ?><span class="required">*</span></label> + <div id="<?php /* @noEscape */ echo $code; ?>_cc_type_exp_div" class="admin__field"> + <label class="label admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_expiration"> + <?php echo $block->escapeHtml(__('Expiration Date')); ?><span class="required">*</span> + </label> <div class="admin__field-control control"> - <select id="<?php /* @escapeNotVerified */ echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry _required select admin__control-select"> - <?php $_ccExpMonth = $_form->getInfoData('cc_exp_month') ?> - <?php foreach ($_form->getCcMonths() as $k=>$v): ?> - <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php /* @escapeNotVerified */ echo $v ?></option> - <?php endforeach ?> + <select id="<?php /* @noEscape */ echo $code; ?>_expiration" name="payment[cc_exp_month]" + class="month validate-cc-exp required-entry _required select admin__control-select"> + <?php foreach ($block->getCcMonths() as $k=>$v): ?> + <option value="<?php /* @noEscape */ echo $k ? $block->escapeHtml($k) : ''; ?>" + <?php if ($k == $ccExpMonth): ?> selected="selected"<?php endif; ?>> + <?php echo $block->escapeHtml($v); ?></option> + <?php endforeach; ?> </select> - <?php $_ccExpYear = $_form->getInfoData('cc_exp_year') ?> - <select id="<?php /* @escapeNotVerified */ echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry _required select admin__control-select"> - <?php foreach ($_form->getCcYears() as $k=>$v): ?> - <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php /* @escapeNotVerified */ echo $v ?></option> + <select id="<?php /* @noEscape */ echo $code; ?>_expiration_yr" name="payment[cc_exp_year]" + class="year required-entry _required select admin__control-select"> + <?php foreach ($block->getCcYears() as $k => $v): ?> + <option value="<?php /* @noEscape */ echo $k ? $block->escapeHtml($k) : ''; ?>" + <?php if ($k == $ccExpYear): ?> selected="selected"<?php endif; ?>> + <?php echo $block->escapeHtml($v); ?> + </option> <?php endforeach ?> </select> </div> </div> </fieldset> - <?php echo $_form->getChildHtml() ?> - <?php if($_form->hasVerification()): ?> - <fieldset class="admin__fieldset hide_if_token_selected"> - <div id="<?php /* @escapeNotVerified */ echo $_code ?>_cc_type_cvv_div" class="admin__field"> - <label class="label admin__field-label" for="<?php /* @escapeNotVerified */ echo $_code ?>_cc_cid" ><?php /* @escapeNotVerified */ echo __('Card Verification Number') ?><span class="required">*</span></label> - <div class="admin__field-control control"> - <div class="v-fix"> - <input type="text" title="<?php /* @escapeNotVerified */ echo __('Card Verification Number') ?>" class="input-text admin__control-text cvv required-entry validate-cc-cvn" id="<?php /* @escapeNotVerified */ echo $_code ?>_cc_cid" data-encrypted-name="payment[cc_cid]" value="" /> + <?php echo $block->getChildHtml(); ?> + <?php if ($block->hasVerification()): ?> + <fieldset class="admin__fieldset hide_if_token_selected"> + <div id="<?php /* @noEscape */ echo $code; ?>_cc_type_cvv_div" class="admin__field"> + <label class="label admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_cc_cid"> + <?php echo $block->escapeHtml(__('Card Verification Number')); ?><span class="required">*</span> + </label> + + <div class="admin__field-control control"> + <div class="v-fix"> + <input type="text" title="<?php echo $block->escapeHtml(__('Card Verification Number')); ?>" + class="input-text admin__control-text cvv required-entry validate-cc-cvn" + id="<?php /* @noEscape */ echo $code; ?>_cc_cid" data-encrypted-name="payment[cc_cid]" value=""/> + </div> </div> </div> - </div> - </fieldset> + </fieldset> <?php endif; ?> <?php if($_useVault): ?> - <fieldset class="admin__fieldset hide_if_token_selected"> - <div id="<?php /* @escapeNotVerified */ echo $_code ?>_store_in_vault_div" style="text-align:left;" class=""> - <input type="checkbox" title="<?php /* @escapeNotVerified */ echo __('Save this card for future use') ?>" class="input-checkbox" id="<?php /* @escapeNotVerified */ echo $_code ?>_store_in_vault" name="payment[store_in_vault]" value="1" /> - <label for="<?php /* @escapeNotVerified */ echo $_code ?>_store_in_vault" style="float:none;"><?php /* @escapeNotVerified */ echo __('Save this card for future use') ?></label> - </div> - </fieldset> + <fieldset class="admin__fieldset hide_if_token_selected"> + <div id="<?php /* @noEscape */ echo $code; ?>_store_in_vault_div" style="text-align:left;" class=""> + <input type="checkbox" title="<?php echo $block->escapeHtml(__('Save this card for future use')); ?>" + class="input-checkbox" id="<?php /* @noEscape */ echo $code; ?>_store_in_vault" + name="payment[store_in_vault]" value="1"/> + <label for="<?php /* @noEscape */ echo $code; ?>_store_in_vault" style="float:none;"> + <?php echo $block->escapeHtml(__('Save this card for future use')); ?> + + </label> + </div> + </fieldset> <?php endif; ?> </div> \ No newline at end of file diff --git a/app/code/Magento/Braintree/view/frontend/templates/creditcard/delete.phtml b/app/code/Magento/Braintree/view/frontend/templates/creditcard/delete.phtml index b9011bdd4f54e009622789aa2992d42cd89f1fe9..cba8e56e5aa3366172f42663999757bfce6b5448 100644 --- a/app/code/Magento/Braintree/view/frontend/templates/creditcard/delete.phtml +++ b/app/code/Magento/Braintree/view/frontend/templates/creditcard/delete.phtml @@ -6,46 +6,54 @@ // @codingStandardsIgnoreFile - $creditCard = $block->creditCard(); - $token = $creditCard->token; +/** + * @var \Magento\Braintree\Block\Creditcard\Management $block + */ +$creditCard = $block->creditCard(); +$token = $block->escapeHtml($creditCard->token); ?> <?php echo $block->getLayout()->getMessagesBlock()->getGroupedHtml();?> -<form action="<?php /* @escapeNotVerified */ echo $block->getDeleteConfirmUrl() ?>" method="post" id="delete-form" +<form action="<?php echo $block->escapeUrl($block->getDeleteConfirmUrl()); ?>" method="post" id="delete-form" xmlns="http://www.w3.org/1999/html"> <fieldset class="fieldset info"> - <legend class="legend"><?php /* @escapeNotVerified */ echo __('Please confirm that you want to delete this credit card') ?></legend> + <legend class="legend"> + <?php echo $block->escapeHtml(__('Please confirm that you want to delete this credit card')); ?> + </legend> <div class="field"> <ul> <li> - <b><?php /* @escapeNotVerified */ echo __('Credit Card Number');?></b> + <b><?php echo $block->escapeHtml(__('Credit Card Number'));?></b> </li> <li> - <?php /* @escapeNotVerified */ echo $creditCard->maskedNumber;?> + <?php echo $block->escapeHtml($creditCard->maskedNumber);?> </li> <li> - <b><?php /* @escapeNotVerified */ echo __('Expiration Date');?></b> + <b><?php echo $block->escapeHtml(__('Expiration Date'));?></b> </li> <li> - <?php /* @escapeNotVerified */ echo $creditCard->expirationDate; ?> + <?php echo $block->escapeHtml($creditCard->expirationDate); ?> </li> <li> - <b><?php /* @escapeNotVerified */ echo __('Cardholder Name');?></b> + <b><?php echo $block->escapeHtml(__('Cardholder Name'));?></b> </li> <li> - <?php /* @escapeNotVerified */ echo $creditCard->cardholderName;?> + <?php echo $block->escapeHtml($creditCard->cardholderName);?> </li> </ul> </div> </fieldset> - <input type="hidden" name="token" value="<?php /* @escapeNotVerified */ echo $token ?>"> + <input type="hidden" name="token" value="<?php /* @noEscape */ echo $token; ?>"> <div class="actions-toolbar"> <div class="primary"> <button type="submit" id="opc-submit" data-role="opc-submit" class="action save primary" - title="<?php /* @escapeNotVerified */ echo __('Delete') ?>" ><?php /* @escapeNotVerified */ echo __('Delete') ?></span></button> + title="<?php echo $block->escapeHtml(__('Delete')); ?>" > + <?php echo $block->escapeHtml(__('Delete')); ?> + </button> </div> <div class="secondary"> - <a class="action back" href="<?php /* @escapeNotVerified */ echo $block->getBackUrl() ?>"><span><span><small>« </small> - <?php /* @escapeNotVerified */ echo __('Back') ?></span></a> + <a class="action back" href="<?php echo $block->escapeUrl($block->getBackUrl()); ?>"> + <span><small>« </small><?php echo $block->escapeHtml(__('Back')); ?></span> + </a> </div> </div> diff --git a/app/code/Magento/Braintree/view/frontend/templates/creditcard/edit.phtml b/app/code/Magento/Braintree/view/frontend/templates/creditcard/edit.phtml index 073009c4c6eb6de718c3d85c41270ebedfedfa85..6fcac2eae9c411929472c7b79ef1038836646183 100644 --- a/app/code/Magento/Braintree/view/frontend/templates/creditcard/edit.phtml +++ b/app/code/Magento/Braintree/view/frontend/templates/creditcard/edit.phtml @@ -53,21 +53,37 @@ if ($block->isEditMode()) { $defaultPostalCode = ''; $defaultCountryCodeAlpha2 = ''; } +$streetValidationClass = $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('street'); +$default = $defaultCountryCodeAlpha2; + +$clientToken = $block->getClientToken(); +$formData = [ + "clientToken" => $clientToken, + 'ajaxSaveUrl' => $block->escapeUrl($block->getAjaxSaveUrl()), + 'isEditMode' => $block->isEditMode() ? true : false, + 'cardToken' => $block->isEditMode() ? $block->escapeHtml($creditCard->token) : '', + 'backUrl' => $block->escapeUrl($block->getBackUrl()), + 'hasVerification' => $block->hasVerification(), + "countrySpecificCardTypes" => $countrySpecificCardTypeConfig, + "applicableCardTypes" => $applicableCardTypeConfig, + "cardTypes" => $block->getCcAvailableTypes(), + "isFraudDetectionEnabled" => $block->isFraudDetectionEnabled() +]; +$serializedFormData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($formData); ?> <form - class="form form-edit-credit-card" - action='<?php /* @escapeNotVerified */ echo $block->getFormAction() ?>' + class="form form-edit-credit-card" action="<?php echo $block->escapeUrl($block->getFormAction()); ?>" method="post" id="form-validate" data-mage-init='{"validation":{}}'> <?php echo $block->getBlockHtml('formkey'); ?> - <fieldset class="fieldset info" data-hasrequired="<?php /* @escapeNotVerified */ echo __('* Required Fields') ?>"> + <fieldset class="fieldset info" data-hasrequired="<?php echo $block->escapeHtml(__('* Required Fields')); ?>"> <legend class="legend"> - <span><?php /* @escapeNotVerified */ echo __('Credit Card') ?></span> + <span><?php echo $block->escapeHtml(__('Credit Card')); ?></span> </legend> <br> <div class="field name required"> <label for="credit_card_cardholder_name" class="label"> - <span><?php /* @escapeNotVerified */ echo __('Cardholder Name') ?></span> + <span><?php echo $block->escapeHtml(__('Cardholder Name')); ?></span> </label> <div class="control"> @@ -75,40 +91,32 @@ if ($block->isEditMode()) { type="text" class="input-text required-entry" id="credit_card_cardholder_name" - value="<?php /* @escapeNotVerified */ echo $defaultCardholder ?>" + value="<?php echo $block->escapeHtml($defaultCardholder); ?>" data-validate="{required:true}"> </div> </div> <div class="field required type"> <label for="credit_card_type" class="label"> - <span><?php /* @escapeNotVerified */ echo __('Credit Card Type') ?></span> + <span><?php echo $block->escapeHtml(__('Credit Card Type')); ?></span> </label> <div class="control"> <select name="credit_card_type" id="credit_card_type" data-container="credit_card_type" data-validate='{required:true, "validate-cc-type-select":"#credit_card_number"}'> - <option value=""><?php /* @escapeNotVerified */ echo __('--Please Select--') ?></option> - <?php - foreach ($block->getCcAvailableTypes() as $_typeCode => $_typeName) : - ?> - <option value="<?php /* @escapeNotVerified */ echo $_typeCode ?>" - <?php - if (stripos($_typeName, $defaultCcType) !== false) : - ?> selected="selected" - <?php - endif; - ?>> - <?php /* @escapeNotVerified */ echo $_typeName ?> + <option value=""><?php echo $block->escapeHtml(__('--Please Select--')); ?></option> + <?php foreach ($block->getCcAvailableTypes() as $typeCode => $typeName): ?> + <option value="<?php echo $block->escapeHtml($typeCode); ?>" + <?php if (stripos($typeName, $defaultCcType) !== false): ?> selected="selected"<?php endif; ?>> + <?php echo $block->escapeHtml($typeName); ?> </option> - <?php - endforeach; + <?php endforeach; ?> </select> </div> </div> <div class="field name required"> - <label for="credit_card_number" class="label"><span> - <?php /* @escapeNotVerified */ echo __('Credit Card Number') ?></span> + <label for="credit_card_number" class="label"> + <span><?php echo $block->escapeHtml(__('Credit Card Number')); ?></span> </label> <div class="control"> @@ -118,19 +126,13 @@ if ($block->isEditMode()) { class="input-text required-entry validate-cc-number" id="credit_card_number" autocomplete="off" - <?php - if ($block->isEditMode()) : - ?> - placeholder="<?php /* @escapeNotVerified */ echo $maskedNumber ?>" - <?php - endif; - ?> + <?php if ($block->isEditMode()): ?> placeholder="<?php echo $block->escapeHtml($maskedNumber); ?>"<?php endif; ?> data-validate="{'required-number':true, 'validate-cc-number':'#credit_card_number', 'validate-cc-type':'#credit_card_type'}"> </div> </div> <div class="field sp-methods required"> <label for="credit_card_expiration_date" class="label"> - <span><?php /* @escapeNotVerified */ echo __('Expiration Date') ?></span> + <span><?php echo $block->escapeHtml(__('Expiration Date')); ?></span> </label> <div class="control"> @@ -143,14 +145,12 @@ if ($block->isEditMode()) { id="credit_card_expiration" class="month validate-cc-exp required-entry" data-validate="{'required-number':true, 'validate-cc-exp':'#credit_card_expiration_yr'}"> - <?php - foreach ($block->getCcMonths() as $k => $v) : - ?> - <option - value="<?php echo $k ? $k : '' ?>"<?php if ($k == $defaultExpMonth) : ?> selected="selected"<?php endif ?>><?php /* @escapeNotVerified */ echo $v ?></option> - <?php - endforeach; - ?> + <?php foreach ($block->getCcMonths() as $k => $v): ?> + <option value="<?php /* @noEscape */ echo $k ? $block->escapeHtml($k) : '' ?>" + <?php if ($k == $defaultExpMonth): ?> selected="selected"<?php endif; ?>> + <?php echo $block->escapeHtml($v); ?> + </option> + <?php endforeach; ?> </select> </div> </div> @@ -163,22 +163,12 @@ if ($block->isEditMode()) { id="credit_card_expiration_yr" class="year required-entry" data-validate="{required:true}"> - <?php - foreach ($block->getCcYears() as $k => $v) : - ?> - <option - value="<?php echo $k ? $k : ''; ?>" - <?php - if ($k == $defaultExpYear) : - ?> selected="selected" - <?php - endif; - ?>> - <?php /* @escapeNotVerified */ echo $v ?> + <?php foreach ($block->getCcYears() as $k => $v): ?> + <option value="<?php /* @noEscape */ echo $k ? $k : ''; ?>" + <?php if ($k == $defaultExpYear): ?> selected="selected"<?php endif; ?>> + <?php echo $block->escapeHtml($v); ?> </option> - <?php - endforeach; - ?> + <?php endforeach; ?> </select> </div> </div> @@ -189,13 +179,13 @@ if ($block->isEditMode()) { <?php if ($block->hasVerification()): ?> <div class="field sp-methods required"> <label for="credit_card_cvv" class="label"> - <span><?php /* @escapeNotVerified */ echo __('CVV') ?></span> + <span><?php echo $block->escapeHtml(__('CVV')); ?></span> </label> <div class="control"> <input type="text" - title="<?php /* @escapeNotVerified */ echo __('Card Verification Number') ?>" + title="<?php echo $block->escapeHtml(__('Card Verification Number')); ?>" class="input-text cvv required-entry validate-cc-cvn validate-cc-cvn-autodetect" name="credit_card_cvv" data-container="credit_card_cvv" @@ -203,14 +193,14 @@ if ($block->isEditMode()) { value="" autocomplete="off" data-validate="{'required-number':true, 'validate-cc-cvn':'#credit_card_type'}"> - <?php $_content = '<img src=\"' . $block->getViewFileUrl('Magento_Checkout::cvv.png') . - '\" alt=\"' . __('Card Verification Number Visual Reference') . '\" title=\"' . - __('Card Verification Number Visual Reference') . '\" />'; ?> + <?php $content = '<img src=\"' . $block->escapeUrl($block->getViewFileUrl('Magento_Checkout::cvv.png')) . + '\" alt=\"' . $block->escapeHtml(__('Card Verification Number Visual Reference')) . '\" title=\"' . + $block->escapeHtml(__('Card Verification Number Visual Reference')) . '\" />'; ?> <div class="note"> <a href="#" id="credit_card-cvv-what-is-this" class="action cvv" title="<?php echo $block->escapeHtml(__('What is this?')); ?>" - data-mage-init='{"tooltip": {"content": "<?php /* @escapeNotVerified */ echo $_content ?>"}}'> - <span><?php /* @escapeNotVerified */ echo __('What is this?') ?></span> + data-mage-init='{"tooltip": {"content": "<?php /* @noEscape */ echo $content; ?>"}}'> + <span><?php echo $block->escapeHtml(__('What is this?')); ?></span> </a> </div> </div> @@ -224,58 +214,61 @@ if ($block->isEditMode()) { <div class="control"> <input type="checkbox" name="credit_card[options][make_default]" id="credit_card_options_make_default" - value="1" <?php /* @escapeNotVerified */ echo $isCCDefault ? "checked" : "" ?>> + value="1" <?php /* @noEscape */ echo $isCCDefault ? "checked" : "" ?>> <label for="credit_card_options_make_default" class="label"> - <span><?php /* @escapeNotVerified */ echo __('Make Default') ?></span> + <span><?php echo $block->escapeHtml(__('Make Default')); ?></span> </label> </div> </div> </fieldset> <fieldset class="fieldset info"> <legend class="legend"> - <span><?php /* @escapeNotVerified */ echo __('Billing Address') ?></span> + <span><?php echo $block->escapeHtml(__('Billing Address')); ?></span> </legend> <div class="field name billing_address_first_name required"> <label for="billing_address_first_name" class="label"> - <span><?php /* @escapeNotVerified */ echo __('First Name') ?></span> + <span><?php echo $block->escapeHtml(__('First Name')); ?></span> </label> <div class="control"> <input type="text" class="input-text required-entry " name="credit_card[billing_address][first_name]" id="billing_address_first_name" - value="<?php /* @escapeNotVerified */ echo $defaultFirstName ?>" + value="<?php echo $block->escapeHtml($defaultFirstName); ?>" data-validate="{required:true}"> </div> </div> <div class="field name billing_address_last_name required"> - <label for="billing_address_last_name" class="label"><span><?php /* @escapeNotVerified */ echo __('Last Name') ?></span></label> + <label for="billing_address_last_name" class="label"> + <span><?php echo $block->escapeHtml(__('Last Name')); ?></span> + </label> <div class="control"> <input type="text" class="input-text required-entry " name="credit_card[billing_address][last_name]" id="billing_address_last_name" - value="<?php /* @escapeNotVerified */ echo $defaultLastName ?>" + value="<?php echo $block->escapeHtml($defaultLastName); ?>" data-validate="{required:true}"> </div> </div> <div class="field name billing_address_company"> - <label for="billing_address_company" class="label"><span><?php /* @escapeNotVerified */ echo __('Company') ?></span></label> + <label for="billing_address_company" class="label"> + <span><?php echo $block->escapeHtml(__('Company')); ?></span> + </label> <div class="control"> <input type="text" class="input-text " name="credit_card[billing_address][company]" id="billing_address_company" - value="<?php /* @escapeNotVerified */ echo $defaultCompany ?>"> + value="<?php echo $block->escapeHtml($defaultCompany); ?>"> </div> </div> - <?php $_streetValidationClass = $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('street'); ?> <div class="field name billing_address_street_address required"> <label for="billing_address_street_address" class="label"> - <span><?php /* @escapeNotVerified */ echo __('Address') ?></span> + <span><?php echo $block->escapeHtml(__('Address')); ?></span> </label> <div class="control"> <input type="text" class="input-text required-entry " name="credit_card[billing_address][street_address]" id="billing_address_street_address" - value="<?php /* @escapeNotVerified */ echo $defaultStreetAddress ?>" + value="<?php echo $block->escapeHtml($defaultStreetAddress); ?>" data-validate="{required:true}"> </div> </div> @@ -287,95 +280,78 @@ if ($block->isEditMode()) { <div class="control"> <input type="text" class="input-text " name="credit_card[billing_address][extended_address]" id="billing_address_extended_address" - value="<?php /* @escapeNotVerified */ echo $defaultExtendedAddress ?>"> + value="<?php echo $block->escapeHtml($defaultExtendedAddress); ?>"> </div> </div> <div class="field name billing_address_locality required"> <label for="billing_address_locality" class="label"> - <span><?php /* @escapeNotVerified */ echo __('City') ?></span> + <span><?php echo $block->escapeHtml(__('City')); ?></span> </label> <div class="control"> <input type="text" class="input-text required-entry " name="credit_card[billing_address][locality]" id="billing_address_locality" - value="<?php /* @escapeNotVerified */ echo $defaultLocality ?>" + value="<?php echo $block->escapeHtml($defaultLocality); ?>" data-validate="{required:true}"> </div> </div> <div class="field region billing_address_region required"> <label for="billing_address_region" class="label"> - <span><?php /* @escapeNotVerified */ echo __('State/Province') ?></span> + <span><?php echo $block->escapeHtml(__('State/Province')); ?></span> </label> <div class="control"> <select id="billing_address_region_id" name="credit_card[billing_address][region_id]" - title="<?php /* @escapeNotVerified */ echo __('State/Province') ?>" class="validate-select" style="display:none;" + title="<?php echo $block->escapeHtml(__('State/Province')); ?>" class="validate-select" style="display:none;" data-validate="{'validate-select':true}"> - <option value=""><?php /* @escapeNotVerified */ echo __('Please select region, state or province') ?></option> + <option value=""><?php echo $block->escapeHtml(__('Please select region, state or province')); ?></option> </select> <input type="text" class="input-text " name="credit_card[billing_address][region]" id="billing_address_region" - value="<?php /* @escapeNotVerified */ echo $block->getPostParam('customer.creditCard.billingAddress.region', $defaultRegion) ?>"> + value="<?php echo $block->escapeHtml($block->getPostParam('customer.creditCard.billingAddress.region', $defaultRegion)); ?>"> </div> </div> <div class="field zip billing_address_postal_code required"> <label for="billing_address_postal_code" class="label"> - <span><?php /* @escapeNotVerified */ echo __('Zip/Postal Code') ?></span> + <span><?php echo $block->escapeHtml(__('Zip/Postal Code')); ?></span> </label> <div class="control"> <input type="text" class="input-text required-entry validate-zip-international " name="credit_card[billing_address][postal_code]" id="billing_address_postal_code" - value="<?php /* @escapeNotVerified */ echo $defaultPostalCode ?>" + value="<?php echo $block->escapeHtml($defaultPostalCode); ?>" data-validate="{required:true, 'validate-zip-international':true}"> </div> </div> <div class="field name billing_address_country required"> <label for="billing_address_country" class="label"> - <span><?php /* @escapeNotVerified */ echo __('Country') ?></span> + <span><?php echo $block->escapeHtml(__('Country')); ?></span> </label> <div class="control"> - <?php $default = $defaultCountryCodeAlpha2 ?> - <?php /* @escapeNotVerified */ echo $block->countrySelect('credit_card' . '[billing_address][country_code_alpha2]', 'billing_address_country', $default) ?> + <?php echo $block->escapeHtml($block->countrySelect('credit_card[billing_address][country_code_alpha2]', 'billing_address_country', $default)); ?> </div> </div> </fieldset> <div class="actions-toolbar"> <div class="primary"> <button type="submit" id="opc-submit" data-role="opc-submit" class="action save primary" - title="<?php /* @escapeNotVerified */ echo __('Submit') ?>"> - <span><?php /* @escapeNotVerified */ echo __('Submit') ?></span> + title="<?php echo $block->escapeHtml(__('Submit')); ?>"> + <span><?php echo $block->escapeHtml(__('Submit')); ?></span> </button> </div> <div class="secondary"> - <a class="action back" href="<?php /* @escapeNotVerified */ echo $block->getBackUrl() ?>"> - <span><span><small>« </small><?php /* @escapeNotVerified */ echo __('Back') ?></span> + <a class="action back" href="<?php echo $block->escapeUrl($block->getBackUrl()); ?>"> + <span><span><small>« </small><?php echo $block->escapeUrl(__('Back')); ?></span> </a> </div> </div> </form> -<?php -$clientToken = $block->getClientToken(); -$formData = [ - "clientToken" => $clientToken, - 'ajaxSaveUrl' => $block->getAjaxSaveUrl(), - 'isEditMode' => $block->isEditMode() ? true : false, - 'cardToken' => $block->isEditMode() ? $creditCard->token : '', - 'backUrl' => $block->getBackUrl(), - 'hasVerification' => $block->hasVerification(), - "countrySpecificCardTypes" => $countrySpecificCardTypeConfig, - "applicableCardTypes" => $applicableCardTypeConfig, - "cardTypes" => $block->getCcAvailableTypes(), - "isFraudDetectionEnabled" => $block->isFraudDetectionEnabled() -]; -$serializedFormData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($formData); -?> <script type="text/x-magento-init"> { "#form-validate": { "validation": {}, - "braintreeEditForm": <?php /* @escapeNotVerified */ echo $serializedFormData ?> + "braintreeEditForm": <?php /* @noEscape */ echo $serializedFormData; ?> }, "#billing_address_country": { "regionUpdater": { @@ -384,13 +360,11 @@ $serializedFormData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonE "regionInputId": "#billing_address_region", "postcodeId": "#billing_address_region", "form": "#form-validate", - "regionJson": <?php /* @escapeNotVerified */ echo $this->helper('Magento\Directory\Helper\Data')->getRegionJson() ?>, - "defaultRegion": "<?php /* @escapeNotVerified */ echo $defaultRegionId ?>", + "regionJson": <?php /* @noEscape */ echo $this->helper('Magento\Directory\Helper\Data')->getRegionJson(); ?>, + "defaultRegion": "<?php echo $block->escapeHtml($defaultRegionId); ?>", "countriesWithOptionalZip": - <?php /* @escapeNotVerified */ echo $this->helper('Magento\Directory\Helper\Data')->getCountriesWithOptionalZip(true) ?> + <?php /* @noEscape */ echo $this->helper('Magento\Directory\Helper\Data')->getCountriesWithOptionalZip(true); ?> } } } - - </script> \ No newline at end of file diff --git a/app/code/Magento/Braintree/view/frontend/templates/creditcard/index.phtml b/app/code/Magento/Braintree/view/frontend/templates/creditcard/index.phtml index f4cef98141bd9a4f549dff973874bd8a63a706a3..fd9ee17028bb6eae399fe70103f3f8e82933681f 100644 --- a/app/code/Magento/Braintree/view/frontend/templates/creditcard/index.phtml +++ b/app/code/Magento/Braintree/view/frontend/templates/creditcard/index.phtml @@ -7,14 +7,18 @@ // @codingStandardsIgnoreFile /** @var $block \Magento\Braintree\Block\Creditcard\Management */ - $_storedCards = $block->getCurrentCustomerStoredCards(); +$storedCards = $block->getCurrentCustomerStoredCards(); ?> <div class="page-title title-buttons"> <?php if ($block->getUsesVault()): ?> - <button type="button" title="<?php /* @escapeNotVerified */ echo __('Add Credit Card') ?>" class="action subscribe primary" onclick="window.location='<?php /* @escapeNotVerified */ echo $block->getAddUrl() ?>';"><span><span><?php /* @escapeNotVerified */ echo __('Add Credit Card') ?></span></span></button> - <?php endif ?> + <button type="button" title="<?php echo $block->escapeHtml(__('Add Credit Card')); ?>" + class="action subscribe primary" + onclick="window.location='<?php echo $block->escapeUrl($block->getAddUrl()) ?>';"> + <span><span><?php echo $block->escapeHtml(__('Add Credit Card')); ?></span></span> + </button> + <?php endif; ?> </div> -<?php echo $block->getLayout()->getMessagesBlock()->getGroupedHtml() ?> +<?php echo $block->getLayout()->getMessagesBlock()->getGroupedHtml(); ?> <?php if (count($_storedCards)): ?> <table class="data-table" id="my-quotes-table"> <col width="1" /> @@ -24,23 +28,27 @@ <col width="1" /> <thead> <tr> - <th><?php /* @escapeNotVerified */ echo __('Type') ?></th> - <th><?php /* @escapeNotVerified */ echo __('Card Number') ?></th> - <th><?php /* @escapeNotVerified */ echo __('Is Default') ?></th> - <th colspan="2"><?php /* @escapeNotVerified */ echo __('Actions') ?></th> + <th><?php echo $block->escapeHtml(__('Type')); ?></th> + <th><?php echo $block->escapeHtml(__('Card Number')); ?></th> + <th><?php echo $block->escapeHtml(__('Is Default')); ?></th> + <th colspan="2"><?php echo $block->escapeHtml(__('Actions')); ?></th> </tr> </thead> <tbody> - <?php foreach ($_storedCards as $card):?> + <?php foreach ($storedCards as $card):?> <tr> - <td><?php /* @escapeNotVerified */ echo $card->cardType ?></td> - <td><?php /* @escapeNotVerified */ echo $card->maskedNumber ?></td> - <td><?php /* @escapeNotVerified */ echo ($card->default) ? __('Yes') : __('No') ?></td> + <td><?php echo $block->escapeHtml($card->cardType); ?></td> + <td><?php echo $block->escapeHtml($card->maskedNumber); ?></td> + <td><?php /* @noEscape */ echo ($card->default) ? $block->escapeHtml(__('Yes')) : $block->escapeHtml(__('No')); ?></td> <td> - <a href="<?php /* @escapeNotVerified */ echo $block->getEditUrl($card->token) ?>"><?php /* @escapeNotVerified */ echo __('Edit')?></a> + <a href="<?php echo $block->escapeUrl($block->getEditUrl($card->token)); ?>"> + <?php echo $block->escapeHtml(__('Edit')); ?> + </a> </td> <td> - <a href="<?php /* @escapeNotVerified */ echo $block->getDeleteUrl($card->token) ?>"><?php /* @escapeNotVerified */ echo __('Delete')?></a> + <a href="<?php echo $block->escapeUrl($block->getDeleteUrl($card->token)); ?>"> + <?php echo $block->escapeHtml(__('Delete'));?> + </a> </td> </tr> <?php endforeach; ?> diff --git a/app/code/Magento/Braintree/view/frontend/templates/data_js.phtml b/app/code/Magento/Braintree/view/frontend/templates/data_js.phtml index cbfe3dcda5f9f52c183a7382e9cf4c33d5a50811..14579540152c5ac6e53839cf17dfdd861f564d89 100644 --- a/app/code/Magento/Braintree/view/frontend/templates/data_js.phtml +++ b/app/code/Magento/Braintree/view/frontend/templates/data_js.phtml @@ -14,14 +14,14 @@ $arrayData = [ $this->helper('Magento\Braintree\Helper\Data')->getKountId() : false, "formId" =>$block->getFormId(), "merchantId" => $block->getMerchantId(), - "braintreeDataJs" => $block->getJsSrc(), + "braintreeDataJs" => $block->escapeUrl($block->getJsSrc()), ]; $serializedFormData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($arrayData); ?> <script type="text/x-magento-init"> { "body": { - "braintreeDataJs": <?php /* @escapeNotVerified */ echo $serializedFormData ?> + "braintreeDataJs": <?php /* @noEscape */ echo $serializedFormData; ?> } } </script> diff --git a/app/code/Magento/Braintree/view/frontend/templates/form.phtml b/app/code/Magento/Braintree/view/frontend/templates/form.phtml index f740ad803b188d5c3c7b53b31021d2e2b8f0edde..459a61568cff7fa67f19d3146b1a2f7e0fb5ff5d 100644 --- a/app/code/Magento/Braintree/view/frontend/templates/form.phtml +++ b/app/code/Magento/Braintree/view/frontend/templates/form.phtml @@ -7,75 +7,112 @@ // @codingStandardsIgnoreFile /** @var \Magento\Braintree\Block\Form $block */ -$_code = $block->getMethodCode(); -$_loggedIn = $block->isCustomerLoggedIn(); -$_storedCards = $block->getStoredCards(); -$_useVault = $_loggedIn && $block->useVault() && count($_storedCards); -$_autoDetection = $block->isCcDetectionEnabled(); -$clientToken = $block->getClientToken(); +$code = $block->getMethodCode(); +$loggedIn = $block->isCustomerLoggedIn(); +$storedCards = $block->getStoredCards(); +$useVault = $loggedIn && $block->useVault() && count($storedCards); +$autoDetection = $block->isCcDetectionEnabled(); +$clientToken = $block->escapeHtml($block->getClientToken()); +$formData = [ + "useVault" => $useVault, + "clientToken" => $clientToken, + "autoDetection" => $autoDetection, + "loggedIn" => $loggedIn, +]; +$serializedFormData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($formData); +$ccType = $block->getInfoData('cc_type'); +$ccExpMonth = $block->getInfoData('cc_exp_month'); +$ccExpYear = $block->getInfoData('cc_exp_year'); ?> -<fieldset class="fieldset items braintree" id="payment_form_<?php /* @escapeNotVerified */ echo $_code ?>" style="display:none;"> +<fieldset class="fieldset items braintree" id="payment_form_<?php /* @noEscape */ echo $code; ?>" style="display:none;"> <input type="hidden" name="payment[payment_method_nonce]" id="braintree_nonce" value="" /> - <input type="hidden" name="payment[cc_last4]" id="<?php /* @escapeNotVerified */ echo $_code ?>_cc_last4" value="" /> - <?php if ($_autoDetection) : ?> + <input type="hidden" name="payment[cc_last4]" id="<?php /* @noEscape */ echo $code; ?>_cc_last4" value="" /> + <?php if ($autoDetection) : ?> <input type="hidden" id="card_type_autoselect" value="" /> <?php endif; ?> - <?php if ($_useVault): ?> - <li id="<?php /* @escapeNotVerified */ echo $_code ?>_token_selector"> - <label for="<?php /* @escapeNotVerified */ echo $_code ?>_cc_token"><?php /* @escapeNotVerified */ echo __('Payment Information') ?></label> + <?php if ($useVault): ?> + <li id="<?php /* @noEscape */ echo $code; ?>_token_selector"> + <label for="<?php /* @noEscape */ echo $code; ?>_cc_token"> + <?php echo $block->escapeHtml(__('Payment Information')); ?> + </label> <div class="input-box"> - <select id="<?php /* @escapeNotVerified */ echo $_code ?>_cc_token" name="payment[cc_token]"> - <?php foreach ($_storedCards as $creditCard): ?> - <option value="<?php /* @escapeNotVerified */ echo $creditCard->token?>" <?php echo $creditCard->default ? 'selected="selected"' : '' ?>> - <?php /* @escapeNotVerified */ echo $creditCard->maskedNumber . ' - ' . $creditCard->cardType; ?> + <select id="<?php /* @noEscape */ echo $code; ?>_cc_token" name="payment[cc_token]"> + <?php foreach ($storedCards as $creditCard): ?> + <option value="<?php echo $block->escapeHtml($creditCard->token); ?>" + <?php /* @noEscape */ echo $creditCard->default ? ' selected="selected"' : ''; ?>> + <?php echo $block->escapeHtml($creditCard->maskedNumber); ?> - <?php echo $block->escapeHtml($creditCard->cardType); ?> </option> <?php endforeach; ?> - <option value=''><?php /* @escapeNotVerified */ echo __('Add new card') ?></option> + <option value=''><?php echo $block->escapeHtml(__('Add new card')); ?></option> </select> </div> </li> <?php endif; ?> <div class="field type required hide_if_token_selected"> - <label for="<?php /* @escapeNotVerified */ echo $_code ?>_cc_type" class="label"><span><?php /* @escapeNotVerified */ echo __('Credit Card Type') ?></span></label> + <label for="<?php /* @noEscape */ echo $code; ?>_cc_type" class="label"> + <span><?php echo $block->escapeHtml(__('Credit Card Type')); ?></span> + </label> <div class="control"> - <select id="<?php /* @escapeNotVerified */ echo $_code ?>_cc_type" - data-mage-init='{"creditCardType":{"creditCardTypeContainer":"#<?php /* @escapeNotVerified */ echo $_code ?>_cc_type_ss_div"}}' - name="payment[cc_type]" data-validate='{required:true, "validate-cc-type-select":"#<?php /* @escapeNotVerified */ echo $_code ?>_cc_number"}' class="select"> - <option value=""><?php /* @escapeNotVerified */ echo __('--Please Select--')?></option> - <?php $_ccType = $block->getInfoData('cc_type') ?> - <?php foreach ($block->getCcAvailableTypes() as $_typeCode => $_typeName): ?> - <option value="<?php /* @escapeNotVerified */ echo $_typeCode ?>"<?php if ($_typeCode == $_ccType): ?> selected="selected"<?php endif ?>><?php /* @escapeNotVerified */ echo $_typeName ?></option> + <select id="<?php /* @noEscape */ echo $code; ?>_cc_type" + data-mage-init='{"creditCardType":{"creditCardTypeContainer":"#<?php /* @noEscape */ echo $code; ?>_cc_type_ss_div"}}' + name="payment[cc_type]" data-validate='{ + required:true, + "validate-cc-type-select":"#<?php /* @noEscape */ echo $code; ?>_cc_number" + }' class="select"> + <option value=""><?php echo $block->escapeHtml(__('--Please Select--')); ?></option> + <?php foreach ($block->getCcAvailableTypes() as $typeCode => $typeName): ?> + <option value="<?php echo $block->escapeHtml($typeCode); ?>" + <?php if ($typeCode == $ccType): ?> selected="selected"<?php endif; ?>> + <?php echo $block->escapeHtml($typeName); ?> + </option> <?php endforeach ?> </select> </div> </div> <div class="field number required hide_if_token_selected"> - <label for="<?php /* @escapeNotVerified */ echo $_code ?>_cc_number" class="label"><span><?php /* @escapeNotVerified */ echo __('Credit Card Number') ?></span></label> + <label for="<?php /* @noEscape */ echo $code; ?>_cc_number" class="label"> + <span><?php echo $block->escapeHtml(__('Credit Card Number')); ?></span> + </label> <div class="control"> - <input type="number" id="<?php /* @escapeNotVerified */ echo $_code ?>_cc_number" name="payment[cc_number]" title="<?php /* @escapeNotVerified */ echo __('Credit Card Number') ?>" class="input-text" value="" data-validate='{"required-number":true, "validate-cc-number":"#<?php /* @escapeNotVerified */ echo $_code ?>_cc_type", "validate-cc-type":"#<?php /* @escapeNotVerified */ echo $_code ?>_cc_type"}'/> + <input type="number" id="<?php /* @noEscape */ echo $code; ?>_cc_number" name="payment[cc_number]" + title="<?php echo $block->escapeHtml(__('Credit Card Number')); ?>" class="input-text" value="" + data-validate='{ + "required-number":true, + "validate-cc-number":"#<?php /* @noEscape */ echo $code; ?>_cc_type", + "validate-cc-type":"#<?php /* @noEscape */ echo $code; ?>_cc_type" + }'/> </div> </div> - <div class="field date required hide_if_token_selected" id="<?php /* @escapeNotVerified */ echo $_code ?>_cc_type_exp_div"> - <label for="<?php /* @escapeNotVerified */ echo $_code ?>_expiration" class="label"><span><?php /* @escapeNotVerified */ echo __('Expiration Date') ?></span></label> + <div class="field date required hide_if_token_selected" id="<?php /* @noEscape */ echo $code; ?>_cc_type_exp_div"> + <label for="<?php /* @noEscape */ echo $code; ?>_expiration" class="label"> + <span><?php echo $block->escapeHtml(__('Expiration Date')); ?></span> + </label> <div class="control"> <div class="fields group group-2"> <div class="field no-label month"> <div class="control"> - <select id="<?php /* @escapeNotVerified */ echo $_code ?>_expiration" name="payment[cc_exp_month]" class="select month" data-validate='{required:true, "validate-cc-exp":"#<?php /* @escapeNotVerified */ echo $_code ?>_expiration_yr"}'> - <?php $_ccExpMonth = $block->getInfoData('cc_exp_month') ?> + <select id="<?php /* @noEscape */ echo $code; ?>_expiration" name="payment[cc_exp_month]" + class="select month" data-validate='{ + required:true, "validate-cc-exp":"#<?php /* @noEscape */ echo $code; ?>_expiration_yr" + }'> <?php foreach ($block->getCcMonths() as $k => $v): ?> - <option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpMonth): ?> selected="selected"<?php endif ?>><?php /* @escapeNotVerified */ echo $v ?></option> - <?php endforeach ?> + <option value="<?php echo $k ? $block->escapeHtml($k) : ''; ?>" + <?php if ($k == $ccExpMonth): ?> selected="selected"<?php endif; ?>> + <?php echo $block->escapeHtml($v); ?> + </option> + <?php endforeach; ?> </select> </div> </div> <div class="field no-label year"> <div class="control"> - <?php $_ccExpYear = $block->getInfoData('cc_exp_year') ?> - <select id="<?php /* @escapeNotVerified */ echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="select year" data-validate='{required:true}'> + <select id="<?php /* @noEscape */ echo $code; ?>_expiration_yr" name="payment[cc_exp_year]" class="select year" data-validate='{required:true}'> <?php foreach ($block->getCcYears() as $k => $v): ?> - <option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpYear): ?> selected="selected"<?php endif ?>><?php /* @escapeNotVerified */ echo $v ?></option> - <?php endforeach ?> + <option value="<?php /* @noEscape */ echo $k ? $block->escapeHtml($k) : '' ?>" + <?php if ($k == $ccExpYear): ?> selected="selected"<?php endif; ?>> + <?php echo $block->escapeHtml($v); ?> + </option> + <?php endforeach; ?> </select> </div> </div> @@ -83,39 +120,44 @@ $clientToken = $block->getClientToken(); </div> </div> <?php if ($block->hasVerification()): ?> - <div class="field cvv required hide_if_token_selected" id="<?php /* @escapeNotVerified */ echo $_code ?>_cc_type_cvv_div"> - <label for="<?php /* @escapeNotVerified */ echo $_code ?>_cc_cid" class="label"><span><?php /* @escapeNotVerified */ echo __('Card Verification Number') ?></span></label> + <div class="field cvv required hide_if_token_selected" id="<?php /* @noEscape */ echo $code; ?>_cc_type_cvv_div"> + <label for="<?php /* @noEscape */ echo $code; ?>_cc_cid" class="label"> + <span><?php echo $block->escapeHtml(__('Card Verification Number')); ?></span> + </label> <div class="control"> - <input type="number" title="<?php /* @escapeNotVerified */ echo __('Card Verification Number') ?>" class="input-text cvv" id="<?php /* @escapeNotVerified */ echo $_code ?>_cc_cid" name="payment[cc_cid]" value="" data-validate='{"required-number":true, "validate-cc-cvn":"#<?php /* @escapeNotVerified */ echo $_code ?>_cc_type"}' /> - <?php $_content = '<img src=\"' . $block->getViewFileUrl('Magento_Checkout::cvv.png') . '\" alt=\"' . __('Card Verification Number Visual Reference') . '\" title=\"' . __('Card Verification Number Visual Reference') . '\" />'; ?> + <input type="number" title="<?php echo $block->escapeHtml(__('Card Verification Number')); ?>" + class="input-text cvv" + id="<?php /* @noEscape */ echo $code; ?>_cc_cid" name="payment[cc_cid]" value="" + data-validate='{ + "required-number":true, "validate-cc-cvn":"#<?php /* @noEscape */ echo $code; ?>_cc_type" + }' /> + <?php $content = '<img src=\"' . $block->escapeUrl($block->getViewFileUrl('Magento_Checkout::cvv.png')) . + '\" alt=\"' . $block->escapeHtml(__('Card Verification Number Visual Reference')) . + '\" title=\"' . $block->escapeHtml(__('Card Verification Number Visual Reference')) . '\" />'; ?> <div class="note"> - <a href="#" class="action cvv" title="<?php /* @escapeNotVerified */ echo __('What is this?') ?>" data-mage-init='{"tooltip": {"content": "<?php /* @escapeNotVerified */ echo $_content ?>"}}'><span><?php /* @escapeNotVerified */ echo __('What is this?') ?></span></a> + <a href="#" class="action cvv" title="<?php echo $block->escapeHtml(__('What is this?')); ?>" + data-mage-init='{"tooltip": {"content": "<?php /* @noEscape */ echo $content; ?>"}}'> + <span><?php echo $block->escapeHtml(__('What is this?')); ?></span> + </a> </div> </div> </div> <?php endif; ?> <?php if($block->canSaveCard()): ?> - <li id="<?php /* @escapeNotVerified */ echo $_code ?>_store_in_vault_div" style="text-align:left;" class="hide_if_token_selected"> - <input type="checkbox" title="<?php /* @escapeNotVerified */ echo __('Save this card for future use') ?>" class="input-checkbox" id="<?php /* @escapeNotVerified */ echo $_code ?>_store_in_vault" checked="checked" name="payment[store_in_vault]" value="1" /> - <label for="<?php /* @escapeNotVerified */ echo $_code ?>_store_in_vault" class="required" style="float:none;"><?php /* @escapeNotVerified */ echo __('Save this card for future use') ?></label> + <li id="<?php /* @noEscape */ echo $code; ?>_store_in_vault_div" style="text-align:left;" class="hide_if_token_selected"> + <input type="checkbox" title="<?php echo $block->escapeHtml(__('Save this card for future use')); ?>" class="input-checkbox" + id="<?php /* @noEscape */ echo $code; ?>_store_in_vault" checked="checked" name="payment[store_in_vault]" value="1" /> + <label for="<?php /* @noEscape */ echo $code; ?>_store_in_vault" class="required" style="float:none;"> + <?php echo $block->escapeHtml(__('Save this card for future use')); ?> + </label> </li> <?php endif; ?> </fieldset> - -<?php - $formData = [ - "useVault" => $_useVault, - "clientToken" => $clientToken, - "autoDetection" => $_autoDetection, - "loggedIn" => $_loggedIn, - ]; - $serializedFormData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($formData); -?> <script type="text/x-magento-init"> { "#payment_form_braintree": { - "braintreeForm": <?php /* @escapeNotVerified */ echo $serializedFormData ?> + "braintreeForm": <?php /* @noEscape */ echo $serializedFormData ?> } } </script> diff --git a/app/code/Magento/Braintree/view/frontend/web/js/cc-edit-form.js b/app/code/Magento/Braintree/view/frontend/web/js/cc-edit-form.js index 075a6418ab8ebc81099cbe1ff05f16108a14ff54..3d8e561448c4698cae2a2a044782fac59638a1de 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/cc-edit-form.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/cc-edit-form.js @@ -7,8 +7,9 @@ define([ "jquery", "braintree", 'mage/translate', + 'Magento_Ui/js/modal/alert', "jquery/ui" -], function ($, braintree, $t) { +], function ($, braintree, $t, alert) { 'use strict'; $.widget('mage.braintreeEditForm', { @@ -199,13 +200,17 @@ define([ } }, error: function (response) { - alert($t('There was error during saving card data')); + alert({ + content: $t('There was error during saving card data') + }); } }); } else { //handle error $('body').trigger('processStop'); - alert($t('There was error during saving card data')); + alert({ + content: $t('There was error during saving card data') + }); } }); } diff --git a/app/code/Magento/Braintree/view/frontend/web/js/cc-form.js b/app/code/Magento/Braintree/view/frontend/web/js/cc-form.js index 303ead9b6546b14874f31a50681e0daf706e7e36..a922038eae6c0e2e299fb776587ced1d13ec1afa 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/cc-form.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/cc-form.js @@ -7,8 +7,9 @@ define([ "jquery", "braintree", 'mage/translate', + 'Magento_Ui/js/modal/alert', "jquery/ui" -], function($, braintree, $t) { +], function($, braintree, $t, alert) { "use strict"; $.widget('mage.braintreeForm', { @@ -92,7 +93,9 @@ define([ var form = $(self.options.formSelector)[0]; form.submit(); } else { - alert($t("An error occured with payment processing.")); + alert({ + content: $t("An error occured with payment processing.") + }); } } ); diff --git a/app/code/Magento/Bundle/view/adminhtml/web/js/bundle-product.js b/app/code/Magento/Bundle/view/adminhtml/web/js/bundle-product.js index 4d4c1526c8aa49835fff12ac7b7d91a3bdef22a8..e66c9b35026b03ed3a78cc4cc42a3672ed54a547 100644 --- a/app/code/Magento/Bundle/view/adminhtml/web/js/bundle-product.js +++ b/app/code/Magento/Bundle/view/adminhtml/web/js/bundle-product.js @@ -9,11 +9,12 @@ define([ "jquery", "Magento_Catalog/js/product/weight-handler", + "Magento_Ui/js/modal/modal", "jquery/ui", "mage/translate", "Magento_Theme/js/sortable", "prototype" -], function ($, weightHandler) { +], function($, weightHandler, modal){ 'use strict'; $.widget('mage.bundleProduct', { @@ -81,7 +82,7 @@ define([ var widget = this; this._on({'click .add-selection': function (event) { var $optionBox = $(event.target).closest('.option-box'), - $selectionGrid = $optionBox.find('.selection-search'), + $selectionGrid = $optionBox.find('.selection-search').clone(), optionIndex = $optionBox.attr('id').replace('bundle_option_', ''), productIds = [], productSkus = [], @@ -114,21 +115,21 @@ define([ delete selectedProductList[$(this).val()]; } }); - $selectionGrid.dialog({ + + $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())), - autoOpen: false, - minWidth: 980, - width: '75%', - dialogClass: 'bundle', - modal: true, - resizable: true, + modalClass: 'bundle', + type: 'slide', + closed: function(e, modal) { + modal.modal.remove(); + }, buttons: [{ text: $.mage.__('Add Selected Products'), 'class': 'action-primary action-add', - click: function() { + click: function () { $.each(selectedProductList, function() { window.bSelection.addRow(optionIndex, this); }); @@ -141,34 +142,10 @@ define([ ); widget.refreshSortableElements(); widget._updateSelectionsPositions.apply(widget.element); - $selectionGrid.dialog('close'); - } - }, { - text: $.mage.__('Cancel'), - 'class': 'action-close', - click: function() { - $selectionGrid.dialog('close'); + $selectionGrid.modal('closeModal'); } - }], - position: { - my: 'left top', - at: 'center top', - of: 'body' - }, - open: function () { - $(this).closest('.ui-dialog').addClass('ui-dialog-active'); - - var topMargin = $(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 45; - $(this).closest('.ui-dialog').css('margin-top', topMargin); - - $(this).addClass('admin__scope-old'); // ToDo UI: remove with old styles removal - }, - close: function() { - $(this).closest('.ui-dialog').removeClass('ui-dialog-active'); - $(this).dialog('destroy'); - } + }] }); - $.ajax({ url: bSelection.selectionSearchUrl, dataType: 'html', @@ -179,7 +156,7 @@ define([ form_key: FORM_KEY }, success: function(data) { - $selectionGrid.html(data).dialog('open'); + $selectionGrid.html(data).modal('openModal'); }, context: $('body'), showLoader: true diff --git a/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php b/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php index 85eaaf679f02ff8a06f0d1200cc79ea572ad7ed6..58de2b262c8ab7489b6f37691e592484dd7d624b 100644 --- a/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php +++ b/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php @@ -53,7 +53,6 @@ class ColumnFactory $config = array_merge([ 'label' => __($attribute->getDefaultFrontendLabel()), 'dataType' => $this->getDataType($attribute), - 'align' => 'left', 'add_field' => true, 'visible' => $attribute->getIsVisibleInGrid(), ], $config); @@ -61,15 +60,16 @@ class ColumnFactory if ($attribute->usesSource()) { $config['options'] = $attribute->getSource()->getAllOptions(); } + + $config['component'] = $this->getJsComponent($config['dataType']); + $arguments = [ 'data' => [ - 'js_config' => [ - 'component' => $this->getJsComponent($config['dataType']), - ], 'config' => $config, ], 'context' => $context, ]; + return $this->componentFactory->create($columnName, 'column', $arguments); } diff --git a/app/code/Magento/Catalog/Ui/Component/Listing/Columns.php b/app/code/Magento/Catalog/Ui/Component/Listing/Columns.php index 2e0243e5875aaba35f44914ba5eebc908d7d1470..04e58709d402f67aa6a6a1fc96d2bfe143cd1438 100644 --- a/app/code/Magento/Catalog/Ui/Component/Listing/Columns.php +++ b/app/code/Magento/Catalog/Ui/Component/Listing/Columns.php @@ -15,6 +15,17 @@ class Columns extends \Magento\Ui\Component\Listing\Columns /** @var \Magento\Catalog\Ui\Component\Listing\Attribute\RepositoryInterface */ protected $attributeRepository; + /** + * @var array + */ + protected $filterMap = [ + 'default' => 'text', + 'select' => 'select', + 'boolean' => 'select', + 'multiselect' => 'select', + 'date' => 'dateRange', + ]; + /** * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context * @param \Magento\Catalog\Ui\Component\ColumnFactory $columnFactory @@ -41,8 +52,12 @@ class Columns extends \Magento\Ui\Component\Listing\Columns { $columnSortOrder = self::DEFAULT_COLUMNS_MAX_ORDER; foreach ($this->attributeRepository->getList() as $attribute) { + $config = []; if (!isset($this->components[$attribute->getAttributeCode()])) { $config['sortOrder'] = ++$columnSortOrder; + if ($attribute->getIsFilterableInGrid()) { + $config['filter'] = $this->getFilterType($attribute->getFrontendInput()); + } $column = $this->columnFactory->create($attribute, $this->getContext(), $config); $column->prepare(); $this->addComponent($attribute->getAttributeCode(), $column); @@ -50,4 +65,15 @@ class Columns extends \Magento\Ui\Component\Listing\Columns } parent::prepare(); } + + /** + * Retrieve filter type by $frontendInput + * + * @param string $frontendInput + * @return string + */ + protected function getFilterType($frontendInput) + { + return isset($this->filterMap[$frontendInput]) ? $this->filterMap[$frontendInput] : $this->filterMap['default']; + } } diff --git a/app/code/Magento/Catalog/Ui/Component/Listing/Columns/Price.php b/app/code/Magento/Catalog/Ui/Component/Listing/Columns/Price.php index ec0547e6f1b9e3377f0443016f95ea6a0823409c..2c4af877568c3d9d33dfb033d034c254e03b376f 100644 --- a/app/code/Magento/Catalog/Ui/Component/Listing/Columns/Price.php +++ b/app/code/Magento/Catalog/Ui/Component/Listing/Columns/Price.php @@ -13,7 +13,7 @@ class Price extends \Magento\Ui\Component\Listing\Columns\Column /** * Column name */ - const NAME = 'price'; + const NAME = 'column.price'; /** * @var \Magento\Framework\Locale\CurrencyInterface diff --git a/app/code/Magento/Catalog/Ui/Component/Listing/Filters.php b/app/code/Magento/Catalog/Ui/Component/Listing/Filters.php deleted file mode 100644 index ba70b679b5e4e4e44781ad1a8363b07e7ce05ad6..0000000000000000000000000000000000000000 --- a/app/code/Magento/Catalog/Ui/Component/Listing/Filters.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Catalog\Ui\Component\Listing; - -class Filters extends \Magento\Ui\Component\Filters -{ - /** - * @var \Magento\Catalog\Ui\Component\Listing\Attribute\RepositoryInterface - */ - protected $attributeRepository; - - /** - * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context - * @param \Magento\Catalog\Ui\Component\FilterFactory $filterFactory - * @param \Magento\Catalog\Ui\Component\Listing\Attribute\RepositoryInterface $attributeRepository - * @param array $components - * @param array $data - */ - public function __construct( - \Magento\Framework\View\Element\UiComponent\ContextInterface $context, - \Magento\Catalog\Ui\Component\FilterFactory $filterFactory, - \Magento\Catalog\Ui\Component\Listing\Attribute\RepositoryInterface $attributeRepository, - array $components = [], - array $data = [] - ) { - parent::__construct($context, $components, $data); - $this->filterFactory = $filterFactory; - $this->attributeRepository = $attributeRepository; - } - - /** - * {@inheritdoc} - */ - public function prepare() - { - foreach ($this->attributeRepository->getList() as $attribute) { - if (!isset($this->components[$attribute->getAttributeCode()]) && $attribute->getIsFilterableInGrid()) { - $filter = $this->filterFactory->create($attribute, $this->getContext()); - $filter->prepare(); - $this->addComponent($attribute->getAttributeCode(), $filter); - } - } - parent::prepare(); - } -} diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/edit.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/edit.phtml index fcf5ba45d80d69ecb9c336a785295eb6a4fb9734..569e0e88458c683f848c64595fa8159c30eeee59 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/edit.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/edit.phtml @@ -20,9 +20,11 @@ require([ "jquery", "tinymce", + 'Magento_Ui/js/modal/confirm', + 'Magento_Ui/js/modal/alert', "loadingPopup", "mage/backend/floating-header" -], function(jQuery, tinyMCE){ +], function(jQuery, tinyMCE, confirm, alert){ //<![CDATA[ function categoryReset(url,useAjax){ @@ -40,9 +42,14 @@ require([ * with this form, we surely delete same category in the tree and at backend */ function categoryDelete(url) { - if (confirm('<?php /* @escapeNotVerified */ echo __('Are you sure you want to delete this category?') ?>')){ - location.href = url; - } + confirm({ + content: '<?php /* @escapeNotVerified */ echo __('Are you sure you want to delete this category?') ?>', + actions: { + confirm: function () { + location.href = url; + } + } + }); } /** @@ -81,7 +88,9 @@ require([ }); $categoryContainer.html(''); } catch (e) { - alert(e.message); + alert({ + content: e.message + }); } $categoryContainer.html(data.content).trigger('contentUpdated'); setTimeout(function() { @@ -98,7 +107,9 @@ require([ window.refreshTreeArea(); } } catch (e) { - alert(e.message); + alert({ + content: e.message + }); }; }, 25); } diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml index eeefa9796b4f85dc48a98950a928717ceffb2ef6..9e1c939c542386dea232351f7be694945c4dd984 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml @@ -16,536 +16,486 @@ </div> <div class="tree-actions"> <?php if ($block->getRoot()): ?> - <?php //echo $block->getCollapseButtonHtml() ?> - <?php //echo $block->getExpandButtonHtml() ?> - <a href="#" - onclick="tree.collapseTree(); return false;"><?php /* @escapeNotVerified */ echo __('Collapse All'); ?></a> - <span class="separator">|</span> <a href="#" - onclick="tree.expandTree(); return false;"><?php /* @escapeNotVerified */ echo __('Expand All'); ?></a> + <?php //echo $block->getCollapseButtonHtml() ?> + <?php //echo $block->getExpandButtonHtml() ?> + <a href="#" + onclick="tree.collapseTree(); return false;"><?php /* @escapeNotVerified */ echo __('Collapse All'); ?></a> + <span class="separator">|</span> <a href="#" + onclick="tree.expandTree(); return false;"><?php /* @escapeNotVerified */ echo __('Expand All'); ?></a> <?php endif; ?> </div> -<?php if ($block->getRoot()): ?> + <?php if ($block->getRoot()): ?> <div class="tree-holder"> <div id="tree-div" class="tree-wrapper"></div> </div> </div> -<div data-id="information-dialog-tree" class="messages" style="display: none;"> - <div class="message message-notice"> - <div><?php /* @escapeNotVerified */ echo __('This operation can take a long time'); ?></div> + <div data-id="information-dialog-tree" class="messages" style="display: none;"> + <div class="message message-notice"> + <div><?php /* @escapeNotVerified */ echo __('This operation can take a long time'); ?></div> + </div> </div> -</div> -<!--[if IE]> -<script id="ie-deferred-loader" defer="defer" src=""></script> -<![endif]--> -<script> -var tree; -require([ - "jquery", - "jquery/ui", - "prototype", - "extjs/ext-tree-checkbox", - "mage/adminhtml/form", - "mage/translate" -], function(jQuery){ - -/** - * Fix ext compatibility with prototype 1.6 - */ -Ext.lib.Event.getTarget = function (e) { - var ee = e.browserEvent || e; - return ee.target ? Event.element(ee) : null; -}; - -Ext.tree.TreePanel.Enhanced = function (el, config) { - Ext.tree.TreePanel.Enhanced.superclass.constructor.call(this, el, config); -}; - -Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, { - - loadTree:function (config, firstLoad) { - var parameters = config['parameters']; - var data = config['data']; - - this.storeId = parameters['store_id']; - - if (this.storeId != 0 && $('add_root_category_button')) { - $('add_root_category_button').hide(); - } - - if ((typeof parameters['root_visible']) != 'undefined') { - this.rootVisible = parameters['root_visible'] * 1; - } - - var root = new Ext.tree.TreeNode(parameters); - - this.nodeHash = {}; - this.setRootNode(root); - - if (firstLoad) { - this.addListener('click', this.categoryClick); - this.addListener('beforenodedrop', categoryMove.createDelegate(this)); - } - - this.loader.buildCategoryTree(root, data); - this.el.dom.innerHTML = ''; - // render the tree - this.render(); - if (parameters['expanded']) { - this.expandAll(); - } else { - root.expand(); - } - - var selectedNode = this.getNodeById(parameters['category_id']); - if (selectedNode) { - this.currentNodeId = parameters['category_id']; - } - this.selectCurrentNode(); - - // Temporary solution will be replaced after refactoring of tree functionality - jQuery('body').off('tabsactivate.tree').on('tabsactivate.tree', jQuery.proxy(function (e, ui) { - this.activeTab = jQuery(ui.newTab).find('a').prop('id'); - }, this)) - }, - - request:function (url, params) { - if (!params) { - if (this.activeTab) { - var params = {active_tab_id:this.activeTab}; - } - else { - var params = {}; - } - } - if (!params.form_key) { - params.form_key = FORM_KEY; - } - var result = new Ajax.Request( - url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), - { - parameters:params, - method:'post' - } - ); - - return result; - }, - - selectCurrentNode:function () { - if (this.currentNodeId) { - var selectedNode = this.getNodeById(this.currentNodeId); - if ((typeof selectedNode.attributes.path) != 'undefined') { - var path = selectedNode.attributes.path; - if (!this.storeId) { - path = '0/' + path; - } - this.selectPath(path); - } else { - this.getSelectionModel().select(selectedNode); - } - } - }, - - collapseTree:function () { - this.collapseAll(); - - this.selectCurrentNode(); - - if (!this.collapsed) { - this.collapsed = true; - this.loader.dataUrl = '<?php /* @escapeNotVerified */ echo $block->getLoadTreeUrl(false) ?>'; - this.request(this.loader.dataUrl, false); - } - }, - - expandTree:function () { - this.expandAll(); - if (this.collapsed) { - this.collapsed = false; - this.loader.dataUrl = '<?php /* @escapeNotVerified */ echo $block->getLoadTreeUrl(true) ?>'; - this.request(this.loader.dataUrl, false); - } - }, - - categoryClick:function (node, e) { - var url = this.buildUrl(node.id); - - this.currentNodeId = node.id; - if (!this.useAjax) { - setLocation(url); - return; - } - if (this.activeTab) { - var params = {active_tab_id:this.activeTab}; - } - updateContent(url, params); - }, - - buildUrl: function(id){ - var urlExt = (this.storeId ? 'store/' + this.storeId + '/' : '') + 'id/' + id + '/'; - - return parseSidUrl(this.baseUrl, urlExt); - }, - - getBaseUrl: function(){ - return this.baseUrl; - } -}); - -function reRenderTree(switcherParams) { - // re-render tree by store switcher - if (tree && switcherParams) { - var url; - if (switcherParams.useConfirm) { - if (!confirm("<?php /* @escapeNotVerified */ echo __('Please confirm site switching. All data that hasn\'t been saved will be lost.') ?>")) { - return false; - } - } + <!--[if IE]> + <script id="ie-deferred-loader" defer="defer" src=""></script> + <![endif]--> + <script> + var tree; + require([ + "jquery", + 'Magento_Ui/js/modal/modal', + "jquery/ui", + "prototype", + "extjs/ext-tree-checkbox", + "mage/adminhtml/form", + "mage/translate" + ], function (jQuery, modal) { + + /** + * Fix ext compatibility with prototype 1.6 + */ + Ext.lib.Event.getTarget = function (e) { + var ee = e.browserEvent || e; + return ee.target ? Event.element(ee) : null; + }; - if ($('add_root_category_button')) { - if (!switcherParams.scopeId) { - $('add_root_category_button').show(); - } - else { - $('add_root_category_button').hide(); - } - } - - if (tree.useAjax) { - // retain current selected category id - url = tree.switchTreeUrl + switcherParams.scopeParams + 'id/' + tree.currentNodeId + '/'; - // load from cache - // load from ajax - // add form key - var params = { - form_key : FORM_KEY + Ext.tree.TreePanel.Enhanced = function (el, config) { + Ext.tree.TreePanel.Enhanced.superclass.constructor.call(this, el, config); }; - new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), { - parameters:params, - method:'post', - onComplete:function (transport) { - var response = eval('(' + transport.responseText + ')'); - if (!response['parameters']) { - return false; + + Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, { + + loadTree: function (config, firstLoad) { + var parameters = config['parameters']; + var data = config['data']; + + this.storeId = parameters['store_id']; + + if (this.storeId != 0 && $('add_root_category_button')) { + $('add_root_category_button').hide(); } - _renderNewTree(response, switcherParams.scopeParams); + if ((typeof parameters['root_visible']) != 'undefined') { + this.rootVisible = parameters['root_visible'] * 1; + } + + var root = new Ext.tree.TreeNode(parameters); + + this.nodeHash = {}; + this.setRootNode(root); + this.modal = modal; + + if (firstLoad) { + this.addListener('click', this.categoryClick); + this.addListener('beforenodedrop', categoryMove.bind(this)); + } + + this.loader.buildCategoryTree(root, data); + this.el.dom.innerHTML = ''; + // render the tree + this.render(); + if (parameters['expanded']) { + this.expandAll(); + } else { + root.expand(); + } + + var selectedNode = this.getNodeById(parameters['category_id']); + if (selectedNode) { + this.currentNodeId = parameters['category_id']; + } + this.selectCurrentNode(); + + // Temporary solution will be replaced after refactoring of tree functionality + jQuery('body').off('tabsactivate.tree').on('tabsactivate.tree', jQuery.proxy(function (e, ui) { + this.activeTab = jQuery(ui.newTab).find('a').prop('id'); + }, this)) + }, + + request: function (url, params) { + if (!params) { + if (this.activeTab) { + var params = {active_tab_id: this.activeTab}; + } + else { + var params = {}; + } + } + if (!params.form_key) { + params.form_key = FORM_KEY; + } + var result = new Ajax.Request( + url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), + { + parameters: params, + method: 'post' + } + ); + + return result; + }, + + selectCurrentNode: function () { + if (this.currentNodeId) { + var selectedNode = this.getNodeById(this.currentNodeId); + if ((typeof selectedNode.attributes.path) != 'undefined') { + var path = selectedNode.attributes.path; + if (!this.storeId) { + path = '0/' + path; + } + this.selectPath(path); + } else { + this.getSelectionModel().select(selectedNode); + } + } + }, + + collapseTree: function () { + this.collapseAll(); + + this.selectCurrentNode(); + + if (!this.collapsed) { + this.collapsed = true; + this.loader.dataUrl = '<?php /* @escapeNotVerified */ echo $block->getLoadTreeUrl(false) ?>'; + this.request(this.loader.dataUrl, false); + } + }, + + expandTree: function () { + this.expandAll(); + if (this.collapsed) { + this.collapsed = false; + this.loader.dataUrl = '<?php /* @escapeNotVerified */ echo $block->getLoadTreeUrl(true) ?>'; + this.request(this.loader.dataUrl, false); + } + }, + + categoryClick: function (node, e) { + var url = this.buildUrl(node.id); + + this.currentNodeId = node.id; + if (!this.useAjax) { + setLocation(url); + return; + } + if (this.activeTab) { + var params = {active_tab_id: this.activeTab}; + } + updateContent(url, params); + }, + + buildUrl: function (id) { + var urlExt = (this.storeId ? 'store/' + this.storeId + '/' : '') + 'id/' + id + '/'; + + return parseSidUrl(this.baseUrl, urlExt); + }, + + getBaseUrl: function () { + return this.baseUrl; } }); - } else { - var baseUrl = '<?php /* @escapeNotVerified */ echo $block->getEditUrl() ?>'; - var urlExt = switcherParams.scopeParams + 'id/' + tree.currentNodeId + '/'; - url = parseSidUrl(baseUrl, urlExt); - setLocation(url); - } - } - // render default tree - else { - _renderNewTree(); - } -} - -function _renderNewTree(config, scopeParams) { - if (!config) { - var config = defaultLoadTreeParams; - } - if (tree) { - tree.purgeListeners(); - tree.el.dom.innerHTML = ''; - } - tree = new Ext.tree.TreePanel.Enhanced('tree-div', newTreeParams); - - tree.loadTree(config, true); - - // try to select current category - var selectedNode = tree.getNodeById(config.parameters.category_id); - if (selectedNode) { - tree.currentNodeId = config.parameters.category_id; - } - tree.selectCurrentNode(); - - // update content area - var url = tree.editUrl; - if (scopeParams) { - url = url + scopeParams; - } - <?php if ($block->isClearEdit()): ?> - if (selectedNode) { - url = url + 'id/' + config.parameters.category_id; - } - <?php endif;?> - //updateContent(url); //commented since ajax requests replaced with http ones to load a category -} - -jQuery(function () { - categoryLoader = new Ext.tree.TreeLoader({ - dataUrl:'<?php /* @escapeNotVerified */ echo $block->getLoadTreeUrl() ?>' - }); - - categoryLoader.processResponse = function(response, parent, callback) { - var config = JSON.parse(response.responseText); - - this.buildCategoryTree(parent, config); - - if (typeof callback == "function") { - callback(this, parent); - } - }; - - categoryLoader.buildCategoryTree = function (parent, config) { - if (!config) return null; - - if (parent && config && config.length) { - for (var i = 0; i < config.length; i++) { - var node; - var _node = Object.clone(config[i]); - if (_node.children && !_node.children.length) { - delete(_node.children); - node = new Ext.tree.AsyncTreeNode(_node); - } else { - node = new Ext.tree.TreeNode(config[i]); + + function reRenderTree(switcherParams) { + // re-render tree by store switcher + if (tree && switcherParams) { + var url; + if (switcherParams.useConfirm) { + if (!confirm("<?php /* @escapeNotVerified */ echo __('Please confirm site switching. All data that hasn\'t been saved will be lost.') ?>")) { + return false; + } + } + + if ($('add_root_category_button')) { + if (!switcherParams.scopeId) { + $('add_root_category_button').show(); + } + else { + $('add_root_category_button').hide(); + } + } + + if (tree.useAjax) { + // retain current selected category id + url = tree.switchTreeUrl + switcherParams.scopeParams + 'id/' + tree.currentNodeId + '/'; + // load from cache + // load from ajax + // add form key + var params = { + form_key: FORM_KEY + }; + new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), { + parameters: params, + method: 'post', + onComplete: function (transport) { + var response; + + try { + response = JSON.parse(transport.responseText); + } catch (e) { + console.warn('An error occured while parsing response'); + } + + if (!response || !response['parameters']) { + return false; + } + + _renderNewTree(response, switcherParams.scopeParams); + } + }); + } else { + var baseUrl = '<?php /* @escapeNotVerified */ echo $block->getEditUrl() ?>'; + var urlExt = switcherParams.scopeParams + 'id/' + tree.currentNodeId + '/'; + url = parseSidUrl(baseUrl, urlExt); + setLocation(url); + } } - parent.appendChild(node); - node.loader = node.getOwnerTree().loader; - if (_node.children) { - this.buildCategoryTree(node, _node.children); + // render default tree + else { + _renderNewTree(); } } - } - }; - categoryLoader.buildHash = function (node) { - var hash = {}; + function _renderNewTree(config, scopeParams) { + if (!config) { + var config = defaultLoadTreeParams; + } - hash = this.toArray(node.attributes); + if (tree) { + tree.purgeListeners(); + tree.el.dom.innerHTML = ''; + } + tree = new Ext.tree.TreePanel.Enhanced('tree-div', newTreeParams); - if (node.childNodes.length > 0 || (node.loaded == false && node.loading == false)) { - hash['children'] = new Array; + tree.loadTree(config, true); - for (var i = 0, len = node.childNodes.length; i < len; i++) { - if (!hash['children']) { - hash['children'] = new Array; + // try to select current category + var selectedNode = tree.getNodeById(config.parameters.category_id); + if (selectedNode) { + tree.currentNodeId = config.parameters.category_id; } - hash['children'].push(this.buildHash(node.childNodes[i])); + tree.selectCurrentNode(); + + // update content area + var url = tree.editUrl; + if (scopeParams) { + url = url + scopeParams; + } + <?php if ($block->isClearEdit()): ?> + if (selectedNode) { + url = url + 'id/' + config.parameters.category_id; + } + <?php endif;?> + //updateContent(url); //commented since ajax requests replaced with http ones to load a category } - } - - return hash; - }; - - categoryLoader.toArray = function (attributes) { - var data = {form_key:FORM_KEY}; - for (var key in attributes) { - var value = attributes[key]; - data[key] = value; - } - - return data; - }; - - categoryLoader.on("beforeload", function (treeLoader, node) { - treeLoader.baseParams.id = node.attributes.id; - treeLoader.baseParams.store = node.attributes.store; - treeLoader.baseParams.form_key = FORM_KEY; - }); - - categoryLoader.on("load", function (treeLoader, node, config) { - //varienWindowOnload(); - }); - - scopeSwitcherHandler = reRenderTree; - - newTreeParams = { - animate:false, - loader:categoryLoader, - enableDD:true, - containerScroll:true, - selModel:new Ext.tree.CheckNodeMultiSelectionModel(), - rootVisible:'<?php /* @escapeNotVerified */ echo $block->getRoot()->getIsVisible() ?>', - useAjax: <?php /* @escapeNotVerified */ echo $block->getUseAjax() ?>, - switchTreeUrl:'<?php /* @escapeNotVerified */ echo $block->getSwitchTreeUrl() ?>', - editUrl:'<?php /* @escapeNotVerified */ echo $block->getEditUrl() ?>', - currentNodeId: <?php echo (int)$block->getCategoryId() ?>, - baseUrl: '<?php /* @escapeNotVerified */ echo $block->getEditUrl() ?>' - }; - - defaultLoadTreeParams = { - parameters:{ - text:'<?php /* @escapeNotVerified */ echo htmlentities($block->getRoot()->getName()) ?>', - draggable:false, - allowDrop : <?php if ($block->getRoot()->getIsVisible()): ?>true<?php else : ?>false<?php endif; ?>, - id: <?php echo (int)$block->getRoot()->getId() ?>, - expanded: <?php echo (int)$block->getIsWasExpanded() ?>, - store_id: <?php echo (int)$block->getStore()->getId() ?>, - category_id: <?php echo (int)$block->getCategoryId() ?> - }, - data: <?php /* @escapeNotVerified */ echo $block->getTreeJson() ?> - }; - - reRenderTree(); -}); - -function addNew(url, isRoot) { - if (isRoot) { - tree.currentNodeId = tree.root.id; - } - - if (/store\/\d+/.test(url)) { - url = url.replace(/store\/\d+/, "store/" + tree.storeId); - } - else { - url += "store/" + tree.storeId + "/"; - } - - url += 'parent/' + tree.currentNodeId; - updateContent(url); -} - -var mageDialog = (function($) { - var self = {dialogOpened: false, callback: []}; - - self.callback = {ok: [], cancel: []}; - self.createDialog = function () { - var onEvent = function (type, dialog) { - self.callback[type].forEach(function(call) { - call(); - }); - $(dialog).dialog( "close" ); - }; - var _resetState = function() { - self.dialogOpened = false; - self.callback = {ok: [], cancel: []}; - delete self.dialog; - }; - self.dialog = $('[data-id="information-dialog-category"]').dialog({ - autoOpen: false, - modal: true, - dialogClass: 'popup-window ui-popup-message', - resizable: false, - width: '75%', - title: $.mage.__('Warning message'), - position: { - my: 'left top', - at: 'center top', - of: 'body' - }, - buttons: [{ - text: $.mage.__('Ok'), - 'class': 'action-primary', - click: function () { - onEvent('ok', this); + + jQuery(function () { + categoryLoader = new Ext.tree.TreeLoader({ + dataUrl: '<?php /* @escapeNotVerified */ echo $block->getLoadTreeUrl() ?>' + }); + + categoryLoader.processResponse = function (response, parent, callback) { + var config = JSON.parse(response.responseText); + + this.buildCategoryTree(parent, config); + + if (typeof callback == "function") { + callback(this, parent); } - }, { - text: $.mage.__('Cancel'), - 'class': 'action-close', - click: function () { - onEvent('cancel', this); + }; + + categoryLoader.buildCategoryTree = function (parent, config) { + if (!config) return null; + + if (parent && config && config.length) { + for (var i = 0; i < config.length; i++) { + var node; + var _node = Object.clone(config[i]); + if (_node.children && !_node.children.length) { + delete(_node.children); + node = new Ext.tree.AsyncTreeNode(_node); + } else { + node = new Ext.tree.TreeNode(config[i]); + } + parent.appendChild(node); + node.loader = node.getOwnerTree().loader; + if (_node.children) { + this.buildCategoryTree(node, _node.children); + } + } + } + }; + + categoryLoader.buildHash = function (node) { + var hash = {}; + + hash = this.toArray(node.attributes); + + if (node.childNodes.length > 0 || (node.loaded == false && node.loading == false)) { + hash['children'] = new Array; + + for (var i = 0, len = node.childNodes.length; i < len; i++) { + if (!hash['children']) { + hash['children'] = new Array; + } + hash['children'].push(this.buildHash(node.childNodes[i])); + } + } + + return hash; + }; + + categoryLoader.toArray = function (attributes) { + var data = {form_key: FORM_KEY}; + for (var key in attributes) { + var value = attributes[key]; + data[key] = value; } + + return data; + }; + + categoryLoader.on("beforeload", function (treeLoader, node) { + treeLoader.baseParams.id = node.attributes.id; + treeLoader.baseParams.store = node.attributes.store; + treeLoader.baseParams.form_key = FORM_KEY; + }); + + categoryLoader.on("load", function (treeLoader, node, config) { + //varienWindowOnload(); + }); + + scopeSwitcherHandler = reRenderTree; + + newTreeParams = { + animate: false, + loader: categoryLoader, + enableDD: true, + containerScroll: true, + selModel: new Ext.tree.CheckNodeMultiSelectionModel(), + rootVisible: '<?php /* @escapeNotVerified */ echo $block->getRoot()->getIsVisible() ?>', + useAjax: <?php /* @escapeNotVerified */ echo $block->getUseAjax() ?>, + switchTreeUrl: '<?php /* @escapeNotVerified */ echo $block->getSwitchTreeUrl() ?>', + editUrl: '<?php /* @escapeNotVerified */ echo $block->getEditUrl() ?>', + currentNodeId: <?php /* @escapeNotVerified */ echo (int)$block->getCategoryId() ?>, + baseUrl: '<?php /* @escapeNotVerified */ echo $block->getEditUrl() ?>' + }; + + defaultLoadTreeParams = { + parameters: { + text: '<?php /* @escapeNotVerified */ echo htmlentities($block->getRoot()->getName()) ?>', + draggable: false, + allowDrop: <?php if ($block->getRoot()->getIsVisible()): ?>true<?php else : ?>false<?php endif; ?>, + id: <?php /* @escapeNotVerified */ echo (int)$block->getRoot()->getId() ?>, + expanded: <?php /* @escapeNotVerified */ echo (int)$block->getIsWasExpanded() ?>, + store_id: <?php /* @escapeNotVerified */ echo (int)$block->getStore()->getId() ?>, + category_id: <?php /* @escapeNotVerified */ echo (int)$block->getCategoryId() ?> + }, + data: <?php /* @escapeNotVerified */ echo $block->getTreeJson() ?> + }; + + reRenderTree(); + }); + + function addNew(url, isRoot) { + if (isRoot) { + tree.currentNodeId = tree.root.id; } - ], - open: function () { - $(this).closest('.ui-dialog').addClass('ui-dialog-active'); - self.dialogOpened = true; - - var topMargin = $(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 30; - $(this).closest('.ui-dialog').css('margin-top', topMargin); - }, - close: function(event, ui) { - $(this).dialog('destroy'); - _resetState(); - } - }); - }; - - return { - onOk: function(call) { - self.callback.ok.push(call); - return this; - }, - onCancel: function(call) { - self.callback.cancel.push(call); - return this; - }, - show: function() { - if (self.dialog == undefined) { - self.createDialog(); - } - if (self.dialogOpened == false) { - self.dialog.dialog('open'); - } - return this; - } - }; -})(jQuery); - -function categoryMove(obj) { - var data = {id:obj.dropNode.id, form_key:FORM_KEY}; - - data.point = obj.point; - switch (obj.point) { - case 'above' : - data.pid = obj.target.parentNode.id; - data.paid = obj.dropNode.parentNode.id; - if (obj.target.previousSibling) { - data.aid = obj.target.previousSibling.id; - } else { - data.aid = 0; - } - break; - case 'below' : - data.pid = obj.target.parentNode.id; - data.aid = obj.target.id; - break; - case 'append' : - data.pid = obj.target.id; - data.paid = obj.dropNode.parentNode.id; - if (obj.target.lastChild) { - data.aid = obj.target.lastChild.id; - } else { - data.aid = 0; - } - break; - default : - obj.cancel = true; - return obj; - } - - var pd = []; - for (var key in data) { - pd.push(encodeURIComponent(key), "=", encodeURIComponent(data[key]), "&"); - } - pd.splice(pd.length - 1, 1); - - mageDialog.onOk(function() { - (function($){ - $.ajax({ - url: '<?php /* @escapeNotVerified */ echo $block->getMoveUrl() ?>', - method : 'POST', - data: pd.join(""), - showLoader: true - }).done(function(data) { - if (data.messages && data.messages.length > 0) { - $('[name=category-edit-form] .messages').html(data.messages); + + if (/store\/\d+/.test(url)) { + url = url.replace(/store\/\d+/, "store/" + tree.storeId); } - if (data.error) { - reRenderTree(); - } else { - $(obj.tree.container.dom).trigger('categoryMove.tree'); + else { + url += "store/" + tree.storeId + "/"; } - }).fail(function(jqXHR, textStatus) { - if (window.console) { - console.log(textStatus); + + url += 'parent/' + tree.currentNodeId; + updateContent(url); + } + + function categoryMove(obj) { + var data = {id: obj.dropNode.id, form_key: FORM_KEY}; + + data.point = obj.point; + switch (obj.point) { + case 'above' : + data.pid = obj.target.parentNode.id; + data.paid = obj.dropNode.parentNode.id; + if (obj.target.previousSibling) { + data.aid = obj.target.previousSibling.id; + } else { + data.aid = 0; + } + break; + case 'below' : + data.pid = obj.target.parentNode.id; + data.aid = obj.target.id; + break; + case 'append' : + data.pid = obj.target.id; + data.paid = obj.dropNode.parentNode.id; + if (obj.target.lastChild) { + data.aid = obj.target.lastChild.id; + } else { + data.aid = 0; + } + break; + default : + obj.cancel = true; + return obj; } - location.reload(); - }); - })(jQuery); - }).onCancel(function() { - reRenderTree(); - }).show(); -} - window.addNew = addNew; - -}); -</script> + + var pd = []; + for (var key in data) { + pd.push(encodeURIComponent(key), "=", encodeURIComponent(data[key]), "&"); + } + pd.splice(pd.length - 1, 1); + + jQuery('[data-id="information-dialog-category"]').modal({ + modalClass: 'confirm', + title: jQuery.mage.__('Warning message'), + buttons: [{ + text: 'Cancel', + class: 'action-secondary', + click: function () { + reRenderTree(); + this.closeModal(); + } + }, { + text: 'Ok', + class: 'action-primary', + click: function () { + (function ($) { + $.ajax({ + url: '<?php /* @escapeNotVerified */ echo $block->getMoveUrl() ?>//', + method: 'POST', + data: pd.join(""), + showLoader: true + }).done(function (data) { + if (data.messages && data.messages.length > 0) { + $('[name=category-edit-form] .messages').html(data.messages); + } + if (data.error) { + reRenderTree(); + } else { + $(obj.tree.container.dom).trigger('categoryMove.tree'); + } + }).fail(function (jqXHR, textStatus) { + if (window.console) { + console.log(textStatus); + } + location.reload(); + }); + })(jQuery); + this.closeModal(); + } + }] + + }).trigger('openModal'); + + } + + window.addNew = addNew; + + }); + </script> <?php endif; ?> diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/form.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/form.phtml index 98f5a0a65052f5e7cea257320245e1d4d21ecdff..8bc0b649753997c6813ce5d6ccf4a167273c5f3e 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/form.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/form.phtml @@ -13,14 +13,15 @@ */ ?> <?php /* @escapeNotVerified */ echo $block->getFormInitScripts() ?> +<div data-mage-init='{"floatingHeader": {}}' class="page-actions attribute-popup-actions" <?php /* @escapeNotVerified */ echo $block->getUiId('content-header') ?>> + <?php echo $block->getButtonsHtml('header') ?> +</div> + <form id="edit_form" class="admin__scope-old" action="<?php echo $block->escapeHtml($block->getSaveUrl()) ?>" method="post"> <input name="form_key" type="hidden" value="<?php echo $block->escapeHtml($block->getFormKey()) ?>" /> <?php echo $block->getChildHtml('form') ?> </form> -<div data-mage-init='{"floatingHeader": {}}' class="page-actions attribute-popup-actions" <?php /* @escapeNotVerified */ echo $block->getUiId('content-header') ?>> - <?php echo $block->getButtonsHtml('header') ?> -</div> <script> require(['jquery', "mage/mage"], function(jQuery){ diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml index 1881699475464a9085b95334f9abe567467d75e5..dfc022ec9b6500efd6dde7e59efd84ffd0fe2411 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml @@ -8,7 +8,13 @@ ?> <script> -require(["jquery", "collapsable", "prototype"], function(jQuery){ +require([ + "jquery", + 'Magento_Ui/js/modal/alert', + 'Magento_Ui/js/modal/prompt', + "collapsable", + "prototype" +], function(jQuery, alert, prompt){ function toggleApplyVisibility(select) { if ($(select).value == 1) { @@ -260,36 +266,48 @@ function updateRequriedOptions() function saveAttributeInNewSet(promptMessage) { - var newAttributeSetName = prompt(promptMessage, ''); - - if (newAttributeSetName == null) { - return; - } - - var rules = ['required-entry', 'validate-no-html-tags']; - for (var i = 0; i < rules.length; i++) { - if (!jQuery.validator.methods[rules[i]](newAttributeSetName)) { - alert(jQuery.validator.messages[rules[i]]); - return; + var newAttributeSetName; + + prompt({ + content: promptMessage, + actions: { + confirm: function(val) { + newAttributeSetName = val; + + if (!newAttributeSetName) { + return; + } + + var rules = ['required-entry', 'validate-no-html-tags']; + for (var i = 0; i < rules.length; i++) { + if (!jQuery.validator.methods[rules[i]](newAttributeSetName)) { + alert({ + content: jQuery.validator.messages[rules[i]] + }); + + return; + } + } + + var newAttributeSetNameInputId = 'new_attribute_set_name'; + + if ($(newAttributeSetNameInputId)) { + $(newAttributeSetNameInputId).value = newAttributeSetName; + } else { + $('edit_form').insert({ + top: new Element('input', { + type: 'hidden', + id: newAttributeSetNameInputId, + name: 'new_attribute_set_name', + value: newAttributeSetName + }) + }); + } + // Temporary solution will replaced after refactoring of attributes functionality + jQuery('#edit_form').triggerHandler('save'); + } } - } - - var newAttributeSetNameInputId = 'new_attribute_set_name'; - - if ($(newAttributeSetNameInputId)) { - $(newAttributeSetNameInputId).value = newAttributeSetName; - } else { - $('edit_form').insert({ - top: new Element('input', { - type: 'hidden', - id: newAttributeSetNameInputId, - name: 'new_attribute_set_name', - value: newAttributeSetName - }) - }); - } - // Temporary solution will replaced after refactoring of attributes functionality - jQuery('#edit_form').triggerHandler('save'); + }); } if($('frontend_input')){ diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/set/main.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/set/main.phtml index 4ccbec13fdbfe645adb9efea563360fe78d0a10d..06edcfbaa2588ae285fac4a456ec0ae5c05b8846 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/set/main.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/set/main.phtml @@ -11,23 +11,23 @@ <div class="edit-attribute-set attribute-set-col"> <?php echo $block->getSetFormHtml() ?> <script> -require([ - "jquery", - "mage/mage" -], function(jQuery){ + require([ + "jquery", + "mage/mage" + ], function(jQuery){ - jQuery('#set-prop-form').mage('validation', {errorClass: 'mage-error'}); + jQuery('#set-prop-form').mage('validation', {errorClass: 'mage-error'}); -}); -</script> + }); + </script> </div> <div class="attribute-set-col fieldset-wrapper"> <div class="fieldset-wrapper-title"> <span class="title"><?php /* @escapeNotVerified */ echo __('Groups') ?></span> </div> <?php if (!$block->getIsReadOnly()): ?> - <?php /* @escapeNotVerified */ echo $block->getAddGroupButton() ?> <?php /* @escapeNotVerified */ echo $block->getDeleteGroupButton() ?> - <p class="note-block"><?php /* @escapeNotVerified */ echo __('Double click on a group to rename it.') ?></p> + <?php /* @escapeNotVerified */ echo $block->getAddGroupButton() ?> <?php /* @escapeNotVerified */ echo $block->getDeleteGroupButton() ?> + <p class="note-block"><?php /* @escapeNotVerified */ echo __('Double click on a group to rename it.') ?></p> <?php endif; ?> <?php echo $block->getSetsFilterHtml() ?> @@ -41,339 +41,359 @@ require([ <!--[if IE]> <script id="ie-deferred-loader" defer="defer" src=""></script> <![endif]--> - <script> -define("tree-panel", ["jquery", "extjs/ext-tree-checkbox", "prototype"], function(jQuery){ - - //<![CDATA[ - var allowDragAndDrop = <?php /* @escapeNotVerified */ echo($block->getIsReadOnly() ? 'false' : 'true'); ?>; - var canEditGroups = <?php /* @escapeNotVerified */ echo($block->getIsReadOnly() ? 'false' : 'true'); ?>; - - var TreePanels = function() { - // shorthand - var Tree = Ext.tree; - - return { - init : function(){ - // yui-ext tree - - var tree = new Ext.tree.TreePanel('tree-div1', { - animate:false, - loader: false, - enableDD:allowDragAndDrop, - containerScroll: true, - rootVisible: false - }); - - // set the root node - this.root = new Ext.tree.TreeNode({ - text: 'ROOT', - allowDrug:false, - allowDrop:true, - id:'1' - }); - - tree.setRootNode(this.root); - buildCategoryTree(this.root, <?php /* @escapeNotVerified */ echo $block->getGroupTreeJson() ?>); - // render the tree - tree.render(); - this.root.expand(false, false); - tree.expandAll(); - - this.ge = new Ext.tree.TreeEditor(tree, { - allowBlank:false, - blankText:'<?php /* @escapeNotVerified */ echo __('A name is required.') ?>', - selectOnFocus:true, - cls:'folder' - }); - - this.root.addListener('beforeinsert', editSet.leftBeforeInsert); - this.root.addListener('beforeappend', editSet.leftBeforeInsert); - - //this.ge.addListener('beforerender', editSet.editGroup); - this.ge.addListener('beforeshow', editSet.editGroup); - this.ge.addListener('beforecomplete', editSet.beforeRenameGroup); - //this.ge.addListener('startedit', editSet.editGroup); - - //------------------------------------------------------------- - - var tree2 = new Ext.tree.TreePanel('tree-div2', { - animate:false, - loader: false, - enableDD:allowDragAndDrop, - containerScroll: true, - rootVisible: false, - lines:false - }); - - // set the root node - this.root2 = new Ext.tree.TreeNode({ - text: 'ROOT', - draggable:false, - id:'free' - }); - tree2.setRootNode(this.root2); - buildCategoryTree(this.root2, <?php /* @escapeNotVerified */ echo $block->getAttributeTreeJson() ?>); - - this.root2.addListener('beforeinsert', editSet.rightBeforeInsert); - this.root2.addListener('beforeappend', editSet.rightBeforeAppend); - - this.root2.addListener('append', editSet.rightAppend); - this.root2.addListener('remove', editSet.rightRemove); - // render the tree - tree2.render(); - this.root2.expand(false, false); - tree2.expandAll(); - }, - - rebuildTrees : function(){ - editSet.req.attributes = new Array(); - rootNode = TreePanels.root; - var gIterator = 0; - for( i in rootNode.childNodes ) { - if(rootNode.childNodes[i].id) { - var group = rootNode.childNodes[i]; - editSet.req.groups[gIterator] = new Array(group.id, group.attributes.text.strip(), (gIterator+1)); - var iterator = 0 - for( j in group.childNodes ) { - iterator ++; - if( group.childNodes[j].id > 0 ) { - editSet.req.attributes[group.childNodes[j].id] = new Array(group.childNodes[j].id, group.id, iterator, group.childNodes[j].attributes.entity_id); + <script> + define("tree-panel", + [ + "jquery", + "Magento_Ui/js/modal/prompt", + "Magento_Ui/js/modal/alert", + "extjs/ext-tree-checkbox", + "prototype" + ], function(jQuery, prompt, alert){ + + //<![CDATA[ + var allowDragAndDrop = <?php /* @escapeNotVerified */ echo($block->getIsReadOnly() ? 'false' : 'true'); ?>; + var canEditGroups = <?php /* @escapeNotVerified */ echo($block->getIsReadOnly() ? 'false' : 'true'); ?>; + + var TreePanels = function() { + // shorthand + var Tree = Ext.tree; + + return { + init : function(){ + // yui-ext tree + + var tree = new Ext.tree.TreePanel('tree-div1', { + animate:false, + loader: false, + enableDD:allowDragAndDrop, + containerScroll: true, + rootVisible: false + }); + + // set the root node + this.root = new Ext.tree.TreeNode({ + text: 'ROOT', + allowDrug:false, + allowDrop:true, + id:'1' + }); + + tree.setRootNode(this.root); + buildCategoryTree(this.root, <?php /* @escapeNotVerified */ echo $block->getGroupTreeJson() ?>); + // render the tree + tree.render(); + this.root.expand(false, false); + tree.expandAll(); + + this.ge = new Ext.tree.TreeEditor(tree, { + allowBlank:false, + blankText:'<?php /* @escapeNotVerified */ echo __('A name is required.') ?>', + selectOnFocus:true, + cls:'folder' + }); + + this.root.addListener('beforeinsert', editSet.leftBeforeInsert); + this.root.addListener('beforeappend', editSet.leftBeforeInsert); + + //this.ge.addListener('beforerender', editSet.editGroup); + this.ge.addListener('beforeshow', editSet.editGroup); + this.ge.addListener('beforecomplete', editSet.beforeRenameGroup); + //this.ge.addListener('startedit', editSet.editGroup); + + //------------------------------------------------------------- + + var tree2 = new Ext.tree.TreePanel('tree-div2', { + animate:false, + loader: false, + enableDD:allowDragAndDrop, + containerScroll: true, + rootVisible: false, + lines:false + }); + + // set the root node + this.root2 = new Ext.tree.TreeNode({ + text: 'ROOT', + draggable:false, + id:'free' + }); + tree2.setRootNode(this.root2); + buildCategoryTree(this.root2, <?php /* @escapeNotVerified */ echo $block->getAttributeTreeJson() ?>); + + this.root2.addListener('beforeinsert', editSet.rightBeforeInsert); + this.root2.addListener('beforeappend', editSet.rightBeforeAppend); + + this.root2.addListener('append', editSet.rightAppend); + this.root2.addListener('remove', editSet.rightRemove); + // render the tree + tree2.render(); + this.root2.expand(false, false); + tree2.expandAll(); + }, + + rebuildTrees : function(){ + editSet.req.attributes = new Array(); + rootNode = TreePanels.root; + var gIterator = 0; + for( i in rootNode.childNodes ) { + if(rootNode.childNodes[i].id) { + var group = rootNode.childNodes[i]; + editSet.req.groups[gIterator] = new Array(group.id, group.attributes.text.strip(), (gIterator+1)); + var iterator = 0 + for( j in group.childNodes ) { + iterator ++; + if( group.childNodes[j].id > 0 ) { + editSet.req.attributes[group.childNodes[j].id] = new Array(group.childNodes[j].id, group.id, iterator, group.childNodes[j].attributes.entity_id); + } } + iterator = 0; } - iterator = 0; + gIterator ++; } - gIterator ++; - } - editSet.req.not_attributes = new Array(); - rootNode = TreePanels.root2; + editSet.req.not_attributes = new Array(); + rootNode = TreePanels.root2; - var iterator = 0; - for( i in rootNode.childNodes ) { - if(rootNode.childNodes[i].id) { - if( rootNode.childNodes[i].id > 0 ) { - editSet.req.not_attributes[iterator] = rootNode.childNodes[i].attributes.entity_id; + var iterator = 0; + for( i in rootNode.childNodes ) { + if(rootNode.childNodes[i].id) { + if( rootNode.childNodes[i].id > 0 ) { + editSet.req.not_attributes[iterator] = rootNode.childNodes[i].attributes.entity_id; + } + iterator ++; } - iterator ++; } } - } - }; - }(); - - function buildCategoryTree(parent, config){ - if (!config) return null; - if (parent && config && config.length){ - for (var i = 0; i < config.length; i++) { - var node = new Ext.tree.TreeNode(config[i]); - parent.appendChild(node); - node.addListener('click', editSet.register); - node.addListener('beforemove', editSet.groupBeforeMove); - node.addListener('beforeinsert', editSet.groupBeforeInsert); - node.addListener('beforeappend', editSet.groupBeforeInsert); - if( config[i].children ) { - for( j in config[i].children ) { - if(config[i].children[j].id) { - newNode = new Ext.tree.TreeNode(config[i].children[j]); - node.appendChild(newNode); - newNode.addListener('click', editSet.unregister); + }; + }(); + + function buildCategoryTree(parent, config){ + if (!config) return null; + if (parent && config && config.length){ + for (var i = 0; i < config.length; i++) { + var node = new Ext.tree.TreeNode(config[i]); + parent.appendChild(node); + node.addListener('click', editSet.register); + node.addListener('beforemove', editSet.groupBeforeMove); + node.addListener('beforeinsert', editSet.groupBeforeInsert); + node.addListener('beforeappend', editSet.groupBeforeInsert); + if( config[i].children ) { + for( j in config[i].children ) { + if(config[i].children[j].id) { + newNode = new Ext.tree.TreeNode(config[i].children[j]); + node.appendChild(newNode); + newNode.addListener('click', editSet.unregister); + } } } } } } - } - - editSet = function() { - return { - register : function(node) { - editSet.currentNode = node; - }, - unregister : function() { - editSet.currentNode = false; - }, + editSet = function() { + return { + register : function(node) { + editSet.currentNode = node; + }, - submit : function() { - if( TreePanels.root.firstChild == TreePanels.root.lastChild ) { - return; - } + unregister : function() { + editSet.currentNode = false; + }, - if( editSet.SystemNodesExists(editSet.currentNode) ) { - alert('<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('This group contains system attributes. Please move system attributes to another group and try again.')) ?>'); - return; - } + submit : function() { + if( TreePanels.root.firstChild == TreePanels.root.lastChild ) { + return; + } + if( editSet.SystemNodesExists(editSet.currentNode) ) { + alert({ + content: '<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('This group contains system attributes. Please move system attributes to another group and try again.')) ?>' + }); + return; + } - if( editSet.currentNode && editSet.currentNode.attributes.cls == 'folder' ) { - TreePanels.root.removeChild(editSet.currentNode); - for( i in editSet.currentNode.childNodes ) { - if( editSet.currentNode.childNodes[i].id ) { - child = editSet.currentNode.childNodes[i]; - newNode = new Ext.tree.TreeNode(child.attributes); + if( editSet.currentNode && editSet.currentNode.attributes.cls == 'folder' ) { + TreePanels.root.removeChild(editSet.currentNode); + for( i in editSet.currentNode.childNodes ) { + if( editSet.currentNode.childNodes[i].id ) { + child = editSet.currentNode.childNodes[i]; + newNode = new Ext.tree.TreeNode(child.attributes); - if( child.attributes.is_user_defined == 1 ) { - TreePanels.root2.appendChild(newNode); + if( child.attributes.is_user_defined == 1 ) { + TreePanels.root2.appendChild(newNode); + } } } + editSet.req.removeGroups[editSet.currentNode.id] = editSet.currentNode.id; + editSet.currentNode = false; } - editSet.req.removeGroups[editSet.currentNode.id] = editSet.currentNode.id; - editSet.currentNode = false; - } - }, - - SystemNodesExists : function(currentNode) { - for (i in currentNode.childNodes) { - if (currentNode.childNodes[i].id) { - child = editSet.currentNode.childNodes[i]; - if (child.attributes.is_unassignable != 1) { - return true; + }, + + SystemNodesExists : function(currentNode) { + for (i in currentNode.childNodes) { + if (currentNode.childNodes[i].id) { + child = editSet.currentNode.childNodes[i]; + if (child.attributes.is_unassignable != 1) { + return true; + } } } - } - }, - - rightAppend : function(node) { - return; - }, + }, - addGroup : function() { - var group_name = prompt("<?php /* @escapeNotVerified */ echo __('Please enter a new group name.') ?>",""); - if (!group_name) { + rightAppend : function(node) { return; - } - group_name = group_name.strip(); - if( group_name == '' ) { - this.addGroup(); - } else if( group_name != false && group_name != null && group_name != '' ) { + }, + + addGroup : function() { + prompt({ + content: "<?php /* @escapeNotVerified */ echo __('Please enter a new group name.') ?>", + value: "", + actions: { + confirm: function (group_name) { + group_name = group_name.strip(); + if( group_name == '' ) { + self.addGroup(); + } else if( group_name != false && group_name != null && group_name != '' ) { + + if (!editSet.validateGroupName(group_name, 0)) { + return; + } + + var newNode = new Ext.tree.TreeNode({ + text : group_name.escapeHTML(), + cls : 'folder', + allowDrop : true, + allowDrag : true + }); + TreePanels.root.appendChild(newNode); + newNode.addListener('beforemove', editSet.groupBeforeMove); + newNode.addListener('beforeinsert', editSet.groupBeforeInsert); + newNode.addListener('beforeappend', editSet.groupBeforeInsert); + newNode.addListener('click', editSet.register); + } + } + } + }); + }, - if (!editSet.validateGroupName(group_name, 0)) { - return; + editGroup : function(obj) { + if( obj.editNode.attributes.cls != 'folder' || !canEditGroups) { + TreePanels.ge.cancelEdit(); + return false; } + }, - var newNode = new Ext.tree.TreeNode({ - text : group_name.escapeHTML(), - cls : 'folder', - allowDrop : true, - allowDrag : true - }); - TreePanels.root.appendChild(newNode); - newNode.addListener('beforemove', editSet.groupBeforeMove); - newNode.addListener('beforeinsert', editSet.groupBeforeInsert); - newNode.addListener('beforeappend', editSet.groupBeforeInsert); - newNode.addListener('click', editSet.register); - } - }, - - editGroup : function(obj) { - if( obj.editNode.attributes.cls != 'folder' || !canEditGroups) { - TreePanels.ge.cancelEdit(); - return false; - } - }, + beforeRenameGroup : function(obj, after, before) { + return editSet.validateGroupName(after, obj.editNode.id); + }, - beforeRenameGroup : function(obj, after, before) { - return editSet.validateGroupName(after, obj.editNode.id); - }, + validateGroupName : function(name, exceptNodeId) { + name = name.strip(); + var result = true; + if (name === '') { + result = false; + } + for (var i=0; i < TreePanels.root.childNodes.length; i++) { + if (TreePanels.root.childNodes[i].text.toLowerCase() == name.toLowerCase() && TreePanels.root.childNodes[i].id != exceptNodeId) { + errorText = '<?php /* @escapeNotVerified */ echo __('An attribute group named "/name/" already exists".') ?>'; + alert({ + content: errorText.replace("/name/",name) + }); + result = false; + } + } + return result; + }, - validateGroupName : function(name, exceptNodeId) { - name = name.strip(); - var result = true; - if (name === '') { - result = false; - } - for (var i=0; i < TreePanels.root.childNodes.length; i++) { - if (TreePanels.root.childNodes[i].text.toLowerCase() == name.toLowerCase() && TreePanels.root.childNodes[i].id != exceptNodeId) { - errorText = '<?php /* @escapeNotVerified */ echo __('An attribute group named "/name/" already exists".') ?>'; - alert(errorText.replace("/name/",name)); - result = false; + save : function() { + if ($('messages')) { + $('messages').update(); } - } - return result; - }, + TreePanels.rebuildTrees(); + if(!jQuery('#set-prop-form').valid()) { + return; + } + editSet.req.attribute_set_name = $('attribute_set_name').value; + if (!editSet.req.form_key) { + editSet.req.form_key = FORM_KEY; + } + var req = {data : Ext.util.JSON.encode(editSet.req)}; + var con = new Ext.lib.Ajax.request('POST', '<?php /* @escapeNotVerified */ echo $block->getMoveUrl() ?>', {success:editSet.success,failure:editSet.failure}, req); + }, + + success : function(o) { + var response = Ext.util.JSON.decode(o.responseText); + if( response.error ) { + $('messages').update(response.message); + } else if( response.ajaxExpired && response.ajaxRedirect ){ + setLocation(response.ajaxRedirect); + } else if( response.url ){ + setLocation(response.url); + } else if( response.message ) { + $('messages').update(response.message); + } + }, - save : function() { - if ($('messages')) { - $('messages').update(); - } - TreePanels.rebuildTrees(); - if(!jQuery('#set-prop-form').valid()) { - return; - } - editSet.req.attribute_set_name = $('attribute_set_name').value; - if (!editSet.req.form_key) { - editSet.req.form_key = FORM_KEY; - } - var req = {data : Ext.util.JSON.encode(editSet.req)}; - var con = new Ext.lib.Ajax.request('POST', '<?php /* @escapeNotVerified */ echo $block->getMoveUrl() ?>', {success:editSet.success,failure:editSet.failure}, req); - }, - - success : function(o) { - var response = Ext.util.JSON.decode(o.responseText); - if( response.error ) { - $('messages').update(response.message); - } else if( response.ajaxExpired && response.ajaxRedirect ){ - setLocation(response.ajaxRedirect); - } else if( response.url ){ - setLocation(response.url); - } else if( response.message ) { - $('messages').update(response.message); - } - }, + failure : function(o) { + alert({ + content: '<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('Sorry, we\'re unable to complete this request.')) ?>' + }); + }, - failure : function(o) { - alert('<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('Sorry, we\'re unable to complete this request.')) ?>'); - }, + groupBeforeMove : function(tree, nodeThis, oldParent, newParent) { + if( newParent.attributes.cls == 'folder' && nodeThis.attributes.cls == 'folder' ) { + return false; + } - groupBeforeMove : function(tree, nodeThis, oldParent, newParent) { - if( newParent.attributes.cls == 'folder' && nodeThis.attributes.cls == 'folder' ) { - return false; - } + if( newParent == TreePanels.root && nodeThis.attributes.cls != 'folder' ) { + return false; + } + }, - if( newParent == TreePanels.root && nodeThis.attributes.cls != 'folder' ) { - return false; - } - }, - - rightBeforeAppend : function(tree, nodeThis, node, newParent) { - if (node.attributes.is_user_defined == 0) { - alert('<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('You can\'t remove attributes from this product template.')) ?>'); - return false; - } else { - return true; - } - }, + rightBeforeAppend : function(tree, nodeThis, node, newParent) { + if (node.attributes.is_user_defined == 0) { + alert({ + content: '<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('You can\'t remove attributes from this product template.')) ?>' + }); + return false; + } else { + return true; + } + }, - rightBeforeInsert : function(tree, nodeThis, node, newParent) { - var empty = TreePanels.root2.findChild('id', 'empty'); - if (empty) { - return false; - } + rightBeforeInsert : function(tree, nodeThis, node, newParent) { + var empty = TreePanels.root2.findChild('id', 'empty'); + if (empty) { + return false; + } - if (node.attributes.is_unassignable == 0) { - alert('<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('You can\'t remove attributes from this product template.')) ?>'); - return false; - } else { - return true; - } - }, + if (node.attributes.is_unassignable == 0) { + alert({ + content: '<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('You can\'t remove attributes from this product template.')) ?>' + }); + return false; + } else { + return true; + } + }, - groupBeforeInsert : function(tree, nodeThis, node, newParent) { - if( node.allowChildren ) { - return false; - } - }, + groupBeforeInsert : function(tree, nodeThis, node, newParent) { + if( node.allowChildren ) { + return false; + } + }, - rightAppend : function(tree, nodeThis, node) { - var empty = TreePanels.root2.findChild('id', 'empty'); - if( empty && node.id != 'empty' ) { - TreePanels.root2.removeChild(empty); - } - }, + rightAppend : function(tree, nodeThis, node) { + var empty = TreePanels.root2.findChild('id', 'empty'); + if( empty && node.id != 'empty' ) { + TreePanels.root2.removeChild(empty); + } + }, - rightRemove : function(tree, nodeThis, node) { - if( nodeThis.firstChild == null && node.id != 'empty' ) { - var newNode = new Ext.tree.TreeNode({ + rightRemove : function(tree, nodeThis, node) { + if( nodeThis.firstChild == null && node.id != 'empty' ) { + var newNode = new Ext.tree.TreeNode({ text : '<?php /* @escapeNotVerified */ echo __('Empty') ?>', id : 'empty', cls : 'folder', @@ -381,35 +401,35 @@ define("tree-panel", ["jquery", "extjs/ext-tree-checkbox", "prototype"], functio allowDrop : false, allowDrag : false }); - TreePanels.root2.appendChild(newNode); - } - }, + TreePanels.root2.appendChild(newNode); + } + }, - leftBeforeInsert : function(tree, nodeThis, node, newParent) { - if( node.allowChildren == false ) { - return false; + leftBeforeInsert : function(tree, nodeThis, node, newParent) { + if( node.allowChildren == false ) { + return false; + } } } + }(); + + function initVars() { + editSet.req = {}; + editSet.req.attributes = false; + editSet.req.groups = new Array(); + editSet.req.not_attributes = false; + editSet.req.attribute_set_name = false; + editSet.req.removeGroups = new Array(); } - }(); - - function initVars() { - editSet.req = {}; - editSet.req.attributes = false; - editSet.req.groups = new Array(); - editSet.req.not_attributes = false; - editSet.req.attribute_set_name = false; - editSet.req.removeGroups = new Array(); - } - - jQuery(function() { - initVars(); - TreePanels.init(); - }); - //]]> -}); -require(["tree-panel"]); -</script> + jQuery(function() { + initVars(); + TreePanels.init(); + }); + //]]> + + }); + require(["tree-panel"]); + </script> </div> </div> diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/wysiwyg/js.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/wysiwyg/js.phtml index c7223ed509f4d6439fa3b9b1299c9ef3de99d91e..d6db808caccad1390c65cc00264cd80a2f6c3bb2 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/wysiwyg/js.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/wysiwyg/js.phtml @@ -5,15 +5,15 @@ */ // @codingStandardsIgnoreFile - ?> <script> require([ "jquery", "tinymce", + "Magento_Ui/js/modal/modal", "prototype", "mage/adminhtml/events" -], function(jQuery, tinyMCE){ +], function(jQuery, tinyMCE, modal){ //<![CDATA[ @@ -21,6 +21,7 @@ Window.keepMultiModalWindow = true; var catalogWysiwygEditor = { overlayShowEffectOptions : null, overlayHideEffectOptions : null, + modal: null, open : function(editorUrl, elementId) { if (editorUrl && elementId) { jQuery.ajax({ @@ -32,43 +33,40 @@ var catalogWysiwygEditor = { showLoader: true, dataType: 'html', success: function(data, textStatus, transport) { - try { - this.openDialogWindow(data, elementId); - } catch(e) { - alert(e.message); - } + this.openDialogWindow(data, elementId); }.bind(this) }); } }, - openDialogWindow : function(content, elementId) { - this.overlayShowEffectOptions = Windows.overlayShowEffectOptions; - this.overlayHideEffectOptions = Windows.overlayHideEffectOptions; - Windows.overlayShowEffectOptions = {duration:0}; - Windows.overlayHideEffectOptions = {duration:0}; - tinyMCE.editors[elementId].save(); - Dialog.confirm(content, { - draggable:true, - resizable:true, - closable:true, - className:"magento", - windowClassName:"popup-window", - title:'WYSIWYG Editor', - width:950, - height:555, - recenterAuto:false, - hideEffect:Element.hide, - showEffect:Element.show, - id:"catalog-wysiwyg-editor", - buttonClass:"form-button", - okLabel:"Submit", - ok: this.okDialogWindow.bind(this), - cancel: this.closeDialogWindow.bind(this), - onClose: this.closeDialogWindow.bind(this), - firedElementId: elementId - }); + openDialogWindow : function(data, elementId) { + var self = this; + + if (this.modal) { + this.modal.html(jQuery(data).html()); + } else { + this.modal = jQuery(data).modal({ + title: 'WYSIWYG Editor', + modalClass: 'magento', + type: 'slide', + firedElementId: elementId, + buttons: [{ + text: 'Cancel', + click: function () { + self.closeDialogWindow(this); + } + },{ + text: 'Submit', + click: function () { + self.okDialogWindow(this); + } + }], + close: function () { + self.closeDialogWindow(this); + } + }); + } + this.modal.modal('openModal'); $(elementId + '_editor').value = $(elementId).value; - content.evalScripts.bind(content).defer(); }, okDialogWindow : function(dialogWindow) { if (dialogWindow.options.firedElementId) { @@ -104,7 +102,7 @@ var catalogWysiwygEditor = { tinyMCE.execCommand('mceRemoveControl', true, wysiwygObj.id); } - dialogWindow.close(); + dialogWindow.closeModal(); Windows.overlayShowEffectOptions = this.overlayShowEffectOptions; Windows.overlayHideEffectOptions = this.overlayHideEffectOptions; } diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml index 04ae1205b1e3a462c3ada0ad7f698357fce1865a..e1bdb4dbcb9be3a0a27e23813425161228673143 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml @@ -40,17 +40,13 @@ <bookmark name="bookmarks"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> - <item name="displayArea" xsi:type="string">dataGridActions</item> <item name="storageConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> - <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> <item name="namespace" xsi:type="string">product_listing</item> </item> </item> </argument> </bookmark> - <container name="columns_controls"> + <component name="columns_controls"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/columns</item> @@ -60,129 +56,27 @@ </item> </item> </argument> - </container> - <filters name="listing_filters" class="Magento\Catalog\Ui\Component\Listing\Filters"> + </component> + <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="displayArea" xsi:type="string">dataGridFilters</item> - <item name="dataScope" xsi:type="string">filters</item> + <item name="columnsProvider" xsi:type="string">product_listing.product_listing.product_columns</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">product_listing.product_listing.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.filters</item> </item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">product_listing.product_listing.listing_top.listing_filters</item> - <item name="imports" xsi:type="array"> - <item name="visible" xsi:type="string">product_listing.product_listing.listing_top.bookmarks:current.columns.${ $.index }.visible</item> - </item> - </item> </item> </argument> - <filterInput name="name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">name</item> - <item name="label" xsi:type="string" translate="true">Name</item> - </item> - </argument> - </filterInput> - <filterSelect name="type_id"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Catalog\Model\Product\Type</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">type_id</item> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="label" xsi:type="string" translate="true">Type</item> - </item> - </argument> - </filterSelect> - <filterSelect name="attribute_set_id"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Catalog\Model\Product\AttributeSet\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">attribute_set_id</item> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="label" xsi:type="string" translate="true">Attribute Set</item> - </item> - </argument> - </filterSelect> - <filterInput name="sku"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">sku</item> - <item name="label" xsi:type="string" translate="true">SKU</item> - </item> - </argument> - </filterInput> - <filterRange name="price"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">price</item> - <item name="label" xsi:type="string" translate="true">Price</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">product_listing.product_listing.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">from</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">to</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterSelect name="visibility"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Catalog\Model\Product\Visibility</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">visibility</item> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="label" xsi:type="string" translate="true">Visibility</item> - </item> - </argument> - </filterSelect> - <filterSelect name="status"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Catalog\Model\Product\Attribute\Source\Status</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">status</item> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="label" xsi:type="string" translate="true">Status</item> - </item> - </argument> - </filterSelect> <filterSelect name="store_id"> <argument name="optionsProvider" xsi:type="configurableObject"> <argument name="class" xsi:type="string">Magento\Store\Ui\Component\Listing\Column\Store\Options</argument> </argument> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> + <item name="provider" xsi:type="string">product_listing.product_listing.listing_top.listing_filters</item> <item name="dataScope" xsi:type="string">store_id</item> <item name="caption" xsi:type="string" translate="true">All Store Views</item> <item name="label" xsi:type="string" translate="true">Store View</item> - <item name="imports" xsi:type="array"> - <item name="visible" xsi:type="string"></item> - </item> </item> </argument> </filterSelect> @@ -192,7 +86,6 @@ <item name="config" xsi:type="array"> <item name="selectProvider" xsi:type="string">product_listing.product_listing.product_columns.ids</item> <item name="component" xsi:type="string">Magento_Ui/js/grid/tree-massactions</item> - <item name="displayArea" xsi:type="string">bottom</item> <item name="indexField" xsi:type="string">entity_id</item> </item> </argument> @@ -251,7 +144,6 @@ <item name="provider" xsi:type="string">product_listing.product_listing.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.paging</item> </item> - <item name="displayArea" xsi:type="string">bottom</item> </item> </argument> </paging> @@ -272,7 +164,6 @@ <item name="1" xsi:type="string">${ $.$data.rowIndex }</item> </item> </item> - <item name="controlVisibility" xsi:type="boolean">true</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">product_listing.product_listing.listing_top.bookmarks</item> <item name="root" xsi:type="string">columns.${ $.index }</item> @@ -281,27 +172,19 @@ </item> </item> </argument> - <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <selectionsColumn name="ids"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> - </item> <item name="config" xsi:type="array"> - <item name="controlVisibility" xsi:type="boolean">false</item> <item name="indexField" xsi:type="string">entity_id</item> <item name="sortOrder" xsi:type="number">0</item> </item> </argument> - </column> + </selectionsColumn> <column name="entity_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> + <item name="filter" xsi:type="string">textRange</item> <item name="sorting" xsi:type="string">asc</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">ID</item> <item name="sortOrder" xsi:type="number">10</item> </item> @@ -309,16 +192,12 @@ </column> <column name="thumbnail" class="Magento\Catalog\Ui\Component\Listing\Columns\Thumbnail"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/thumbnail</item> - </item> <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/thumbnail</item> <item name="add_field" xsi:type="boolean">true</item> <item name="sortable" xsi:type="boolean">false</item> <item name="altField" xsi:type="string">name</item> <item name="has_preview" xsi:type="string">1</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Thumbnail</item> <item name="sortOrder" xsi:type="number">20</item> </item> @@ -326,13 +205,9 @@ </column> <column name="name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="add_field" xsi:type="boolean">true</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Name</item> <item name="sortOrder" xsi:type="number">30</item> </item> @@ -341,12 +216,10 @@ <column name="type_id"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\Catalog\Model\Product\Type</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Type</item> <item name="sortOrder" xsi:type="number">40</item> </item> @@ -355,12 +228,10 @@ <column name="attribute_set_id"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\Catalog\Model\Product\AttributeSet\Options</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Attribute Set</item> <item name="sortOrder" xsi:type="number">50</item> </item> @@ -368,12 +239,8 @@ </column> <column name="sku"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">SKU</item> <item name="sortOrder" xsi:type="number">60</item> </item> @@ -381,13 +248,9 @@ </column> <column name="price" class="Magento\Catalog\Ui\Component\Listing\Columns\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="add_field" xsi:type="boolean">true</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Price</item> <item name="sortOrder" xsi:type="number">70</item> </item> @@ -396,13 +259,11 @@ <column name="visibility"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\Catalog\Model\Product\Visibility</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="add_field" xsi:type="boolean">true</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Visibility</item> <item name="sortOrder" xsi:type="number">80</item> </item> @@ -411,46 +272,35 @@ <column name="status"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\Catalog\Model\Product\Attribute\Source\Status</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="add_field" xsi:type="boolean">true</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Status</item> <item name="sortOrder" xsi:type="number">90</item> </item> </argument> </column> - <column name="websites" class="Magento\Catalog\Ui\Component\Listing\Columns\Websites"> + <column name="websites"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\Store\Model\ResourceModel\Website\Collection</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="add_field" xsi:type="boolean">true</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Websites</item> <item name="sortOrder" xsi:type="number">100</item> </item> </argument> </column> - <column name="actions" class="Magento\Catalog\Ui\Component\Listing\Columns\ProductActions"> + <actionsColumn name="actions" class="Magento\Catalog\Ui\Component\Listing\Columns\ProductActions"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> + <item name="indexField" xsi:type="string">entity_id</item> <item name="sortOrder" xsi:type="number">200</item> - <item name="dataType" xsi:type="string">actions</item> - <item name="align" xsi:type="string">left</item> - <item name="label" xsi:type="string" translate="true">Action</item> - <item name="data_type" xsi:type="string">actions</item> - <item name="filterable" xsi:type="boolean">false</item> - <item name="sortable" xsi:type="boolean">false</item> - <item name="draggable" xsi:type="boolean">false</item> </item> </argument> - </column> + </actionsColumn> </columns> </listing> diff --git a/app/code/Magento/Catalog/view/adminhtml/web/catalog/base-image-uploader.js b/app/code/Magento/Catalog/view/adminhtml/web/catalog/base-image-uploader.js index 17b5f95205fdfaeb6269c411d2c254b838060e51..de62ea60219a74287c9d2846849f8a9d297a1c08 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/catalog/base-image-uploader.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/catalog/base-image-uploader.js @@ -6,11 +6,12 @@ define([ 'jquery', 'mage/template', + 'Magento_Ui/js/modal/alert', 'jquery/ui', 'jquery/file-uploader', 'mage/translate', 'mage/backend/notification' -], function ($, mageTemplate) { +], function ($, mageTemplate, alert) { 'use strict'; $.widget('mage.baseImage', { @@ -131,7 +132,9 @@ define([ if (!data.result.error) { $galleryContainer.trigger('addItem', data.result); } else { - alert($.mage.__('We don\'t recognize or support this file extension type.')); + alert({ + content: $.mage.__('We don\'t recognize or support this file extension type.') + }); } }, change: function(e, data) { diff --git a/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/form.js b/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/form.js index 0d5be338a5a7a6ff1be672387a408459ca7ebfff..eaa65160561c9f589d1aaf2e2738a843d80069f0 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/form.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/form.js @@ -6,10 +6,11 @@ /*global Ajax:true alert:true*/ define([ "jquery", + 'Magento_Ui/js/modal/alert', "mage/backend/form", "jquery/ui", "prototype" -], function($){ +], function($, alert){ "use strict"; $.widget("mage.categoryForm", $.mage.form, { @@ -55,7 +56,9 @@ define([ if (transport.responseText.isJSON()) { var response = transport.responseText.evalJSON(); if (response.error) { - alert(response.message); + alert({ + content: response.message + }); } else { if (this.element.find(this.options.categoryIdSelector).prop('value') == response.id) { this.element.find(this.options.categoryPathSelector) diff --git a/app/code/Magento/Catalog/view/adminhtml/web/catalog/product-attributes.js b/app/code/Magento/Catalog/view/adminhtml/web/catalog/product-attributes.js index f4624937f02556dc18dd44e07c6a6da77088de4f..b48cfec50ea7bb56bc379d4c68751745506934a6 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/catalog/product-attributes.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/catalog/product-attributes.js @@ -4,8 +4,9 @@ */ define([ 'jquery', + 'underscore', 'jquery/ui' -], function ($) { +], function ($, _) { 'use strict'; $.widget('mage.productAttributes', { @@ -15,74 +16,69 @@ define([ }); }, - _prepareUrl: function () { - var name = $('[data-role=product-attribute-search]').val(); + _initModal: function () { + var self = this; - return this.options.url + - (/\?/.test(this.options.url) ? '&' : '?') + - 'set=' + $('#attribute_set_id').val() + - '&attribute[frontend_label]=' + - window.encodeURIComponent(name); - }, - - _showPopup: function (event) { - var wrapper, - iframe; - - wrapper = $('<div id="create_new_attribute"/>').appendTo('body').dialog({ - // ToDo: refactor to a sliding panel + this.modal = $('<div id="create_new_attribute"/>').modal({ title: 'New Attribute', - width: '75%', - minHeight: 650, - modal: true, - resizable: false, - resizeStop: function () { - iframe.height($(this).outerHeight() + 'px'); - iframe.width($(this).outerWidth() + 'px'); + type: 'slide', + buttons: [], + opened: function () { + self.iframe = $('<iframe id="create_new_attribute_container">').attr({ + src: self._prepareUrl(), + frameborder: 0 + }); + self.modal.append(self.iframe); + self._changeIframeSize(); + $(window).off().on('resize', _.debounce(self._changeIframeSize.bind(self), 400)); }, - position: { - my: 'left top', - at: 'center top', - of: 'body' - }, - open: function () { - $(this).closest('.ui-dialog').addClass('ui-dialog-active'); + closed: function () { + var doc = self.iframe.get(0).document; - var topMargin = jQuery(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 45; - jQuery(this).closest('.ui-dialog').css('margin-top', topMargin); - }, - close: function () { - $(this).closest('.ui-dialog').removeClass('ui-dialog-active'); + if (doc && $.isFunction(doc.execCommand)) { + //IE9 break script loading but not execution on iframe removing + doc.execCommand('stop'); + self.iframe.remove(); + } + self.modal.data('modal').modal.remove(); } }); + }, - iframe = $('<iframe id="create_new_attribute_container">').attr({ - src: this._prepareUrl(event), - frameborder: 0, - style: 'position:absolute;top:58px;left:0px;right:0px;bottom:0px' - }); + _getHeight: function () { + var modal = this.modal.data('modal').modal, + modalHead = modal.find('header'), + modalHeadHeight = modalHead.outerHeight(), + modalHeight = modal.outerHeight(), + modalContentPadding = this.modal.parent().outerHeight() - this.modal.parent().height(); - iframe.on('load', function () { - $(this).css({ - height: wrapper.outerHeight() + 'px', - width: wrapper.outerWidth() + 'px' - }); - }); + return modalHeight - modalHeadHeight - modalContentPadding; + }, - wrapper.append(iframe); + _getWidth: function () { + return this.modal.width(); + }, - wrapper.on('dialogclose', function () { - var dialog = this, - doc = iframe.get(0).document; + _changeIframeSize: function () { + this.modal.parent().outerHeight(this._getHeight()); + this.iframe.outerHeight(this._getHeight()); + this.iframe.outerWidth(this._getWidth()); - if (doc && $.isFunction(doc.execCommand)) { - //IE9 break script loading but not execution on iframe removing - doc.execCommand('stop'); - iframe.remove(); - } + }, - $(dialog).remove(); - }); + _prepareUrl: function () { + var name = $('[data-role=product-attribute-search]').val(); + + return this.options.url + + (/\?/.test(this.options.url) ? '&' : '?') + + 'set=' + $('#attribute_set_id').val() + + '&attribute[frontend_label]=' + + window.encodeURIComponent(name); + }, + + _showPopup: function () { + this._initModal(); + this.modal.modal('openModal'); } }); diff --git a/app/code/Magento/Catalog/view/adminhtml/web/catalog/product/composite/configure.js b/app/code/Magento/Catalog/view/adminhtml/web/catalog/product/composite/configure.js index 648632e2aacbe36150e3c99e4a9d22df2f136e8c..030962f2f06413a56129efbbbc6aa3c6d8b4830a 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/catalog/product/composite/configure.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/catalog/product/composite/configure.js @@ -6,651 +6,627 @@ define([ "jquery", "jquery/ui", "mage/translate", - "prototype" + "prototype", + 'Magento_Ui/js/modal/modal' ], function(jQuery){ -window.ProductConfigure = Class.create(); - -ProductConfigure.prototype = { - - listTypes: $H({}), - current: $H({}), - itemsFilter: $H({}), - blockWindow: null, - blockForm: null, - blockFormFields: null, - blockFormAdd: null, - blockFormConfirmed: null, - blockConfirmed: null, - blockIFrame: null, - blockCancelBtn: null, - blockMask: null, - blockMsg: null, - blockMsgError: null, - windowHeight: null, - confirmedCurrentId: null, - confirmCallback: {}, - cancelCallback: {}, - onLoadIFrameCallback: {}, - showWindowCallback: {}, - beforeSubmitCallback: {}, - iFrameJSVarname: null, - _listTypeId: 1, - - /** - * Initialize object - */ - initialize: function() { - this._initWindowElements(); - var self = this; - this.dialog = jQuery('#product_composite_configure').dialog({ - autoOpen: false, - title: jQuery.mage.__('Configure Product'), - modal: true, - minWidth: 500, - width: '75%', - dialogClass: 'popup-window', - position: { - my: 'left top', - at: 'center top', - of: 'body' - }, - open: function () { - jQuery(this).addClass('magento_message').css('max-height', '500px'); - jQuery(this).closest('.ui-dialog').addClass('ui-dialog-active'); - - var topMargin = jQuery(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 30; - jQuery(this).closest('.ui-dialog').css('margin-top', topMargin); - }, - close: function() { - jQuery(this).closest('.ui-dialog').removeClass('ui-dialog-active'); - }, - buttons: [{ - text: jQuery.mage.__('OK'), - 'class': 'action-primary', - click: function() { - self.onConfirmBtn(); - } - }, { - id: "product_composite_configure_form_cancel", - text: "Cancel", - 'class': 'action-close', - click: function() { - jQuery(this).dialog("close"); - } - }] - }); - }, - - /** - * Initialize window elements - */ - _initWindowElements: function() { - this.blockWindow = $('product_composite_configure'); - this.blockForm = $('product_composite_configure_form'); - this.blockFormFields = $('product_composite_configure_form_fields'); - this.blockFormAdd = $('product_composite_configure_form_additional'); - this.blockFormConfirmed = $('product_composite_configure_form_confirmed'); - this.blockConfirmed = $('product_composite_configure_confirmed'); - this.blockIFrame = $('product_composite_configure_iframe'); - this.blockCancelBtn = $('product_composite_configure_form_cancel'); - this.blockMsg = $('product_composite_configure_messages'); - this.blockMsgError = this.blockMsg.select('.message.error div')[0]; - this.iFrameJSVarname = this.blockForm.select('input[name="as_js_varname"]')[0].value; - }, - - /** - * Returns next unique list type id - */ - _generateListTypeId: function () { - return '_internal_lt_' + (this._listTypeId++); - }, - - /** - * Add product list types as scope and their urls - * expamle: addListType('product_to_add', {urlFetch: 'http://magento...'}) - * expamle: addListType('wishlist', {urlSubmit: 'http://magento...'}) - * - * @param type types as scope - * @param urls obj can be - * - {urlFetch: 'http://magento...'} for fetching configuration fields through ajax - * - {urlConfirm: 'http://magento...'} for submit configured data through iFrame when clicked confirm button - * - {urlSubmit: 'http://magento...'} for submit configured data through iFrame - */ - addListType: function(type, urls) { - if ('undefined' == typeof this.listTypes[type]) { + window.ProductConfigure = Class.create(); + + ProductConfigure.prototype = { + + listTypes: $H({}), + current: $H({}), + itemsFilter: $H({}), + blockWindow: null, + blockForm: null, + blockFormFields: null, + blockFormAdd: null, + blockFormConfirmed: null, + blockConfirmed: null, + blockIFrame: null, + blockCancelBtn: null, + blockMask: null, + blockMsg: null, + blockMsgError: null, + windowHeight: null, + confirmedCurrentId: null, + confirmCallback: {}, + cancelCallback: {}, + onLoadIFrameCallback: {}, + showWindowCallback: {}, + beforeSubmitCallback: {}, + iFrameJSVarname: null, + _listTypeId: 1, + + /** + * Initialize object + */ + initialize: function() { + var self = this; + + this._initWindowElements(); + this.dialog = jQuery('#product_composite_configure').modal({ + title: jQuery.mage.__('Configure Product'), + type: 'slide', + buttons: [{ + text: jQuery.mage.__('OK'), + 'class': 'action-primary', + click: function () { + self.onConfirmBtn(); + } + }] + }); + }, + + /** + * Initialize window elements + */ + _initWindowElements: function() { + this.blockWindow = $('product_composite_configure'); + this.blockForm = $('product_composite_configure_form'); + this.blockFormFields = $('product_composite_configure_form_fields'); + this.blockFormAdd = $('product_composite_configure_form_additional'); + this.blockFormConfirmed = $('product_composite_configure_form_confirmed'); + this.blockConfirmed = $('product_composite_configure_confirmed'); + this.blockIFrame = $('product_composite_configure_iframe'); + this.blockCancelBtn = $('product_composite_configure_form_cancel'); + this.blockMsg = $('product_composite_configure_messages'); + this.blockMsgError = this.blockMsg.select('.message.error div')[0]; + this.iFrameJSVarname = this.blockForm.select('input[name="as_js_varname"]')[0].value; + }, + + /** + * Returns next unique list type id + */ + _generateListTypeId: function () { + return '_internal_lt_' + (this._listTypeId++); + }, + + /** + * Add product list types as scope and their urls + * expamle: addListType('product_to_add', {urlFetch: 'http://magento...'}) + * expamle: addListType('wishlist', {urlSubmit: 'http://magento...'}) + * + * @param type types as scope + * @param urls obj can be + * - {urlFetch: 'http://magento...'} for fetching configuration fields through ajax + * - {urlConfirm: 'http://magento...'} for submit configured data through iFrame when clicked confirm button + * - {urlSubmit: 'http://magento...'} for submit configured data through iFrame + */ + addListType: function(type, urls) { + if ('undefined' == typeof this.listTypes[type]) { + this.listTypes[type] = {}; + } + Object.extend(this.listTypes[type], urls); + return this; + }, + + /** + * Adds complex list type - that is used to submit several list types at once + * Only urlSubmit is possible for this list type + * expamle: addComplexListType(['wishlist', 'product_list'], 'http://magento...') + * + * @param type types as scope + * @param urls obj can be + * - {urlSubmit: 'http://magento...'} for submit configured data through iFrame + * @return type string + */ + addComplexListType: function(types, urlSubmit) { + var type = this._generateListTypeId(); this.listTypes[type] = {}; - } - Object.extend(this.listTypes[type], urls); - return this; - }, - - /** - * Adds complex list type - that is used to submit several list types at once - * Only urlSubmit is possible for this list type - * expamle: addComplexListType(['wishlist', 'product_list'], 'http://magento...') - * - * @param type types as scope - * @param urls obj can be - * - {urlSubmit: 'http://magento...'} for submit configured data through iFrame - * @return type string - */ - addComplexListType: function(types, urlSubmit) { - var type = this._generateListTypeId(); - this.listTypes[type] = {}; - this.listTypes[type].complexTypes = types; - this.listTypes[type].urlSubmit = urlSubmit; - return type; - }, - - /** - * Add filter of items - * - * @param listType scope name - * @param itemsFilter - */ - addItemsFilter: function(listType, itemsFilter) { - if (!listType || !itemsFilter) { - return false; - } - if ('undefined' == typeof this.itemsFilter[listType]) { - this.itemsFilter[listType] = []; - } - this.itemsFilter[listType] = this.itemsFilter[listType].concat(itemsFilter); - return this; - }, - - /** - * Returns id of block where configuration for an item is stored - * - * @param listType scope name - * @param itemId - * @return string - */ - _getConfirmedBlockId: function (listType, itemId) { - return this.blockConfirmed.id + '[' + listType + '][' + itemId + ']'; - }, - - /** - * Checks whether item has some configuration fields - * - * @param listType scope name - * @param itemId - * @return bool - */ - itemConfigured: function (listType, itemId) { - var confirmedBlockId = this._getConfirmedBlockId(listType, itemId); - var itemBlock = $(confirmedBlockId); - return !!(itemBlock && itemBlock.innerHTML); - }, - - /** - * Show configuration fields of item, if it not found then get it through ajax - * - * @param listType scope name - * @param itemId - */ - showItemConfiguration: function(listType, itemId) { - if (!listType || !itemId) { - return false; - } + this.listTypes[type].complexTypes = types; + this.listTypes[type].urlSubmit = urlSubmit; + return type; + }, - this.initialize(); - this.current.listType = listType; - this.current.itemId = itemId; - this.confirmedCurrentId = this._getConfirmedBlockId(listType, itemId); + /** + * Add filter of items + * + * @param listType scope name + * @param itemsFilter + */ + addItemsFilter: function(listType, itemsFilter) { + if (!listType || !itemsFilter) { + return false; + } + if ('undefined' == typeof this.itemsFilter[listType]) { + this.itemsFilter[listType] = []; + } + this.itemsFilter[listType] = this.itemsFilter[listType].concat(itemsFilter); + return this; + }, - if (!this.itemConfigured(listType, itemId)) { - this._requestItemConfiguration(listType, itemId); - } else { - this._processFieldsData('item_restore'); - this._showWindow(); - } - }, - - /** - * Get configuration fields of product through ajax and show them - * - * @param listType scope name - * @param itemId - */ - _requestItemConfiguration: function(listType, itemId) { - if (!this.listTypes[listType].urlFetch) { - return false; - } - var url = this.listTypes[listType].urlFetch; - if (url) { - new Ajax.Request(url, { - parameters: {id: itemId}, - onSuccess: function(transport) { - var response = transport.responseText; - if (response.isJSON()) { - response = response.evalJSON(); - if (response.error) { - this.blockMsg.show(); - this.blockMsgError.innerHTML = response.message; - this.blockCancelBtn.hide(); - this.setConfirmCallback(listType, null); - this._showWindow(); - } - } else if (response) { - response = response + ''; - this.blockFormFields.update(response); + /** + * Returns id of block where configuration for an item is stored + * + * @param listType scope name + * @param itemId + * @return string + */ + _getConfirmedBlockId: function (listType, itemId) { + return this.blockConfirmed.id + '[' + listType + '][' + itemId + ']'; + }, - // Add special div to hold mage data, e.g. scripts to execute on every popup show - var mageData = {}; - var scripts = response.extractScripts(); - mageData.scripts = scripts; + /** + * Checks whether item has some configuration fields + * + * @param listType scope name + * @param itemId + * @return bool + */ + itemConfigured: function (listType, itemId) { + var confirmedBlockId = this._getConfirmedBlockId(listType, itemId); + var itemBlock = $(confirmedBlockId); + return !!(itemBlock && itemBlock.innerHTML); + }, - var scriptHolder = new Element('div', {'style': 'display:none'}); - scriptHolder.mageData = mageData; - this.blockFormFields.insert(scriptHolder); + /** + * Show configuration fields of item, if it not found then get it through ajax + * + * @param listType scope name + * @param itemId + */ + showItemConfiguration: function(listType, itemId) { + if (!listType || !itemId) { + return false; + } - // Show window - this._showWindow(); - } - }.bind(this) - }); - } - }, - - /** - * Triggered on confirm button click - * Do submit configured data through iFrame if needed - */ - onConfirmBtn: function() { - if (jQuery(this.blockForm).valid()) { - if (this.listTypes[this.current.listType].urlConfirm) { - this.submit(); + this.initialize(); + this.current.listType = listType; + this.current.itemId = itemId; + this.confirmedCurrentId = this._getConfirmedBlockId(listType, itemId); + + if (!this.itemConfigured(listType, itemId)) { + this._requestItemConfiguration(listType, itemId); } else { - this._processFieldsData('item_confirm'); - this._closeWindow(); - if (Object.isFunction(this.confirmCallback[this.current.listType])) { - this.confirmCallback[this.current.listType](); - } + this._processFieldsData('item_restore'); + this._showWindow(); } - } - return this; - }, - - /** - * Triggered on cancel button click - */ - onCancelBtn: function() { - this._closeWindow(); - if (Object.isFunction(this.cancelCallback[this.current.listType])) { - this.cancelCallback[this.current.listType](); - } - return this; - }, - - /** - * Submit configured data through iFrame - * - * @param listType scope name - */ - submit: function (listType) { - // prepare data - if (listType) { - this.current.listType = listType; - this.current.itemId = null; - } - var urlConfirm = this.listTypes[this.current.listType].urlConfirm; - var urlSubmit = this.listTypes[this.current.listType].urlSubmit; - if (!urlConfirm && !urlSubmit) { - return false; - } - if (urlConfirm) { - this.blockForm.action = urlConfirm; - this.addFields([new Element('input', {type: 'hidden', name: 'id', value: this.current.itemId})]); - } else { - this.blockForm.action = urlSubmit; - - var complexTypes = this.listTypes[this.current.listType].complexTypes; - if (complexTypes) { - this.addFields([new Element('input', {type: 'hidden', name: 'configure_complex_list_types', value: complexTypes.join(',')})]); + }, + + /** + * Get configuration fields of product through ajax and show them + * + * @param listType scope name + * @param itemId + */ + _requestItemConfiguration: function(listType, itemId) { + if (!this.listTypes[listType].urlFetch) { + return false; } + var url = this.listTypes[listType].urlFetch; + if (url) { + new Ajax.Request(url, { + parameters: {id: itemId}, + onSuccess: function(transport) { + var response = transport.responseText; + if (response.isJSON()) { + response = response.evalJSON(); + if (response.error) { + this.blockMsg.show(); + this.blockMsgError.innerHTML = response.message; + this.blockCancelBtn.hide(); + this.setConfirmCallback(listType, null); + this._showWindow(); + } + } else if (response) { + response = response + ''; + this.blockFormFields.update(response); - this._processFieldsData('current_confirmed_to_form'); + // Add special div to hold mage data, e.g. scripts to execute on every popup show + var mageData = {}; + var scripts = response.extractScripts(); + mageData.scripts = scripts; - // Disable item controls that duplicate added fields (e.g. sometimes qty controls can intersect) - // so they won't be submitted - var tagNames = ['input', 'select', 'textarea']; + var scriptHolder = new Element('div', {'style': 'display:none'}); + scriptHolder.mageData = mageData; + this.blockFormFields.insert(scriptHolder); - var names = {}; // Map of added field names - for (var i = 0, len = tagNames.length; i < len; i++) { - var tagName = tagNames[i]; - var elements = this.blockFormAdd.getElementsByTagName(tagName); - for (var index = 0, elLen = elements.length; index < elLen; index++) { - names[elements[index].name] = true; - } + // Show window + this._showWindow(); + } + }.bind(this) + }); } + }, - for (var i = 0, len = tagNames.length; i < len; i++) { - var tagName = tagNames[i]; - var elements = this.blockFormConfirmed.getElementsByTagName(tagName); - for (var index = 0, elLen = elements.length; index < elLen; index++) { - var element = elements[index]; - if (names[element.name]) { - element.setAttribute('configure_disabled', 1); - element.setAttribute('configure_prev_disabled', element.disabled ? 1 : 0); - element.disabled = true; - } else { - element.setAttribute('configure_disabled', 0); - } - } - } - } - // do submit - if (Object.isFunction(this.beforeSubmitCallback[this.current.listType])) { - this.beforeSubmitCallback[this.current.listType](); - } - this.blockForm.submit(); - - // Show loader - jQuery(this.blockForm).trigger('processStart'); - - return this; - }, - - /** - * Add dynamically additional fields for form - * - * @param fields - */ - addFields: function(fields) { - fields.each(function(elm) { - this.blockFormAdd.insert(elm); - }.bind(this)); - return this; - }, - - /** - * Triggered when form was submitted and iFrame was loaded. Get response from iFrame and handle it - */ - onLoadIFrame: function() { - this.blockFormConfirmed.select('[configure_disabled=1]').each(function (element) { - element.disabled = element.getAttribute('configure_prev_disabled') == '1'; - }); - - this._processFieldsData('form_confirmed_to_confirmed'); - - var response = this.blockIFrame.contentWindow[this.iFrameJSVarname]; - if (response && "object" == typeof response) { - if (this.listTypes[this.current.listType].urlConfirm) { - if (response.ok) { + /** + * Triggered on confirm button click + * Do submit configured data through iFrame if needed + */ + onConfirmBtn: function() { + if (jQuery(this.blockForm).valid()) { + if (this.listTypes[this.current.listType].urlConfirm) { + this.submit(); + } else { + this._processFieldsData('item_confirm'); this._closeWindow(); - this.clean('current'); - } else if (response.error) { - this.showItemConfiguration(this.current.listType, this.current.itemId); - this.blockMsg.show(); - this.blockMsgError.innerHTML = response.message; - this._showWindow(); - return false; + if (Object.isFunction(this.confirmCallback[this.current.listType])) { + this.confirmCallback[this.current.listType](); + } } } - if (Object.isFunction(this.onLoadIFrameCallback[this.current.listType])) { - this.onLoadIFrameCallback[this.current.listType](response); + return this; + }, + + /** + * Triggered on cancel button click + */ + onCancelBtn: function() { + this._closeWindow(); + if (Object.isFunction(this.cancelCallback[this.current.listType])) { + this.cancelCallback[this.current.listType](); } - document.fire(this.current.listType + ':afterIFrameLoaded'); - } - // Hide loader - jQuery(this.blockForm).trigger('processStop'); - - this.clean('current'); - this.initialize(); - }, - - /** - * Helper for fetching content from iFrame - */ - _getIFrameContent: function() { - var content = (this.blockIFrame.contentWindow || this.blockIFrame.contentDocument); - if (content.document) { - content=content.document; - } - return content; - }, - - /** - * Helper to find qty of currently confirmed item - */ - getCurrentConfirmedQtyElement: function() { - var elms = $(this.confirmedCurrentId).getElementsByTagName('input'); - for (var i = 0; i < elms.length; i++) { - if (elms[i].name == 'qty') { - return elms[i]; + return this; + }, + + /** + * Submit configured data through iFrame + * + * @param listType scope name + */ + submit: function (listType) { + // prepare data + if (listType) { + this.current.listType = listType; + this.current.itemId = null; } - } - }, - - /** - * Helper to find qty of active form - */ - getCurrentFormQtyElement: function() { - var elms = this.blockFormFields.getElementsByTagName('input'); - for (var i = 0; i < elms.length; i++) { - if (elms[i].name == 'qty') { - return elms[i]; + var urlConfirm = this.listTypes[this.current.listType].urlConfirm; + var urlSubmit = this.listTypes[this.current.listType].urlSubmit; + if (!urlConfirm && !urlSubmit) { + return false; } - } - }, + if (urlConfirm) { + this.blockForm.action = urlConfirm; + this.addFields([new Element('input', {type: 'hidden', name: 'id', value: this.current.itemId})]); + } else { + this.blockForm.action = urlSubmit; - /** - * Show configuration window - */ - _showWindow: function() { - this.dialog.dialog('open'); - //this._toggleSelectsExceptBlock(false); + var complexTypes = this.listTypes[this.current.listType].complexTypes; + if (complexTypes) { + this.addFields([new Element('input', {type: 'hidden', name: 'configure_complex_list_types', value: complexTypes.join(',')})]); + } - if (Object.isFunction(this.showWindowCallback[this.current.listType])) { - this.showWindowCallback[this.current.listType](); - } - }, - - /** - * toggles Selects states (for IE) except those to be shown in popup - */ - /*_toggleSelectsExceptBlock: function(flag) { - if(Prototype.Browser.IE){ - if (this.blockForm) { - var states = new Array; - var selects = this.blockForm.getElementsByTagName("select"); - for(var i=0; i<selects.length; i++){ - states[i] = selects[i].style.visibility + this._processFieldsData('current_confirmed_to_form'); + + // Disable item controls that duplicate added fields (e.g. sometimes qty controls can intersect) + // so they won't be submitted + var tagNames = ['input', 'select', 'textarea']; + + var names = {}; // Map of added field names + for (var i = 0, len = tagNames.length; i < len; i++) { + var tagName = tagNames[i]; + var elements = this.blockFormAdd.getElementsByTagName(tagName); + for (var index = 0, elLen = elements.length; index < elLen; index++) { + names[elements[index].name] = true; + } } + + for (var i = 0, len = tagNames.length; i < len; i++) { + var tagName = tagNames[i]; + var elements = this.blockFormConfirmed.getElementsByTagName(tagName); + for (var index = 0, elLen = elements.length; index < elLen; index++) { + var element = elements[index]; + if (names[element.name]) { + element.setAttribute('configure_disabled', 1); + element.setAttribute('configure_prev_disabled', element.disabled ? 1 : 0); + element.disabled = true; + } else { + element.setAttribute('configure_disabled', 0); + } + } + } + } + // do submit + if (Object.isFunction(this.beforeSubmitCallback[this.current.listType])) { + this.beforeSubmitCallback[this.current.listType](); } - if (this.blockForm) { - for(i=0; i<selects.length; i++){ - selects[i].style.visibility = states[i] + this.blockForm.submit(); + + // Show loader + jQuery(this.blockForm).trigger('processStart'); + + return this; + }, + + /** + * Add dynamically additional fields for form + * + * @param fields + */ + addFields: function(fields) { + fields.each(function(elm) { + this.blockFormAdd.insert(elm); + }.bind(this)); + return this; + }, + + /** + * Triggered when form was submitted and iFrame was loaded. Get response from iFrame and handle it + */ + onLoadIFrame: function() { + this.blockFormConfirmed.select('[configure_disabled=1]').each(function (element) { + element.disabled = element.getAttribute('configure_prev_disabled') == '1'; + }); + + this._processFieldsData('form_confirmed_to_confirmed'); + + var response = this.blockIFrame.contentWindow[this.iFrameJSVarname]; + if (response && "object" == typeof response) { + if (this.listTypes[this.current.listType].urlConfirm) { + if (response.ok) { + this._closeWindow(); + this.clean('current'); + } else if (response.error) { + this.showItemConfiguration(this.current.listType, this.current.itemId); + this.blockMsg.show(); + this.blockMsgError.innerHTML = response.message; + this._showWindow(); + return false; + } } + if (Object.isFunction(this.onLoadIFrameCallback[this.current.listType])) { + this.onLoadIFrameCallback[this.current.listType](response); + } + document.fire(this.current.listType + ':afterIFrameLoaded'); } - } - },*/ - - /** - * Close configuration window - */ - _closeWindow: function() { - this.dialog.dialog('close'); - //this.blockWindow.style.display = 'none'; - //this.clean('window'); - }, - - /** - * Attach callback function triggered when confirm button was clicked - * - * @param confirmCallback - */ - setConfirmCallback: function(listType, confirmCallback) { - this.confirmCallback[listType] = confirmCallback; - return this; - }, - - /** - * Attach callback function triggered when cancel button was clicked - * - * @param cancelCallback - */ - setCancelCallback: function(listType, cancelCallback) { - this.cancelCallback[listType] = cancelCallback; - return this; - }, - - /** - * Attach callback function triggered when iFrame was loaded - * - * @param onLoadIFrameCallback - */ - setOnLoadIFrameCallback: function(listType, onLoadIFrameCallback) { - this.onLoadIFrameCallback[listType] = onLoadIFrameCallback; - return this; - }, - - /** - * Attach callback function triggered when iFrame was loaded - * - * @param showWindowCallback - */ - setShowWindowCallback: function(listType, showWindowCallback) { - this.showWindowCallback[listType] = showWindowCallback; - return this; - }, - - /** - * Attach callback function triggered before submitting form - * - * @param beforeSubmitCallback - */ - setBeforeSubmitCallback: function(listType, beforeSubmitCallback) { - this.beforeSubmitCallback[listType] = beforeSubmitCallback; - return this; - }, - - /** - * Clean object data - * - * @param method can be 'all' or 'current' - */ - clean: function(method) { - var listInfo = null; - var listTypes = null; - var removeConfirmed = function (listTypes) { - this.blockConfirmed.childElements().each(function(elm) { - for (var i = 0, len = listTypes.length; i < len; i++) { - var pattern = this.blockConfirmed.id + '[' + listTypes[i] + ']'; - if (elm.id.indexOf(pattern) == 0) { - elm.remove(); - break; - } + // Hide loader + jQuery(this.blockForm).trigger('processStop'); + + this.clean('current'); + this.initialize(); + }, + + /** + * Helper for fetching content from iFrame + */ + _getIFrameContent: function() { + var content = (this.blockIFrame.contentWindow || this.blockIFrame.contentDocument); + if (content.document) { + content=content.document; + } + return content; + }, + + /** + * Helper to find qty of currently confirmed item + */ + getCurrentConfirmedQtyElement: function() { + var elms = $(this.confirmedCurrentId).getElementsByTagName('input'); + for (var i = 0; i < elms.length; i++) { + if (elms[i].name == 'qty') { + return elms[i]; } - }.bind(this)); - }.bind(this); - - switch (method) { - case 'current': - listInfo = this.listTypes[this.current.listType]; - listTypes = [this.current.listType]; - if (listInfo && listInfo.complexTypes) { - listTypes = listTypes.concat(listInfo.complexTypes); + } + }, + + /** + * Helper to find qty of active form + */ + getCurrentFormQtyElement: function() { + var elms = this.blockFormFields.getElementsByTagName('input'); + for (var i = 0; i < elms.length; i++) { + if (elms[i].name == 'qty') { + return elms[i]; } - removeConfirmed(listTypes); - break; - case 'window': - this.blockFormFields.update(); - this.blockMsg.hide(); - this.blockMsgError.update(); - this.blockCancelBtn.show(); - break; - default: - // search in list types for its cleaning - if (this.listTypes[method]) { - listInfo = this.listTypes[method]; - listTypes = [method]; - if (listInfo.complexTypes) { + } + }, + + /** + * Show configuration window + */ + _showWindow: function() { + this.dialog.modal('openModal'); + //this._toggleSelectsExceptBlock(false); + + if (Object.isFunction(this.showWindowCallback[this.current.listType])) { + this.showWindowCallback[this.current.listType](); + } + }, + + /** + * toggles Selects states (for IE) except those to be shown in popup + */ + /*_toggleSelectsExceptBlock: function(flag) { + if(Prototype.Browser.IE){ + if (this.blockForm) { + var states = new Array; + var selects = this.blockForm.getElementsByTagName("select"); + for(var i=0; i<selects.length; i++){ + states[i] = selects[i].style.visibility + } + } + if (this.blockForm) { + for(i=0; i<selects.length; i++){ + selects[i].style.visibility = states[i] + } + } + } + },*/ + + /** + * Close configuration window + */ + _closeWindow: function() { + this.dialog.modal('closeModal'); + //this.blockWindow.style.display = 'none'; + //this.clean('window'); + }, + + /** + * Attach callback function triggered when confirm button was clicked + * + * @param confirmCallback + */ + setConfirmCallback: function(listType, confirmCallback) { + this.confirmCallback[listType] = confirmCallback; + return this; + }, + + /** + * Attach callback function triggered when cancel button was clicked + * + * @param cancelCallback + */ + setCancelCallback: function(listType, cancelCallback) { + this.cancelCallback[listType] = cancelCallback; + return this; + }, + + /** + * Attach callback function triggered when iFrame was loaded + * + * @param onLoadIFrameCallback + */ + setOnLoadIFrameCallback: function(listType, onLoadIFrameCallback) { + this.onLoadIFrameCallback[listType] = onLoadIFrameCallback; + return this; + }, + + /** + * Attach callback function triggered when iFrame was loaded + * + * @param showWindowCallback + */ + setShowWindowCallback: function(listType, showWindowCallback) { + this.showWindowCallback[listType] = showWindowCallback; + return this; + }, + + /** + * Attach callback function triggered before submitting form + * + * @param beforeSubmitCallback + */ + setBeforeSubmitCallback: function(listType, beforeSubmitCallback) { + this.beforeSubmitCallback[listType] = beforeSubmitCallback; + return this; + }, + + /** + * Clean object data + * + * @param method can be 'all' or 'current' + */ + clean: function(method) { + var listInfo = null; + var listTypes = null; + var removeConfirmed = function (listTypes) { + this.blockConfirmed.childElements().each(function(elm) { + for (var i = 0, len = listTypes.length; i < len; i++) { + var pattern = this.blockConfirmed.id + '[' + listTypes[i] + ']'; + if (elm.id.indexOf(pattern) == 0) { + elm.remove(); + break; + } + } + }.bind(this)); + }.bind(this); + + switch (method) { + case 'current': + listInfo = this.listTypes[this.current.listType]; + listTypes = [this.current.listType]; + if (listInfo && listInfo.complexTypes) { listTypes = listTypes.concat(listInfo.complexTypes); } removeConfirmed(listTypes); - // clean all - } else if (!method) { - this.current = $H({}); - this.blockConfirmed.update(); + break; + case 'window': this.blockFormFields.update(); this.blockMsg.hide(); this.blockMsgError.update(); this.blockCancelBtn.show(); - } - break; - } - this._getIFrameContent().body.innerHTML = ''; - this.blockIFrame.contentWindow[this.iFrameJSVarname] = {}; - this.blockFormAdd.update(); - this.blockFormConfirmed.update(); - this.blockForm.action = ''; - - return this; - }, - - /** - * Process fields data: save, restore, move saved to form and back - * - * @param method can be 'item_confirm', 'item_restore', 'current_confirmed_to_form', 'form_confirmed_to_confirmed' - */ - _processFieldsData: function(method) { + break; + default: + // search in list types for its cleaning + if (this.listTypes[method]) { + listInfo = this.listTypes[method]; + listTypes = [method]; + if (listInfo.complexTypes) { + listTypes = listTypes.concat(listInfo.complexTypes); + } + removeConfirmed(listTypes); + // clean all + } else if (!method) { + this.current = $H({}); + this.blockConfirmed.update(); + this.blockFormFields.update(); + this.blockMsg.hide(); + this.blockMsgError.update(); + this.blockCancelBtn.show(); + } + break; + } + this._getIFrameContent().body.innerHTML = ''; + this.blockIFrame.contentWindow[this.iFrameJSVarname] = {}; + this.blockFormAdd.update(); + this.blockFormConfirmed.update(); + this.blockForm.action = ''; + + return this; + }, /** - * Internal function for rename fields names of some list type - * if listType is not specified, then it won't be added as prefix to all names + * Process fields data: save, restore, move saved to form and back * - * @param method can be 'current_confirmed_to_form', 'form_confirmed_to_confirmed' - * @param blockItem + * @param method can be 'item_confirm', 'item_restore', 'current_confirmed_to_form', 'form_confirmed_to_confirmed' */ - var _renameFields = function(method, blockItem, listType) { - var pattern = null; - var patternFlat = null; - var replacement = null; - var replacementFlat = null - var scopeArr = blockItem.id.match(/.*\[\w+\]\[([^\]]+)\]$/); - var itemId = scopeArr[1]; - if (method == 'current_confirmed_to_form') { - pattern = RegExp('(\\w+)(\\[?)'); - patternFlat = RegExp('(\\w+)'); - replacement = 'item[' + itemId + '][$1]$2'; - replacementFlat = 'item_' + itemId + '_$1'; - if (listType) { - replacement = 'list[' + listType + '][item][' + itemId + '][$1]$2'; - replacementFlat = 'list_' + listType + '_' + replacementFlat; - } - } else if (method == 'form_confirmed_to_confirmed') { - var stPattern = 'item\\[' + itemId + '\\]\\[(\\w+)\\](.*)'; - var stPatternFlat = 'item_' + itemId + '_(\\w+)'; - if (listType) { - stPattern = 'list\\[' + listType + '\\]\\[item\\]\\[' + itemId + '\\]\\[(\\w+)\\](.*)'; - stPatternFlat = 'list_' + listType + '_' + stPatternFlat; - } - pattern = new RegExp(stPattern); - patternFlat = new RegExp(stPatternFlat); - replacement = '$1$2'; - replacementFlat = '$1'; - } else { - return false; - } - var rename = function (elms) { - for (var i = 0; i < elms.length; i++) { - if (elms[i].name && elms[i].type == 'file') { - elms[i].name = elms[i].name.replace(patternFlat, replacementFlat); - } else if (elms[i].name) { - elms[i].name = elms[i].name.replace(pattern, replacement); + _processFieldsData: function(method) { + + /** + * Internal function for rename fields names of some list type + * if listType is not specified, then it won't be added as prefix to all names + * + * @param method can be 'current_confirmed_to_form', 'form_confirmed_to_confirmed' + * @param blockItem + */ + var _renameFields = function(method, blockItem, listType) { + var pattern = null; + var patternFlat = null; + var replacement = null; + var replacementFlat = null + var scopeArr = blockItem.id.match(/.*\[\w+\]\[([^\]]+)\]$/); + var itemId = scopeArr[1]; + if (method == 'current_confirmed_to_form') { + pattern = RegExp('(\\w+)(\\[?)'); + patternFlat = RegExp('(\\w+)'); + replacement = 'item[' + itemId + '][$1]$2'; + replacementFlat = 'item_' + itemId + '_$1'; + if (listType) { + replacement = 'list[' + listType + '][item][' + itemId + '][$1]$2'; + replacementFlat = 'list_' + listType + '_' + replacementFlat; + } + } else if (method == 'form_confirmed_to_confirmed') { + var stPattern = 'item\\[' + itemId + '\\]\\[(\\w+)\\](.*)'; + var stPatternFlat = 'item_' + itemId + '_(\\w+)'; + if (listType) { + stPattern = 'list\\[' + listType + '\\]\\[item\\]\\[' + itemId + '\\]\\[(\\w+)\\](.*)'; + stPatternFlat = 'list_' + listType + '_' + stPatternFlat; } + pattern = new RegExp(stPattern); + patternFlat = new RegExp(stPatternFlat); + replacement = '$1$2'; + replacementFlat = '$1'; + } else { + return false; } - }; - rename(blockItem.getElementsByTagName('input')); - rename(blockItem.getElementsByTagName('select')); - rename(blockItem.getElementsByTagName('textarea')); - }.bind(this); - - switch (method) { - case 'item_confirm': + var rename = function (elms) { + for (var i = 0; i < elms.length; i++) { + if (elms[i].name && elms[i].type == 'file') { + elms[i].name = elms[i].name.replace(patternFlat, replacementFlat); + } else if (elms[i].name) { + elms[i].name = elms[i].name.replace(pattern, replacement); + } + } + }; + rename(blockItem.getElementsByTagName('input')); + rename(blockItem.getElementsByTagName('select')); + rename(blockItem.getElementsByTagName('textarea')); + }.bind(this); + + switch (method) { + case 'item_confirm': if (!$(this.confirmedCurrentId)) { this.blockConfirmed.insert(new Element('div', {id: this.confirmedCurrentId})); } else { @@ -659,8 +635,8 @@ ProductConfigure.prototype = { this.blockFormFields.childElements().each(function(elm) { $(this.confirmedCurrentId).insert(elm); }.bind(this)); - break; - case 'item_restore': + break; + case 'item_restore': this.blockFormFields.update(); // clone confirmed to form @@ -730,14 +706,14 @@ ProductConfigure.prototype = { } catch (e) {} this.restorePhase = false; } - break; - case 'current_confirmed_to_form': + break; + case 'current_confirmed_to_form': var allowedListTypes = {}; allowedListTypes[this.current.listType] = true; var listInfo = this.listTypes[this.current.listType]; if (listInfo.complexTypes) { for (var i = 0, len = listInfo.complexTypes.length; i < len; i++) { - allowedListTypes[listInfo.complexTypes[i]] = true; + allowedListTypes[listInfo.complexTypes[i]] = true; } } @@ -747,13 +723,13 @@ ProductConfigure.prototype = { var listType = scopeArr[1]; var itemId = scopeArr[2]; if (allowedListTypes[listType] && (!this.itemsFilter[listType] - || this.itemsFilter[listType].indexOf(itemId) != -1)) { + || this.itemsFilter[listType].indexOf(itemId) != -1)) { _renameFields(method, blockItem, listInfo.complexTypes ? listType : null); this.blockFormConfirmed.insert(blockItem); } }.bind(this)); - break; - case 'form_confirmed_to_confirmed': + break; + case 'form_confirmed_to_confirmed': var listInfo = this.listTypes[this.current.listType]; this.blockFormConfirmed.childElements().each(function(blockItem) { var scopeArr = blockItem.id.match(/.*\[(\w+)\]\[([^\]]+)\]$/); @@ -761,32 +737,32 @@ ProductConfigure.prototype = { _renameFields(method, blockItem, listInfo.complexTypes ? listType : null); this.blockConfirmed.insert(blockItem); }.bind(this)); - break; - } - }, - - /** - * Check if qty selected correctly - * - * @param object element - * @param object event - */ - changeOptionQty: function(element, event) - { - var checkQty = true; - if ('undefined' != typeof event) { - if (event.keyCode == 8 || event.keyCode == 46) { - checkQty = false; + break; + } + }, + + /** + * Check if qty selected correctly + * + * @param object element + * @param object event + */ + changeOptionQty: function(element, event) + { + var checkQty = true; + if ('undefined' != typeof event) { + if (event.keyCode == 8 || event.keyCode == 46) { + checkQty = false; + } + } + if (checkQty && (Number(element.value) <= 0 || isNaN(Number(element.value)))) { + element.value = 1; } } - if (checkQty && (Number(element.value) <= 0 || isNaN(Number(element.value)))) { - element.value = 1; - } - } -}; + }; -jQuery(document).ready(function(){ - productConfigure = new ProductConfigure(); -}); + jQuery(document).ready(function(){ + productConfigure = new ProductConfigure(); + }); }); \ No newline at end of file diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/custom-options.js b/app/code/Magento/Catalog/view/adminhtml/web/js/custom-options.js index b7a16ce3db853a02f454b58af0d72e6e6d32dc31..d68497046a5bf00619fc2db9109ffb8869b7eed2 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/custom-options.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/custom-options.js @@ -7,12 +7,14 @@ define([ 'jquery', 'mage/template', + 'Magento_Ui/js/modal/alert', 'jquery/ui', 'useDefault', 'collapsable', 'mage/translate', - 'mage/backend/validation' -], function ($, mageTemplate) { + 'mage/backend/validation', + 'Magento_Ui/js/modal/modal' +], function ($, mageTemplate, alert) { 'use strict'; $.widget('mage.customOptions', { @@ -120,90 +122,66 @@ define([ var importContainer = $('#import-container'), widget = this; - importContainer.dialog({ + importContainer.modal({ title: $.mage.__('Select Product'), - autoOpen: false, - minWidth: 980, - width: '75%', - modal: true, - resizable: true, - position: { - my: 'left top', - at: 'center top', - of: 'body' - }, - create: function (event, ui) { - $(document).on('click', '#productGrid_massaction-form button', function () { - $('#import-custom-options-apply-button').trigger('click', 'massActionTrigger'); + type: 'slide', + opened: function () { + $(document).off().on('click', '#productGrid_massaction-form button', function () { + $('.import-custom-options-apply-button').trigger('click', 'massActionTrigger'); }); }, - open: function () { - $(this).closest('.ui-dialog').addClass('ui-dialog-active'); - - var topMargin = $(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 135; - $(this).closest('.ui-dialog').css('margin-top', topMargin); - - $(this).addClass('admin__scope-old'); // ToDo UI: remove with old styles removal - }, - close: function () { - $(this).closest('.ui-dialog').removeClass('ui-dialog-active'); - }, - buttons: [ - { - text: $.mage.__('Import'), - id: 'import-custom-options-apply-button', - 'class': 'action-primary action-import', - click: function (event, massActionTrigger) { - var request = []; - $(this).find('input[name=product]:checked').map(function () { - request.push(this.value); - }); + buttons: [{ + text: $.mage.__('Import'), + attr: { + id: 'import-custom-options-apply-button' + }, + 'class': 'action-primary action-import import-custom-options-apply-button', + click: function (event, massActionTrigger) { + var request = []; - if (request.length === 0) { - if (!massActionTrigger) { - alert($.mage.__('Please select items.')); - } + $(this.element).find('input[name=product]:checked').map(function () { + request.push(this.value); + }); - return; + if (request.length === 0) { + if (!massActionTrigger) { + alert({ + content: $.mage.__('Please select items.') + }); } - $.post(widget.options.customOptionsUrl, { - 'products[]': request, - form_key: widget.options.formKey - }, function ($data) { - $.parseJSON($data).each(function (el) { - el.id = widget.getFreeOptionId(el.id); - el.option_id = el.id; - - if (typeof el.optionValues !== 'undefined') { - for (var i = 0; i < el.optionValues.length; i++) { - el.optionValues[i].option_id = el.id; - } + return; + } + + $.post(widget.options.customOptionsUrl, { + 'products[]': request, + form_key: widget.options.formKey + }, function ($data) { + $.parseJSON($data).each(function (el) { + el.id = widget.getFreeOptionId(el.id); + el.option_id = el.id; + + if (typeof el.optionValues !== 'undefined') { + for (var i = 0; i < el.optionValues.length; i++) { + el.optionValues[i].option_id = el.id; } - //Adding option - widget.addOption(el); - //Will save new option on server side - $('#product_option_' + el.id + '_option_id').val(0); - $('#option_' + el.id + ' input[name$="option_type_id]"]').val(-1); - }); - importContainer.dialog('close'); + } + //Adding option + widget.addOption(el); + //Will save new option on server side + $('#product_option_' + el.id + '_option_id').val(0); + $('#option_' + el.id + ' input[name$="option_type_id]"]').val(-1); }); - } - }, - { - text: $.mage.__('Cancel'), - id: 'import-custom-options-close-button', - 'class': 'action-close', - click: function () { - $(this).dialog('close'); - } - }] + importContainer.modal('closeModal'); + }); + } + }] }); importContainer.load( this.options.productGridUrl, {form_key: this.options.formKey}, function () { - importContainer.dialog('open'); + importContainer.modal('openModal'); } ); }, diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/new-category-dialog.js b/app/code/Magento/Catalog/view/adminhtml/web/js/new-category-dialog.js index d70f2e17193afe202495b505a22cf26416dbdae7..44f3371cf9371b8f181de7d950e8796ce156520c 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/new-category-dialog.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/new-category-dialog.js @@ -32,7 +32,6 @@ define([ .on('suggestbeforeselect', function (event) { clearParentCategory(); $(event.target).treeSuggest('close'); - $('#new_category_name').focus(); }); $.validator.addMethod('validate-parent-category', function () { diff --git a/app/code/Magento/Catalog/view/base/templates/product/price/tier_prices.phtml b/app/code/Magento/Catalog/view/base/templates/product/price/tier_prices.phtml index c0b494718c0242c51680a0f6982384556c8f27e2..030e663359f01e1dc99094226ebcd499a3edf447 100644 --- a/app/code/Magento/Catalog/view/base/templates/product/price/tier_prices.phtml +++ b/app/code/Magento/Catalog/view/base/templates/product/price/tier_prices.phtml @@ -86,8 +86,9 @@ $product = $block->getSaleableItem(); <script type="text/x-magento-init"> { ".product-info-main": { - "tierPrice": { + "addToCart": { "inputQty": "#qty", + "attr": "[data-tier-price]", "productForm": "#product_addtocart_form" } } diff --git a/app/code/Magento/Catalog/view/base/web/js/tier-price.js b/app/code/Magento/Catalog/view/base/web/js/tier-price.js deleted file mode 100644 index 95622a56f6cca22f2791827e20775d3f6c77cabd..0000000000000000000000000000000000000000 --- a/app/code/Magento/Catalog/view/base/web/js/tier-price.js +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*jshint browser:true jquery:true*/ -define([ - "jquery", - "jquery/ui" -], function($){ - "use strict"; - - $.widget('mage.tierPrice', { - options: { - popupHeading: '#map-popup-heading', - productForm: '#product_addtocart_form', - popupPrice: '#map-popup-price', - popupMsrp: '#map-popup-msrp', - popup: '#map-popup', - popupContent: '#map-popup-content', - popupText: '#map-popup-text', - popupOnlyText: 'map-popup-only-text', - popupTextWhatThis: '#map-popup-text-what-this', - popupCartButtonId: '#map-popup-button' - }, - - _create: function() { - this.element.on('click', '[data-tier-price]', $.proxy(this._showTierPrice, this)); - }, - - /** - * Show tier price popup on gesture - * @private - * @param e - element got the clicked on - * @return {Boolean} - */ - _showTierPrice: function(e) { - var data = $(e.target).data('tier-price'); - $(this.options.popupCartButtonId).off('click'); - $(this.options.popupCartButtonId).on('click', $.proxy(function() { - this.element.find(this.options.inputQty).val(data.qty); - this.element.find(this.options.productForm).submit(); - }, this)); - $(this.options.popupHeading).text(data.name); - $(this.options.popupPrice).html($(data.price)).find('[id^="product-price-"]').attr('id', function() { - // change price element id, so price option won't update the tier price - return 'tier' + $(this).attr('id'); - }); - $(this.options.popupMsrp).html(data.msrp); - var width = $(this.options.popup).width(); - var offsetX = e.pageX - (width / 2) + "px"; - $(this.options.popup).css({left: offsetX, top: e.pageY}).addClass('active').show(); - $(this.options.popupContent).show(); - $(this.options.popupText).addClass(this.options.popupOnlyText).show(); - $(this.options.popupTextWhatThis).hide(); - return false; - } - }); - - return $.mage.tierPrice; -}); \ No newline at end of file diff --git a/app/code/Magento/Catalog/view/frontend/requirejs-config.js b/app/code/Magento/Catalog/view/frontend/requirejs-config.js index a840a196c6a89c0c60ffdef8d5f7d52384c0e723..3c0ffa65c8d43c9aa0f58c858871e703378b7b60 100644 --- a/app/code/Magento/Catalog/view/frontend/requirejs-config.js +++ b/app/code/Magento/Catalog/view/frontend/requirejs-config.js @@ -12,6 +12,7 @@ var config = { upsellProducts: 'Magento_Catalog/js/upsell-products', productListToolbarForm: 'Magento_Catalog/js/product/list/toolbar', tierPrice: 'Magento_Catalog/js/tier-price', + addToCart: 'Magento_Msrp/js/msrp', catalogGallery: 'Magento_Catalog/js/gallery', priceBox: 'Magento_Catalog/js/price-box', priceOptionDate: 'Magento_Catalog/js/price-option-date', diff --git a/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_listing.xml b/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_listing.xml index 01bd9d50c93f5f69ac9b17c0bf06f292f4301373..a4f0f8c41ec975ac84ec5f1050952e6a73c52e34 100644 --- a/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_listing.xml +++ b/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_listing.xml @@ -6,49 +6,12 @@ */ --> <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Ui/etc/ui_configuration.xsd"> - <container name="listing_top"> - <filters name="listing_filters" class="Magento\Catalog\Ui\Component\Listing\Filters"> - <filterRange name="qty"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">qty</item> - <item name="label" xsi:type="string" translate="true">Quantity</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">product_listing.product_listing.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">from</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">to</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - </filters> - </container> <columns name="product_columns" class="Magento\Catalog\Ui\Component\Listing\Columns"> <column name="qty"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="add_field" xsi:type="boolean">true</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Quantity</item> <item name="sortOrder" xsi:type="number">75</item> </item> diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js index dd675d53117b01cc785f8497b7e324c100a351a3..0f92f6ea63362f1de7e995e7db9ee721d012b15c 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js @@ -12,10 +12,11 @@ define([ "jquery", "accordion", + 'Magento_Ui/js/modal/alert', "jquery/ui", "mage/validation/validation", "mage/translate" -], function($, accordion){ +], function($, accordion, alert){ 'use strict'; // Base widget, handle ajax events and first section(Checkout Method) in one page checkout accordion @@ -182,7 +183,9 @@ define([ if (json.isGuestCheckoutAllowed) { if( !guestChecked && !registerChecked ){ - alert( $.mage.__('Please create an account or check out as a guest.') ); + alert({ + content: $.mage.__('Please create an account or check out as a guest.') + }); return false; } @@ -244,7 +247,9 @@ define([ $(this.options.countrySelector).trigger('change'); - alert(msg); + alert({ + content: msg + }); } return; diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-payment-info.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-payment-info.js index 8d6793b5ad461d4e63ea69682fa3b81469473b74..bfa87548aea2a170d7372bbc547266c482e9d7f6 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-payment-info.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opc-payment-info.js @@ -12,10 +12,11 @@ define([ 'jquery', 'mage/template', + 'Magento_Ui/js/modal/alert', 'jquery/ui', 'mage/translate', 'Magento_Checkout/js/opc-shipping-method' -], function ($, mageTemplate) { +], function ($, mageTemplate, alert) { 'use strict'; // Extension for mage.opcheckout - fifth section(Payment Information) in one page checkout accordion @@ -120,7 +121,9 @@ define([ var methods = this.element.find('[name^="payment["]'); if (methods.length === 0) { - alert($.mage.__('We can\'t complete your order because you don\'t have a payment method set up.')); + alert({ + content: $.mage.__('We can\'t complete your order because you don\'t have a payment method set up.') + }); return false; } @@ -131,7 +134,9 @@ define([ return true; } - alert($.mage.__('Please choose a payment method.')); + alert({ + content: $.mage.__('Please choose a payment method.') + }); return false; }, diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-method.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-method.js index 6dd87549e1bcfc7ad4d3494d9df4b4aa24da81b8..505db47ab57901c4dcc73330ed27ebf66d0a4968 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-method.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-method.js @@ -11,11 +11,12 @@ */ define([ "jquery", + 'Magento_Ui/js/modal/alert', "jquery/ui", "Magento_Checkout/js/opc-shipping-info", "mage/validation", "mage/translate" -], function($){ +], function($, alert){ 'use strict'; // Extension for mage.opcheckout - fourth section(Shipping Method) in one page checkout accordion @@ -62,13 +63,20 @@ define([ _validateShippingMethod: function() { var methods = this.element.find('[name="shipping_method"]'); if (methods.length === 0) { - alert($.mage.__('We can\'t ship to this address. Please enter another address or edit this one.')); + alert({ + content: $.mage.__('We can\'t ship to this address. Please enter another address or edit this one.') + }); + return false; } + if (methods.filter(':checked').length) { return true; } - alert($.mage.__('Please specify a shipping method.')); + alert({ + content:$.mage.__('Please specify a shipping method.') + }); + return false; } }); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js b/app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js index b7665f89c0db66e94c016cf4835a7a499da17da5..570dd9edf2d892eb39266dc467fc85f2861c84fc 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js @@ -10,10 +10,11 @@ define([ 'jquery', 'mage/template', + 'Magento_Ui/js/modal/alert', 'jquery/ui', 'mage/validation', 'mage/translate' -], function ($, mageTemplate) { +], function ($, mageTemplate, alert) { 'use strict'; // Base widget, handle ajax events and first section(Checkout Method) in one page checkout accordion @@ -155,7 +156,9 @@ define([ this.element.find(this.options.checkout.registerCustomerPasswordSelector).show(); } else { - alert($.mage.__('Please create an account or check out as a guest.')); + alert({ + content: $.mage.__('Please create an account or check out as a guest.') + }); return false; } @@ -201,9 +204,13 @@ define([ $(this.options.countrySelector).trigger('change'); - alert(msg); + alert({ + content: msg + }); } else { - alert(response.error); + alert({ + content: response.error + }); } return; @@ -426,7 +433,9 @@ define([ var methods = this.element.find('[name="shipping_method"]'); if (methods.length === 0) { - alert($.mage.__('We can\'t ship to this address. Please choose another address or edit the current one.')); + alert({ + content: $.mage.__('We can\'t ship to this address. Please choose another address or edit the current one.') + }); return false; } @@ -435,7 +444,9 @@ define([ return true; } - alert($.mage.__('Please specify a shipping method.')); + alert({ + content: $.mage.__('Please specify a shipping method.') + }); return false; } @@ -550,7 +561,9 @@ define([ var methods = this.element.find('[name^="payment["]'); if (methods.length === 0) { - alert($.mage.__('We can\'t complete your order because you don\'t have a payment method set up.')); + alert({ + content: $.mage.__('We can\'t complete your order because you don\'t have a payment method set up.') + }); return false; } @@ -561,7 +574,9 @@ define([ return true; } - alert($.mage.__('Please choose a payment method.')); + alert({ + content: $.mage.__('Please choose a payment method.') + }); return false; }, diff --git a/app/code/Magento/Checkout/view/frontend/web/js/payment.js b/app/code/Magento/Checkout/view/frontend/web/js/payment.js index 507322ba4a200b87d773aaf1f60d3690ccfe7a3f..1442bb787605236b3b40abfe430e9b98af6afd24 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/payment.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/payment.js @@ -10,9 +10,10 @@ define([ 'jquery', 'mage/template', + 'Magento_Ui/js/modal/alert', 'jquery/ui', 'mage/translate' -], function ($, mageTemplate) { +], function ($, mageTemplate, alert) { 'use strict'; $.widget('mage.payment', { @@ -78,13 +79,17 @@ define([ isValid = false; if (methods.length === 0) { - alert($.mage.__('We can\'t complete your order because you don\'t have a payment method set up.')); + alert({ + content: $.mage.__('We can\'t complete your order because you don\'t have a payment method set up.') + }); } else if (this.options.checkoutPrice < this.options.minBalance) { isValid = true; } else if (methods.filter('input:radio:checked').length) { isValid = true; } else { - alert($.mage.__('Please choose a payment method.')); + alert({ + content: $.mage.__('Please choose a payment method.') + }); } return isValid; diff --git a/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js b/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js index 98d2c607ae0c90b4bc241625101c59d9e71b985a..34501bbeb107889899f1e26478fa41aadb772847 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js @@ -8,9 +8,11 @@ define([ "jquery", 'Magento_Customer/js/model/authentication-popup', 'Magento_Customer/js/customer-data', + 'Magento_Ui/js/modal/alert', + 'Magento_Ui/js/modal/confirm', "jquery/ui", "mage/decorate" -], function($, authenticationPopup, customerData){ +], function($, authenticationPopup, customerData, alert, confirm){ $.widget('mage.sidebar', { options: { @@ -46,9 +48,14 @@ define([ }, this); events['click ' + this.options.button.remove] = function(event) { event.stopPropagation(); - if (confirm(self.options.confirmMessage)) { - self._removeItem($(event.currentTarget)); - } + confirm({ + content: self.options.confirmMessage, + actions: { + confirm: function () { + self._removeItem($(event.currentTarget)); + } + } + }); }; events['keyup ' + this.options.item.qty] = function(event) { self._showItemButton($(event.target)); @@ -169,7 +176,9 @@ define([ } else { var msg = response.error_message; if (msg) { - window.alert($.mage.__(msg)); + alert({ + content: $.mage.__(msg) + }); } } }) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/cart/shipping-rates.js b/app/code/Magento/Checkout/view/frontend/web/js/view/cart/shipping-rates.js index e569f88a11125b175001015e70581d65b7fbc410..f8a63000aa8ff75024939cfd7543562c6f79b0c6 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/cart/shipping-rates.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/cart/shipping-rates.js @@ -42,7 +42,7 @@ define( /** * @override */ - initProperties: function () { + initObservable: function () { var self = this; this._super(); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/payment/default.js b/app/code/Magento/Checkout/view/frontend/web/js/view/payment/default.js index dca2878703a4da3e7b4014e648f51f4e4f115688..4d80012fd1ffe3b143f89e4b4430aa296e61b56a 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/payment/default.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/payment/default.js @@ -17,7 +17,7 @@ define( 'uiRegistry', 'Magento_Checkout/js/model/payment/additional-validators', 'Magento_Ui/js/model/messages', - 'Magento_Ui/js/core/renderer/layout' + 'uiLayout' ], function ( ko, diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/payment/list.js b/app/code/Magento/Checkout/view/frontend/web/js/view/payment/list.js index 4559bbbc745f0ebb7eab1cfd6ec8e848c9f10874..7764f5ec9e0c8ddfe55af4847a6d0110becfe765 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/payment/list.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/payment/list.js @@ -9,7 +9,7 @@ define([ 'uiComponent', 'Magento_Checkout/js/model/payment/method-list', 'Magento_Checkout/js/model/payment/renderer-list', - 'Magento_Ui/js/core/renderer/layout', + 'uiLayout', 'Magento_Checkout/js/model/checkout-data-resolver' ], function (_, ko, utils, Component, paymentMethods, rendererList, layout, checkoutDataResolver) { 'use strict'; diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/address-renderer/default.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/address-renderer/default.js index 221e9f6f1514cc48740413f6271766ead7e4f6c4..0b932a29e52d99a48db84b7c8ea93ea1a56eec8b 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/address-renderer/default.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/address-renderer/default.js @@ -20,7 +20,7 @@ define([ template: 'Magento_Checkout/shipping-address/address-renderer/default' }, - initProperties: function () { + initObservable: function () { this._super(); this.isSelected = ko.computed(function() { var isSelected = false; diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/list.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/list.js index 352d8e628e37f4a598115181c8a3c576e56b8ed2..5ee2b5d4ed9fe79316b88265380e8c45c1fba929 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/list.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/list.js @@ -8,7 +8,7 @@ define([ 'ko', 'mageUtils', 'uiComponent', - 'Magento_Ui/js/core/renderer/layout', + 'uiLayout', 'Magento_Customer/js/model/address-list' ], function (_, ko, utils, Component, layout, addressList) { 'use strict'; @@ -44,7 +44,7 @@ define([ return this; }, - initProperties: function () { + initConfig: function () { this._super(); // the list of child components that are responsible for address rendering this.rendererComponents = []; diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/list.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/list.js index 36342149c66e6fcc140e5c1d6ab9316c45e26958..f024358ae0dace9e0cb362f195e6234e3e6181fe 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/list.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/list.js @@ -8,7 +8,7 @@ define([ 'ko', 'mageUtils', 'uiComponent', - 'Magento_Ui/js/core/renderer/layout', + 'uiLayout', 'Magento_Checkout/js/model/quote' ], function ($, ko, utils, Component, layout, quote) { 'use strict'; @@ -35,7 +35,7 @@ define([ return this; }, - initProperties: function () { + initConfig: function () { this._super(); // the list of child components that are responsible for address rendering this.rendererComponents = {}; diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php index e50be29ce1130c98691d649fb5bf2dc0677cdb03..59bcbf7a18596f13eb9f3afe36dc7e8f6f686069 100644 --- a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php @@ -18,12 +18,19 @@ class PageActionsTest extends \PHPUnit_Framework_TestCase $urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface') ->disableOriginalConstructor() ->getMock(); + $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); /** @var \Magento\Cms\Ui\Component\Listing\Column\PageActions $model */ $model = $objectManager->getObject( 'Magento\Cms\Ui\Component\Listing\Column\PageActions', [ 'urlBuilder' => $urlBuilderMock, + 'context' => $contextMock, ] ); diff --git a/app/code/Magento/Cms/view/adminhtml/templates/browser/content.phtml b/app/code/Magento/Cms/view/adminhtml/templates/browser/content.phtml index 54f22698a0ffe64e9630ab42253d1bccd2a65290..d40b8445058cc689523ef8c9e41a6a41892c2bcd 100644 --- a/app/code/Magento/Cms/view/adminhtml/templates/browser/content.phtml +++ b/app/code/Magento/Cms/view/adminhtml/templates/browser/content.phtml @@ -20,7 +20,7 @@ <div class="title"><?php /* @escapeNotVerified */ echo $block->getHeaderText() ?></div> </div> </div> - <div id="contents-uploader"><?php echo $block->getChildHtml('wysiwyg_images.uploader') ?></div> + <div id="contents-uploader" class="contents-uploader"><?php echo $block->getChildHtml('wysiwyg_images.uploader') ?></div> <div id="contents"></div> </div> </div> diff --git a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml index 867326e61ab278df5b95b58505e42a4d9113eae6..6934d263535b59bde9a0a6c72ead01ec3dc0e0c0 100644 --- a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml +++ b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml @@ -48,17 +48,13 @@ <bookmark name="bookmarks"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> - <item name="displayArea" xsi:type="string">dataGridActions</item> <item name="storageConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> - <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> <item name="namespace" xsi:type="string">cms_block_listing</item> </item> </item> </argument> </bookmark> - <container name="columns_controls"> + <component name="columns_controls"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="columnsData" xsi:type="array"> @@ -68,12 +64,10 @@ <item name="displayArea" xsi:type="string">dataGridActions</item> </item> </argument> - </container> + </component> <filterSearch name="fulltext"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/search/search</item> - <item name="displayArea" xsi:type="string">dataGridFilters</item> <item name="provider" xsi:type="string">cms_block_listing.cms_block_listing_data_source</item> <item name="chipsProvider" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.listing_filters_chips</item> <item name="storageConfig" xsi:type="array"> @@ -86,8 +80,7 @@ <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="displayArea" xsi:type="string">dataGridFilters</item> - <item name="dataScope" xsi:type="string">filters</item> + <item name="columnsProvider" xsi:type="string">cms_block_listing.cms_block_listing.cms_block_columns</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.filters</item> @@ -95,56 +88,11 @@ <item name="childDefaults" xsi:type="array"> <item name="provider" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.listing_filters</item> <item name="imports" xsi:type="array"> - <item name="visible" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.bookmarks:current.columns.${ $.index }.visible</item> + <item name="visible" xsi:type="string">cms_block_listing.cms_block_listing.cms_block_columns.${ $.index }:visible</item> </item> </item> </item> </argument> - <filterRange name="block_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">block_id</item> - <item name="label" xsi:type="string" translate="true">ID</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">from</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">to</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterInput name="title"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">title</item> - <item name="label" xsi:type="string" translate="true">Title</item> - </item> - </argument> - </filterInput> - <filterInput name="identifier"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">identifier</item> - <item name="label" xsi:type="string" translate="true">Identifier</item> - </item> - </argument> - </filterInput> <filterSelect name="store_id"> <argument name="optionsProvider" xsi:type="configurableObject"> <argument name="class" xsi:type="string">Magento\Cms\Ui\Component\Listing\Column\Cms\Options</argument> @@ -157,93 +105,11 @@ </item> </argument> </filterSelect> - <filterSelect name="is_active"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="label" xsi:type="string" translate="true">Status</item> - <item name="dataScope" xsi:type="string">is_active</item> - <item name="options" xsi:type="array"> - <item name="disable" xsi:type="array"> - <item name="value" xsi:type="string">0</item> - <item name="label" xsi:type="string" translate="true">Disabled</item> - </item> - <item name="enable" xsi:type="array"> - <item name="value" xsi:type="string">1</item> - <item name="label" xsi:type="string" translate="true">Enabled</item> - </item> - </item> - </item> - </argument> - </filterSelect> - <filterRange name="creation_time" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">creation_time</item> - <item name="label" xsi:type="string" translate="true">Created</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterRange name="update_time" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">update_time</item> - <item name="label" xsi:type="string" translate="true">Modified</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> </filters> <massaction name="listing_massaction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="selectProvider" xsi:type="string">cms_block_listing.cms_block_listing.cms_block_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> <item name="indexField" xsi:type="string">block_id</item> </item> </argument> @@ -281,7 +147,6 @@ <item name="namespace" xsi:type="string">current.paging</item> </item> <item name="selectProvider" xsi:type="string">cms_block_listing.cms_block_listing.cms_block_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> </item> </argument> </paging> @@ -298,8 +163,7 @@ <item name="enabled" xsi:type="boolean">true</item> <item name="indexField" xsi:type="string">block_id</item> <item name="clientConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="string">cms/block/inlineEdit</item> - <item name="validateUrl" xsi:type="string">/path/to</item> + <item name="saveUrl" xsi:type="url" path="cms/block/inlineEdit"/> <item name="validateBeforeSave" xsi:type="boolean">false</item> </item> </item> @@ -312,7 +176,6 @@ <item name="1" xsi:type="boolean">true</item> </item> </item> - <item name="controlVisibility" xsi:type="boolean">true</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.bookmarks</item> <item name="root" xsi:type="string">columns.${ $.index }</item> @@ -321,35 +184,24 @@ </item> </item> </argument> - <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <selectionsColumn name="ids"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> - </item> <item name="config" xsi:type="array"> <item name="indexField" xsi:type="string">block_id</item> - <item name="controlVisibility" xsi:type="boolean">false</item> </item> </argument> - </column> + </selectionsColumn> <column name="block_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> + <item name="filter" xsi:type="string">textRange</item> <item name="sorting" xsi:type="string">asc</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">ID</item> </item> </argument> </column> <column name="title"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> <item name="editor" xsi:type="array"> <item name="editorType" xsi:type="string">text</item> @@ -357,17 +209,13 @@ <item name="required-entry" xsi:type="boolean">true</item> </item> </item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Title</item> </item> </argument> </column> <column name="identifier"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> <item name="editor" xsi:type="array"> <item name="editorType" xsi:type="string">text</item> @@ -376,31 +224,22 @@ <item name="required-entry" xsi:type="boolean">true</item> </item> </item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Identifier</item> </item> </argument> </column> <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="sortable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Store View</item> </item> </argument> </column> <column name="is_active"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="options" xsi:type="array"> <item name="disable" xsi:type="array"> <item name="value" xsi:type="string">0</item> @@ -412,50 +251,40 @@ </item> </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="editor" xsi:type="string">select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Status</item> </item> </argument> </column> <column name="creation_time"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Created</item> </item> </argument> </column> <column name="update_time"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Modified</item> </item> </argument> </column> - <column name="actions" class="Magento\Cms\Ui\Component\Listing\Column\BlockActions"> + <actionsColumn name="actions" class="Magento\Cms\Ui\Component\Listing\Column\BlockActions"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">actions</item> <item name="indexField" xsi:type="string">block_id</item> - <item name="align" xsi:type="string">left</item> - <item name="label" xsi:type="string" translate="true">Action</item> - <item name="data_type" xsi:type="string">actions</item> - <item name="filterable" xsi:type="boolean">false</item> - <item name="sortable" xsi:type="boolean">false</item> </item> </argument> - </column> + </actionsColumn> </columns> </listing> diff --git a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml index 45915ef2435514e92c1539d0d9d92528ce4c85f9..c55c919be2164d32927ef1dce7d2933fcfb178da 100644 --- a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml +++ b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml @@ -49,17 +49,13 @@ <bookmark name="bookmarks"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> - <item name="displayArea" xsi:type="string">dataGridActions</item> <item name="storageConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> - <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> <item name="namespace" xsi:type="string">cms_page_listing</item> </item> </item> </argument> </bookmark> - <container name="columns_controls"> + <component name="columns_controls"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="columnsData" xsi:type="array"> @@ -69,12 +65,10 @@ <item name="displayArea" xsi:type="string">dataGridActions</item> </item> </argument> - </container> + </component> <filterSearch name="fulltext"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/search/search</item> - <item name="displayArea" xsi:type="string">dataGridFilters</item> <item name="provider" xsi:type="string">cms_page_listing.cms_page_listing_data_source</item> <item name="chipsProvider" xsi:type="string">cms_page_listing.cms_page_listing.listing_top.listing_filters_chips</item> <item name="storageConfig" xsi:type="array"> @@ -87,8 +81,7 @@ <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="displayArea" xsi:type="string">dataGridFilters</item> - <item name="dataScope" xsi:type="string">filters</item> + <item name="columnsProvider" xsi:type="string">cms_page_listing.cms_page_listing.cms_page_columns</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">cms_page_listing.cms_page_listing.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.filters</item> @@ -96,56 +89,14 @@ <item name="childDefaults" xsi:type="array"> <item name="provider" xsi:type="string">cms_page_listing.cms_page_listing.listing_top.listing_filters</item> <item name="imports" xsi:type="array"> - <item name="visible" xsi:type="string">cms_page_listing.cms_page_listing.listing_top.bookmarks:current.columns.${ $.index }.visible</item> + <item name="visible" xsi:type="string">cms_page_listing.cms_page_listing.cms_page_columns.${ $.index }:visible</item> </item> </item> </item> + <item name="observers" xsi:type="array"> + <item name="column" xsi:type="string">column</item> + </item> </argument> - <filterRange name="page_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">page_id</item> - <item name="label" xsi:type="string" translate="true">ID</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">cms_page_listing.cms_page_listing.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">from</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">to</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterInput name="title"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">title</item> - <item name="label" xsi:type="string" translate="true">Title</item> - </item> - </argument> - </filterInput> - <filterInput name="identifier"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">identifier</item> - <item name="label" xsi:type="string" translate="true">URL Key</item> - </item> - </argument> - </filterInput> <filterSelect name="store_id"> <argument name="optionsProvider" xsi:type="configurableObject"> <argument name="class" xsi:type="string">Magento\Cms\Ui\Component\Listing\Column\Cms\Options</argument> @@ -158,211 +109,11 @@ </item> </argument> </filterSelect> - <filterSelect name="is_active"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">is_active</item> - <item name="label" xsi:type="string" translate="true">Status</item> - <item name="component" xsi:type="string">Magento_Ui/js/form/element/ui-select</item> - <item name="template" xsi:type="string">ui/grid/filters/elements/ui-select</item> - <item name="options" xsi:type="array"> - <item name="disable" xsi:type="array"> - <item name="value" xsi:type="string">0</item> - <item name="label" xsi:type="string" translate="true">Disabled</item> - </item> - <item name="enable" xsi:type="array"> - <item name="value" xsi:type="string">1</item> - <item name="label" xsi:type="string" translate="true">Published</item> - </item> - </item> - </item> - </argument> - </filterSelect> - <filterRange name="creation_time" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">creation_time</item> - <item name="label" xsi:type="string" translate="true">Created</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">cms_page_listing.cms_page_listing.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">from</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">to</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterRange name="update_time" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">update_time</item> - <item name="label" xsi:type="string" translate="true">Modified</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">cms_page_listing.cms_page_listing.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">from</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">to</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterRange name="custom_theme_from" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">custom_theme_from</item> - <item name="label" xsi:type="string" translate="true">Custom design from</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">cms_page_listing.cms_page_listing.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">from</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">to</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterRange name="custom_theme_to" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">custom_theme_to</item> - <item name="label" xsi:type="string" translate="true">Custom design to</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">cms_page_listing.cms_page_listing.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">from</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">to</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterSelect name="custom_theme"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Cms\Model\Page\Source\ThemeFilter</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">custom_theme</item> - <item name="label" xsi:type="string" translate="true">Custom Theme</item> - <item name="component" xsi:type="string">Magento_Ui/js/form/element/ui-select</item> - <item name="template" xsi:type="string">ui/grid/filters/elements/ui-select</item> - </item> - </argument> - </filterSelect> - <filterSelect name="custom_root_template"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Cms\Model\Page\Source\PageLayoutFilter</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">custom_root_template</item> - <item name="label" xsi:type="string" translate="true">Custom Layout</item> - <item name="component" xsi:type="string">Magento_Ui/js/form/element/ui-select</item> - <item name="template" xsi:type="string">ui/grid/filters/elements/ui-select</item> - </item> - </argument> - </filterSelect> - <filterInput name="meta_keywords"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">meta_keywords</item> - <item name="label" xsi:type="string" translate="true">Meta Keywords</item> - </item> - </argument> - </filterInput> - <filterInput name="meta_description"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">meta_description</item> - <item name="label" xsi:type="string" translate="true">Meta Description</item> - </item> - </argument> - </filterInput> - <filterSelect name="page_layout"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Cms\Model\Page\Source\PageLayoutFilter</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/form/element/ui-select</item> - <item name="template" xsi:type="string">ui/grid/filters/elements/ui-select</item> - <item name="dataScope" xsi:type="string">page_layout</item> - <item name="label" xsi:type="string" translate="true">Layout</item> - </item> - </argument> - </filterSelect> </filters> <massaction name="listing_massaction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="selectProvider" xsi:type="string">cms_page_listing.cms_page_listing.cms_page_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> <item name="indexField" xsi:type="string">page_id</item> </item> </argument> @@ -418,7 +169,6 @@ <item name="namespace" xsi:type="string">current.paging</item> </item> <item name="selectProvider" xsi:type="string">cms_page_listing.cms_page_listing.cms_page_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> </item> </argument> </paging> @@ -435,8 +185,7 @@ <item name="enabled" xsi:type="boolean">true</item> <item name="indexField" xsi:type="string">page_id</item> <item name="clientConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="string">cms/page/inlineEdit</item> - <item name="validateUrl" xsi:type="string">/path/to</item> + <item name="saveUrl" xsi:type="url" path="cms/page/inlineEdit"/> <item name="validateBeforeSave" xsi:type="boolean">false</item> </item> </item> @@ -449,7 +198,6 @@ <item name="1" xsi:type="boolean">true</item> </item> </item> - <item name="controlVisibility" xsi:type="boolean">true</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">cms_page_listing.cms_page_listing.listing_top.bookmarks</item> <item name="root" xsi:type="string">columns.${ $.index }</item> @@ -458,65 +206,48 @@ </item> </item> </argument> - <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <selectionsColumn name="ids"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> - </item> <item name="config" xsi:type="array"> <item name="resizeEnabled" xsi:type="boolean">false</item> <item name="resizeDefaultWidth" xsi:type="string">55</item> - <item name="draggable" xsi:type="boolean">false</item> <item name="indexField" xsi:type="string">page_id</item> - <item name="controlVisibility" xsi:type="boolean">false</item> </item> </argument> - </column> + </selectionsColumn> <column name="page_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> + <item name="filter" xsi:type="string">textRange</item> <item name="sorting" xsi:type="string">asc</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">ID</item> </item> </argument> </column> <column name="title"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="editor" xsi:type="array"> <item name="editorType" xsi:type="string">text</item> <item name="validation" xsi:type="array"> <item name="required-entry" xsi:type="boolean">true</item> </item> </item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Title</item> </item> </argument> </column> <column name="identifier"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="editor" xsi:type="array"> <item name="editorType" xsi:type="string">text</item> <item name="validation" xsi:type="array"> <item name="validate-identifier" xsi:type="boolean">true</item> </item> </item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">URL Key</item> </item> </argument> @@ -524,27 +255,20 @@ <column name="page_layout"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\Cms\Model\Page\Source\PageLayout</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="editor" xsi:type="string">select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Layout</item> </item> </argument> </column> <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="sortable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Store View</item> </item> </argument> @@ -552,50 +276,42 @@ <column name="is_active"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\Cms\Model\Page\Source\IsActive</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="editor" xsi:type="string">select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Status</item> </item> </argument> </column> <column name="creation_time"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Created</item> </item> </argument> </column> <column name="update_time"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Modified</item> </item> </argument> </column> <column name="custom_theme_from"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="editor" xsi:type="string">date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Custom design from</item> <item name="dateFormat" xsi:type="string">MMM d, y</item> <item name="visible" xsi:type="boolean">false</item> @@ -604,13 +320,11 @@ </column> <column name="custom_theme_to"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="editor" xsi:type="string">date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Custom design to</item> <item name="dateFormat" xsi:type="string">MMM d, y</item> <item name="visible" xsi:type="boolean">false</item> @@ -620,13 +334,11 @@ <column name="custom_theme"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\Cms\Model\Page\Source\Theme</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="editor" xsi:type="string">select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Custom Theme</item> <item name="visible" xsi:type="boolean">false</item> </item> @@ -635,13 +347,11 @@ <column name="custom_root_template"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\Cms\Model\Page\Source\PageLayout</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="editor" xsi:type="string">select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Custom Layout</item> <item name="visible" xsi:type="boolean">false</item> </item> @@ -649,13 +359,9 @@ </column> <column name="meta_keywords"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="editor" xsi:type="string">text</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Meta Keywords</item> <item name="visible" xsi:type="boolean">false</item> </item> @@ -663,35 +369,23 @@ </column> <column name="meta_description"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="editor" xsi:type="string">text</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Meta Description</item> <item name="visible" xsi:type="boolean">false</item> </item> </argument> </column> - <column name="actions" class="Magento\Cms\Ui\Component\Listing\Column\PageActions"> + <actionsColumn name="actions" class="Magento\Cms\Ui\Component\Listing\Column\PageActions"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> <item name="resizeEnabled" xsi:type="boolean">false</item> <item name="resizeDefaultWidth" xsi:type="string">107</item> - <item name="dataType" xsi:type="string">actions</item> <item name="indexField" xsi:type="string">page_id</item> - <item name="blockVisibility" xsi:type="boolean">true</item> - <item name="align" xsi:type="string">left</item> - <item name="label" xsi:type="string" translate="true">Action</item> - <item name="data_type" xsi:type="string">actions</item> - <item name="filterable" xsi:type="boolean">false</item> - <item name="sortable" xsi:type="boolean">false</item> </item> </argument> - </column> + </actionsColumn> </columns> <container name="sticky"> <argument name="data" xsi:type="array"> diff --git a/app/code/Magento/Config/view/adminhtml/templates/system/config/edit.phtml b/app/code/Magento/Config/view/adminhtml/templates/system/config/edit.phtml index dc585c33cea087bb2aa3774c8e85b66977b8e11a..5c2157d83a930d48abe35f3d969ae25550bc3676 100644 --- a/app/code/Magento/Config/view/adminhtml/templates/system/config/edit.phtml +++ b/app/code/Magento/Config/view/adminhtml/templates/system/config/edit.phtml @@ -25,7 +25,7 @@ <script> require([ "jquery", - "Magento_Ui/js/lib/registry/registry", + "uiRegistry", "jquery/jquery.hashchange", "mage/mage", "prototype", diff --git a/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Filters.php b/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Filters.php index 8ed9f3d718e21f27955c53048d57721f89f61229..551c8a5f9ba817987980cab217563d66055d53fa 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Filters.php +++ b/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Filters.php @@ -5,43 +5,61 @@ */ namespace Magento\ConfigurableProduct\Ui\Component\Listing\AssociatedProduct; -class Filters extends \Magento\Ui\Component\Filters +use Magento\Catalog\Ui\Component\FilterFactory; +use Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory; +use Magento\Framework\View\Element\UiComponent\ObserverInterface; +use Magento\Framework\View\Element\UiComponentInterface; + +class Filters implements ObserverInterface { - /** @var \Magento\Catalog\Ui\Component\Listing\Attribute\RepositoryInterface */ - protected $attributeRepository; + /** + * @var FilterFactory + */ + protected $filterFactory; /** - * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context - * @param \Magento\Catalog\Ui\Component\FilterFactory $filterFactory - * @param \Magento\Catalog\Ui\Component\Listing\Attribute\RepositoryInterface $attributeRepository - * @param array $components - * @param array $data + * @var CollectionFactory + */ + protected $attributeCollectionFactory; + + /** + * @param FilterFactory $filterFactory + * @param CollectionFactory $attributeCollectionFactory */ public function __construct( - \Magento\Framework\View\Element\UiComponent\ContextInterface $context, - \Magento\Catalog\Ui\Component\FilterFactory $filterFactory, - \Magento\Catalog\Ui\Component\Listing\Attribute\RepositoryInterface $attributeRepository, - array $components = [], - array $data = [] + FilterFactory $filterFactory, + CollectionFactory $attributeCollectionFactory ) { - parent::__construct($context, $components, $data); $this->filterFactory = $filterFactory; - $this->attributeRepository = $attributeRepository; + $this->attributeCollectionFactory = $attributeCollectionFactory; } /** * {@inheritdoc} */ - public function prepare() + public function update(UiComponentInterface $component) { - $attributeIds = $this->getContext()->getRequestParam('attributes_codes'); + if (!$component instanceof \Magento\Ui\Component\Filters) { + return; + } + + $attributeIds = $component->getContext()->getRequestParam('attribute_ids'); if ($attributeIds) { - foreach ($this->attributeRepository->getList() as $attribute) { - $filter = $this->filterFactory->create($attribute, $this->getContext(), ['component' => '']); + foreach ($this->getAttributes($attributeIds) as $attribute) { + $filter = $this->filterFactory->create($attribute, $component->getContext()); $filter->prepare(); - $this->addComponent($attribute->getAttributeCode(), $filter); + $component->addComponent($attribute->getAttributeCode(), $filter); } } - parent::prepare(); + } + + /** + * @param array $attributeIds + * @return mixed + */ + protected function getAttributes($attributeIds) + { + $attributeCollection = $this->attributeCollectionFactory->create(); + return $attributeCollection->addFieldToFilter('attribute_code', ['in' => $attributeIds]); } } diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/attribute/new/created.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/attribute/new/created.phtml index 92a4924eab2b82dda46f626952720cebe3aa75bf..78fda69531c9fed40bf93877548d90a4244524c4 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/attribute/new/created.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/attribute/new/created.phtml @@ -15,7 +15,7 @@ } else { $('[data-form=edit-product]').trigger('changeAttributeSet', set); } - $('#create_new_attribute').dialog('close'); + $('#create_new_attribute').modal('closeModal'); })(window.parent.jQuery); </script> diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/attribute/set/js.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/attribute/set/js.phtml index d78e50b66be1f1e7d334a1078a88ad7a0b17a39e..ea036bbf5d6c0eedfd3cb70d46125ac1d9c80938 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/attribute/set/js.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/attribute/set/js.phtml @@ -9,7 +9,10 @@ ?> <script> -require(["tree-panel"], function(){ +require([ + "Magento_Ui/js/modal/alert", + "tree-panel" +], function(alert){ ConfigurableNodeExists = function(currentNode) { for (var i in currentNode.childNodes ) { if (currentNode.childNodes[i].id) { @@ -25,7 +28,9 @@ ConfigurableNodeExists = function(currentNode) { editSet.submit = editSet.submit.wrap(function(original) { if (editSet.currentNode){ if (ConfigurableNodeExists(editSet.currentNode)) { - alert('<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('This group contains attributes used in configurable products. Please move these attributes to another group and try again.')) ?>'); + alert({ + content: '<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('This group contains attributes used in configurable products. Please move these attributes to another group and try again.')) ?>' + }); return; } } @@ -34,7 +39,9 @@ editSet.submit = editSet.submit.wrap(function(original) { editSet.rightBeforeAppend = editSet.rightBeforeAppend.wrap(function(original, tree, nodeThis, node, newParent) { if (node.attributes.is_configurable == 1) { - alert('<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('This attribute is used in configurable products. You cannot remove it from the product template.')) ?>'); + alert({ + content: '<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('This attribute is used in configurable products. You cannot remove it from the product template.')) ?>' + }); return false; } return original(tree, nodeThis, node, newParent); @@ -42,7 +49,9 @@ editSet.rightBeforeAppend = editSet.rightBeforeAppend.wrap(function(original, tr editSet.rightBeforeInsert = editSet.rightBeforeInsert.wrap(function(original, tree, nodeThis, node, newParent) { if (node.attributes.is_configurable == 1) { - alert('<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('This attribute is used in configurable products. You cannot remove it from the product template.')) ?>'); + alert({ + content: '<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('This attribute is used in configurable products. You cannot remove it from the product template.')) ?>' + }); return false; } return original(tree, nodeThis, node, newParent); diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/product/configurable/affected-attribute-set-selector/js.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/product/configurable/affected-attribute-set-selector/js.phtml index 111ab842f22a9143806406e44411b7cea0584d78..704568283748a660aed1941410b28ebf1e99b622 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/product/configurable/affected-attribute-set-selector/js.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/product/configurable/affected-attribute-set-selector/js.phtml @@ -93,6 +93,7 @@ } },{ text: '<?php /* @escapeNotVerified */ echo __('Cancel'); ?>', + id: '<?php /* @escapeNotVerified */ echo $block->getJsId('close-button') ?>', 'class': 'action-close', click: function() { $form.modal('closeModal'); diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml index 8212cbc0c4a22e90c63a9473f6875b54b06b82c1..7fd14ff394f9bff99203fe4af1ace655faf37472 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml @@ -37,73 +37,24 @@ <item name="template" xsi:type="string">ui/grid/toolbar</item> </item> </argument> - <filters name="listing_filters" class="Magento\ConfigurableProduct\Ui\Component\Listing\AssociatedProduct\Filters"> + <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> + <item name="columnsProvider" xsi:type="string">configurable_associated_product_listing.configurable_associated_product_listing.product_columns</item> <item name="params" xsi:type="array"> <item name="filters_modifier" xsi:type="array" /> </item> - <item name="displayArea" xsi:type="string">dataGridFilters</item> - <item name="dataScope" xsi:type="string">filters</item> <item name="childDefaults" xsi:type="array"> <item name="provider" xsi:type="string">configurable_associated_product_listing.configurable_associated_product_listing.listing_top.listing_filters</item> + <item name="imports" xsi:type="array"> + <item name="visible" xsi:type="string">configurable_associated_product_listing.configurable_associated_product_listing.product_columns.${ $.index }:visible</item> + </item> + </item> + <item name="observers" xsi:type="array"> + <item name="filters" xsi:type="object">Magento\ConfigurableProduct\Ui\Component\Listing\AssociatedProduct\Filters</item> </item> </item> </argument> - <filterInput name="entity_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="component" xsi:type="string" /> - <item name="dataScope" xsi:type="string">entity_id</item> - <item name="label" xsi:type="string" translate="true">Name</item> - </item> - </argument> - </filterInput> - <filterInput name="name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">name</item> - <item name="label" xsi:type="string" translate="true">Name</item> - </item> - </argument> - </filterInput> - <filterInput name="sku"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">sku</item> - <item name="label" xsi:type="string" translate="true">SKU</item> - </item> - </argument> - </filterInput> - <filterRange name="price"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">price</item> - <item name="label" xsi:type="string" translate="true">Price</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">configurable_associated_product_listing.configurable_associated_product_listing.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">from</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">to</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> <filterSelect name="status"> <argument name="optionsProvider" xsi:type="configurableObject"> <argument name="class" xsi:type="string">Magento\Catalog\Model\Product\Attribute\Source\Status</argument> @@ -121,29 +72,6 @@ <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="selectProvider" xsi:type="string">configurable_associated_product_listing.configurable_associated_product_listing.product_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> - <item name="options" xsi:type="array"> - <item name="20" xsi:type="array"> - <item name="value" xsi:type="number">20</item> - <item name="label" xsi:type="string" translate="true">20</item> - </item> - <item name="30" xsi:type="array"> - <item name="value" xsi:type="number">30</item> - <item name="label" xsi:type="string" translate="true">30</item> - </item> - <item name="50" xsi:type="array"> - <item name="value" xsi:type="number">50</item> - <item name="label" xsi:type="string" translate="true">50</item> - </item> - <item name="100" xsi:type="array"> - <item name="value" xsi:type="number">100</item> - <item name="label" xsi:type="string" translate="true">100</item> - </item> - <item name="200" xsi:type="array"> - <item name="value" xsi:type="number">200</item> - <item name="label" xsi:type="string" translate="true">200</item> - </item> - </item> </item> </argument> </paging> @@ -159,31 +87,22 @@ <item name="0" xsi:type="string">${ $.$data.rowIndex }</item> </item> </item> - <item name="controlVisibility" xsi:type="boolean">true</item> </item> </item> </argument> - <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <selectionsColumn name="ids"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> - </item> <item name="config" xsi:type="array"> - <item name="controlVisibility" xsi:type="boolean">false</item> <item name="indexField" xsi:type="string">entity_id</item> <item name="sortOrder" xsi:type="number">0</item> </item> </argument> - </column> + </selectionsColumn> <column name="entity_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> + <item name="filter" xsi:type="string">textRange</item> <item name="sorting" xsi:type="string">asc</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">ID</item> <item name="sortOrder" xsi:type="number">10</item> </item> @@ -191,15 +110,12 @@ </column> <column name="thumbnail" class="Magento\Catalog\Ui\Component\Listing\Columns\Thumbnail"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/thumbnail</item> - </item> <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/thumbnail</item> <item name="add_field" xsi:type="boolean">true</item> <item name="sortable" xsi:type="boolean">false</item> <item name="altField" xsi:type="string">name</item> <item name="has_preview" xsi:type="string">1</item> - <item name="dataType" xsi:type="string">text</item> <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Thumbnail</item> <item name="sortOrder" xsi:type="number">20</item> @@ -208,13 +124,9 @@ </column> <column name="name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="add_field" xsi:type="boolean">true</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Name</item> <item name="sortOrder" xsi:type="number">30</item> </item> @@ -222,12 +134,8 @@ </column> <column name="sku"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">SKU</item> <item name="sortOrder" xsi:type="number">60</item> </item> @@ -235,13 +143,9 @@ </column> <column name="price" class="Magento\Catalog\Ui\Component\Listing\Columns\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="add_field" xsi:type="boolean">true</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Price</item> <item name="sortOrder" xsi:type="number">70</item> </item> diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml index e72edb975aede0f02d705f2a4f55de072ef3ba9a..edf1f8cae1c9ebb9bd8a2ca89a24ebaaa296c5cf 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml @@ -40,17 +40,13 @@ <bookmark name="bookmarks"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> - <item name="displayArea" xsi:type="string">dataGridActions</item> <item name="storageConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> - <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> <item name="namespace" xsi:type="string">product_attributes_listing</item> </item> </item> </argument> </bookmark> - <container name="columns_controls"> + <component name="columns_controls"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/columns</item> @@ -60,15 +56,14 @@ </item> </item> </argument> - </container> + </component> <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="links" xsi:type="array"> <item name="applied" xsi:type="string">not-save-filter</item> </item> - <item name="displayArea" xsi:type="string">dataGridFilters</item> - <item name="dataScope" xsi:type="string">filters</item> + <item name="columnsProvider" xsi:type="string">product_attributes_listing.product_attributes_listing.product_attributes_columns</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">product_attributes_listing.product_attributes_listing.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.filters</item> @@ -76,99 +71,11 @@ <item name="childDefaults" xsi:type="array"> <item name="provider" xsi:type="string">product_attributes_listing.product_attributes_listing.listing_top.listing_filters</item> <item name="imports" xsi:type="array"> - <item name="visible" xsi:type="string">product_attributes_listing.product_attributes_listing.listing_top.bookmarks:current.columns.${ $.index }.visible</item> + <item name="visible" xsi:type="string">product_attributes_listing.product_attributes_listing.product_attributes_columns:${ $.index }.visible</item> </item> </item> </item> </argument> - <filterInput name="attribute_code"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">attribute_code</item> - <item name="label" xsi:type="string" translate="true">Attribute Code</item> - </item> - </argument> - </filterInput> - <filterInput name="frontend_label"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">frontend_label</item> - <item name="label" xsi:type="string" translate="true">Attribute Label</item> - </item> - </argument> - </filterInput> - <filterSelect name="is_required"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Config\Model\Config\Source\Yesno</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">is_required</item> - <item name="label" xsi:type="string" translate="true">Required</item> - <item name="caption" xsi:type="string" translate="true">Select...</item> - </item> - </argument> - </filterSelect> - <filterSelect name="is_user_defined"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Config\Model\Config\Source\Yesno</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">is_user_defined</item> - <item name="label" xsi:type="string" translate="true">System</item> - <item name="caption" xsi:type="string" translate="true">Select...</item> - </item> - </argument> - </filterSelect> - <filterSelect name="is_visible"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Config\Model\Config\Source\Yesno</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">is_visible</item> - <item name="label" xsi:type="string" translate="true">Visible</item> - <item name="caption" xsi:type="string" translate="true">Select...</item> - </item> - </argument> - </filterSelect> - <filterSelect name="is_global"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Catalog\Model\Attribute\Source\Scopes</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">is_global</item> - <item name="label" xsi:type="string" translate="true">Scope</item> - <item name="caption" xsi:type="string" translate="true">Select...</item> - </item> - </argument> - </filterSelect> - <filterSelect name="is_searchable"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Config\Model\Config\Source\Yesno</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">is_searchable</item> - <item name="label" xsi:type="string" translate="true">Searchable</item> - <item name="caption" xsi:type="string" translate="true">Select...</item> - </item> - </argument> - </filterSelect> - <filterSelect name="is_comparable"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Config\Model\Config\Source\Yesno</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">is_comparable</item> - <item name="label" xsi:type="string" translate="true">Comparable</item> - <item name="caption" xsi:type="string" translate="true">Select...</item> - </item> - </argument> - </filterSelect> </filters> <paging name="listing_paging"> <argument name="data" xsi:type="array"> @@ -178,7 +85,6 @@ <item name="namespace" xsi:type="string">current.paging</item> </item> <item name="selectProvider" xsi:type="string">product_attributes_listing.product_attributes_listing.product_attributes_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> </item> </argument> </paging> @@ -191,7 +97,6 @@ <item name="namespace" xsi:type="string">current</item> </item> <item name="childDefaults" xsi:type="array"> - <item name="controlVisibility" xsi:type="boolean">true</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">product_attributes_listing.product_attributes_listing.listing_top.bookmarks</item> <item name="root" xsi:type="string">columns.${ $.index }</item> @@ -200,39 +105,27 @@ </item> </item> </argument> - <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <selectionsColumn name="ids"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> - </item> <item name="config" xsi:type="array"> <item name="indexField" xsi:type="string">attribute_id</item> <item name="sortOrder" xsi:type="number">0</item> - <item name="controlVisibility" xsi:type="string">false</item> </item> </argument> - </column> + </selectionsColumn> <column name="attribute_code"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> + <item name="filter" xsi:type="string">text</item> <item name="sorting" xsi:type="string">asc</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Attribute Code</item> </item> </argument> </column> <column name="frontend_label"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Attribute Label</item> </item> </argument> @@ -240,12 +133,10 @@ <column name="is_required"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\Config\Model\Config\Source\Yesno</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Required</item> </item> </argument> @@ -253,12 +144,10 @@ <column name="is_user_defined"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\Config\Model\Config\Source\Yesno</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">System</item> </item> </argument> @@ -266,12 +155,10 @@ <column name="is_visible"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\Config\Model\Config\Source\Yesno</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Visible</item> </item> </argument> @@ -279,12 +166,10 @@ <column name="is_global"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\Catalog\Model\Attribute\Source\Scopes</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Scope</item> </item> </argument> @@ -292,12 +177,10 @@ <column name="is_searchable"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\Config\Model\Config\Source\Yesno</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Searchable</item> </item> </argument> @@ -305,12 +188,10 @@ <column name="is_comparable"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\Config\Model\Config\Source\Yesno</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Comparable</item> </item> </argument> diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/product-grid.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/product-grid.js index 39267f93a149ee3247773d529e7ac8cd293e2860..37d52c6e146895267a96f72e608e96debd4bd65e 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/product-grid.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/product-grid.js @@ -115,9 +115,9 @@ define([ this.callbackName = callbackName; this.productsMassAction(function (massActionComponent) { this.productsColumns().elems().each(function (rowElement) { - rowElement.disableAction(showMassActionColumn); + rowElement.disableAction = showMassActionColumn; }); - massActionComponent.visible(showMassActionColumn); + massActionComponent.visible = showMassActionColumn; }.bind(this)); this._setFilter(filterData); this._initGrid(filterData); @@ -129,10 +129,10 @@ define([ */ close: function (rowIndex) { try { - if (this.productsMassAction().selected().length) { + if (this.productsMassAction().selected.length) { this.variationsComponent()[this.callbackName](this.productsMassAction() .selected.map(this.getProductById.bind(this))); - this.productsMassAction().selected([]); + this.productsMassAction().deselectAll(); } else if (!_.isNull(rowIndex)) { this.variationsComponent()[this.callbackName]([this.getProductByIndex(rowIndex)]); } @@ -257,7 +257,7 @@ define([ _handleManualGridOpening: function (data) { if (data.items.length && this.callbackName == 'appendProducts') { this.productsColumns().elems().each(function (rowElement) { - rowElement.disableAction(true); + rowElement.disableAction = true; }); this._disableRows(data.items); @@ -314,12 +314,14 @@ define([ */ _getVariationKeyMap: function (items) { this._variationKeyMap = {}; + _.each(items, function (row) { this._variationKeyMap[row['entity_id']] = _.values( _.pick(row, this._getAttributesCodes()) ).sort().join('-'); - }.bind(this)); + }, this); + return this._variationKeyMap; }, diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/bulk.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/bulk.js index 435a7ace21418d35de1bf96cf4b24b490315258b..5f4af9cd5e3e2e777c05fe58bd5760e938654661 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/bulk.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/bulk.js @@ -12,9 +12,10 @@ define([ 'underscore', 'Magento_Ui/js/lib/collapsible', 'mage/template', + 'Magento_Ui/js/modal/alert', 'jquery/file-uploader', 'mage/translate' -], function (Component, $, ko, _, Collapsible, mageTemplate) { +], function (Component, $, ko, _, Collapsible, mageTemplate, alert) { 'use strict'; return Component.extend({ @@ -365,7 +366,9 @@ define([ $('#' + data.fileId) .delay(2000) .hide('highlight'); - alert($.mage.__('We don\'t recognize or support this file extension type.')); + alert({ + content: $.mage.__('We don\'t recognize or support this file extension type.') + }); } $('#' + data.fileId).remove(); }, diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js index 43c040facf544c8362e30219a16fdff667d36874..862ffe05a6cfc78bfa750cce52b2c2fef1258273 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js @@ -8,8 +8,9 @@ define([ 'uiComponent', 'jquery', 'ko', - 'underscore' -], function (Component, $, ko, _) { + 'underscore', + 'Magento_Ui/js/modal/alert' +], function (Component, $, ko, _, alert) { 'use strict'; function UserException(message) { @@ -337,7 +338,9 @@ define([ parentElement.find('[name$="[image]"]').val(data.result.file); parentElement.find('[data-toggle=dropdown]').dropdown().show(); } else { - alert($.mage.__('We don\'t recognize or support this file extension type.')); + alert({ + content: $.mage.__('We don\'t recognize or support this file extension type.') + }); } }, start: function (event) { diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php index 19809e6e5ae13e5629156909bccf0babbdc9d9b6..92df9f65692f64d3e6cda9aff0e2aa64fd7fb29a 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php @@ -23,12 +23,12 @@ class ActionsTest extends \PHPUnit_Framework_TestCase public function setup() { - $this->context = $this->getMockForAbstractClass( - 'Magento\Framework\View\Element\UiComponent\ContextInterface', - [], - '', - false - ); + $this->context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->context->expects($this->any())->method('getProcessor')->willReturn($processor); $this->uiComponentFactory = $this->getMock( 'Magento\Framework\View\Element\UiComponentFactory', [], diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php index 68853c63e37515538ccc35e427120ab7200f9071..292f73888809a420b5055320577d49a5e1d5633e 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php @@ -27,12 +27,12 @@ class AttributeColumnTest extends \PHPUnit_Framework_TestCase public function setup() { - $this->context = $this->getMockForAbstractClass( - 'Magento\Framework\View\Element\UiComponent\ContextInterface', - [], - '', - false - ); + $this->context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->context->expects($this->any())->method('getProcessor')->willReturn($processor); $this->uiComponentFactory = $this->getMock( 'Magento\Framework\View\Element\UiComponentFactory', [], diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php index fbdfdf3ff4798c2e0b034a175ca92a6d6844922e..2ff207ba75f96d75a54e8bd91a63ff175e0ae023 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php @@ -32,12 +32,12 @@ class ColumnsTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->context = $this->getMockForAbstractClass( - 'Magento\Framework\View\Element\UiComponent\ContextInterface', - [], - '', - false - ); + $this->context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->context->expects($this->any())->method('getProcessor')->willReturn($processor); $this->columnFactory = $this->getMock( 'Magento\Customer\Ui\Component\ColumnFactory', ['create'], @@ -173,6 +173,7 @@ class ColumnsTest extends \PHPUnit_Framework_TestCase [ 'name' => $attributeCode, 'dataType' => $backendType, + 'filter' => 'text', 'visible' => true ] ); diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/FiltersTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/FiltersTest.php deleted file mode 100644 index 2dc73c58104a5746ba8513e3816d646aba770240..0000000000000000000000000000000000000000 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/FiltersTest.php +++ /dev/null @@ -1,135 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Customer\Test\Unit\Ui\Component\Listing; - -use Magento\Customer\Ui\Component\Listing\Filters; - -class FiltersTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $context; - - /** @var \Magento\Customer\Ui\Component\FilterFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $filterFactory; - - /** @var \Magento\Customer\Ui\Component\Listing\AttributeRepository|\PHPUnit_Framework_MockObject_MockObject */ - protected $attributeRepository; - - /** @var \Magento\Customer\Api\Data\AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $attributeMetadata; - - /** @var \Magento\Ui\Component\Listing\Columns\ColumnInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $filter; - - /** @var Filters */ - protected $component; - - public function setUp() - { - $this->context = $this->getMockForAbstractClass( - 'Magento\Framework\View\Element\UiComponent\ContextInterface', - [], - '', - false - ); - $this->filterFactory = $this->getMock( - 'Magento\Customer\Ui\Component\FilterFactory', - ['create'], - [], - '', - false - ); - $this->attributeRepository = $this->getMock( - 'Magento\Customer\Ui\Component\Listing\AttributeRepository', - [], - [], - '', - false - ); - $this->attributeMetadata = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AttributeMetadataInterface', - [], - '', - false - ); - $this->filter = $this->getMockForAbstractClass( - 'Magento\Ui\Component\Listing\Columns\ColumnInterface', - [], - '', - false - ); - - $this->component = new Filters( - $this->context, - $this->filterFactory, - $this->attributeRepository - ); - } - - public function testPrepare() - { - $attributeCode = 'billing_attribute_code'; - $attributeData = [ - 'attribute_code' => $attributeCode, - 'frontend_input' => 'frontend-input', - 'frontend_label' => 'frontend-label', - 'backend_type' => 'backend-type', - 'options' => [ - [ - 'label' => 'Label', - 'value' => 'Value' - ] - ], - 'is_used_in_grid' => true, - 'is_visible_in_grid' => true, - 'is_filterable_in_grid' => true, - 'is_searchable_in_grid' => true, - ]; - - $this->attributeRepository->expects($this->atLeastOnce()) - ->method('getList') - ->willReturn([$attributeCode => $attributeData]); - $this->filterFactory->expects($this->once()) - ->method('create') - ->with($attributeData, $this->context) - ->willReturn($this->filter); - $this->filter->expects($this->once()) - ->method('prepare'); - - $this->component->prepare(); - $this->assertSame($this->filter, $this->component->getComponent($attributeCode)); - } - - public function testPrepareWithAlreadyAddedComponent() - { - $attributeCode = 'billing_attribute_code'; - $attributeData = [ - 'attribute_code' => $attributeCode, - 'frontend_input' => 'frontend-input', - 'frontend_label' => 'frontend-label', - 'backend_type' => 'backend-type', - 'options' => [ - [ - 'label' => 'Label', - 'value' => 'Value' - ] - ], - 'is_used_in_grid' => true, - 'is_visible_in_grid' => true, - 'is_filterable_in_grid' => false, - 'is_searchable_in_grid' => true, - ]; - - $this->component->addComponent($attributeCode, $this->filter); - - $this->attributeRepository->expects($this->atLeastOnce()) - ->method('getList') - ->willReturn([$attributeCode => $attributeData]); - - $this->component->prepare(); - $this->assertEquals(null, $this->component->getComponent($attributeCode)); - } -} diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Columns.php b/app/code/Magento/Customer/Ui/Component/Listing/Columns.php index 36b2f42d3b020710b6fa2e653a6778e0926fa36f..bcb43fb4bfc2123dd62678e27fee5127c0fcd361 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/Columns.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/Columns.php @@ -23,6 +23,17 @@ class Columns extends \Magento\Ui\Component\Listing\Columns /** @var InlineEditUpdater */ protected $inlineEditUpdater; + /** + * @var array + */ + protected $filterMap = [ + 'default' => 'text', + 'select' => 'select', + 'boolean' => 'select', + 'multiselect' => 'select', + 'date' => 'dateRange', + ]; + /** * @param ContextInterface $context * @param ColumnFactory $columnFactory @@ -103,6 +114,9 @@ class Columns extends \Magento\Ui\Component\Listing\Columns public function addColumn(array $attributeData, $columnName) { $config['sortOrder'] = ++$this->columnSortOrder; + if ($attributeData[AttributeMetadata::IS_FILTERABLE_IN_GRID]) { + $config['filter'] = $this->getFilterType($attributeData[AttributeMetadata::FRONTEND_INPUT]); + } $column = $this->columnFactory->create($attributeData, $columnName, $this->getContext(), $config); $column->prepare(); $this->addComponent($attributeData[AttributeMetadata::ATTRIBUTE_CODE], $column); @@ -128,6 +142,9 @@ class Columns extends \Magento\Ui\Component\Listing\Columns 'visible' => (bool)$attributeData[AttributeMetadata::IS_VISIBLE_IN_GRID] ] ); + if ($attributeData[AttributeMetadata::IS_FILTERABLE_IN_GRID]) { + $config['filter'] = $this->getFilterType($attributeData[AttributeMetadata::FRONTEND_INPUT]); + } $component->setData('config', $config); } } else { @@ -168,4 +185,15 @@ class Columns extends \Magento\Ui\Component\Listing\Columns ); } } + + /** + * Retrieve filter type by $frontendInput + * + * @param string $frontendInput + * @return string + */ + protected function getFilterType($frontendInput) + { + return isset($this->filterMap[$frontendInput]) ? $this->filterMap[$frontendInput] : $this->filterMap['default']; + } } diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Filters.php b/app/code/Magento/Customer/Ui/Component/Listing/Filters.php deleted file mode 100644 index 2e0816d079729756e70f826148fcb86c66fd3835..0000000000000000000000000000000000000000 --- a/app/code/Magento/Customer/Ui/Component/Listing/Filters.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Customer\Ui\Component\Listing; - -use Magento\Customer\Api\Data\AttributeMetadataInterface as AttributeMetadata; - -class Filters extends \Magento\Ui\Component\Filters -{ - /** - * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context - * @param \Magento\Customer\Ui\Component\FilterFactory $filterFactory - * @param AttributeRepository $attributeRepository - * @param array $components - * @param array $data - */ - public function __construct( - \Magento\Framework\View\Element\UiComponent\ContextInterface $context, - \Magento\Customer\Ui\Component\FilterFactory $filterFactory, - \Magento\Customer\Ui\Component\Listing\AttributeRepository $attributeRepository, - array $components = [], - array $data = [] - ) { - parent::__construct($context, $components, $data); - $this->filterFactory = $filterFactory; - $this->attributeRepository = $attributeRepository; - } - - /** - * {@inheritdoc} - */ - public function prepare() - { - /** @var \Magento\Customer\Model\Attribute $attribute */ - foreach ($this->attributeRepository->getList() as $attributeCode => $attributeData) { - if (!isset($this->components[$attributeCode])) { - if (!$attributeData[AttributeMetadata::BACKEND_TYPE] != 'static' - && $attributeData[AttributeMetadata::IS_USED_IN_GRID] - && $attributeData[AttributeMetadata::IS_FILTERABLE_IN_GRID] - ) { - $filter = $this->filterFactory->create($attributeData, $this->getContext()); - $filter->prepare(); - $this->addComponent($attributeCode, $filter); - } - } elseif ($attributeData[AttributeMetadata::IS_USED_IN_GRID] - && !$attributeData[AttributeMetadata::IS_FILTERABLE_IN_GRID] - ) { - unset($this->components[$attributeCode]); - } - } - parent::prepare(); - } -} diff --git a/app/code/Magento/Customer/view/adminhtml/templates/tab/cart.phtml b/app/code/Magento/Customer/view/adminhtml/templates/tab/cart.phtml index 82cd7c7066718720a42ff7239656bb3956f838bb..f7d93b699c1af76a20db9c3aa4f522d07701c838 100644 --- a/app/code/Magento/Customer/view/adminhtml/templates/tab/cart.phtml +++ b/app/code/Magento/Customer/view/adminhtml/templates/tab/cart.phtml @@ -24,8 +24,10 @@ ?> <script> require([ + "Magento_Ui/js/modal/alert", + "Magento_Ui/js/modal/confirm", "Magento_Catalog/catalog/product/composite/configure" -], function(){ +], function(alert, confirm){ <?php /* @escapeNotVerified */ echo $block->getJsObjectName() ?>cartControl = { reload: function (params) { @@ -51,17 +53,24 @@ require([ }, removeItem: function (itemId) { + var self = this; + if (!itemId) { - alert('<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('No item specified.')) ?>'); - return false; - } - if(!confirm('<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('Are you sure you want to remove this item?')) ?>')) { + alert({ + content: '<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('No item specified.')) ?>' + }); + return false; } - this.reload({'delete':itemId}); - - return false; + confirm({ + content: '<?php /* @escapeNotVerified */ echo $block->escapeJsQuote(__('Are you sure you want to remove this item?')) ?>', + actions: { + confirm: function(){ + self.reload({'delete':itemId}); + } + } + }); } }; diff --git a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml index 44af0c2764ffa164c440fcb38c6c6efa701b3971..5c01b2cb6c7b8aced92bd6ddd731325c7abcc3bd 100644 --- a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml +++ b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml @@ -48,17 +48,13 @@ <bookmark name="bookmarks"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> - <item name="displayArea" xsi:type="string">dataGridActions</item> <item name="storageConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> - <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> <item name="namespace" xsi:type="string">customer_listing</item> </item> </item> </argument> </bookmark> - <container name="columns_controls"> + <component name="columns_controls"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="columnsData" xsi:type="array"> @@ -68,7 +64,7 @@ <item name="displayArea" xsi:type="string">dataGridActions</item> </item> </argument> - </container> + </component> <exportButton name="export_button"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> @@ -79,8 +75,6 @@ <filterSearch name="fulltext"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/search/search</item> - <item name="displayArea" xsi:type="string">dataGridFilters</item> <item name="provider" xsi:type="string">customer_listing.customer_listing_data_source</item> <item name="chipsProvider" xsi:type="string">customer_listing.customer_listing.listing_top.listing_filters_chips</item> <item name="storageConfig" xsi:type="array"> @@ -90,11 +84,10 @@ </item> </argument> </filterSearch> - <filters name="listing_filters" class="Magento\Customer\Ui\Component\Listing\Filters"> + <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="displayArea" xsi:type="string">dataGridFilters</item> - <item name="dataScope" xsi:type="string">filters</item> + <item name="columnsProvider" xsi:type="string">customer_listing.customer_listing.customer_columns</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">customer_listing.customer_listing.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.filters</item> @@ -102,154 +95,17 @@ <item name="childDefaults" xsi:type="array"> <item name="provider" xsi:type="string">customer_listing.customer_listing.listing_top.listing_filters</item> <item name="imports" xsi:type="array"> - <item name="visible" xsi:type="string">customer_listing.customer_listing.listing_top.bookmarks:current.columns.${ $.index }.visible</item> + <item name="visible" xsi:type="string">customer_listing.customer_listing.customer_columns.${ $.index }:visible</item> </item> </item> </item> </argument> - <filterRange name="entity_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">entity_id</item> - <item name="label" xsi:type="string" translate="true">ID</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">customer_listing.customer_listing.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">from</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">to</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterInput name="name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">name</item> - <item name="label" xsi:type="string" translate="true">Name</item> - </item> - </argument> - </filterInput> - <filterInput name="email"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">email</item> - <item name="label" xsi:type="string" translate="true">Email</item> - </item> - </argument> - </filterInput> - <filterSelect name="group_id"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Customer\Model\Config\Source\Group\Multiselect</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">group_id</item> - <item name="label" xsi:type="string" translate="true">Group</item> - <item name="caption" xsi:type="string" translate="true">Select...</item> - </item> - </argument> - </filterSelect> - <filterInput name="billing_telephone"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_telephone</item> - <item name="label" xsi:type="string" translate="true">Phone</item> - </item> - </argument> - </filterInput> - <filterInput name="billing_postcode"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_postcode</item> - <item name="label" xsi:type="string" translate="true">ZIP</item> - </item> - </argument> - </filterInput> - <filterSelect name="billing_country_id"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Directory\Model\ResourceModel\Country\Collection</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_country_id</item> - <item name="label" xsi:type="string" translate="true">Country</item> - <item name="caption" xsi:type="string" translate="true">Select...</item> - </item> - </argument> - </filterSelect> - <filterInput name="billing_region"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_region</item> - <item name="label" xsi:type="string" translate="true">State/Province</item> - </item> - </argument> - </filterInput> - <filterRange name="created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">created_at</item> - <item name="label" xsi:type="string" translate="true">Customer Since</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">customer_listing.customer_listing.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterSelect name="website_id"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Config\Model\Config\Source\Website</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">website_id</item> - <item name="label" xsi:type="string" translate="true">Website</item> - <item name="caption" xsi:type="string" translate="true">Select...</item> - </item> - </argument> - </filterSelect> </filters> <massaction name="listing_massaction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="selectProvider" xsi:type="string">customer_listing.customer_listing.customer_columns.ids</item> <item name="component" xsi:type="string">Magento_Ui/js/grid/tree-massactions</item> - <item name="displayArea" xsi:type="string">bottom</item> <item name="indexField" xsi:type="string">entity_id</item> </item> </argument> @@ -328,7 +184,6 @@ <item name="namespace" xsi:type="string">current.paging</item> </item> <item name="selectProvider" xsi:type="string">customer_listing.customer_listing.customer_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> </item> </argument> </paging> @@ -345,8 +200,7 @@ <item name="enabled" xsi:type="boolean">true</item> <item name="indexField" xsi:type="string">entity_id</item> <item name="clientConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="string">customer/index/inlineEdit</item> - <item name="validateUrl" xsi:type="string">/path/to</item> + <item name="saveUrl" xsi:type="url" path="customer/index/inlineEdit"/> <item name="validateBeforeSave" xsi:type="boolean">false</item> </item> </item> @@ -359,7 +213,6 @@ <item name="1" xsi:type="boolean">true</item> </item> </item> - <item name="controlVisibility" xsi:type="boolean">true</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">customer_listing.customer_listing.listing_top.bookmarks</item> <item name="root" xsi:type="string">columns.${ $.index }</item> @@ -368,28 +221,19 @@ </item> </item> </argument> - <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <selectionsColumn name="ids"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> - </item> <item name="config" xsi:type="array"> <item name="indexField" xsi:type="string">entity_id</item> - <item name="controlVisibility" xsi:type="boolean">false</item> <item name="sortOrder" xsi:type="number">10</item> </item> </argument> - </column> + </selectionsColumn> <column name="entity_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> + <item name="filter" xsi:type="string">textRange</item> <item name="sorting" xsi:type="string">asc</item> - <item name="sortable" xsi:type="string">true</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">ID</item> <item name="sortOrder" xsi:type="number">20</item> </item> @@ -397,13 +241,8 @@ </column> <column name="name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="sortable" xsi:type="string">true</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Name</item> <item name="sortOrder" xsi:type="number">30</item> </item> @@ -411,14 +250,9 @@ </column> <column name="email"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="editor" xsi:type="string">text</item> - <item name="sortable" xsi:type="string">true</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Email</item> <item name="sortOrder" xsi:type="number">40</item> </item> @@ -426,16 +260,11 @@ </column> <column name="group_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> - <item name="editor" xsi:type="array"> - <item name="editorType" xsi:type="string">select</item> - </item> - <item name="sortable" xsi:type="string">true</item> + <item name="filter" xsi:type="string">select</item> + <item name="editor" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Group</item> <item name="sortOrder" xsi:type="number">50</item> </item> @@ -443,14 +272,9 @@ </column> <column name="billing_telephone"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="editor" xsi:type="string">text</item> - <item name="sortable" xsi:type="string">true</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Phone</item> <item name="sortOrder" xsi:type="number">60</item> </item> @@ -458,14 +282,9 @@ </column> <column name="billing_postcode"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="editor" xsi:type="string">text</item> - <item name="sortable" xsi:type="string">true</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">ZIP</item> <item name="sortOrder" xsi:type="number">70</item> </item> @@ -473,12 +292,10 @@ </column> <column name="billing_country_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Country</item> <item name="sortOrder" xsi:type="number">80</item> </item> @@ -486,13 +303,8 @@ </column> <column name="billing_region"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="sortable" xsi:type="string">true</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">State/Province</item> <item name="sortOrder" xsi:type="number">90</item> </item> @@ -500,13 +312,9 @@ </column> <column name="created_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> - <item name="sortable" xsi:type="string">true</item> + <item name="filter" xsi:type="string">dateRange</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Customer Since</item> <item name="sortOrder" xsi:type="number">100</item> </item> @@ -514,30 +322,23 @@ </column> <column name="website_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> - <item name="editor" xsi:type="array"> - <item name="editorType" xsi:type="string">select</item> - </item> + <item name="filter" xsi:type="string">select</item> + <item name="editor" xsi:type="string">select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="label" xsi:type="string" translate="true">Web Site</item> <item name="sortOrder" xsi:type="number">110</item> </item> </argument> </column> - <column name="last_visit_at" > + <column name="last_visit_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> - <item name="sortable" xsi:type="string">true</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> + <item name="filter" xsi:type="string">dateRange</item> <item name="visible" xsi:type="boolean">false</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Last Logged In</item> <item name="sortOrder" xsi:type="number">120</item> </item> @@ -545,14 +346,8 @@ </column> <column name="confirmation"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="sortable" xsi:type="string">true</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Confirmed email</item> <item name="sortOrder" xsi:type="number">130</item> </item> @@ -560,14 +355,8 @@ </column> <column name="created_in"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="sortable" xsi:type="string">true</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Account Created in</item> <item name="sortOrder" xsi:type="number">140</item> </item> @@ -575,13 +364,8 @@ </column> <column name="billing_full"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Billing Address</item> <item name="sortOrder" xsi:type="number">150</item> </item> @@ -589,13 +373,8 @@ </column> <column name="shipping_full"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping Address</item> <item name="sortOrder" xsi:type="number">160</item> </item> @@ -603,31 +382,22 @@ </column> <column name="dob"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> - <item name="editor" xsi:type="string">date</item> - <item name="sortable" xsi:type="string">true</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="visible" xsi:type="boolean">false</item> + <item name="filter" xsi:type="string">dateRange</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> - <item name="label" xsi:type="string" translate="true">Date Of Birth</item> + <item name="label" xsi:type="string" translate="true">Date of Birth</item> <item name="sortOrder" xsi:type="number">170</item> </item> </argument> </column> <column name="taxvat"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="editor" xsi:type="string">text</item> - <item name="sortable" xsi:type="string">true</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Tax VAT Number</item> <item name="sortOrder" xsi:type="number">180</item> </item> @@ -635,14 +405,12 @@ </column> <column name="gender"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + <item name="filter" xsi:type="string">select</item> <item name="editor" xsi:type="string">select</item> <item name="visible" xsi:type="boolean">false</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Gender</item> <item name="sortOrder" xsi:type="number">190</item> </item> @@ -650,13 +418,8 @@ </column> <column name="billing_street"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Street Address</item> <item name="sortOrder" xsi:type="number">200</item> </item> @@ -664,15 +427,10 @@ </column> <column name="billing_city"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="editor" xsi:type="string">text</item> - <item name="sortable" xsi:type="string">true</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">City</item> <item name="sortOrder" xsi:type="number">210</item> </item> @@ -680,15 +438,10 @@ </column> <column name="billing_fax"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="editor" xsi:type="string">text</item> - <item name="sortable" xsi:type="string">true</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Fax</item> <item name="sortOrder" xsi:type="number">220</item> </item> @@ -696,15 +449,10 @@ </column> <column name="billing_vat_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="editor" xsi:type="string">text</item> - <item name="sortable" xsi:type="string">true</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">VAT Number</item> <item name="sortOrder" xsi:type="number">230</item> </item> @@ -712,15 +460,10 @@ </column> <column name="billing_company"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="editor" xsi:type="string">text</item> - <item name="sortable" xsi:type="string">true</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Company</item> <item name="sortOrder" xsi:type="number">240</item> </item> @@ -728,15 +471,10 @@ </column> <column name="billing_firstname"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="editor" xsi:type="string">text</item> - <item name="sortable" xsi:type="string">true</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Billing Firstname</item> <item name="sortOrder" xsi:type="number">250</item> </item> @@ -744,33 +482,21 @@ </column> <column name="billing_lastname"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="editor" xsi:type="string">text</item> - <item name="sortable" xsi:type="string">true</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Billing Lastname</item> <item name="sortOrder" xsi:type="number">260</item> </item> </argument> </column> - <column name="actions" class="Magento\Customer\Ui\Component\Listing\Column\Actions"> + <actionsColumn name="actions" class="Magento\Customer\Ui\Component\Listing\Column\Actions"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">actions</item> <item name="indexField" xsi:type="string">entity_id</item> - <item name="align" xsi:type="string">left</item> - <item name="label" xsi:type="string" translate="true">Action</item> - <item name="data_type" xsi:type="string">actions</item> - <item name="filterable" xsi:type="boolean">false</item> - <item name="sortable" xsi:type="boolean">false</item> </item> </argument> - </column> + </actionsColumn> </columns> </listing> diff --git a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml index 4c7b5ed565fb1c03faebb1afcdde2f34b2a8c49c..c864f2ac240f44a160f0420ce22dcbfaee91081f 100644 --- a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml +++ b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml @@ -40,17 +40,13 @@ <bookmark name="bookmarks"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> - <item name="displayArea" xsi:type="string">dataGridActions</item> <item name="storageConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> - <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> <item name="namespace" xsi:type="string">customer_online_grid</item> </item> </item> </argument> </bookmark> - <container name="columns_controls"> + <component name="columns_controls"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="columnsData" xsi:type="array"> @@ -60,12 +56,11 @@ <item name="displayArea" xsi:type="string">dataGridActions</item> </item> </argument> - </container> + </component> <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="displayArea" xsi:type="string">dataGridFilters</item> - <item name="dataScope" xsi:type="string">filters</item> + <item name="columnsProvider" xsi:type="string">customer_online_grid.customer_online_grid.customer_online_columns</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">customer_online_grid.customer_online_grid.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.filters</item> @@ -73,107 +68,11 @@ <item name="childDefaults" xsi:type="array"> <item name="provider" xsi:type="string">customer_online_grid.customer_online_grid.listing_top.listing_filters</item> <item name="imports" xsi:type="array"> - <item name="visible" xsi:type="string">customer_online_grid.customer_online_grid.listing_top.bookmarks:current.columns.${ $.index }.visible</item> + <item name="visible" xsi:type="string">customer_online_grid.customer_online_grid.customer_online_columns.${ $.index }:visible</item> </item> </item> </item> </argument> - <filterRange name="customer_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">customer_id</item> - <item name="label" xsi:type="string" translate="true">ID</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">customer_online_grid.customer_online_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterInput name="firstname"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">firstname</item> - <item name="label" xsi:type="string" translate="true">First Name</item> - </item> - </argument> - </filterInput> - <filterInput name="lastname"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">lastname</item> - <item name="label" xsi:type="string" translate="true">Last Name</item> - </item> - </argument> - </filterInput> - <filterInput name="email"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">email</item> - <item name="label" xsi:type="string" translate="true">Email</item> - </item> - </argument> - </filterInput> - <filterRange name="last_visit_at" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">last_visit_at</item> - <item name="label" xsi:type="string" translate="true">Last Activity</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">customer_online_grid.customer_online_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterSelect name="visitor_type"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Customer\Ui\Component\Listing\Column\Online\Type\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">visitor_type</item> - <item name="label" xsi:type="string" translate="true">Type</item> - </item> - </argument> - </filterSelect> </filters> <paging name="listing_paging"> <argument name="data" xsi:type="array"> @@ -183,7 +82,6 @@ <item name="namespace" xsi:type="string">current.paging</item> </item> <item name="selectProvider" xsi:type="string">customer_online_grid.customer_online_grid.customer_online_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> </item> </argument> </paging> @@ -196,9 +94,6 @@ <item name="namespace" xsi:type="string">current</item> </item> <item name="childDefaults" xsi:type="array"> - <item name="controlVisibility" xsi:type="boolean">true</item> - <item name="actionField" xsi:type="string">actions</item> - <item name="clickAction" xsi:type="string">view</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">customer_online_grid.customer_online_grid.listing_top.bookmarks</item> <item name="root" xsi:type="string">columns.${ $.index }</item> @@ -207,125 +102,80 @@ </item> </item> </argument> - <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> - <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> - </item> - <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> - <item name="indexField" xsi:type="string">visitor_id</item> - <item name="controlVisibility" xsi:type="boolean">false</item> - </item> - </argument> - </column> <column name="customer_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">textRange</item> + <item name="sorting" xsi:type="string">asc</item> <item name="label" xsi:type="string" translate="true">ID</item> </item> </argument> </column> <column name="firstname"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">First Name</item> </item> </argument> </column> <column name="lastname"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Last Name</item> </item> </argument> </column> <column name="email"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Email</item> </item> </argument> </column> - <!--<column name="remote_addr">--> - <!--<argument name="data" xsi:type="array">--> - <!--<item name="js_config" xsi:type="array">--> - <!--<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item>--> - <!--</item>--> - <!--<item name="config" xsi:type="array">--> - <!--<item name="dataType" xsi:type="string">text</item>--> - <!--<item name="align" xsi:type="string">left</item>--> - <!--<item name="label" xsi:type="string" translate="true">IP Address</item>--> - <!--</item>--> - <!--</argument>--> - <!--</column>--> - <column name="first_visit_at"> + <!-- <column name="remote_addr"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> + <item name="config" xsi:type="array"> + <item name="label" xsi:type="string" translate="true">IP Address</item> </item> + </argument> + </column> --> + <column name="first_visit_at"> + <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Session Start Time</item> </item> </argument> </column> <column name="last_visit_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Last Activity</item> </item> </argument> </column> - <column name="visitor_type" class="Magento\Customer\Ui\Component\Listing\Column\Online\Type"> + <column name="visitor_type"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> + <item name="options" xsi:type="object">Magento\Customer\Ui\Component\Listing\Column\Online\Type\Options</item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Type</item> </item> </argument> </column> - <!--<column name="last_url">--> - <!--<argument name="data" xsi:type="array">--> - <!--<item name="js_config" xsi:type="array">--> - <!--<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item>--> - <!--</item>--> - <!--<item name="config" xsi:type="array">--> - <!--<item name="dataType" xsi:type="string">text</item>--> - <!--<item name="align" xsi:type="string">left</item>--> - <!--<item name="label" xsi:type="string" translate="true">Last URL</item>--> - <!--</item>--> - <!--</argument>--> - <!--</column>--> + <!-- <column name="last_url"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="label" xsi:type="string" translate="true">Last URL</item> + </item> + </argument> + </column> --> </columns> </listing> diff --git a/app/code/Magento/Customer/view/adminhtml/web/edit/tab/js/addresses.js b/app/code/Magento/Customer/view/adminhtml/web/edit/tab/js/addresses.js index 7067fbe2e153bed002acf81ced41a5daba3fefe0..cbaaafb86bcdf51b31d9f8f93e389f9c09ac346d 100644 --- a/app/code/Magento/Customer/view/adminhtml/web/edit/tab/js/addresses.js +++ b/app/code/Magento/Customer/view/adminhtml/web/edit/tab/js/addresses.js @@ -5,9 +5,10 @@ define([ 'jquery', 'mage/template', + 'Magento_Ui/js/modal/confirm', 'jquery/ui', 'mage/backend/tabs' -], function ($, mageTemplate) { +], function ($, mageTemplate, confirm) { 'use strict'; $.widget('mage.addressTabs', $.mage.tabs, { @@ -136,9 +137,16 @@ define([ * @private */ _deleteItemPrompt: function (event, data) { - if (window.confirm(this.options.deleteConfirmPrompt)) { - this._deleteItem(data.item); - } + var self = this; + + confirm({ + content: this.options.deleteConfirmPrompt, + actions: { + confirm: function () { + self._deleteItem(data.item); + } + } + }); }, /** diff --git a/app/code/Magento/Customer/view/base/ui_component/customer_form.xml b/app/code/Magento/Customer/view/base/ui_component/customer_form.xml index b7646d9b11f48af4e8f40c5154be6897150f9877..0fa2ab59bcc75e9d49a6c72c7475adafefca3332 100644 --- a/app/code/Magento/Customer/view/base/ui_component/customer_form.xml +++ b/app/code/Magento/Customer/view/base/ui_component/customer_form.xml @@ -120,10 +120,8 @@ <container name="container_group"> <argument name="data" xsi:type="array"> <item name="type" xsi:type="string">group</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item> - </item> <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item> <item name="label" xsi:type="string" translate="true">Group</item> <item name="required" xsi:type="boolean">true</item> <item name="dataScope" xsi:type="boolean">false</item> @@ -351,10 +349,8 @@ <container name="street_container"> <argument name="data" xsi:type="array"> <item name="type" xsi:type="string">group</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item> - </item> <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item> <item name="label" xsi:type="string" translate="true">Street Address</item> <item name="required" xsi:type="boolean">true</item> <item name="dataScope" xsi:type="string">street</item> diff --git a/app/code/Magento/Customer/view/frontend/web/address.js b/app/code/Magento/Customer/view/frontend/web/address.js index 5a6ea1b6ee3e76127760dd8759bdd742b8b8ea2e..4ea88c7067b400500e22917c25ec5dc21084d6f5 100644 --- a/app/code/Magento/Customer/view/frontend/web/address.js +++ b/app/code/Magento/Customer/view/frontend/web/address.js @@ -6,9 +6,10 @@ /*global confirm:true*/ define([ "jquery", + 'Magento_Ui/js/modal/confirm', "jquery/ui", "mage/translate" -], function($){ +], function($, confirm){ "use strict"; $.widget('mage.address', { @@ -53,14 +54,22 @@ define([ * @return {Boolean} */ _deleteAddress: function(e) { - if (confirm(this.options.deleteConfirmMessage)) { - if (typeof $(e.target).parent().data('address') !== 'undefined') { - window.location = this.options.deleteUrlPrefix + $(e.target).parent().data('address'); - } - else { - window.location = this.options.deleteUrlPrefix + $(e.target).data('address'); + var self = this; + + confirm({ + content: this.options.deleteConfirmMessage, + actions: { + confirm: function() { + if (typeof $(e.target).parent().data('address') !== 'undefined') { + window.location = self.options.deleteUrlPrefix + $(e.target).parent().data('address'); + } + else { + window.location = self.options.deleteUrlPrefix + $(e.target).data('address'); + } + } } - } + }); + return false; } }); diff --git a/app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js b/app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js index 324b0711f6b0381c7d323d3b9f1f9d0c25cc1996..dffbc6c380eade6a17adfd1b7d26c01b9ba5bc46 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js +++ b/app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js @@ -14,9 +14,10 @@ define( 'Magento_Customer/js/model/authentication-popup', 'mage/translate', 'mage/url', + 'Magento_Ui/js/modal/alert', 'mage/validation' ], - function($, ko, Component, loginAction, customerData, authenticationPopup, $t, url) { + function($, ko, Component, loginAction, customerData, authenticationPopup, $t, url, alert) { 'use strict'; return Component.extend({ registerUrl: window.authenticationPopup.customerRegisterUrl, @@ -55,7 +56,9 @@ define( if (this.modalWindow) { $(this.modalWindow).modal('openModal'); } else { - alert($t('Guest checkout is disabled.')); + alert({ + content: $t('Guest checkout is disabled.') + }); } }, diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml index 688d231547f437eaf906b38beca4503ea91ab729..0c4077543059fd746f88a67b946889ca286ce287 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml @@ -16,11 +16,12 @@ <script> require([ 'jquery', - 'Magento_Ui/js/lib/registry/registry', + 'uiRegistry', 'mage/template', + 'Magento_Ui/js/modal/alert', 'mage/mage', 'prototype' -], function (jQuery, registry, mageTemplate) { +], function (jQuery, registry, mageTemplate, alert) { //<![CDATA[> var uploaderTemplate = '<div class="no-display" id="[[idName]]-template">' + @@ -113,7 +114,9 @@ var uploaderTemplate = '<div class="no-display" id="[[idName]]-template">' + try { console.log(e); } catch (e2) { - alert(e.name + '\n' + e.message); + alert({ + content: e.name + '\n' + e.message + }); } } }, @@ -124,7 +127,9 @@ var uploaderTemplate = '<div class="no-display" id="[[idName]]-template">' + try { console.log(e); } catch (e2) { - alert(e.name + '\n' + e.message); + alert({ + content: e.name + '\n' + e.message + }); } } }, @@ -142,7 +147,9 @@ var uploaderTemplate = '<div class="no-display" id="[[idName]]-template">' + try { console.log(e); } catch (e2) { - alert(e.name + '\n' + e.message); + alert({ + content: e.name + '\n' + e.message + }); } } } diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/links.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/links.phtml index f68fcc7b1963f5406a6bc57d7f33530efd1dfb3d..d5c4b6dca86ea769bc9bb04fe98309bffcccd0e5 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/links.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/links.phtml @@ -73,7 +73,7 @@ <script> require([ 'jquery', - 'Magento_Ui/js/lib/registry/registry', + 'uiRegistry', 'mage/template', 'jquery/file-uploader', 'mage/mage', diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml index 7ea23e633c6c9732a5857a16ddd81065a9db399b..cd78725695ef1d6b2590310c721d4fa412127cfa 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml @@ -60,7 +60,7 @@ $block->getConfigJson(); <script> require([ 'jquery', - 'Magento_Ui/js/lib/registry/registry', + 'uiRegistry', 'mage/template', 'jquery/file-uploader', 'prototype' diff --git a/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml b/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml index 6ca97943019f9a2a128f6dd78c716b1fa3a1176a..7036d332825c43d4068879ebccf080a4993c74b2 100644 --- a/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml +++ b/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml @@ -59,10 +59,11 @@ use Magento\Framework\App\TemplateTypesInterface; require([ "jquery", "tinymce", + "Magento_Ui/js/modal/alert", "mage/mage", "Magento_Variable/variables", "prototype" -], function(jQuery, tinyMCE){ +], function(jQuery, tinyMCE, alert){ //<![CDATA[ jQuery('#email_template_edit_form').mage('form').mage('validation'); @@ -207,7 +208,9 @@ require([ } }.bind(this)); } else { - alert('<?php /* @escapeNotVerified */ echo __('The template did not load. Please review the log for details.') ?>'); + alert({ + content: '<?php /* @escapeNotVerified */ echo __('The template did not load. Please review the log for details.') ?>' + }); } }.bind(this) }); diff --git a/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-message.js b/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-message.js index ad91613b1364535ec43548e251bb46fefb67ec5f..502e3ab77d2a9d5bc5e8298dbf1084b99cee57b6 100644 --- a/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-message.js +++ b/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-message.js @@ -3,9 +3,12 @@ * See COPYING.txt for license details. */ /*global define*/ -define(['Magento_Ui/js/lib/component/provider', 'underscore', 'mage/url'], - function (provider, _, url) { - "use strict"; +define(['uiElement', 'underscore', 'mage/url'], + function (uiElement, _, url) { + 'use strict'; + + var provider = uiElement(); + return function (itemId) { var model = { id: 'message-' + itemId, diff --git a/app/code/Magento/ImportExport/view/adminhtml/templates/export/form/before.phtml b/app/code/Magento/ImportExport/view/adminhtml/templates/export/form/before.phtml index c9084964d9ffb2f6fb34fa9b768bc58fe1f73a98..e5c60e69e8272bea15620679817d5467a236169b 100644 --- a/app/code/Magento/ImportExport/view/adminhtml/templates/export/form/before.phtml +++ b/app/code/Magento/ImportExport/view/adminhtml/templates/export/form/before.phtml @@ -5,7 +5,10 @@ */ ?> <script> -require(['prototype'], function(){ +require([ + 'Magento_Ui/js/modal/alert', + 'prototype' +], function(alert){ //<![CDATA[ // Temporary Class will be replaced after refactoring of import/export functionality @@ -81,7 +84,9 @@ require(['prototype'], function(){ form.submit(); form.action = oldAction; } else { - alert('Invalid data'); + alert({ + content: 'Invalid data' + }); } }; diff --git a/app/code/Magento/ImportExport/view/adminhtml/templates/import/form/before.phtml b/app/code/Magento/ImportExport/view/adminhtml/templates/import/form/before.phtml index 78b5a7139d7bb1f782b77b940c7f88776ea0c7bb..b74663620882ad4159b0c7bfd53d4ce79d9b80c1 100644 --- a/app/code/Magento/ImportExport/view/adminhtml/templates/import/form/before.phtml +++ b/app/code/Magento/ImportExport/view/adminhtml/templates/import/form/before.phtml @@ -10,7 +10,11 @@ /** @var $block \Magento\ImportExport\Block\Adminhtml\Import\Edit\Before */ ?> <script> -require(['jquery', 'prototype'], function(jQuery){ +require([ + 'jquery', + 'Magento_Ui/js/modal/alert', + 'prototype' +], function(jQuery, alert){ //<![CDATA[ // Temporary Class will be replaced after refactoring of import/export functionality @@ -200,7 +204,11 @@ require(['jquery', 'prototype'], function(jQuery){ */ postToFrameProcessResponse: function(response) { if ('object' != typeof(response)) { - return alert('Invalid response'); + alert({ + content: 'Invalid response' + }); + + return false; } $H(response).each(function(pair) { switch (pair.key) { @@ -231,7 +239,9 @@ require(['jquery', 'prototype'], function(jQuery){ }); break; default: - alert(pair.key + ': ' + pair.value); + alert({ + content: pair.key + ': ' + pair.value + }); break; } }); diff --git a/app/code/Magento/Integration/view/adminhtml/templates/integration/popup_container.phtml b/app/code/Magento/Integration/view/adminhtml/templates/integration/popup_container.phtml index 43e7996f6c192a0c176d8992cb36ef1a920bf41b..1150ac083a6c19df536c3cfaf6b5459a40340f86 100644 --- a/app/code/Magento/Integration/view/adminhtml/templates/integration/popup_container.phtml +++ b/app/code/Magento/Integration/view/adminhtml/templates/integration/popup_container.phtml @@ -11,66 +11,40 @@ // @codingStandardsIgnoreFile ?> <script> -require([ - "jquery", - "jquery/ui", - "Magento_Integration/js/integration" -], function($){ + require([ + "jquery", + 'Magento_Ui/js/modal/confirm', + "jquery/ui", + "Magento_Integration/js/integration" + ], function ($, Confirm) { - window.integration = new Integration( - '<?php /* @escapeNotVerified */ echo $block->getUrl('*/*/permissionsDialog', ['id' => ':id', 'reauthorize' => ':isReauthorize']); ?>', - '<?php /* @escapeNotVerified */ echo $block->getUrl('*/*/tokensDialog', ['id' => ':id', 'reauthorize' => ':isReauthorize']); ?>', - '<?php /* @escapeNotVerified */ echo $block->getUrl('*/*/tokensExchange', ['id' => ':id', 'reauthorize' => ':isReauthorize']); ?>', - '<?php /* @escapeNotVerified */ echo $block->getUrl('*/*'); ?>', - '<?php /* @escapeNotVerified */ echo $block->getUrl('*/*/loginSuccessCallback'); ?>' - ); + window.integration = new Integration( + '<?php /* @escapeNotVerified */ echo $block->getUrl('*/*/permissionsDialog', ['id' => ':id', 'reauthorize' => ':isReauthorize']); ?>', + '<?php /* @escapeNotVerified */ echo $block->getUrl('*/*/tokensDialog', ['id' => ':id', 'reauthorize' => ':isReauthorize']); ?>', + '<?php /* @escapeNotVerified */ echo $block->getUrl('*/*/tokensExchange', ['id' => ':id', 'reauthorize' => ':isReauthorize']); ?>', + '<?php /* @escapeNotVerified */ echo $block->getUrl('*/*'); ?>', + '<?php /* @escapeNotVerified */ echo $block->getUrl('*/*/loginSuccessCallback'); ?>' + ); - /** - * Confirm dialog for delete integration action - */ - $(function () { - $('div#integrationGrid').on('click', 'button#delete', function (e) { - $('#integration-delete-container').dialog({ - modal: true, - autoOpen: true, - resizable: false, - minHeight: 0, - width: '75%', - dialogClass: 'no-close ui-popup-message', - position: { - my: 'left top', - at: 'center top', - of: 'body' - }, - open: function () { - $(this).closest('.ui-dialog').addClass('ui-dialog-active'); + /** + * Confirm dialog for delete integration action + */ + $(function () { + $('div#integrationGrid').on('click', 'button#delete', function (e) { - var topMargin = $(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight(); - $(this).closest('.ui-dialog').css('margin-top', topMargin); - }, - close: function () { - $(this).closest('.ui-dialog').removeClass('ui-dialog-active'); - }, - buttons: [{ - text: $.mage.__('Delete'), - 'class': 'action-primary', - click: function () { - $(this).dialog("close"); - window.location.href = $(e.target).data('url'); + new Confirm({ + title: 'Are you sure?', + content: "Are you sure you want to delete this integration? You can't undo this action.", + actions: { + confirm: function () { + window.location.href = $(e.target).data('url'); + } } - }, { - text: $.mage.__('Cancel'), - 'class': 'action-close', - click: function () { - $(this).dialog('close'); - } - }] + }); + e.stopPropagation(); }); - e.stopPropagation(); }); }); - -}); </script> <div id="integration-popup-container" style="display: none;"></div> diff --git a/app/code/Magento/Integration/view/adminhtml/web/js/integration.js b/app/code/Magento/Integration/view/adminhtml/web/js/integration.js index 3e299ddf77e45aacd9d480d355dea456157689d7..93504661db61493e45eea27b28b27c024fab5417 100644 --- a/app/code/Magento/Integration/view/adminhtml/web/js/integration.js +++ b/app/code/Magento/Integration/view/adminhtml/web/js/integration.js @@ -7,9 +7,11 @@ /*global integration*/ define([ "jquery", + "Magento_Ui/js/modal/alert", "jquery/ui", - "mage/translate" -], function($){ + "mage/translate", + "Magento_Ui/js/modal/modal" +], function($, alert){ "use strict"; $.widget('mage.integration', { @@ -80,7 +82,9 @@ define([ } }, error: function (jqXHR, status, error) { - alert($.mage.__('Sorry, something went wrong. Please try again later.')); + alert({ + content: $.mage.__('Sorry, something went wrong. Please try again later.') + }); window.console && console.log(status + ': ' + error + "\nResponse text:\n" + jqXHR.responseText); }, complete: function () { @@ -168,12 +172,12 @@ define([ $('body').trigger('processStart'); //Check for window closed window.location.reload(); - IdentityLogin.jqInfoDialog.dialog('close'); + IdentityLogin.jqInfoDialog.modal('closeModal'); } } catch (e) { //squash. In case Window closed without success callback, clear polling if (IdentityLogin.win.closed) { - IdentityLogin.jqInfoDialog.dialog('close'); + IdentityLogin.jqInfoDialog.modal('closeModal'); clearInterval(IdentityLogin.checker); } return; @@ -217,53 +221,24 @@ define([ } catch (e) { //This is expected if result is not json. Do nothing. } + if (identityLinkUrl && consumerId && popupHtml) { IdentityLogin.invokePopup(identityLinkUrl, consumerId, popup); } else { popupHtml = result; } + if (popup.length === 0){ + popup = $('<div/>'); + } popup.html(popupHtml); var buttons = [], dialogProperties = { title: title, - modal: true, - autoOpen: true, - minHeight: 450, - minWidth: 600, - width: '75%', + type: 'slide', dialogClass: dialog == 'permissions' ? 'integration-dialog' : 'integration-dialog no-close', - closeOnEscape: false, - position: { - my: 'left top', - at: 'center top', - of: 'body' - }, - open: function () { - $(this).closest('.ui-dialog').addClass('ui-dialog-active'); - - var topMargin = $(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 30; - $(this).closest('.ui-dialog').css('margin-top', topMargin); - }, - close: function () { - $(this).closest('.ui-dialog').removeClass('ui-dialog-active'); - } }; - if (dialog == 'permissions') { - // We don't need this button in 'tokens' dialog, since if you got there - integration is - // already activated and have necessary tokens - buttons.push({ - text: $.mage.__('Cancel'), - 'class': 'action-close', - click: function () { - $(this).dialog('close'); - } - }); - } else if (dialog == 'tokensExchange') { - dialogProperties['minHeight'] = 150; - dialogProperties['minWidth'] = 500; - } // Add confirmation button to the list of dialog buttons. okButton not set for tokenExchange dialog if (okButton) { @@ -273,10 +248,13 @@ define([ if (buttons.length > 0) { dialogProperties['buttons'] = buttons } - popup.dialog(dialogProperties); + popup.modal(dialogProperties); + popup.modal('openModal'); }, error: function (jqXHR, status, error) { - alert($.mage.__('Sorry, something went wrong. Please try again later.')); + alert({ + content: $.mage.__('Sorry, something went wrong. Please try again later.') + }); window.console && console.log(status + ': ' + error + "\nResponse text:\n" + jqXHR.responseText); }, complete: function () { @@ -322,17 +300,20 @@ define([ permissions: { text: (isReauthorize == '1') ? $.mage.__('Reauthorize') : $.mage.__('Allow'), 'class': 'action-primary', - // This data is going to be used in the next dialog - 'data-row-id': integrationId, - 'data-row-name': integrationName, - 'data-row-dialog': (isTokenExchange == '1') ? 'tokensExchange' : 'tokens', - 'data-row-is-reauthorize': isReauthorize, - 'data-row-is-token-exchange': isTokenExchange, + attr: { + 'data-row-id': integrationId, + 'data-row-name': integrationName, + 'data-row-dialog': (isTokenExchange == '1') ? 'tokensExchange' : 'tokens', + 'data-row-is-reauthorize': isReauthorize, + 'data-row-is-token-exchange': isTokenExchange + }, click: function () { // Find the 'Allow' button and clone - it has all necessary data, but is going to be // destroyed along with the current dialog - var ctx = $(this).parent().find('button.action-primary').clone(true); - $(this).dialog('destroy'); + var ctx = this.modal.find('button.action-primary').clone(true); + + this.closeModal(); + this.modal.remove(); // Make popup out of data we saved from 'Allow' button window.integration.popup.show(ctx); } diff --git a/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attributes_listing.xml b/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attributes_listing.xml index 6b7142d703cdfc489fc8229873359a8cdf4b65f7..39cd52f20586c760145b8ef62211037800154c8a 100644 --- a/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attributes_listing.xml +++ b/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attributes_listing.xml @@ -6,32 +6,15 @@ */ --> <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Ui/etc/ui_configuration.xsd"> - <container name="listing_top"> - <filters name="listing_filters"> - <filterSelect name="is_filterable"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\LayeredNavigation\Model\Attribute\Source\FilterableOptions</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">is_filterable</item> - <item name="label" xsi:type="string" translate="true">Use in Layered Navigation</item> - <item name="caption" xsi:type="string" translate="true">Select...</item> - </item> - </argument> - </filterSelect> - </filters> - </container> + <container name="listing_top"></container> <columns name="product_attributes_columns"> <column name="is_filterable"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Magento\LayeredNavigation\Model\Attribute\Source\FilterableOptions</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="dataType" xsi:type="string">select</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Use in Layered Navigation</item> </item> </argument> diff --git a/app/code/Magento/MediaStorage/view/adminhtml/templates/system/config/system/storage/media/synchronize.phtml b/app/code/Magento/MediaStorage/view/adminhtml/templates/system/config/system/storage/media/synchronize.phtml index 0c9080bc8db1bcbc0e6ff30b7f624d850a8bbf3a..316c5fa5b3d28b73476f0d7e2e8cdbe1a75b41e1 100644 --- a/app/code/Magento/MediaStorage/view/adminhtml/templates/system/config/system/storage/media/synchronize.phtml +++ b/app/code/Magento/MediaStorage/view/adminhtml/templates/system/config/system/storage/media/synchronize.phtml @@ -102,7 +102,7 @@ require([ var response; try { - response = eval('(' + transport.responseText + ')'); + response = JSON.parse(transport.responseText); if (response.state == '<?php /* @escapeNotVerified */ echo \Magento\MediaStorage\Model\File\Storage\Flag::STATE_RUNNING ?>' && response.message ) { diff --git a/app/code/Magento/Msrp/view/base/web/js/msrp.js b/app/code/Magento/Msrp/view/base/web/js/msrp.js index 8bad507ec0714436cf00d2e37f46f3d11758f192..18ea804d23818b1b8a1a4813a7c6675e0d957629 100644 --- a/app/code/Magento/Msrp/view/base/web/js/msrp.js +++ b/app/code/Magento/Msrp/view/base/web/js/msrp.js @@ -6,11 +6,11 @@ define([ 'jquery', 'underscore', 'jquery/ui', - 'mage/dropdown' + 'mage/dropdown', + 'mage/template' ], function ($, _) { 'use strict'; - var openDropDown = null; $.widget('mage.addToCart', { options: { showAddToCart: true, @@ -21,6 +21,9 @@ define([ // Selectors cartForm: '.form.map.checkout', + msrpLabelId: '#map-popup-msrp', + priceLabelId: '#map-popup-price', + popUpAttr: '[data-role=msrp-popup-template]', cartButtonId: '', // better to be cartButton popupId: '', // better to be popup realPrice: '', @@ -31,143 +34,109 @@ define([ // Text options productName: '', addToCartUrl: '' + }, openDropDown: null, + triggerClass: 'dropdown-active', + + popUpOptions: { + appendTo: 'body', + dialogContentClass: 'active', + closeOnMouseLeave: false, + autoPosition: true, + closeOnClickOutside: false, + 'dialogClass': 'popup map-popup-wrapper', + position: { + my: 'left top', + collision: 'fit none', + at: 'left bottom', + within: 'body' + }, + shadowHinter: 'popup popup-pointer' + }, + popupOpened: false, /** * Creates widget instance * @private */ _create: function () { - $(this.options.cartButtonId).on('click', this._addToCartSubmit.bind(this)); - - $(this.options.popupId).on('click', function (event) { - var dialog; - event.preventDefault(); - - if (this.options.submitUrl) { - location.href = this.options.submitUrl; - } else { - $(this.options.popupCartButtonId) - .off('click') - .on('click', this._addToCartSubmit.bind(this)); - $('#map-popup-heading-price').text(this.options.productName); - $('#map-popup-price').html($(this.options.realPrice).html().trim()); - $('#map-popup-msrp > span.price').html(this.options.msrpPrice); - - this.element.trigger('reloadPrice'); - - dialog = $('#map-popup-click-for-price'); - this._popupDialog(dialog, this.options.popupId); - - if (this.options.addToCartUrl) { - $(this.options.cartForm).attr('action', this.options.addToCartUrl); - } - - if (!this.options.showAddToCart) { - $('#product_addtocart_form_from_popup').hide(); - } - - return false; - } - }.bind(this)); + var tierOptions; + + this.popupDOM = $(this.options.popUpAttr)[0]; + this.infoPopupDOM = $('[data-role=msrp-info-template]')[0]; + + if (this.options.popupId) { + $('body').append($(this.popupDOM).html()); + this.$popup = $($(this.popupDOM).html()); + + $(this.options.popupId).on('click', function (e) { + this.popUpOptions.position.of = $(e.target); + this.$popup.find(this.options.msrpLabelId).html(this.options.msrpPrice); + this.$popup.find(this.options.priceLabelId).html(this.options.realPrice); + this.$popup.dropdownDialog(this.popUpOptions).dropdownDialog('open'); + + this.$popup.find('button').on('click', function () { + if (this.options.addToCartButton) { + $(this.options.addToCartButton).click(); + } + }.bind(this)); + this._toggle(this.$popup); + }.bind(this)); + } - $(this.options.helpLinkId).on('click', function () { - $('#map-popup-heading-what-this').text(this.options.productName); - this._popupDialog($('#map-popup-what-this'), this.options.helpLinkId); + if (this.options.helpLinkId) { + this.$infoPopup = $(this.infoPopupDOM.innerText).appendTo('body'); + $(this.options.helpLinkId).on('click', function (e) { + this.popUpOptions.position.of = $(e.target); + this.$infoPopup.dropdownDialog(this.popUpOptions).dropdownDialog('open'); + this._toggle(this.$infoPopup); + }.bind(this)); + } - return false; - }.bind(this)); + if (this.options.attr) { + this.popupDOM = $(this.options.popUpAttr)[0]; + this.$popup = $(this.popupDOM.innerText).appendTo('body'); + this.popUpOptions.position.of = $(this.options.helpLinkId); + $(this.options.attr).on('click', function (e) { + this.popUpOptions.position.of = $(e.target); + tierOptions = JSON.parse($(e.target).attr('data-tier-price')); + this.$popup.find(this.options.msrpLabelId).html(tierOptions.msrp); + this.$popup.find(this.options.priceLabelId).html(tierOptions.price); + this.$popup.find('button').on('click', function (e) { + e.preventDefault(); + this.$popup.find('form').attr('action', tierOptions.addToCartUrl).submit(); + }.bind(this)); + this.$popup.dropdownDialog(this.popUpOptions).dropdownDialog('open'); + this._toggle(this.$popup); + }.bind(this)); + } }, /** - * Handler for dialog popup - * @param {jQuery} elementTarget - * @param {jQuery} elementTrigger + * + * @param $elem * @private */ - _popupDialog: function (elementTarget, elementTrigger) { - var target = $(elementTarget), - trigger = $(elementTrigger), - counter = 0, - triggerClass = 'dropdown-active', - options; - - options = { - appendTo: 'body', - dialogContentClass: 'active', - closeOnMouseLeave: false, - autoPosition: true, - 'dialogClass': 'popup map-popup-wrapper', - position: { - my: 'left top', - collision: 'fit none', - at: 'left bottom', - within: 'body', - of: trigger - }, - shadowHinter: 'popup popup-pointer' - }; - options = _.extend(options, this.options.dialog); - - if (openDropDown && openDropDown.is(':data(mage-dropdownDialog)')) { - openDropDown.dropdownDialog('close'); - } - - if (this.options.singleOpenDropDown) { - this.openDropDown = openDropDown; - } - openDropDown = target - .dropdownDialog(options) - .off('dropdowndialogclose') - .on('dropdowndialogclose', function () { - if (!counter) { - openDropDown = null; - $(window).off('resize'); - } - trigger.removeClass(triggerClass); - }) - .on('dropdowndialogopen', function () { - trigger.addClass(triggerClass); - }) - .dropdownDialog('open'); - - $(window) - .resize(_.debounce(function () { - if (openDropDown) { - counter--; - openDropDown.dropdownDialog('open'); - } - }, this.options.dialogDelay)) - .resize(_.debounce(function () { - if (openDropDown) { - counter++; - openDropDown.dropdownDialog('close'); - } - }, this.options.dialogDelay, true)); + _toggle: function ($elem) { + $(document).on('mouseup', function (e) { + if (!$elem.is(e.target) && $elem.has(e.target).length === 0) { + this.closePopup($elem); + } + }.bind(this)); + $(window).on('resize', function () { + this.closePopup($elem); + }.bind(this)) }, /** - * Handler for addToCart action - * @private + * + * @param $elem */ - _addToCartSubmit: function () { - this.element.trigger('addToCart', this.element); - if (this.element.data('stop-processing')) { - return false; - } - - if (this.options.addToCartButton) { - $(this.options.addToCartButton).click(); - - return; - } - - if (this.options.addToCartUrl) { - $('.mage-dropdown-dialog > .ui-dialog-content').dropdownDialog('close'); - } - $(this.options.cartForm).submit(); + closePopup: function ($elem) { + $elem.dropdownDialog('close'); + $(document).off('mouseup'); } }); diff --git a/app/code/Magento/Msrp/view/frontend/templates/popup.phtml b/app/code/Magento/Msrp/view/frontend/templates/popup.phtml index 07230989e180869fe60a765a41d784c7f533f198..521f17e4971b68827f75e2b89e2877d1601ab517 100644 --- a/app/code/Magento/Msrp/view/frontend/templates/popup.phtml +++ b/app/code/Magento/Msrp/view/frontend/templates/popup.phtml @@ -11,6 +11,7 @@ /** @var \Magento\Msrp\Block\Popup $block */ ?> <?php if ($block->isEnabled()): ?> + <script data-role="msrp-popup-template" type="text/x-magento-template"> <div id="map-popup-click-for-price" class="map-popup"> <div class="popup-header"> <strong class="title" id="map-popup-heading-price"></strong> @@ -47,7 +48,8 @@ </div> </div> </div> - + </script> + <script data-role="msrp-info-template" type="text/x-magento-template"> <div id="map-popup-what-this" class="map-popup"> <div class="popup-header"> <strong class="title" id="map-popup-heading-what-this"></strong> @@ -58,4 +60,5 @@ </div> </div> </div> + </script> <?php endif; ?> diff --git a/app/code/Magento/Newsletter/view/adminhtml/templates/template/edit.phtml b/app/code/Magento/Newsletter/view/adminhtml/templates/template/edit.phtml index 84c07890a4efe022fa170b0750383362d350e9bf..26ac1a28b3c06a1ad78afc5b7ce5d6eb149c1739 100644 --- a/app/code/Magento/Newsletter/view/adminhtml/templates/template/edit.phtml +++ b/app/code/Magento/Newsletter/view/adminhtml/templates/template/edit.phtml @@ -31,9 +31,11 @@ use Magento\Framework\App\TemplateTypesInterface; require([ 'jquery', 'tinymce', + 'Magento_Ui/js/modal/prompt', + 'Magento_Ui/js/modal/confirm', 'mage/mage', 'prototype' -], function(jQuery, tinyMCE){ +], function(jQuery, tinyMCE, prompt, confirm){ //<![CDATA[ jQuery('#newsletter_template_edit_form').mage('form').mage('validation'); @@ -81,20 +83,26 @@ require([ }, stripTags: function () { - if(!window.confirm("<?php /* @escapeNotVerified */ echo __('Are you sure that you want to strip all tags?') ?>")) { - return false; - } - if(this.isEditor()) { - this.getEditor().turnOff(); - this.getEditor().getToggleButton().hide(); - } - this.unconvertedText = $(this.id).value; - $('convert_button').hide(); - $('convert_button_back').show(); - $(this.id).value = $(this.id).value.stripScripts().stripTags(); - $('field_template_styles').hide(); - this.typeChange = true; - return false; + var self = this; + + confirm({ + content: "<?php /* @escapeNotVerified */ echo __('Are you sure that you want to strip all tags?') ?>", + actions: { + confirm: function(){ + if(self.isEditor()) { + self.getEditor().turnOff(); + self.getEditor().getToggleButton().hide(); + } + self.unconvertedText = $(self.id).value; + $('convert_button').hide(); + $('convert_button_back').show(); + $(self.id).value = $(self.id).value.stripScripts().stripTags(); + $('field_template_styles').hide(); + self.typeChange = true; + } + } + }); + }, unStripTags: function () { @@ -123,24 +131,38 @@ require([ }, saveAs: function() { + var self = this; + if (this.typeChange) { $('change_flag_element').value = '1'; } if($F('code').blank() || $F('code')==templateControl.templateName) { - value = prompt('<?php /* @escapeNotVerified */ echo __('Please enter a new template name.') ?>', templateControl.templateName + '<?php /* @escapeNotVerified */ echo __(' Copy') ?>'); - if(!value) { - if(value !== null) { - $('code').value = ''; - // Temporary solution will be replaced after refactoring of newsletter functionality - jQuery('#newsletter_template_edit_form').triggerHandler('save'); - } - return false; - } else { - $('code').value = value; - } + + prompt({ + content: '<?php /* @escapeNotVerified */ echo __('Please enter a new template name.') ?>', + value: templateControl.templateName + '<?php /* @escapeNotVerified */ echo __(' Copy') ?>', + actions: { + confirm: function(value) { + $('code').value = value; + self._saveAs(); + + return false; + }, + cancel: function(){ + $('code').value = ''; + // Temporary solution will be replaced after refactoring of newsletter functionality + jQuery('#newsletter_template_edit_form').triggerHandler('save'); + self._saveAs(); + + return false; + } + } + }); } + }, + _saveAs: function() { $('save_as_flag').value = '1'; if(this.isEditor()) { @@ -176,9 +198,14 @@ require([ }, deleteTemplate: function() { - if(window.confirm("<?php /* @escapeNotVerified */ echo __('Are you sure you want to delete this template?') ?>")) { - window.location.href = '<?php /* @escapeNotVerified */ echo $block->getDeleteUrl() ?>'; - } + confirm({ + content: "<?php /* @escapeNotVerified */ echo __('Are you sure you want to delete this template?') ?>", + actions: { + confirm: function() { + window.location.href = '<?php /* @escapeNotVerified */ echo $block->getDeleteUrl() ?>'; + } + } + }); }, isEditor: function() { diff --git a/app/code/Magento/Payment/view/adminhtml/templates/info/default.phtml b/app/code/Magento/Payment/view/adminhtml/templates/info/default.phtml index 9980563201013c5afd144b026df184fcfaac7738..2ce70dcad46a2f0b06e69eecf856cc6fe6bb9c05 100644 --- a/app/code/Magento/Payment/view/adminhtml/templates/info/default.phtml +++ b/app/code/Magento/Payment/view/adminhtml/templates/info/default.phtml @@ -9,10 +9,11 @@ * @var \Magento\Payment\Block\Info $block * @see \Magento\Payment\Block\Info */ +$specificInfo = $block->getSpecificInformation(); ?> <?php echo $block->escapeHtml($block->getMethod()->getTitle()); ?> -<?php if ($_specificInfo = $block->getSpecificInformation()):?> +<?php if ($specificInfo): ?> <table class="data-table admin__table-secondary"> <?php foreach ($specificInfo as $label => $value):?> <tr> diff --git a/app/code/Magento/Payment/view/adminhtml/templates/transparent/form.phtml b/app/code/Magento/Payment/view/adminhtml/templates/transparent/form.phtml index 92c44c6c5d4b9ccadda17fe6fbbec87b46ad3451..1bb248e6fd5662bced43e2f7ee9d4c5a942a1f69 100644 --- a/app/code/Magento/Payment/view/adminhtml/templates/transparent/form.phtml +++ b/app/code/Magento/Payment/view/adminhtml/templates/transparent/form.phtml @@ -10,6 +10,7 @@ $code = $block->getMethodCode(); $ccType = $block->getInfoData('cc_type'); $ccExpYear = $block->getInfoData('cc_exp_year'); +$ccExpMonth = $block->getInfoData('cc_exp_month'); ?> <!-- IFRAME for request to Payment Gateway --> @@ -87,11 +88,10 @@ $ccExpYear = $block->getInfoData('cc_exp_year'); data-container="<?php /* @noEscape */ echo $code; ?>-cc-month" class="admin__control-select admin__control-select-month" data-validate='{required:true, "validate-cc-exp":"#<?php /* @noEscape */ echo $code; ?>_expiration_yr"}'> - <?php $_ccExpMonth = $block->getInfoData('cc_exp_month') ?> <?php foreach ($block->getCcMonths() as $k => $v): ?> <option - value="<?php /* @noEscape */ echo $k ? $block->escapeHtml($k) : '' ?>" - <?php if ($k == $_ccExpMonth): ?> selected="selected"<?php endif ?>> + value="<?php /* @noEscape */ echo $k ? $block->escapeHtml($k) : ''; ?>" + <?php if ($k == $ccExpMonth): ?> selected="selected"<?php endif; ?>> <?php echo $block->escapeHtml($v); ?> </option> <?php endforeach ?> diff --git a/app/code/Magento/Payment/view/adminhtml/web/transparent.js b/app/code/Magento/Payment/view/adminhtml/web/transparent.js index 7edbb30c6318ffd45339c6b55b3b612067f76b62..11593e2a5b5f634a42a8b1779afdcfd5a71f2686 100644 --- a/app/code/Magento/Payment/view/adminhtml/web/transparent.js +++ b/app/code/Magento/Payment/view/adminhtml/web/transparent.js @@ -6,8 +6,9 @@ define([ "jquery", "mage/template", + 'Magento_Ui/js/modal/alert', "jquery/ui" -], function($, mageTemplate){ +], function($, mageTemplate, alert){ "use strict"; $.widget('mage.transparent', { @@ -157,10 +158,14 @@ define([ _processErrors: function (response) { var msg = response.error_messages; if (typeof (msg) === 'object') { - alert(msg.join("\n")); + alert({ + content: msg.join("\n") + }); } if (msg) { - alert(msg); + alert({ + content: msg + }); } } }); diff --git a/app/code/Magento/Payment/view/frontend/templates/transparent/form.phtml b/app/code/Magento/Payment/view/frontend/templates/transparent/form.phtml index eeaa13ee814cc4d420fdbbc0ec7e66eb84c58aa7..64ea503996cd280d8b29dc154b4dc20e9e47f69d 100644 --- a/app/code/Magento/Payment/view/frontend/templates/transparent/form.phtml +++ b/app/code/Magento/Payment/view/frontend/templates/transparent/form.phtml @@ -10,6 +10,7 @@ $code = $block->getMethodCode(); $ccExpMonth = $block->getInfoData('cc_exp_month'); $ccExpYear = $block->getInfoData('cc_exp_year'); +$ccType = $block->getInfoData('cc_type'); $content = '<img src=\"' . $block->getViewFileUrl('Magento_Checkout::cvv.png') . '\" alt=\"' . $block->escapeHtml(__('Card Verification Number Visual Reference')) . '\" title=\"' . $block->escapeHtml(__('Card Verification Number Visual Reference')) . '\" />'; @@ -46,10 +47,9 @@ $content = '<img src=\"' . $block->getViewFileUrl('Magento_Checkout::cvv.png') . "validate-cc-type-select":"#<?php /* @noEscape */ echo $code; ?>_cc_number" }'> <option value=""><?php echo $block->escapeHtml(__('--Please Select--'));?></option> - <?php $_ccType = $block->getInfoData('cc_type') ?> <?php foreach ($block->getCcAvailableTypes() as $typeCode => $typeName): ?> <option value="<?php echo $block->escapeHtml($typeCode); ?>" - <?php if ($typeCode == $_ccType): ?> selected="selected"<?php endif; ?>> + <?php if ($typeCode == $ccType): ?> selected="selected"<?php endif; ?>> <?php echo $block->escapeHtml($typeName); ?></option> <?php endforeach ?> </select> diff --git a/app/code/Magento/Payment/view/frontend/web/transparent.js b/app/code/Magento/Payment/view/frontend/web/transparent.js index 2060ca7c8ea5e5a344329c0e48ad935859f77f8a..66b3203d7bc5181aae26afe4c7153ef5b2266497 100644 --- a/app/code/Magento/Payment/view/frontend/web/transparent.js +++ b/app/code/Magento/Payment/view/frontend/web/transparent.js @@ -6,9 +6,10 @@ define([ "jquery", "mage/template", + 'Magento_Ui/js/modal/alert', "jquery/ui", "Magento_Payment/js/model/credit-card-validation/validator" -], function($, mageTemplate){ +], function($, mageTemplate, alert){ 'use strict'; $.widget('mage.transparent', { @@ -101,10 +102,14 @@ define([ } else { msg = response.error_messages; if (typeof (msg) === 'object') { - alert(msg.join("\n")); + alert({ + content: msg.join("\n") + }); } if (msg) { - alert(msg); + alert({ + content: msg + }); } } } diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index d9b9d986f1b31c0db42b578c6074e0f53dbc5453..d3b0cf72fc76bf9047b4a82e4cdc663380834123 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -1191,10 +1191,10 @@ class Checkout /** * Set shipping options to api * @param \Magento\Paypal\Model\Cart $cart - * @param \Magento\Quote\Model\Quote\Address $address + * @param \Magento\Quote\Model\Quote\Address|null $address * @return void */ - private function setShippingOptions(PaypalCart $cart, Address $address) + private function setShippingOptions(PaypalCart $cart, Address $address = null) { // for included tax always disable line items (related to paypal amount rounding problem) $this->_api->setIsLineItemsEnabled($this->_config->getValue(PaypalConfig::TRANSFER_CART_LINE_ITEMS)); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rule.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rule.js index 0c49932d489a22e0d5e64274221ebc29ea949bd4..b565aa2d66d6b46c2165650567b06fe440291b4e 100644 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rule.js +++ b/app/code/Magento/Paypal/view/adminhtml/web/js/rule.js @@ -3,7 +3,7 @@ * See COPYING.txt for license details. */ define([ - "Magento_Ui/js/lib/class", + "uiClass", "underscore" ], function (Class, _) { "use strict"; diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/conflict.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/conflict.js index 98c79243d483266581e0d52bc1d1041fc9b4ce7a..4d94f6a2a9ff63cdb9195b4bbdaf012f98ec4cf7 100644 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/conflict.js +++ b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/conflict.js @@ -4,7 +4,9 @@ */ (function() { var executed = false; - define([], function () { + define([ + 'Magento_Ui/js/modal/alert' + ], function (alert) { "use strict"; return function ($target, $owner, data) { if ($owner.find(data.enableButton).val() == 1) { @@ -22,11 +24,11 @@ if (!isDisabled && !executed) { executed = true; - alert( - "The following error(s) occured:\n\r" - + "Some PayPal solutions conflict.\n\r" - + "Please re-enable the previously enabled payment solutions." - ); + alert({ + content: "The following error(s) occured:\n\r" + +"Some PayPal solutions conflict.\n\r" + +"Please re-enable the previously enabled payment solutions." + }); } } }; diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/solution.js b/app/code/Magento/Paypal/view/adminhtml/web/js/solution.js index 3ff36adf61426bbbd23d77fbe559d22c581d82d9..787d9e066cdbe0234bb434f57d39919d00639181 100644 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/solution.js +++ b/app/code/Magento/Paypal/view/adminhtml/web/js/solution.js @@ -4,7 +4,7 @@ */ define([ "jquery", - "Magento_Ui/js/lib/class", + "uiClass", "Magento_Paypal/js/rule", "mageUtils", "underscore" diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/solutions.js b/app/code/Magento/Paypal/view/adminhtml/web/js/solutions.js index fc688c2da2a2c84d20663d3a82a784253f1a2d34..b1e124aca387a556069a776721a90d0c529db62a 100644 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/solutions.js +++ b/app/code/Magento/Paypal/view/adminhtml/web/js/solutions.js @@ -4,7 +4,7 @@ */ define([ "jquery", - "Magento_Ui/js/lib/class", + "uiClass", "Magento_Paypal/js/solution", "underscore" ], function ($, Class, Solution, _) { diff --git a/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js b/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js index bd0111de817d5c680de491e0a50b5aafbb5f472b..bc474987c897f42f28e40d6a651d68ce6009869d 100644 --- a/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js +++ b/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js @@ -5,9 +5,10 @@ /*jshint browser:true jquery:true*/ define([ 'jquery', + 'Magento_Ui/js/modal/confirm', 'jquery/ui', 'mage/mage' -], function ($) { +], function ($, confirm) { 'use strict'; $.widget('mage.paypalCheckout', { @@ -18,26 +19,43 @@ define([ _create: function () { this.element.on('click', '[data-action="checkout-form-submit"]', $.proxy(function (e) { var returnUrl = $(e.target).data('checkout-url'), - form; + self = this; e.preventDefault(); if (this.options.confirmUrl && this.options.confirmMessage) { - if (window.confirm(this.options.confirmMessage)) { - returnUrl = this.options.confirmUrl; - } + confirm({ + content: this.options.confirmMessage, + actions: { + confirm: function() { + returnUrl = self.options.confirmUrl; + self._redirect(returnUrl); + }, + cancel: function() { + self.redirect(returnUrl); + } + } + }); + + return false; } - if (this.options.isCatalogProduct) { - // find the form from which the button was clicked - form = $(this.options.shortcutContainerClass).closest('form'); + this._redirect(returnUrl); - $(form).find(this.options.paypalCheckoutSelector).val(returnUrl); - $(form).submit(); - } else { - $.mage.redirect(returnUrl); - } }, this)); + }, + _redirect: function(returnUrl) { + var form; + + if (this.options.isCatalogProduct) { + // find the form from which the button was clicked + form = $(this.options.shortcutContainerClass).closest('form'); + + $(form).find(this.options.paypalCheckoutSelector).val(returnUrl); + $(form).submit(); + } else { + $.mage.redirect(returnUrl); + } } }); diff --git a/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflowpro-method.js b/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflowpro-method.js index a7a031848124e90d904a433912a4cdc722a27ed6..f0095877bbc9cb3a3831de67668c3234a287ec75 100644 --- a/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflowpro-method.js +++ b/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflowpro-method.js @@ -51,9 +51,8 @@ define( placeOrder: function () { var self = this; - fullScreenLoader.startLoader(); - if (this.validateHandler() && additionalValidators.validate()) { + fullScreenLoader.startLoader(); this.isPlaceOrderActionAllowed(false); $.when(setPaymentInformationAction(this.messageContainer, { 'method': self.getCode() diff --git a/app/code/Magento/Paypal/view/frontend/web/order-review.js b/app/code/Magento/Paypal/view/frontend/web/order-review.js index 56514f9164c8f8acb9db20d12f4f97ca7fda6efc..b1a072d8e98e87815de24ac306f4673e8fec7c38 100644 --- a/app/code/Magento/Paypal/view/frontend/web/order-review.js +++ b/app/code/Magento/Paypal/view/frontend/web/order-review.js @@ -6,11 +6,12 @@ /*global alert*/ define([ "jquery", + 'Magento_Ui/js/modal/alert', "jquery/ui", "mage/translate", "mage/mage", "mage/validation" -], function($){ +], function($, alert){ "use strict"; $.widget('mage.orderReview', { @@ -129,7 +130,9 @@ define([ msg = msg.join("\n"); } } - alert($.mage.__(msg)); + alert({ + content: $.mage.__(msg) + }); return false; } if (response.redirect) { @@ -141,11 +144,15 @@ define([ return false; } this._ajaxComplete(); - alert($.mage.__('Sorry, something went wrong.')); + alert({ + content: $.mage.__('Sorry, something went wrong.') + }); } }, error: function () { - alert($.mage.__('Sorry, something went wrong. Please try again later.')); + alert({ + content: $.mage.__('Sorry, something went wrong. Please try again later.') + }); this._ajaxComplete(); } }); diff --git a/app/code/Magento/Rule/view/adminhtml/web/rules.js b/app/code/Magento/Rule/view/adminhtml/web/rules.js index 262d155a53cd14cec982876aa37396a31a403b37..50b3fdd85ea39f8cd1ec0ab4ff6cc3442f0a373e 100644 --- a/app/code/Magento/Rule/view/adminhtml/web/rules.js +++ b/app/code/Magento/Rule/view/adminhtml/web/rules.js @@ -4,6 +4,7 @@ */ define([ "jquery", + 'Magento_Ui/js/modal/alert', "mage/translate", "prototype" ], function(jQuery){ diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php index 848c9ebc498fcaef7fbe2e04d2c8399af6c69dd5..379117ef1d2dfade9c6f787777ed97c4578a9114 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php @@ -27,10 +27,19 @@ class AddressTest extends \PHPUnit_Framework_TestCase public function setUp() { $objectManager = new ObjectManager($this); + $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $this->escaper = $this->getMock('Magento\Framework\Escaper', ['escapeHtml'], [], '', false); $this->model = $objectManager->getObject( 'Magento\Sales\Ui\Component\Listing\Column\Address', - ['escaper' => $this->escaper] + [ + 'context' => $contextMock, + 'escaper' => $this->escaper, + ] ); } diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/CustomerGroupTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/CustomerGroupTest.php index 262f0fdcb94ff88633c148b2ab38c3b8f2e3c6f4..d0e9e34bf7ac8fe3a9e51cee368cc61a5f6bc05a 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/CustomerGroupTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/CustomerGroupTest.php @@ -27,10 +27,16 @@ class CustomerGroupTest extends \PHPUnit_Framework_TestCase public function setUp() { $objectManager = new ObjectManager($this); + $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $this->groupRepository = $this->getMockForAbstractClass('Magento\Customer\Api\GroupRepositoryInterface'); $this->model = $objectManager->getObject( 'Magento\Sales\Ui\Component\Listing\Column\CustomerGroup', - ['groupRepository' => $this->groupRepository] + ['groupRepository' => $this->groupRepository, 'context' => $contextMock] ); } diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PaymentMethodTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PaymentMethodTest.php index 10e64a079d6112899079a7a6c696ae6bc34eafaf..d8424896f059bcc9618d2160d9a7dc0ac612567c 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PaymentMethodTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PaymentMethodTest.php @@ -27,10 +27,16 @@ class PaymentMethodTest extends \PHPUnit_Framework_TestCase public function setUp() { $objectManager = new ObjectManager($this); + $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $this->paymentHelper = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); $this->model = $objectManager->getObject( 'Magento\Sales\Ui\Component\Listing\Column\PaymentMethod', - ['paymentHelper' => $this->paymentHelper] + ['paymentHelper' => $this->paymentHelper, 'context' => $contextMock] ); } diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php index edc68cf7ab480af81789b3b0d8aa22b6b83857c5..a3cf58f61c04bb5e4be793ae9e36fac7f06aa222 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php @@ -27,10 +27,16 @@ class PriceTest extends \PHPUnit_Framework_TestCase public function setUp() { $objectManager = new ObjectManager($this); + $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $this->priceFormatterMock = $this->getMockForAbstractClass('Magento\Framework\Pricing\PriceCurrencyInterface'); $this->model = $objectManager->getObject( 'Magento\Sales\Ui\Component\Listing\Column\Price', - ['priceFormatter' => $this->priceFormatterMock] + ['priceFormatter' => $this->priceFormatterMock, 'context' => $contextMock] ); } diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/StatusTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/StatusTest.php index a550acf25be4188d26c1338f66c2bcb3922936bd..8ac8bc95748c5c623c8a5a1bb520450d22080c17 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/StatusTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/StatusTest.php @@ -43,9 +43,15 @@ class StatusTest extends \PHPUnit_Framework_TestCase ->willReturn($collection); $objectManager = new ObjectManager($this); + $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $model = $objectManager->getObject( 'Magento\Sales\Ui\Component\Listing\Column\Status', - ['collectionFactory' => $collectionFactoryMock] + ['collectionFactory' => $collectionFactoryMock, 'context' => $contextMock] ); $model->setData('name', $itemName); $dataSource = $model->prepareDataSource($dataSource); diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php index 660ee18828293e22a2e0e07384e361a32eb7e74c..11ad73a8b0f3a352b5b7316c07889e15c83bf30f 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php @@ -50,11 +50,18 @@ class ViewActionTest extends \PHPUnit_Framework_TestCase $expectedUrlPath, $expectedUrlParam ) { + $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $this->model = $this->objectManager->getObject( 'Magento\Sales\Ui\Component\Listing\Column\ViewAction', [ 'urlBuilder' => $this->urlBuilder, - 'data' => $data + 'data' => $data, + 'context' => $contextMock, ] ); diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml index 71a86a9e296b65fc40c89178e912974527a7c7ab..a7f92654a75d0223583291749c5d0dbb5d8a83d7 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml @@ -40,17 +40,13 @@ <bookmark name="bookmarks"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> - <item name="displayArea" xsi:type="string">dataGridActions</item> <item name="storageConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> - <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> <item name="namespace" xsi:type="string">sales_order_creditmemo_grid</item> </item> </item> </argument> </bookmark> - <container name="columns_controls"> + <component name="columns_controls"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="columnsData" xsi:type="array"> @@ -60,7 +56,7 @@ <item name="displayArea" xsi:type="string">dataGridActions</item> </item> </argument> - </container> + </component> <exportButton name="export_button"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> @@ -83,8 +79,7 @@ <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="displayArea" xsi:type="string">dataGridFilters</item> - <item name="dataScope" xsi:type="string">filters</item> + <item name="columnsProvider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.sales_order_creditmemo_columns</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.filters</item> @@ -92,150 +87,11 @@ <item name="childDefaults" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> <item name="imports" xsi:type="array"> - <item name="visible" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.bookmarks:current.columns.${ $.index }.visible</item> + <item name="visible" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.sales_order_creditmemo_columns:${ $.index }.visible</item> </item> </item> </item> </argument> - <filterInput name="increment_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">increment_id</item> - <item name="label" xsi:type="string" translate="true">Credit Memo #</item> - </item> - </argument> - </filterInput> - <filterRange name="created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">created_at</item> - <item name="label" xsi:type="string" translate="true">Created</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterInput name="order_increment_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">order_increment_id</item> - <item name="label" xsi:type="string" translate="true">Order #</item> - </item> - </argument> - </filterInput> - <filterRange name="order_created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">order_created_at</item> - <item name="label" xsi:type="string" translate="true">Order Date</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterInput name="billing_name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_name</item> - <item name="label" xsi:type="string" translate="true">Bill-to Name</item> - </item> - </argument> - </filterInput> - <filterSelect name="state"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Sales\Ui\Component\Listing\Column\Creditmemo\State\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">state</item> - <item name="label" xsi:type="string" translate="true">Status</item> - </item> - </argument> - </filterSelect> - <filterRange name="base_grand_total"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">base_grand_total</item> - <item name="label" xsi:type="string" translate="true">Refunded</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterSelect name="order_status"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Sales\Ui\Component\Listing\Column\Status\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">order_status</item> - <item name="label" xsi:type="string" translate="true">Order Status</item> - </item> - </argument> - </filterSelect> <filterSelect name="store_id"> <argument name="optionsProvider" xsi:type="configurableObject"> <argument name="class" xsi:type="string">Magento\Store\Ui\Component\Listing\Column\Store\Options</argument> @@ -248,221 +104,11 @@ </item> </argument> </filterSelect> - <filterInput name="billing_address"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_address</item> - <item name="label" xsi:type="string" translate="true">Billing Address</item> - </item> - </argument> - </filterInput> - <filterInput name="shipping_address"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_address</item> - <item name="label" xsi:type="string" translate="true">Shipping Address</item> - </item> - </argument> - </filterInput> - <filterInput name="customer_name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">customer_name</item> - <item name="label" xsi:type="string" translate="true">Customer Name</item> - </item> - </argument> - </filterInput> - <filterInput name="customer_email"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">customer_email</item> - <item name="label" xsi:type="string" translate="true">Customer Email</item> - </item> - </argument> - </filterInput> - <filterSelect name="customer_group_id"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Customer\Ui\Component\Listing\Column\Group\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">customer_group_id</item> - <item name="label" xsi:type="string" translate="true">Customer Group</item> - </item> - </argument> - </filterSelect> - <filterSelect name="payment_method"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Payment\Ui\Component\Listing\Column\Method\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">payment_method</item> - <item name="label" xsi:type="string" translate="true">Payment Method</item> - </item> - </argument> - </filterSelect> - <filterInput name="shipping_information"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_information</item> - <item name="label" xsi:type="string" translate="true">Shipping Information</item> - </item> - </argument> - </filterInput> - <filterRange name="subtotal"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">subtotal</item> - <item name="label" xsi:type="string" translate="true">Subtotal</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterRange name="shipping_and_handling"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_and_handling</item> - <item name="label" xsi:type="string" translate="true">Shipping and Handling</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterRange name="adjustment_positive"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">adjustment_positive</item> - <item name="label" xsi:type="string" translate="true">Adjustment Refund</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterRange name="adjustment_negative"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">adjustment_negative</item> - <item name="label" xsi:type="string" translate="true">Adjustment Fee</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterRange name="order_base_grand_total"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">order_base_grand_total</item> - <item name="label" xsi:type="string" translate="true">Grand Total</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> </filters> <massaction name="listing_massaction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="selectProvider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.sales_order_creditmemo_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> <item name="indexField" xsi:type="string">entity_id</item> </item> </argument> @@ -484,7 +130,6 @@ <item name="namespace" xsi:type="string">current.paging</item> </item> <item name="selectProvider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.sales_order_creditmemo_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> </item> </argument> </paging> @@ -497,9 +142,14 @@ <item name="namespace" xsi:type="string">current</item> </item> <item name="childDefaults" xsi:type="array"> - <item name="controlVisibility" xsi:type="boolean">true</item> - <item name="actionField" xsi:type="string">actions</item> - <item name="clickAction" xsi:type="string">view</item> + <item name="fieldAction" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.sales_order_creditmemo_columns.actions</item> + <item name="target" xsi:type="string">applyAction</item> + <item name="params" xsi:type="array"> + <item name="0" xsi:type="string">view</item> + <item name="1" xsi:type="string">${ $.$data.rowIndex }</item> + </item> + </item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.bookmarks</item> <item name="root" xsi:type="string">columns.${ $.index }</item> @@ -508,303 +158,222 @@ </item> </item> </argument> - <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <selectionsColumn name="ids"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> - </item> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> <item name="indexField" xsi:type="string">entity_id</item> - <item name="controlVisibility" xsi:type="boolean">false</item> </item> </argument> - </column> + </selectionsColumn> <column name="increment_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Credit Memo</item> </item> </argument> </column> <column name="created_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Created</item> </item> </argument> </column> <column name="order_increment_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Order</item> </item> </argument> </column> <column name="order_created_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Order Date</item> </item> </argument> </column> <column name="billing_name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Bill-to Name</item> </item> </argument> </column> - <column name="state" class="Magento\Sales\Ui\Component\Listing\Column\Creditmemo\State"> + <column name="state"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> + <item name="options" xsi:type="object">Magento\Sales\Ui\Component\Listing\Column\Creditmemo\State\Options</item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Status</item> </item> </argument> </column> <column name="base_grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">textRange</item> <item name="label" xsi:type="string" translate="true">Refunded</item> </item> </argument> </column> - <column name="order_status" class="Magento\Sales\Ui\Component\Listing\Column\Status"> + <column name="order_status"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> + <item name="options" xsi:type="object">Magento\Sales\Ui\Component\Listing\Column\Status\Options</item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Order Status</item> </item> </argument> </column> <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> <item name="sortable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Purchased From</item> </item> </argument> </column> <column name="billing_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Billing Address</item> </item> </argument> </column> <column name="shipping_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping Address</item> </item> </argument> </column> <column name="customer_name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Customer Name</item> </item> </argument> </column> <column name="customer_email"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Email</item> </item> </argument> </column> - <column name="customer_group_id" class="Magento\Sales\Ui\Component\Listing\Column\CustomerGroup"> + <column name="customer_group_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> + <item name="options" xsi:type="object">Magento\Customer\Ui\Component\Listing\Column\Group\Options</item> <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + <item name="filter" xsi:type="string">select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Customer Group</item> </item> </argument> </column> - <column name="payment_method" class="Magento\Sales\Ui\Component\Listing\Column\PaymentMethod"> + <column name="payment_method"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> + <item name="options" xsi:type="object">Magento\Payment\Ui\Component\Listing\Column\Method\Options</item> <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + <item name="filter" xsi:type="string">select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Payment Method</item> </item> </argument> </column> <column name="shipping_information"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping Information</item> </item> </argument> </column> <column name="subtotal" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Subtotal</item> </item> </argument> </column> <column name="shipping_and_handling" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping & Handling</item> </item> </argument> </column> <column name="adjustment_positive" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Adjustment Refund</item> </item> </argument> </column> <column name="adjustment_negative" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Adjustment Fee</item> </item> </argument> </column> <column name="order_base_grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Grand Total</item> </item> </argument> </column> - <column name="actions" class="Magento\Sales\Ui\Component\Listing\Column\ViewAction"> + <actionsColumn name="actions" class="Magento\Sales\Ui\Component\Listing\Column\ViewAction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">actions</item> <item name="indexField" xsi:type="string">entity_id</item> - <item name="align" xsi:type="string">left</item> - <item name="label" xsi:type="string" translate="true">Action</item> - <item name="data_type" xsi:type="string">actions</item> - <item name="filterable" xsi:type="boolean">false</item> - <item name="sortable" xsi:type="boolean">false</item> <item name="viewUrlPath" xsi:type="string">sales/creditmemo/view</item> <item name="urlEntityParamName" xsi:type="string">creditmemo_id</item> </item> </argument> - </column> + </actionsColumn> </columns> </listing> diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml index 80f60a06ceddb460748e28d1f0647f610302c671..6e57da8d260845951285c1c6cedc3b2f6a0f003a 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml @@ -48,17 +48,13 @@ <bookmark name="bookmarks"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> - <item name="displayArea" xsi:type="string">dataGridActions</item> <item name="storageConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> - <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> <item name="namespace" xsi:type="string">sales_order_grid</item> </item> </item> </argument> </bookmark> - <container name="columns_controls"> + <component name="columns_controls"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="columnsData" xsi:type="array"> @@ -68,7 +64,7 @@ <item name="displayArea" xsi:type="string">dataGridActions</item> </item> </argument> - </container> + </component> <exportButton name="export_button"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> @@ -91,8 +87,7 @@ <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="displayArea" xsi:type="string">dataGridFilters</item> - <item name="dataScope" xsi:type="string">filters</item> + <item name="columnsProvider" xsi:type="string">sales_order_grid.sales_order_grid.sales_order_columns</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.filters</item> @@ -100,19 +95,11 @@ <item name="childDefaults" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.listing_filters</item> <item name="imports" xsi:type="array"> - <item name="visible" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.bookmarks:current.columns.${ $.index }.visible</item> + <item name="visible" xsi:type="string">sales_order_grid.sales_order_grid.sales_order_columns.${ $.index }:visible</item> </item> </item> </item> </argument> - <filterInput name="increment_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">increment_id</item> - <item name="label" xsi:type="string" translate="true">ID</item> - </item> - </argument> - </filterInput> <filterSelect name="store_id"> <argument name="optionsProvider" xsi:type="configurableObject"> <argument name="class" xsi:type="string">Magento\Store\Ui\Component\Listing\Column\Store\Options</argument> @@ -125,280 +112,11 @@ </item> </argument> </filterSelect> - <filterRange name="created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">created_at</item> - <item name="label" xsi:type="string" translate="true">Purchase Date</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterInput name="billing_name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_name</item> - <item name="label" xsi:type="string" translate="true">Bill-to Name</item> - </item> - </argument> - </filterInput> - <filterInput name="shipping_name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_name</item> - <item name="label" xsi:type="string" translate="true">Ship-to Name</item> - </item> - </argument> - </filterInput> - <filterRange name="base_grand_total"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">base_grand_total</item> - <item name="label" xsi:type="string" translate="true">Grand Total (Base)</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterRange name="grand_total"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">grand_total</item> - <item name="label" xsi:type="string" translate="true">Grand Total (Purchased)</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterSelect name="status"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Sales\Ui\Component\Listing\Column\Status\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">status</item> - <item name="label" xsi:type="string" translate="true">Status</item> - </item> - </argument> - </filterSelect> - <filterInput name="billing_address"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_address</item> - <item name="label" xsi:type="string" translate="true">Bill-to Name</item> - </item> - </argument> - </filterInput> - <filterInput name="shipping_address"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_address</item> - <item name="label" xsi:type="string" translate="true">Shipping Address</item> - </item> - </argument> - </filterInput> - <filterInput name="shipping_information"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_information</item> - <item name="label" xsi:type="string" translate="true">Shipping Information</item> - </item> - </argument> - </filterInput> - <filterInput name="customer_email"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">customer_email</item> - <item name="label" xsi:type="string" translate="true">Customer Email</item> - </item> - </argument> - </filterInput> - <filterSelect name="customer_group"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Customer\Ui\Component\Listing\Column\Group\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">customer_group</item> - <item name="label" xsi:type="string" translate="true">Customer Group</item> - </item> - </argument> - </filterSelect> - <filterRange name="subtotal"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">subtotal</item> - <item name="label" xsi:type="string" translate="true">Subtotal</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterRange name="shipping_and_handling"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_and_handling</item> - <item name="label" xsi:type="string" translate="true">Shipping and Handling</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterInput name="customer_name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">customer_name</item> - <item name="label" xsi:type="string" translate="true">Customer Name</item> - </item> - </argument> - </filterInput> - <filterSelect name="payment_method"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Payment\Ui\Component\Listing\Column\Method\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">payment_method</item> - <item name="label" xsi:type="string" translate="true">Payment Method</item> - </item> - </argument> - </filterSelect> - <filterRange name="total_refunded"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">total_refunded</item> - <item name="label" xsi:type="string" translate="true">Total Refunded</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> </filters> <massaction name="listing_massaction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="selectProvider" xsi:type="string">sales_order_grid.sales_order_grid.sales_order_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> <item name="indexField" xsi:type="string">entity_id</item> </item> </argument> @@ -483,7 +201,6 @@ <item name="namespace" xsi:type="string">current.paging</item> </item> <item name="selectProvider" xsi:type="string">sales_order_grid.sales_order_grid.sales_order_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> </item> </argument> </paging> @@ -496,9 +213,14 @@ <item name="namespace" xsi:type="string">current</item> </item> <item name="childDefaults" xsi:type="array"> - <item name="controlVisibility" xsi:type="boolean">true</item> - <item name="actionField" xsi:type="string">actions</item> - <item name="clickAction" xsi:type="string">view</item> + <item name="fieldAction" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.sales_order_columns.actions</item> + <item name="target" xsi:type="string">applyAction</item> + <item name="params" xsi:type="array"> + <item name="0" xsi:type="string">view</item> + <item name="1" xsi:type="string">${ $.$data.rowIndex }</item> + </item> + </item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.bookmarks</item> <item name="root" xsi:type="string">columns.${ $.index }</item> @@ -507,264 +229,190 @@ </item> </item> </argument> - <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <selectionsColumn name="ids"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> - </item> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> <item name="indexField" xsi:type="string">entity_id</item> - <item name="controlVisibility" xsi:type="boolean">false</item> </item> </argument> - </column> + </selectionsColumn> <column name="increment_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> + <item name="filter" xsi:type="string">text</item> <item name="sorting" xsi:type="string">desc</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">ID</item> </item> </argument> </column> <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="sortable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Purchase Point</item> </item> </argument> </column> <column name="created_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Purchase Date</item> </item> </argument> </column> <column name="billing_name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Bill-to Name</item> </item> </argument> </column> <column name="shipping_name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Ship-to Name</item> </item> </argument> </column> <column name="base_grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">textRange</item> <item name="label" xsi:type="string" translate="true">Grand Total (Base)</item> </item> </argument> </column> <column name="grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">textRange</item> <item name="label" xsi:type="string" translate="true">Grand Total (Purchased)</item> </item> </argument> </column> - <column name="status" class="Magento\Sales\Ui\Component\Listing\Column\Status"> + <column name="status"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> + <item name="options" xsi:type="object">Magento\Sales\Ui\Component\Listing\Column\Status\Options</item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Status</item> </item> </argument> </column> <column name="billing_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Billing Address</item> </item> </argument> </column> <column name="shipping_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping Address</item> </item> </argument> </column> <column name="shipping_information"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping Information</item> </item> </argument> </column> <column name="customer_email"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Customer Email</item> </item> </argument> </column> - <column name="customer_group" class="Magento\Sales\Ui\Component\Listing\Column\CustomerGroup"> + <column name="customer_group"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> + <item name="options" xsi:type="object">Magento\Customer\Ui\Component\Listing\Column\Group\Options</item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Customer Group</item> </item> </argument> </column> <column name="subtotal" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Subtotal</item> </item> </argument> </column> <column name="shipping_and_handling" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping and Handling</item> </item> </argument> </column> <column name="customer_name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Customer Name</item> </item> </argument> </column> - <column name="payment_method" class="Magento\Sales\Ui\Component\Listing\Column\PaymentMethod"> + <column name="payment_method"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> + <item name="options" xsi:type="object">Magento\Payment\Ui\Component\Listing\Column\Method\Options</item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Payment Method</item> </item> </argument> </column> <column name="total_refunded" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Total Refunded</item> </item> </argument> </column> - <column name="actions" class="Magento\Sales\Ui\Component\Listing\Column\ViewAction"> + <actionsColumn name="actions" class="Magento\Sales\Ui\Component\Listing\Column\ViewAction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">actions</item> <item name="indexField" xsi:type="string">entity_id</item> - <item name="align" xsi:type="string">left</item> - <item name="label" xsi:type="string" translate="true">Action</item> - <item name="data_type" xsi:type="string">actions</item> - <item name="filterable" xsi:type="boolean">false</item> - <item name="sortable" xsi:type="boolean">false</item> <item name="viewUrlPath" xsi:type="string">sales/order/view</item> <item name="urlEntityParamName" xsi:type="string">order_id</item> </item> </argument> - </column> + </actionsColumn> </columns> </listing> diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_invoice_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_invoice_grid.xml index 6053306f0980f6a7b1da5574205a767aa7095a67..2022ef7f1d5847b84dafdf368c065b0672acfc8c 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_invoice_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_invoice_grid.xml @@ -40,17 +40,13 @@ <bookmark name="bookmarks"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> - <item name="displayArea" xsi:type="string">dataGridActions</item> <item name="storageConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> - <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> <item name="namespace" xsi:type="string">sales_order_invoice_grid</item> </item> </item> </argument> </bookmark> - <container name="columns_controls"> + <component name="columns_controls"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="columnsData" xsi:type="array"> @@ -60,7 +56,7 @@ <item name="displayArea" xsi:type="string">dataGridActions</item> </item> </argument> - </container> + </component> <exportButton name="export_button"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> @@ -83,8 +79,7 @@ <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="displayArea" xsi:type="string">dataGridFilters</item> - <item name="dataScope" xsi:type="string">filters</item> + <item name="columnsProvider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.sales_order_invoice_columns</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.filters</item> @@ -92,109 +87,11 @@ <item name="childDefaults" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.listing_filters</item> <item name="imports" xsi:type="array"> - <item name="visible" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.bookmarks:current.columns.${ $.index }.visible</item> + <item name="visible" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.sales_order_invoice_columns.${ $.index }:visible</item> </item> </item> </item> </argument> - <filterInput name="increment_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">increment_id</item> - <item name="label" xsi:type="string" translate="true">Invoice #</item> - </item> - </argument> - </filterInput> - <filterRange name="created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">created_at</item> - <item name="label" xsi:type="string" translate="true">Invoice Date</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterInput name="order_increment_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">order_increment_id</item> - <item name="label" xsi:type="string" translate="true">Order #</item> - </item> - </argument> - </filterInput> - <filterRange name="order_created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">order_created_at</item> - <item name="label" xsi:type="string" translate="true">Order Date</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterInput name="billing_name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_name</item> - <item name="label" xsi:type="string" translate="true">Bill-to Name</item> - </item> - </argument> - </filterInput> - <filterSelect name="state"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Sales\Ui\Component\Listing\Column\Invoice\State\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">state</item> - <item name="label" xsi:type="string" translate="true">Status</item> - </item> - </argument> - </filterSelect> <filterSelect name="store_id"> <argument name="optionsProvider" xsi:type="configurableObject"> <argument name="class" xsi:type="string">Magento\Store\Ui\Component\Listing\Column\Store\Options</argument> @@ -207,163 +104,11 @@ </item> </argument> </filterSelect> - <filterInput name="billing_address"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_address</item> - <item name="label" xsi:type="string" translate="true">Billing Address</item> - </item> - </argument> - </filterInput> - <filterInput name="shipping_address"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_address</item> - <item name="label" xsi:type="string" translate="true">Shipping Address</item> - </item> - </argument> - </filterInput> - <filterInput name="customer_name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">customer_name</item> - <item name="label" xsi:type="string" translate="true">Customer Name</item> - </item> - </argument> - </filterInput> - <filterInput name="customer_email"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">customer_email</item> - <item name="label" xsi:type="string" translate="true">Customer Email</item> - </item> - </argument> - </filterInput> - <filterSelect name="customer_group_id"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Customer\Ui\Component\Listing\Column\Group\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">customer_group_id</item> - <item name="label" xsi:type="string" translate="true">Customer Group</item> - </item> - </argument> - </filterSelect> - <filterSelect name="payment_method"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Payment\Ui\Component\Listing\Column\Method\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">payment_method</item> - <item name="label" xsi:type="string" translate="true">Payment Method</item> - </item> - </argument> - </filterSelect> - <filterInput name="shipping_information"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_information</item> - <item name="label" xsi:type="string" translate="true">Shipping Information</item> - </item> - </argument> - </filterInput> - <filterRange name="subtotal"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">subtotal</item> - <item name="label" xsi:type="string" translate="true">Subtotal</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterRange name="shipping_and_handling"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_and_handling</item> - <item name="label" xsi:type="string" translate="true">Shipping and Handling</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterRange name="grand_total"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">grand_total</item> - <item name="label" xsi:type="string" translate="true">Grand Total</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> </filters> <massaction name="listing_massaction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="selectProvider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.sales_order_invoice_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> <item name="indexField" xsi:type="string">entity_id</item> </item> </argument> @@ -385,7 +130,6 @@ <item name="namespace" xsi:type="string">current.paging</item> </item> <item name="selectProvider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.sales_order_invoice_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> </item> </argument> </paging> @@ -398,9 +142,14 @@ <item name="namespace" xsi:type="string">current</item> </item> <item name="childDefaults" xsi:type="array"> - <item name="controlVisibility" xsi:type="boolean">true</item> - <item name="actionField" xsi:type="string">actions</item> - <item name="clickAction" xsi:type="string">view</item> + <item name="fieldAction" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.sales_order_invoice_columns.actions</item> + <item name="target" xsi:type="string">applyAction</item> + <item name="params" xsi:type="array"> + <item name="0" xsi:type="string">view</item> + <item name="1" xsi:type="string">${ $.$data.rowIndex }</item> + </item> + </item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.bookmarks</item> <item name="root" xsi:type="string">columns.${ $.index }</item> @@ -409,253 +158,183 @@ </item> </item> </argument> - <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <selectionsColumn name="ids"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> - </item> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> <item name="indexField" xsi:type="string">entity_id</item> - <item name="controlVisibility" xsi:type="boolean">false</item> </item> </argument> - </column> + </selectionsColumn> <column name="increment_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> + <item name="filter" xsi:type="string">text</item> <item name="sorting" xsi:type="string">asc</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Invoice</item> </item> </argument> </column> <column name="created_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Invoice Date</item> </item> </argument> </column> <column name="order_increment_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="sorting" xsi:type="string">asc</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Order #</item> </item> </argument> </column> <column name="order_created_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Order Date</item> </item> </argument> </column> <column name="billing_name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Bill-to Name</item> </item> </argument> </column> - <column name="state" class="Magento\Sales\Ui\Component\Listing\Column\Invoice\State"> + <column name="state"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> + <item name="options" xsi:type="object">Magento\Sales\Ui\Component\Listing\Column\Invoice\State\Options</item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Status</item> </item> </argument> </column> <column name="grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">textRange</item> <item name="label" xsi:type="string" translate="true">Amount</item> </item> </argument> </column> <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> <item name="sortable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Purchased From</item> </item> </argument> </column> <column name="billing_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Billing Address</item> </item> </argument> </column> <column name="shipping_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping Address</item> </item> </argument> </column> <column name="customer_name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Customer Name</item> </item> </argument> </column> <column name="customer_email"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Email</item> </item> </argument> </column> - <column name="customer_group_id" class="Magento\Sales\Ui\Component\Listing\Column\CustomerGroup"> + <column name="customer_group_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> + <item name="options" xsi:type="object">Magento\Customer\Ui\Component\Listing\Column\Group\Options</item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Customer Group</item> </item> </argument> </column> - <column name="payment_method" class="Magento\Sales\Ui\Component\Listing\Column\PaymentMethod"> + <column name="payment_method"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> + <item name="options" xsi:type="object">Magento\Payment\Ui\Component\Listing\Column\Method\Options</item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Payment Method</item> </item> </argument> </column> <column name="shipping_information"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping Information</item> </item> </argument> </column> <column name="subtotal" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Subtotal</item> </item> </argument> </column> <column name="shipping_and_handling" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping and Handling</item> </item> </argument> </column> - <column name="actions" class="Magento\Sales\Ui\Component\Listing\Column\ViewAction"> + <actionsColumn name="actions" class="Magento\Sales\Ui\Component\Listing\Column\ViewAction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">actions</item> <item name="indexField" xsi:type="string">increment_id</item> - <item name="align" xsi:type="string">left</item> - <item name="label" xsi:type="string" translate="true">Action</item> - <item name="data_type" xsi:type="string">actions</item> - <item name="filterable" xsi:type="boolean">false</item> - <item name="sortable" xsi:type="boolean">false</item> <item name="viewUrlPath" xsi:type="string">sales/invoice/view</item> <item name="urlEntityParamName" xsi:type="string">invoice_id</item> </item> </argument> - </column> + </actionsColumn> </columns> </listing> diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml index 054cbdfa52420bcacb017045acd16690d6f0c59e..7fed1927717889996266120fc16e4d31db073391 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml @@ -40,17 +40,13 @@ <bookmark name="bookmarks"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> - <item name="displayArea" xsi:type="string">dataGridActions</item> <item name="storageConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> - <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> <item name="namespace" xsi:type="string">sales_order_shipment_grid</item> </item> </item> </argument> </bookmark> - <container name="columns_controls"> + <component name="columns_controls"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="columnsData" xsi:type="array"> @@ -60,7 +56,7 @@ <item name="displayArea" xsi:type="string">dataGridActions</item> </item> </argument> - </container> + </component> <exportButton name="export_button"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> @@ -83,8 +79,7 @@ <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="displayArea" xsi:type="string">dataGridFilters</item> - <item name="dataScope" xsi:type="string">filters</item> + <item name="columnsProvider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.sales_order_shipment_columns</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.filters</item> @@ -92,138 +87,11 @@ <item name="childDefaults" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.listing_filters</item> <item name="imports" xsi:type="array"> - <item name="visible" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.bookmarks:current.columns.${ $.index }.visible</item> + <item name="visible" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.sales_order_shipment_columns.${ $.index }:visible</item> </item> </item> </item> </argument> - <filterInput name="increment_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">increment_id</item> - <item name="label" xsi:type="string" translate="true">Shipment #</item> - </item> - </argument> - </filterInput> - <filterRange name="created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">created_at</item> - <item name="label" xsi:type="string" translate="true">Ship Date</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterInput name="order_increment_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">order_increment_id</item> - <item name="label" xsi:type="string" translate="true">Order #</item> - </item> - </argument> - </filterInput> - <filterRange name="order_created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">order_created_at</item> - <item name="label" xsi:type="string" translate="true">Order Date</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterInput name="shipping_name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_name</item> - <item name="label" xsi:type="string" translate="true">Ship-to Name</item> - </item> - </argument> - </filterInput> - <filterRange name="total_qty"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">total_qty</item> - <item name="label" xsi:type="string" translate="true">Total Quantity</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterSelect name="order_status"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Sales\Ui\Component\Listing\Column\Status\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">order_status</item> - <item name="label" xsi:type="string" translate="true">Order Status</item> - </item> - </argument> - </filterSelect> <filterSelect name="store_id"> <argument name="optionsProvider" xsi:type="configurableObject"> <argument name="class" xsi:type="string">Magento\Store\Ui\Component\Listing\Column\Store\Options</argument> @@ -236,76 +104,11 @@ </item> </argument> </filterSelect> - <filterInput name="customer_name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">customer_name</item> - <item name="label" xsi:type="string" translate="true">Customer Name</item> - </item> - </argument> - </filterInput> - <filterInput name="customer_email"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">customer_email</item> - <item name="label" xsi:type="string" translate="true">Customer Email</item> - </item> - </argument> - </filterInput> - <filterSelect name="customer_group_id"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Customer\Ui\Component\Listing\Column\Group\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">customer_group_id</item> - <item name="label" xsi:type="string" translate="true">Customer Group</item> - </item> - </argument> - </filterSelect> - <filterInput name="billing_address"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_address</item> - <item name="label" xsi:type="string" translate="true">Billing Address</item> - </item> - </argument> - </filterInput> - <filterInput name="shipping_address"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_address</item> - <item name="label" xsi:type="string" translate="true">Shipping Address</item> - </item> - </argument> - </filterInput> - <filterSelect name="payment_method"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Payment\Ui\Component\Listing\Column\Method\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">payment_method</item> - <item name="label" xsi:type="string" translate="true">Payment Method</item> - </item> - </argument> - </filterSelect> - <filterInput name="shipping_information"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_information</item> - <item name="label" xsi:type="string" translate="true">Shipping Information</item> - </item> - </argument> - </filterInput> </filters> <massaction name="listing_massaction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="selectProvider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.sales_order_shipment_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> <item name="indexField" xsi:type="string">entity_id</item> </item> </argument> @@ -336,7 +139,6 @@ <item name="namespace" xsi:type="string">current.paging</item> </item> <item name="selectProvider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.sales_order_shipment_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> </item> </argument> </paging> @@ -349,9 +151,14 @@ <item name="namespace" xsi:type="string">current</item> </item> <item name="childDefaults" xsi:type="array"> - <item name="controlVisibility" xsi:type="boolean">true</item> - <item name="actionField" xsi:type="string">actions</item> - <item name="clickAction" xsi:type="string">view</item> + <item name="fieldAction" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.sales_order_shipment_columns.actions</item> + <item name="target" xsi:type="string">applyAction</item> + <item name="params" xsi:type="array"> + <item name="0" xsi:type="string">view</item> + <item name="1" xsi:type="string">${ $.$data.rowIndex }</item> + </item> + </item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.bookmarks</item> <item name="root" xsi:type="string">columns.${ $.index }</item> @@ -360,228 +167,167 @@ </item> </item> </argument> - <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <selectionsColumn name="ids"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> - </item> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> <item name="indexField" xsi:type="string">entity_id</item> - <item name="controlVisibility" xsi:type="boolean">false</item> </item> </argument> - </column> + </selectionsColumn> <column name="increment_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> + <item name="filter" xsi:type="string">text</item> <item name="sorting" xsi:type="string">asc</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipment</item> </item> </argument> </column> <column name="created_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Ship Date</item> </item> </argument> </column> <column name="order_increment_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="sorting" xsi:type="string">asc</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Order</item> </item> </argument> </column> <column name="order_created_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Order Date</item> </item> </argument> </column> <column name="shipping_name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Ship-to Name</item> </item> </argument> </column> <column name="total_qty"> - <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> + <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">textRange</item> <item name="label" xsi:type="string" translate="true">Total Quantity</item> </item> </argument> </column> - <column name="order_status" class="Magento\Sales\Ui\Component\Listing\Column\Status"> + <column name="order_status"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> + <item name="options" xsi:type="object">Magento\Sales\Ui\Component\Listing\Column\Status\Options</item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Order Status</item> </item> </argument> </column> <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> <item name="sortable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Purchased From</item> </item> </argument> </column> <column name="customer_name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Customer Name</item> </item> </argument> </column> <column name="customer_email"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Email</item> </item> </argument> </column> - <column name="customer_group_id" class="Magento\Sales\Ui\Component\Listing\Column\CustomerGroup"> + <column name="customer_group_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> + <item name="options" xsi:type="object">Magento\Customer\Ui\Component\Listing\Column\Group\Options</item> <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + <item name="filter" xsi:type="string">select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Customer Group</item> </item> </argument> </column> <column name="billing_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Billing Address</item> </item> </argument> </column> <column name="shipping_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping Address</item> </item> </argument> </column> - <column name="payment_method" class="Magento\Sales\Ui\Component\Listing\Column\PaymentMethod"> + <column name="payment_method"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> + <item name="options" xsi:type="object">Magento\Payment\Ui\Component\Listing\Column\Method\Options</item> <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + <item name="filter" xsi:type="string">select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Payment Method</item> </item> </argument> </column> <column name="shipping_information"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping Information</item> </item> </argument> </column> - <column name="actions" class="Magento\Sales\Ui\Component\Listing\Column\ViewAction"> + <actionsColumn name="actions" class="Magento\Sales\Ui\Component\Listing\Column\ViewAction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">actions</item> <item name="indexField" xsi:type="string">entity_id</item> - <item name="align" xsi:type="string">left</item> - <item name="label" xsi:type="string" translate="true">Action</item> - <item name="data_type" xsi:type="string">actions</item> - <item name="filterable" xsi:type="boolean">false</item> - <item name="sortable" xsi:type="boolean">false</item> <item name="viewUrlPath" xsi:type="string">sales/shipment/view</item> <item name="urlEntityParamName" xsi:type="string">shipment_id</item> </item> </argument> - </column> + </actionsColumn> </columns> </listing> diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml index 25971bdc21b848dd90db3627e125e9fd989655a9..4377aefc1b19b007bf3b9922994ba114cbb1add9 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml @@ -43,17 +43,13 @@ <bookmark name="bookmarks"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> - <item name="displayArea" xsi:type="string">dataGridActions</item> <item name="storageConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> - <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> <item name="namespace" xsi:type="string">sales_order_view_creditmemo_grid</item> </item> </item> </argument> </bookmark> - <container name="columns_controls"> + <component name="columns_controls"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="columnsData" xsi:type="array"> @@ -63,7 +59,7 @@ <item name="displayArea" xsi:type="string">dataGridActions</item> </item> </argument> - </container> + </component> <exportButton name="export_button"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> @@ -86,8 +82,7 @@ <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="displayArea" xsi:type="string">dataGridFilters</item> - <item name="dataScope" xsi:type="string">filters</item> + <item name="columnsProvider" xsi:type="string">sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.sales_order_creditmemo_columns</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.filters</item> @@ -95,150 +90,11 @@ <item name="childDefaults" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.listing_top.listing_filters</item> <item name="imports" xsi:type="array"> - <item name="visible" xsi:type="string">sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.listing_top.bookmarks:current.columns.${ $.index }.visible</item> + <item name="visible" xsi:type="string">sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.sales_order_creditmemo_columns.${ $.index }:visible</item> </item> </item> </item> </argument> - <filterInput name="increment_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">increment_id</item> - <item name="label" xsi:type="string" translate="true">Credit Memo</item> - </item> - </argument> - </filterInput> - <filterRange name="created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">created_at</item> - <item name="label" xsi:type="string" translate="true">Created</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterInput name="order_increment_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">order_increment_id</item> - <item name="label" xsi:type="string" translate="true">Order</item> - </item> - </argument> - </filterInput> - <filterRange name="order_created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">order_created_at</item> - <item name="label" xsi:type="string" translate="true">Order Date</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterInput name="billing_name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_name</item> - <item name="label" xsi:type="string" translate="true">Bill-to Name</item> - </item> - </argument> - </filterInput> - <filterSelect name="state"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Sales\Ui\Component\Listing\Column\Creditmemo\State\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">state</item> - <item name="label" xsi:type="string" translate="true">Status</item> - </item> - </argument> - </filterSelect> - <filterRange name="base_grand_total"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">base_grand_total</item> - <item name="label" xsi:type="string" translate="true">Refunded</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterSelect name="order_status"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Sales\Ui\Component\Listing\Column\Status\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">order_status</item> - <item name="label" xsi:type="string" translate="true">Order Status</item> - </item> - </argument> - </filterSelect> <filterSelect name="store_id"> <argument name="optionsProvider" xsi:type="configurableObject"> <argument name="class" xsi:type="string">Magento\Store\Ui\Component\Listing\Column\Store\Options</argument> @@ -251,163 +107,11 @@ </item> </argument> </filterSelect> - <filterInput name="billing_address"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_address</item> - <item name="label" xsi:type="string" translate="true">Billing Address</item> - </item> - </argument> - </filterInput> - <filterInput name="shipping_address"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_address</item> - <item name="label" xsi:type="string" translate="true">Shipping Address</item> - </item> - </argument> - </filterInput> - <filterInput name="customer_name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">customer_name</item> - <item name="label" xsi:type="string" translate="true">Customer Name</item> - </item> - </argument> - </filterInput> - <filterInput name="customer_email"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">customer_email</item> - <item name="label" xsi:type="string" translate="true">Customer Email</item> - </item> - </argument> - </filterInput> - <filterSelect name="customer_group_id"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Customer\Ui\Component\Listing\Column\Group\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">customer_group_id</item> - <item name="label" xsi:type="string" translate="true">Customer Group</item> - </item> - </argument> - </filterSelect> - <filterSelect name="payment_method"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Payment\Ui\Component\Listing\Column\Method\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">payment_method</item> - <item name="label" xsi:type="string" translate="true">Payment Method</item> - </item> - </argument> - </filterSelect> - <filterInput name="shipping_information"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_information</item> - <item name="label" xsi:type="string" translate="true">Shipping Information</item> - </item> - </argument> - </filterInput> - <filterRange name="subtotal"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">subtotal</item> - <item name="label" xsi:type="string" translate="true">Subtotal</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterRange name="shipping_and_handling"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_and_handling</item> - <item name="label" xsi:type="string" translate="true">Shipping and Handling</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterRange name="order_base_grand_total"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">order_base_grand_total</item> - <item name="label" xsi:type="string" translate="true">Grand Total</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> </filters> <massaction name="listing_massaction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="selectProvider" xsi:type="string">sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.sales_order_creditmemo_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> <item name="indexField" xsi:type="string">entity_id</item> </item> </argument> @@ -429,7 +133,6 @@ <item name="namespace" xsi:type="string">current.paging</item> </item> <item name="selectProvider" xsi:type="string">sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.sales_order_creditmemo_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> </item> </argument> </paging> @@ -442,9 +145,14 @@ <item name="namespace" xsi:type="string">current</item> </item> <item name="childDefaults" xsi:type="array"> - <item name="controlVisibility" xsi:type="boolean">true</item> - <item name="actionField" xsi:type="string">actions</item> - <item name="clickAction" xsi:type="string">view</item> + <item name="fieldAction" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.sales_order_creditmemo_columns.actions</item> + <item name="target" xsi:type="string">applyAction</item> + <item name="params" xsi:type="array"> + <item name="0" xsi:type="string">view</item> + <item name="1" xsi:type="string">${ $.$data.rowIndex }</item> + </item> + </item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.listing_top.bookmarks</item> <item name="root" xsi:type="string">columns.${ $.index }</item> @@ -453,303 +161,222 @@ </item> </item> </argument> - <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <selectionsColumn name="ids"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> - </item> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> <item name="indexField" xsi:type="string">entity_id</item> - <item name="controlVisibility" xsi:type="boolean">false</item> </item> </argument> - </column> + </selectionsColumn> <column name="increment_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Credit Memo</item> </item> </argument> </column> <column name="created_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Created</item> </item> </argument> </column> <column name="order_increment_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Order</item> </item> </argument> </column> <column name="order_created_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Order Date</item> </item> </argument> </column> <column name="billing_name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Bill-to Name</item> </item> </argument> </column> - <column name="state" class="Magento\Sales\Ui\Component\Listing\Column\Creditmemo\State"> + <column name="state"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> + <item name="options" xsi:type="object">Magento\Sales\Ui\Component\Listing\Column\Creditmemo\State\Options</item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Status</item> </item> </argument> </column> <column name="base_grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">textRange</item> <item name="label" xsi:type="string" translate="true">Refunded</item> </item> </argument> </column> - <column name="order_status" class="Magento\Sales\Ui\Component\Listing\Column\Status"> + <column name="order_status"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> + <item name="options" xsi:type="object">Magento\Sales\Ui\Component\Listing\Column\Status\Options</item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Order Status</item> </item> </argument> </column> <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> <item name="sortable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Purchased From</item> </item> </argument> </column> <column name="billing_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Billing Address</item> </item> </argument> </column> <column name="shipping_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping Address</item> </item> </argument> </column> <column name="customer_name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Customer Name</item> </item> </argument> </column> <column name="customer_email"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Email</item> </item> </argument> </column> - <column name="customer_group_id" class="Magento\Sales\Ui\Component\Listing\Column\CustomerGroup"> + <column name="customer_group_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> + <item name="options" xsi:type="object">Magento\Customer\Ui\Component\Listing\Column\Group\Options</item> <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + <item name="filter" xsi:type="string">select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Customer Group</item> </item> </argument> </column> - <column name="payment_method" class="Magento\Sales\Ui\Component\Listing\Column\PaymentMethod"> + <column name="payment_method"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> + <item name="options" xsi:type="object">Magento\Payment\Ui\Component\Listing\Column\Method\Options</item> <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + <item name="filter" xsi:type="string">select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Payment Method</item> </item> </argument> </column> <column name="shipping_information"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping Information</item> </item> </argument> </column> <column name="subtotal" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Subtotal</item> </item> </argument> </column> <column name="shipping_and_handling" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping & Handling</item> </item> </argument> </column> <column name="adjustment_positive" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Adjustment Refund</item> </item> </argument> </column> <column name="adjustment_negative" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Adjustment Fee</item> </item> </argument> </column> <column name="order_base_grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Grand Total</item> </item> </argument> </column> - <column name="actions" class="Magento\Sales\Ui\Component\Listing\Column\ViewAction"> + <actionsColumn name="actions" class="Magento\Sales\Ui\Component\Listing\Column\ViewAction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">actions</item> <item name="indexField" xsi:type="string">entity_id</item> - <item name="align" xsi:type="string">left</item> - <item name="label" xsi:type="string" translate="true">Action</item> - <item name="data_type" xsi:type="string">actions</item> - <item name="filterable" xsi:type="boolean">false</item> - <item name="sortable" xsi:type="boolean">false</item> <item name="viewUrlPath" xsi:type="string">sales/order_creditmemo/view</item> <item name="urlEntityParamName" xsi:type="string">creditmemo_id</item> </item> </argument> - </column> + </actionsColumn> </columns> </listing> diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml index d77d4fceeaeafeaddb745c5bb8141e4e5600b1f1..9ea839d31c23a9dea465d9806109c4e2a2ca6320 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml @@ -43,17 +43,13 @@ <bookmark name="bookmarks"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> - <item name="displayArea" xsi:type="string">dataGridActions</item> <item name="storageConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> - <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> <item name="namespace" xsi:type="string">sales_order_view_invoice_grid</item> </item> </item> </argument> </bookmark> - <container name="columns_controls"> + <component name="columns_controls"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="columnsData" xsi:type="array"> @@ -63,7 +59,7 @@ <item name="displayArea" xsi:type="string">dataGridActions</item> </item> </argument> - </container> + </component> <exportButton name="export_button"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> @@ -86,8 +82,7 @@ <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="displayArea" xsi:type="string">dataGridFilters</item> - <item name="dataScope" xsi:type="string">filters</item> + <item name="columnsProvider" xsi:type="string">sales_order_view_invoice_grid.sales_order_view_invoice_grid.sales_order_invoice_columns</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_view_invoice_grid.sales_order_view_invoice_grid.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.filters</item> @@ -100,104 +95,6 @@ </item> </item> </argument> - <filterInput name="increment_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">increment_id</item> - <item name="label" xsi:type="string" translate="true">Invoice #</item> - </item> - </argument> - </filterInput> - <filterRange name="created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">created_at</item> - <item name="label" xsi:type="string" translate="true">Invoice Date</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_view_invoice_grid.sales_order_view_invoice_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterInput name="order_increment_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">order_increment_id</item> - <item name="label" xsi:type="string" translate="true">Order #</item> - </item> - </argument> - </filterInput> - <filterRange name="order_created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">order_created_at</item> - <item name="label" xsi:type="string" translate="true">Order Date</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_view_invoice_grid.sales_order_view_invoice_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterInput name="billing_name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_name</item> - <item name="label" xsi:type="string" translate="true">Bill-to Name</item> - </item> - </argument> - </filterInput> - <filterSelect name="state"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Sales\Ui\Component\Listing\Column\Invoice\State\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">state</item> - <item name="label" xsi:type="string" translate="true">Status</item> - </item> - </argument> - </filterSelect> <filterSelect name="store_id"> <argument name="optionsProvider" xsi:type="configurableObject"> <argument name="class" xsi:type="string">Magento\Store\Ui\Component\Listing\Column\Store\Options</argument> @@ -210,163 +107,11 @@ </item> </argument> </filterSelect> - <filterInput name="billing_address"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_address</item> - <item name="label" xsi:type="string" translate="true">Billing Address</item> - </item> - </argument> - </filterInput> - <filterInput name="shipping_address"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_address</item> - <item name="label" xsi:type="string" translate="true">Shipping Address</item> - </item> - </argument> - </filterInput> - <filterInput name="customer_name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">customer_name</item> - <item name="label" xsi:type="string" translate="true">Customer Name</item> - </item> - </argument> - </filterInput> - <filterInput name="customer_email"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">customer_email</item> - <item name="label" xsi:type="string" translate="true">Customer Email</item> - </item> - </argument> - </filterInput> - <filterSelect name="customer_group_id"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Customer\Ui\Component\Listing\Column\Group\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">customer_group_id</item> - <item name="label" xsi:type="string" translate="true">Customer Group</item> - </item> - </argument> - </filterSelect> - <filterSelect name="payment_method"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Payment\Ui\Component\Listing\Column\Method\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">payment_method</item> - <item name="label" xsi:type="string" translate="true">Payment Method</item> - </item> - </argument> - </filterSelect> - <filterInput name="shipping_information"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_information</item> - <item name="label" xsi:type="string" translate="true">Shipping Information</item> - </item> - </argument> - </filterInput> - <filterRange name="subtotal"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">subtotal</item> - <item name="label" xsi:type="string" translate="true">Subtotal</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_view_invoice_grid.sales_order_view_invoice_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterRange name="shipping_and_handling"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_and_handling</item> - <item name="label" xsi:type="string" translate="true">Shipping and Handling</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_view_invoice_grid.sales_order_view_invoice_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterRange name="grand_total"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">grand_total</item> - <item name="label" xsi:type="string" translate="true">Grand Total</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_view_invoice_grid.sales_order_view_invoice_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> </filters> <massaction name="listing_massaction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="selectProvider" xsi:type="string">sales_order_view_invoice_grid.sales_order_view_invoice_grid.sales_order_invoice_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> <item name="indexField" xsi:type="string">entity_id</item> </item> </argument> @@ -388,7 +133,6 @@ <item name="namespace" xsi:type="string">current.paging</item> </item> <item name="selectProvider" xsi:type="string">sales_order_view_invoice_grid.sales_order_view_invoice_grid.sales_order_invoice_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> </item> </argument> </paging> @@ -401,9 +145,14 @@ <item name="namespace" xsi:type="string">current</item> </item> <item name="childDefaults" xsi:type="array"> - <item name="controlVisibility" xsi:type="boolean">true</item> - <item name="actionField" xsi:type="string">actions</item> - <item name="clickAction" xsi:type="string">view</item> + <item name="fieldAction" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_view_invoice_grid.sales_order_view_invoice_grid.sales_order_invoice_columns.actions</item> + <item name="target" xsi:type="string">applyAction</item> + <item name="params" xsi:type="array"> + <item name="0" xsi:type="string">view</item> + <item name="1" xsi:type="string">${ $.$data.rowIndex }</item> + </item> + </item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_view_invoice_grid.sales_order_view_invoice_grid.listing_top.bookmarks</item> <item name="root" xsi:type="string">columns.${ $.index }</item> @@ -412,253 +161,183 @@ </item> </item> </argument> - <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <selectionsColumn name="ids"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> - </item> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> <item name="indexField" xsi:type="string">entity_id</item> - <item name="controlVisibility" xsi:type="boolean">false</item> </item> </argument> - </column> + </selectionsColumn> <column name="increment_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> + <item name="filter" xsi:type="string">text</item> <item name="sorting" xsi:type="string">asc</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Invoice</item> </item> </argument> </column> <column name="created_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Invoice Date</item> </item> </argument> </column> <column name="order_increment_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="sorting" xsi:type="string">asc</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Order #</item> </item> </argument> </column> <column name="order_created_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Order Date</item> </item> </argument> </column> <column name="billing_name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Bill-to Name</item> </item> </argument> </column> - <column name="state" class="Magento\Sales\Ui\Component\Listing\Column\Invoice\State"> + <column name="state"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> + <item name="options" xsi:type="object">Magento\Sales\Ui\Component\Listing\Column\Invoice\State\Options</item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Status</item> </item> </argument> </column> <column name="grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">textRange</item> <item name="label" xsi:type="string" translate="true">Amount</item> </item> </argument> </column> <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> <item name="sortable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Purchased From</item> </item> </argument> </column> <column name="billing_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Billing Address</item> </item> </argument> </column> <column name="shipping_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping Address</item> </item> </argument> </column> <column name="customer_name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Customer Name</item> </item> </argument> </column> <column name="customer_email"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Email</item> </item> </argument> </column> - <column name="customer_group_id" class="Magento\Sales\Ui\Component\Listing\Column\CustomerGroup"> + <column name="customer_group_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> + <item name="options" xsi:type="object">Magento\Customer\Ui\Component\Listing\Column\Group\Options</item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Customer Group</item> </item> </argument> </column> - <column name="payment_method" class="Magento\Sales\Ui\Component\Listing\Column\PaymentMethod"> + <column name="payment_method"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> + <item name="options" xsi:type="object">Magento\Payment\Ui\Component\Listing\Column\Method\Options</item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Payment Method</item> </item> </argument> </column> <column name="shipping_information"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping Information</item> </item> </argument> </column> <column name="subtotal" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Subtotal</item> </item> </argument> </column> <column name="shipping_and_handling" class="Magento\Sales\Ui\Component\Listing\Column\Price"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">textRange</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping and Handling</item> </item> </argument> </column> - <column name="actions" class="Magento\Sales\Ui\Component\Listing\Column\ViewAction"> + <actionsColumn name="actions" class="Magento\Sales\Ui\Component\Listing\Column\ViewAction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">actions</item> <item name="indexField" xsi:type="string">increment_id</item> - <item name="align" xsi:type="string">left</item> - <item name="label" xsi:type="string" translate="true">Action</item> - <item name="data_type" xsi:type="string">actions</item> - <item name="filterable" xsi:type="boolean">false</item> - <item name="sortable" xsi:type="boolean">false</item> <item name="viewUrlPath" xsi:type="string">sales/order_invoice/view</item> <item name="urlEntityParamName" xsi:type="string">invoice_id</item> </item> </argument> - </column> + </actionsColumn> </columns> </listing> diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml index b90cf777cd15f22daba95ff7829d2588f14ae6bd..43539e5c20ccba9f758f5daab99fe880cb1c682e 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml @@ -43,17 +43,13 @@ <bookmark name="bookmarks"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> - <item name="displayArea" xsi:type="string">dataGridActions</item> <item name="storageConfig" xsi:type="array"> - <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> - <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> <item name="namespace" xsi:type="string">sales_order_view_shipment_grid</item> </item> </item> </argument> </bookmark> - <container name="columns_controls"> + <component name="columns_controls"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="columnsData" xsi:type="array"> @@ -63,7 +59,7 @@ <item name="displayArea" xsi:type="string">dataGridActions</item> </item> </argument> - </container> + </component> <exportButton name="export_button"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> @@ -86,8 +82,7 @@ <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="displayArea" xsi:type="string">dataGridFilters</item> - <item name="dataScope" xsi:type="string">filters</item> + <item name="columnsProvider" xsi:type="string">sales_order_view_shipment_grid.sales_order_view_shipment_grid.sales_order_shipment_columns</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_view_shipment_grid.sales_order_view_shipment_grid.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.filters</item> @@ -100,133 +95,6 @@ </item> </item> </argument> - <filterInput name="increment_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">increment_id</item> - <item name="label" xsi:type="string" translate="true">Shipment #</item> - </item> - </argument> - </filterInput> - <filterRange name="created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">created_at</item> - <item name="label" xsi:type="string" translate="true">Ship Date</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_view_shipment_grid.sales_order_view_shipment_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterInput name="order_increment_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">order_increment_id</item> - <item name="label" xsi:type="string" translate="true">Order #</item> - </item> - </argument> - </filterInput> - <filterRange name="order_created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">order_created_at</item> - <item name="label" xsi:type="string" translate="true">Order Date</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_view_shipment_grid.sales_order_view_shipment_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterDate name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - <filterDate name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> - </item> - </argument> - </filterDate> - </filterRange> - <filterInput name="shipping_name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_name</item> - <item name="label" xsi:type="string" translate="true">Ship-to Name</item> - </item> - </argument> - </filterInput> - <filterRange name="total_qty"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">total_qty</item> - <item name="label" xsi:type="string" translate="true">Total Quantity</item> - <item name="childDefaults" xsi:type="array"> - <item name="provider" xsi:type="string">sales_order_view_shipment_grid.sales_order_view_shipment_grid.listing_top.listing_filters</item> - </item> - </item> - </argument> - <filterInput name="from"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">from</item> - <item name="label" xsi:type="string" translate="true">From</item> - <item name="placeholder" xsi:type="string" translate="true">From</item> - </item> - </argument> - </filterInput> - <filterInput name="to"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">to</item> - <item name="label" xsi:type="string" translate="true">To</item> - <item name="placeholder" xsi:type="string" translate="true">To</item> - </item> - </argument> - </filterInput> - </filterRange> - <filterSelect name="order_status"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Sales\Ui\Component\Listing\Column\Status\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">order_status</item> - <item name="label" xsi:type="string" translate="true">Order Status</item> - </item> - </argument> - </filterSelect> <filterSelect name="store_id"> <argument name="optionsProvider" xsi:type="configurableObject"> <argument name="class" xsi:type="string">Magento\Store\Ui\Component\Listing\Column\Store\Options</argument> @@ -239,80 +107,11 @@ </item> </argument> </filterSelect> - <filterInput name="customer_name"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">customer_name</item> - <item name="label" xsi:type="string" translate="true">Customer Name</item> - </item> - </argument> - </filterInput> - <filterInput name="customer_email"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">customer_email</item> - <item name="label" xsi:type="string" translate="true">Customer Email</item> - </item> - </argument> - </filterInput> - <filterSelect name="customer_group_id"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Customer\Ui\Component\Listing\Column\Group\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">customer_group_id</item> - <item name="label" xsi:type="string" translate="true">Customer Group</item> - </item> - </argument> - </filterSelect> - <filterInput name="billing_address"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">billing_address</item> - <item name="label" xsi:type="string" translate="true">Billing Address</item> - </item> - </argument> - </filterInput> - <filterInput name="shipping_address"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_address</item> - <item name="label" xsi:type="string" translate="true">Shipping Address</item> - </item> - </argument> - </filterInput> - <filterSelect name="payment_method"> - <argument name="optionsProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Payment\Ui\Component\Listing\Column\Method\Options</argument> - </argument> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="caption" xsi:type="string" translate="true">Select...</item> - <item name="dataScope" xsi:type="string">payment_method</item> - <item name="label" xsi:type="string" translate="true">Payment Method</item> - </item> - </argument> - </filterSelect> - <filterInput name="shipping_information"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataScope" xsi:type="string">shipping_information</item> - <item name="label" xsi:type="string" translate="true">Shipping Information</item> - </item> - </argument> - </filterInput> </filters> <massaction name="listing_massaction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="selectProvider" xsi:type="string">sales_order_view_shipment_grid.sales_order_view_shipment_grid.sales_order_shipment_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> - <item name="actions" xsi:type="array"> - <item name="pdfshipments_order" xsi:type="array"> - </item> - </item> <item name="indexField" xsi:type="string">entity_id</item> </item> </argument> @@ -334,7 +133,6 @@ <item name="namespace" xsi:type="string">current.paging</item> </item> <item name="selectProvider" xsi:type="string">sales_order_view_shipment_grid.sales_order_view_shipment_grid.sales_order_shipment_columns.ids</item> - <item name="displayArea" xsi:type="string">bottom</item> </item> </argument> </paging> @@ -347,9 +145,14 @@ <item name="namespace" xsi:type="string">current</item> </item> <item name="childDefaults" xsi:type="array"> - <item name="controlVisibility" xsi:type="boolean">true</item> - <item name="actionField" xsi:type="string">actions</item> - <item name="clickAction" xsi:type="string">view</item> + <item name="fieldAction" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_view_shipment_grid.sales_order_view_shipment_grid.sales_order_shipment_columns.actions</item> + <item name="target" xsi:type="string">applyAction</item> + <item name="params" xsi:type="array"> + <item name="0" xsi:type="string">view</item> + <item name="1" xsi:type="string">${ $.$data.rowIndex }</item> + </item> + </item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">sales_order_view_shipment_grid.sales_order_view_shipment_grid.listing_top.bookmarks</item> <item name="root" xsi:type="string">columns.${ $.index }</item> @@ -358,228 +161,167 @@ </item> </item> </argument> - <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <selectionsColumn name="ids"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> - </item> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> <item name="indexField" xsi:type="string">entity_id</item> - <item name="controlVisibility" xsi:type="boolean">false</item> </item> </argument> - </column> + </selectionsColumn> <column name="increment_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> + <item name="filter" xsi:type="string">text</item> <item name="sorting" xsi:type="string">asc</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipment</item> </item> </argument> </column> <column name="created_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Ship Date</item> </item> </argument> </column> <column name="order_increment_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="sorting" xsi:type="string">asc</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">textRange</item> <item name="label" xsi:type="string" translate="true">Order</item> </item> </argument> </column> <column name="order_created_at"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">dateRange</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> <item name="dataType" xsi:type="string">date</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Order Date</item> </item> </argument> </column> <column name="shipping_name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">text</item> <item name="label" xsi:type="string" translate="true">Ship-to Name</item> </item> </argument> </column> <column name="total_qty"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="filter" xsi:type="string">textRange</item> <item name="label" xsi:type="string" translate="true">Total Quantity</item> </item> </argument> </column> - <column name="order_status" class="Magento\Sales\Ui\Component\Listing\Column\Status"> + <column name="order_status"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> - </item> + <item name="options" xsi:type="object">Magento\Sales\Ui\Component\Listing\Column\Status\Options</item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">select</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Order Status</item> </item> </argument> </column> <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> <item name="sortable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Purchased From</item> </item> </argument> </column> <column name="customer_name"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Customer Name</item> </item> </argument> </column> <column name="customer_email"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Email</item> </item> </argument> </column> - <column name="customer_group_id" class="Magento\Sales\Ui\Component\Listing\Column\CustomerGroup"> + <column name="customer_group_id"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> + <item name="options" xsi:type="object">Magento\Customer\Ui\Component\Listing\Column\Group\Options</item> <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + <item name="filter" xsi:type="string">select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Customer Group</item> </item> </argument> </column> <column name="billing_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Billing Address</item> </item> </argument> </column> <column name="shipping_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping Address</item> </item> </argument> </column> - <column name="payment_method" class="Magento\Sales\Ui\Component\Listing\Column\PaymentMethod"> + <column name="payment_method"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> + <item name="options" xsi:type="object">Magento\Payment\Ui\Component\Listing\Column\Method\Options</item> <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + <item name="filter" xsi:type="string">select</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> + <item name="dataType" xsi:type="string">select</item> <item name="label" xsi:type="string" translate="true">Payment Method</item> </item> </argument> </column> <column name="shipping_information"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> - </item> <item name="config" xsi:type="array"> + <item name="filter" xsi:type="string">text</item> <item name="visible" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">text</item> - <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Shipping Information</item> </item> </argument> </column> - <column name="actions" class="Magento\Sales\Ui\Component\Listing\Column\ViewAction"> + <actionsColumn name="actions" class="Magento\Sales\Ui\Component\Listing\Column\ViewAction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="draggable" xsi:type="boolean">false</item> - <item name="dataType" xsi:type="string">actions</item> <item name="indexField" xsi:type="string">entity_id</item> - <item name="align" xsi:type="string">left</item> - <item name="label" xsi:type="string" translate="true">Action</item> - <item name="data_type" xsi:type="string">actions</item> - <item name="filterable" xsi:type="boolean">false</item> - <item name="sortable" xsi:type="boolean">false</item> <item name="viewUrlPath" xsi:type="string">adminhtml/order_shipment/view</item> <item name="urlEntityParamName" xsi:type="string">shipment_id</item> </item> </argument> - </column> + </actionsColumn> </columns> </listing> diff --git a/app/code/Magento/Sales/view/adminhtml/web/order/create/form.js b/app/code/Magento/Sales/view/adminhtml/web/order/create/form.js index 6d88d084c36635f2c6d0f8f54e04dd491edd9730..1bcd3103237e7d2763d30036bb58bc2fcb73fa44 100644 --- a/app/code/Magento/Sales/view/adminhtml/web/order/create/form.js +++ b/app/code/Magento/Sales/view/adminhtml/web/order/create/form.js @@ -4,16 +4,18 @@ */ define([ - "jquery", - "Magento_Sales/order/create/scripts" -], function(jQuery){ - var $el = jQuery('#edit_form'), - config, - baseUrl, + 'jquery', + 'Magento_Sales/order/create/scripts' +], function (jQuery) { + 'use strict'; + + var $el = jQuery('#edit_form'), + config, + baseUrl, order, payment; - if( !$el.length || !$el.data('order-config') ){ + if (!$el.length || !$el.data('order-config')) { return; } @@ -22,7 +24,7 @@ define([ order = new AdminOrder(config); order.setLoadBaseUrl(baseUrl); - + payment = { switchMethod: order.switchPaymentMethod.bind(order) }; diff --git a/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js b/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js index da408242575901a134ea5af0fbd6cc7f550b4d1a..90f8b04c5c70b9d4d9fbb88d70e08bd307c83d04 100644 --- a/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js +++ b/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js @@ -4,1367 +4,1385 @@ */ define([ "jquery", + 'Magento_Ui/js/modal/confirm', + 'Magento_Ui/js/modal/alert', "mage/translate", "prototype", - "Magento_Catalog/catalog/product/composite/configure" -], function(jQuery){ - -window.AdminOrder = new Class.create(); - -AdminOrder.prototype = { - initialize : function(data){ - if(!data) data = {}; - this.loadBaseUrl = false; - this.customerId = data.customer_id ? data.customer_id : false; - this.storeId = data.store_id ? data.store_id : false; - this.currencyId = false; - this.currencySymbol = data.currency_symbol ? data.currency_symbol : ''; - this.addresses = data.addresses ? data.addresses : $H({}); - this.shippingAsBilling = data.shippingAsBilling ? data.shippingAsBilling : false; - this.gridProducts = $H({}); - this.gridProductsGift = $H({}); - this.billingAddressContainer = ''; - this.shippingAddressContainer= ''; - this.isShippingMethodReseted = data.shipping_method_reseted ? data.shipping_method_reseted : false; - this.overlayData = $H({}); - this.giftMessageDataChanged = false; - this.productConfigureAddFields = {}; - this.productPriceBase = {}; - this.collectElementsValue = true; - this.isOnlyVirtualProduct = false; - this.excludedPaymentMethods = []; - this.summarizePrice = true; - Event.observe(window, 'load', (function(){ - this.dataArea = new OrderFormArea('data', $(this.getAreaId('data')), this); - this.itemsArea = Object.extend(new OrderFormArea('items', $(this.getAreaId('items')), this), { - addControlButton: function(button){ - var controlButtonArea = $(this.node).select('.actions')[0]; - if (typeof controlButtonArea != 'undefined') { - var buttons = controlButtonArea.childElements(); - for (var i = 0; i < buttons.length; i++) { - if (buttons[i].innerHTML.include(button.label)) { - return ; + "Magento_Catalog/catalog/product/composite/configure", + 'Magento_Ui/js/lib/view/utils/async' +], function(jQuery, confirm, alert){ + + window.AdminOrder = new Class.create(); + + AdminOrder.prototype = { + initialize : function(data){ + if(!data) data = {}; + this.loadBaseUrl = false; + this.customerId = data.customer_id ? data.customer_id : false; + this.storeId = data.store_id ? data.store_id : false; + this.currencyId = false; + this.currencySymbol = data.currency_symbol ? data.currency_symbol : ''; + this.addresses = data.addresses ? data.addresses : $H({}); + this.shippingAsBilling = data.shippingAsBilling ? data.shippingAsBilling : false; + this.gridProducts = $H({}); + this.gridProductsGift = $H({}); + this.billingAddressContainer = ''; + this.shippingAddressContainer= ''; + this.isShippingMethodReseted = data.shipping_method_reseted ? data.shipping_method_reseted : false; + this.overlayData = $H({}); + this.giftMessageDataChanged = false; + this.productConfigureAddFields = {}; + this.productPriceBase = {}; + this.collectElementsValue = true; + this.isOnlyVirtualProduct = false; + this.excludedPaymentMethods = []; + this.summarizePrice = true; + jQuery.async('#order-items', (function(){ + this.dataArea = new OrderFormArea('data', $(this.getAreaId('data')), this); + this.itemsArea = Object.extend(new OrderFormArea('items', $(this.getAreaId('items')), this), { + addControlButton: function(button){ + var controlButtonArea = $(this.node).select('.actions')[0]; + if (typeof controlButtonArea != 'undefined') { + var buttons = controlButtonArea.childElements(); + for (var i = 0; i < buttons.length; i++) { + if (buttons[i].innerHTML.include(button.label)) { + return ; + } } + button.insertIn(controlButtonArea, 'top'); } - button.insertIn(controlButtonArea, 'top'); } - } - }); - - var searchButton = new ControlButton(jQuery.mage.__('Add Products')), - searchAreaId = this.getAreaId('search'); - searchButton.onClick = function() { - $(searchAreaId).show(); - var el = this; - window.setTimeout(function () { - el.remove(); - }, 10); - }; + }); - this.dataArea.onLoad = this.dataArea.onLoad.wrap(function(proceed) { - proceed(); - this._parent.itemsArea.setNode($(this._parent.getAreaId('items'))); - this._parent.itemsArea.onLoad(); - }); + var searchButton = new ControlButton(jQuery.mage.__('Add Products')), + searchAreaId = this.getAreaId('search'); + searchButton.onClick = function() { + $(searchAreaId).show(); + var el = this; + window.setTimeout(function () { + el.remove(); + }, 10); + }; + + this.dataArea.onLoad = this.dataArea.onLoad.wrap(function(proceed) { + proceed(); + this._parent.itemsArea.setNode($(this._parent.getAreaId('items'))); + this._parent.itemsArea.onLoad(); + }); - this.itemsArea.onLoad = this.itemsArea.onLoad.wrap(function(proceed) { - proceed(); - if ($(searchAreaId) && !$(searchAreaId).visible()) { - this.addControlButton(searchButton); - } - }); - this.areasLoaded(); - this.itemsArea.onLoad(); - }).bind(this)); - - jQuery('#edit_form') - .on('submitOrder', function(){ - jQuery(this).trigger('realOrder'); - }) - .on('realOrder', this._realSubmit.bind(this)); - - }, - - areasLoaded: function(){ - }, - - itemsLoaded: function(){ - }, - - dataLoaded: function(){ - this.dataShow(); - }, - - setLoadBaseUrl : function(url){ - this.loadBaseUrl = url; - }, - - setAddresses : function(addresses){ - this.addresses = addresses; - }, - - addExcludedPaymentMethod : function(method){ - this.excludedPaymentMethods.push(method); - }, - - setCustomerId : function(id){ - this.customerId = id; - this.loadArea('header', true); - $(this.getAreaId('header')).callback = 'setCustomerAfter'; - $('back_order_top_button').hide(); - $('reset_order_top_button').show(); - }, - - setCustomerAfter : function () { - this.customerSelectorHide(); - if (this.storeId) { - $(this.getAreaId('data')).callback = 'dataLoaded'; + this.itemsArea.onLoad = this.itemsArea.onLoad.wrap(function(proceed) { + proceed(); + if ($(searchAreaId) && !$(searchAreaId).visible()) { + this.addControlButton(searchButton); + } + }); + this.areasLoaded(); + this.itemsArea.onLoad(); + }).bind(this)); + + jQuery('#edit_form') + .on('submitOrder', function(){ + jQuery(this).trigger('realOrder'); + }) + .on('realOrder', this._realSubmit.bind(this)); + + }, + + areasLoaded: function(){ + }, + + itemsLoaded: function(){ + }, + + dataLoaded: function(){ + this.dataShow(); + }, + + setLoadBaseUrl : function(url){ + this.loadBaseUrl = url; + }, + + setAddresses : function(addresses){ + this.addresses = addresses; + }, + + addExcludedPaymentMethod : function(method){ + this.excludedPaymentMethods.push(method); + }, + + setCustomerId : function(id){ + this.customerId = id; + this.loadArea('header', true); + $(this.getAreaId('header')).callback = 'setCustomerAfter'; + $('back_order_top_button').hide(); + $('reset_order_top_button').show(); + }, + + setCustomerAfter : function () { + this.customerSelectorHide(); + if (this.storeId) { + $(this.getAreaId('data')).callback = 'dataLoaded'; + this.loadArea(['data'], true); + } + else { + this.storeSelectorShow(); + } + }, + + setStoreId : function(id){ + this.storeId = id; + this.storeSelectorHide(); + this.sidebarShow(); + //this.loadArea(['header', 'sidebar','data'], true); + this.dataShow(); + this.loadArea(['header', 'data'], true); + }, + + setCurrencyId : function(id){ + this.currencyId = id; + //this.loadArea(['sidebar', 'data'], true); this.loadArea(['data'], true); - } - else { - this.storeSelectorShow(); - } - }, - - setStoreId : function(id){ - this.storeId = id; - this.storeSelectorHide(); - this.sidebarShow(); - //this.loadArea(['header', 'sidebar','data'], true); - this.dataShow(); - this.loadArea(['header', 'data'], true); - }, - - setCurrencyId : function(id){ - this.currencyId = id; - //this.loadArea(['sidebar', 'data'], true); - this.loadArea(['data'], true); - }, - - setCurrencySymbol : function(symbol){ - this.currencySymbol = symbol; - }, - - selectAddress : function(el, container){ - id = el.value; - if (id.length == 0) { - id = '0'; - } - if(this.addresses[id]){ - this.fillAddressFields(container, this.addresses[id]); - } - else{ - this.fillAddressFields(container, {}); - } + }, - var data = this.serializeData(container); - data[el.name] = id; - if(this.isShippingField(container) && !this.isShippingMethodReseted){ - this.resetShippingMethod(data); - } - else{ - this.saveData(data); - } - }, + setCurrencySymbol : function(symbol){ + this.currencySymbol = symbol; + }, - isShippingField : function(fieldId){ - if(this.shippingAsBilling){ - return fieldId.include('billing'); - } - return fieldId.include('shipping'); - }, + selectAddress : function(el, container){ + id = el.value; + if (id.length == 0) { + id = '0'; + } + if(this.addresses[id]){ + this.fillAddressFields(container, this.addresses[id]); + } + else{ + this.fillAddressFields(container, {}); + } - isBillingField : function(fieldId){ - return fieldId.include('billing'); - }, + var data = this.serializeData(container); + data[el.name] = id; + if(this.isShippingField(container) && !this.isShippingMethodReseted){ + this.resetShippingMethod(data); + } + else{ + this.saveData(data); + } + }, - bindAddressFields : function(container) { - var fields = $(container).select('input', 'select', 'textarea'); - for(var i=0;i<fields.length;i++){ - Event.observe(fields[i], 'change', this.changeAddressField.bind(this)); - } - }, + isShippingField : function(fieldId){ + if(this.shippingAsBilling){ + return fieldId.include('billing'); + } + return fieldId.include('shipping'); + }, - changeAddressField : function(event){ - var field = Event.element(event); - var re = /[^\[]*\[([^\]]*)_address\]\[([^\]]*)\](\[(\d)\])?/; - var matchRes = field.name.match(re); + isBillingField : function(fieldId){ + return fieldId.include('billing'); + }, - if (!matchRes) { - return; - } + bindAddressFields : function(container) { + var fields = $(container).select('input', 'select', 'textarea'); + for(var i=0;i<fields.length;i++){ + Event.observe(fields[i], 'change', this.changeAddressField.bind(this)); + } + }, - var type = matchRes[1]; - var name = matchRes[2]; - var data; + changeAddressField : function(event){ + var field = Event.element(event); + var re = /[^\[]*\[([^\]]*)_address\]\[([^\]]*)\](\[(\d)\])?/; + var matchRes = field.name.match(re); - if(this.isBillingField(field.id)){ - data = this.serializeData(this.billingAddressContainer) - } - else{ - data = this.serializeData(this.shippingAddressContainer) - } - data = data.toObject(); + if (!matchRes) { + return; + } - if( (type == 'billing' && this.shippingAsBilling) - || (type == 'shipping' && !this.shippingAsBilling) ) { - data['reset_shipping'] = true; - } + var type = matchRes[1]; + var name = matchRes[2]; + var data; - data['order['+type+'_address][customer_address_id]'] = $('order-'+type+'_address_customer_address_id').value; + if(this.isBillingField(field.id)){ + data = this.serializeData(this.billingAddressContainer) + } + else{ + data = this.serializeData(this.shippingAddressContainer) + } + data = data.toObject(); - if (data['reset_shipping']) { - this.resetShippingMethod(data); - } else { - this.saveData(data); - if (name == 'country_id' || name == 'customer_address_id') { - this.loadArea(['shipping_method', 'billing_method', 'totals', 'items'], true, data); + if( (type == 'billing' && this.shippingAsBilling) + || (type == 'shipping' && !this.shippingAsBilling) ) { + data['reset_shipping'] = true; } - // added for reloading of default sender and default recipient for giftmessages - //this.loadArea(['giftmessage'], true, data); - } - }, - - fillAddressFields : function(container, data){ - var regionIdElem = false; - var regionIdElemValue = false; - - var fields = $(container).select('input', 'select', 'textarea'); - var re = /[^\[]*\[[^\]]*\]\[([^\]]*)\](\[(\d)\])?/; - for(var i=0;i<fields.length;i++){ - // skip input type file @Security error code: 1000 - if (fields[i].tagName.toLowerCase() == 'input' && fields[i].type.toLowerCase() == 'file') { - continue; - } - var matchRes = fields[i].name.match(re); - if (matchRes === null) { - continue; - } - var name = matchRes[1]; - var index = matchRes[3]; - - if (index){ - // multiply line - if (data[name]){ - var values = data[name].split("\n"); - fields[i].value = values[index] ? values[index] : ''; + + data['order['+type+'_address][customer_address_id]'] = $('order-'+type+'_address_customer_address_id').value; + + if (data['reset_shipping']) { + this.resetShippingMethod(data); + } else { + this.saveData(data); + if (name == 'country_id' || name == 'customer_address_id') { + this.loadArea(['shipping_method', 'billing_method', 'totals', 'items'], true, data); + } + // added for reloading of default sender and default recipient for giftmessages + //this.loadArea(['giftmessage'], true, data); + } + }, + + fillAddressFields : function(container, data){ + var regionIdElem = false; + var regionIdElemValue = false; + + var fields = $(container).select('input', 'select', 'textarea'); + var re = /[^\[]*\[[^\]]*\]\[([^\]]*)\](\[(\d)\])?/; + for(var i=0;i<fields.length;i++){ + // skip input type file @Security error code: 1000 + if (fields[i].tagName.toLowerCase() == 'input' && fields[i].type.toLowerCase() == 'file') { + continue; + } + var matchRes = fields[i].name.match(re); + if (matchRes === null) { + continue; + } + var name = matchRes[1]; + var index = matchRes[3]; + + if (index){ + // multiply line + if (data[name]){ + var values = data[name].split("\n"); + fields[i].value = values[index] ? values[index] : ''; + } else { + fields[i].value = ''; + } + } else if (fields[i].tagName.toLowerCase() == 'select' && fields[i].multiple) { + // multiselect + if (data[name]) { + values = ['']; + if (Object.isString(data[name])) { + values = data[name].split(','); + } else if (Object.isArray(data[name])) { + values = data[name]; + } + fields[i].setValue(values); + } } else { - fields[i].value = ''; + fields[i].setValue(data[name] ? data[name] : ''); } - } else if (fields[i].tagName.toLowerCase() == 'select' && fields[i].multiple) { - // multiselect - if (data[name]) { - values = ['']; - if (Object.isString(data[name])) { - values = data[name].split(','); - } else if (Object.isArray(data[name])) { - values = data[name]; + + if (fields[i].changeUpdater) fields[i].changeUpdater(); + if (name == 'region' && data['region_id'] && !data['region']){ + fields[i].value = data['region_id']; + } + } + }, + + disableShippingAddress : function(flag) { + this.shippingAsBilling = flag; + if ($('order-shipping_address_customer_address_id')) { + $('order-shipping_address_customer_address_id').disabled = flag; + } + if ($(this.shippingAddressContainer)) { + var dataFields = $(this.shippingAddressContainer).select('input', 'select', 'textarea'); + for (var i = 0; i < dataFields.length; i++) { + dataFields[i].disabled = flag; + + if(this.isOnlyVirtualProduct) { + dataFields[i].setValue(''); } - fields[i].setValue(values); } + var buttons = $(this.shippingAddressContainer).select('button'); + // Add corresponding class to buttons while disabling them + for (i = 0; i < buttons.length; i++) { + buttons[i].disabled = flag; + if (flag) { + buttons[i].addClassName('disabled'); + } else { + buttons[i].removeClassName('disabled'); + } + } + } + }, + + setShippingAsBilling : function(flag){ + var data; + var areasToLoad = ['billing_method', 'shipping_address', 'totals', 'giftmessage']; + this.disableShippingAddress(flag); + if(flag){ + data = this.serializeData(this.billingAddressContainer); } else { - fields[i].setValue(data[name] ? data[name] : ''); + data = this.serializeData(this.shippingAddressContainer); + areasToLoad.push('shipping_method'); } + data = data.toObject(); + data['shipping_as_billing'] = flag ? 1 : 0; + data['reset_shipping'] = 1; + this.loadArea( areasToLoad, true, data); + }, + + resetShippingMethod : function(data){ + var areasToLoad = ['billing_method', 'shipping_address', 'totals', 'giftmessage', 'items']; + if(!this.isOnlyVirtualProduct) { + areasToLoad.push('shipping_method'); + areasToLoad.push('shipping_address'); + } + + data['reset_shipping'] = 1; + this.isShippingMethodReseted = true; + this.loadArea(areasToLoad, true, data); + }, + + loadShippingRates : function(){ + this.isShippingMethodReseted = false; + this.loadArea(['shipping_method', 'totals'], true, {collect_shipping_rates: 1}); + }, + + setShippingMethod : function(method){ + var data = {}; + data['order[shipping_method]'] = method; + this.loadArea(['shipping_method', 'totals', 'billing_method'], true, data); + }, - if (fields[i].changeUpdater) fields[i].changeUpdater(); - if (name == 'region' && data['region_id'] && !data['region']){ - fields[i].value = data['region_id']; + switchPaymentMethod : function(method){ + jQuery('#edit_form').trigger('changePaymentMethod', [method]); + this.setPaymentMethod(method); + var data = {}; + data['order[payment_method]'] = method; + this.loadArea(['card_validation'], true, data); + }, + + setPaymentMethod : function(method){ + if (this.paymentMethod && $('payment_form_'+this.paymentMethod)) { + var form = 'payment_form_'+this.paymentMethod; + [form + '_before', form, form + '_after'].each(function(el) { + var block = $(el); + if (block) { + block.hide(); + block.select('input', 'select', 'textarea').each(function(field) { + field.disabled = true; + }); + } + }); } - } - }, - disableShippingAddress : function(flag) { - this.shippingAsBilling = flag; - if ($('order-shipping_address_customer_address_id')) { - $('order-shipping_address_customer_address_id').disabled = flag; - } - if ($(this.shippingAddressContainer)) { - var dataFields = $(this.shippingAddressContainer).select('input', 'select', 'textarea'); - for (var i = 0; i < dataFields.length; i++) { - dataFields[i].disabled = flag; + if(!this.paymentMethod || method){ + $('order-billing_method_form').select('input', 'select', 'textarea').each(function(elem){ + if(elem.type != 'radio') elem.disabled = true; + }) + } - if(this.isOnlyVirtualProduct) { - dataFields[i].setValue(''); - } + if ($('payment_form_'+method)){ + jQuery('#' + this.getAreaId('billing_method')).trigger('contentUpdated'); + this.paymentMethod = method; + var form = 'payment_form_'+method; + [form + '_before', form, form + '_after'].each(function(el) { + var block = $(el); + if (block) { + block.show(); + block.select('input', 'select', 'textarea').each(function(field) { + field.disabled = false; + if (!el.include('_before') && !el.include('_after') && !field.bindChange) { + field.bindChange = true; + field.paymentContainer = form; + field.method = method; + field.observe('change', this.changePaymentData.bind(this)) + } + },this); + } + },this); } - var buttons = $(this.shippingAddressContainer).select('button'); - // Add corresponding class to buttons while disabling them - for (i = 0; i < buttons.length; i++) { - buttons[i].disabled = flag; - if (flag) { - buttons[i].addClassName('disabled'); + }, + + changePaymentData : function(event){ + var elem = Event.element(event); + if(elem && elem.method){ + var data = this.getPaymentData(elem.method); + if (data) { + this.loadArea(['card_validation'], true, data); } else { - buttons[i].removeClassName('disabled'); + return; } } - } - }, - - setShippingAsBilling : function(flag){ - var data; - var areasToLoad = ['billing_method', 'shipping_address', 'totals', 'giftmessage']; - this.disableShippingAddress(flag); - if(flag){ - data = this.serializeData(this.billingAddressContainer); - } else { - data = this.serializeData(this.shippingAddressContainer); - areasToLoad.push('shipping_method'); - } - data = data.toObject(); - data['shipping_as_billing'] = flag ? 1 : 0; - data['reset_shipping'] = 1; - this.loadArea( areasToLoad, true, data); - }, - - resetShippingMethod : function(data){ - var areasToLoad = ['billing_method', 'shipping_address', 'totals', 'giftmessage', 'items']; - if(!this.isOnlyVirtualProduct) { - areasToLoad.push('shipping_method'); - areasToLoad.push('shipping_address'); - } + }, - data['reset_shipping'] = 1; - this.isShippingMethodReseted = true; - this.loadArea(areasToLoad, true, data); - }, - - loadShippingRates : function(){ - this.isShippingMethodReseted = false; - this.loadArea(['shipping_method', 'totals'], true, {collect_shipping_rates: 1}); - }, - - setShippingMethod : function(method){ - var data = {}; - data['order[shipping_method]'] = method; - this.loadArea(['shipping_method', 'totals', 'billing_method'], true, data); - }, - - switchPaymentMethod : function(method){ - jQuery('#edit_form').trigger('changePaymentMethod', [method]); - this.setPaymentMethod(method); - var data = {}; - data['order[payment_method]'] = method; - this.loadArea(['card_validation'], true, data); - }, - - setPaymentMethod : function(method){ - if (this.paymentMethod && $('payment_form_'+this.paymentMethod)) { - var form = 'payment_form_'+this.paymentMethod; - [form + '_before', form, form + '_after'].each(function(el) { - var block = $(el); - if (block) { - block.hide(); - block.select('input', 'select', 'textarea').each(function(field) { - field.disabled = true; - }); - } - }); - } - - if(!this.paymentMethod || method){ - $('order-billing_method_form').select('input', 'select', 'textarea').each(function(elem){ - if(elem.type != 'radio') elem.disabled = true; - }) - } - - if ($('payment_form_'+method)){ - jQuery('#' + this.getAreaId('billing_method')).trigger('contentUpdated'); - this.paymentMethod = method; - var form = 'payment_form_'+method; - [form + '_before', form, form + '_after'].each(function(el) { - var block = $(el); - if (block) { - block.show(); - block.select('input', 'select', 'textarea').each(function(field) { - field.disabled = false; - if (!el.include('_before') && !el.include('_after') && !field.bindChange) { - field.bindChange = true; - field.paymentContainer = form; - field.method = method; - field.observe('change', this.changePaymentData.bind(this)) - } - },this); + getPaymentData : function(currentMethod){ + if (typeof(currentMethod) == 'undefined') { + if (this.paymentMethod) { + currentMethod = this.paymentMethod; + } else { + return false; } - },this); - } - }, - - changePaymentData : function(event){ - var elem = Event.element(event); - if(elem && elem.method){ - var data = this.getPaymentData(elem.method); - if (data) { - this.loadArea(['card_validation'], true, data); - } else { - return; } - } - }, - - getPaymentData : function(currentMethod){ - if (typeof(currentMethod) == 'undefined') { - if (this.paymentMethod) { - currentMethod = this.paymentMethod; - } else { + if (this.isPaymentValidationAvailable() == false) { return false; } - } - if (this.isPaymentValidationAvailable() == false) { - return false; - } - var data = {}; - var fields = $('payment_form_' + currentMethod).select('input', 'select'); - for(var i=0;i<fields.length;i++){ - data[fields[i].name] = fields[i].getValue(); - } - if ((typeof data['payment[cc_type]']) != 'undefined' && (!data['payment[cc_type]'] || !data['payment[cc_number]'])) { - return false; - } - return data; - }, - - applyCoupon : function(code){ - this.loadArea(['items', 'shipping_method', 'totals', 'billing_method'], true, {'order[coupon][code]':code, reset_shipping: true}); - this.orderItemChanged = false; - }, - - addProduct : function(id){ - this.loadArea(['items', 'shipping_method', 'totals', 'billing_method'], true, {add_product:id, reset_shipping: true}); - }, - - removeQuoteItem : function(id){ - this.loadArea(['items', 'shipping_method', 'totals', 'billing_method'], true, - {remove_item:id, from:'quote',reset_shipping: true}); - }, - - moveQuoteItem : function(id, to){ - this.loadArea(['sidebar_'+to, 'items', 'shipping_method', 'totals', 'billing_method'], this.getAreaId('items'), - {move_item:id, to:to, reset_shipping: true}); - }, - - productGridShow : function(buttonElement){ - this.productGridShowButton = buttonElement; - Element.hide(buttonElement); - this.showArea('search'); - }, - - productGridRowInit : function(grid, row){ - var checkbox = $(row).select('.checkbox')[0]; - var inputs = $(row).select('.input-text'); - if (checkbox && inputs.length > 0) { - checkbox.inputElements = inputs; - for (var i = 0; i < inputs.length; i++) { - var input = inputs[i]; - input.checkboxElement = checkbox; - - var product = this.gridProducts.get(checkbox.value); - if (product) { - var defaultValue = product[input.name]; - if (defaultValue) { - if (input.name == 'giftmessage') { - input.checked = true; - } else { - input.value = defaultValue; + var data = {}; + var fields = $('payment_form_' + currentMethod).select('input', 'select'); + for(var i=0;i<fields.length;i++){ + data[fields[i].name] = fields[i].getValue(); + } + if ((typeof data['payment[cc_type]']) != 'undefined' && (!data['payment[cc_type]'] || !data['payment[cc_number]'])) { + return false; + } + return data; + }, + + applyCoupon : function(code){ + this.loadArea(['items', 'shipping_method', 'totals', 'billing_method'], true, {'order[coupon][code]':code, reset_shipping: true}); + this.orderItemChanged = false; + }, + + addProduct : function(id){ + this.loadArea(['items', 'shipping_method', 'totals', 'billing_method'], true, {add_product:id, reset_shipping: true}); + }, + + removeQuoteItem : function(id){ + this.loadArea(['items', 'shipping_method', 'totals', 'billing_method'], true, + {remove_item:id, from:'quote',reset_shipping: true}); + }, + + moveQuoteItem : function(id, to){ + this.loadArea(['sidebar_'+to, 'items', 'shipping_method', 'totals', 'billing_method'], this.getAreaId('items'), + {move_item:id, to:to, reset_shipping: true}); + }, + + productGridShow : function(buttonElement){ + this.productGridShowButton = buttonElement; + Element.hide(buttonElement); + this.showArea('search'); + }, + + productGridRowInit : function(grid, row){ + var checkbox = $(row).select('.checkbox')[0]; + var inputs = $(row).select('.input-text'); + if (checkbox && inputs.length > 0) { + checkbox.inputElements = inputs; + for (var i = 0; i < inputs.length; i++) { + var input = inputs[i]; + input.checkboxElement = checkbox; + + var product = this.gridProducts.get(checkbox.value); + if (product) { + var defaultValue = product[input.name]; + if (defaultValue) { + if (input.name == 'giftmessage') { + input.checked = true; + } else { + input.value = defaultValue; + } } } - } - input.disabled = !checkbox.checked || input.hasClassName('input-inactive'); + input.disabled = !checkbox.checked || input.hasClassName('input-inactive'); - Event.observe(input,'keyup', this.productGridRowInputChange.bind(this)); - Event.observe(input,'change',this.productGridRowInputChange.bind(this)); + Event.observe(input,'keyup', this.productGridRowInputChange.bind(this)); + Event.observe(input,'change',this.productGridRowInputChange.bind(this)); + } } - } - }, - - productGridRowInputChange : function(event){ - var element = Event.element(event); - if (element && element.checkboxElement && element.checkboxElement.checked){ - if (element.name!='giftmessage' || element.checked) { - this.gridProducts.get(element.checkboxElement.value)[element.name] = element.value; - } else if (element.name=='giftmessage' && this.gridProducts.get(element.checkboxElement.value)[element.name]) { - delete(this.gridProducts.get(element.checkboxElement.value)[element.name]); + }, + + productGridRowInputChange : function(event){ + var element = Event.element(event); + if (element && element.checkboxElement && element.checkboxElement.checked){ + if (element.name!='giftmessage' || element.checked) { + this.gridProducts.get(element.checkboxElement.value)[element.name] = element.value; + } else if (element.name=='giftmessage' && this.gridProducts.get(element.checkboxElement.value)[element.name]) { + delete(this.gridProducts.get(element.checkboxElement.value)[element.name]); + } } - } - }, - - productGridRowClick : function(grid, event){ - var trElement = Event.findElement(event, 'tr'); - var qtyElement = trElement.select('input[name="qty"]')[0]; - var eventElement = Event.element(event); - var isInputCheckbox = eventElement.tagName == 'INPUT' && eventElement.type == 'checkbox'; - var isInputQty = eventElement.tagName == 'INPUT' && eventElement.name == 'qty'; - if (trElement && !isInputQty) { - var checkbox = Element.select(trElement, 'input[type="checkbox"]')[0]; - var confLink = Element.select(trElement, 'a')[0]; - var priceColl = Element.select(trElement, '.price')[0]; - if (checkbox) { - // processing non composite product - if (confLink.readAttribute('disabled')) { - var checked = isInputCheckbox ? checkbox.checked : !checkbox.checked; - grid.setCheckboxChecked(checkbox, checked); - // processing composite product - } else if (isInputCheckbox && !checkbox.checked) { - grid.setCheckboxChecked(checkbox, false); - // processing composite product - } else if (!isInputCheckbox || (isInputCheckbox && checkbox.checked)) { - var listType = confLink.readAttribute('list_type'); - var productId = confLink.readAttribute('product_id'); - if (typeof this.productPriceBase[productId] == 'undefined') { - var priceBase = priceColl.innerHTML.match(/.*?([\d,]+\.?\d*)/); - if (!priceBase) { - this.productPriceBase[productId] = 0; - } else { - this.productPriceBase[productId] = parseFloat(priceBase[1].replace(/,/g,'')); + }, + + productGridRowClick : function(grid, event){ + var trElement = Event.findElement(event, 'tr'); + var qtyElement = trElement.select('input[name="qty"]')[0]; + var eventElement = Event.element(event); + var isInputCheckbox = eventElement.tagName == 'INPUT' && eventElement.type == 'checkbox'; + var isInputQty = eventElement.tagName == 'INPUT' && eventElement.name == 'qty'; + if (trElement && !isInputQty) { + var checkbox = Element.select(trElement, 'input[type="checkbox"]')[0]; + var confLink = Element.select(trElement, 'a')[0]; + var priceColl = Element.select(trElement, '.price')[0]; + if (checkbox) { + // processing non composite product + if (confLink.readAttribute('disabled')) { + var checked = isInputCheckbox ? checkbox.checked : !checkbox.checked; + grid.setCheckboxChecked(checkbox, checked); + // processing composite product + } else if (isInputCheckbox && !checkbox.checked) { + grid.setCheckboxChecked(checkbox, false); + // processing composite product + } else if (!isInputCheckbox || (isInputCheckbox && checkbox.checked)) { + var listType = confLink.readAttribute('list_type'); + var productId = confLink.readAttribute('product_id'); + if (typeof this.productPriceBase[productId] == 'undefined') { + var priceBase = priceColl.innerHTML.match(/.*?([\d,]+\.?\d*)/); + if (!priceBase) { + this.productPriceBase[productId] = 0; + } else { + this.productPriceBase[productId] = parseFloat(priceBase[1].replace(/,/g,'')); + } } + productConfigure.setConfirmCallback(listType, function() { + // sync qty of popup and qty of grid + var confirmedCurrentQty = productConfigure.getCurrentConfirmedQtyElement(); + if (qtyElement && confirmedCurrentQty && !isNaN(confirmedCurrentQty.value)) { + qtyElement.value = confirmedCurrentQty.value; + } + // calc and set product price + var productPrice = this._calcProductPrice(); + if (this._isSummarizePrice()) { + productPrice += this.productPriceBase[productId]; + } + productPrice = parseFloat(productPrice); + priceColl.innerHTML = this.currencySymbol + productPrice.toFixed(2); + // and set checkbox checked + grid.setCheckboxChecked(checkbox, true); + }.bind(this)); + productConfigure.setCancelCallback(listType, function() { + if (!$(productConfigure.confirmedCurrentId) || !$(productConfigure.confirmedCurrentId).innerHTML) { + grid.setCheckboxChecked(checkbox, false); + } + }); + productConfigure.setShowWindowCallback(listType, function() { + // sync qty of grid and qty of popup + var formCurrentQty = productConfigure.getCurrentFormQtyElement(); + if (formCurrentQty && qtyElement && !isNaN(qtyElement.value)) { + formCurrentQty.value = qtyElement.value; + } + }.bind(this)); + productConfigure.showItemConfiguration(listType, productId); } - productConfigure.setConfirmCallback(listType, function() { - // sync qty of popup and qty of grid - var confirmedCurrentQty = productConfigure.getCurrentConfirmedQtyElement(); - if (qtyElement && confirmedCurrentQty && !isNaN(confirmedCurrentQty.value)) { - qtyElement.value = confirmedCurrentQty.value; - } - // calc and set product price - var productPrice = this._calcProductPrice(); - if (this._isSummarizePrice()) { - productPrice += this.productPriceBase[productId]; - } - productPrice = parseFloat(productPrice); - priceColl.innerHTML = this.currencySymbol + productPrice.toFixed(2); - // and set checkbox checked - grid.setCheckboxChecked(checkbox, true); - }.bind(this)); - productConfigure.setCancelCallback(listType, function() { - if (!$(productConfigure.confirmedCurrentId) || !$(productConfigure.confirmedCurrentId).innerHTML) { - grid.setCheckboxChecked(checkbox, false); - } - }); - productConfigure.setShowWindowCallback(listType, function() { - // sync qty of grid and qty of popup - var formCurrentQty = productConfigure.getCurrentFormQtyElement(); - if (formCurrentQty && qtyElement && !isNaN(qtyElement.value)) { - formCurrentQty.value = qtyElement.value; - } - }.bind(this)); - productConfigure.showItemConfiguration(listType, productId); } } - } - }, - - /** - * Is need to summarize price - */ - _isSummarizePrice: function(elm) { - if (elm && elm.hasAttribute('summarizePrice')) { - this.summarizePrice = parseInt(elm.readAttribute('summarizePrice')); - } - return this.summarizePrice; - }, - /** - * Calc product price through its options - */ - _calcProductPrice: function () { - var productPrice = 0; - var getPriceFields = function (elms) { + }, + + /** + * Is need to summarize price + */ + _isSummarizePrice: function(elm) { + if (elm && elm.hasAttribute('summarizePrice')) { + this.summarizePrice = parseInt(elm.readAttribute('summarizePrice')); + } + return this.summarizePrice; + }, + /** + * Calc product price through its options + */ + _calcProductPrice: function () { var productPrice = 0; - var getPrice = function (elm) { - var optQty = 1; - if (elm.hasAttribute('qtyId')) { - if (!$(elm.getAttribute('qtyId')).value) { - return 0; - } else { - optQty = parseFloat($(elm.getAttribute('qtyId')).value); + var getPriceFields = function (elms) { + var productPrice = 0; + var getPrice = function (elm) { + var optQty = 1; + if (elm.hasAttribute('qtyId')) { + if (!$(elm.getAttribute('qtyId')).value) { + return 0; + } else { + optQty = parseFloat($(elm.getAttribute('qtyId')).value); + } } - } - if (elm.hasAttribute('price') && !elm.disabled) { - return parseFloat(elm.readAttribute('price')) * optQty; - } - return 0; - }; - for(var i = 0; i < elms.length; i++) { - if (elms[i].type == 'select-one' || elms[i].type == 'select-multiple') { - for(var ii = 0; ii < elms[i].options.length; ii++) { - if (elms[i].options[ii].selected) { - if (this._isSummarizePrice(elms[i].options[ii])) { - productPrice += getPrice(elms[i].options[ii]); - } else { - productPrice = getPrice(elms[i].options[ii]); + if (elm.hasAttribute('price') && !elm.disabled) { + return parseFloat(elm.readAttribute('price')) * optQty; + } + return 0; + }; + for(var i = 0; i < elms.length; i++) { + if (elms[i].type == 'select-one' || elms[i].type == 'select-multiple') { + for(var ii = 0; ii < elms[i].options.length; ii++) { + if (elms[i].options[ii].selected) { + if (this._isSummarizePrice(elms[i].options[ii])) { + productPrice += getPrice(elms[i].options[ii]); + } else { + productPrice = getPrice(elms[i].options[ii]); + } } } } - } - else if (((elms[i].type == 'checkbox' || elms[i].type == 'radio') && elms[i].checked) + else if (((elms[i].type == 'checkbox' || elms[i].type == 'radio') && elms[i].checked) || ((elms[i].type == 'file' || elms[i].type == 'text' || elms[i].type == 'textarea' || elms[i].type == 'hidden') - && Form.Element.getValue(elms[i])) - ) { - if (this._isSummarizePrice(elms[i])) { - productPrice += getPrice(elms[i]); - } else { - productPrice = getPrice(elms[i]); + && Form.Element.getValue(elms[i])) + ) { + if (this._isSummarizePrice(elms[i])) { + productPrice += getPrice(elms[i]); + } else { + productPrice = getPrice(elms[i]); + } } } - } + return productPrice; + }.bind(this); + productPrice += getPriceFields($(productConfigure.confirmedCurrentId).getElementsByTagName('input')); + productPrice += getPriceFields($(productConfigure.confirmedCurrentId).getElementsByTagName('select')); + productPrice += getPriceFields($(productConfigure.confirmedCurrentId).getElementsByTagName('textarea')); return productPrice; - }.bind(this); - productPrice += getPriceFields($(productConfigure.confirmedCurrentId).getElementsByTagName('input')); - productPrice += getPriceFields($(productConfigure.confirmedCurrentId).getElementsByTagName('select')); - productPrice += getPriceFields($(productConfigure.confirmedCurrentId).getElementsByTagName('textarea')); - return productPrice; - }, - - productGridCheckboxCheck : function(grid, element, checked){ - if (checked) { - if(element.inputElements) { - this.gridProducts.set(element.value, {}); - var product = this.gridProducts.get(element.value); - for (var i = 0; i < element.inputElements.length; i++) { - var input = element.inputElements[i]; - if (!input.hasClassName('input-inactive')) { - input.disabled = false; - if (input.name == 'qty' && !input.value) { - input.value = 1; + }, + + productGridCheckboxCheck : function(grid, element, checked){ + if (checked) { + if(element.inputElements) { + this.gridProducts.set(element.value, {}); + var product = this.gridProducts.get(element.value); + for (var i = 0; i < element.inputElements.length; i++) { + var input = element.inputElements[i]; + if (!input.hasClassName('input-inactive')) { + input.disabled = false; + if (input.name == 'qty' && !input.value) { + input.value = 1; + } } - } - if (input.checked || input.name != 'giftmessage') { - product[input.name] = input.value; - } else if (product[input.name]) { - delete(product[input.name]); + if (input.checked || input.name != 'giftmessage') { + product[input.name] = input.value; + } else if (product[input.name]) { + delete(product[input.name]); + } + } + } + } else { + if(element.inputElements){ + for(var i = 0; i < element.inputElements.length; i++) { + element.inputElements[i].disabled = true; } } + this.gridProducts.unset(element.value); } - } else { - if(element.inputElements){ - for(var i = 0; i < element.inputElements.length; i++) { - element.inputElements[i].disabled = true; + grid.reloadParams = {'products[]':this.gridProducts.keys()}; + }, + + /** + * Submit configured products to quote + */ + productGridAddSelected : function(){ + if(this.productGridShowButton) Element.show(this.productGridShowButton); + var area = ['search', 'items', 'shipping_method', 'totals', 'giftmessage','billing_method']; + // prepare additional fields and filtered items of products + var fieldsPrepare = {}; + var itemsFilter = []; + var products = this.gridProducts.toObject(); + for (var productId in products) { + itemsFilter.push(productId); + var paramKey = 'item['+productId+']'; + for (var productParamKey in products[productId]) { + paramKey += '['+productParamKey+']'; + fieldsPrepare[paramKey] = products[productId][productParamKey]; } } - this.gridProducts.unset(element.value); - } - grid.reloadParams = {'products[]':this.gridProducts.keys()}; - }, - - /** - * Submit configured products to quote - */ - productGridAddSelected : function(){ - if(this.productGridShowButton) Element.show(this.productGridShowButton); - var area = ['search', 'items', 'shipping_method', 'totals', 'giftmessage','billing_method']; - // prepare additional fields and filtered items of products - var fieldsPrepare = {}; - var itemsFilter = []; - var products = this.gridProducts.toObject(); - for (var productId in products) { - itemsFilter.push(productId); - var paramKey = 'item['+productId+']'; - for (var productParamKey in products[productId]) { - paramKey += '['+productParamKey+']'; - fieldsPrepare[paramKey] = products[productId][productParamKey]; + this.productConfigureSubmit('product_to_add', area, fieldsPrepare, itemsFilter); + productConfigure.clean('quote_items'); + this.hideArea('search'); + this.gridProducts = $H({}); + }, + + selectCustomer : function(grid, event){ + var element = Event.findElement(event, 'tr'); + if (element.title){ + this.setCustomerId(element.title); } - } - this.productConfigureSubmit('product_to_add', area, fieldsPrepare, itemsFilter); - productConfigure.clean('quote_items'); - this.hideArea('search'); - this.gridProducts = $H({}); - }, - - selectCustomer : function(grid, event){ - var element = Event.findElement(event, 'tr'); - if (element.title){ - this.setCustomerId(element.title); - } - }, - - customerSelectorHide : function(){ - this.hideArea('customer-selector'); - }, + }, - customerSelectorShow : function(){ - this.showArea('customer-selector'); - }, + customerSelectorHide : function(){ + this.hideArea('customer-selector'); + }, - storeSelectorHide : function(){ - this.hideArea('store-selector'); - }, + customerSelectorShow : function(){ + this.showArea('customer-selector'); + }, - storeSelectorShow : function(){ - this.showArea('store-selector'); - }, + storeSelectorHide : function(){ + this.hideArea('store-selector'); + }, - dataHide : function(){ - this.hideArea('data'); - }, + storeSelectorShow : function(){ + this.showArea('store-selector'); + }, - dataShow : function(){ - if ($('submit_order_top_button')) { - $('submit_order_top_button').show(); - } - this.showArea('data'); - }, - - clearShoppingCart : function(confirmMessage){ - if (confirm(confirmMessage)) { - this.collectElementsValue = false; - order.sidebarApplyChanges({'sidebar[empty_customer_cart]': 1}); - this.collectElementsValue = true; - } - }, + dataHide : function(){ + this.hideArea('data'); + }, - sidebarApplyChanges : function(auxiliaryParams) { - if ($(this.getAreaId('sidebar'))) { - var data = {}; - if (this.collectElementsValue) { - var elems = $(this.getAreaId('sidebar')).select('input'); - for (var i=0; i < elems.length; i++) { - if (elems[i].getValue()) { - data[elems[i].name] = elems[i].getValue(); + dataShow : function(){ + if ($('submit_order_top_button')) { + $('submit_order_top_button').show(); + } + this.showArea('data'); + }, + + clearShoppingCart : function(confirmMessage){ + var self = this; + + confirm({ + content: confirmMessage, + actions: { + confirm: function() { + self.collectElementsValue = false; + order.sidebarApplyChanges({'sidebar[empty_customer_cart]': 1}); + self.collectElementsValue = true; } } - } - if (auxiliaryParams instanceof Object) { - for (var paramName in auxiliaryParams) { - data[paramName] = String(auxiliaryParams[paramName]); + }); + }, + + sidebarApplyChanges : function(auxiliaryParams) { + if ($(this.getAreaId('sidebar'))) { + var data = {}; + if (this.collectElementsValue) { + var elems = $(this.getAreaId('sidebar')).select('input'); + for (var i=0; i < elems.length; i++) { + if (elems[i].getValue()) { + data[elems[i].name] = elems[i].getValue(); + } + } + } + if (auxiliaryParams instanceof Object) { + for (var paramName in auxiliaryParams) { + data[paramName] = String(auxiliaryParams[paramName]); + } } + data.reset_shipping = true; + this.loadArea(['sidebar', 'items', 'shipping_method', 'billing_method','totals', 'giftmessage'], true, data); } - data.reset_shipping = true; - this.loadArea(['sidebar', 'items', 'shipping_method', 'billing_method','totals', 'giftmessage'], true, data); - } - }, + }, - sidebarHide : function(){ - if(this.storeId === false && $('page:left') && $('page:container')){ - $('page:left').hide(); - $('page:container').removeClassName('container'); - $('page:container').addClassName('container-collapsed'); - } - }, + sidebarHide : function(){ + if(this.storeId === false && $('page:left') && $('page:container')){ + $('page:left').hide(); + $('page:container').removeClassName('container'); + $('page:container').addClassName('container-collapsed'); + } + }, - sidebarShow : function(){ - if($('page:left') && $('page:container')){ - $('page:left').show(); - $('page:container').removeClassName('container-collapsed'); - $('page:container').addClassName('container'); - } - }, - - /** - * Show configuration of product and add handlers on submit form - * - * @param productId - */ - sidebarConfigureProduct: function (listType, productId, itemId) { - // create additional fields - var params = {}; - params.reset_shipping = true; - params.add_product = productId; - this.prepareParams(params); - for (var i in params) { - if (params[i] === null) { - unset(params[i]); - } else if (typeof(params[i]) == 'boolean') { - params[i] = params[i] ? 1 : 0; + sidebarShow : function(){ + if($('page:left') && $('page:container')){ + $('page:left').show(); + $('page:container').removeClassName('container-collapsed'); + $('page:container').addClassName('container'); } - } - var fields = []; - for (var name in params) { - fields.push(new Element('input', {type: 'hidden', name: name, value: params[name]})); - } - // add additional fields before triggered submit - productConfigure.setBeforeSubmitCallback(listType, function() { - productConfigure.addFields(fields); - }.bind(this)); - // response handler - productConfigure.setOnLoadIFrameCallback(listType, function(response) { - if (!response.ok) { - return; + }, + + /** + * Show configuration of product and add handlers on submit form + * + * @param productId + */ + sidebarConfigureProduct: function (listType, productId, itemId) { + // create additional fields + var params = {}; + params.reset_shipping = true; + params.add_product = productId; + this.prepareParams(params); + for (var i in params) { + if (params[i] === null) { + unset(params[i]); + } else if (typeof(params[i]) == 'boolean') { + params[i] = params[i] ? 1 : 0; + } } - this.loadArea(['items', 'shipping_method', 'billing_method','totals', 'giftmessage'], true); - }.bind(this)); - // show item configuration - itemId = itemId ? itemId : productId; - productConfigure.showItemConfiguration(listType, itemId); - return false; - }, - - removeSidebarItem : function(id, from){ - this.loadArea(['sidebar_'+from], 'sidebar_data_'+from, {remove_item:id, from:from}); - }, - - itemsUpdate : function(){ - var area = ['sidebar', 'items', 'shipping_method', 'billing_method','totals', 'giftmessage']; - // prepare additional fields - var fieldsPrepare = {update_items: 1}; - var info = $('order-items_grid').select('input', 'select', 'textarea'); - for(var i=0; i<info.length; i++){ - if(!info[i].disabled && (info[i].type != 'checkbox' || info[i].checked)) { - fieldsPrepare[info[i].name] = info[i].getValue(); + var fields = []; + for (var name in params) { + fields.push(new Element('input', {type: 'hidden', name: name, value: params[name]})); } - } - fieldsPrepare = Object.extend(fieldsPrepare, this.productConfigureAddFields); - this.productConfigureSubmit('quote_items', area, fieldsPrepare); - this.orderItemChanged = false; - }, - - itemsOnchangeBind : function(){ - var elems = $('order-items_grid').select('input', 'select', 'textarea'); - for(var i=0; i<elems.length; i++){ - if(!elems[i].bindOnchange){ - elems[i].bindOnchange = true; - elems[i].observe('change', this.itemChange.bind(this)) + // add additional fields before triggered submit + productConfigure.setBeforeSubmitCallback(listType, function() { + productConfigure.addFields(fields); + }.bind(this)); + // response handler + productConfigure.setOnLoadIFrameCallback(listType, function(response) { + if (!response.ok) { + return; + } + this.loadArea(['items', 'shipping_method', 'billing_method','totals', 'giftmessage'], true); + }.bind(this)); + // show item configuration + itemId = itemId ? itemId : productId; + productConfigure.showItemConfiguration(listType, itemId); + return false; + }, + + removeSidebarItem : function(id, from){ + this.loadArea(['sidebar_'+from], 'sidebar_data_'+from, {remove_item:id, from:from}); + }, + + itemsUpdate : function(){ + var area = ['sidebar', 'items', 'shipping_method', 'billing_method','totals', 'giftmessage']; + // prepare additional fields + var fieldsPrepare = {update_items: 1}; + var info = $('order-items_grid').select('input', 'select', 'textarea'); + for(var i=0; i<info.length; i++){ + if(!info[i].disabled && (info[i].type != 'checkbox' || info[i].checked)) { + fieldsPrepare[info[i].name] = info[i].getValue(); + } } - } - }, - - itemChange : function(event){ - this.giftmessageOnItemChange(event); - this.orderItemChanged = true; - }, - - /** - * Submit batch of configured products - * - * @param listType - * @param area - * @param fieldsPrepare - * @param itemsFilter - */ - productConfigureSubmit : function(listType, area, fieldsPrepare, itemsFilter) { - // prepare loading areas and build url - area = this.prepareArea(area); - this.loadingAreas = area; - var url = this.loadBaseUrl + 'block/' + area + '?isAjax=true'; - - // prepare additional fields - fieldsPrepare = this.prepareParams(fieldsPrepare); - fieldsPrepare.reset_shipping = 1; - fieldsPrepare.json = 1; - - // create fields - var fields = []; - for (var name in fieldsPrepare) { - fields.push(new Element('input', {type: 'hidden', name: name, value: fieldsPrepare[name]})); - } - productConfigure.addFields(fields); + fieldsPrepare = Object.extend(fieldsPrepare, this.productConfigureAddFields); + this.productConfigureSubmit('quote_items', area, fieldsPrepare); + this.orderItemChanged = false; + }, + + itemsOnchangeBind : function(){ + var elems = $('order-items_grid').select('input', 'select', 'textarea'); + for(var i=0; i<elems.length; i++){ + if(!elems[i].bindOnchange){ + elems[i].bindOnchange = true; + elems[i].observe('change', this.itemChange.bind(this)) + } + } + }, + + itemChange : function(event){ + this.giftmessageOnItemChange(event); + this.orderItemChanged = true; + }, + + /** + * Submit batch of configured products + * + * @param listType + * @param area + * @param fieldsPrepare + * @param itemsFilter + */ + productConfigureSubmit : function(listType, area, fieldsPrepare, itemsFilter) { + // prepare loading areas and build url + area = this.prepareArea(area); + this.loadingAreas = area; + var url = this.loadBaseUrl + 'block/' + area + '?isAjax=true'; - // filter items - if (itemsFilter) { - productConfigure.addItemsFilter(listType, itemsFilter); - } + // prepare additional fields + fieldsPrepare = this.prepareParams(fieldsPrepare); + fieldsPrepare.reset_shipping = 1; + fieldsPrepare.json = 1; - // prepare and do submit - productConfigure.addListType(listType, {urlSubmit: url}); - productConfigure.setOnLoadIFrameCallback(listType, function(response){ - this.loadAreaResponseHandler(response); - }.bind(this)); - productConfigure.submit(listType); - // clean - this.productConfigureAddFields = {}; - }, - - /** - * Show configuration of quote item - * - * @param itemId - */ - showQuoteItemConfiguration: function(itemId){ - var listType = 'quote_items'; - var qtyElement = $('order-items_grid').select('input[name="item\['+itemId+'\]\[qty\]"]')[0]; - productConfigure.setConfirmCallback(listType, function() { - // sync qty of popup and qty of grid - var confirmedCurrentQty = productConfigure.getCurrentConfirmedQtyElement(); - if (qtyElement && confirmedCurrentQty && !isNaN(confirmedCurrentQty.value)) { - qtyElement.value = confirmedCurrentQty.value; - } - this.productConfigureAddFields['item['+itemId+'][configured]'] = 1; - - }.bind(this)); - productConfigure.setShowWindowCallback(listType, function() { - // sync qty of grid and qty of popup - var formCurrentQty = productConfigure.getCurrentFormQtyElement(); - if (formCurrentQty && qtyElement && !isNaN(qtyElement.value)) { - formCurrentQty.value = qtyElement.value; - } - }.bind(this)); - productConfigure.showItemConfiguration(listType, itemId); - }, - - accountFieldsBind : function(container){ - if($(container)){ - var fields = $(container).select('input', 'select', 'textarea'); - for(var i=0; i<fields.length; i++){ - if(fields[i].id == 'group_id'){ - fields[i].observe('change', this.accountGroupChange.bind(this)) + // create fields + var fields = []; + for (var name in fieldsPrepare) { + fields.push(new Element('input', {type: 'hidden', name: name, value: fieldsPrepare[name]})); + } + productConfigure.addFields(fields); + + // filter items + if (itemsFilter) { + productConfigure.addItemsFilter(listType, itemsFilter); + } + + // prepare and do submit + productConfigure.addListType(listType, {urlSubmit: url}); + productConfigure.setOnLoadIFrameCallback(listType, function(response){ + this.loadAreaResponseHandler(response); + }.bind(this)); + productConfigure.submit(listType); + // clean + this.productConfigureAddFields = {}; + }, + + /** + * Show configuration of quote item + * + * @param itemId + */ + showQuoteItemConfiguration: function(itemId){ + var listType = 'quote_items'; + var qtyElement = $('order-items_grid').select('input[name="item\['+itemId+'\]\[qty\]"]')[0]; + productConfigure.setConfirmCallback(listType, function() { + // sync qty of popup and qty of grid + var confirmedCurrentQty = productConfigure.getCurrentConfirmedQtyElement(); + if (qtyElement && confirmedCurrentQty && !isNaN(confirmedCurrentQty.value)) { + qtyElement.value = confirmedCurrentQty.value; } - else{ - fields[i].observe('change', this.accountFieldChange.bind(this)) + this.productConfigureAddFields['item['+itemId+'][configured]'] = 1; + + }.bind(this)); + productConfigure.setShowWindowCallback(listType, function() { + // sync qty of grid and qty of popup + var formCurrentQty = productConfigure.getCurrentFormQtyElement(); + if (formCurrentQty && qtyElement && !isNaN(qtyElement.value)) { + formCurrentQty.value = qtyElement.value; + } + }.bind(this)); + productConfigure.showItemConfiguration(listType, itemId); + }, + + accountFieldsBind : function(container){ + if($(container)){ + var fields = $(container).select('input', 'select', 'textarea'); + for(var i=0; i<fields.length; i++){ + if(fields[i].id == 'group_id'){ + fields[i].observe('change', this.accountGroupChange.bind(this)) + } + else{ + fields[i].observe('change', this.accountFieldChange.bind(this)) + } } } - } - }, + }, - accountGroupChange : function(){ - this.loadArea(['data'], true, this.serializeData('order-form_account').toObject()); - }, + accountGroupChange : function(){ + this.loadArea(['data'], true, this.serializeData('order-form_account').toObject()); + }, - accountFieldChange : function(){ - this.saveData(this.serializeData('order-form_account')); - }, + accountFieldChange : function(){ + this.saveData(this.serializeData('order-form_account')); + }, - commentFieldsBind : function(container){ - if($(container)){ - var fields = $(container).select('input', 'textarea'); - for(var i=0; i<fields.length; i++) - fields[i].observe('change', this.commentFieldChange.bind(this)) - } - }, + commentFieldsBind : function(container){ + if($(container)){ + var fields = $(container).select('input', 'textarea'); + for(var i=0; i<fields.length; i++) + fields[i].observe('change', this.commentFieldChange.bind(this)) + } + }, - commentFieldChange : function(){ - this.saveData(this.serializeData('order-comment')); - }, + commentFieldChange : function(){ + this.saveData(this.serializeData('order-comment')); + }, - giftmessageFieldsBind : function(container){ - if($(container)){ - var fields = $(container).select('input', 'textarea'); - for(var i=0; i<fields.length; i++) - fields[i].observe('change', this.giftmessageFieldChange.bind(this)) - } - }, - - giftmessageFieldChange : function(){ - this.giftMessageDataChanged = true; - }, - - giftmessageOnItemChange : function(event) { - var element = Event.element(event); - if(element.name.indexOf("giftmessage") != -1 && element.type == "checkbox" && !element.checked) { - var messages = $("order-giftmessage").select('textarea'); - var name; - for(var i=0; i<messages.length; i++) { - name = messages[i].id.split("_"); - if(name.length < 2) continue; - if (element.name.indexOf("[" + name[1] + "]") != -1 && messages[i].value != "") { - alert("First, clean the Message field in Gift Message form"); - element.checked = true; + giftmessageFieldsBind : function(container){ + if($(container)){ + var fields = $(container).select('input', 'textarea'); + for(var i=0; i<fields.length; i++) + fields[i].observe('change', this.giftmessageFieldChange.bind(this)) + } + }, + + giftmessageFieldChange : function(){ + this.giftMessageDataChanged = true; + }, + + giftmessageOnItemChange : function(event) { + var element = Event.element(event); + if(element.name.indexOf("giftmessage") != -1 && element.type == "checkbox" && !element.checked) { + var messages = $("order-giftmessage").select('textarea'); + var name; + for(var i=0; i<messages.length; i++) { + name = messages[i].id.split("_"); + if(name.length < 2) continue; + if (element.name.indexOf("[" + name[1] + "]") != -1 && messages[i].value != "") { + alert({ + content: "First, clean the Message field in Gift Message form" + }); + element.checked = true; + } } } - } - }, + }, + + loadArea : function(area, indicator, params){ + var deferred = new jQuery.Deferred(); + var url = this.loadBaseUrl; + if (area) { + area = this.prepareArea(area); + url += 'block/' + area; + } + if (indicator === true) indicator = 'html-body'; + params = this.prepareParams(params); + params.json = true; + if (!this.loadingAreas) this.loadingAreas = []; + if (indicator) { + this.loadingAreas = area; + new Ajax.Request(url, { + parameters:params, + loaderArea: indicator, + onSuccess: function(transport) { + var response = transport.responseText.evalJSON(); + this.loadAreaResponseHandler(response); + deferred.resolve(); + }.bind(this) + }); + } + else { + new Ajax.Request(url, { + parameters:params, + loaderArea: indicator, + onSuccess: function(transport) { + deferred.resolve(); + } + }); + } + if (typeof productConfigure != 'undefined' && area instanceof Array && area.indexOf('items') != -1) { + productConfigure.clean('quote_items'); + } + return deferred.promise(); + }, - loadArea : function(area, indicator, params){ - var deferred = new jQuery.Deferred(); - var url = this.loadBaseUrl; - if (area) { - area = this.prepareArea(area); - url += 'block/' + area; - } - if (indicator === true) indicator = 'html-body'; - params = this.prepareParams(params); - params.json = true; - if (!this.loadingAreas) this.loadingAreas = []; - if (indicator) { - this.loadingAreas = area; - new Ajax.Request(url, { - parameters:params, - loaderArea: indicator, - onSuccess: function(transport) { - var response = transport.responseText.evalJSON(); - this.loadAreaResponseHandler(response); - deferred.resolve(); - }.bind(this) - }); - } - else { - new Ajax.Request(url, { - parameters:params, - loaderArea: indicator, - onSuccess: function(transport) { - deferred.resolve(); + loadAreaResponseHandler : function (response) { + if (response.error) { + alert({ + content: response.message + }); + } + if (response.ajaxExpired && response.ajaxRedirect) { + setLocation(response.ajaxRedirect); + } + if (!this.loadingAreas) { + this.loadingAreas = []; + } + if (typeof this.loadingAreas == 'string') { + this.loadingAreas = [this.loadingAreas]; + } + if (this.loadingAreas.indexOf('message') == -1) { + this.loadingAreas.push('message'); + } + if (response.header) { + jQuery('.page-actions-inner').attr('data-title', response.header); + } + + for (var i = 0; i < this.loadingAreas.length; i++) { + var id = this.loadingAreas[i]; + if ($(this.getAreaId(id))) { + if ('message' != id || response[id]) { + $(this.getAreaId(id)).update(response[id]); + } + if ($(this.getAreaId(id)).callback) { + this[$(this.getAreaId(id)).callback](); + } } - }); - } - if (typeof productConfigure != 'undefined' && area instanceof Array && area.indexOf('items') != -1) { - productConfigure.clean('quote_items'); - } - return deferred.promise(); - }, + } + }, - loadAreaResponseHandler : function (response) { - if (response.error) { - alert(response.message); - } - if (response.ajaxExpired && response.ajaxRedirect) { - setLocation(response.ajaxRedirect); - } - if (!this.loadingAreas) { - this.loadingAreas = []; - } - if (typeof this.loadingAreas == 'string') { - this.loadingAreas = [this.loadingAreas]; - } - if (this.loadingAreas.indexOf('message') == -1) { - this.loadingAreas.push('message'); - } - if (response.header) { - jQuery('.page-actions-inner').attr('data-title', response.header); - } + prepareArea : function(area) { + if (this.giftMessageDataChanged) { + return area.without('giftmessage'); + } + return area; + }, + + saveData : function(data){ + this.loadArea(false, false, data); + }, + + showArea : function(area){ + var id = this.getAreaId(area); + if($(id)) { + $(id).show(); + this.areaOverlay(); + } + }, - for (var i = 0; i < this.loadingAreas.length; i++) { - var id = this.loadingAreas[i]; - if ($(this.getAreaId(id))) { - if ('message' != id || response[id]) { - $(this.getAreaId(id)).update(response[id]); - } - if ($(this.getAreaId(id)).callback) { - this[$(this.getAreaId(id)).callback](); - } + hideArea : function(area){ + var id = this.getAreaId(area); + if($(id)) { + $(id).hide(); + this.areaOverlay(); } - } - }, + }, - prepareArea : function(area) { - if (this.giftMessageDataChanged) { - return area.without('giftmessage'); - } - return area; - }, - - saveData : function(data){ - this.loadArea(false, false, data); - }, - - showArea : function(area){ - var id = this.getAreaId(area); - if($(id)) { - $(id).show(); - this.areaOverlay(); - } - }, + areaOverlay : function() + { + $H(order.overlayData).each(function(e){ + e.value.fx(); + }); + }, - hideArea : function(area){ - var id = this.getAreaId(area); - if($(id)) { - $(id).hide(); - this.areaOverlay(); - } - }, - - areaOverlay : function() - { - $H(order.overlayData).each(function(e){ - e.value.fx(); - }); - }, - - getAreaId : function(area){ - return 'order-'+area; - }, - - prepareParams : function(params){ - if (!params) { - params = {}; - } - if (!params.customer_id) { - params.customer_id = this.customerId; - } - if (!params.store_id) { - params.store_id = this.storeId; - } - if (!params.currency_id) { - params.currency_id = this.currencyId; - } - if (!params.form_key) { - params.form_key = FORM_KEY; - } + getAreaId : function(area){ + return 'order-'+area; + }, - if (this.isPaymentValidationAvailable()) { - var data = this.serializeData('order-billing_method'); - if (data) { - data.each(function(value) { - params[value[0]] = value[1]; - }); + prepareParams : function(params){ + if (!params) { + params = {}; } - } else { - params['payment[method]'] = this.paymentMethod; - } - return params; - }, - - /** - * Prevent from sending credit card information to server for some payment methods - * - * @returns {boolean} - */ - isPaymentValidationAvailable : function(){ - return ((typeof this.paymentMethod) == 'undefined' + if (!params.customer_id) { + params.customer_id = this.customerId; + } + if (!params.store_id) { + params.store_id = this.storeId; + } + if (!params.currency_id) { + params.currency_id = this.currencyId; + } + if (!params.form_key) { + params.form_key = FORM_KEY; + } + + if (this.isPaymentValidationAvailable()) { + var data = this.serializeData('order-billing_method'); + if (data) { + data.each(function(value) { + params[value[0]] = value[1]; + }); + } + } else { + params['payment[method]'] = this.paymentMethod; + } + return params; + }, + + /** + * Prevent from sending credit card information to server for some payment methods + * + * @returns {boolean} + */ + isPaymentValidationAvailable : function(){ + return ((typeof this.paymentMethod) == 'undefined' || this.excludedPaymentMethods.indexOf(this.paymentMethod) == -1); - }, + }, - serializeData : function(container){ - var fields = $(container).select('input', 'select', 'textarea'); - var data = Form.serializeElements(fields, true); + serializeData : function(container){ + var fields = $(container).select('input', 'select', 'textarea'); + var data = Form.serializeElements(fields, true); - return $H(data); - }, + return $H(data); + }, - toggleCustomPrice: function(checkbox, elemId, tierBlock) { - if (checkbox.checked) { - $(elemId).disabled = false; - $(elemId).show(); - if($(tierBlock)) $(tierBlock).hide(); - } - else { - $(elemId).disabled = true; - $(elemId).hide(); - if($(tierBlock)) $(tierBlock).show(); - } - }, - - submit : function() - { - jQuery('#edit_form').trigger('processStart'); - jQuery('#edit_form').trigger('submitOrder'); - }, - - _realSubmit: function () { - var disableAndSave = function() { - disableElements('save'); - jQuery('#edit_form').on('invalid-form.validate', function() { - enableElements('save'); - jQuery('#edit_form').trigger('processStop'); - jQuery('#edit_form').off('invalid-form.validate'); - }); - jQuery('#edit_form').triggerHandler('save'); - } - if (this.orderItemChanged) { - if (confirm('You have item changes')) { + toggleCustomPrice: function(checkbox, elemId, tierBlock) { + if (checkbox.checked) { + $(elemId).disabled = false; + $(elemId).show(); + if($(tierBlock)) $(tierBlock).hide(); + } + else { + $(elemId).disabled = true; + $(elemId).hide(); + if($(tierBlock)) $(tierBlock).show(); + } + }, + + submit : function() + { + jQuery('#edit_form').trigger('processStart'); + jQuery('#edit_form').trigger('submitOrder'); + }, + + _realSubmit: function () { + var disableAndSave = function() { + disableElements('save'); + jQuery('#edit_form').on('invalid-form.validate', function() { + enableElements('save'); + jQuery('#edit_form').trigger('processStop'); + jQuery('#edit_form').off('invalid-form.validate'); + }); + jQuery('#edit_form').triggerHandler('save'); + } + if (this.orderItemChanged) { + if (confirm('You have item changes')) { + disableAndSave(); + } else { + this.itemsUpdate(); + } + } else { disableAndSave(); + } + }, + + overlay : function(elId, show, observe) { + if (typeof(show) == 'undefined') { show = true; } + + var orderObj = this; + var obj = this.overlayData.get(elId); + if (!obj) { + obj = { + show: show, + el: elId, + order: orderObj, + fx: function(event) { + this.order.processOverlay(this.el, this.show); + } + }; + obj.bfx = obj.fx.bindAsEventListener(obj); + this.overlayData.set(elId, obj); } else { - this.itemsUpdate(); + obj.show = show; + Event.stopObserving(window, 'resize', obj.bfx); } - } else { - disableAndSave(); - } - }, - - overlay : function(elId, show, observe) { - if (typeof(show) == 'undefined') { show = true; } - - var orderObj = this; - var obj = this.overlayData.get(elId); - if (!obj) { - obj = { - show: show, - el: elId, - order: orderObj, - fx: function(event) { - this.order.processOverlay(this.el, this.show); - } - }; - obj.bfx = obj.fx.bindAsEventListener(obj); - this.overlayData.set(elId, obj); - } else { - obj.show = show; - Event.stopObserving(window, 'resize', obj.bfx); - } - Event.observe(window, 'resize', obj.bfx); + Event.observe(window, 'resize', obj.bfx); - this.processOverlay(elId, show); - }, + this.processOverlay(elId, show); + }, - processOverlay : function(elId, show) { - var el = $(elId); + processOverlay : function(elId, show) { + var el = $(elId); - if (!el) { - return; - } + if (!el) { + return; + } - var parentEl = el.up(1); - if (show) { - parentEl.removeClassName('ignore-validate'); - } else { - parentEl.addClassName('ignore-validate'); - } + var parentEl = el.up(1); + if (show) { + parentEl.removeClassName('ignore-validate'); + } else { + parentEl.addClassName('ignore-validate'); + } - if (Prototype.Browser.IE) { - parentEl.select('select').each(function (elem) { - if (show) { - elem.needShowOnSuccess = false; - elem.style.visibility = ''; - } else { - elem.style.visibility = 'hidden'; - elem.needShowOnSuccess = true; - } + if (Prototype.Browser.IE) { + parentEl.select('select').each(function (elem) { + if (show) { + elem.needShowOnSuccess = false; + elem.style.visibility = ''; + } else { + elem.style.visibility = 'hidden'; + elem.needShowOnSuccess = true; + } + }); + } + + parentEl.setStyle({position: 'relative'}); + el.setStyle({ + display: show ? 'none' : '' }); - } + }, - parentEl.setStyle({position: 'relative'}); - el.setStyle({ - display: show ? 'none' : '' - }); - }, - - validateVat: function(parameters) - { - var params = { - country: $(parameters.countryElementId).value, - vat: $(parameters.vatElementId).value - }; - - if (this.storeId !== false) { - params.store_id = this.storeId; - } + validateVat: function(parameters) + { + var params = { + country: $(parameters.countryElementId).value, + vat: $(parameters.vatElementId).value + }; - var currentCustomerGroupId = $(parameters.groupIdHtmlId).value; - - new Ajax.Request(parameters.validateUrl, { - parameters: params, - onSuccess: function(response) { - var message = ''; - var groupActionRequired = null; - try { - response = response.responseText.evalJSON(); - - if (null === response.group) { - if (true === response.valid) { - message = parameters.vatValidMessage; - } else if (true === response.success) { - message = parameters.vatInvalidMessage.replace(/%s/, params.vat); + if (this.storeId !== false) { + params.store_id = this.storeId; + } + + var currentCustomerGroupId = $(parameters.groupIdHtmlId).value; + + new Ajax.Request(parameters.validateUrl, { + parameters: params, + onSuccess: function(response) { + var message = ''; + var groupActionRequired = null; + try { + response = response.responseText.evalJSON(); + + if (null === response.group) { + if (true === response.valid) { + message = parameters.vatValidMessage; + } else if (true === response.success) { + message = parameters.vatInvalidMessage.replace(/%s/, params.vat); + } else { + message = parameters.vatValidationFailedMessage; + } } else { - message = parameters.vatValidationFailedMessage; - } - } else { - if (true === response.valid) { - message = parameters.vatValidAndGroupValidMessage; - if (0 === response.group) { - message = parameters.vatValidAndGroupInvalidMessage; + if (true === response.valid) { + message = parameters.vatValidAndGroupValidMessage; + if (0 === response.group) { + message = parameters.vatValidAndGroupInvalidMessage; + groupActionRequired = 'inform'; + } else if (currentCustomerGroupId != response.group) { + message = parameters.vatValidAndGroupChangeMessage; + groupActionRequired = 'change'; + } + } else if (response.success) { + message = parameters.vatInvalidMessage.replace(/%s/, params.vat); + groupActionRequired = 'inform'; + } else { + message = parameters.vatValidationFailedMessage; groupActionRequired = 'inform'; - } else if (currentCustomerGroupId != response.group) { - message = parameters.vatValidAndGroupChangeMessage; - groupActionRequired = 'change'; } - } else if (response.success) { - message = parameters.vatInvalidMessage.replace(/%s/, params.vat); - groupActionRequired = 'inform'; - } else { - message = parameters.vatValidationFailedMessage; - groupActionRequired = 'inform'; } + } catch (e) { + message = parameters.vatValidationFailedMessage; } - } catch (e) { - message = parameters.vatValidationFailedMessage; - } - if (null === groupActionRequired) { - alert(message); - } - else { - this.processCustomerGroupChange( - parameters.groupIdHtmlId, - message, - parameters.vatCustomerGroupMessage, - parameters.vatGroupErrorMessage, - response.group, - groupActionRequired - ); + if (null === groupActionRequired) { + alert({ + content: message + }); + } + else { + this.processCustomerGroupChange( + parameters.groupIdHtmlId, + message, + parameters.vatCustomerGroupMessage, + parameters.vatGroupErrorMessage, + response.group, + groupActionRequired + ); + } + }.bind(this) + }); + }, + + processCustomerGroupChange: function(groupIdHtmlId, message, customerGroupMessage, errorMessage, groupId, action) + { + var groupMessage = ''; + try { + var currentCustomerGroupId = $(groupIdHtmlId).value; + var currentCustomerGroupTitle = + $$('#' + groupIdHtmlId + ' > option[value=' + currentCustomerGroupId + ']')[0].text; + var customerGroupOption = $$('#' + groupIdHtmlId + ' > option[value=' + groupId + ']')[0]; + groupMessage = customerGroupMessage.replace(/%s/, customerGroupOption.text); + } catch (e) { + groupMessage = errorMessage; + if (action === 'change') { + message = ''; + action = 'inform'; } - }.bind(this) - }); - }, - - processCustomerGroupChange: function(groupIdHtmlId, message, customerGroupMessage, errorMessage, groupId, action) - { - var groupMessage = ''; - try { - var currentCustomerGroupId = $(groupIdHtmlId).value; - var currentCustomerGroupTitle = - $$('#' + groupIdHtmlId + ' > option[value=' + currentCustomerGroupId + ']')[0].text; - var customerGroupOption = $$('#' + groupIdHtmlId + ' > option[value=' + groupId + ']')[0]; - groupMessage = customerGroupMessage.replace(/%s/, customerGroupOption.text); - } catch (e) { - groupMessage = errorMessage; - if (action === 'change') { - message = ''; - action = 'inform'; } - } - if (action === 'change') { - var confirmText = message.replace(/%s/, customerGroupOption.text); - confirmText = confirmText.replace(/%s/, currentCustomerGroupTitle); - if (confirm(confirmText)) { - $$('#' + groupIdHtmlId + ' option').each(function (o) { - o.selected = o.readAttribute('value') == groupId; + if (action === 'change') { + var confirmText = message.replace(/%s/, customerGroupOption.text); + confirmText = confirmText.replace(/%s/, currentCustomerGroupTitle); + if (confirm(confirmText)) { + $$('#' + groupIdHtmlId + ' option').each(function (o) { + o.selected = o.readAttribute('value') == groupId; + }); + this.accountGroupChange(); + } + } else if (action === 'inform') { + alert({ + content: message + '\n' + groupMessage }); - this.accountGroupChange(); } - } else if (action === 'inform') { - alert(message + '\n' + groupMessage); } - } -}; - -window.OrderFormArea = Class.create(); -OrderFormArea.prototype = { - _name: null, - _node: null, - _parent: null, - _callbackName: null, - - initialize: function(name, node, parent){ - if(!node) - return; - this._name = name; - this._parent = parent; - this._callbackName = node.callback; - if (typeof this._callbackName == 'undefined') { - this._callbackName = name + 'Loaded'; - node.callback = this._callbackName; + }; + + window.OrderFormArea = Class.create(); + OrderFormArea.prototype = { + _name: null, + _node: null, + _parent: null, + _callbackName: null, + + initialize: function(name, node, parent){ + if(!node) + return; + this._name = name; + this._parent = parent; + this._callbackName = node.callback; + if (typeof this._callbackName == 'undefined') { + this._callbackName = name + 'Loaded'; + node.callback = this._callbackName; + } + parent[this._callbackName] = parent[this._callbackName].wrap((function (proceed){ + proceed(); + this.onLoad(); + }).bind(this)); + + this.setNode(node); + }, + + setNode: function(node){ + if (!node.callback) { + node.callback = this._callbackName; + } + this.node = node; + }, + + onLoad: function(){ } - parent[this._callbackName] = parent[this._callbackName].wrap((function (proceed){ - proceed(); - this.onLoad(); - }).bind(this)); + }; + + window.ControlButton = Class.create(); + + ControlButton.prototype = { + _label: '', + _node: null, + + initialize: function(label){ + this._label = label; + this._node = new Element('button', { + 'class': 'action-secondary action-add', + 'type': 'button' + }); + }, - this.setNode(node); - }, + onClick: function(){ + }, - setNode: function(node){ - if (!node.callback) { - node.callback = this._callbackName; + insertIn: function(element, position){ + var node = Object.extend(this._node), + content = {}; + node.observe('click', this.onClick); + node.update('<span>' + this._label + '</span>'); + content[position] = node; + Element.insert(element, content); } - this.node = node; - }, - - onLoad: function(){ - } -}; - -window.ControlButton = Class.create(); - -ControlButton.prototype = { - _label: '', - _node: null, - - initialize: function(label){ - this._label = label; - this._node = new Element('button', { - 'class': 'action-secondary action-add', - 'type': 'button' - }); - }, - - onClick: function(){ - }, - - insertIn: function(element, position){ - var node = Object.extend(this._node), - content = {}; - node.observe('click', this.onClick); - node.update('<span>' + this._label + '</span>'); - content[position] = node; - Element.insert(element, content); - } -}; + }; }); diff --git a/app/code/Magento/SalesRule/view/adminhtml/templates/promo/salesrulejs.phtml b/app/code/Magento/SalesRule/view/adminhtml/templates/promo/salesrulejs.phtml index fab5791b698062f5d2249fe8c204734fb5fbed64..329ef5513920b13295bcc86a8e435a36a1e658c3 100644 --- a/app/code/Magento/SalesRule/view/adminhtml/templates/promo/salesrulejs.phtml +++ b/app/code/Magento/SalesRule/view/adminhtml/templates/promo/salesrulejs.phtml @@ -5,7 +5,12 @@ */ ?> <script> -require(["jquery", "uiRegistry", "prototype"], function(jQuery, registry){ +require([ + 'jquery', + "uiRegistry", + 'Magento_Ui/js/modal/alert', + 'prototype' +], function(jQuery, registry, alert){ //<![CDATA[ var couponTypeSpecific = '<?php /* @escapeNotVerified */ echo \Magento\SalesRule\Model\Rule::COUPON_TYPE_SPECIFIC ?>', @@ -80,7 +85,11 @@ function generateCouponCodes(idPrefix, generateUrl, grid) { onComplete : function (transport, param){ var response = false; if (transport && transport.responseText) { - response = eval('(' + transport.responseText + ')'); + try { + response = JSON.parse(transport.responseText); + } catch (e) { + console.warn('An error occured while parsing response'); + } } if (couponCodesGrid) { couponCodesGrid.reload(); @@ -93,7 +102,9 @@ function generateCouponCodes(idPrefix, generateUrl, grid) { } } if (response && response.error) { - alert(response.error); + alert({ + content: response.error + }); } } }); diff --git a/app/code/Magento/Shipping/view/adminhtml/templates/create/items.phtml b/app/code/Magento/Shipping/view/adminhtml/templates/create/items.phtml index 0aed9867ff6502cc619759ab8dec71882bcfdc41..3044a6dc5e844f7c330e262683e998d4c7f4755c 100644 --- a/app/code/Magento/Shipping/view/adminhtml/templates/create/items.phtml +++ b/app/code/Magento/Shipping/view/adminhtml/templates/create/items.phtml @@ -115,8 +115,9 @@ <script> require([ "jquery", + "Magento_Ui/js/modal/alert", "prototype" -], function(jQuery){ +], function(jQuery, alert){ //<![CDATA[ var sendEmailCheckbox = $('send_email'); @@ -145,7 +146,9 @@ window.toggleCreateLabelCheckbox = function() { } window.submitShipment = function(btn) { if (!validQtyItems()) { - alert('<?php /* @escapeNotVerified */ echo __('Invalid value(s) for Qty to Ship') ?>'); + alert({ + content: '<?php /* @escapeNotVerified */ echo __('Invalid value(s) for Qty to Ship') ?>' + }); return; } var checkbox = $(btn).up('.order-totals').select('#create_shipping_label')[0]; diff --git a/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/js.phtml b/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/js.phtml index 8b2b70a2cdbfb947c6f7716c1d51d23d07deb0ee..0f911d563f714492a0700f50cdbb1746683f3fbe 100644 --- a/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/js.phtml +++ b/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/js.phtml @@ -8,7 +8,14 @@ ?> <script> -require(["jquery", 'uiRegistry', "collapsable", "prototype"], function(jQuery, rg){ +require([ + "jquery", + "uiRegistry", + "Magento_Ui/js/modal/alert", + 'Magento_Ui/js/modal/prompt', + "collapsable", + "prototype" +], function(jQuery, rg, alert, prompt){ function toggleApplyVisibility(select) { if ($(select).value == 1) { @@ -324,36 +331,48 @@ function updateRequriedOptions() function saveAttributeInNewSet(promptMessage) { - var newAttributeSetName = prompt(promptMessage, ''); - - if (newAttributeSetName == null) { - return; - } - - var rules = ['required-entry', 'validate-no-html-tags']; - for (var i = 0; i < rules.length; i++) { - if (!jQuery.validator.methods[rules[i]](newAttributeSetName)) { - alert(jQuery.validator.messages[rules[i]]); - return; + var newAttributeSetName; + + prompt({ + content: promptMessage, + actions: { + confirm: function(val) { + newAttributeSetName = val; + + if (!newAttributeSetName) { + return; + } + + var rules = ['required-entry', 'validate-no-html-tags']; + for (var i = 0; i < rules.length; i++) { + if (!jQuery.validator.methods[rules[i]](newAttributeSetName)) { + alert({ + content: jQuery.validator.messages[rules[i]] + }); + + return; + } + } + + var newAttributeSetNameInputId = 'new_attribute_set_name'; + + if ($(newAttributeSetNameInputId)) { + $(newAttributeSetNameInputId).value = newAttributeSetName; + } else { + $('edit_form').insert({ + top: new Element('input', { + type: 'hidden', + id: newAttributeSetNameInputId, + name: 'new_attribute_set_name', + value: newAttributeSetName + }) + }); + } + // Temporary solution will replaced after refactoring of attributes functionality + jQuery('#edit_form').triggerHandler('save'); + } } - } - - var newAttributeSetNameInputId = 'new_attribute_set_name'; - - if ($(newAttributeSetNameInputId)) { - $(newAttributeSetNameInputId).value = newAttributeSetName; - } else { - $('edit_form').insert({ - top: new Element('input', { - type: 'hidden', - id: newAttributeSetNameInputId, - name: 'new_attribute_set_name', - value: newAttributeSetName - }) - }); - } - // Temporary solution will replaced after refactoring of attributes functionality - jQuery('#edit_form').triggerHandler('save'); + }); } if($('frontend_input')){ diff --git a/app/code/Magento/Tax/view/adminhtml/templates/rule/edit.phtml b/app/code/Magento/Tax/view/adminhtml/templates/rule/edit.phtml index c2fa7a5543d56ac9a40e955344b717c6cb5c2812..e04ddfeeefeb8028d1d6159558ef2340b8e80c1c 100644 --- a/app/code/Magento/Tax/view/adminhtml/templates/rule/edit.phtml +++ b/app/code/Magento/Tax/view/adminhtml/templates/rule/edit.phtml @@ -11,25 +11,25 @@ <script> require([ "jquery", + 'Magento_Ui/js/modal/alert', "jquery/ui", "jquery/editableMultiselect/js/jquery.multiselect", - "mage/mage" -], function($){ + "mage/mage", + 'Magento_Ui/js/modal/modal' +], function($, alert){ - $.widget("adminhtml.dialogRates", $.ui.dialog, { + $.widget("adminhtml.dialogRates", $.mage.modal, { options: { itemRate: {}, itemRateDefault: {} }, _create: function() { - $.ui.dialog.prototype._create.apply(this); + this._super(); this._getFormData(this.options.itemRateDefault); }, - open: function() { - var zipIsRange = this.uiDialog.find('#zip_is_range'); - if (this._trigger('beforeOpen', null, this) === false) { - return; - } + openModal: function() { + var zipIsRange = this.modal.find('#zip_is_range'); + this._applyItem(this.options.itemRateDefault); if (this.options.itemRate && !$.isEmptyObject(this.options.itemRate)) { this._applyItem(this.options.itemRate); @@ -37,13 +37,14 @@ require([ zipIsRange.attr('checked', zipIsRange.val() == 1); zipIsRange.trigger('change'); updater.update(); - $.ui.dialog.prototype.open.apply(this); + this._super(); }, - close: function() { - $.ui.dialog.prototype.close.apply(this); + closeModal: function() { + this._super(); }, _applyItem: function(rate) { - var dialogElement = this.uiDialog; + var dialogElement = this.modal; + $.each(rate, function(key, value) { if (!value) { value = ''; @@ -55,7 +56,7 @@ require([ this._getFormData(this.options.itemRate); }, _getFormData: function(data) { - $.each(this.uiDialog.find(':input'), function() { + $.each(this.modal.find(':input'), function() { if (this.name) { data[this.name] = this.value } @@ -91,14 +92,20 @@ require([ } else { if (result.error_message) - alert(result.error_message); + alert({ + content: result.error_message + }); else - alert('<?php /* @escapeNotVerified */ echo __('An error occurred'); ?>'); + alert({ + content: '<?php /* @escapeNotVerified */ echo __('An error occurred'); ?>' + }); } }, error: function () { $('body').trigger('processStop'); - alert('<?php /* @escapeNotVerified */ echo __('An error occurred'); ?>'); + alert({ + content: '<?php /* @escapeNotVerified */ echo __('An error occurred'); ?>' + }); }, dataType: "json" }); @@ -177,14 +184,20 @@ require([ select.find('option').eq(index).remove(); } else { if (result.error_message) - alert(result.error_message); + alert({ + content: result.error_message + }); else - alert('<?php /* @escapeNotVerified */ echo __('An error occurred'); ?>'); + alert({ + content: '<?php /* @escapeNotVerified */ echo __('An error occurred'); ?>' + }); } }, error: function () { $('body').trigger('processStop'); - alert('<?php /* @escapeNotVerified */ echo __('An error occurred'); ?>'); + alert({ + content: '<?php /* @escapeNotVerified */ echo __('An error occurred'); ?>' + }); } }; $.ajax(ajaxOptions); @@ -193,7 +206,7 @@ require([ .on('click.mselectAdd', '.mselect-button-add', function () { taxRateForm .dialogRates({itemRate: {}}) - .dialogRates('open'); + .dialogRates('openModal'); }) .on('click.mselect-checked', '.mselect-list-item input', function (event) { var el = $(this), @@ -205,42 +218,20 @@ require([ taxRateForm.dialogRates({ title: '<?php /* @escapeNotVerified */ echo __('Tax Rate'); ?>', - autoOpen: false, + type: 'slide', id: '<?php /* @escapeNotVerified */ echo $block->getJsId() ?>', - minWidth: 560, - modal: true, - dialogClass: 'tax-rate-popup', - resizable: false, - width: '75%', - position: { - my: 'left top', - at: 'center top', - of: 'body' - }, - open: function () { - var topMargin; - - $(this).closest('.ui-dialog').addClass('ui-dialog-active'); - topMargin = $(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 80; - $(this).closest('.ui-dialog').css({ - top: '1%', - position: 'absolute', - left: '10%' - }); - $(this).closest('.ui-dialog').css('margin-top', topMargin); - $(this).addClass('admin__scope-old'); // ToDo UI: remove with old styles removal - }, - close: function() { - $(this).closest('.ui-dialog').removeClass('ui-dialog-active'); + modalClass: 'tax-rate-popup', + closed: function () { + taxRateFormElement.data('validation').clearError(); }, buttons: [{ text: '<?php /* @escapeNotVerified */ echo __('Save'); ?>', - id: '<?php /* @escapeNotVerified */ echo $block->getJsId('apply-button') ?>', 'class': 'action-save action-primary', click: function() { - $(this).dialogRates('updateItemRate'); - var itemRate = $(this).dialogRates('option').itemRate, + this.updateItemRate(); + var itemRate = this.option('itemRate'), itemRateData = $.extend({}, itemRate); + if (itemRateData.itemElement) { delete itemRateData.itemElement; } @@ -272,29 +263,27 @@ require([ taxRateField.find('option[value=""]:last') .val(itemRate.tax_calculation_rate_id); } - taxRateForm.dialogRates("close"); + taxRateForm.dialogRates('closeModal'); } else { if (result.error_message) - alert(result.error_message); + alert({ + content: result.error_message + }); else - alert('<?php /* @escapeNotVerified */ echo __('An error occurred'); ?>'); + alert({ + content: '<?php /* @escapeNotVerified */ echo __('An error occurred'); ?>' + }); } }, error: function () { $('body').trigger('processStop'); - alert('<?php /* @escapeNotVerified */ echo __('An error occurred'); ?>'); + alert({ + content: '<?php /* @escapeNotVerified */ echo __('An error occurred'); ?>' + }); } }; $.ajax(ajaxOptions); } - }, { - text: '<?php /* @escapeNotVerified */ echo __('Cancel'); ?>', - id: '<?php /* @escapeNotVerified */ echo $block->getJsId('close-button') ?>', - 'class': 'action-close', - click: function() { - $(this).dialogRates("close"); - taxRateFormElement.data('validation').clearError(); - } }] }); $('.grid-loading-mask').hide(); diff --git a/app/code/Magento/Theme/view/adminhtml/templates/browser/content.phtml b/app/code/Magento/Theme/view/adminhtml/templates/browser/content.phtml index 1d1a41632209d262c7e99da8cb001a9ffd718a3b..e2413267b89dd29112696096904445d17c5709d2 100644 --- a/app/code/Magento/Theme/view/adminhtml/templates/browser/content.phtml +++ b/app/code/Magento/Theme/view/adminhtml/templates/browser/content.phtml @@ -13,17 +13,6 @@ ?> <?php echo $block->getChildHtml('wysiwyg_files.js') ?> -<div class="content-header skip-header" id="content_header"> - <table> - <tr> - <td><h3 id="content_header_text"><?php /* @escapeNotVerified */ echo $block->getHeaderText() ?></h3></td> - <td class="form-buttons"> - <?php echo $block->getButtonsHtml() ?> - </td> - </tr> - </table> -</div> - -<div id="contents-uploader"><?php echo $block->getChildHtml('wysiwyg_files.uploader') ?></div> +<div id="contents-uploader" class="contents-uploader"><?php echo $block->getChildHtml('wysiwyg_files.uploader') ?></div> <div id="contents"></div> <div id="contents-newfolder" class="no-display"><?php echo $block->getChildHtml('wysiwyg_files.newfolder') ?></div> diff --git a/app/code/Magento/Theme/view/adminhtml/templates/tabs/css.phtml b/app/code/Magento/Theme/view/adminhtml/templates/tabs/css.phtml index 4fe1d1b1aec2550192f6dbdc1314e54b5620db06..192ca0fbcdba756148ef5980cc3fc22af3c25658 100644 --- a/app/code/Magento/Theme/view/adminhtml/templates/tabs/css.phtml +++ b/app/code/Magento/Theme/view/adminhtml/templates/tabs/css.phtml @@ -12,9 +12,10 @@ <script> require([ "jquery", + "Magento_Ui/js/modal/alert", "jquery/file-uploader", "mage/translate" -], function($){ +], function($, alert){ $( '#css_file_uploader' ).fileupload({ dataType: 'json', @@ -65,7 +66,9 @@ require([ */ fail: function(e, data) { $(this).val(''); - alert($.mage.__("We don't recognize this file extension.")); + alert({ + content: $.mage.__("We don't recognize this file extension.") + }); } }); diff --git a/app/code/Magento/Theme/view/adminhtml/templates/tabs/js.phtml b/app/code/Magento/Theme/view/adminhtml/templates/tabs/js.phtml index 8c7e677ceeb2001019fc2ed1d6349f78419e0377..5ba996c844600d9e4151c43b1347c22d3686f669 100644 --- a/app/code/Magento/Theme/view/adminhtml/templates/tabs/js.phtml +++ b/app/code/Magento/Theme/view/adminhtml/templates/tabs/js.phtml @@ -10,11 +10,12 @@ <script> require([ "jquery", - 'mage/template', + "mage/template", + "Magento_Ui/js/modal/alert", "jquery/file-uploader", "Magento_Theme/js/sortable", "mage/translate" -], function ($, mageTemplate) { +], function ($, mageTemplate, alert) { $('#js_files_uploader').fileupload({ dataType: 'json', @@ -109,7 +110,9 @@ require([ $(progressSelector).removeClass('upload-progress').addClass('upload-failure'); $(this).val(''); - alert($.mage.__("We don't recognize this file extension.")); + alert({ + content: $.mage.__("We don't recognize this file extension.") + }); } }); diff --git a/app/code/Magento/Theme/view/base/requirejs-config.js b/app/code/Magento/Theme/view/base/requirejs-config.js index e5504adda39b61a16fd166e91e159572528e41a5..f1f164431d417a681ac0e2424e6549beb2108f85 100644 --- a/app/code/Magento/Theme/view/base/requirejs-config.js +++ b/app/code/Magento/Theme/view/base/requirejs-config.js @@ -7,7 +7,9 @@ var config = { "waitSeconds": 0, "map": { "*": { - "mageUtils": "mage/utils/main" + "mageUtils": "mage/utils/main", + "ko": "knockoutjs/knockout", + "knockout": "knockoutjs/knockout" } }, "shim": { @@ -19,16 +21,12 @@ var config = { "mage/captcha": ["prototype"], "mage/common": ["jquery"], "mage/new-gallery": ["jquery"], - "mage/requirejs/plugin/id-normalizer": ["jquery"], "mage/webapi": ["jquery"], "jquery/ui": ["jquery"], "MutationObserver": ["es6-collections"], "tinymce": { "exports": "tinymce" }, - "ko": { - "exports": "ko" - }, "moment": { "exports": "moment" }, @@ -48,7 +46,6 @@ var config = { "jquery/jquery-storageapi": "jquery/jquery.storageapi.min", "text": "requirejs/text", "domReady": "requirejs/domReady", - "ko": "ko/ko", "tinymce": "tiny_mce/tiny_mce_src" }, "deps": [ diff --git a/app/code/Magento/Ui/Component/AbstractComponent.php b/app/code/Magento/Ui/Component/AbstractComponent.php index 27ffd158016cb207e0943056847539813cacb7a8..f6b0d543c0469531d2976f74d6831e9a34739fe6 100644 --- a/app/code/Magento/Ui/Component/AbstractComponent.php +++ b/app/code/Magento/Ui/Component/AbstractComponent.php @@ -9,6 +9,7 @@ use Magento\Framework\DataObject; use Magento\Framework\View\Element\UiComponentInterface; use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponent\DataSourceInterface; +use Magento\Framework\View\Element\UiComponent\ObserverInterface; /** * Abstract class AbstractComponent @@ -52,6 +53,8 @@ abstract class AbstractComponent extends DataObject implements UiComponentInterf ) { $this->context = $context; $this->components = $components; + $this->initObservers($data); + $this->context->getProcessor()->register($this); $this->_data = array_replace_recursive($this->_data, $data); } @@ -92,6 +95,7 @@ abstract class AbstractComponent extends DataObject implements UiComponentInterf if ($this->hasData('buttons')) { $this->getContext()->addButtons($this->getData('buttons'), $this); } + $this->getContext()->getProcessor()->notify($this->getComponentName()); } /** @@ -239,4 +243,25 @@ abstract class AbstractComponent extends DataObject implements UiComponentInterf { return []; } + + /** + * Initiate observers + * + * @param array $data + * @return void + */ + protected function initObservers(array & $data = []) + { + if (isset($data['observers']) && is_array($data['observers'])) { + foreach ($data['observers'] as $observerType => $observer) { + if (!is_object($observer)) { + $observer = $this; + } + if ($observer instanceof ObserverInterface) { + $this->getContext()->getProcessor()->attach($observerType, $observer); + } + unset($data['observers']); + } + } + } } diff --git a/app/code/Magento/Ui/Component/Filters.php b/app/code/Magento/Ui/Component/Filters.php index c250487fc91367abf1d81dbb39ca2b08a572160a..dadcdc2f09535bb7b8275eedea8f52f8dfc1b55f 100644 --- a/app/code/Magento/Ui/Component/Filters.php +++ b/app/code/Magento/Ui/Component/Filters.php @@ -5,13 +5,57 @@ */ namespace Magento\Ui\Component; +use Magento\Framework\View\Element\UiComponent\ContextInterface; +use Magento\Framework\View\Element\UiComponent\ObserverInterface; +use Magento\Framework\View\Element\UiComponentFactory; +use Magento\Framework\View\Element\UiComponentInterface; +use Magento\Ui\Component\Listing\Columns\ColumnInterface; + /** * Class Filters */ -class Filters extends AbstractComponent +class Filters extends AbstractComponent implements ObserverInterface { const NAME = 'filters'; + /** + * Filters created from columns + * + * @var UiComponentInterface[] + */ + protected $columnFilters = []; + + /** + * Maps filter declaration to type + * + * @var array + */ + protected $filterMap = [ + 'text' => 'filterInput', + 'textRange' => 'filterRange', + 'select' => 'filterSelect', + 'dateRange' => 'filterDate', + ]; + + /** + * @var UiComponentFactory + */ + protected $uiComponentFactory; + + /** + * @inheritDoc + */ + public function __construct( + ContextInterface $context, + UiComponentFactory $uiComponentFactory, + array $components = [], + array $data = [] + ) { + parent::__construct($context, $components, $data); + $this->uiComponentFactory = $uiComponentFactory; + } + + /** * Get component name * @@ -21,4 +65,52 @@ class Filters extends AbstractComponent { return static::NAME; } + + /** + * @inheritDoc + */ + public function update(UiComponentInterface $component) + { + if ($component instanceof ColumnInterface) { + $filterType = $component->getData('config/filter'); + if (!$filterType) { + return; + } + + if (isset($this->filterMap[$filterType])) { + $filterComponent = $this->uiComponentFactory->create( + $component->getName(), + $this->filterMap[$filterType], + ['context' => $this->getContext()] + ); + $filterComponent->setData('config', $component->getConfiguration()); + $filterComponent->prepare(); + $this->addComponent($component->getName(), $filterComponent); + } + } + } + + /** + * @inheritDoc + */ + public function addComponent($name, UiComponentInterface $component) + { + $this->columnFilters[$name] = $component; + parent::addComponent($name, $component); + } + + /** + * @inheritDoc + */ + public function getChildComponents() + { + $result = parent::getChildComponents(); + foreach (array_keys($this->columnFilters) as $componentName) { + if ($this->getComponent($componentName)) { + unset($result[$componentName]); + } + } + + return $result; + } } diff --git a/app/code/Magento/Ui/Component/Filters/Type/Date.php b/app/code/Magento/Ui/Component/Filters/Type/Date.php index f1689efa87af25bc441fc8a0669ebe0b903427df..98e782a4da1c201b8820f6596e189242b0752b1c 100644 --- a/app/code/Magento/Ui/Component/Filters/Type/Date.php +++ b/app/code/Magento/Ui/Component/Filters/Type/Date.php @@ -66,16 +66,40 @@ class Date extends AbstractFilter if (isset($this->filterData[$this->getName()])) { $value = $this->filterData[$this->getName()]; - if (!empty($value)) { - $value = $this->wrappedComponent->convertDate($value); + if (empty($value)) { + return; + } - $filter = $this->filterBuilder->setConditionType('eq') - ->setField($this->getName()) - ->setValue($value->format('Y-m-d H:i:s')) - ->create(); + if (is_array($value)) { + if (isset($value['from'])) { + $this->applyFilterByType('gteq', $this->wrappedComponent->convertDate($value['from'])); + } - $this->getContext()->getDataProvider()->addFilter($filter); + if (isset($value['to'])) { + $this->applyFilterByType('lteq', $this->wrappedComponent->convertDate($value['to'])); + } + } else { + $this->applyFilterByType('eq', $this->wrappedComponent->convertDate($value)); } } } + + /** + * Apply filter by its type + * + * @param string $type + * @param string $value + * @return void + */ + protected function applyFilterByType($type, $value) + { + if (!empty($value)) { + $filter = $this->filterBuilder->setConditionType($type) + ->setField($this->getName()) + ->setValue($value->format('Y-m-d H:i:s')) + ->create(); + + $this->getContext()->getDataProvider()->addFilter($filter); + } + } } diff --git a/app/code/Magento/Ui/Component/Listing/Columns.php b/app/code/Magento/Ui/Component/Listing/Columns.php index b0f3142b920a61fccbd123c708ad40d5ef4ef08f..29eaf63f6bafdbfb40de35a712e4a867ef8f3046 100644 --- a/app/code/Magento/Ui/Component/Listing/Columns.php +++ b/app/code/Magento/Ui/Component/Listing/Columns.php @@ -44,25 +44,7 @@ class Columns extends AbstractComponent } } } - $this->buildUrlsForInlineEditing(); - parent::prepare(); - } - /** - * Build urls for inline editing - * - * @return void - */ - protected function buildUrlsForInlineEditing() - { - $config = $this->getConfiguration(); - if (isset($config['editorConfig']) && isset($config['editorConfig']['clientConfig'])) { - foreach ($config['editorConfig']['clientConfig'] as $key => &$value) { - if (in_array($key, ['saveUrl', 'validateUrl'])) { - $value = $this->getContext()->getUrl($value); - } - } - } - $this->setData('config', $config); + parent::prepare(); } } diff --git a/app/code/Magento/Ui/Component/MassAction.php b/app/code/Magento/Ui/Component/MassAction.php index 62498131c1bdb011a79c8b1f23f923ad7aca2b2f..4acb21e7cf97262160043084a7ed51d44983be76 100644 --- a/app/code/Magento/Ui/Component/MassAction.php +++ b/app/code/Magento/Ui/Component/MassAction.php @@ -29,6 +29,7 @@ class MassAction extends AbstractComponent } $this->setData('config', $config); + $this->components = []; parent::prepare(); } diff --git a/app/code/Magento/Ui/Test/Unit/Component/Control/ActionTest.php b/app/code/Magento/Ui/Test/Unit/Component/Control/ActionTest.php index be25a5957f10d22e90fc5f2b91be11910b60b342..6d02b1395bad9608ddcbb2b8032e9366d4a9af3b 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Control/ActionTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Control/ActionTest.php @@ -28,9 +28,14 @@ class ActionTest extends \PHPUnit_Framework_TestCase */ public function setUp() { + $context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $context->expects($this->any())->method('getProcessor')->willReturn($processor); $this->objectManager = new ObjectManager($this); - - $this->action = $this->objectManager->getObject('Magento\Ui\Component\Control\Action'); + $this->action = $this->objectManager->getObject('Magento\Ui\Component\Control\Action', ['context' => $context]); } /** diff --git a/app/code/Magento/Ui/Test/Unit/Component/Control/LinkTest.php b/app/code/Magento/Ui/Test/Unit/Component/Control/LinkTest.php index 1615690f8674f3668f502e6b45328c535286fe74..00cd56b56f84e66ea8055b2d51c64763d3dbfdb0 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Control/LinkTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Control/LinkTest.php @@ -28,9 +28,15 @@ class LinkTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->objectManager = new ObjectManager($this); + $context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $context->expects($this->any())->method('getProcessor')->willReturn($processor); - $this->link = $this->objectManager->getObject('Magento\Ui\Component\Control\Link'); + $this->objectManager = new ObjectManager($this); + $this->link = $this->objectManager->getObject('Magento\Ui\Component\Control\Link', ['context' => $context]); } /** diff --git a/app/code/Magento/Ui/Test/Unit/Component/ExportButtonTest.php b/app/code/Magento/Ui/Test/Unit/Component/ExportButtonTest.php index 0e65e804ce8583c7ab67147c31c46a575156edd7..dc6a1004b69fb79cfc77137f6b2cd63ca72d089b 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/ExportButtonTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/ExportButtonTest.php @@ -29,6 +29,12 @@ class ExportButtonTest extends \PHPUnit_Framework_TestCase protected function setUp() { + $context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $context->expects($this->any())->method('getProcessor')->willReturn($processor); $this->objectManager = new ObjectManager($this); $this->urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface') @@ -37,7 +43,8 @@ class ExportButtonTest extends \PHPUnit_Framework_TestCase $this->model = $this->objectManager->getObject( 'Magento\Ui\Component\ExportButton', [ - 'urlBuilder' => $this->urlBuilderMock + 'urlBuilder' => $this->urlBuilderMock, + 'context' => $context, ] ); } diff --git a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateRangeTest.php b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateRangeTest.php index 6a2a0b545678dc66181b408795e15be8bebbba4d..29262bc9e3f8679cbca8e3cfabfa71cd1dcf8da1 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateRangeTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateRangeTest.php @@ -48,6 +48,10 @@ class DateRangeTest extends \PHPUnit_Framework_TestCase '', false ); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $this->uiComponentFactory = $this->getMock( 'Magento\Framework\View\Element\UiComponentFactory', ['create'], diff --git a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php index 79af8056579f644d965f348b20302f9c8dd122b6..e921d1d52d19b885e960189277e835f3b0f584a8 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php @@ -48,6 +48,10 @@ class DateTest extends \PHPUnit_Framework_TestCase '', false ); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $this->uiComponentFactory = $this->getMock( 'Magento\Framework\View\Element\UiComponentFactory', ['create'], diff --git a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/InputTest.php b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/InputTest.php index a3736ad6bd5028bbfc4e2201253a6aaa4043a59c..e4b291134e6f9df9902cc55bf29876cf8efa3d02 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/InputTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/InputTest.php @@ -48,6 +48,10 @@ class InputTest extends \PHPUnit_Framework_TestCase '', false ); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $this->uiComponentFactory = $this->getMock( 'Magento\Framework\View\Element\UiComponentFactory', ['create'], diff --git a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/RangeTest.php b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/RangeTest.php index d28cb78ee21c9e8dd2535003786193975c1e9f45..8907f0c02aacbd47767e9760df915611a4654507 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/RangeTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/RangeTest.php @@ -47,7 +47,10 @@ class RangeTest extends \PHPUnit_Framework_TestCase '', false ); - + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $this->uiComponentFactory = $this->getMock( 'Magento\Framework\View\Element\UiComponentFactory', [], diff --git a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/SelectTest.php b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/SelectTest.php index 45b200fc58494f0964058447e5fe04cb97a5de94..469e8ef5696537a84d0216a9f18d0b2798de62eb 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/SelectTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/SelectTest.php @@ -48,6 +48,10 @@ class SelectTest extends \PHPUnit_Framework_TestCase '', false ); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $this->uiComponentFactory = $this->getMock( 'Magento\Framework\View\Element\UiComponentFactory', ['create'], diff --git a/app/code/Magento/Ui/Test/Unit/Component/Form/Field/MultilineTest.php b/app/code/Magento/Ui/Test/Unit/Component/Form/Field/MultilineTest.php index c1e717c1525fed4c226a20a697b0e9ce5f488172..c724bc049fedb5959e8266b584a8b8aef9295bbb 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Form/Field/MultilineTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Form/Field/MultilineTest.php @@ -47,6 +47,10 @@ class MultilineTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $this->multiline = new Multiline( $this->contextMock, diff --git a/app/code/Magento/Ui/Test/Unit/Component/Form/FieldTest.php b/app/code/Magento/Ui/Test/Unit/Component/Form/FieldTest.php index 86a47115d31129abfedb6fe3ceafafc394879912..a5462493e45d7214aedad235ccd63568f43208c7 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Form/FieldTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Form/FieldTest.php @@ -56,6 +56,10 @@ class FieldTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $this->field = new Field( $this->contextMock, @@ -138,7 +142,7 @@ class FieldTest extends \PHPUnit_Framework_TestCase $wrappedComponentMock->expects($this->once()) ->method('getChildComponents') ->willReturn($this->getComponentsMock()); - $wrappedComponentMock->expects($this->exactly(2)) + $wrappedComponentMock->expects($this->any()) ->method('getComponentName') ->willReturn(self::COMPONENT_NAME); $wrappedComponentMock->expects($this->once()) diff --git a/app/code/Magento/Ui/Test/Unit/Component/Listing/Columns/ColumnTest.php b/app/code/Magento/Ui/Test/Unit/Component/Listing/Columns/ColumnTest.php index 98005246955763c90120fd66e06ff8f9eabb0a1a..c42ba043d2db78a7763dc845c5567121e1ba70fe 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Listing/Columns/ColumnTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Listing/Columns/ColumnTest.php @@ -43,6 +43,10 @@ class ColumnTest extends \PHPUnit_Framework_TestCase true, [] ); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); } /** @@ -78,7 +82,10 @@ class ColumnTest extends \PHPUnit_Framework_TestCase public function testPrepareItems() { $testItems = ['item1','item2', 'item3']; - $column = $this->objectManager->getObject('Magento\Ui\Component\Listing\Columns\Column'); + $column = $this->objectManager->getObject( + 'Magento\Ui\Component\Listing\Columns\Column', + ['context' => $this->contextMock] + ); $this->assertEquals($testItems, $column->prepareItems($testItems)); } diff --git a/app/code/Magento/Ui/Test/Unit/Component/Listing/ColumnsTest.php b/app/code/Magento/Ui/Test/Unit/Component/Listing/ColumnsTest.php index fca1b2a4eded577e2f550170522318559b310a07..e381cc7a096643719291d4cc89647b7e963ecbb6 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Listing/ColumnsTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Listing/ColumnsTest.php @@ -42,6 +42,10 @@ class ColumnsTest extends \PHPUnit_Framework_TestCase true, [] ); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); } /** @@ -105,10 +109,6 @@ class ColumnsTest extends \PHPUnit_Framework_TestCase $this->contextMock->expects($this->once()) ->method('addComponentDefinition') ->with('columns', ['extends' => 'test_config_extends']); - $this->contextMock->expects($this->once()) - ->method('getUrl') - ->with($saveUrl) - ->willReturn('http://localhost.com/admin/' . $saveUrl); $dataProviderMock->expects($this->once()) ->method('getFieldMetaInfo') @@ -152,7 +152,7 @@ class ColumnsTest extends \PHPUnit_Framework_TestCase 'test_config_data' => 'test_config_value', 'editorConfig' => [ 'clientConfig' => [ - 'saveUrl' => 'http://localhost.com/admin/' . $saveUrl, + 'saveUrl' => $saveUrl, ] ] ], diff --git a/app/code/Magento/Ui/Test/Unit/Component/ListingTest.php b/app/code/Magento/Ui/Test/Unit/Component/ListingTest.php index 9ee36c9ad4acbdda69373ad5fc92482f626af166..530e02138f1849db442f29650cd747d943cf2988 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/ListingTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/ListingTest.php @@ -38,6 +38,10 @@ class ListingTest extends \PHPUnit_Framework_TestCase '', false ); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); } /** diff --git a/app/code/Magento/Ui/Test/Unit/Component/MassAction/Columns/ColumnTest.php b/app/code/Magento/Ui/Test/Unit/Component/MassAction/Columns/ColumnTest.php index 43b9271d4e013ab291e2e0b0346298456ef6be12..2d35559c0c1ef08270ccf82134d305830d1fcfcc 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/MassAction/Columns/ColumnTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/MassAction/Columns/ColumnTest.php @@ -45,6 +45,10 @@ class ColumnTest extends \PHPUnit_Framework_TestCase true, [] ); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); $this->column = $this->objectManager->getObject( 'Magento\Ui\Component\MassAction\Columns\Column', diff --git a/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php b/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php index a2d2401fed792d07c4c63f4a0ff62d58435e66ad..5f4174a99b580bbe0c88b8796d918ee02bc8e7e8 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php @@ -33,6 +33,10 @@ class MassActionTest extends \PHPUnit_Framework_TestCase $this->contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); } /** diff --git a/app/code/Magento/Ui/Test/Unit/Component/PagingTest.php b/app/code/Magento/Ui/Test/Unit/Component/PagingTest.php index fd4c63c3b28870ad1a60068d66ee86eb52c6291a..3992644a9b6fdf0347247873224614993a206a27 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/PagingTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/PagingTest.php @@ -41,6 +41,10 @@ class PagingTest extends \PHPUnit_Framework_TestCase true, [] ); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor); } /** diff --git a/app/code/Magento/Ui/view/base/requirejs-config.js b/app/code/Magento/Ui/view/base/requirejs-config.js index b96c395b7c5582be713dd54b917241f72653db75..604ed1e59043efd150359f4a8381cb3a72488a63 100644 --- a/app/code/Magento/Ui/view/base/requirejs-config.js +++ b/app/code/Magento/Ui/view/base/requirejs-config.js @@ -9,10 +9,13 @@ var config = { }, map: { '*': { - uiComponent: 'Magento_Ui/js/lib/component/main', - uiRegistry: 'Magento_Ui/js/lib/registry/registry', - uiLayout: 'Magento_Ui/js/core/renderer/layout', - uiClass: 'Magento_Ui/js/lib/class' + uiElement: 'Magento_Ui/js/lib/core/element/element', + uiCollection: 'Magento_Ui/js/lib/core/collection', + uiComponent: 'Magento_Ui/js/lib/core/collection', + uiClass: 'Magento_Ui/js/lib/core/class', + uiEvents: 'Magento_Ui/js/lib/core/events', + uiRegistry: 'Magento_Ui/js/lib/registry/registry', + uiLayout: 'Magento_Ui/js/core/renderer/layout' } } }; diff --git a/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml b/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml index edb853da11302f136131afa172f139bcc815a43a..b8485998fec512fafd41dc1aa3dcf606a16b6e7e 100755 --- a/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml +++ b/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml @@ -12,7 +12,7 @@ <item name="template" xsi:type="string">templates/listing/default</item> <item name="save_parameters_in_session" xsi:type="string">1</item> <item name="client_root" xsi:type="string">mui/index/render</item> - <item name="js_config" xsi:type="array"> + <item name="config" xsi:type="array"> <item name="component" xsi:type="string">uiComponent</item> </item> </argument> @@ -20,17 +20,22 @@ <paging class="Magento\Ui\Component\Paging"> <argument name="data" xsi:type="array"> - <item name="template" xsi:type="string">templates/paging/default</item> - <item name="js_config" xsi:type="array"> + <item name="config" xsi:type="array"> <item name="component" xsi:type="string">Magento_Ui/js/grid/paging/paging</item> + <item name="displayArea" xsi:type="string">bottom</item> </item> </argument> </paging> <filters class="Magento\Ui\Component\Filters"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> + <item name="config" xsi:type="array"> <item name="component" xsi:type="string">Magento_Ui/js/grid/filters/filters</item> + <item name="displayArea" xsi:type="string">dataGridFilters</item> + <item name="dataScope" xsi:type="string">filters</item> + </item> + <item name="observers" xsi:type="array"> + <item name="column" xsi:type="string">column</item> </item> </argument> </filters> @@ -39,7 +44,6 @@ <item name="config" xsi:type="array"> <item name="component" xsi:type="string">Magento_Ui/js/grid/search/search</item> <item name="displayArea" xsi:type="string">dataGridFilters</item> - </item> </argument> </filterSearch> @@ -52,8 +56,8 @@ </filterSelect> <filterRange class="Magento\Ui\Component\Filters\Type\Range"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/filters/group</item> + <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/filters/range</item> </item> </argument> </filterRange> @@ -73,7 +77,7 @@ </filterDate> <container class="Magento\Ui\Component\Container"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> + <item name="config" xsi:type="array"> <item name="component" xsi:type="string">uiComponent</item> </item> <item name="template" xsi:type="string">templates/container/default</item> @@ -81,22 +85,22 @@ </container> <massaction class="Magento\Ui\Component\MassAction"> <argument name="data" xsi:type="array"> - <item name="template" xsi:type="string">templates/listingcontainer/massaction/default</item> - <item name="js_config" xsi:type="array"> + <item name="config" xsi:type="array"> <item name="component" xsi:type="string">Magento_Ui/js/grid/massactions</item> + <item name="displayArea" xsi:type="string">bottom</item> </item> </argument> </massaction> <actions class="Magento\Ui\Component\Control\Action"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> + <item name="config" xsi:type="array"> <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/actions</item> </item> </argument> </actions> <action class="Magento\Ui\Component\Action"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> + <item name="config" xsi:type="array"> <item name="component" xsi:type="string">uiComponent</item> </item> </argument> @@ -104,7 +108,7 @@ <columns class="Magento\Ui\Component\Listing\Columns"> <argument name="data" xsi:type="array"> - <item name="js_config" xsi:type="array"> + <item name="config" xsi:type="array"> <item name="component" xsi:type="string">Magento_Ui/js/grid/listing</item> </item> </argument> @@ -112,9 +116,37 @@ <column class="Magento\Ui\Component\Listing\Columns\Column"> <argument name="data" xsi:type="array"> <item name="state_prefix" xsi:type="string">columns</item> + <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + <item name="dataType" xsi:type="string">text</item> + </item> </argument> </column> + <actionsColumn class="Magento\Ui\Component\Listing\Columns\Column"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/actions</item> + <item name="dataType" xsi:type="string">actions</item> + <item name="label" xsi:type="string" translate="true">Action</item> + </item> + </argument> + </actionsColumn> + <selectionsColumn class="Magento\Ui\Component\MassAction\Columns\Column"> + <argument name="data" xsi:type="array"> + <item name="state_prefix" xsi:type="string">columns</item> + <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> + </item> + </argument> + </selectionsColumn> + <component class="Magento\Ui\Component\Container"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">uiComponent</item> + </item> + </argument> + </component> <form class="Magento\Ui\Component\Form"> <argument name="data" xsi:type="array"> @@ -212,7 +244,7 @@ <image class="Magento\Ui\Component\Form\Element\DataType\Media"> <argument name="data" xsi:type="array"> <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/form/element/abstract</item> + <item name="component" xsi:type="string">Magento_Ui/js/form/element/media</item> <item name="config" xsi:type="array"> <item name="template" xsi:type="string">ui/form/field</item> <item name="elementTmpl" xsi:type="string">ui/form/element/media</item> @@ -220,6 +252,17 @@ </item> </argument> </image> + <file class="Magento\Ui\Component\Form\Element\DataType\Media"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/form/element/media</item> + <item name="config" xsi:type="array"> + <item name="template" xsi:type="string">ui/form/field</item> + <item name="elementTmpl" xsi:type="string">ui/form/element/media</item> + </item> + </item> + </argument> + </file> <date class="Magento\Ui\Component\Form\Element\DataType\Date"> <argument name="data" xsi:type="array"> <item name="js_config" xsi:type="array"> @@ -279,15 +322,20 @@ <!-- bookmark --> <bookmark class="Magento\Ui\Component\Bookmark"> <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> + <item name="displayArea" xsi:type="string">dataGridActions</item> + <item name="storageConfig" xsi:type="array"> + <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> + <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> + </item> + </item> </argument> </bookmark> <exportButton class="Magento\Ui\Component\ExportButton"> <argument name="data" xsi:type="array"> - <item name="template" xsi:type="string">templates/export/button</item> - <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/export</item> - </item> <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/export</item> <item name="displayArea" xsi:type="string">dataGridActions</item> <item name="options" xsi:type="array"> <item name="cvs" xsi:type="array"> diff --git a/app/code/Magento/Ui/view/base/web/js/block-loader.js b/app/code/Magento/Ui/view/base/web/js/block-loader.js index e3cb1b422bb31f070307e26f8f037cb3753f4e99..bc1d30db768d1b2a38c889a078fb058033e16a73 100644 --- a/app/code/Magento/Ui/view/base/web/js/block-loader.js +++ b/app/code/Magento/Ui/view/base/web/js/block-loader.js @@ -5,7 +5,7 @@ define([ 'ko', 'jquery', - 'Magento_Ui/js/lib/loader', + 'Magento_Ui/js/lib/ko/template/loader', 'mage/template' ], function (ko, $, templateLoader, template) { 'use strict'; diff --git a/app/code/Magento/Ui/view/base/web/js/core/app.js b/app/code/Magento/Ui/view/base/web/js/core/app.js index 5c4593bd486a312ecc1233c2a4cc2940d2025817..b009aca28d21d930df9d33bd5b5d04ada6e10ed1 100644 --- a/app/code/Magento/Ui/view/base/web/js/core/app.js +++ b/app/code/Magento/Ui/view/base/web/js/core/app.js @@ -4,7 +4,8 @@ */ define([ './renderer/types', - './renderer/layout' + './renderer/layout', + 'Magento_Ui/js/lib/ko/initialize' ], function (types, layout) { 'use strict'; diff --git a/app/code/Magento/Ui/view/base/web/js/form/client.js b/app/code/Magento/Ui/view/base/web/js/form/client.js index 6c6bdbfcf30067a496a874c1fd1eb24e4d4eec05..6deaa92dfb5e9a2b7ef8c64648153b60df2f2077 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/client.js +++ b/app/code/Magento/Ui/view/base/web/js/form/client.js @@ -6,7 +6,7 @@ define([ 'jquery', 'underscore', 'mageUtils', - 'Magento_Ui/js/lib/class' + 'uiClass' ], function ($, _, utils, Class) { 'use strict'; @@ -15,7 +15,7 @@ define([ data = utils.serialize(data); - data.form_key = FORM_KEY; + data.form_key = window.FORM_KEY; if (!url) { save.resolve(); @@ -52,15 +52,6 @@ define([ } return Class.extend({ - /** - * Initializes DataProvider instance. - * @param {Object} settings - Settings to initialize object with. - */ - initialize: function (config) { - _.extend(this, config); - - return this; - }, /** * Assembles data and submits it using 'utils.submit' method @@ -79,8 +70,6 @@ define([ options = options || {}; - data.form_key = FORM_KEY; - if (!options.redirect) { url += 'back/edit'; } @@ -88,7 +77,7 @@ define([ utils.submit({ url: url, data: data - }); + }, options.attributes); return this; } diff --git a/app/code/Magento/Ui/view/base/web/js/form/components/collection.js b/app/code/Magento/Ui/view/base/web/js/form/components/collection.js index bf10209d9d97cd0b08da0742c85a19f22bc8b1d5..b9c812af84d67cc253f7336808adddd342a2b30e 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/components/collection.js +++ b/app/code/Magento/Ui/view/base/web/js/form/components/collection.js @@ -7,8 +7,9 @@ define([ 'mageUtils', 'uiRegistry', 'uiComponent', - 'Magento_Ui/js/core/renderer/layout' -], function (_, utils, registry, Component, layout) { + 'uiLayout', + 'Magento_Ui/js/modal/confirm' +], function (_, utils, registry, Component, layout, confirm) { 'use strict'; var childTemplate = { @@ -67,6 +68,7 @@ define([ return this; }, + /** * Creates new item of collection, based on incoming 'index'. * If not passed creates one with 'new_' prefix. @@ -152,11 +154,16 @@ define([ * it requires function to invoke. */ removeAddress: function (elem) { - var confirmed = confirm(this.removeMessage); - - if (confirmed) { - this._removeAddress(elem); - } + var self = this; + + confirm({ + content: this.removeMessage, + actions: { + confirm: function () { + self._removeAddress(elem) + } + } + }); }, /** diff --git a/app/code/Magento/Ui/view/base/web/js/form/components/collection/item.js b/app/code/Magento/Ui/view/base/web/js/form/components/collection/item.js index 4f7c38f4adbf958ea6689c344be3f04d079d0ff8..91cee0068ca97df41e1d0629633ad6015784b6a9 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/components/collection/item.js +++ b/app/code/Magento/Ui/view/base/web/js/form/components/collection/item.js @@ -54,7 +54,7 @@ define([ * * @return {Object} - reference to instance */ - initProperties: function () { + initConfig: function () { this._super(); this.displayed = []; @@ -69,12 +69,11 @@ define([ * @return {Object} - reference to instance */ initObservable: function () { - this._super(); - - this.observe({ - 'noPreview': true, - 'indexed': {} - }); + this._super() + .observe({ + noPreview: true, + indexed: {} + }); return this; }, @@ -109,6 +108,27 @@ define([ return this; }, + /** + * Destroys current instance along with all of its' children. + * Overrides base method to clear data when this method is called. + */ + destroy: function () { + this._super(); + this._clearData(); + }, + + /** + * Clears all data associated with component. + * @private + * + * @returns {Item} Chainable. + */ + _clearData: function () { + this.source.remove(this.dataScope); + + return this; + }, + /** * Formats incoming previews array via parsePreview function. * @@ -157,7 +177,7 @@ define([ items = items.map(function (index) { var elem = elems[index]; - preview = elem && elem.visible() ? elem.delegate('getPreview') : ''; + preview = elem && elem.visible() ? elem.getPreview() : ''; preview = Array.isArray(preview) ? _.compact(preview).join(', ') : diff --git a/app/code/Magento/Ui/view/base/web/js/form/components/group.js b/app/code/Magento/Ui/view/base/web/js/form/components/group.js index daf56e7e564a719823b153883f8a74bc508f24fb..468dff2ec6678aa1a13f520fcaab3e8ca248228c 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/components/group.js +++ b/app/code/Magento/Ui/view/base/web/js/form/components/group.js @@ -4,11 +4,11 @@ */ define([ 'underscore', - 'uiComponent' -], function (_, Component) { + 'uiCollection' +], function (_, Collection) { 'use strict'; - return Component.extend({ + return Collection.extend({ defaults: { visible: true, label: '', @@ -88,6 +88,15 @@ define([ */ isMultiple: function () { return this.elems.getLength() > 1; + }, + + /** + * Returns an array of child components previews. + * + * @returns {Array} + */ + getPreview: function () { + return this.elems.map('getPreview'); } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/form/components/tab.js b/app/code/Magento/Ui/view/base/web/js/form/components/tab.js index 61560892e3e9ddd8dc3885644eb3d874a50ea9fb..bd9537f747e23709a257beac0da9faf4941ae212 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/components/tab.js +++ b/app/code/Magento/Ui/view/base/web/js/form/components/tab.js @@ -3,11 +3,11 @@ * See COPYING.txt for license details. */ define([ - 'uiComponent' -], function (Component) { + 'uiCollection' +], function (Collection) { 'use strict'; - return Component.extend({ + return Collection.extend({ defaults: { uniqueProp: 'active', active: false, @@ -35,14 +35,6 @@ define([ return this; }, - onUniqueUpdate: function (name) { - var active = name === this.name; - - this._super(); - - this.trigger('active', active); - }, - /** * Sets active property to true, then invokes pushParams method. */ @@ -51,6 +43,8 @@ define([ this.wasActivated(true); this.setUnique(); + + return true; } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/abstract.js b/app/code/Magento/Ui/view/base/web/js/form/element/abstract.js index 591d9de82b07ce80f2840b8f28f98f3daeb47bd5..4795afde0002490438afa082fe3e0d59b0a61e35 100755 --- a/app/code/Magento/Ui/view/base/web/js/form/element/abstract.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/abstract.js @@ -6,19 +6,18 @@ define([ 'underscore', 'mageUtils', - 'uiComponent', + 'uiElement', 'Magento_Ui/js/lib/validation/validator' -], function (_, utils, Component, validator) { +], function (_, utils, Element, validator) { 'use strict'; - return Component.extend({ + return Element.extend({ defaults: { visible: true, preview: '', focused: false, required: false, disabled: false, - tmpPath: 'ui/form/element/', tooltipTpl: 'ui/form/element/helper/tooltip', 'input_type': 'input', placeholder: '', @@ -78,15 +77,20 @@ define([ * * @returns {Abstract} Chainable. */ - initProperties: function () { - var uid = utils.uniqueid(); + initConfig: function () { + var uid = utils.uniqueid(), + name, + scope; this._super(); + scope = this.dataScope, + name = scope.split('.').slice(1); + _.extend(this, { - 'uid': uid, - 'noticeId': 'notice-' + uid, - 'inputName': utils.serializeName(this.dataScope) + uid: uid, + noticeId: 'notice-' + uid, + inputName: utils.serializeName(name.join('.')) }); return this; diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/date.js b/app/code/Magento/Ui/view/base/web/js/form/element/date.js index c9ee948d681470da296ae16a1ebe6ff213017928..d4dc131c7a29a030dbd404e30d5a4c5ca7711e13 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/date.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/date.js @@ -20,10 +20,12 @@ define([ * * @returns {Object} Chainable. */ - initProperties: function () { + initConfig: function () { + this._super(); + this.dateFormat = utils.normalizeDate(this.dateFormat); - return this._super(); + return this; }, /** diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/helpers/options.js b/app/code/Magento/Ui/view/base/web/js/form/element/helpers/options.js deleted file mode 100644 index 99b14e19582ee7c32ae6113b313c89aa24e8d578..0000000000000000000000000000000000000000 --- a/app/code/Magento/Ui/view/base/web/js/form/element/helpers/options.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -define([ - 'uiComponent' -], function (Component) { - 'use strict'; - - return Component.extend({ - }); -}); diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/media.js b/app/code/Magento/Ui/view/base/web/js/form/element/media.js new file mode 100644 index 0000000000000000000000000000000000000000..31b610c481bc17c31024a0e8640f05964204c7f7 --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/js/form/element/media.js @@ -0,0 +1,48 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'mageUtils', + './abstract' +], function (utils, Abstract) { + 'use strict'; + + return Abstract.extend({ + defaults: { + links: { + value: '' + } + }, + + /** + * Initializes file component. + * + * @returns {Media} Chainable. + */ + initialize: function () { + this._super() + .initFormId(); + + return this; + }, + + /** + * Defines form ID with which file input will be associated. + * + * @returns {Media} Chainable. + */ + initFormId: function () { + var namespace; + + if (this.formId) { + return this; + } + + namespace = this.name.split('.'); + this.formId = namespace[0]; + + return this; + } + }); +}); diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js b/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js index 624d2df5c7e79eaf3b3add5fd049051010a4b4e1..6c5de791d1e87337876b2919c7b1c6180729ff1a 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js @@ -16,12 +16,11 @@ define([ }, /** - * Calls 'getInitialValue' of parent and if the result of it is not empty - * string, returs it, else returnes caption or first found option's value + * Splits incoming string value. * - * @returns {Array|String} + * @returns {Array} */ - getInitialValue: function () { + normalizeData: function () { var value = this._super(); return _.isString(value) ? value.split(',') : value; @@ -29,6 +28,7 @@ define([ /** * Defines if value has changed + * * @returns {Boolean} */ hasChanged: function () { diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/select.js b/app/code/Magento/Ui/view/base/web/js/form/element/select.js index a28cac0ae7681e9069059928e9eb56e7f2b856f4..061844da9b05a357a325bd50195fca0d140d7ad7 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/select.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/select.js @@ -7,7 +7,7 @@ define([ 'mageUtils', 'uiRegistry', './abstract', - 'Magento_Ui/js/core/renderer/layout' + 'uiLayout' ], function (_, utils, registry, Abstract, layout) { 'use strict'; diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/textarea.js b/app/code/Magento/Ui/view/base/web/js/form/element/textarea.js index b5d263cc344d080936252d8881bcd963fd9a06ab..2731725ae2de939d83016d2be506473169dc0a79 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/textarea.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/textarea.js @@ -10,9 +10,9 @@ define([ return Abstract.extend({ defaults: { - cols: 15, - rows: 2, - template: 'ui/form/element/textarea' + cols: 15, + rows: 2, + template: 'ui/form/element/textarea' } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/ui-select.js b/app/code/Magento/Ui/view/base/web/js/form/element/ui-select.js index 638f78341d61d774a342ca07ce0aad752bb02b82..5547e3ad9dba80b8a4573e5ea08c6fc2107e710a 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/ui-select.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/ui-select.js @@ -5,12 +5,10 @@ define([ 'underscore', - 'ko', './abstract', 'Magento_Ui/js/lib/key-codes', - 'mage/translate', - 'uiLayout' -], function (_, ko, Abstract, keyCodes, $t, layout) { + 'mage/translate' +], function (_, Abstract, keyCodes, $t) { 'use strict'; /** @@ -52,20 +50,10 @@ define([ defaultPlaceholder: $t('Select...'), lotPlaceholders: $t('Selected') }, - optionsConfig: { - name: '${ $.name }_options', - component: 'Magento_Ui/js/form/element/helpers/options' - }, hoverElIndex: null, listens: { listVisible: 'cleanHoveredElement', filterInputValue: 'filterOptionsList' - }, - imports: { - options: '${ $.optionsConfig.name }:options' - }, - modules: { - optionsProvider: '${ $.optionsConfig.name }' } }, @@ -134,18 +122,6 @@ define([ return this; }, - /** - * Initializes optionsProvider - * - * @returns {Object} Chainable. - */ - initOptions: function () { - this.optionsConfig.options = this.options(); - layout([this.optionsConfig]); - - return this; - }, - /** * Handler outerClick event. Closed options list */ @@ -490,16 +466,11 @@ define([ * @returns {String} */ getPreview: function () { - var i = 0, - selected = this.getSelected(), - length = selected.length, - result = []; - - for (i; i < length; i++) { - result.push(selected[i].label); - } + var selected = this.getSelected(); - return result.join(', '); + return selected.map(function (option) { + return option.label; + }).join(', '); } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/form/form.js b/app/code/Magento/Ui/view/base/web/js/form/form.js index 2a192c20c2463e29397750f0ade0e147ac0d80bd..25e193877c1804c4610d94b253b881bd1a8d5105 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/form.js +++ b/app/code/Magento/Ui/view/base/web/js/form/form.js @@ -4,10 +4,10 @@ */ define([ 'underscore', - 'uiComponent', + 'uiCollection', 'Magento_Ui/js/lib/spinner', './adapter' -], function (_, Component, loader, adapter) { +], function (_, Collection, loader, adapter) { 'use strict'; function collectData(selector) { @@ -23,7 +23,7 @@ define([ return result; } - return Component.extend({ + return Collection.extend({ initialize: function () { this._super() .initAdapter() @@ -42,7 +42,7 @@ define([ return this; }, - initProperties: function () { + initConfig: function () { this._super(); this.selector = '[data-form-part=' + this.namespace + ']'; @@ -76,7 +76,10 @@ define([ }); source.save({ - redirect: redirect + redirect: redirect, + attributes: { + id: this.namespace + } }); }, diff --git a/app/code/Magento/Ui/view/base/web/js/form/provider.js b/app/code/Magento/Ui/view/base/web/js/form/provider.js index 8b182d2b8f2383266f101921d4e8668478c2934b..d992c8e1678bb423cfde5b2675dde6d97f655bf1 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/provider.js +++ b/app/code/Magento/Ui/view/base/web/js/form/provider.js @@ -4,12 +4,26 @@ */ define([ 'underscore', - 'uiComponent', + 'uiElement', './client' -], function (_, Component, Client) { +], function (_, Element, Client) { 'use strict'; - return Component.extend({ + return Element.extend({ + defaults: { + clientConfig: { + urls: { + save: '${ $.submit_url }', + beforeSave: '${ $.validate_url }' + } + } + }, + + /** + * Initializes provider component. + * + * @returns {Provider} Chainable. + */ initialize: function () { this._super() .initClient(); @@ -17,17 +31,23 @@ define([ return this; }, + /** + * Initializes client component. + * + * @returns {Provider} Chainable. + */ initClient: function () { - this.client = new Client({ - urls: { - beforeSave: this.validate_url, - save: this.submit_url - } - }); + this.client = new Client(this.clientConfig); return this; }, + /** + * Saves currently available data. + * + * @param {Object} [options] - Addtitional request options. + * @returns {Provider} Chainable. + */ save: function (options) { var data = this.get('data'); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/actions.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/actions.js index 091cd9ee2ea570a238e72a1a27cb9eb36d579322..e1bbb011db85044800729329c92a7810d42a11e3 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/actions.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/actions.js @@ -15,12 +15,17 @@ define([ return Column.extend({ defaults: { bodyTmpl: 'ui/grid/cells/actions', + sortable: false, + draggable: false, actions: [], rows: [], + rowsProvider: '${ $.parentName }', + fieldClass: { + 'data-grid-actions-cell': true + }, templates: { actions: {} }, - rowsProvider: '${ $.parentName }', imports: { rows: '${ $.rowsProvider }:rows' }, @@ -36,7 +41,7 @@ define([ */ initObservable: function () { this._super() - .observe('actions'); + .track('actions'); return this; }, @@ -50,7 +55,7 @@ define([ * @returns {Array|Object} */ getAction: function (rowIndex, actionIndex) { - var rowActions = this.actions()[rowIndex]; + var rowActions = this.actions[rowIndex]; return rowActions && actionIndex ? rowActions[actionIndex] : @@ -93,10 +98,7 @@ define([ * @returns {ActionsColumn} Chainable. */ updateActions: function () { - var rows = this.rows, - actions = rows.map(this._formatActions, this); - - this.actions(actions); + this.actions = this.rows.map(this._formatActions, this); return this; }, @@ -156,6 +158,34 @@ define([ return this; }, + /** + * Creates handler for the provided action if it's required. + * + * @param {Object} action - Action object. + * @returns {Function|Undefined} + */ + getActionHandler: function (action) { + var index = action.index, + rowIndex = action.rowIndex; + + if (this.isHandlerRequired(index, rowIndex)) { + return this.applyAction.bind(this, index, rowIndex); + } + }, + + /** + * Checks if specified action requires a handler function. + * + * @param {String} actionIndex - Actions' identifier. + * @param {Number} rowIndex - Index of a row. + * @returns {Boolean} + */ + isHandlerRequired: function (actionIndex, rowIndex) { + var action = this.getAction(rowIndex, actionIndex); + + return _.isObject(action.callback) || action.confirm || !action.href; + }, + /** * Creates action callback based on its' data. If action doesn't spicify * a callback function than the default one will be used. @@ -244,16 +274,13 @@ define([ }, /** - * Checks if specified action requires a handler function. + * Overrides base method, because this component + * can't have global field action. * - * @param {String} actionIndex - Actions' identifier. - * @param {Number} rowIndex - Index of a row. - * @returns {Boolean} + * @returns {Boolean} False. */ - isHandlerRequired: function (actionIndex, rowIndex) { - var action = this.getAction(rowIndex, actionIndex); - - return _.isObject(action.callback) || action.confirm || !action.href; + hasFieldAction: function () { + return false; } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/column.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/column.js index 06ee7dea8c3f30da8b76d9d8408ea8c2e3526e23..0d113fdbae53f4ad2b7a84cc8ef2b22bc6bfb391 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/column.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/column.js @@ -6,25 +6,27 @@ define([ 'underscore', 'uiRegistry', 'mageUtils', - 'uiComponent' -], function (_, registry, utils, Component) { + 'uiElement' +], function (_, registry, utils, Element) { 'use strict'; - return Component.extend({ + return Element.extend({ defaults: { headerTmpl: 'ui/grid/columns/text', bodyTmpl: 'ui/grid/cells/text', disableAction: false, + controlVisibility: true, sortable: true, sorting: false, visible: true, draggable: true, + fieldClass: {}, ignoreTmpls: { fieldAction: true }, - links: { - visible: '${ $.storageConfig.path }.visible', - sorting: '${ $.storageConfig.path }.sorting' + statefull: { + visible: true, + sorting: true }, imports: { exportSorting: 'sorting' @@ -37,6 +39,18 @@ define([ } }, + /** + * Initializes column component. + * + * @returns {Column} Chainable. + */ + initialize: function () { + this._super() + .initFieldClass(); + + return this; + }, + /** * Initializes observable properties. * @@ -44,7 +58,27 @@ define([ */ initObservable: function () { this._super() - .observe('visible dragging dragover sorting disableAction'); + .track([ + 'visible', + 'sorting', + 'disableAction' + ]) + .observe([ + 'dragging' + ]); + + return this; + }, + + /** + * Extends list of field classes. + * + * @returns {Column} Chainable. + */ + initFieldClass: function () { + _.extend(this.fieldClass, { + _dragging: this.dragging + }); return this; }, @@ -54,7 +88,7 @@ define([ * * @param {String} state - Defines what state should be used: saved or default. * @param {String} [property] - Defines what columns' property should be applied. - * If not specfied, then all columns stored properties will be used. + * If not specified, then all columns stored properties will be used. * @returns {Column} Chainable. */ applyState: function (state, property) { @@ -64,7 +98,7 @@ define([ namespace += '.' + property; } - this.storage('applyState', state, namespace); + this.storage('applyStateOf', state, namespace); return this; }, @@ -78,47 +112,78 @@ define([ * @returns {Column} Chainable. */ sort: function (enable) { - var direction = false; - if (!this.sortable) { return this; } - if (enable !== false) { - direction = this.toggleDirection(); - } + enable !== false ? + this.toggleSorting() : + this.sorting = false; - this.sorting(direction); + return this; + }, + + /** + * Sets descending columns' sorting. + * + * @returns {Column} Chainable. + */ + sortDescending: function () { + if (this.sortable) { + this.sorting = 'desc'; + } return this; }, /** - * Exports sorting data to the dataProvider if - * sorting of a column is enabled. + * Sets ascending columns' sorting. * - * @param {(String|Boolean)} sorting - Columns' sorting state. + * @returns {Column} Chainable. */ - exportSorting: function (sorting) { - if (!sorting) { - return; + sortAscending: function () { + if (this.sortable) { + this.sorting = 'asc'; } - this.source('set', 'params.sorting', { - field: this.index, - direction: sorting - }); + return this; }, /** * Toggles sorting direction. * - * @returns {String} New direction. + * @returns {Column} Chainable. + */ + toggleSorting: function () { + this.sorting === 'asc' ? + this.sortDescending() : + this.sortAscending(); + + return this; + }, + + /** + * Checks if column is sorted. + * + * @returns {Boolean} + */ + isSorted: function () { + return !!this.sorting; + }, + + /** + * Exports sorting data to the dataProvider if + * sorting of a column is enabled. */ - toggleDirection: function () { - return this.sorting() === 'asc' ? - 'desc' : - 'asc'; + exportSorting: function () { + if (!this.sorting) { + return; + } + + this.source('set', 'params.sorting', { + field: this.index, + direction: this.sorting + }); }, /** @@ -151,7 +216,7 @@ define([ var action = this.fieldAction, callback; - if (!this.hasFieldAction() || this.disableAction()) { + if (!this.hasFieldAction() || this.disableAction) { return this; } @@ -169,12 +234,24 @@ define([ return this; }, + /** + * Returns field action handler if it was specified. + * + * @param {Object} record - Record object with which action is associated. + * @returns {Function|Undefined} + */ + getFieldHandler: function (record) { + if (this.hasFieldAction()) { + return this.applyFieldAction.bind(this, record._rowIndex); + } + }, + /** * Creates action callback based on its' data. * * @param {Object} action - Actions' object. * @returns {Function|Boolean} Callback function or false - * value if it was imposible create a callback. + * value if it was impossible create a callback. */ _getFieldCallback: function (action) { var args = action.params || [], @@ -198,11 +275,20 @@ define([ /** * Ment to preprocess data associated with a current columns' field. * - * @param {*} data - Data to be preprocessed. + * @param {Object} record - Data to be preprocessed. * @returns {String} */ - getLabel: function (data) { - return data; + getLabel: function (record) { + return record[this.index]; + }, + + /** + * Returns list of classes that should be applied to a field. + * + * @returns {Object} + */ + getFieldClass: function () { + return this.fieldClass; }, /** diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js index 90ace7d79af6ad4eb96d1c0bceb5140ccdc7afe1..19ac459e2dc476338683cc0cd350f7ee34927f28 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js @@ -15,24 +15,25 @@ define([ }, /** - * Initializes components' static properties. + * Overrides base method to normalize date format. * * @returns {DateColumn} Chainable. */ - initProperties: function () { + initConfig: function () { + this._super(); + this.dateFormat = utils.normalizeDate(this.dateFormat); - return this._super(); + return this; }, /** * Formats incoming date based on the 'dateFormat' property. * - * @param {String} date - Date to be formatted. * @returns {String} Formatted date. */ - getLabel: function (date) { - date = moment(date); + getLabel: function () { + var date = moment(this._super()); date = date.isValid() ? date.format(this.dateFormat) : diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js index b48f1c9ed8a35adc457b2f03b0190a2cb4d7c3d2..80ab7e814ae5cfcad6b2a15cd3646ea08cdad69c 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js @@ -13,14 +13,19 @@ define([ defaults: { headerTmpl: 'ui/grid/columns/multiselect', bodyTmpl: 'ui/grid/cells/multiselect', + controlVisibility: false, sortable: false, + draggable: false, menuVisible: false, excludeMode: false, allSelected: false, indetermine: false, - selected: [], disabled: [], + selected: [], excluded: [], + fieldClass: { + 'data-grid-checkbox-cell': true + }, actions: [{ value: 'selectAll', label: $t('Select All') @@ -195,10 +200,9 @@ define([ * @returns {Multiselect} Chainable. */ selectPage: function () { - var selected = _.difference( - _.union(this.selected(), this.getIds()), - this.disabled() - ); + var selected = _.union(this.selected(), this.getIds()); + + selected = _.difference(selected, this.disabled()); this.selected(selected); @@ -436,6 +440,16 @@ define([ return this; }, + /** + * Overrides base method, because this component + * can't have global field action. + * + * @returns {Boolean} False. + */ + hasFieldAction: function () { + return false; + }, + /** * Callback method to handle changes of selected items. * diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/onoff.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/onoff.js index 86647b88bd174dbf959f68a092448aef66cf42d2..407544fd2ccdc6d29b6324b6f91a08cfacc70bbb 100755 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/onoff.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/onoff.js @@ -14,6 +14,11 @@ define([ defaults: { headerTmpl: 'ui/grid/columns/onoff', bodyTmpl: 'ui/grid/cells/onoff', + fieldClass: { + 'admin__scope-old': true, + 'data-grid-onoff-cell': true, + 'data-grid-checkbox-cell': false + }, imports: { selectedData: '${ $.provider }:data.selectedData' }, diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js index f55a2efdd6311ec0078830eb1a50d37dc82bb3a5..afa8831e5105b4d2041ca04cc082fc776ac25409 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js @@ -3,32 +3,41 @@ * See COPYING.txt for license details. */ define([ + 'underscore', './column' -], function (Column) { +], function (_, Column) { 'use strict'; return Column.extend({ + + /*eslint-disable eqeqeq*/ /** * Retrieves label associated with a provided value. * - * @param {Array} values - Values of the option. * @returns {String} */ - getLabel: function (values) { + getLabel: function () { var options = this.options || [], - labels = []; + values = this._super(), + label = []; + + if (!Array.isArray(values)) { + values = [values]; + } - values = values || []; + values = values.map(function (value) { + return value + ''; + }); - /*eslint-disable eqeqeq*/ options.forEach(function (item) { - if(values.indexOf(item.value) > -1) { - labels.push(item.label); + if (_.contains(values, item.value + '')) { + label.push(item.label); } }); - /*eslint-enable eqeqeq*/ - return labels.join(', '); + return label.join(', '); } + + /*eslint-enable eqeqeq*/ }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/thumbnail.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/thumbnail.js index 11455b30680706bf4d2ef578da5d45aa301fdbff..ef46cfc712452990de66364fd540322157ec662e 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/thumbnail.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/thumbnail.js @@ -13,7 +13,10 @@ define([ return Column.extend({ defaults: { - bodyTmpl: 'ui/grid/cells/thumbnail' + bodyTmpl: 'ui/grid/cells/thumbnail', + fieldClass: { + 'data-grid-thumbnail-cell': true + } }, getSrc: function (row) { return row[this.index + '_src'] @@ -44,6 +47,11 @@ define([ innerScroll: true, modalClass: '_image-box', buttons: []}).trigger('openModal'); + }, + getFieldHandler: function (row) { + if (this.isPreviewAvailable()) { + return this.preview.bind(this, row); + } } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/bookmarks.js b/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/bookmarks.js index 8bd34bb57f6a29a6413a6405275506ca6fee1db8..02ab2b1ec167fccdf4003a4832f6c3cf8176aadf 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/bookmarks.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/bookmarks.js @@ -5,9 +5,10 @@ define([ 'underscore', 'mageUtils', + 'mage/translate', 'uiLayout', - 'uiComponent' -], function (_, utils, layout, Component) { + 'uiCollection' +], function (_, utils, $t, layout, Collection) { 'use strict'; /** @@ -26,27 +27,14 @@ define([ return path.join('.'); } - return Component.extend({ + return Collection.extend({ defaults: { template: 'ui/grid/controls/bookmarks/bookmarks', + viewTmpl: 'ui/grid/controls/bookmarks/view', + newViewLabel: $t('New View'), defaultIndex: 'default', activeIndex: 'default', hasChanges: false, - templates: { - view: { - parent: '${ $.$data.name }', - name: '${ $.$data.index }', - label: '${ $.$data.label }', - provider: '${ $.$data.provider }', - component: 'Magento_Ui/js/grid/controls/bookmarks/view' - }, - newView: { - label: 'New View', - index: '_${ Date.now() }', - editing: true, - isNew: true - } - }, storageConfig: { provider: '${ $.storageConfig.name }', name: '${ $.name }_storage', @@ -54,14 +42,14 @@ define([ }, views: { default: { - label: 'Default View', + label: $t('Default View'), index: 'default', editable: false } }, listens: { activeIndex: 'onActiveIndexChange', - activeView: 'checkChanges', + activeView: 'checkState', current: 'onStateChange' } }, @@ -72,9 +60,9 @@ define([ * @returns {Bookmarks} Chainable. */ initialize: function () { - utils.limit(this, 'saveSate', 2000); - utils.limit(this, '_defaultPolyfill', 1000); - utils.limit(this, 'checkChanges', 50); + utils.limit(this, 'checkState', 5); + utils.limit(this, 'saveState', 2000); + utils.limit(this, '_defaultPolyfill', 3000); this._super() .restore() @@ -91,7 +79,16 @@ define([ */ initObservable: function () { this._super() - .observe('activeView hasChanges'); + .track([ + 'hasChanges', + 'editing', + 'activeView', + 'customVisible', + 'customLabel' + ]) + .track({ + viewsArray: [] + }); return this; }, @@ -108,209 +105,436 @@ define([ }, /** - * Called when another element was added to the current component. + * Creates instances of a previously saved views. * - * @param {Object} elem - Instance of an element that was added. * @returns {Bookmarks} Chainable. */ - initElement: function (elem) { - var index = elem.index; + initViews: function () { + _.each(this.views, function (config) { + this.addView(config); + }, this); + + this.activeView = this.getActiveView(); + + return this; + }, + + /** + * Creates complete configuration for a view. + * + * @param {Object} [config] - Additional configuration object. + * @returns {Object} + */ + buildView: function (config) { + var view = { + label: this.newViewLabel, + index: '_' + Date.now(), + editable: true + }; + + utils.extend(view, config || {}); + + view.data = view.data || utils.copy(this.current); + view.value = view.label; + + this.observe.call(view, true, 'label value'); + + return view; + }, + + /** + * Creates instance of a view with a provided configuration. + * + * @param {Object} [config] - View configuration. + * @param {Boolean} [saveView=false] - Whether to save created view automatically or not. + * @param {Boolean} [applyView=false] - Whether to apply created view automatically or not. + * @returns {View} Created view. + */ + addView: function (config, saveView, applyView) { + var view = this.buildView(config), + index = view.index; - if (index === this.defaultIndex) { - this.defaultView = elem; + this.views[index] = view; + + if (saveView) { + this.saveView(index); } - if (index === this.activeIndex) { - this.activeView(elem); + if (applyView) { + this.applyView(index); } - elem.on({ - editing: this.onEditingChange.bind(this, elem) - }); + this.updateArray(); - return this._super(); + return view; }, /** - * Creates instances of a previously saved views. + * Removes specified view. * + * @param {String} index - Index of a view to be removed. * @returns {Bookmarks} Chainable. */ - initViews: function () { - var views = this.views, - active = _.findWhere(views, {index: this.activeIndex}); + removeView: function (index) { + var viewPath = this.getViewPath(index); - if (!active) { - this.activeIndex = this.defaultIndex; + if (this.isViewActive(index)) { + this.applyView(this.defaultIndex); } - _.each(views, this.createView, this); + this.endEdit(index) + .remove(viewPath) + .removeStored(viewPath) + .updateArray(); return this; }, /** - * Creates view with a provided data. + * Saves data of a specified view. * - * @param {Object} item - Data object that will be passed to a view instance. + * @param {String} index - Index of a view to be saved. * @returns {Bookmarks} Chainable. */ - createView: function (item) { - var data = _.extend({}, this, item), - child = utils.template(this.templates.view, data); + saveView: function (index) { + var viewPath = this.getViewPath(index); - _.extend(child, item); + this.updateViewLabel(index) + .endEdit(index) + .store(viewPath) + .checkState(); - if (this.activeIndex === item.index) { - child.active = true; - } + return this; + }, - layout([child]); + /** + * Sets specified view as active + * and applies its' state. + * + * @param {String} index - Index of a view to be applied. + * @returns {Bookmarks} Chainable. + */ + applyView: function (index) { + this.applyStateOf(index) + .set('activeIndex', index); return this; }, /** - * Creates new view instance. + * Updates data of a specified view if it's + * currently active and saves its' data. * + * @param {String} index - Index of a view. * @returns {Bookmarks} Chainable. */ - createNewView: function () { - var view = this.templates.newView; + updateAndSave: function (index) { + if (this.isViewActive(index)) { + this.updateActiveView(index); + } + + this.saveView(index); + + return this; + }, + + /** + * Returns instance of a specified view. + * + * @param {String} index - Index of a view to be retrieved. + * @returns {View} + */ + getView: function (index) { + return this.views[index]; + }, - view.data = this.current; + /** + * Returns instance of an active view. + * + * @returns {View} + */ + getActiveView: function () { + return this.views[this.activeIndex]; + }, - this.createView(view); + /** + * Checks if specified view is active. + * + * @param {String} index - Index of a view to be checked. + * @returns {Boolean} + */ + isViewActive: function (index) { + return this.activeView === this.getView(index); + }, + + /** + * Sets current state as a data of an active view. + * + * @returns {Bookmarks} Chainable. + */ + updateActiveView: function () { + this.setViewData(this.activeIndex, this.current); return this; }, /** - * Deletes specfied view. + * Replaces label a view with a provided one. + * If new label is not specified, then views' + * 'value' property will be taken. * - * @param {View} view - View to be deleted. + * @param {String} index - Index of a view. + * @param {String} [label=view.value] - New labels' value. * @returns {Bookmarks} Chainable. */ - removeView: function (view) { - if (view.active()) { - this.applyView(this.defaultIndex); - } + updateViewLabel: function (index, label) { + var view = this.getView(index), + current = view.label; - if (!view.isNew) { - this.removeStored('views.' + view.index); - } + label = (label || view.value).trim() || current; + label = this.uniqueLabel(label, current); - view.destroy(); + view.label = view.value = label; return this; }, /** - * Saves data of a specified view. + * Retrieves data of a specified view. * - * @param {View} view - View to be saved. - * @returns {Bookmarks} Chainable. + * @param {String} index - Index of a view whose data should be retrieved. + * @param {String} [property] - If not specified then whole views' data will be retrieved. + * @returns {Object} Views' data. */ - saveView: function (view) { - if (view.isNew || view.active()) { - view.setData(this.current); + getViewData: function (index, property) { + var view = this.getView(index), + data = view.data; - this.hasChanges(false); + if (property) { + data = utils.nested(data, property); } - this.store('views.' + view.index, view.exportView()); + return utils.copy(data); + }, - if (view.isNew) { - view.isNew = false; + /** + * Sets data to the specified view. + * + * @param {String} index - Index of a view whose data will be replaced. + * @param {Object} data - New view data. + * @returns {Bookmarks} Chainable. + */ + setViewData: function (index, data) { + var path = this.getViewPath(index) + '.data'; - view.active(true); - } + this.set(path, utils.copy(data)); return this; }, /** - * Activates specified view and applies its' data. + * Starts editing of a specified view. * - * @param {(View|String)} view - View to be applied. + * @param {String} index - Index of a view. * @returns {Bookmarks} Chainable. */ - applyView: function (view) { - if (typeof view === 'string') { - view = this.elems.findWhere({ - index: view - }); + editView: function (index) { + this.editing = index; + + return this; + }, + + /** + * Ends editing of specified view + * and restores its' label. + * + * @param {String} index - Index of a view. + * @returns {Bookmarks} Chainable. + */ + endEdit: function (index) { + var view; + + if (!this.isEditing(index)) { + return this; } - view.active(true); + index = index || this.editing; + view = this.getView(index); - this.activeView(view); - this.applyState('saved'); + view.value = view.label; + + this.editing = false; return this; }, /** - * Applies specified views' data on a current data object. + * Checks if specified view is in editing state. * - * @param {String} state - Defines what state shultd be used: default or saved. - * @param {String} [path] - Path to the property whose value - * will be inserted to a current data object. - * @returns {Bookmarks} Chainable. + * @param {String} index - Index of a view to be checked. + * @returns {Bollean} */ - applyState: function (state, path) { - var view, - value; + isEditing: function (index) { + return this.editing === index; + }, - view = state === 'default' ? - this.defaultView : - this.activeView(); + /** + * Generates label unique among present views, based + * on the incoming label pattern. + * + * @param {String} [label=this.newViewLabel] - Label pattern. + * @param {String} [exclude] + * @returns {String} + */ + uniqueLabel: function (label, exclude) { + var labels = _.pluck(this.views, 'label'), + hasParenth = _.last(label) === ')', + index = 2, + result, + suffix; - path = removeStateNs(path); - value = view.getData(path); + labels = _.without(labels, exclude); + result = label = label || this.newViewLabel; - if (!_.isUndefined(value)) { - path = path ? 'current.' + path : 'current'; + for (index = 2; _.contains(labels, result); index++) { + suffix = '(' + index + ')'; - this.set(path, value); + if (!hasParenth) { + suffix = ' ' + suffix; + } + + result = label + suffix; } + return result; + }, + + /** + * Applies state of a specified view, without + * making it active. + * + * @param {String} [state=this.activeIndex] + * @param {String} [property] + * @returns {Bookmarks} Chainable. + */ + applyStateOf: function (state, property) { + var index = state || this.activeIndex, + dataPath = removeStateNs(property), + viewData = this.getViewData(index, dataPath); + + dataPath = dataPath ? + 'current.' + dataPath : + 'current'; + + this.set(dataPath, viewData); + return this; }, /** - * Saves current data state. + * Saves current state. * * @returns {Bookmarks} Chainable. */ - saveSate: function () { + saveState: function () { this.store('current'); return this; }, /** - * Defines whether current state is different - * from a saved state of an active view. + * Applies state of an active view. + * + * @returns {Bookmarks} Chainable. + */ + resetState: function () { + this.applyStateOf(this.activeIndex); + + return this; + }, + + /** + * Checks if current state is different + * from the state of an active view. * * @returns {Bookmarks} Chainable. */ - checkChanges: function () { - var view = this.activeView(), - diff = utils.compare(view.getData(), this.current); + checkState: function () { + var viewData = this.getViewData(this.activeIndex), + diff = utils.compare(viewData, this.current); - this.hasChanges(!diff.equal); + this.hasChanges = !diff.equal; return this; }, /** - * Resets current state to a saved state of an active view. + * Returns path to the view instance, + * based on a provided index. + * + * @param {String} index - Index of a view. + * @returns {String} + */ + getViewPath: function (index) { + return 'views.' + index; + }, + + /** + * Updates the array of views. + * + * @returns {Bookmarks} Chainable + */ + updateArray: function () { + this.viewsArray = _.values(this.views); + + return this; + }, + + /** + * Shows custom view field and creates unique label for it. + * + * @returns {Bookmarks} Chainable. + */ + showCustom: function () { + this.customLabel = this.uniqueLabel(); + this.customVisible = true; + + return this; + }, + + /** + * Hides custom view field. * * @returns {Bookmarks} Chainable. */ - discardChanges: function () { - this.applyState('saved'); + hideCustom: function () { + this.customVisible = false; + + return this; + }, + + /** + * Checks if custom view field is visible. + * + * @returns {Boolean} + */ + isCustomVisible: function () { + return this.customVisible; + }, + + /** + * Creates new view instance with a label specified + * in a custom view field. + * + * @returns {Bookmarks} Chainable. + */ + applyCustom: function () { + var label = this.customLabel.trim(); + + this.hideCustom() + .addView({ + label: this.uniqueLabel(label) + }, true, true); return this; }, @@ -324,54 +548,37 @@ define([ * @returns {Bookmarks} Chainbale. */ _defaultPolyfill: function () { - var view = this.defaultView, - data = view.data; - - if (!_.size(data.items)) { - data.items = utils.copy(this.current); + var data = this.getViewData(this.defaultIndex); - this.store('views.' + view.index, view.exportView()); + if (!_.size(data)) { + this.setViewData(this.defaultIndex, this.current) + .saveView(this.defaultIndex); } this.defaultDefined = true; - this.checkChanges(); - return this; }, /** * Listener of the activeIndex property. - * - * @param {String} index - Index of the active view. */ - onActiveIndexChange: function (index) { - this.store('activeIndex') - .applyView(index); + onActiveIndexChange: function () { + this.activeView = this.getActiveView(); + + this.store('activeIndex'); }, /** - * Listens changes of a current data object. + * Listener of the activeIndex property. */ onStateChange: function () { - this.saveSate(); - - if (this.activeView()) { - this.checkChanges(); - } + this.checkState(); + this.saveState(); if (!this.defaultDefined) { this._defaultPolyfill(); } - }, - - /** - * Lsitens changes of the views' 'editing' property. - */ - onEditingChange: function (view, isEditing) { - if (!isEditing && view.isNew) { - this.removeView(view); - } } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/storage.js b/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/storage.js index ac0656ec5a4636d838f293fbd76f9c3e736de5ae..48d3e7fa73dac505e4da849a61f1b99d0ff1cc79 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/storage.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/storage.js @@ -5,8 +5,8 @@ define([ 'jquery', 'mageUtils', - 'Magento_Ui/js/lib/storage', - 'Magento_Ui/js/lib/class' + 'Magento_Ui/js/lib/core/storage', + 'uiClass' ], function ($, utils, storage, Class) { 'use strict'; diff --git a/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/view.js b/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/view.js deleted file mode 100644 index afd5d4276de442947da6755cf208f191268226d3..0000000000000000000000000000000000000000 --- a/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/view.js +++ /dev/null @@ -1,161 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'uiComponent', - 'mageUtils' -], function (Component, utils) { - 'use strict'; - - return Component.extend({ - defaults: { - template: 'ui/grid/controls/bookmarks/view', - value: '${ $.isNew ? "" : $.label }', - active: false, - editable: true, - editing: false, - isNew: false, - statesProvider: '${ $.parentName }', - exports: { - active: 'onActivate' - }, - listens: { - 'editing value': 'syncLabel', - '${ $.statesProvider }:activeIndex': 'onActiveChange' - }, - modules: { - states: '${ $.statesProvider }' - } - }, - - /** - * Initializes view component. - * - * @returns {View} Chainable. - */ - initialize: function () { - this._super(); - - this.data = { - label: this.label(), - items: this.data || {} - }; - - return this; - }, - - /** - * Creates observable properties. - * - * @returns {View} Chainable. - */ - initObservable: function () { - this._super() - .observe('active label value editing'); - - return this; - }, - - /** - * Retrieves copied views' data. - * - * @param {String} [path] - Path to the specific property. - * @returns {*} - */ - getData: function (path) { - var data = this.data.items; - - if (path) { - data = utils.nested(data, path); - } - - return utils.copy(data); - }, - - /** - * Replaces current data with a provided one. - * - * @param {Object} data - New data object. - * @returns {View} Chainable. - */ - setData: function (data) { - if (this.editable) { - this.set('data.items', utils.copy(data)); - } - - return this; - }, - - /** - * Sets new label. - * - * @returns {View} Chainable. - */ - syncLabel: function () { - var label = this.value(); - - label = label.trim() || this.data.label; - - this.label(label); - this.value(label); - - this.data.label = label; - - return this; - }, - - /** - * Sets 'editing' flag to true. - * - * @returns {View} Chainable. - */ - startEdit: function () { - this.editing(true); - - return this; - }, - - /** - * Sets 'editing' flag to false. - * - * @returns {View} Chainable. - */ - endEdit: function () { - this.editing(false); - - return this; - }, - - /** - * Returns views' data including 'label' and 'index' properties. - * - * @returns {Object} - */ - exportView: function () { - return { - index: this.index, - label: this.label(), - data: this.data.items - }; - }, - - /** - * Listener of the 'active' property. - */ - onActivate: function (active) { - if (active) { - this.states('set', 'activeIndex', this.index); - } - }, - - /** - * Listener of the collections' active index value. - */ - onActiveChange: function (index) { - if (index !== this.index) { - this.active(false); - } - } - }); -}); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/controls/columns.js b/app/code/Magento/Ui/view/base/web/js/grid/controls/columns.js index 4673bedd251f7a8b3ac778b40985bff8ed7a5eb0..9965231c535ef211cf963f71155b9a2fc83a3af0 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/controls/columns.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/controls/columns.js @@ -6,21 +6,18 @@ define([ 'underscore', 'mageUtils', 'mage/translate', - 'uiComponent' -], function (_, utils, $t, Component) { + 'uiCollection' +], function (_, utils, $t, Collection) { 'use strict'; - return Component.extend({ + return Collection.extend({ defaults: { template: 'ui/grid/controls/columns', minVisible: 1, maxVisible: 30, viewportSize: 18, - columnsData: { - container: 'elems' - }, imports: { - addColumns: '${ $.columnsData.provider }:${ $.columnsData.container }' + addColumns: '${ $.columnsData.provider }:elems' }, templates: { headerMsg: $t('${ $.visible } out of ${ $.total } visible') @@ -44,7 +41,7 @@ define([ * @returns {Columns} Chainable. */ cancel: function () { - this.elems.each('applyState', 'saved', 'visible'); + this.elems.each('applyState', '', 'visible'); return this; }, @@ -86,7 +83,7 @@ define([ isDisabled: function (elem) { var visible = this.countVisible(); - return elem.visible() ? + return elem.visible ? visible === this.minVisible : visible === this.maxVisible; }, diff --git a/app/code/Magento/Ui/view/base/web/js/grid/dnd.js b/app/code/Magento/Ui/view/base/web/js/grid/dnd.js index fbcffc466f1d01583e1b470799550a8afa78e7fe..0f10358bb7db1eeb987bcacde0b7d72bdf8198a2 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/dnd.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/dnd.js @@ -212,15 +212,19 @@ define([ return this; } + if (!ko.es5.isTracked(model, 'dragover')) { + model.track('dragover'); + } + this.columns.push(column); $(column).bindings({ css: { '_dragover-left': ko.computed(function () { - return model.dragover() === 'right'; + return model.dragover === 'right'; }), '_dragover-right': ko.computed(function () { - return model.dragover() === 'left'; + return model.dragover === 'left'; }) } }); @@ -468,7 +472,7 @@ define([ 'left' : 'right'; - getModel(dropArea.target).dragover(direction); + getModel(dropArea.target).dragover = direction; }, /** @@ -477,7 +481,7 @@ define([ * @param {Object} dropArea */ dragleave: function (dropArea) { - getModel(dropArea.target).dragover(false); + getModel(dropArea.target).dragover = false; }, /** @@ -511,7 +515,7 @@ define([ dragModel = getModel(dragArea.target); getModel(this.table).insertChild(dragModel, dropModel); - dropModel.dragover(false); + dropModel.dragover = false; }, /** diff --git a/app/code/Magento/Ui/view/base/web/js/grid/editing/bulk.js b/app/code/Magento/Ui/view/base/web/js/grid/editing/bulk.js index 9fd4e7e6795eea1f7fe8e4060d7de9c1fdd00cfe..9c259144b843816b20fd65f3c97937b466105171 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/editing/bulk.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/editing/bulk.js @@ -2,7 +2,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - + define([ 'underscore', 'mageUtils', @@ -50,7 +50,7 @@ define([ */ initObservable: function () { this._super() - .observe({ + .track({ hasData: false }); @@ -121,7 +121,7 @@ define([ var fields = _.keys(this.getData()), hasData = !!fields.length; - this.hasData(hasData); + this.hasData = hasData; if (!this.active()) { fields = []; diff --git a/app/code/Magento/Ui/view/base/web/js/grid/editing/client.js b/app/code/Magento/Ui/view/base/web/js/grid/editing/client.js index c5bcbeee459083799d6cf29f8b668132080c6370..6651a605f05a382298e96370efe2e4f9807d662b 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/editing/client.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/editing/client.js @@ -2,7 +2,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - + define([ 'jquery', 'underscore', diff --git a/app/code/Magento/Ui/view/base/web/js/grid/editing/editor-view.js b/app/code/Magento/Ui/view/base/web/js/grid/editing/editor-view.js index 9bd9d5318fef5db2c341e98c18abd6ad7bf211bc..64fa58ac17ce138bcdce42e7b5fffb0cc4efb41e 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/editing/editor-view.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/editing/editor-view.js @@ -25,11 +25,13 @@ define([ '<!-- /ko -->', rowTmpl: '<!-- ko with: _editor -->' + - '<!-- ko scope: formRecordName($index(), true) -->' + - '<!-- ko template: rowTmpl --><!-- /ko -->' + - '<!-- /ko -->' + - '<!-- ko if: isActive($index(), true) && isSingleEditing() -->' + - '<!-- ko template: rowButtonsTmpl --><!-- /ko -->' + + '<!-- ko if: isActive($row()._rowIndex, true) -->' + + '<!-- ko with: getRecord($row()._rowIndex, true) -->' + + '<!-- ko template: rowTmpl --><!-- /ko -->' + + '<!-- /ko -->' + + '<!-- ko if: isSingleEditing -->' + + '<!-- ko template: rowButtonsTmpl --><!-- /ko -->' + + '<!-- /ko -->' + '<!-- /ko -->' + '<!-- /ko -->' }, @@ -112,14 +114,18 @@ define([ * @returns {View} Chainable. */ initRow: function (row) { + var $editingRow; + $(row).extendCtx({ _editor: this.model }).bindings(this.rowBindings); - $(this.rowTmpl) + $editingRow = $(this.rowTmpl) .insertBefore(row) .applyBindings(row); + ko.utils.domNodeDisposal.addDisposeCallback(row, this.removeEditingRow.bind(this, $editingRow)); + return this; }, @@ -134,7 +140,10 @@ define([ return { visible: ko.computed(function () { - return !model.isActive(ctx.$index(), true); + var record = ctx.$row(), + index = record && record._rowIndex; + + return !model.isActive(index, true); }) }; }, @@ -154,6 +163,15 @@ define([ }) } }; + }, + + /** + * Removes specified array of nodes. + * + * @param {ArrayLike} row + */ + removeEditingRow: function (row) { + _.toArray(row).forEach(ko.removeNode); } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/editing/editor.js b/app/code/Magento/Ui/view/base/web/js/grid/editing/editor.js index 5bfde4f5705513ebf8c30a27ff5a88e245b1ecff..38c36ae137bd0516a3fd10fca983e1a5bd2ef66b 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/editing/editor.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/editing/editor.js @@ -8,17 +8,16 @@ define([ 'mageUtils', 'uiLayout', 'mage/translate', - 'uiComponent' -], function (_, utils, layout, $t, Component) { + 'uiCollection' +], function (_, utils, layout, $t, Collection) { 'use strict'; - return Component.extend({ + return Collection.extend({ defaults: { rowButtonsTmpl: 'ui/grid/editing/row-buttons', headerButtonsTmpl: 'ui/grid/editing/header-buttons', successMsg: $t('You have successfully saved your edits.'), errorsCount: 0, - canSave: true, isMultiEditing: false, isSingleEditing: false, rowsData: [], @@ -91,14 +90,14 @@ define([ */ initObservable: function () { this._super() - .observe([ - 'canSave', + .track([ 'errorsCount', 'isMultiEditing', 'isSingleEditing' ]) .observe({ - active: [], + canSave: true, + activeRecords: [], messages: [] }); @@ -253,7 +252,7 @@ define([ * @returns {Editor} Chainable. */ hide: function () { - this.active.each('active', false); + this.activeRecords.each('active', false); return this; }, @@ -304,7 +303,7 @@ define([ * @returns {Array} An array of records and theirs validation results. */ validate: function () { - return this.active.map(function (record) { + return this.activeRecords.map(function (record) { return { target: record, valid: record.isValid() @@ -327,7 +326,7 @@ define([ * @returns {Object} Collection of records data. */ getData: function () { - var data = this.active.map('getData'); + var data = this.activeRecords.map('getData'); return _.indexBy(data, this.indexField); }, @@ -340,7 +339,7 @@ define([ * @returns {Editor} Chainable. */ setData: function (data, partial) { - this.active.each('setData', data, partial); + this.activeRecords.each('setData', data, partial); return this; }, @@ -457,7 +456,7 @@ define([ isActive: function (id, isIndex) { var record = this.getRecord(id, isIndex); - return record && record.active(); + return _.contains(this.activeRecords(), record); }, /** @@ -466,7 +465,7 @@ define([ * @returns {Boolean} */ hasActive: function () { - return !!this.active().length; + return !!this.activeRecords().length; }, /** @@ -475,7 +474,7 @@ define([ * @returns {Number} */ countActive: function () { - return this.active().length; + return this.activeRecords().length; }, /** @@ -486,11 +485,11 @@ define([ countErrors: function () { var errorsCount = 0; - this.active.each(function (record) { - errorsCount += record.errorsCount(); + this.activeRecords.each(function (record) { + errorsCount += record.errorsCount; }); - this.errorsCount(errorsCount); + this.errorsCount = errorsCount; return errorsCount; }, @@ -516,10 +515,10 @@ define([ columns.each('disableAction', !!activeCount); - this.isMultiEditing(activeCount > 1); - this.isSingleEditing(activeCount === 1); + this.isMultiEditing = activeCount > 1; + this.isSingleEditing = activeCount === 1; - this.active(active); + this.activeRecords(active); return this; }, diff --git a/app/code/Magento/Ui/view/base/web/js/grid/editing/record.js b/app/code/Magento/Ui/view/base/web/js/grid/editing/record.js index a6ba6aca19bb2d537f497622883a724cc1a9854a..15baff272c94cf5849a123493af00c4f6b33b0bf 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/editing/record.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/editing/record.js @@ -7,11 +7,11 @@ define([ 'underscore', 'mageUtils', 'uiLayout', - 'uiComponent' -], function (_, utils, layout, Component) { + 'uiCollection' +], function (_, utils, layout, Collection) { 'use strict'; - return Component.extend({ + return Collection.extend({ defaults: { active: true, hasChanges: false, @@ -79,7 +79,8 @@ define([ */ initObservable: function () { this._super() - .observe('active fields errorsCount hasChanges'); + .track('errorsCount hasChanges') + .observe('active fields'); return this; }, @@ -119,19 +120,18 @@ define([ var fields = this.templates.fields, field = column.editor; - if (typeof field === 'object' && field.editorType) { + if (_.isObject(field) && field.editorType) { field = utils.extend({}, fields[field.editorType], field); - } else if (typeof field == 'string') { + } else if (_.isString(field)) { field = fields[field]; } field = utils.extend({}, fields.base, field); - field = utils.template(field, { + + return utils.template(field, { record: this, column: column }, true, true); - - return field; }, /** @@ -142,7 +142,7 @@ define([ */ createFields: function (columns) { columns.forEach(function (column) { - if (column.editor && !this.getField(column.index)) { + if (column.editor && !this.hasChild(column.index)) { this.initField(column); } }, this); @@ -150,18 +150,6 @@ define([ return this; }, - /** - * Returns instance of a field found by provided identifier. - * - * @param {String} index - Identifier of a field inside record. - * @returns {Object} - */ - getField: function (index) { - return this.elems.findWhere({ - index: index - }); - }, - /** * Returns instance of a column found by provided index. * @@ -169,7 +157,7 @@ define([ * @returns {Column} */ getColumn: function (index) { - return this.columns().getColumn(index); + return this.columns().getChild(index); }, /** @@ -292,7 +280,7 @@ define([ countErrors: function () { var errorsCount = this.elems.filter('error').length; - this.errorsCount(errorsCount); + this.errorsCount = errorsCount; return errorsCount; }, @@ -320,7 +308,7 @@ define([ var fields; fields = this.columns().elems.map(function (column) { - return this.getField(column.index) || column; + return this.getChild(column.index) || column; }, this); this.fields(fields); @@ -336,7 +324,7 @@ define([ updateState: function () { var diff = this.checkChanges(); - this.hasChanges(!diff.equal); + this.hasChanges = !diff.equal; return this; }, diff --git a/app/code/Magento/Ui/view/base/web/js/grid/export.js b/app/code/Magento/Ui/view/base/web/js/grid/export.js index 032f5fcc36717432c9a8c0f08a41d7f9c42f5d13..cbc99b0319e818307e78c1d0bc5095f8c2de535f 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/export.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/export.js @@ -5,12 +5,11 @@ define([ 'jquery', 'underscore', - 'uiComponent' -], function ($, _, Component) { + 'uiElement' +], function ($, _, Element) { 'use strict'; - return Component.extend({ - + return Element.extend({ defaults: { template: 'ui/grid/exportButton', checked: '', diff --git a/app/code/Magento/Ui/view/base/web/js/grid/filters/chips.js b/app/code/Magento/Ui/view/base/web/js/grid/filters/chips.js index a31b1fd2d50ad971f39ad8f4644d7bdb361cd095..e7617aadf955b5854f33505e4adecb83814c67cf 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/filters/chips.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/filters/chips.js @@ -3,11 +3,12 @@ * See COPYING.txt for license details. */ define([ - 'uiComponent' -], function (Component) { + 'underscore', + 'uiCollection' +], function (_, Collection) { 'use strict'; - return Component.extend({ + return Collection.extend({ defaults: { template: 'ui/grid/filters/chips', stickyTmpl: 'ui/grid/sticky/chips' @@ -18,9 +19,9 @@ define([ * * @returns {Boolean} */ - hasData: function () { + hasPreviews: function () { return this.elems().some(function (elem) { - return !!elem.previews().length; + return !!elem.previews.length; }); }, @@ -30,7 +31,7 @@ define([ * @returns {Chips} Chainable. */ clear: function () { - this.elems.each('clear'); + _.invoke(this.elems(), 'clear'); return this; } diff --git a/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js b/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js index e90dfd5984189c933635261bcfbf9d17da9dcbe8..d58e7895654517d1a749da6ee09b34eef4bca708 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js @@ -6,8 +6,8 @@ define([ 'underscore', 'mageUtils', 'uiLayout', - 'uiComponent' -], function (_, utils, layout, Component) { + 'uiCollection' +], function (_, utils, layout, Collection) { 'use strict'; /** @@ -34,32 +34,69 @@ define([ return utils.mapRecursive(data, utils.removeEmptyValues.bind(utils)); } - return Component.extend({ + return Collection.extend({ defaults: { template: 'ui/grid/filters/filters', stickyTmpl: 'ui/grid/sticky/filters', + _processed: [], applied: { placeholder: true }, filters: { placeholder: true }, + templates: { + filters: { + base: { + parent: '${ $.$data.filters.name }', + name: '${ $.$data.column.index }', + provider: '${ $.$data.filters.name }', + dataScope: '${ $.$data.column.index }', + label: '${ $.$data.column.label }', + imports: { + visible: '${ $.$data.column.name }:visible' + } + }, + text: { + component: 'Magento_Ui/js/form/element/abstract', + template: 'ui/grid/filters/elements/input' + }, + select: { + component: 'Magento_Ui/js/form/element/select', + template: 'ui/grid/filters/elements/select', + options: '${ JSON.stringify($.$data.column.options) }', + caption: ' ' + }, + dateRange: { + component: 'Magento_Ui/js/grid/filters/range', + rangeType: 'date' + }, + textRange: { + component: 'Magento_Ui/js/grid/filters/range', + rangeType: 'text' + } + } + }, chipsConfig: { name: '${ $.name }_chips', provider: '${ $.chipsConfig.name }', component: 'Magento_Ui/js/grid/filters/chips' }, listens: { - active: 'extractPreviews', - applied: 'cancel extractActive' + active: 'updatePreviews', + applied: 'cancel updateActive' }, - links: { - applied: '${ $.storageConfig.path }' + statefull: { + applied: true }, exports: { applied: '${ $.provider }:params.filters' }, + imports: { + 'onColumnsUpdate': '${ $.columnsProvider }:elems' + }, modules: { + columns: '${ $.columnsProvider }', chips: '${ $.chipsConfig.provider }' } }, @@ -70,10 +107,11 @@ define([ * @returns {Filters} Chainable. */ initialize: function () { + _.bindAll(this, 'updateActive'); + this._super() .initChips() - .cancel() - .extractActive(); + .cancel(); return this; }, @@ -85,7 +123,7 @@ define([ */ initObservable: function () { this._super() - .observe({ + .track({ active: [], previews: [] }); @@ -107,13 +145,16 @@ define([ }, /** - * Called when another element was added to current component. + * Called when another element was added to filters collection. * * @returns {Filters} Chainable. */ - initElement: function () { - this._super() - .extractActive(); + initElement: function (elem) { + this._super(); + + elem.on('elems', this.updateActive); + + this.updateActive(); return this; }, @@ -121,15 +162,14 @@ define([ /** * Clears filters data. * - * @param {Object} [filter] - If provided, then only specified filter will be cleared. - * Otherwise, clears all data. - * + * @param {Object} [filter] - If provided, then only specified + * filter will be cleared. Otherwise, clears all data. * @returns {Filters} Chainable. */ clear: function (filter) { filter ? filter.clear() : - this.active.each('clear'); + _.invoke(this.active, 'clear'); this.apply(); @@ -158,6 +198,95 @@ define([ return this; }, + /** + * Sets provided data to filter components (without applying it). + * + * @param {Object} data - Filters data. + * @param {Boolean} [partial=false] - Flag that defines whether + * to completely replace current filters data or to extend it. + * @returns {Filters} Chainable. + */ + setData: function (data, partial) { + var filters = partial ? this.filters : {}; + + data = utils.extend({}, filters, data); + + this.set('filters', data); + + return this; + }, + + /** + * Creates instance of a filter associated with the provided column. + * + * @param {Column} column - Column component for which to create a filter. + * @returns {Filters} Chainable. + */ + addFilter: function (column) { + var index = column.index, + processed = this._processed, + filter; + + if (!column.filter || _.contains(processed, index)) { + return this; + } + + filter = this.buildFilter(column); + + processed.push(index); + + layout([filter]); + + return this; + }, + + /** + * Creates filter component configuration associated with the provided column. + * + * @param {Column} column - Column component whith a basic filter declaration. + * @returns {Object} Filters' configuration. + */ + buildFilter: function (column) { + var filters = this.templates.filters, + filter = column.filter, + type = filters[filter.filterType]; + + if (_.isObject(filter) && type) { + filter = utils.extend({}, type, filter); + } else if (_.isString(filter)) { + filter = filters[filter]; + } + + filter = utils.extend({}, filters.base, filter); + + return utils.template(filter, { + filters: this, + column: column + }, true, true); + }, + + /** + * Returns an array of range filters. + * + * @returns {Array} + */ + getRanges: function () { + return this.elems.filter(function (filter) { + return filter.isRange; + }); + }, + + /** + * Returns an array of non-range filters. + * + * @returns {Array} + */ + getPlain: function () { + return this.elems.filter(function (filter) { + return !filter.isRange; + }); + }, + /** * Tells wether specified filter should be visible. * @@ -175,7 +304,7 @@ define([ * @returns {Boolean} */ isFilterActive: function (filter) { - return this.active.contains(filter); + return _.contains(this.active, filter); }, /** @@ -193,24 +322,46 @@ define([ * * @returns {Filters} Chainable. */ - extractActive: function () { - this.active(this.elems.filter('hasData')); + updateActive: function () { + var applied = _.keys(this.applied); + + this.active = this.elems.filter(function (elem) { + return _.contains(applied, elem.index); + }); return this; }, + /** + * Returns number of applied filters. + * + * @returns {Number} + */ + countActive: function () { + return this.active.length; + }, + /** * Extract previews of a specified filters. * * @param {Array} filters - Filters to be processed. * @returns {Filters} Chainable. */ - extractPreviews: function (filters) { + updatePreviews: function (filters) { var previews = filters.map(extractPreview); - this.previews(_.compact(previews)); + this.previews = _.compact(previews); return this; + }, + + /** + * Listener of the columns provider children array changes. + * + * @param {Array} columns - Current columns list. + */ + onColumnsUpdate: function (columns) { + columns.forEach(this.addFilter, this); } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/filters/group.js b/app/code/Magento/Ui/view/base/web/js/grid/filters/group.js deleted file mode 100644 index 405436d7353c4179110c65b1329bc030b48c6a70..0000000000000000000000000000000000000000 --- a/app/code/Magento/Ui/view/base/web/js/grid/filters/group.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'underscore', - 'Magento_Ui/js/form/components/group' -], function (_, Group) { - 'use strict'; - - return Group.extend({ - defaults: { - template: 'ui/grid/filters/elements/group', - isGroup: true - }, - - reset: function () { - this.elems.each('reset'); - - return this; - }, - - clear: function () { - this.elems.each('clear'); - - return this; - }, - - hasData: function () { - return this.elems.some('hasData'); - }, - - getPreview: function () { - return this.elems.map('getPreview'); - } - }); -}); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/filters/range.js b/app/code/Magento/Ui/view/base/web/js/grid/filters/range.js new file mode 100644 index 0000000000000000000000000000000000000000..361d2db07139b0bae306671ceb0fe57f4067e0f5 --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/js/grid/filters/range.js @@ -0,0 +1,109 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'underscore', + 'uiLayout', + 'mageUtils', + 'Magento_Ui/js/form/components/group' +], function (_, layout, utils, Group) { + 'use strict'; + + return Group.extend({ + defaults: { + template: 'ui/grid/filters/elements/group', + isRange: true, + templates: { + base: { + parent: '${ $.$data.group.name }', + provider: '${ $.$data.group.provider }' + }, + date: { + component: 'Magento_Ui/js/form/element/date', + template: 'ui/grid/filters/elements/date', + dateFormat: 'MM/dd/YYYY' + }, + text: { + component: 'Magento_Ui/js/form/element/abstract', + template: 'ui/grid/filters/elements/input' + }, + ranges: { + from: { + label: 'from', + dataScope: 'from' + }, + to: { + label: 'to', + dataScope: 'to' + } + } + } + }, + + /** + * Initializes range component. + * + * @returns {Range} Chainable. + */ + initialize: function () { + this._super() + .initChildren(); + + return this; + }, + + /** + * Creates instances of child components. + * + * @returns {Range} Chainable. + */ + initChildren: function () { + var children = this.buildChildren(); + + layout(children); + + return this; + }, + + /** + * Creates configuration for the child components. + * + * @returns {Object} + */ + buildChildren: function () { + var templates = this.templates, + typeTmpl = templates[this.rangeType], + tmpl = utils.extend({}, templates.base, typeTmpl), + children = {}; + + _.each(templates.ranges, function (range, key) { + children[key] = utils.extend({}, tmpl, range); + }); + + return utils.template(children, { + group: this + }, true, true); + }, + + /** + * Clears childrens data. + * + * @returns {Range} Chainable. + */ + clear: function () { + this.elems.each('clear'); + + return this; + }, + + /** + * Checks if some children has data. + * + * @returns {Boolean} + */ + hasData: function () { + return this.elems.some('hasData'); + } + }); +}); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/listing.js b/app/code/Magento/Ui/view/base/web/js/grid/listing.js index 7ec985fcf76a53dc540a4cd020b5a339b8e9065e..5b68524bc698452e7afb5bb947c8b35e8ee8a48d 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/listing.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/listing.js @@ -4,21 +4,19 @@ */ define([ + 'ko', 'underscore', 'Magento_Ui/js/lib/spinner', 'uiLayout', - 'uiComponent' -], function (_, loader, layout, Component) { + 'uiCollection' +], function (ko, _, loader, layout, Collection) { 'use strict'; - return Component.extend({ + return Collection.extend({ defaults: { template: 'ui/grid/listing', stickyTmpl: 'ui/grid/sticky/listing', positions: false, - storageConfig: { - positions: '${ $.storageConfig.path }.positions' - }, dndConfig: { name: '${ $.name }_dnd', component: 'Magento_Ui/js/grid/dnd', @@ -36,18 +34,13 @@ define([ name: '${ $.name }_resize', columnsProvider: '${ $.name }', component: 'Magento_Ui/js/grid/resize', - provider: '${ $.provider }', - classResize: 'shadow-div', - divsAttrParams: { - 'data-cl-elem': 'shadow-div' - }, - enabled: true + enabled: false }, imports: { rows: '${ $.provider }:data.items' }, listens: { - elems: 'setPositions', + elems: 'updatePositions updateVisible', '${ $.provider }:reload': 'showLoader', '${ $.provider }:reloaded': 'hideLoader' }, @@ -63,19 +56,12 @@ define([ * @returns {Listing} Chainable. */ initialize: function () { - this._super(); - - if (this.resizeConfig.enabled) { - this.initResize(); - } - - if (this.dndConfig.enabled) { - this.initDnd(); - } + _.bindAll(this, 'updateVisible'); - if (this.editorConfig.enabled) { - this.initEditor(); - } + this._super() + .initDnd() + .initEditor() + .initResize(); return this; }, @@ -87,8 +73,9 @@ define([ */ initObservable: function () { this._super() - .observe({ - rows: [] + .track({ + rows: [], + visibleColumns: [] }); return this; @@ -100,18 +87,22 @@ define([ * @returns {Listing} Chainable. */ initDnd: function () { - layout([this.dndConfig]); + if (this.dndConfig.enabled) { + layout([this.dndConfig]); + } return this; }, /** - * Creates resize widget instance. + * Inititalizes resize component. * * @returns {Listing} Chainable. */ initResize: function () { - layout([this.resizeConfig]); + if (this.resizeConfig.enabled) { + layout([this.resizeConfig]); + } return this; }, @@ -122,7 +113,9 @@ define([ * @returns {Listing} Chainable. */ initEditor: function () { - layout([this.editorConfig]); + if (this.editorConfig.enabled) { + layout([this.editorConfig]); + } return this; }, @@ -132,7 +125,7 @@ define([ * * @returns {Listing} Chainable. */ - initElement: function () { + initElement: function (element) { var currentCount = this.elems().length, totalCount = this.initChildCount; @@ -140,6 +133,8 @@ define([ this.initPositions(); } + element.on('visible', this.updateVisible); + return this._super(); }, @@ -149,14 +144,9 @@ define([ * @returns {Listing} Chainable. */ initPositions: function () { - var link = { - positions: this.storageConfig.positions - }; - this.on('positions', this.applyPositions.bind(this)); - this.setLinks(link, 'imports') - .setLinks(link, 'exports'); + this.setStatefull('positions'); return this; }, @@ -166,7 +156,7 @@ define([ * * @returns {Listing} Chainable. */ - setPositions: function () { + updatePositions: function () { var positions = {}; this.elems.each(function (elem, index) { @@ -201,38 +191,34 @@ define([ }, /** - * Returns instance of a column found by provided identifier. + * Returns reference to 'visibleColumns' array. * - * @param {String} index - Columns' identifier. - * @returns {Column} + * @returns {Array} */ - getColumn: function (index) { - return this.elems.findWhere({ - index: index - }); - }, + getVisible: function () { + var observable = ko.getObservable(this, 'visibleColumns'); - /** - * Hides loader. - */ - hideLoader: function () { - loader.get(this.name).hide(); + return observable || this.visibleColumns; }, /** - * Shows loader. + * Returns total number of displayed columns in grid. + * + * @returns {Number} */ - showLoader: function () { - loader.get(this.name).show(); + countVisible: function () { + return this.visibleColumns.length; }, /** - * Returns total number of displayed columns in grid. + * Updates array of visible columns. * - * @returns {Number} + * @returns {Listing} Chainable. */ - countVisible: function () { - return this.elems.filter('visible').length; + updateVisible: function () { + this.visibleColumns = this.elems.filter('visible'); + + return this; }, /** @@ -241,7 +227,21 @@ define([ * @returns {Boolean} */ hasData: function () { - return !!this.rows().length; + return !!this.rows.length; + }, + + /** + * Hides loader. + */ + hideLoader: function () { + loader.get(this.name).hide(); + }, + + /** + * Shows loader. + */ + showLoader: function () { + loader.get(this.name).show(); } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/massactions.js b/app/code/Magento/Ui/view/base/web/js/grid/massactions.js index 2e9a39b2bddd261c83c889ff1f31de99836b9544..e2273b9a1f316b22e727d639eef394e1536d47bd 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/massactions.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/massactions.js @@ -18,7 +18,6 @@ define([ defaults: { template: 'ui/grid/actions', stickyTmpl: 'ui/grid/sticky/actions', - componentType: 'massaction', selectProvider: '', actions: [], noItemsMsg: $t('You haven\'t selected any items!'), diff --git a/app/code/Magento/Ui/view/base/web/js/grid/paging/paging.js b/app/code/Magento/Ui/view/base/web/js/grid/paging/paging.js index 3f8c6cd8a658c3d9f660897434d1ca026033247a..5605f8faf92417905549d02dff1ae239bad17202 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/paging/paging.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/paging/paging.js @@ -8,18 +8,17 @@ define([ 'underscore', 'mageUtils', 'uiLayout', - 'uiComponent' -], function (ko, _, utils, layout, Component) { + 'uiElement' +], function (ko, _, utils, layout, Element) { 'use strict'; - return Component.extend({ + return Element.extend({ defaults: { template: 'ui/grid/paging/paging', totalTmpl: 'ui/grid/paging-total', pageSize: 20, current: 1, selectProvider: '', - componentType: 'paging', sizesConfig: { component: 'Magento_Ui/js/grid/paging/sizes', @@ -38,13 +37,13 @@ define([ exports: { pageSize: '${ $.provider }:params.paging.pageSize', - current: '${ $.provider }:params.paging.current', - pages: '${ $.provider }:data.pages' + current: '${ $.provider }:params.paging.current' }, listens: { 'pages': 'onPagesChange', - 'pageSize totalRecords': 'countPages', + 'pageSize': 'onPageSizeChange', + 'totalRecords': 'updateCounter', '${ $.provider }:params.filters': 'goFirst' }, @@ -61,7 +60,7 @@ define([ initialize: function () { this._super() .initSizes() - .countPages(); + .updateCounter(); return this; }, @@ -73,17 +72,16 @@ define([ */ initObservable: function () { this._super() - .observe([ + .track([ 'totalSelected', 'totalRecords', 'pageSize', - 'current', 'pages', - 'options' + 'current' ]); this._current = ko.pureComputed({ - read: this.current, + read: ko.getObservable(this, 'current'), /** * Validates page change according to user's input. @@ -91,10 +89,8 @@ define([ * Calls reload method then. */ write: function (value) { - value = this.normalize(value); - - this.current(value); - this._current.notifySubscribers(value); + this.setPage(value) + ._current.notifySubscribers(this.current); }, owner: this @@ -121,7 +117,7 @@ define([ * @returns {Paging} Chainable. */ setPage: function (value) { - this.current(this.normalize(value)); + this.current = this.normalize(value); return this; }, @@ -132,7 +128,7 @@ define([ * @returns {Paging} Chainable. */ next: function () { - this.setPage(this.current() + 1); + this.setPage(this.current + 1); return this; }, @@ -143,7 +139,7 @@ define([ * @returns {Paging} Chainable. */ prev: function () { - this.setPage(this.current() - 1); + this.setPage(this.current - 1); return this; }, @@ -154,7 +150,7 @@ define([ * @returns {Paging} Chainable. */ goFirst: function () { - this.current(1); + this.current = 1; return this; }, @@ -165,7 +161,7 @@ define([ * @returns {Paging} Chainable. */ goLast: function () { - this.current(this.pages()); + this.current = this.pages; return this; }, @@ -176,7 +172,7 @@ define([ * @returns {Boolean} */ isFirst: function () { - return this.current() === 1; + return this.current === 1; }, /** @@ -185,7 +181,41 @@ define([ * @returns {Boolean} */ isLast: function () { - return this.current() === this.pages(); + return this.current === this.pages; + }, + + /** + * Updates number of pages. + */ + updateCounter: function () { + this.pages = Math.ceil(this.totalRecords / this.pageSize) || 1; + + return this; + }, + + /** + * Calculates new page cursor based on the + * previous and current page size values. + * + * @returns {Number} Updated cursor value. + */ + updateCursor: function () { + var cursor = this.current - 1, + size = this.pageSize, + oldSize = this.previousSize, + delta = cursor * (oldSize - size) / size; + + delta = size > oldSize ? + Math.ceil(delta) : + Math.floor(delta); + + cursor += delta + 1; + + this.previousSize = size; + + this.setPage(cursor); + + return this; }, /** @@ -196,37 +226,28 @@ define([ * @returns {Number} */ normalize: function (value) { - var total = this.pages(); - value = +value; if (isNaN(value)) { return 1; } - return utils.inRange(Math.round(value), 1, total); + return utils.inRange(Math.round(value), 1, this.pages); }, /** - * Calculates number of pages. + * Handles changes of the page size. */ - countPages: function () { - var pages = Math.ceil(this.totalRecords() / this.pageSize()); - - this.pages(pages || 1); + onPageSizeChange: function () { + this.updateCounter() + .updateCursor(); }, /** - * Listens changes of the 'pages' property. - * Might change current page if its' value - * is greater than total amount of pages. - * - * @param {Number} pages - Total amount of pages. + * Handles changes of the pages amount. */ - onPagesChange: function (pages) { - var current = this.current; - - current(utils.inRange(current(), 1, pages)); + onPagesChange: function () { + this.updateCursor(); } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/paging/sizes.js b/app/code/Magento/Ui/view/base/web/js/grid/paging/sizes.js index 62908da372266e90bba65a6f5c8dd368d42129c9..0354dd4517e8f220efb5ae9c86b4d221f7a7c616 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/paging/sizes.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/paging/sizes.js @@ -6,18 +6,16 @@ define([ 'ko', 'underscore', 'mageUtils', - 'uiComponent' -], function (ko, _, utils, Component) { + 'uiElement' +], function (ko, _, utils, Element) { 'use strict'; - return Component.extend({ + return Element.extend({ defaults: { template: 'ui/grid/paging/sizes', value: 20, minSize: 1, maxSize: 999, - customVisible: false, - customValue: '', options: { '20': { value: 20, @@ -40,10 +38,9 @@ define([ label: 200 } }, - optionsArray: [], - links: { - options: '${ $.storageConfig.path }.options', - value: '${ $.storageConfig.path }.value' + statefull: { + options: true, + value: true }, listens: { value: 'onValueChange', @@ -70,16 +67,18 @@ define([ */ initObservable: function () { this._super() - .observe([ - 'optionsArray', - 'editing', + .track([ 'value', + 'editing', 'customVisible', 'customValue' - ]); + ]) + .track({ + optionsArray: [] + }); this._value = ko.pureComputed({ - read: this.value, + read: ko.getObservable(this, 'value'), /** * Validates input field prior to updating 'value' property. @@ -87,7 +86,7 @@ define([ write: function (value) { value = this.normalize(value); - this.value(value); + this.value = value; this._value.notifySubscribers(value); }, @@ -104,7 +103,7 @@ define([ * @returns {Sizes} Chainable. */ edit: function (value) { - this.editing(value); + this.editing = value; return this; }, @@ -115,7 +114,7 @@ define([ * @returns {Sizes} Chainable. */ discardEditing: function () { - var value = this.editing(); + var value = this.editing; if (value) { this.updateSize(value, value); @@ -142,7 +141,7 @@ define([ * @returns {Number} */ getFirst: function () { - return this.optionsArray()[0].value; + return this.optionsArray[0].value; }, /** @@ -162,7 +161,7 @@ define([ * @returns {Sizes} Chainable. */ setSize: function (value) { - this.value(value); + this.value = value; return this; }, @@ -283,7 +282,7 @@ define([ * @returns {Sizes} Chainable. */ showCustom: function () { - this.customVisible(true); + this.customVisible = true; return this; }, @@ -294,7 +293,7 @@ define([ * @returns {Sizes} Chainable. */ hideCustom: function () { - this.customVisible(false); + this.customVisible = false; return this; }, @@ -305,7 +304,7 @@ define([ * @returns {Sizes} Chainable. */ clearCustom: function () { - this.customValue(''); + this.customValue = ''; return this; }, @@ -316,7 +315,7 @@ define([ * @returns {Sizes} Chainable. */ applyCustom: function () { - var value = this.customValue(); + var value = this.customValue; value = this.normalize(value); @@ -333,7 +332,7 @@ define([ * @returns {Boolean} */ isCustomVisible: function () { - return this.customVisible(); + return this.customVisible; }, /** @@ -361,9 +360,7 @@ define([ updateArray: function () { var array = _.values(this.options); - array = _.sortBy(array, 'value'); - - this.optionsArray(array); + this.optionsArray = _.sortBy(array, 'value'); return this; }, @@ -375,7 +372,7 @@ define([ * @returns {Boolean} */ isEditing: function (value) { - return this.editing() === value; + return this.editing === value; }, /** @@ -385,7 +382,7 @@ define([ * @returns {Boolean} */ isSelected: function (value) { - return this.value() === value; + return this.value === value; }, /** @@ -400,8 +397,9 @@ define([ * Listener of the 'options' object changes. */ onSizesChange: function () { - this.editing(false) - .updateArray(); + this.editing = false; + + this.updateArray(); } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/provider.js b/app/code/Magento/Ui/view/base/web/js/grid/provider.js index f665319bdc1671181c4b84efaa02211bdd7ae343..9232347df8337c34a52bde3e76597c6c9f9c830e 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/provider.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/provider.js @@ -7,13 +7,13 @@ define([ 'jquery', 'underscore', 'mageUtils', - 'uiComponent', + 'uiElement', 'Magento_Ui/js/modal/alert', 'mage/translate' -], function ($, _, utils, Component, alert, $t) { +], function ($, _, utils, Element, alert, $t) { 'use strict'; - return Component.extend({ + return Element.extend({ defaults: { listens: { params: 'reload' @@ -26,7 +26,7 @@ define([ * @returns {Provider} Chainable. */ initialize: function () { - utils.limit(this, 'reload', 200); + utils.limit(this, 'reload', 300); _.bindAll(this, 'onReload'); return this._super(); @@ -40,7 +40,7 @@ define([ initConfig: function () { this._super(); - _.extend(this.data, { + this.setData({ items: [], totalRecords: 0 }); @@ -48,20 +48,39 @@ define([ return this; }, + /** + * + * @param {Object} data + * @returns {Provider} Chainable. + */ + setData: function (data) { + data = this.processData(data); + + this.set('data', data); + + return this; + }, + /** * Reloads data with current parameters. */ reload: function () { this.trigger('reload'); - $.ajax({ - url: this.update_url, + if (this.request && this.request.readyState !== 4) { + this.request.abort(); + } + + this.request = $.ajax({ + url: this['update_url'], method: 'GET', data: this.get('params'), dataType: 'json' - }) - .error(this.onError) - .done(this.onReload); + }); + + this.request + .done(this.onReload) + .error(this.onError); }, /** @@ -83,7 +102,11 @@ define([ /** * Handles reload error. */ - onError: function () { + onError: function (xhr) { + if (xhr.statusText === 'abort') { + return; + } + alert({ content: $t('Something went wrong.') }); @@ -95,9 +118,7 @@ define([ * @param {Object} data - Retrieved data object. */ onReload: function (data) { - data = this.processData(data); - - this.set('data', data) + this.setData(data) .trigger('reloaded'); } }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/resize.js b/app/code/Magento/Ui/view/base/web/js/grid/resize.js index cef9cb707cf7d064cea50b21c89142009fb0c087..7f2b6cb26a0f4bca83c31f1a2fcb928941933ef5 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/resize.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/resize.js @@ -10,11 +10,11 @@ define([ 'mageUtils', 'uiRegistry', 'Magento_Ui/js/lib/ko/extender/bound-nodes', - 'uiComponent' -], function ($, ko, _, utils, registry, boundedNodes, Component) { + 'uiElement' +], function ($, ko, _, utils, registry, boundedNodes, Element) { 'use strict'; - return Component.extend({ + return Element.extend({ defaults: { rootSelector: '${ $.columnsProvider }:.admin__data-grid-wrap', tableSelector: '${ $.rootSelector } -> table.data-grid', @@ -37,6 +37,7 @@ define([ visibleClass: '_resize-visible', cellContentElement: 'div.data-grid-cell-content', minColumnWidth: 40, + layoutFixedPolyfillIterator: 0, windowResize: false, resizable: false, resizeConfig: { @@ -92,6 +93,12 @@ define([ $(window).resize(this.checkAfterResize); } + //TODO - Must be deleted when Firefox fixed problem with table-layout: fixed + //ticket to Firefox: https://bugs.webkit.org/show_bug.cgi?id=90068 + if (navigator.userAgent.search(/Firefox/) > -1) { + this._layoutFixedPolyfill(); + } + $(table).addClass(this.fixedLayoutClass); return this; @@ -224,21 +231,27 @@ define([ this.refreshLastColumn(column); this.preprocessingWidth(); - //TODO - Must be deleted when Firefox fixed problem with table-layout: fixed - //ticket to Firefox: https://bugs.webkit.org/show_bug.cgi?id=90068 - if (navigator.userAgent.search(/Firefox/) > -1) { - setTimeout(function () { - $(table).css('table-layout', 'auto'); - setTimeout(function () { - $(table).css('table-layout', 'fixed'); - }, 500); - }, 500); - } - model.on('visible', this.refreshLastColumn.bind(this, column)); model.on('visible', this.preprocessingWidth.bind(this)); }, + /** + * Hack for mozilla firefox + */ + _layoutFixedPolyfill: function () { + var self = this; + + setTimeout(function () { + if (self.layoutFixedPolyfillIterator < 20) { + $(window).resize(); + self.layoutFixedPolyfillIterator++; + self._layoutFixedPolyfill(); + } else { + return false; + } + }, 500); + }, + /** * Check element is resizable or not * and append resizable element to DOM @@ -531,7 +544,7 @@ define([ nextElemData = this.hasColumn(nextElemModel, false, true); if (nextElemData) { - if (nextElemModel.visible()) { + if (nextElemModel.visible) { return nextElemData; } diff --git a/app/code/Magento/Ui/view/base/web/js/grid/search/search.js b/app/code/Magento/Ui/view/base/web/js/grid/search/search.js index 71e0570311aea9a9b4144a51340504846d7acd38..88c6bf6e4490d1d2a025b0579f0093e666bbfcfa 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/search/search.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/search/search.js @@ -7,16 +7,19 @@ define([ 'uiLayout', 'mage/translate', 'mageUtils', - 'uiComponent' -], function (_, layout, $t, utils, Component) { + 'uiElement' +], function (_, layout, $t, utils, Element) { 'use strict'; - return Component.extend({ + return Element.extend({ defaults: { template: 'ui/grid/search/search', placeholder: $t('Search by keyword'), label: $t('Keyword'), value: '', + statefull: { + value: true + }, imports: { inputValue: 'value', updatePreview: 'value' @@ -24,9 +27,6 @@ define([ exports: { value: '${ $.provider }:params.search' }, - links: { - value: '${ $.storageConfig.path }' - }, modules: { chips: '${ $.chipsProvider }' } @@ -51,11 +51,8 @@ define([ */ initObservable: function () { this._super() - .observe([ - 'inputValue', - 'value' - ]) - .observe({ + .track('inputValue value') + .track({ previews: [] }); @@ -79,7 +76,7 @@ define([ * @returns {Search} Chainable. */ clear: function () { - this.value(''); + this.value = ''; return this; }, @@ -90,7 +87,7 @@ define([ * @returns {Search} Chainable. */ cancel: function () { - this.inputValue(this.value()); + this.inputValue = this.value; return this; }, @@ -103,10 +100,9 @@ define([ * @returns {Search} Chainable. */ apply: function (value) { - value = value || this.inputValue(); + value = value || this.inputValue; - this.value(value); - this.inputValue(value); + this.value = this.inputValue = value; return this; }, @@ -119,15 +115,15 @@ define([ updatePreview: function () { var preview = []; - if (this.value()) { + if (this.value) { preview.push({ elem: this, label: this.label, - preview: this.value() + preview: this.value }); } - this.previews(preview); + this.previews = preview; return this; } diff --git a/app/code/Magento/Ui/view/base/web/js/grid/sticky/sticky.js b/app/code/Magento/Ui/view/base/web/js/grid/sticky/sticky.js index e779851a9315625ebe3b60f5c09c8769098139d1..8daa9999633ac16af713551813a11e9128ecb522 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/sticky/sticky.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/sticky/sticky.js @@ -58,6 +58,7 @@ define([ 'initListingNode', 'initToolbarNode', 'initContainerNode', + 'initColumns', 'initStickyListingNode', 'initStickyToolbarNode', 'initLeftDataGridCap', @@ -89,7 +90,7 @@ define([ */ initObservable: function () { this._super() - .observe(['visible']); + .track('visible'); return this; }, @@ -104,7 +105,7 @@ define([ return; } this.listingNode = $(node); - this.columns = this.listingNode.find(this.columnSelector); + $.async(this.columnSelector, node, this.initColumns); }, /** @@ -155,6 +156,14 @@ define([ this.initRightDataGridCap); }, + /** + * Init columns (each time when amount of columns is changed) + * + */ + initColumns: function () { + this.columns = this.listingNode.find(this.columnSelector); + }, + /** * Init left DataGridCap * @@ -237,7 +246,7 @@ define([ this.checkPos(); } - if (this.visible()) { + if (this.visible) { this.checkTableElemsWidth(); if (this.flags.originalWidthChanged) { @@ -364,13 +373,22 @@ define([ return this.otherStickyElsSize; }, + /** + * Get original bulk row height, if is visible + * + * @returns {Number}. + */ + getBulkRowHeight: function () { + return this.listingNode.find(this.bulkRowSelector).filter(':visible').height(); + }, + /** * Get top Y coord of the sticky header * * @returns {Number}. */ getListingTopYCoord: function () { - var bulkRowHeight = (this.listingNode.find(this.bulkRowSelector) || {}).height(); + var bulkRowHeight = this.getBulkRowHeight(); return this.listingNode.find('tbody').offset().top - this.containerNode.height() - @@ -387,8 +405,8 @@ define([ var stickyTopCondition = this.getListingTopYCoord() - this.getOtherStickyElementsSize(), stickyBottomCondition = this.listingNode.offset().top + this.listingNode.height() - - $(window).scrollTop() - - (this.listingNode.find(this.bulkRowSelector) || {}).height() - + $(window).scrollTop() + + this.getBulkRowHeight() - this.getOtherStickyElementsSize(); return stickyTopCondition < 0 && stickyBottomCondition > 0; @@ -449,9 +467,12 @@ define([ */ resizeBulk: function () { var bulk = this.containerNode.find(this.bulkRowHeaderSelector)[0]; - if (bulk){ + + if (bulk) { $(bulk).innerWidth(this.getListingWidth()); } + + return this; }, /** @@ -542,7 +563,7 @@ define([ * @returns {Object} Chainable. */ toggleContainerVisibility: function () { - this.visible(!this.visible()); + this.visible = !this.visible; return this; }, @@ -553,7 +574,7 @@ define([ * @returns {Boolean} whether the visibility of the sticky header was toggled. */ checkPos: function () { - var isSticky = this.visible(), + var isSticky = this.visible, mustBeSticky = this.getMustBeSticky(), needChange = isSticky !== mustBeSticky; diff --git a/app/code/Magento/Ui/view/base/web/js/lib/component/core.js b/app/code/Magento/Ui/view/base/web/js/lib/component/core.js deleted file mode 100644 index 65eca7b967d7a31cb7ad750cd213ee051ad0898c..0000000000000000000000000000000000000000 --- a/app/code/Magento/Ui/view/base/web/js/lib/component/core.js +++ /dev/null @@ -1,184 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'underscore', - 'uiRegistry', - 'Magento_Ui/js/lib/storage' -], function (_, registry) { - 'use strict'; - - return { - defaults: { - template: 'ui/collection', - registerNodes: true, - ignoreTmpls: { - childDefaults: true - }, - storageConfig: { - provider: 'localStorage', - namespace: '${ $.name }', - path: '${ $.storageConfig.provider }:${ $.storageConfig.namespace }' - }, - modules: { - storage: '${ $.storageConfig.provider }' - }, - componentType: 'container' - }, - - /** - * Initializes component. - * - * @returns {Component} Chainable. - */ - initialize: function () { - this._super() - .initProperties() - .initObservable() - .initModules() - .initUnique() - .setListeners(this.listens) - .initLinks(); - - return this; - }, - - /** - * Defines various properties. - * - * @returns {Component} Chainable. - */ - initProperties: function () { - _.extend(this, { - source: registry.get(this.provider), - containers: [], - _elems: [] - }); - - return this; - }, - - /** - * Initializes observable properties. - * - * @returns {Component} Chainable. - */ - initObservable: function () { - this.observe({ - elems: [] - }); - - return this; - }, - - /** - * Initializes links between properties. - * - * @returns {Component} Chainbale. - */ - initLinks: function () { - this.setLinks(this.links, 'imports') - .setLinks(this.links, 'exports'); - - _.each({ - exports: this.exports, - imports: this.imports - }, this.setLinks, this); - - return this; - }, - - /** - * Parses 'modules' object and creates - * async wrappers on specified components. - * - * @returns {Component} Chainable. - */ - initModules: function () { - var modules = this.modules || {}; - - _.each(modules, function (component, property) { - this[property] = registry.async(component); - }, this); - - return this; - }, - - /** - * Initializes listeners of the unique property. - * - * @returns {Component} Chainable. - */ - initUnique: function () { - var update = this.onUniqueUpdate.bind(this), - uniqueNs = this.uniqueNs; - - this.hasUnique = this.uniqueProp && uniqueNs; - - if (this.hasUnique) { - this.source.on(uniqueNs, update, this.name); - } - - return this; - }, - - /** - * Called when current element was injected to another component. - * - * @param {Object} parent - Instance of a 'parent' component. - * @returns {Component} Chainable. - */ - initContainer: function (parent) { - this.containers.push(parent); - - return this; - }, - - /** - * Called when another element was added to current component. - * - * @param {Object} elem - Instance of an element that was added. - * @returns {Component} Chainable. - */ - initElement: function (elem) { - elem.initContainer(this); - - return this; - }, - - /** - * Returns path to components' template. - * @returns {String} - */ - getTemplate: function () { - return this.template; - }, - - /** - * Updates property specified in uniqueNs - * if components' unique property is set to 'true'. - * - * @returns {Component} Chainable. - */ - setUnique: function () { - var property = this.uniqueProp; - - if (this[property]()) { - this.source.set(this.uniqueNs, this.name); - } - - return this; - }, - - /** - * Callback which fires when property under uniqueNs has changed. - */ - onUniqueUpdate: function (name) { - var active = name === this.name, - property = this.uniqueProp; - - this[property](active); - } - }; -}); diff --git a/app/code/Magento/Ui/view/base/web/js/lib/component/main.js b/app/code/Magento/Ui/view/base/web/js/lib/component/main.js deleted file mode 100644 index a48220b0194dc4e8c41e1ed7af3e0a3c16f38cbc..0000000000000000000000000000000000000000 --- a/app/code/Magento/Ui/view/base/web/js/lib/component/main.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'mageUtils', - './core', - './links', - './manip', - './traversal', - './provider', - 'uiClass', - 'Magento_Ui/js/lib/ko/initialize' -], function (utils, core, links, manip, traversal, provider, Class) { - 'use strict'; - - var extenders; - - extenders = utils.extend({}, core, links, manip, traversal, provider); - - return Class.extend(extenders); -}); diff --git a/app/code/Magento/Ui/view/base/web/js/lib/component/manip.js b/app/code/Magento/Ui/view/base/web/js/lib/component/manip.js deleted file mode 100644 index 8bc3f881796a8d50ce31e9a59e44ff0f80fbb49c..0000000000000000000000000000000000000000 --- a/app/code/Magento/Ui/view/base/web/js/lib/component/manip.js +++ /dev/null @@ -1,197 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'ko', - 'underscore', - 'mageUtils', - 'uiRegistry' -], function (ko, _, utils, registry) { - 'use strict'; - - /** - * Removes non plain object items from the specfied array. - * - * @param {Array} container - Array whose value should be filtered. - * @returns {Array} - */ - function compact(container) { - return container.filter(utils.isObject); - } - - return { - /** - * Retrieves requested region. - * Creates region if it was not created yet - * - * @returns {ObservableArray}. - */ - getRegion: function (name) { - var regions = this.regions = this.regions || {}; - - if (!regions[name]) { - regions[name] = ko.observable([]); - } - - return regions[name]; - }, - - /** - * Replaces specified regions' data with a provided one. - * Creates region if it was not created yet. - * - * @param {Array} items - New regions' data. - * @param {String} name - Name of the region. - * @returns {Component} Chainable. - */ - updateRegion: function (items, name) { - var region = this.getRegion(name); - - region(items); - - return this; - }, - - /** - * Requests specified components to insert - * them into 'elems' array starting from provided position. - * - * @param {(String|Array)} elems - Name of the component to insert. - * @param {Number} [position=-1] - Position at which to insert elements. - * @returns {Component} Chainable. - */ - insertChild: function (elems, position) { - var container = this._elems, - insert = this._insert.bind(this), - update; - - if (!Array.isArray(elems)) { - elems = [elems]; - } - - elems.map(function (item) { - return item.elem ? - utils.insert(item.elem, container, item.position) : - utils.insert(item, container, position); - }).forEach(function (item) { - if (item === true) { - update = true; - } else if (_.isString(item)) { - registry.get(item, insert); - } else if (utils.isObject(item)) { - insert(item); - } - }); - - if (update) { - this._update(); - } - - return this; - }, - - /** - * Removes specified element from the 'elems' array. - * - * @param {Object} elem - Element to be removed. - * @returns {Component} Chainable. - */ - removeChild: function (elem) { - utils.remove(this._elems, elem); - this._update(); - - return this; - }, - - /** - * Destroys current instance along with all of its' children. - */ - destroy: function () { - this._dropHandlers() - ._clearData() - ._clearRefs(); - }, - - /** - * Removes events listeners. - * @private - * - * @returns {Component} Chainable. - */ - _dropHandlers: function () { - this.off(); - - this.source.off(this.name); - - return this; - }, - - /** - * Clears all data associated with component. - * @private - * - * @returns {Component} Chainable. - */ - _clearData: function () { - this.source.remove(this.dataScope); - this.source.remove('params.' + this.name); - - return this; - }, - - /** - * Removes all references to current instance and - * calls 'destroy' method on all of its' children. - * @private - * - * @returns {Component} Chainable. - */ - _clearRefs: function () { - registry.remove(this.name); - - this.containers.forEach(function (parent) { - parent.removeChild(this); - }, this); - - this.elems.each('destroy'); - - return this; - }, - - /** - * Inserts provided component into 'elems' array at a specified position. - * @private - * - * @param {Object} elem - Element to insert. - */ - _insert: function (elem) { - var index = this._elems.indexOf(elem.name); - - if (~index) { - this._elems[index] = elem; - } - - this._update() - .initElement(elem); - }, - - /** - * Synchronizes multiple elements arrays with a core '_elems' container. - * Performs elemets grouping by theirs 'displayArea' property. - * @private - * - * @returns {Component} Chainable. - */ - _update: function () { - var _elems = compact(this._elems), - grouped = _.groupBy(_elems, 'displayArea'); - - _.each(grouped, this.updateRegion, this); - - this.elems(_elems); - - return this; - } - }; -}); diff --git a/app/code/Magento/Ui/view/base/web/js/lib/component/provider.js b/app/code/Magento/Ui/view/base/web/js/lib/component/provider.js deleted file mode 100644 index c6c1c195186c775c19594040d632be143665fe89..0000000000000000000000000000000000000000 --- a/app/code/Magento/Ui/view/base/web/js/lib/component/provider.js +++ /dev/null @@ -1,193 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'ko', - 'underscore', - 'mageUtils' -], function (ko, _, utils) { - 'use strict'; - - /** - * Wrapper for ko.observable and ko.observableArray. - * Assignes one or another ko property to obj[key] - * - * @param {Object} obj - object to store property to - * @param {String} key - key - * @param {*} value - initial value of observable - */ - function observe(obj, key, value) { - var method = Array.isArray(value) ? 'observableArray' : 'observable'; - - if (_.isFunction(obj[key]) && !ko.isObservable(obj[key])) { - return; - } - - if (ko.isObservable(obj[key])) { - if (ko.isObservable(value)) { - value = value(); - } - - obj[key](value); - - return; - } - - obj[key] = ko[method](value); - } - - return { - /** - * Returns value of the nested property. - * - * @param {String} path - Path to the property. - * @returns {*} Value of the property. - */ - get: function (path) { - return utils.nested(this, path); - }, - - /** - * Sets provided value as a value of the specified nested property. - * Triggers changes notifications, if value has mutated. - * - * @param {String} path - Path to property. - * @param {*} value - New value of the property. - * @returns {Component} Chainable. - */ - set: function (path, value) { - var data = utils.nested(this, path), - diffs; - - if (!_.isFunction(data)) { - diffs = utils.compare(data, value, path); - - utils.nested(this, path, value); - - this._notify(diffs); - } else { - utils.nested(this, path, value); - } - - return this; - }, - - /** - * Removes nested property from the object. - * - * @param {String} path - Path to the property. - * @returns {Component} Chainable. - */ - remove: function (path) { - var data, - diffs; - - if (!path) { - return this; - } - - data = utils.nested(this, path); - - if (!_.isUndefined(data) && !_.isFunction(data)) { - diffs = utils.compare(data, undefined, path); - - utils.nestedRemove(this, path); - - this._notify(diffs); - } - - return this; - }, - - /** - * If 2 params passed, path is considered as key. - * Else, path is considered as object. - * Assignes props to this based on incoming params - * - * @param {(Object|String)} path - * @returns {Component} Chainable. - */ - observe: function (path) { - var type = typeof path; - - if (type === 'string') { - path = path.split(' '); - } - - if (Array.isArray(path)) { - path.forEach(function (key) { - observe(this, key, this[key]); - }, this); - } else if (type === 'object') { - _.each(path, function (value, key) { - observe(this, key, value); - }, this); - } - - return this; - }, - - /** - * - */ - _notify: function (diffs) { - diffs.changes.forEach(function (change) { - this.trigger(change.path, change.value, change); - }, this); - - _.each(diffs.containers, function (changes, name) { - var value = utils.nested(this, name); - - this.trigger(name, value, changes); - }, this); - }, - - /** - * - */ - restore: function () { - var ns = this.storageConfig.namespace, - storage = this.storage(); - - if (storage) { - utils.extend(this, storage.get(ns)); - } - - return this; - }, - - /** - * Stores value of the specified property in components' storage module. - * - * @param {String} property - * @param {*} [data=this[property]] - * @returns {Component} Chainable. - */ - store: function (property, data) { - var ns = this.storageConfig.namespace, - path = utils.fullPath(ns, property); - - data = data || this.get(property); - - this.storage('set', path, data); - - return this; - }, - - /** - * Removes stored property. - * - * @param {String} property - Property to be removed from storage. - * @returns {Component} Chainable. - */ - removeStored: function (property) { - var ns = this.storageConfig.namespace, - path = utils.fullPath(ns, property); - - this.storage('remove', path); - - return this; - } - }; -}); diff --git a/app/code/Magento/Ui/view/base/web/js/lib/component/traversal.js b/app/code/Magento/Ui/view/base/web/js/lib/component/traversal.js deleted file mode 100644 index cb17ce3e2de78d0120d14ef3078e23109080e088..0000000000000000000000000000000000000000 --- a/app/code/Magento/Ui/view/base/web/js/lib/component/traversal.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'underscore', - 'Magento_Ui/js/lib/events' -], function (_, EventsBus) { - 'use strict'; - - return _.extend({}, EventsBus, { - /** - * Tries to call specified method of a current component, - * otherwise delegates attempt to its' children. - * - * @param {String} target - Name of the method. - * @param [...] Arguments that will be passed to method. - * @returns {*} Result of the method calls. - */ - delegate: function (target) { - var args = _.toArray(arguments); - - target = this[target]; - - if (_.isFunction(target)) { - return target.apply(this, args.slice(1)); - } - - return this._delegate(args); - }, - - /** - * Calls 'delegate' method of all of it's children components. - * @private - * - * @param {Array} args - An array of arguments to pass to the next delegation call. - * @returns {Array} An array of delegation resutls. - */ - _delegate: function (args) { - var result; - - result = this.elems.map(function (elem) { - return elem.delegate.apply(elem, args); - }); - - return _.flatten(result); - }, - - /** - * Overrides 'EventsBus.trigger' method to implement events bubbling. - * - * @param {String} name - Name of the event. - * @param [...] Any number of arguments that should be to the events' handler. - * @returns {Boolean} False if event bubbling was canceled. - */ - bubble: function () { - var args = _.toArray(arguments), - bubble = this.trigger.apply(this, args), - result; - - if (!bubble) { - return false; - } - - this.containers.forEach(function (parent) { - result = parent.bubble.apply(parent, args); - - if (result === false) { - bubble = false; - } - }); - - return !!bubble; - } - }); -}); diff --git a/app/code/Magento/Ui/view/base/web/js/lib/class.js b/app/code/Magento/Ui/view/base/web/js/lib/core/class.js similarity index 87% rename from app/code/Magento/Ui/view/base/web/js/lib/class.js rename to app/code/Magento/Ui/view/base/web/js/lib/core/class.js index d118959bd26039f10444f59a31d05572991a6975..4aab2423cd593909d962b9316d8fea5747d4ec27 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/class.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/core/class.js @@ -20,7 +20,7 @@ define([ * @returns {*} Value of the property or false. */ function getOwn(obj, prop) { - return obj.hasOwnProperty(prop) && obj[prop]; + return _.isObject(obj) && obj.hasOwnProperty(prop) && obj[prop]; } /** @@ -34,13 +34,14 @@ define([ var constr = consturctor; if (!constr) { + /** * Default constructor function. */ constr = function () { var obj = this; - if (!obj || !Object.getPrototypeOf(obj) === constr.prototype || obj === window) { + if (!_.isObject(obj) || Object.getPrototypeOf(obj) !== constr.prototype) { obj = Object.create(constr.prototype); } @@ -57,6 +58,7 @@ define([ } Class = createConstructor({ + /** * Entry point to the initialization of consturctors' instance. * @@ -112,10 +114,10 @@ define([ parentProto = parent.prototype, childProto = Object.create(parentProto), child = createConstructor(childProto, getOwn(extender, 'constructor')), - defaults = extender.defaults || {}; + defaults; - defaults = defaults || {}; extender = extender || {}; + defaults = extender.defaults; delete extender.defaults; @@ -123,10 +125,16 @@ define([ childProto[name] = wrapper.wrapSuper(parentProto[name], method); }); + child.defaults = utils.extend({}, parent.defaults || {}); + + if (defaults) { + utils.extend(child.defaults, defaults); + extender.defaults = defaults; + } + return _.extend(child, { __super__: parentProto, - extend: parent.extend, - defaults: utils.extend({}, parent.defaults, defaults) + extend: parent.extend }); } diff --git a/app/code/Magento/Ui/view/base/web/js/lib/core/collection.js b/app/code/Magento/Ui/view/base/web/js/lib/core/collection.js new file mode 100644 index 0000000000000000000000000000000000000000..5cac8edb895d7b81447342aeac5f7a19a8225b30 --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/js/lib/core/collection.js @@ -0,0 +1,289 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'underscore', + 'mageUtils', + 'uiRegistry', + 'uiElement' +], function (_, utils, registry, Element) { + 'use strict'; + + /** + * Removes non plain object items from the specfied array. + * + * @param {Array} container - Array whose value should be filtered. + * @returns {Array} + */ + function compact(container) { + return container.filter(utils.isObject); + } + + return Element.extend({ + defaults: { + template: 'ui/collection', + _elems: [], + ignoreTmpls: { + childDefaults: true + } + }, + + /** + * Initializes observable properties. + * + * @returns {Model} Chainable. + */ + initObservable: function () { + this._super() + .observe({ + elems: [] + }); + + return this; + }, + + /** + * Called when another element was added to current component. + * + * @param {Object} elem - Instance of an element that was added. + * @returns {Collection} Chainable. + */ + initElement: function (elem) { + elem.initContainer(this); + + return this; + }, + + /** + * Returns instance of a child found by provided index. + * + * @param {String} index - Index of a child. + * @returns {Object} + */ + getChild: function (index) { + return _.findWhere(this.elems(), { + index: index + }); + }, + + /** + * Requests specified components to insert + * them into 'elems' array starting from provided position. + * + * @param {(String|Array)} elems - Name of the component to insert. + * @param {Number} [position=-1] - Position at which to insert elements. + * @returns {Collection} Chainable. + */ + insertChild: function (elems, position) { + var container = this._elems, + insert = this._insert.bind(this), + update; + + if (!Array.isArray(elems)) { + elems = [elems]; + } + + elems.map(function (item) { + return item.elem ? + utils.insert(item.elem, container, item.position) : + utils.insert(item, container, position); + }).forEach(function (item) { + if (item === true) { + update = true; + } else if (_.isString(item)) { + registry.get(item, insert); + } else if (utils.isObject(item)) { + insert(item); + } + }); + + if (update) { + this._updateCollection(); + } + + return this; + }, + + /** + * Removes specified child from collection. + * + * @param {(Object|String)} elem - Child or index of a child to be removed. + * @returns {Collection} Chainable. + */ + removeChild: function (elem) { + if (_.isString(elem)) { + elem = this.getChild(elem); + } + + if (elem) { + utils.remove(this._elems, elem); + this._updateCollection(); + } + + return this; + }, + + /** + * Checks if specified child exists in collection. + * + * @param {Sring} index - Index of a child. + * @returns {Boolean} + */ + hasChild: function (index) { + return !!this.getChild(index); + }, + + /** + * Creates 'async' wrapper for the specified child + * using uiRegistry 'async' method and caches it + * in a '_requested' components object. + * + * @param {String} index - Index of a child. + * @returns {Function} Async module wrapper. + */ + requestChild: function (index) { + var name = this.formChildName(index); + + return this.requestModule(name); + }, + + /** + * Creates complete child name based on a provided index. + * + * @param {String} index - Index of a child. + * @returns {String} + */ + formChildName: function (index) { + return this.name + '.' + index; + }, + + /** + * Retrieves requested region. + * Creates region if it was not created yet + * + * @returns {ObservableArray} + */ + getRegion: function (name) { + var regions = this.regions = this.regions || {}; + + if (!regions[name]) { + regions[name] = []; + + this.observe.call(regions, name); + } + + return regions[name]; + }, + + /** + * Replaces specified regions' data with a provided one. + * Creates region if it was not created yet. + * + * @param {Array} items - New regions' data. + * @param {String} name - Name of the region. + * @returns {Collection} Chainable. + */ + updateRegion: function (items, name) { + this.getRegion(name)(items); + + return this; + }, + + /** + * Destroys collection along with its' elements. + */ + destroy: function () { + this._super(); + + this.elems.each('destroy'); + }, + + /** + * Inserts provided component into 'elems' array at a specified position. + * @private + * + * @param {Object} elem - Element to insert. + */ + _insert: function (elem) { + var index = this._elems.indexOf(elem.name); + + if (~index) { + this._elems[index] = elem; + } + + this._updateCollection() + .initElement(elem); + }, + + /** + * Synchronizes multiple elements arrays with a core '_elems' container. + * Performs elemets grouping by theirs 'displayArea' property. + * @private + * + * @returns {Collection} Chainable. + */ + _updateCollection: function () { + var _elems = compact(this._elems), + grouped; + + grouped = _elems.filter(function (elem) { + return elem.displayArea && _.isString(elem.displayArea); + }); + grouped = _.groupBy(grouped, 'displayArea'); + + _.each(grouped, this.updateRegion, this); + + this.elems(_elems); + + return this; + }, + + /** + * Tries to call specified method of a current component, + * otherwise delegates attempt to its' children. + * + * @param {String} target - Name of the method. + * @param {...*} parameters - Arguments that will be passed to method. + * @returns {*} Result of the method calls. + */ + delegate: function (target) { + var args = _.toArray(arguments); + + target = this[target]; + + if (_.isFunction(target)) { + return target.apply(this, args.slice(1)); + } + + return this._delegate(args); + }, + + /** + * Calls 'delegate' method of all of it's children components. + * @private + * + * @param {Array} args - An array of arguments to pass to the next delegation call. + * @returns {Array} An array of delegation resutls. + */ + _delegate: function (args) { + var result; + + result = this.elems.map(function (elem) { + var target; + + if (!_.isFunction(elem.delegate)) { + target = elem[args[0]]; + + if (_.isFunction(target)) { + return target.apply(elem, args.slice(1)); + } + } else { + return elem.delegate.apply(elem, args); + } + }); + + return _.flatten(result); + } + }); +}); diff --git a/app/code/Magento/Ui/view/base/web/js/lib/core/element/element.js b/app/code/Magento/Ui/view/base/web/js/lib/core/element/element.js new file mode 100644 index 0000000000000000000000000000000000000000..4e83320b6b39224cf2d919e1e88520e665400cf0 --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/js/lib/core/element/element.js @@ -0,0 +1,573 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'ko', + 'underscore', + 'mageUtils', + 'uiRegistry', + 'uiEvents', + 'uiClass', + './links', + '../storage' +], function (ko, _, utils, registry, Events, Class, links) { + 'use strict'; + + var Element; + + /** + * Creates observable property using knockouts' + * 'observableArray' or 'observable' methods, + * depending on a type of 'value' parameter. + * + * @param {Object} obj - Object to whom property belongs. + * @param {String} key - Key of the property. + * @param {*} value - Initial value. + */ + function observable(obj, key, value) { + var method = Array.isArray(value) ? 'observableArray' : 'observable'; + + if (_.isFunction(obj[key]) && !ko.isObservable(obj[key])) { + return; + } + + if (ko.isObservable(value)) { + value = value(); + } + + ko.isObservable(obj[key]) ? + obj[key](value) : + obj[key] = ko[method](value); + } + + /** + * Creates observable propery using 'track' method. + * + * @param {Object} obj - Object to whom property belongs. + * @param {String} key - Key of the property. + * @param {*} value - Initial value. + */ + function accessor(obj, key, value) { + if (_.isFunction(obj[key]) || ko.isObservable(obj[key])) { + return; + } + + obj[key] = value; + + if (!ko.es5.isTracked(obj, key)) { + ko.track(obj, [key]); + } + } + + Element = _.extend({ + defaults: { + template: '', + containers: [], + _requesetd: {}, + registerNodes: true, + storageConfig: { + provider: 'localStorage', + namespace: '${ $.name }', + path: '${ $.storageConfig.provider }:${ $.storageConfig.namespace }' + }, + maps: { + imports: {}, + exports: {} + }, + modules: { + storage: '${ $.storageConfig.provider }' + } + }, + + /** + * Initializes model instance. + * + * @returns {Element} Chainable. + */ + initialize: function () { + this._super() + .initObservable() + .initModules() + .initStatefull() + .initLinks() + .initUnique(); + + return this; + }, + + /** + * Initializes observable properties. + * + * @returns {Element} Chainable. + */ + initObservable: function () { + return this; + }, + + /** + * Parses 'modules' object and creates + * async wrappers for specified components. + * + * @returns {Element} Chainable. + */ + initModules: function () { + var modules = this.modules || {}; + + _.each(modules, function (name, property) { + this[property] = this.requestModule(name); + }, this); + + if (!_.isFunction(this.source)) { + this.source = registry.get(this.provider); + } + + return this; + }, + + /** + * Called when current element was injected to another component. + * + * @param {Object} parent - Instance of a 'parent' component. + * @returns {Collection} Chainable. + */ + initContainer: function (parent) { + this.containers.push(parent); + + return this; + }, + + /** + * Initializes statefull properties + * based on the keys of 'statefull' object. + * + * @returns {Element} Chainable. + */ + initStatefull: function () { + var statefull = this.statefull || {}; + + _.each(statefull, function (path, key) { + if (!path) { + return; + } + + this.setStatefull(key, path); + }, this); + + return this; + }, + + /** + * Initializes links between properties. + * + * @returns {Element} Chainbale. + */ + initLinks: function () { + this.setListeners(this.listens) + .setLinks(this.links, 'imports') + .setLinks(this.links, 'exports'); + + _.each({ + exports: this.exports, + imports: this.imports + }, this.setLinks, this); + + return this; + }, + + /** + * Initializes listeners of the unique property. + * + * @returns {Element} Chainable. + */ + initUnique: function () { + var update = this.onUniqueUpdate.bind(this), + uniqueNs = this.uniqueNs; + + this.hasUnique = this.uniqueProp && uniqueNs; + + if (this.hasUnique) { + this.source.on(uniqueNs, update, this.name); + } + + return this; + }, + + /** + * Makes specified property to be stored automatically. + * + * @param {String} key - Name of the property + * that will be stored. + * @param {String} [path=key] - Path to the property in storage. + * @returns {Element} Chainable. + */ + setStatefull: function (key, path) { + var link = {}; + + path = !_.isString(path) || !path ? key : path; + link[key] = this.storageConfig.path + '.' + path; + + this.setLinks(link, 'imports') + .setLinks(link, 'exports'); + + return this; + }, + + /** + * Updates property specified in uniqueNs + * if elements' unique property is set to 'true'. + * + * @returns {Element} Chainable. + */ + setUnique: function () { + var property = this.uniqueProp; + + if (this[property]()) { + this.source.set(this.uniqueNs, this.name); + } + + return this; + }, + + /** + * Creates 'async' wrapper for the specified component + * using uiRegistry 'async' method and caches it + * in a '_requested' components object. + * + * @param {String} name - Name of requested component. + * @returns {Function} Async module wrapper. + */ + requestModule: function (name) { + var requested = this._requesetd; + + if (!requested[name]) { + requested[name] = registry.async(name); + } + + return requested[name]; + }, + + /** + * Returns path to elements' template. + * + * @returns {String} + */ + getTemplate: function () { + return this.template; + }, + + /** + * Checks if template was specified for an element. + * + * @returns {Boolean} + */ + hasTemplate: function () { + return !!this.template; + }, + + /** + * Returns value of the nested property. + * + * @param {String} path - Path to the property. + * @returns {*} Value of the property. + */ + get: function (path) { + return utils.nested(this, path); + }, + + /** + * Sets provided value as a value of the specified nested property. + * Triggers changes notifications, if value has mutated. + * + * @param {String} path - Path to property. + * @param {*} value - New value of the property. + * @returns {Element} Chainable. + */ + set: function (path, value) { + var data = this.get(path), + diffs; + + diffs = !_.isFunction(data) && !this.isTracked(path) ? + utils.compare(data, value, path) : + false; + + utils.nested(this, path, value); + + if (diffs) { + this._notifyChanges(diffs); + } + + return this; + }, + + /** + * Removes nested property from the object. + * + * @param {String} path - Path to the property. + * @returns {Element} Chainable. + */ + remove: function (path) { + var data = utils.nested(this, path), + diffs; + + if (_.isUndefined(data) || _.isFunction(data)) { + return this; + } + + diffs = utils.compare(data, undefined, path); + + utils.nestedRemove(this, path); + + this._notifyChanges(diffs); + + return this; + }, + + /** + * Creates observable properties for the current object. + * + * If 'useTrack' flag is set to 'true' then each property will be + * created with a ES5 get/set accessor descriptors, instead of + * making them an observable functions. + * See 'knockout-es5' library for more information. + * + * @param {Boolean} [useAccessors=false] - Whether to create an + * observable function or to use property accesessors. + * @param {(Object|String|Array)} properties - List of observable properties. + * @returns {Element} Chainable. + * + * @example Sample declaration and equivalent knockout methods. + * this.key = 'value'; + * this.array = ['value']; + * + * this.observe(['key', 'array']); + * => + * this.key = ko.observable('value'); + * this.array = ko.observableArray(['value']); + * + * @example Another syntaxes of the previous example. + * this.observe({ + * key: 'value', + * array: ['value'] + * }); + */ + observe: function (useAccessors, properties) { + var model = this, + trackMethod; + + if (typeof useAccessors !== 'boolean') { + properties = useAccessors; + useAccessors = false; + } + + trackMethod = useAccessors ? accessor : observable; + + if (_.isString(properties)) { + properties = properties.split(' '); + } + + if (Array.isArray(properties)) { + properties.forEach(function (key) { + trackMethod(model, key, model[key]); + }); + } else if (typeof properties === 'object') { + _.each(properties, function (value, key) { + trackMethod(model, key, value); + }); + } + + return this; + }, + + /** + * Delegates call to 'observe' method but + * with a predefined 'useAccessors' flag. + * + * @param {(String|Array|Object)} properties - List of observable properties. + * @returns {Element} Chainable. + */ + track: function (properties) { + this.observe(true, properties); + + return this; + }, + + /** + * Checks if specified property is tracked. + * + * @param {String} property - Property to be checked. + * @returns {Boolean} + */ + isTracked: function (property) { + return ko.es5.isTracked(this, property); + }, + + /** + * Invokes subscribers for the provided changes. + * + * @param {Object} diffs - Object with changes descriptions. + * @returns {Element} Chainable. + */ + _notifyChanges: function (diffs) { + diffs.changes.forEach(function (change) { + this.trigger(change.path, change.value, change); + }, this); + + _.each(diffs.containers, function (changes, name) { + var value = utils.nested(this, name); + + this.trigger(name, value, changes); + }, this); + + return this; + }, + + /** + * Extracts all stored data and sets it to element. + * + * @returns {Element} Chainable. + */ + restore: function () { + var ns = this.storageConfig.namespace, + storage = this.storage(); + + if (storage) { + utils.extend(this, storage.get(ns)); + } + + return this; + }, + + /** + * Stores value of the specified property in components' storage module. + * + * @param {String} property + * @param {*} [data=this[property]] + * @returns {Element} Chainable. + */ + store: function (property, data) { + var ns = this.storageConfig.namespace, + path = utils.fullPath(ns, property); + + if (arguments.length < 2) { + data = this.get(property); + } + + this.storage('set', path, data); + + return this; + }, + + /** + * Extracts specified property from storage. + * + * @param {String} [property] - Name of the property + * to be extracted. If not specified then all of the + * stored will be returned. + * @returns {*} + */ + getStored: function (property) { + var ns = this.storageConfig.namespace, + path = utils.fullPath(ns, property), + storage = this.storage(), + data; + + if (storage) { + data = storage.get(path); + } + + return data; + }, + + /** + * Removes stored property. + * + * @param {String} property - Property to be removed from storage. + * @returns {Element} Chainable. + */ + removeStored: function (property) { + var ns = this.storageConfig.namespace, + path = utils.fullPath(ns, property); + + this.storage('remove', path); + + return this; + }, + + /** + * Destroys current instance along with all of its' children. + */ + destroy: function () { + this._dropHandlers() + ._clearRefs(); + }, + + /** + * Removes events listeners. + * @private + * + * @returns {Element} Chainable. + */ + _dropHandlers: function () { + this.off(); + this.source.off(this.name); + + return this; + }, + + /** + * Removes all references to current instance and + * calls 'destroy' method on all of its' children. + * @private + * + * @returns {Element} Chainable. + */ + _clearRefs: function () { + registry.remove(this.name); + + this.containers.forEach(function (parent) { + parent.removeChild(this); + }, this); + + return this; + }, + + /** + * Overrides 'EventsBus.trigger' method to implement events bubbling. + * + * @param {...*} parameters - Any number of arguments that should be passed to the events' handler. + * @returns {Boolean} False if event bubbling was canceled. + */ + bubble: function () { + var args = _.toArray(arguments), + bubble = this.trigger.apply(this, args), + result; + + if (!bubble) { + return false; + } + + this.containers.forEach(function (parent) { + result = parent.bubble.apply(parent, args); + + if (result === false) { + bubble = false; + } + }); + + return !!bubble; + }, + + /** + * Callback which fires when property under uniqueNs has changed. + */ + onUniqueUpdate: function (name) { + var active = name === this.name, + property = this.uniqueProp; + + this[property](active); + } + }, Events, links); + + return Class.extend(Element); +}); diff --git a/app/code/Magento/Ui/view/base/web/js/lib/component/links.js b/app/code/Magento/Ui/view/base/web/js/lib/core/element/links.js similarity index 97% rename from app/code/Magento/Ui/view/base/web/js/lib/component/links.js rename to app/code/Magento/Ui/view/base/web/js/lib/core/element/links.js index 83e963dfcb2fce31ce493d626aea78758c054a63..c769be3775f46ddba47d5d9110974fc2bd5782da 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/component/links.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/core/element/links.js @@ -163,13 +163,6 @@ define([ } return { - defaults: { - maps: { - exports: {}, - imports: {} - } - }, - setListeners: function (listeners) { var owner = this, data; diff --git a/app/code/Magento/Ui/view/base/web/js/lib/events.js b/app/code/Magento/Ui/view/base/web/js/lib/core/events.js similarity index 89% rename from app/code/Magento/Ui/view/base/web/js/lib/events.js rename to app/code/Magento/Ui/view/base/web/js/lib/core/events.js index 5ef76cfa2ce998d3a7742b92ae59e2271998d61e..f5e086575527132319f2a8b5c0375f6f3ded0f4e 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/events.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/core/events.js @@ -38,11 +38,16 @@ define([ * @param {String} name - Name of the event. */ function addHandler(obj, ns, callback, name) { - var events = getEvents(obj), + var events = getEvents(obj), + observable, data; - if (ko.isObservable(obj[name])) { - obj[name].subscribe(callback); + observable = !ko.isObservable(obj[name]) ? + ko.getObservable(obj, name) : + obj[name]; + + if (observable) { + observable.subscribe(callback); return; } @@ -86,6 +91,7 @@ define([ } return { + /** * Calls callback when name event is triggered. * @param {String} events @@ -134,9 +140,10 @@ define([ }, /** - * Triggers event and executes all attached callbacks - * @param {String} name - * @return {Object} reference to this + * Triggers event and executes all attached callbacks. + * + * @param {String} name - Name of the event to be triggered. + * @returns {Boolean} */ trigger: function (name) { var handlers, diff --git a/app/code/Magento/Ui/view/base/web/js/lib/storage.js b/app/code/Magento/Ui/view/base/web/js/lib/core/storage.js similarity index 89% rename from app/code/Magento/Ui/view/base/web/js/lib/storage.js rename to app/code/Magento/Ui/view/base/web/js/lib/core/storage.js index a41bad442f11e4f417d1c0360458c76c1026d63a..62f87dcd432d2ddec9b8ba11b01442cc8a5e92d5 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/storage.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/core/storage.js @@ -6,19 +6,30 @@ define([ 'underscore', 'uiRegistry', 'mageUtils', - 'Magento_Ui/js/lib/events' + 'uiEvents' ], function (_, registry, utils, EventsBus) { 'use strict'; var root = 'appData', storage; + /** + * Extracts and parses data stored in localStorage by the + * key specified in 'root' varaible. + * + * @returns {Object} + */ function getRoot() { var data = localStorage.getItem(root); return !_.isNull(data) ? JSON.parse(data) : {}; } + /** + * Writes provided data to the localStorage. + * + * @param {*} data - Data to be stored. + */ function setRoot(data) { localStorage.setItem(root, JSON.stringify(data)); } @@ -28,6 +39,7 @@ define([ * as a single nested structure. */ storage = _.extend({ + /** * Retrieves value of the specified property. * diff --git a/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/after-render.js b/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/after-render.js index 2297f2d5cf1764d0198b791ec6011f3b2debf2b8..67a48c89a92a57de35bb95876bb9c8656a651c93 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/after-render.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/after-render.js @@ -8,6 +8,7 @@ define([ 'use strict'; ko.bindingHandlers.afterRender = { + /** * Binding init callback. */ diff --git a/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/autoselect.js b/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/autoselect.js new file mode 100644 index 0000000000000000000000000000000000000000..5a6207b4c5a113d9a857729924b6aecec4669f80 --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/autoselect.js @@ -0,0 +1,34 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'ko', + 'jquery' +], function (ko, $) { + 'use strict'; + + /** + * 'Focus' event handler. + * + * @param {EventObject} e + */ + function onFocus(e) { + e.target.select(); + } + + ko.bindingHandlers.autoselect = { + + /** + * Adds event handler which automatically + * selects inputs' element text when field gets focused. + */ + init: function (element, valueAccessor) { + var enabled = ko.unwrap(valueAccessor()); + + if (enabled !== false) { + $(element).on('focus', onFocus); + } + } + }; +}); diff --git a/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/class.js b/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/class.js deleted file mode 100644 index 8d3b6bbfbd02cf34ca83ad544b905a8dd225e989..0000000000000000000000000000000000000000 --- a/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/class.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'ko', - 'underscore' -], function(ko, _) { - 'use strict'; - - ko.bindingHandlers['class'] = { - /** - * @param {HTMLElement} element - Element, that binding is applied to - * @param {Function} valueAccessor - Function that returns value, passed to binding - */ - update: function (element, valueAccessor) { - var currentValue = ko.utils.unwrapObservable(valueAccessor()), - prevValue = element['__ko__previousClassValue__'], - - /** - * Helper for setting classes11 - * @param {Array|Object|String} singleValueOrArrayOrObject - * @param {Boolean} shouldHaveClass - */ - addOrRemoveClasses = function addOrRemoveClassesFn (singleValueOrArrayOrObject, shouldHaveClass) { - if (_.isArray(singleValueOrArrayOrObject)) { - ko.utils.arrayForEach(singleValueOrArrayOrObject, function (cssClass) { - var value = ko.utils.unwrapObservable(cssClass); - ko.utils.toggleDomNodeCssClass(element, value, shouldHaveClass); - }); - } else if (_.isObject(singleValueOrArrayOrObject)) { - _.each(singleValueOrArrayOrObject, function(classname, condition) { - if(ko.utils.unwrapObservable(condition)) { - ko.utils.toggleDomNodeCssClass(element, classname, shouldHaveClass); - } - }) - - } else if (singleValueOrArrayOrObject) { - ko.utils.toggleDomNodeCssClass(element, singleValueOrArrayOrObject, shouldHaveClass); - } - }; - - // Remove old value(s) (preserves any existing CSS classes) - addOrRemoveClasses(prevValue, false); - - // Set new value(s) - addOrRemoveClasses(currentValue, true); - - // Store a copy of the current value - element['__ko__previousClassValue__'] = currentValue.concat(); - } - }; -}); \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/scope.js b/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/scope.js index 2f9d78541d7ccb5ff2e7391fdec38e3e807e3abd..aae69f9fe18f5256b37f59709a1eece0fe6c5233 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/scope.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/scope.js @@ -1,13 +1,11 @@ /** - * @category storage - * @package test * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ /** Creates scope binding and registers in to ko.bindingHandlers object */ define([ 'ko', - 'Magento_Ui/js/lib/registry/registry', + 'uiRegistry', 'jquery', 'mage/translate' ], function (ko, registry, $) { @@ -15,30 +13,6 @@ define([ var i18n = $.mage.__; - /** - * Fetches components from registry and stores them to context object, then passes it to callback function. - * @param {Object} components - map, representing components to be attached to the new context. - * @param {Function} callback - Function to be called when components are fetched. - */ - function getMultiple(components, callback) { - var key, - paths = [], - context = {}; - - for (key in components) { - paths.push(components[key]); - } - - registry.get(paths, function () { - - for (key in components) { - context[key] = registry.get(components[key]); - } - - callback(context); - }); - } - /** * Creates child context with passed component param as $data. Extends context with $t helper. * Applies bindings to descendant nodes. @@ -58,8 +32,6 @@ define([ ko.applyBindingsToDescendants(component, el); } - ko.virtualElements.allowedBindings.scope = true; - ko.bindingHandlers.scope = { /** @@ -85,13 +57,13 @@ define([ var component = valueAccessor(), apply = applyComponents.bind(this, el, bindingContext); - if (typeof component === 'object') { - getMultiple(component, apply); - } else if (typeof component === 'string') { + if (typeof component === 'string') { registry.get(component, apply); } else if (typeof component === 'function') { component(apply); } } }; + + ko.virtualElements.allowedBindings.scope = true; }); diff --git a/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/staticChecked.js b/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/staticChecked.js new file mode 100644 index 0000000000000000000000000000000000000000..b766fcfa870c6fcd21bf6c40df23d16ebfe2e266 --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/staticChecked.js @@ -0,0 +1,103 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'ko' +], function (ko) { + 'use strict'; + + ko.bindingHandlers.staticChecked = { + 'after': ['value', 'attr'], + + /** + * Implements same functionality as a standard 'checked' binding, + * but with a difference that it wont' change values array if + * value of DOM element changes. + */ + init: function (element, valueAccessor, allBindings) { + var isCheckbox = element.type === 'checkbox', + isRadio = element.type === 'radio', + isValueArray, + oldElemValue, + useCheckedValue, + checkedValue, + updateModel, + updateView; + + if (!isCheckbox && !isRadio) { + return; + } + + checkedValue = ko.pureComputed(function () { + if (allBindings.has('checkedValue')) { + return ko.utils.unwrapObservable(allBindings.get('checkedValue')); + } else if (allBindings.has('value')) { + return ko.utils.unwrapObservable(allBindings.get('value')); + } + + return element.value; + }); + + isValueArray = isCheckbox && ko.utils.unwrapObservable(valueAccessor()) instanceof Array; + oldElemValue = isValueArray ? checkedValue() : undefined; + useCheckedValue = isRadio || isValueArray; + + /** + * Updates values array if it's necessary. + */ + updateModel = function () { + var isChecked = element.checked, + elemValue = useCheckedValue ? checkedValue() : isChecked, + modelValue; + + if (ko.computedContext.isInitial()) { + return; + } + + if (isRadio && !isChecked) { + return; + } + + modelValue = ko.dependencyDetection.ignore(valueAccessor); + + if (isValueArray) { + if (oldElemValue !== elemValue) { + oldElemValue = elemValue; + } else { + ko.utils.addOrRemoveItem(modelValue, elemValue, isChecked); + } + } else { + ko.expressionRewriting.writeValueToProperty(modelValue, allBindings, 'checked', elemValue, true); + } + }; + + /** + * Updates checkbox state. + */ + updateView = function () { + var modelValue = ko.utils.unwrapObservable(valueAccessor()); + + if (isValueArray) { + element.checked = ko.utils.arrayIndexOf(modelValue, checkedValue()) >= 0; + } else if (isCheckbox) { + element.checked = modelValue; + } else { + element.checked = checkedValue() === modelValue; + } + }; + + ko.computed(updateModel, null, { + disposeWhenNodeIsRemoved: element + }); + + ko.utils.registerEventHandler(element, 'click', updateModel); + + ko.computed(updateView, null, { + disposeWhenNodeIsRemoved: element + }); + } + }; + + ko.expressionRewriting.twoWayBindings.staticChecked = true; +}); diff --git a/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/stop_propagation.js b/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/stop_propagation.js deleted file mode 100644 index 7269d7774a3809c36686dab6d5e36736954ec88d..0000000000000000000000000000000000000000 --- a/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/stop_propagation.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/** Creates stopPropagation binding and registers in to ko.bindingHandlers object */ -define(['ko'], function (ko) { - 'use strict'; - - ko.bindingHandlers.stopPropagation = { - - /** - * Stops propagation on element - * @param {HTMLElement} element - element to apply binding to - */ - init: function (element) { - ko.utils.registerEventHandler(element, 'click', function (event) { - event.cancelBubble = true; - if (event.stopPropagation) { - event.stopPropagation(); - } - }); - } - }; -}); \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/js/lib/ko/extender/bound-nodes.js b/app/code/Magento/Ui/view/base/web/js/lib/ko/extender/bound-nodes.js index ed7b85b6f4127614e57466375267d404d4d43f06..62a13e52add7a587a9aad83fb0f8397296ea0e35 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/ko/extender/bound-nodes.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/ko/extender/bound-nodes.js @@ -7,7 +7,7 @@ define([ 'ko', 'underscore', 'mage/utils/wrapper', - 'Magento_Ui/js/lib/events', + 'uiEvents', 'es6-collections' ], function (ko, _, wrapper, Events) { 'use strict'; @@ -84,6 +84,7 @@ define([ } wrapper.extend(ko, { + /** * Extends kncokouts' 'applyBindings' * to track nodes associated with model. @@ -132,6 +133,7 @@ define([ }); return { + /** * Returns root nodes associated with a model. If callback is provided, * will iterate through all of the present nodes triggering callback diff --git a/app/code/Magento/Ui/view/base/web/js/lib/ko/initialize.js b/app/code/Magento/Ui/view/base/web/js/lib/ko/initialize.js index 2b0f3d1fc5dcadfc5f630efaea6a0bf5c4379dae..7a4dbb25680830eb990a436f89627f54e0400ca1 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/ko/initialize.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/ko/initialize.js @@ -7,9 +7,12 @@ define([ 'ko', './template/engine', + 'knockoutjs/knockout-repeat', + 'knockoutjs/knockout-fast-foreach', + 'knockoutjs/knockout-es5', './bind/scope', + './bind/staticChecked', './bind/datepicker', - './bind/stop_propagation', './bind/outer_click', './bind/keyboard', './bind/optgroup', @@ -18,9 +21,9 @@ define([ './bind/after-render', './bind/i18n', './bind/collapsible', + './bind/autoselect', './extender/observable_array', - './extender/bound-nodes', - './extender/observable_array' + './extender/bound-nodes' ], function (ko, templateEngine) { 'use strict'; diff --git a/app/code/Magento/Ui/view/base/web/js/lib/ko/template/engine.js b/app/code/Magento/Ui/view/base/web/js/lib/ko/template/engine.js index 213d0ea8a7f0c6b1b3f87bc178b4b52a7d500751..ad56e701e37388c10d19eafba892a0dbc7b004ad 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/ko/template/engine.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/ko/template/engine.js @@ -5,11 +5,18 @@ define([ 'ko', './observable_source', - '../../renderer/renderer' + './renderer' ], function (ko, Source, Renderer) { 'use strict'; - var sources = {}; + var RemoteTemplateEngine, + NativeTemplateEngine = ko.nativeTemplateEngine, + sources = {}; + + /** + * Remote template engine class. Is used to be able to load remote templates via knockout template binding. + */ + RemoteTemplateEngine = function () {}; /** * Creates unique template identifier based on template name and it's extenders (optional) @@ -20,12 +27,6 @@ define([ return templateName; } - /** - * Remote template engine class. Is used to be able to load remote templates via knockout template binding. - */ - var RemoteTemplateEngine = function () {}; - var NativeTemplateEngine = ko.nativeTemplateEngine; - RemoteTemplateEngine.prototype = new NativeTemplateEngine; RemoteTemplateEngine.prototype.constructor = RemoteTemplateEngine; @@ -34,7 +35,7 @@ define([ * Caches template after it's unique name and renders in once. * If template name is not typeof string, delegates work to knockout.templateSources.anonymousTemplate. * @param {*} template - * @return {TemplateSource} - object with methods 'nodes' and 'data'. + * @returns {TemplateSource} Object with methods 'nodes' and 'data'. */ RemoteTemplateEngine.prototype.makeTemplateSource = function (template) { var source, @@ -54,11 +55,13 @@ define([ } return source; - } else if ((template.nodeType == 1) || (template.nodeType == 8)) { - return new ko.templateSources.anonymousTemplate(template); - } else { - throw new Error("Unknown template type: " + template); + } else if (template.nodeType === 1 || template.nodeType === 8) { + source = new ko.templateSources.anonymousTemplate(template); + + return source; } + + throw new Error('Unknown template type: ' + template); }; /** diff --git a/app/code/Magento/Ui/view/base/web/js/lib/loader.js b/app/code/Magento/Ui/view/base/web/js/lib/ko/template/loader.js similarity index 99% rename from app/code/Magento/Ui/view/base/web/js/lib/loader.js rename to app/code/Magento/Ui/view/base/web/js/lib/ko/template/loader.js index 03d97b399d7130727a01ff43eb4264dfa3b82d72..da06db381245c02e5c2dd70902898d9dd1b0bbee 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/loader.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/ko/template/loader.js @@ -46,6 +46,7 @@ define([ } return { + /** * Loops over arguments and loads template for each. * @return {Deferred} - promise of templates to be loaded diff --git a/app/code/Magento/Ui/view/base/web/js/lib/ko/template/observable_source.js b/app/code/Magento/Ui/view/base/web/js/lib/ko/template/observable_source.js index d97291dcf15c5686af8f2d0fa0efb74edd503984..251163992ba056cb2d287e8f67ae96b5b750a577 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/ko/template/observable_source.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/ko/template/observable_source.js @@ -5,16 +5,20 @@ /** * Is being used by knockout template engine to store template to. */ -define(['ko', 'Magento_Ui/js/lib/class'], function(ko, Class) { +define([ + 'ko', + 'uiClass' +], function (ko, Class) { 'use strict'; return Class.extend({ /** * Initializes templateName, _data, nodes properties. + * * @param {template} template - identifier of template */ - initialize: function(template) { + initialize: function (template) { this.templateName = template; this._data = {}; this.nodes = ko.observable([]); @@ -27,7 +31,7 @@ define(['ko', 'Magento_Ui/js/lib/class'], function(ko, Class) { * @param {*} value * @return {*} - if 1 arg provided, returnes _data[key] property */ - data: function(key, value) { + data: function (key, value) { if (arguments.length === 1) { return this._data[key]; } @@ -35,4 +39,4 @@ define(['ko', 'Magento_Ui/js/lib/class'], function(ko, Class) { this._data[key] = value; } }); -}); \ No newline at end of file +}); diff --git a/app/code/Magento/Ui/view/base/web/js/lib/renderer/renderer.js b/app/code/Magento/Ui/view/base/web/js/lib/ko/template/renderer.js similarity index 92% rename from app/code/Magento/Ui/view/base/web/js/lib/renderer/renderer.js rename to app/code/Magento/Ui/view/base/web/js/lib/ko/template/renderer.js index 9da1291111f07e421eb1f41ca8b1ee6aa67bf1bb..55bf63998479fea2c220a9d0ad92102c7a447fdc 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/renderer/renderer.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/ko/template/renderer.js @@ -3,17 +3,20 @@ * See COPYING.txt for license details. */ define([ - '../loader', + './loader', 'jquery', 'underscore' ], function (loader, $, _) { 'use strict'; return { + /** * Renders template and it's extenders using this._parse function. - * Loads all extenders then merges them and wraps into div[data-template-extend="parent"] where parent is target template. + * Loads all extenders then merges them and wraps into + * div[data-template-extend="parent"] where parent is target template. * If no extenders provider, simply loads target template and passes execution to _parse. + * * @param {String} template - string, representing path to core template and it's extenders. * @returns {Deferred} - Promise of template to be rendered. Is being resolved with array of HTML elements. */ diff --git a/app/code/Magento/Ui/view/base/web/js/lib/registry/events.js b/app/code/Magento/Ui/view/base/web/js/lib/registry/events.js index 09c398ef01a896962342ad95fc39f8178f01007d..69fcebf547ef5fa076440a736fece570373fc629 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/registry/events.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/registry/events.js @@ -9,10 +9,13 @@ define([ ], function (_, utils) { 'use strict'; + /** + * @constructor + */ function Events(storage) { this.id = 0, - this.requests = new Map() + this.requests = new Map(); this.map = {}; this.storage = storage; diff --git a/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js b/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js index e31839400d0d171b332e76ecb0f1f5ba906167e4..eb01b49615c7427738985af0982bf9175094800c 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js @@ -10,6 +10,19 @@ define([ ], function (utils, _, Storage, Events) { 'use strict'; + /** + * Wrapper function used for convinient access to elements. + * See 'async' method for examples of usage and comparison + * with a regular 'get' method. + * + * @param {String} name - Key of the requested element. + * @param {Registry} registry - Instance of a registry + * where to search for the element. + * @param {(Function|String)} [method] - Optional callback function + * or a name of the elements' method which + * will be invoked when element is registered. + * @returns {*} + */ function async(name, registry, method) { var args = _.toArray(arguments).slice(3); @@ -24,6 +37,9 @@ define([ } } + /** + * @constructor + */ function Registry() { this.storage = new Storage(); this.events = new Events(this.storage); @@ -35,15 +51,12 @@ define([ /** * Retrieves data from registry. * - * @param {(String|Array)} elems - - * An array of elements' names or a string of names divided by spaces. - * @param {Function} [callback] - - * Callback function that will be triggered - * when all of the elements are registered. - * @returns {Array|*|Undefined} - * Returns either an array of elements - * or an element itself if only is requested. - * If callback function is specified then returns 'undefined'. + * @param {(String|Array)} elems - An array of elements' names or + * a string of names divided by spaces. + * @param {Function} [callback] - Callback function that will be invoked + * when all of the requested elements are registered. + * @returns {Array|*|Undefined} An array of elements + * or an element itself if only one was requested. */ get: function (elems, callback) { var records; @@ -61,12 +74,12 @@ define([ } }, - /** + /** * Sets data to registry. * * @param {String} elem - Elements' name. * @param {*} value - Value that will be assigned to the element. - * @returns {registry} Chainable. + * @returns {Registry} Chainable. */ set: function (elem, value) { this.storage.set(elem, value); @@ -77,9 +90,10 @@ define([ /** * Removes specified elements from a storage. - * @param {(String|Array)} elems - - * An array of elements' names or a string of names divided by spaces. - * @returns {registry} Chainable. + * + * @param {(String|Array)} elems - An array of elements' names or + * a string of names divided by spaces. + * @returns {Registry} Chainable. */ remove: function (elems) { elems = utils.stringToArray(elems); @@ -89,11 +103,11 @@ define([ return this; }, - /** + /** * Checks whether specified elements has been registered. * - * @param {(String|Array)} elems - - * An array of elements' names or a string of names divided by spaces. + * @param {(String|Array)} elems - An array of elements' names or + * a string of names divided by spaces. * @returns {Boolean} */ has: function (elems) { @@ -102,10 +116,40 @@ define([ return this.storage.has(elems); }, + /** + * Creates a function wrapper for the specified element, + * to provide more convinient access. + * + * @param {String} name - Name of the element. + * @returns {Function} + * + * @example Comparison with a 'get' method on requesting elements. + * var module = registry.async('name'); + * + * module(); + * => registry.get('name'); + * + * @example Requesting an element with a callback. + * module(function (component) {}); + * + * => registry.get('name', function (component) {}); + * + * @example Requesting an element and invoking its' method. + * module('trigger', true); + * + * => registry.get('name', function (component) { + * component.trigger(true); + * }); + */ async: function (name) { return async.bind(null, name, this); }, + /** + * Creates new instance of a Registry. + * + * @returns {Registry} New instance. + */ create: function () { return new Registry; } diff --git a/app/code/Magento/Ui/view/base/web/js/lib/registry/storage.js b/app/code/Magento/Ui/view/base/web/js/lib/registry/storage.js index ae3063cb07c2035df1189b86912792636bd35874..5012eba16a5e9927064346e08f0307750157cbfb 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/registry/storage.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/registry/storage.js @@ -7,6 +7,9 @@ define([ ], function () { 'use strict'; + /** + * @constructor + */ function Storage() { this.data = new Map(); } diff --git a/app/code/Magento/Ui/view/base/web/js/lib/view/utils/async.js b/app/code/Magento/Ui/view/base/web/js/lib/view/utils/async.js index 1b5743cd9d29aea5d12841306cd3dc0c1fd4ee6f..7986b18780600f7a3c705572d29149b54ab50be6 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/view/utils/async.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/view/utils/async.js @@ -126,7 +126,6 @@ define([ */ function setRootListener(data, component) { boundedNodes.get(component, function (root) { - var ctx = data.ctx || '*' if (!$(root).is(data.ctx || '*')) { return; } @@ -223,7 +222,7 @@ define([ /** * Sets removal listener of the specified nodes. * - * @param {{HTMLElement|Array|ArrayLike}} nodes - Nodes whose removal to track. + * @param {(HTMLElement|Array|ArrayLike)} nodes - Nodes whose removal to track. * @param {Function} fn - Callback that will be invoked when node is removed. */ remove: function (nodes, fn) { diff --git a/app/code/Magento/Ui/view/base/web/js/modal/alert.js b/app/code/Magento/Ui/view/base/web/js/modal/alert.js index 33be3c8041dea6c2f0586124bc3f1e8120020cef..f422083aab9b27af1969866da18182716a241ad1 100644 --- a/app/code/Magento/Ui/view/base/web/js/modal/alert.js +++ b/app/code/Magento/Ui/view/base/web/js/modal/alert.js @@ -2,6 +2,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + define([ 'jquery', 'underscore', @@ -16,19 +17,31 @@ define([ modalClass: 'confirm', title: $.mage.__('Attention'), actions: { + + /** + * Callback always - called on all actions. + */ always: function () {} }, buttons: [{ text: $.mage.__('OK'), - class: 'action-secondary', + class: 'action-primary action-accept', + + /** + * Click handler. + */ click: function () { this.closeModal(true); } }] }, + + /** + * Close modal window. + */ closeModal: function () { this.options.actions.always(); - this.element.bind('confirmclosed', _.bind(this._remove, this)); + this.element.bind('alertclosed', _.bind(this._remove, this)); return this._super(); } diff --git a/app/code/Magento/Ui/view/base/web/js/modal/confirm.js b/app/code/Magento/Ui/view/base/web/js/modal/confirm.js index 7bad2023b649b18edeaf710780d8cf0e73a5f6b9..098cb8669741e15eedb8fb0df607a0658cec98f8 100644 --- a/app/code/Magento/Ui/view/base/web/js/modal/confirm.js +++ b/app/code/Magento/Ui/view/base/web/js/modal/confirm.js @@ -2,6 +2,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + define([ 'jquery', 'underscore', @@ -16,36 +17,72 @@ define([ modalClass: 'confirm', title: '', actions: { - always: function(){}, - confirm: function(){}, - cancel: function(){} + + /** + * Callback always - called on all actions. + */ + always: function () {}, + + /** + * Callback confirm. + */ + confirm: function () {}, + + /** + * Callback cancel. + */ + cancel: function () {} }, buttons: [{ text: $.mage.__('Cancel'), - class: 'action-tertiary', - click: function(){ + class: 'action-secondary action-dismiss', + + /** + * Click handler. + */ + click: function () { this.closeModal(); } }, { text: $.mage.__('OK'), - class: 'action-secondary', - click: function() { + class: 'action-primary action-accept', + + /** + * Click handler. + */ + click: function () { this.closeModal(true); } }] }, - _create: function() { + + /** + * Create widget. + */ + _create: function () { this._super(); this.modal.find(this.options.modalCloseBtn).off().on('click', _.bind(this.closeModal, this, false)); this.openModal(); }, - _remove: function() { + + /** + * Remove modal window. + */ + _remove: function () { this.modal.remove(); }, - openModal: function() { + + /** + * Open modal window. + */ + openModal: function () { return this._super(); }, - closeModal: function(result) { + + /** + * Close modal window. + */ + closeModal: function (result) { result = result || false; if (result) { diff --git a/app/code/Magento/Ui/view/base/web/js/modal/modal.js b/app/code/Magento/Ui/view/base/web/js/modal/modal.js index 84074ebf9800e689fd6a900afe986c8242664ac9..e99f818068534b4578bdebc4b4f3ef2dc36becc3 100644 --- a/app/code/Magento/Ui/view/base/web/js/modal/modal.js +++ b/app/code/Magento/Ui/view/base/web/js/modal/modal.js @@ -10,9 +10,10 @@ define([ 'text!ui/template/modal/modal-popup.html', 'text!ui/template/modal/modal-slide.html', 'text!ui/template/modal/modal-custom.html', + 'Magento_Ui/js/lib/key-codes', 'jquery/ui', 'mage/translate' -], function ($, _, template, popupTpl, slideTpl, customTpl) { +], function ($, _, template, popupTpl, slideTpl, customTpl, keyCodes) { 'use strict'; /** @@ -44,6 +45,9 @@ define([ type: 'popup', title: '', modalClass: '', + focus: '[data-role="closeBtn"]', + autoOpen: false, + clickableOverlay: true, popupTpl: popupTpl, slideTpl: slideTpl, customTpl: customTpl, @@ -56,6 +60,9 @@ define([ modalCloseBtn: '[data-role="closeBtn"]', modalContent: '[data-role="content"]', modalAction: '[data-role="action"]', + focusableScope: '[data-role="focusable-scope"]', + focusableStart: '[data-role="focusable-start"]', + focusableEnd: '[data-role="focusable-end"]', appendTo: 'body', wrapperClass: 'modals-wrapper', overlayClass: 'modals-overlay', @@ -66,6 +73,7 @@ define([ buttons: [{ text: $.mage.__('Ok'), class: '', + attr: {}, /** * Default action on button click @@ -75,16 +83,45 @@ define([ } }] }, + keyEventHandlers: { + + /** + * Tab key press handler, + * set focus to elements + */ + tabKey: function () { + if (document.activeElement === this.modal[0]) { + this._setFocus('start'); + } + }, + + /** + * Escape key press handler, + * close modal window + */ + escapeKey: function () { + if (this.options.isOpen && this.modal.find(document.activeElement).length || + this.options.isOpen && this.modal[0] === document.activeElement) { + this.closeModal(); + } + } + }, /** * Creates modal widget. */ _create: function () { + _.bindAll( + this, + 'keyEventSwitcher', + '_tabSwitcher', + 'closeModal' + ); + this.options.transitionEvent = transitionEvent; this._createWrapper(); this._renderModal(); this._createButtons(); - $(this.options.trigger).on('click', _.bind(this.toggleModal, this)); this._on(this.modal.find(this.options.modalCloseBtn), { 'click': this.closeModal @@ -93,6 +130,7 @@ define([ 'openModal': this.openModal, 'closeModal': this.closeModal }); + this.options.autoOpen ? this.openModal() : false; }, /** @@ -123,6 +161,18 @@ define([ return elems.filter('.' + this.options.modalVisibleClass).length; }, + /** + * Listener key events. + * Call handler function if it exists + */ + keyEventSwitcher: function (event) { + var key = keyCodes[event.keyCode]; + + if (this.keyEventHandlers.hasOwnProperty(key)) { + this.keyEventHandlers[key].apply(this, arguments); + } + }, + /** * Toggle modal. * * @return {Element} - current element. @@ -141,9 +191,12 @@ define([ */ openModal: function () { this.options.isOpen = true; + this.focussedElement = document.activeElement; this._createOverlay(); this._setActive(); + this._setKeyListener(); this.modal.one(this.options.transitionEvent, _.bind(this._trigger, this, 'opened')); + this.modal.one(this.options.transitionEvent, _.bind(this._setFocus, this, 'end', 'opened')); this.modal.addClass(this.options.modalVisibleClass); if (!this.options.transitionEvent) { @@ -153,6 +206,68 @@ define([ return this.element; }, + /** + * Set focus to element. + * @param {String} position - can be "start" and "end" + * positions. + * If position is "end" - sets focus to first + * focusable element in modal window scope. + * If position is "start" - sets focus to last + * focusable element in modal window scope + * + * @param {String} type - can be "opened" or false + * If type is "opened" - looks to "this.options.focus" + * property and sets focus + */ + _setFocus: function (position, type) { + var focusableElements, + infelicity; + + if (type === 'opened' && this.options.focus) { + this.modal.find($(this.options.focus)).focus(); + } else if (type === 'opened' && !this.options.focus) { + this.modal.find(this.options.focusableScope).focus(); + } else if (position === 'end') { + this.modal.find(this.options.modalCloseBtn).focus(); + } else if (position === 'start') { + infelicity = 2; //Constant for find last focusable element + focusableElements = this.modal.find(':focusable'); + focusableElements.eq(focusableElements.length - infelicity).focus(); + } + }, + + /** + * Set events listener when modal is opened. + */ + _setKeyListener: function () { + this.modal.find(this.options.focusableStart).bind('focusin', this._tabSwitcher); + this.modal.find(this.options.focusableEnd).bind('focusin', this._tabSwitcher); + this.modal.bind('keydown', this.keyEventSwitcher); + }, + + /** + * Remove events listener when modal is closed. + */ + _removeKeyListener: function () { + this.modal.find(this.options.focusableStart).unbind('focusin', this._tabSwitcher); + this.modal.find(this.options.focusableEnd).unbind('focusin', this._tabSwitcher); + this.modal.unbind('keydown', this.keyEventSwitcher); + }, + + /** + * Switcher for focus event. + * @param {Object} e - event + */ + _tabSwitcher: function (e) { + var target = $(e.target); + + if (target.is(this.options.focusableStart)) { + this._setFocus('start'); + } else if (target.is(this.options.focusableEnd)) { + this._setFocus('end'); + } + }, + /** * Close modal. * * @return {Element} - current element. @@ -160,6 +275,7 @@ define([ closeModal: function () { var that = this; + this._removeKeyListener(); this.options.isOpen = false; this.modal.one(this.options.transitionEvent, function () { that._close(); @@ -179,6 +295,7 @@ define([ _close: function () { var trigger = _.bind(this._trigger, this, 'closed', this.modal); + $(this.focussedElement).focus(); this._destroyOverlay(); this._unsetActive(); _.defer(trigger, this); @@ -246,6 +363,9 @@ define([ _.each(this.options.buttons, function (btn, key) { var button = that.buttons[key]; + if (btn.attr) { + $(button).attr(btn.attr); + } $(button).on('click', _.bind(btn.click, that)); }); }, @@ -254,8 +374,7 @@ define([ * Creates overlay, append it to wrapper, set previous click event on overlay. */ _createOverlay: function () { - var that = this, - events; + var events; this.overlay = $('.' + this.options.overlayClass); @@ -266,13 +385,8 @@ define([ .appendTo(this.modalWrapper); } events = $._data(this.overlay.get(0), 'events'); - - if (events) { - this.prevOverlayHandler = events.click[0].handler; - } - this.overlay.unbind().on('click', function () { - that.closeModal(); - }); + events ? this.prevOverlayHandler = events.click[0].handler : false; + this.options.clickableOverlay ? this.overlay.unbind().on('click', this.closeModal) : false; }, /** diff --git a/app/code/Magento/Ui/view/base/web/js/modal/prompt.js b/app/code/Magento/Ui/view/base/web/js/modal/prompt.js new file mode 100644 index 0000000000000000000000000000000000000000..0866050dcafc5f571fb3a8049036cda5345faf9e --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/js/modal/prompt.js @@ -0,0 +1,120 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'jquery', + 'underscore', + 'jquery/ui', + 'Magento_Ui/js/modal/modal', + 'mage/translate' +], function ($, _) { + 'use strict'; + + $.widget('mage.prompt', $.mage.modal, { + options: { + modalClass: 'prompt', + promptField: '[data-role="promptField"]', + value: '', + actions: { + + /** + * Callback always - called on all actions. + */ + always: function () {}, + + /** + * Callback confirm. + */ + confirm: function () {}, + + /** + * Callback cancel. + */ + cancel: function () {} + }, + buttons: [{ + text: $.mage.__('Cancel'), + class: 'action-secondary action-dismiss', + + /** + * Click handler. + */ + click: function () { + this.closeModal(); + } + }, { + text: $.mage.__('OK'), + class: 'action-primary action-accept', + + /** + * Click handler. + */ + click: function () { + this.closeModal(true); + } + }] + }, + + /** + * Create widget. + */ + _create: function () { + this.options.focus = this.options.promptField; + this._super(); + this.modal.find(this.options.modalContent).append( + '<div class="prompt-message">' + + '<input data-role="promptField" id="prompt-field" class="admin__control-text" type="text"/>' + + '</div>' + ); + this.modal.find(this.options.modalCloseBtn).off().on('click', _.bind(this.closeModal, this, false)); + this.openModal(); + }, + + /** + * Compile template and append to wrapper. + */ + _renderModal: function () { + this._super(); + this.element.wrap('<label for="prompt-field"></label>'); + }, + + /** + * Remove widget + */ + _remove: function () { + this.modal.remove(); + }, + + /** + * Open modal window + */ + openModal: function () { + this._super(); + this.modal.find(this.options.promptField).val(this.options.value); + }, + + /** + * Close modal window + */ + closeModal: function (result) { + var value; + + if (result) { + value = this.modal.find(this.options.promptField).val(); + this.options.actions.confirm(value); + } else { + this.options.actions.cancel(); + } + this.options.actions.always(); + this.element.bind('promptclosed', _.bind(this._remove, this)); + + return this._super(); + } + }); + + return function (config) { + return $('<div></div>').html(config.content).prompt(config); + }; +}); diff --git a/app/code/Magento/Ui/view/base/web/templates/collection.html b/app/code/Magento/Ui/view/base/web/templates/collection.html index ac5ce2ca9de45d64dfd2f850e5598ed0aa9bc617..a5e802420e3882aed300a992b82a01e740296dbe 100644 --- a/app/code/Magento/Ui/view/base/web/templates/collection.html +++ b/app/code/Magento/Ui/view/base/web/templates/collection.html @@ -5,5 +5,7 @@ */ --> <!-- ko foreach: { data: elems, as: 'element' } --> - <!-- ko template: element.getTemplate() --><!-- /ko --> + <!-- ko if: hasTemplate() --> + <!-- ko template: getTemplate() --><!-- /ko --> + <!-- /ko --> <!-- /ko --> diff --git a/app/code/Magento/Ui/view/base/web/templates/form/element/checkbox.html b/app/code/Magento/Ui/view/base/web/templates/form/element/checkbox.html index 01dca8a5b9318157f562333f27546e07f3d0e081..1d00fae66ae2ab08fefef861146d0658cdc405df 100644 --- a/app/code/Magento/Ui/view/base/web/templates/form/element/checkbox.html +++ b/app/code/Magento/Ui/view/base/web/templates/form/element/checkbox.html @@ -7,8 +7,7 @@ <div class="admin__field admin__field-option"> <input type="checkbox" class="admin__control-checkbox" data-bind="checked: value, attr: { id: uid, disabled: disabled, name: inputName }, hasFocus: focused"> - <label class="admin__field-label" data-bind="checked: value, attr: { for: uid }"> - <span data-bind="text: description || label"></span> + <label class="admin__field-label" data-bind="text: description || label, attr: { for: uid }"> </label> <!-- ko if: notice --> diff --git a/app/code/Magento/Ui/view/base/web/templates/form/element/media.html b/app/code/Magento/Ui/view/base/web/templates/form/element/media.html index 64c9f82070dd23b382f04b1f1af237ce376365f7..627d6689262fd1e5cba45c023193e59cd3f306a9 100644 --- a/app/code/Magento/Ui/view/base/web/templates/form/element/media.html +++ b/app/code/Magento/Ui/view/base/web/templates/form/element/media.html @@ -12,6 +12,7 @@ placeholder: placeholder, 'aria-describedby': noticeId, id: uid, - disabled: disabled + disabled: disabled, + form: formId }" /> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/cells/actions.html b/app/code/Magento/Ui/view/base/web/templates/grid/cells/actions.html index 22105aed42f6d0eb382162432c3317431a32cbeb..653696ed6fd0cf085345fd8b8f2bdd5c42536e91 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/cells/actions.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/cells/actions.html @@ -4,50 +4,49 @@ * See COPYING.txt for license details. */ --> +<!-- ko if: $col.isSingle($row()._rowIndex) --> +<a + class="action-menu-item" + data-bind=" + repeat: { + foreach: $col.getVisibleActions($row()._rowIndex), + item: '$action' + }" + data-repeat-bind=" + attr: { + href: $action().href + }, + click: $col.getActionHandler($action()), + text: $action().label" + ></a> +<!-- /ko --> -<td data-bind="visible: visible" class="data-grid-actions-cell"> - <!-- ko if: isSingle(row._rowIndex) --> - <!-- ko foreach: getVisibleActions(row._rowIndex) --> - <a - class="action-menu-item" +<!-- ko if: $col.isMultiple($row()._rowIndex) --> +<div + class="action-select-wrap" + data-bind="collapsible"> + <button class="action-select" data-bind="toggleCollapsible"> + <span data-bind="i18n: 'Select'"></span> + </button> + <ul + class="action-menu" data-bind=" - attr: { - href: $data.href - }, - click: $parent.isHandlerRequired(index, rowIndex) ? - $parent.applyAction.bind($parent, index, rowIndex) : - false, - text: $data.label"></a> - <!-- /ko --> - <!-- /ko --> - - <!-- ko if: isMultiple(row._rowIndex) --> - <div - class="action-select-wrap" - data-bind="collapsible"> - <button class="action-select" data-bind="toggleCollapsible"> - <span data-bind="i18n: 'Select'"></span> - </button> - <ul - class="action-menu" - data-bind="css: { - '_active': $collapsible.opened - }, - foreach: getVisibleActions(row._rowIndex)" - > - <li> - <a - class="action-menu-item" - data-bind=" - attr: { - href: $data.href - }, - click: $parent.isHandlerRequired(index, rowIndex) ? - $parent.applyAction.bind($parent, index, rowIndex) : - false, - text: $data.label"></a> - </li> - </ul> - </div> - <!-- /ko --> -</td> + css: {'_active': $collapsible.opened}"> + <li + data-bind=" + repeat: { + foreach: $col.getVisibleActions($row()._rowIndex), + item: '$action' + }"> + <a + class="action-menu-item" + data-bind=" + attr: { + href: $action().href + }, + click: $col.getActionHandler($action()), + text: $action().label"></a> + </li> + </ul> +</div> +<!-- /ko --> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/cells/html.html b/app/code/Magento/Ui/view/base/web/templates/grid/cells/html.html index 9d5226a5e3c792fc466dbfd28f7f29e846c5606e..5e48189716a9322c1cfbc16de8f7076442a3e8db 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/cells/html.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/cells/html.html @@ -4,16 +4,7 @@ * See COPYING.txt for license details. */ --> -<td - data-bind=" - visible: visible, - css: { _dragging: dragging }, - click: hasFieldAction() ? - applyFieldAction.bind($data, row._rowIndex) : - false" - data-action="grid-row-edit"> - <div - data-bind="html: getLabel(row[field.index])" - class="data-grid-cell-content"> - </div> -</td> +<div + class="data-grid-cell-content" + data-bind="html: $col.getLabel($row())"> +</div> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/cells/multiselect.html b/app/code/Magento/Ui/view/base/web/templates/grid/cells/multiselect.html index 242c651f006d16896d55dcb52d0d8332bab9eb71..f0964a155e1e89fd453d748f0af3d20ef6bbec50 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/cells/multiselect.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/cells/multiselect.html @@ -4,20 +4,16 @@ * See COPYING.txt for license details. */ --> - -<td class="data-grid-checkbox-cell" data-bind="visible: visible"> - <label class="data-grid-checkbox-cell-inner"> - <input - class="admin__control-checkbox" - type="checkbox" - data-action="select-row" - data-bind=" - disable: disabled.indexOf(row[indexField]) != -1, - checked: selected, - value: row[indexField], - attr: { - id: 'check' + row[indexField] - }"> - <label data-bind="attr: {for: 'check' + row[indexField]}"></label> - </label> -</td> +<label class="data-grid-checkbox-cell-inner"> + <input + class="admin__control-checkbox" + type="checkbox" + data-action="select-row" + data-bind=" + staticChecked: $col.selected, + checkedValue: $row()[$col.indexField], + attr: { + id: 'check' + $row()[$col.indexField] + }"> + <label data-bind="attr: {for: 'check' + $row()[$col.indexField]}"></label> +</label> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/cells/onoff.html b/app/code/Magento/Ui/view/base/web/templates/grid/cells/onoff.html index 54bc04ebbda12c7a5d22bed1cb1dfc8fd1a7c245..9a23d227e583a5f35db1d2ea2a28592fced7c248 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/cells/onoff.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/cells/onoff.html @@ -4,15 +4,21 @@ * See COPYING.txt for license details. */ --> - -<td class="data-grid-onoff-cell admin__scope-old"> - <div class="switcher"> - <input - class="admin__control-onoff" - type="checkbox" - data-bind="checked: selected, - value: row[indexField], - attr: {id: 'check' + row[indexField]}"> - <label class="switcher-label" data-bind="attr: {for: 'check' + row[indexField]}, text: getLabel(row[indexField])"></label> - </div> -</td> +<div class="switcher"> + <input + class="admin__control-onoff" + type="checkbox" + data-bind=" + staticChecked: $col.selected, + value: $row()[$col.indexField], + attr: { + id: 'check' + $row()[$col.indexField] + }"> + <label + class="switcher-label" + data-bind=" + attr: { + for: 'check' + $row()[$col.indexField] + }, + text: $col.getLabel($row()[$col.indexField])"></label> +</div> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/cells/text.html b/app/code/Magento/Ui/view/base/web/templates/grid/cells/text.html index 3544f503de6d9189933c9f0ef603da5841b935f3..bdd0d673514637cfb7b655d42eb510cad2247489 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/cells/text.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/cells/text.html @@ -4,17 +4,7 @@ * See COPYING.txt for license details. */ --> -<td - data-bind=" - visible: visible, - css: { _dragging: dragging }, - click: hasFieldAction() ? - applyFieldAction.bind($data, row._rowIndex) : - false" - data-action="grid-row-edit"> - <div - data-bind=" - text: getLabel(row[field.index])" - class="data-grid-cell-content"> - </div> -</td> +<div + class="data-grid-cell-content" + data-bind="text: $col.getLabel($row())"> +</div> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/cells/thumbnail.html b/app/code/Magento/Ui/view/base/web/templates/grid/cells/thumbnail.html index d8ce11138decf4e3cd5eca47b75dde55192690f8..e45dd5eabc3a73dc91c8fef473101cd2ccad2dc6 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/cells/thumbnail.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/cells/thumbnail.html @@ -4,12 +4,11 @@ * See COPYING.txt for license details. */ --> -<td class="data-grid-thumbnail-cell" - data-bind="visible: visible, click: isPreviewAvailable() ? preview.bind($data, row, $parentContext.$index()) : false" - data-action="grid-row-edit"> - <img src="" class="admin__control-thumbnail" data-bind=" - attr: { - src: getSrc(row), - alt: getAlt(row) - }"/> -</td> +<img + class="admin__control-thumbnail" + data-bind=" + attr: { + src: $col.getSrc($row()), + alt: $col.getAlt($row()) + } + "/> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/columns/multiselect.html b/app/code/Magento/Ui/view/base/web/templates/grid/columns/multiselect.html index 4606d8e27b9a19e5236f6b7f28d66076805b43d1..8caad7bfc0980c68c19d38ac421ed2fe21fc70c6 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/columns/multiselect.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/columns/multiselect.html @@ -5,7 +5,7 @@ */ --> -<th class="data-grid-multicheck-cell" data-bind="visible: visible"> +<th class="data-grid-multicheck-cell"> <div class="action-multicheck-wrap" data-bind="css: {'_disabled': !totalRecords()}, @@ -36,4 +36,4 @@ </li> </ul> </div> -</th> +</th> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/columns/onoff.html b/app/code/Magento/Ui/view/base/web/templates/grid/columns/onoff.html index f98dcf944f27fcb80f4bac2235b11bdeb2fa2d3e..5e68fc3a77bb5b317db04d737af43644e9f7bd73 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/columns/onoff.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/columns/onoff.html @@ -10,13 +10,12 @@ <div class="action-multicheck-wrap" style="width: 3.3rem" - data-bind="css: { '_active': menuVisible, '_disabled': !totalRecords()}, - outerClick: hideMenu"> + data-bind="css: {'_disabled': !totalRecords()}, collapsible"> <input id="mass-select-checkbox" class="admin__control-checkbox" type="checkbox" - data-bind="checked: allSelected, + data-bind="checked: allSelected(), event: { change: toggleSelectAll }, css: { '_indeterminate': indetermine }, enable: totalRecords"> @@ -26,14 +25,14 @@ <button class="action-multicheck-toggle" data-toggle="dropdown" - data-bind="css: { '_active': menuVisible }, - click: toggleMenu, - enable: totalRecords"> + data-bind="css: { '_active': $collapsible.opened }, + enable: totalRecords + toggleCollapsible"> <span data-bind="i18n: 'Options'"></span> </button> <ul class="action-menu" - data-bind="click: hideMenu, foreach: actions"> + data-bind="closeCollapsible, foreach: actions"> <li data-bind="click: $parent[value].bind($parent), visible: $parent.isActionRelevant(value)"> <span class="action-menu-item" data-bind="text: label"></span> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/columns/text.html b/app/code/Magento/Ui/view/base/web/templates/grid/columns/text.html index dfd36be3f731022266fcccb9fe6cceefaa7c4872..318cb9d09427ed332185bb4c2ec1e9dcb9931d07 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/columns/text.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/columns/text.html @@ -10,13 +10,12 @@ css: { '_sortable': sortable, '_draggable': draggable, - '_ascend': sorting() === 'asc', - '_descend': sorting() === 'desc' + '_ascend': sorting === 'asc', + '_descend': sorting === 'desc' }, - click: sort, - visible: visible"> + click: sort"> <span class="data-grid-cell-content" data-bind="text: label"> </span> -</th> +</th> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/bookmarks.html b/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/bookmarks.html index 850f3c2fce793487392414a8ff1f95bc45f5daa5..8dcb904750dff5aa75fd5988244387ffda390049 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/bookmarks.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/bookmarks.html @@ -15,15 +15,63 @@ data-bind="toggleCollapsible" data-toggle="dropdown" aria-haspopup="true"> - <span class="admin__action-dropdown-text" - data-bind="i18n: activeView() ? activeView().label() : 'Default View' "></span> + <span + class="admin__action-dropdown-text" + data-bind="text: activeView.label"></span> </button> <ul class="admin__action-dropdown-menu"> - <!-- ko foreach: elems --> - <!-- ko template: getTemplate() --><!-- /ko --> - <!-- /ko --> - <li data-bind="visible: hasChanges" class="action-dropdown-menu-action action-dropdown-menu-item-last"> - <a href="" data-bind="click: createNewView, i18n: 'Save Current View'"></a> + <li + data-bind="repeat: { + foreach: viewsArray, + item: '$view' + }" + data-repeat-bind=" + css: { + _edit: isEditing($view().index) + }, + outerClick: endEdit.bind($data, $view().index), + template: viewTmpl + "> + </li> + <li data-bind=" + visible: hasChanges, + outerClick: hideCustom.bind($data), + css: { + _edit: customVisible, + 'action-dropdown-menu-action action-dropdown-menu-item-last': !customVisible + } + "> + <a href="" + data-bind=" + visible: !customVisible, + click: showCustom, + i18n: 'Save View As...' + "></a> + <div class="action-dropdown-menu-item-edit" data-bind="visible: customVisible"> + <input + class="admin__control-text" + data-bind=" + value: customLabel, + autoselect, + hasFocus: isCustomVisible(), + keyboard: { + 13: applyCustom.bind($data), + 27: hideCustom.bind($data) + }" + type="text"> + <div class="action-dropdown-menu-item-actions"> + <button + class="action-submit" + data-bind=" + attr: { + title: $t('Save all changes') + }, + click: applyCustom" + type="button"> + <span data-bind="i18n: 'Submit'"></span> + </button> + </div> + </div> </li> </ul> -</div> +</div> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/view.html b/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/view.html index 707fad8eabbe87f3fc4120fd49e9b2afb6ce4b26..6aa2fc9556298a7529388be5addb4a7cb0f73f2f 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/view.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/controls/bookmarks/view.html @@ -4,52 +4,70 @@ * See COPYING.txt for license details. */ --> -<li - data-bind="css: {_edit: editing}, outerClick: endEdit.bind($data)"> - <!-- ko if: editable --> - <div class="action-dropdown-menu-item-edit"> - <input - class="admin__control-text" +<!-- ko if: $view().editable --> +<div + class="action-dropdown-menu-item-edit"> + <input + class="admin__control-text" + data-bind=" + value: $view().value, + hasFocus: isEditing($view().index), + autoselect, + attr: { + placeholder: $view().label + }, + keyboard: { + 13: updateAndSave.bind($data, $view().index), + 27: endEdit.bind($data, $view().index) + }" + type="text"> + <button + class="action-submit" + data-bind=" + attr: { + title: $t('Save all changes') + }, + click: updateAndSave.bind($data, $view().index)" + type="button"> + <span data-bind="i18n: 'Submit'"></span> + </button> + <div class="action-dropdown-menu-item-actions"> + <button data-bind=" - value: value, - hasFocus: editing(), attr: { - placeholder: label + title: $t('Delete bookmark') }, - keyboard: { - 13: function(){ $collapsible.close(); $parent.saveView($data) } - }" - type="text"> + click: removeView.bind($data, $view().index)" + class="action-delete" + type="button"> + <span data-bind="i18n: 'Delete'"></span> + </button> + </div> +</div> +<!-- /ko --> + +<div class="action-dropdown-menu-item"> + <a + class="action-dropdown-menu-link" + href="" + data-bind=" + text: $view().label, + click: applyView.bind($data, $view().index), + closeCollapsible"> + </a> + + <!-- ko if: $view().editable --> + <div class="action-dropdown-menu-item-actions"> <button - class="action-submit" - data-bind="click: $parent.saveView.bind($parent, $data), closeCollapsible, attr: {title: $t('Save all changes')}" + class="action-edit" + data-bind=" + attr: { + title: $t('Edit bookmark') + }, + click: editView.bind($data, $view().index)" type="button"> - <span data-bind="i18n: 'Submit'"></span> + <span data-bind="i18n: 'Edit'"></span> </button> - <div class="action-dropdown-menu-item-actions"> - <button - data-bind="click: $parent.removeView.bind($parent, $data), closeCollapsible, attr: {title: $t('Delete bookmark')}" - class="action-delete" - type="button"> - <span data-bind="i18n: 'Delete'"></span> - </button> - </div> </div> <!-- /ko --> - <div class="action-dropdown-menu-item"> - <a - class="action-dropdown-menu-link" - href="" - data-bind="text: label, click: function(){ active(true); }, closeCollapsible"></a> - <!-- ko if: editable --> - <div class="action-dropdown-menu-item-actions"> - <button - class="action-edit" - data-bind="click: startEdit, attr: {title: $t('Edit bookmark')}" - type="button"> - <span data-bind="i18n: 'Edit'"></span> - </button> - </div> - <!-- /ko --> - </div> -</li> +</div> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/controls/columns.html b/app/code/Magento/Ui/view/base/web/templates/grid/controls/columns.html index e2dcc3d816376756169ad5896c5e14de65475fe8..2eff0b403073eaf2e367e26dbb0c65f34fac66b3 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/controls/columns.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/controls/columns.html @@ -19,21 +19,21 @@ <div class="admin__action-dropdown-menu-header"> <span data-bind="text: getHeaderMessage()"></span> </div> - <div class="admin__action-dropdown-menu-content" data-bind="foreach: elems"> - <div class="admin__field-option"> + <div class="admin__action-dropdown-menu-content"> + <div class="admin__field-option" data-bind="repeat: {foreach: elems, item: '$col'}"> <input class="admin__control-checkbox" type="checkbox" data-bind=" attr: { - id: ++ko.bindingHandlers['uniqueName'].currentIndex + '_uid' + id: ++ko.bindingHandlers['uniqueName'].currentIndex + '_uid' }, - disable: $parent.isDisabled($data), - checked: visible"/> + disable: isDisabled($col()), + checked: $col().visible"/> <label class="admin__field-label" data-bind=" - text: label, + text: $col().label, attr: { for: ko.bindingHandlers['uniqueName'].currentIndex + '_uid' }"></label> @@ -52,4 +52,4 @@ </div> </div> </div> -</div> +</div> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/editing/bulk.html b/app/code/Magento/Ui/view/base/web/templates/grid/editing/bulk.html index fe3d785f3d29a4cece894b3df02ece7467f7a6b1..951e0af5cd12d82ad8b053947c324ae105a065fc 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/editing/bulk.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/editing/bulk.html @@ -8,15 +8,18 @@ class="data-grid-bulk-edit-panel data-grid-editable-row" data-bind=" visible: active, - foreach: fields" + foreach: { + data: fields, + as: '$col' + }" data-role="data-grid-bulk-row"> + <!-- ko if: $parent.getColumn(index).visible --> <td data-bind=" - visible: $parent.getColumn(index).visible, css: { - 'data-grid-actions-cell': $parent.isActionsColumn($data) + 'data-grid-actions-cell': $parent.isActionsColumn($col) }"> - <!-- ko if: $parent.isActionsColumn($data) --> + <!-- ko if: $parent.isActionsColumn($col) --> <!-- ko with: $parent --> <button class="action-default" @@ -24,7 +27,7 @@ data-bind=" click: apply, attr: { - disabled: !hasData() + disabled: !hasData }"> <span data-bind="i18n: 'Apply'"></span> </button> @@ -43,4 +46,5 @@ <!-- ko template: getTemplate() --><!-- /ko --> <!-- /ko --> </td> + <!-- /ko --> </tr> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/editing/field.html b/app/code/Magento/Ui/view/base/web/templates/grid/editing/field.html index 77cc47351c89f72d68d7ba428a7c7f7a816ab7ab..a01514ff19136807fe40066d8a3fc6fc6c7f3d3d 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/editing/field.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/editing/field.html @@ -5,16 +5,14 @@ */ --> -<td data-bind="visible: $parent.getColumn(index).visible"> - <div - class="admin__field-control" - data-bind="css: { - _error: error(), - _focus: focused() - }"> - <!-- ko template: getTemplate() --><!-- /ko --> - <label - class="admin__field-error" - data-bind="attr: { for: uid }, text: error, visible: error() && focused()"></label> - </div> -</td> +<div + class="admin__field-control" + data-bind="css: { + _error: error(), + _focus: focused() + }"> + <!-- ko template: getTemplate() --><!-- /ko --> + <label + class="admin__field-error" + data-bind="attr: { for: uid }, text: error, visible: error() && focused()"></label> +</div> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/editing/header-buttons.html b/app/code/Magento/Ui/view/base/web/templates/grid/editing/header-buttons.html index 834ef42fdbfc620ed0378b594e1077cf3f04ef78..cb41d2538e8afd9e398c73226e6a4586bb4abb78 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/editing/header-buttons.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/editing/header-buttons.html @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ --> -<div class="data-grid-info-panel" data-bind="visible: isMultiEditing() || (hasActive() && (hasMessages() || hasErrors() ))"> +<div class="data-grid-info-panel" data-bind="visible: isMultiEditing || (hasActive() && (hasMessages() || hasErrors() ))"> <div class="messages" data-bind="visible: hasMessages() || hasErrors()"> <div class="message message-warning" data-bind="visible: hasErrors()"> <strong>There are <!-- ko text: countErrors() --><!-- /ko --> meesages requires your attention.</strong> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/editing/row.html b/app/code/Magento/Ui/view/base/web/templates/grid/editing/row.html index 892eaf35872389aaef796659e7fdb59ca863f2f4..ad64b2a630e93bcecd1767fa751a30a6cd4dfa18 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/editing/row.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/editing/row.html @@ -8,21 +8,28 @@ data-part="body.row" class="data-grid-editable-row" data-bind=" - visible: active, - '_odd-row': !!($index() % 2), + '_odd-row': !!($row()._rowIndex % 2), foreach: { data: fields, - as: 'field' + as: '$col' }"> + <!-- ko if: $parent.getColumn(index).visible --> + <!-- ko if: $parent.isActionsColumn($data) --> <td class="data-grid-actions-cell"> - <span class="data-grid-row-changed" data-bind="css: { _changed: $parent.hasChanges() }"> + <span class="data-grid-row-changed" data-bind="css: {_changed: $parent.hasChanges}"> <span class="data-grid-row-changed-tooltip" data-bind="i18n: 'Record contains unsaved changes.'"></span> </span> </td> <!-- /ko --> - <!-- ko ifnot: $parent.isActionsColumn($data) --> - <!-- ko template: $data.isEditor ? $parent.fieldTmpl : getBody() --><!-- /ko --> + <!-- ko if: $col.isEditor --> + <td data-bind="template: $parent.fieldTmpl"></td> + <!-- /ko --> + <!-- ko ifnot: $col.isEditor --> + <td data-bind="template: $col.getBody(), css: $col.getFieldClass()"></td> + <!-- /ko --> + <!-- /ko --> + <!-- /ko --> </tr> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/exportButton.html b/app/code/Magento/Ui/view/base/web/templates/grid/exportButton.html index 84df5efc7227f9e2fde80a844b39c8017d177dea..b77069084f4793a8753418c1c8003da549878ecf 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/exportButton.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/exportButton.html @@ -23,8 +23,8 @@ class="admin__control-radio" data-bind=" attr: { - id: 'export-field-' + value + $index(), - name: 'export' + id: ++ko.bindingHandlers['uniqueName'].currentIndex + '_uid', + name: $parent.name }, checkedValue: value, checked: $parent.checked" @@ -34,7 +34,7 @@ data-bind=" text: label, attr: { - for: 'export-field-' + value + $index() + for: ko.bindingHandlers['uniqueName'].currentIndex + '_uid' }"></label> </div> <!-- /ko --> @@ -52,4 +52,4 @@ </button> </div> </div> -</div> +</div> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/filters/chips.html b/app/code/Magento/Ui/view/base/web/templates/grid/filters/chips.html index e396c223d8a92a5486335ffb6367c95f087322e6..11ef2a9dda524b42bb476e9318908ad74e7883f3 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/filters/chips.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/filters/chips.html @@ -6,7 +6,9 @@ --> <div class="admin__data-grid-filters-current" - data-bind="css: {_show: hasData()}"> + data-bind="css: { + _show: hasPreviews() + }"> <div class="admin__current-filters-title-wrap"> <span class="admin__current-filters-title" @@ -50,7 +52,7 @@ i18n: 'Clear all', click: clear, attr: { - 'data-action': hasData() ? 'grid-filter-reset' : '' + 'data-action': hasPreviews() ? 'grid-filter-reset' : '' }" ></button> </div> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/filters/filters.html b/app/code/Magento/Ui/view/base/web/templates/grid/filters/filters.html index c3ae31d52b181ec49fa5ca785cb018cb4824275a..06ca73a0cfba582847e08ca67c87ad31ce3b435b 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/filters/filters.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/filters/filters.html @@ -37,18 +37,11 @@ <legend class="admin__filters-legend"> <span data-bind="i18n: 'Advanced filter'"></span> </legend> - <!-- ko foreach: elems --> - <!-- ko if: $data.isGroup --> - <fieldset class="admin__form-field" data-bind="visible: $parent.isFilterVisible($data)"> - <!-- ko template: getTemplate() --><!-- /ko --> - </fieldset> - <!-- /ko --> - - <!-- ko ifnot: $data.isGroup --> - <div class="admin__form-field" data-bind="visible: $parent.isFilterVisible($data)"> - <!-- ko template: getTemplate() --><!-- /ko --> - </div> - <!-- /ko --> + <!-- ko foreach: getRanges() --> + <fieldset class="admin__form-field" data-bind="visible: $parent.isFilterVisible($data), template: getTemplate()"></fieldset> + <!-- /ko --> + <!-- ko foreach: getPlain() --> + <div class="admin__form-field" data-bind="visible: $parent.isFilterVisible($data), template: getTemplate()"></div> <!-- /ko --> </fieldset> @@ -70,4 +63,4 @@ </button> </div> </div> -</div> +</div> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/listing.html b/app/code/Magento/Ui/view/base/web/templates/grid/listing.html index 1a1428162c153627ca8d67ac3dad8199101a33c7..68595ee87849926fe6096cbfc6c75ec04864d709 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/listing.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/listing.html @@ -6,26 +6,28 @@ --> <div class="admin__data-grid-wrap" data-role="grid-wrapper"> <table class="data-grid" data-role="grid"> - <thead> - <tr data-bind="foreach: elems"> - <!-- ko template: getHeader() --><!-- /ko --> + <thead> + <tr data-bind="fastForEach: {data: getVisible(), as: '$col'}"> + <!-- ko template: $col.getHeader() --><!-- /ko --> </tr> </thead> <tbody> - <!-- ko foreach: { data: rows, as: 'row' } --> - <tr class="data-row" - data-role="row" - data-bind=" - css: { - '_odd-row': !!($index() % 2) - }, - foreach: { - data: $parent.elems, - as: 'field' - } - "> - <!-- ko template: getBody() --><!-- /ko --> - </tr> + <!-- ko repeat: {foreach: rows, item: '$row'} --> + <tr class="data-row" + data-bind=" + css: { + '_odd-row': !!($index % 2) + } + "> + <!-- ko fastForEach: {data: getVisible(), as: '$col'} --> + <td data-bind=" + css: $col.getFieldClass(), + click: $col.getFieldHandler($row()), + template: $col.getBody() + "> + </td> + <!-- /ko --> + </tr> <!-- /ko --> <!-- ko ifnot: hasData() --> @@ -36,4 +38,4 @@ <!-- /ko --> </tbody> </table> -</div> +</div> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/paging-total.html b/app/code/Magento/Ui/view/base/web/templates/grid/paging-total.html index 0c79131bc2f8e4c994858b5e5d157641d571c5fd..bd2e821dbec25a4d3707d541bcda6041f2eeede2 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/paging-total.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/paging-total.html @@ -6,8 +6,8 @@ --> <div class="admin__control-support-text"> - <span data-bind="i18n: totalRecords"></span> records found + <span data-bind="text: totalRecords"></span> records found <!-- ko if: totalSelected --> - (<span data-bind="i18n: totalSelected"></span> selected) + (<span data-bind="text: totalSelected"></span> selected) <!-- /ko --> -</div> +</div> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/paging/paging.html b/app/code/Magento/Ui/view/base/web/templates/grid/paging/paging.html index 1961cfff11a3d7be640aace14992455fbb0981f8..10f1ff7fd63c37514439b61220c6118acd6181a9 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/paging/paging.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/paging/paging.html @@ -13,9 +13,14 @@ <button class="action-previous" type="button" - data-bind="css: { disabled: isFirst() }, - click: prev"> - <span>Previous page</span> + data-bind=" + attr: { + title: $t('Previous Page') + }, + css: { + disabled: isFirst() + }, + click: prev"> </button> <input id="pageCurrent" @@ -27,9 +32,14 @@ </label> <button class="action-next" - data-bind="css: { disabled: isLast() }, - click: next"> - <span>Next page</span> + data-bind=" + attr: { + title: $t('Next Page') + }, + css: { + disabled: isLast() + }, + click: next"> </button> </div> -</div> +</div> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/paging/sizes.html b/app/code/Magento/Ui/view/base/web/templates/grid/paging/sizes.html index dcc9692793e40d2508b061fdf1a33a5f98c1bc6c..87f093270a5047aaa19807698d197bfc1d820f7c 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/paging/sizes.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/paging/sizes.html @@ -23,47 +23,58 @@ aria-haspopup="true"> <span data-bind="i18n: 'Select'"></span> </button> - <div class="selectmenu-items" data-bind="css: {_active: $collapsible.opened}, - outerClick: discardAll.bind($data)" - data-role="toolbar-collapsible-menu"> + <div + class="selectmenu-items" + data-role="toolbar-collapsible-menu" + data-bind=" + css: {_active: $collapsible.opened}, + outerClick: discardAll.bind($data)"> <ul> - <!-- ko foreach: optionsArray --> - <li data-bind="css: { _edit: $parent.isEditing(value)}"> - <!-- ko if: $data.editable --> + <li + data-bind=" + repeat: { + foreach: optionsArray, + item: '$size' + }" + data-repeat-bind=" + css: { + _edit: isEditing($size().value) + }"> + <!-- ko if: $size().editable --> <div class="selectmenu-item-edit" - data-bind="keyboard: {13: $parent.updateSize.bind($parent, value, false)}"> + data-bind="keyboard: {13: updateSize.bind($data, $size().value, false)}"> <input class="admin__control-text" type="text" - data-bind="value: _value, hasFocus: $parent.isEditing(value)"/> + data-bind="value: $size()._value, hasFocus: isEditing($size().value)"/> <button class="action-save" - data-bind="click: $parent.updateSize.bind($parent, value, false)" + data-bind="click: updateSize.bind($data, $size().value, false)" type="button"> <span data-bind="i18n: 'Save'"></span> </button> <button class="action-delete" - data-bind="click: $parent.removeSize.bind($parent, value, false)" + data-bind="click: removeSize.bind($data, $size().value, false)" type="button"> <span data-bind="i18n: 'Delete'"></span> </button> </div> <!-- /ko --> + <div class="selectmenu-item"> <button type="button" class="selectmenu-item-action" - data-bind="text: label, click: $parent.setSize.bind($parent, value)"></button> - <!-- ko if: $data.editable --> + data-bind="text: $size().label, click: setSize.bind($data, $size().value)"></button> + + <!-- ko if: $size().editable --> <button class="action-edit" data-bind=" click: function () { - $parent - .discardCustom() - .edit(value); + discardCustom().edit($size().value); }" type="button"> <span data-bind="i18n: 'Edit'"></span> @@ -71,7 +82,6 @@ <!-- /ko --> </div> </li> - <!-- /ko --> <li data-bind="css: { _edit: isCustomVisible() }"> <div class="selectmenu-item"> @@ -102,4 +112,4 @@ </ul> </div> </div> -<label class="admin__control-support-text" data-bind="i18n: 'per page', attr: { for: index }"></label> +<label class="admin__control-support-text" data-bind="i18n: 'per page', attr: { for: index }"></label> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/sticky/chips.html b/app/code/Magento/Ui/view/base/web/templates/grid/sticky/chips.html index e396c223d8a92a5486335ffb6367c95f087322e6..178e93097966e92b313cb236e6106d34f9bcd134 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/sticky/chips.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/sticky/chips.html @@ -6,7 +6,7 @@ --> <div class="admin__data-grid-filters-current" - data-bind="css: {_show: hasData()}"> + data-bind="css: {_show: hasPreviews()}"> <div class="admin__current-filters-title-wrap"> <span class="admin__current-filters-title" @@ -50,7 +50,7 @@ i18n: 'Clear all', click: clear, attr: { - 'data-action': hasData() ? 'grid-filter-reset' : '' + 'data-action': hasPreviews() ? 'grid-filter-reset' : '' }" ></button> </div> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/sticky/filters.html b/app/code/Magento/Ui/view/base/web/templates/grid/sticky/filters.html index 9a7e06d5699a531809b9527972df744197a6feab..25c27cfb3ca14b832afc2072b0d9c1691a91f34f 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/sticky/filters.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/sticky/filters.html @@ -17,6 +17,6 @@ attr: {disabled: !hasVisible()}"> <span data-bind="i18n: 'Filters'"></span> </button> - <span class="filters-active" data-bind="text: $data.active().length || ''"></span> <!-- Added the amount of selected filters --> + <span class="filters-active" data-bind="text: countActive() || ''"></span> <!-- Added the amount of selected filters --> </div> </div> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/sticky/listing.html b/app/code/Magento/Ui/view/base/web/templates/grid/sticky/listing.html index fc0c43a4b43315304418d1e1ecbdc602236c06c9..880b52f4dcdbacfb654ecbb09c326e210f335372 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/sticky/listing.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/sticky/listing.html @@ -7,7 +7,7 @@ <div class="admin__data-grid-wrap" data-role="sticky-el-root"> <table class="data-grid"> <thead> - <tr data-bind="foreach: elems"> + <tr data-bind="foreach: {data: visibleColumns, as: '$col'}"> <!-- ko template: getHeader() --><!-- /ko --> </tr> </thead> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/sticky/toolbar.html b/app/code/Magento/Ui/view/base/web/templates/grid/sticky/toolbar.html index 156873520509f2e1c3cc25168f761102344d448d..140a524228935c731d53b250095251f92eb250c9 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/sticky/toolbar.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/sticky/toolbar.html @@ -4,38 +4,25 @@ * See COPYING.txt for license details. */ --> - <div class="admin__data-grid-header" data-role="sticky-el-root"> <div class="admin__data-grid-header-row"> - <!-- ko foreach: getRegion('bottom') --> - <!-- ko if: $data.componentType === 'massaction' --> - <!-- ko template: getTemplate() --><!-- /ko --> - <!-- /ko --> + <!-- ko scope: requestChild('listing_massaction') --> + <!-- ko template: getTemplate() --><!-- /ko --> <!-- /ko --> - <!-- ko foreach: getRegion('bottom') --> - <!-- ko if: $data.componentType === 'paging' --> - <!-- ko template: totalTmpl --><!-- /ko --> - <!-- /ko --> + <!-- ko scope: requestChild('listing_paging') --> + <!-- ko template: totalTmpl --><!-- /ko --> <!-- /ko --> <!-- ko foreach: getRegion('dataGridFilters') --> <!-- ko template: $data.stickyTmpl || getTemplate() --><!-- /ko --> <!-- /ko --> - <div class="admin__data-grid-actions-wrap"> - <!-- ko foreach: getRegion('dataGridActions') --> - <!-- ko template: getTemplate() --><!-- /ko --> - <!-- /ko --> + <div class="admin__data-grid-actions-wrap" data-bind="foreach: getRegion('dataGridActions')"> + <!-- ko template: getTemplate() --><!-- /ko --> </div> - <!-- ko foreach: getRegion('bottom') --> - <!-- ko if: $data.componentType === 'paging' --> - <!-- ko template: getTemplate() --><!-- /ko --> - <!-- /ko --> + <!-- ko scope: requestChild('listing_paging') --> + <!-- ko template: getTemplate() --><!-- /ko --> <!-- /ko --> </div> </div> -<!-- ko foreach: getRegion('dataGridFilters') --> - <!-- ko if: $data.index === 'listing_filters' --> - <!-- ko scope: chips --> - <!-- ko template: $data.stickyTmpl || getTemplate() --> - <!-- /ko --> - <!-- /ko --> +<!-- ko scope: requestChild('listing_filters_chips') --> + <!-- ko template: $data.stickyTmpl || getTemplate() --> <!-- /ko --> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/toolbar.html b/app/code/Magento/Ui/view/base/web/templates/grid/toolbar.html index 36482b1d973bae48f5d946dff86c27f6c0bc724e..529b32d7d7a7b43ed1c7c6ce82f72f81210afef4 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/toolbar.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/toolbar.html @@ -5,41 +5,26 @@ */ --> -<div class="admin__data-grid-header" - data-role="data-grid-toolbar"> +<div class="admin__data-grid-header" data-role="data-grid-toolbar"> <div class="admin__data-grid-header-row"> - <div class="admin__data-grid-actions-wrap"> - <!-- ko foreach: getRegion('dataGridActions') --> + <div class="admin__data-grid-actions-wrap" data-bind="foreach: getRegion('dataGridActions')"> <!-- ko template: getTemplate() --><!-- /ko --> - <!-- /ko --> </div> <!-- ko foreach: getRegion('dataGridFilters') --> - <!-- ko template: getTemplate() --><!-- /ko --> + <!-- ko template: getTemplate() --><!-- /ko --> <!-- /ko --> </div> <div class="admin__data-grid-header-row row row-gutter"> - <div class="col-xs-2"> - <!-- ko foreach: getRegion('bottom') --> - <!-- ko if: $data.componentType === 'massaction' --> - <!-- ko template: getTemplate() --><!-- /ko --> - <!-- /ko --> - <!-- /ko --> + <div class="col-xs-2" data-bind="scope: requestChild('listing_massaction')"> + <!-- ko template: getTemplate() --><!-- /ko --> </div> <div class="col-xs-10"> <div class="row"> - <div class="col-xs-3"> - <!-- ko foreach: getRegion('bottom') --> - <!-- ko if: $data.componentType === 'paging' --> - <!-- ko template: totalTmpl --><!-- /ko --> - <!-- /ko --> - <!-- /ko --> + <div class="col-xs-3" data-bind="scope: requestChild('listing_paging')"> + <!-- ko template: totalTmpl --><!-- /ko --> </div> - <div class="col-xs-9"> - <!-- ko foreach: getRegion('bottom') --> - <!-- ko if: $data.componentType === 'paging' --> - <!-- ko template: getTemplate() --><!-- /ko --> - <!-- /ko --> - <!-- /ko --> + <div class="col-xs-9" data-bind="scope: requestChild('listing_paging')"> + <!-- ko template: getTemplate() --><!-- /ko --> </div> </div> </div> diff --git a/app/code/Magento/Ui/view/base/web/templates/modal/modal-custom.html b/app/code/Magento/Ui/view/base/web/templates/modal/modal-custom.html index 990630aa02b9c1ee71088b56bd345ed33e4d3a6e..0a45aa20a02e275baf8433894568b86b7ff2a87f 100644 --- a/app/code/Magento/Ui/view/base/web/templates/modal/modal-custom.html +++ b/app/code/Magento/Ui/view/base/web/templates/modal/modal-custom.html @@ -9,8 +9,11 @@ <% if(data.responsive){ %><%= data.responsiveClass %><% } %> <% if(data.innerScroll){ %><%= data.innerScrollClass %><% } %>" data-role="modal" - data-type="<%= data.type %>"> - <div class="modal-inner-wrap"> + data-type="<%= data.type %>" + tabindex="0"> + <div data-role="focusable-start" tabindex="0"></div> + <div class="modal-inner-wrap" + data-role="focusable-scope"> <header class="modal-header"> <% if(data.title){ %> <h1 class="modal-title" @@ -35,4 +38,5 @@ </footer> <% } %> </div> + <div data-role="focusable-end" tabindex="0"></div> </aside> diff --git a/app/code/Magento/Ui/view/base/web/templates/modal/modal-popup.html b/app/code/Magento/Ui/view/base/web/templates/modal/modal-popup.html index 43ac20b2aeb1e26bce6330232755be77e5c4605c..22aad07f4ea2983750a7957ce1e5f74357fce4be 100644 --- a/app/code/Magento/Ui/view/base/web/templates/modal/modal-popup.html +++ b/app/code/Magento/Ui/view/base/web/templates/modal/modal-popup.html @@ -10,8 +10,11 @@ <% if(data.responsive){ %><%= data.responsiveClass %><% } %> <% if(data.innerScroll){ %><%= data.innerScrollClass %><% } %>" data-role="modal" - data-type="<%= data.type %>"> - <div class="modal-inner-wrap"> + data-type="<%= data.type %>" + tabindex="0"> + <div data-role="focusable-start" tabindex="0"></div> + <div class="modal-inner-wrap" + data-role="focusable-scope"> <header class="modal-header"> <% if(data.title){ %> <h1 class="modal-title" @@ -38,4 +41,5 @@ </footer> <% } %> </div> + <div data-role="focusable-end" tabindex="0"></div> </aside> diff --git a/app/code/Magento/Ui/view/base/web/templates/modal/modal-slide.html b/app/code/Magento/Ui/view/base/web/templates/modal/modal-slide.html index abffa4573962a7acc129a0f3f0a96c2765240731..8b828035939a0dc928e6cec6a61a31e665599275 100644 --- a/app/code/Magento/Ui/view/base/web/templates/modal/modal-slide.html +++ b/app/code/Magento/Ui/view/base/web/templates/modal/modal-slide.html @@ -9,8 +9,11 @@ class="modal-<%= data.type %> <%= data.modalClass %> <% if(data.innerScroll){ %><%= data.innerScrollClass %><% } %>" data-role="modal" - data-type="<%= data.type %>"> - <div class="modal-inner-wrap"> + data-type="<%= data.type %>" + tabindex="0"> + <div data-role="focusable-start" tabindex="0"></div> + <div class="modal-inner-wrap" + data-role="focusable-scope"> <header class="modal-header"> <% if(data.title){ %> <h1 class="modal-title" @@ -40,4 +43,5 @@ </header> <div class="modal-content" data-role="content"></div> </div> + <div data-role="focusable-end" tabindex="0"></div> </aside> diff --git a/app/code/Magento/User/view/adminhtml/web/app-config.js b/app/code/Magento/User/view/adminhtml/web/app-config.js index 25bc4e7b6ca8902b794662884a09d6c755b14882..378afec02a6223d1eabc80c7e76dc5a7521e7774 100644 --- a/app/code/Magento/User/view/adminhtml/web/app-config.js +++ b/app/code/Magento/User/view/adminhtml/web/app-config.js @@ -11,7 +11,6 @@ require.config({ "mage/adminhtml/backup": ["prototype"], "mage/captcha": ["prototype"], "mage/common": ["jquery"], - "mage/requirejs/plugin/id-normalizer": ["jquery"], "mage/webapi": ["jquery"], "ko": { exports: "ko" }, "moment": { exports: "moment" } diff --git a/app/code/Magento/Variable/view/adminhtml/web/variables.js b/app/code/Magento/Variable/view/adminhtml/web/variables.js index 2b71f6bc50c7c4aff622bc881b35818f5bad2f77..20292ecdf3c6d93fa5be3f0e8c74546b63a62dd6 100644 --- a/app/code/Magento/Variable/view/adminhtml/web/variables.js +++ b/app/code/Magento/Variable/view/adminhtml/web/variables.js @@ -3,10 +3,12 @@ * See COPYING.txt for license details. */ define([ - "jquery", - "jquery/ui", - "prototype" -], function(jQuery){ + 'jquery', + 'mage/translate', + 'Magento_Ui/js/modal/modal', + 'jquery/ui', + 'prototype', +], function(jQuery, $t){ window.Variables = { textareaElementId: null, @@ -50,43 +52,23 @@ window.Variables = { this.openDialogWindow(this.variablesContent); } }, - openDialogWindow: function(variablesContent) { + openDialogWindow: function (variablesContent) { var windowId = this.dialogWindowId; - jQuery('body').append('<div id="' + windowId + '">'+ Variables.variablesContent +'</div>'); - jQuery('#' + windowId).dialog({ - autoOpen: false, - title: "Insert Variable...", - modal: true, - resizable: false, - minWidth: 500, - width: '75%', - position: { - my: 'left top', - at: 'center top', - of: 'body' - }, - open: function () { - jQuery(this).closest('.ui-dialog').addClass('ui-dialog-active'); - - var topMargin = jQuery(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 30; - jQuery(this).closest('.ui-dialog').css('margin-top', topMargin); - }, - close: function(event, ui) { - jQuery(this).closest('.ui-dialog').removeClass('ui-dialog-active'); - jQuery(this).dialog('destroy'); - jQuery('#' + windowId).remove(); + jQuery('<div id="' + windowId + '">' + Variables.variablesContent + '</div>').modal({ + title: $t('Insert Variable...'), + type: 'slide', + buttons: [], + closed: function (e, modal) { + modal.modal.remove(); } }); - jQuery('#' + windowId).dialog('open'); + jQuery('#' + windowId).modal('openModal'); variablesContent.evalScripts.bind(variablesContent).defer(); }, - closeDialogWindow: function(window) { - var windowId = this.dialogWindowId; - if(jQuery('#' + windowId).length){ - jQuery('#' + windowId).dialog('close'); - } + closeDialogWindow: function() { + jQuery('#' + this.dialogWindowId).modal('closeModal'); }, prepareVariableRow: function(varValue, varLabel) { var value = (varValue).replace(/"/g, '"').replace(/'/g, '\\''); @@ -95,7 +77,7 @@ window.Variables = { }, insertVariable: function(value) { var windowId = this.dialogWindowId; - jQuery('#' + windowId).dialog('close'); + jQuery('#' + windowId).modal('closeModal'); var textareaElm = $(this.textareaElementId); if (textareaElm) { var scrollPos = textareaElm.scrollTop; diff --git a/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml b/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml index bcdf62afc6bf8abd99a6519309af87bd9c109801..94a3eb7145be0c27125f3adfbddd11b998bade3e 100644 --- a/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml +++ b/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml @@ -22,9 +22,10 @@ require([ 'jquery', 'mage/template', + 'Magento_Ui/js/modal/alert', "prototype", "extjs/ext-tree-checkbox" -], function (jQuery, mageTemplate) { +], function (jQuery, mageTemplate, alert) { //<![CDATA[ @@ -376,7 +377,9 @@ var WidgetInstance = { chooser.show(); } } catch (e) { - alert('Error occurs during loading chooser.'); + alert({ + content: 'Error occurs during loading chooser.' + }); } } }); @@ -469,7 +472,9 @@ var WidgetInstance = { } } } catch (e) { - alert('Error occurs during loading chooser.'); + alert({ + content: 'Error occurs during loading chooser.' + }); } } }); diff --git a/app/code/Magento/Wishlist/view/adminhtml/templates/customer/edit/tab/wishlist.phtml b/app/code/Magento/Wishlist/view/adminhtml/templates/customer/edit/tab/wishlist.phtml index ff2714c07c92ad5a0607ecda388e5cb17f6b770c..0262fe571fd4a6094a5ee9c007f1831f97dde78c 100644 --- a/app/code/Magento/Wishlist/view/adminhtml/templates/customer/edit/tab/wishlist.phtml +++ b/app/code/Magento/Wishlist/view/adminhtml/templates/customer/edit/tab/wishlist.phtml @@ -11,30 +11,31 @@ */ ?> <script> -require([ - "prototype", - "Magento_Catalog/catalog/product/composite/configure" -], function(){ + require([ + "Magento_Ui/js/modal/confirm", + "prototype", + "Magento_Catalog/catalog/product/composite/configure" + ], function(confirm){ //<!-- -wishlistControl = { - reload: function (urlParams) { - if (!urlParams) { - urlParams = ''; - } - var url = <?php /* @escapeNotVerified */ echo $block->getJsObjectName() ?>.url + '?ajax=true' + urlParams; - new Ajax.Updater( - <?php /* @escapeNotVerified */ echo $block->getJsObjectName() ?>.containerId, - url, - { - parameters: {form_key: FORM_KEY}, - onComplete: <?php /* @escapeNotVerified */ echo $block->getJsObjectName() ?>.initGrid.bind(<?php /* @escapeNotVerified */ echo $block->getJsObjectName() ?>), - evalScripts:true - } - ); - }, + wishlistControl = { + reload: function (urlParams) { + if (!urlParams) { + urlParams = ''; + } + var url = <?php /* @escapeNotVerified */ echo $block->getJsObjectName() ?>.url + '?ajax=true' + urlParams; + new Ajax.Updater( + <?php /* @escapeNotVerified */ echo $block->getJsObjectName() ?>.containerId, + url, + { + parameters: {form_key: FORM_KEY}, + onComplete: <?php /* @escapeNotVerified */ echo $block->getJsObjectName() ?>.initGrid.bind(<?php /* @escapeNotVerified */ echo $block->getJsObjectName() ?>), + evalScripts:true + } + ); + }, - configureItem: function (itemId) { + configureItem: function (itemId) { productConfigure.setOnLoadIFrameCallback('wishlist', this.cbOnLoadIframe.bind(this)); productConfigure.showItemConfiguration('wishlist', itemId); return false; @@ -48,22 +49,27 @@ wishlistControl = { }, removeItem: function (itemId) { - if(!confirm('<?php /* @escapeNotVerified */ echo __('Are you sure you want to remove this item?') ?>')) { - return false; - } - this.reload('&delete=' + itemId); - return false; - } -} + var self = this; -productConfigure.addListType( - 'wishlist', - { - urlFetch: '<?php /* @escapeNotVerified */ echo $block->getUrl('customer/wishlist_product_composite_wishlist/configure') ?>', - urlConfirm: '<?php /* @escapeNotVerified */ echo $block->getUrl('customer/wishlist_product_composite_wishlist/update') ?>' + confirm({ + content: '<?php /* @escapeNotVerified */ echo __('Are you sure you want to remove this item?') ?>', + actions: { + confirm: function () { + self.reload('&delete=' + itemId); + } + } + }); + } } -); -//--> -}); + productConfigure.addListType( + 'wishlist', + { + urlFetch: '<?php /* @escapeNotVerified */ echo $block->getUrl('customer/wishlist_product_composite_wishlist/configure') ?>', + urlConfirm: '<?php /* @escapeNotVerified */ echo $block->getUrl('customer/wishlist_product_composite_wishlist/update') ?>' + } + ); + //--> + + }); </script> diff --git a/app/code/Magento/Wishlist/view/frontend/web/wishlist.js b/app/code/Magento/Wishlist/view/frontend/web/wishlist.js index bb697c1fa5259c12f20b4ac550b0d49f4f83ec85..a831603f9d1b4f8cc26ea81ccc841d8dd8a76746 100644 --- a/app/code/Magento/Wishlist/view/frontend/web/wishlist.js +++ b/app/code/Magento/Wishlist/view/frontend/web/wishlist.js @@ -7,10 +7,12 @@ define([ 'jquery', 'mage/template', + 'Magento_Ui/js/modal/alert', 'jquery/ui', 'mage/validation/validation', + 'mage/dataPost' -], function ($, mageTemplate) { +], function ($, mageTemplate, alert) { 'use strict'; $.widget('mage.wishlist', { @@ -152,7 +154,9 @@ define([ if ($(form).find('input:checkbox:checked').length) { form.submit(); } else { - alert(this.options.checkBoxValidationMessage); + alert({ + content: this.options.checkBoxValidationMessage + }); } }, this) }); diff --git a/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_steps-wizard.less b/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_steps-wizard.less index f09454d5862d66eebae899491dd4c32879e7d5c4..4cd621361e3b64df0cef4771ebf137359bbd9f6c 100644 --- a/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_steps-wizard.less +++ b/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_steps-wizard.less @@ -72,8 +72,4 @@ margin: @indent__base 0; } } - - .admin__data-grid-pager-wrap { - float: right; - } } diff --git a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-pager.less b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-pager.less index a30087cb5a6972ca99f7636d3a4fe26e9ee59219..ec5761b7b2a0c70151d46df186d13f1aeb89ad97 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-pager.less +++ b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-pager.less @@ -17,6 +17,7 @@ .admin__data-grid-pager-wrap { text-align: right; + float: right; } .admin__data-grid-pager { diff --git a/app/design/adminhtml/Magento/backend/web/css/source/_components.less b/app/design/adminhtml/Magento/backend/web/css/source/_components.less index a9ee8f523cc024a0cf14676317158fd8175d58a2..b376a1a2bd201c0c7281bc9cd8c01f4ccf392114 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/_components.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/_components.less @@ -13,3 +13,4 @@ @import 'components/_popups.less'; @import 'components/_modals.less'; @import 'components/_modals_extend.less'; +@import 'components/_file-insertion.less'; diff --git a/app/design/adminhtml/Magento/backend/web/css/source/_forms.less b/app/design/adminhtml/Magento/backend/web/css/source/_forms.less index 2e18751ca49556d148c3c8eb2689908a5956ebec..8e1e484f69ac804738d756db855b4a2f09ab7295 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/_forms.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/_forms.less @@ -7,3 +7,4 @@ @import 'forms/_controls.less'; @import 'forms/_fields.less'; @import 'forms/_temp.less'; +@import 'forms/_form-wysiwyg.less'; diff --git a/app/design/adminhtml/Magento/backend/web/css/source/components/_file-insertion.less b/app/design/adminhtml/Magento/backend/web/css/source/components/_file-insertion.less new file mode 100644 index 0000000000000000000000000000000000000000..cdc66d477555dc532e9f3d9d264c6df18ad0a131 --- /dev/null +++ b/app/design/adminhtml/Magento/backend/web/css/source/components/_file-insertion.less @@ -0,0 +1,49 @@ +// /** +// * Copyright © 2015 Magento. All rights reserved. +// * See COPYING.txt for license details. +// */ + +// +// Block 'Insert File' +// _________________________________________ + +.contents-uploader { + margin: 0 0 @indent__base; + .fileinput-button { + cursor: pointer; + display: inline-block; + float: none; + vertical-align: middle; + span { + display: none; + } + input { + -moz-transforms: none; + border: none; + opacity: 1; + position: static; + } + } +} + +.file-row { + border: 1px solid @color-gray68; + margin: @indent__xs 0; + padding: 2px; +} + +.filecnt { + border: 1px solid @color-gray68; + cursor: pointer; + display: inline-block; + margin: 0 @indent__xs 15px 0; + overflow: hidden; + padding: 3px; + width: 100px; + &.selected { + border-color: @color-blue-dodger; + } + p { + text-align: center; + } +} diff --git a/app/design/adminhtml/Magento/backend/web/css/source/components/_modals_extend.less b/app/design/adminhtml/Magento/backend/web/css/source/components/_modals_extend.less index 0ea7e84b1447fd2084d24fe1bf1259959f6ca77c..babbdf33f37c48d257f8b9ab055cc49154831065 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/components/_modals_extend.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/components/_modals_extend.less @@ -21,6 +21,13 @@ @modal-action-close__font-size: 2rem; @modal-action-close__active__font-size: 1.8rem; @modal-action-close__hover__color: darken(@color-brownie-vanilla, 10%); +@modal-popup-footer-button__margin: 2rem; +@modal-popup-footer-button__padding: 1.4rem; +@modal-popup-footer-button__font-size: 1.5rem; +@modal-popup-footer-button__color: @color-brownie; +@modal-popup-colored__background: @color-lazy-sun; +@modal-popup-colorless__background: @color-white; +@modal-prompt-message__padding: 2rem; // @@ -31,6 +38,7 @@ position: absolute; right: 0; top: 0; + z-index: 1; &:active { transform: none; &:before { @@ -49,10 +57,74 @@ } .modal-popup { + &.prompt { + .prompt-message { + padding: @modal-prompt-message__padding 0; + input { + width: 100%; + } + } + } + &.confirm, + &.prompt { + .modal-inner-wrap { + .message { + background: @modal-popup-colorless__background; + } + } + } + &.modal-system-messages { + .modal-inner-wrap { + background: @modal-popup-colored__background; + } + } + &._image-box { + .modal-inner-wrap { + margin: 5rem auto; + max-width: @modal-popup-image-box__max-width; + position: static; + } + .thumbnail-preview { + padding-bottom: @indent__l; + text-align: center; + .thumbnail-preview-image-block { + border: 1px solid @modal-popup-image-box__border-color; + margin: 0 auto @indent__base; + max-width: @modal-popup-image-box-preview__max-width; + padding: @indent__base; + } + .thumbnail-preview-image { + max-height: @modal-popup-image-box-preview-image__max-height; + } + } + } + .modal-title { font-size: @modal-popup-title__font-size; margin-right: @modal-popup-title__font-size + @modal-popup__padding + 1rem; } + + .action-close { + padding: @modal-popup__padding @modal-popup__padding; + &:active{ + padding-top: @modal-popup__padding + (@modal-action-close__font-size - @modal-action-close__active__font-size) / 3; + padding-right: @modal-popup__padding + (@modal-action-close__font-size - @modal-action-close__active__font-size) / 3; + } + } + + .modal-footer { + text-align: right; + padding-top: @modal-slide__padding; + + .action-primary { + &:extend(.abs-action-secondary all); + &:extend(.abs-action-l all); + } + .action-secondary { + &:extend(.abs-action-tertiary all); + &:extend(.abs-action-l all); + } + } .action-close { padding: @modal-popup__padding; &:active, @@ -69,16 +141,63 @@ font-size: @modal-slide-title__font-size; margin-right: @modal-slide-title__font-size + @modal-slide__padding + 1rem; } + .action-close { padding: @modal-slide-header__padding-vertical @modal-slide__padding; &:active { - padding-right: @modal-slide__padding + (@modal-action-close__font-size - @modal-action-close__active__font-size) / 2; padding-top: @modal-slide-header__padding-vertical + (@modal-action-close__font-size - @modal-action-close__active__font-size) / 2; + padding-right: @modal-slide__padding + (@modal-action-close__font-size - @modal-action-close__active__font-size) / 2; } } .page-main-actions { - margin-bottom: @modal-slide-header__padding-vertical - @page-main-actions__padding; margin-top: @modal-slide-header__padding-vertical; + margin-bottom: @modal-slide-header__padding-vertical - @page-main-actions__padding; + } + + .magento_message { + padding: 0 @popup__padding__horizontal @popup__padding__vertical; + position: relative; + } + + .main-col, + .magento_message { + .insert-title-inner { + &:extend(.abs-clearfix all); + border-bottom: 1px solid @color-gray68; + margin: 0 0 @indent__base; + padding-bottom: @indent__xs; + } + .insert-actions { + float: right; + } + .title { + font-size: @font-size__l; + padding-top: @indent__xs; + } + } + + .main-col, + .side-col { + float: left; + padding-bottom: 0; + &:after { + display: none; + } + } + + .side-col { + width: 20%; + } + + .main-col { + padding-right: 0; + width: 80%; + } + + .content-footer { + .form-buttons { + float: right; + } } } @@ -86,4 +205,4 @@ font-weight: @font-weight__regular; margin-bottom: 0; min-height: 1em; -} +} \ No newline at end of file diff --git a/app/design/adminhtml/Magento/backend/web/css/source/components/_popups.less b/app/design/adminhtml/Magento/backend/web/css/source/components/_popups.less index 6586433b784236fba11f88d78df23519b19a5ca3..520b26a148b743f5a05985e148f70d34ef844299 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/components/_popups.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/components/_popups.less @@ -389,15 +389,24 @@ // Attribute Popup // _____________________________________________ -.attribute-popup-actions { - background: @color-white; - border-top: 1px solid @color-gray68; - bottom: 0; - left: 0; - padding: @popup__padding; - position: fixed; - right: 0; - top: auto !important; +.catalog-product-attribute-edit { + .page-wrapper { + width: 100%; + .page-content { + padding-left: 0; + } + } +} + +.attribute-popup-actions { // ToDo UI: remove or refactor after New attribute popup refactored to sliding panel + &:extend(.abs-clearfix all); + background: @page-main-actions__background-color; + border-bottom: 1px solid @page-main-actions__border-color; + border-top: 1px solid @page-main-actions__border-color; + padding: @page-main-actions__padding; + &.page-actions { + float: none; + } &.fixed { // ToDo UI: remove or refactor after New attribute popup refactored to sliding panel background: @color-white !important; border-bottom: 0 !important; diff --git a/app/design/adminhtml/Magento/backend/web/css/source/forms/_form-wysiwyg.less b/app/design/adminhtml/Magento/backend/web/css/source/forms/_form-wysiwyg.less new file mode 100644 index 0000000000000000000000000000000000000000..8ce2fedb6619f3f25d73bd6a55752266ee5a2eda --- /dev/null +++ b/app/design/adminhtml/Magento/backend/web/css/source/forms/_form-wysiwyg.less @@ -0,0 +1,20 @@ +// /** +// * Copyright © 2015 Magento. All rights reserved. +// * See COPYING.txt for license details. +// */ + +// +// Wysiwyg form control styles +// --------------------------------------------- + +.admin__control-wysiwig { + .buttons-set { + margin: 0 0 15px; + button { + margin-right: 4px; + } + } + textarea{ + width: 100%; + } +} diff --git a/app/design/adminhtml/Magento/backend/web/js/theme.js b/app/design/adminhtml/Magento/backend/web/js/theme.js index 9d1524c4e2352bcdf793859851d0ed0b63c4e3db..5fdaa4c582430c25e0c085121e00ce6ed8e3580a 100644 --- a/app/design/adminhtml/Magento/backend/web/js/theme.js +++ b/app/design/adminhtml/Magento/backend/web/js/theme.js @@ -126,12 +126,13 @@ define('globalNavigationScroll', [ menuItems.on('click', function (e) { var submenu = $(this).children(subMenuClass), - delta; + delta, + logo = $('.logo')[0].offsetHeight; submenuHeight = submenu.height(); - if (submenuHeight > menuHeight && menuHeight > winHeight) { - menu.height(submenuHeight - $('.logo')[0].offsetHeight); + if (submenuHeight > menuHeight && menuHeight + logo > winHeight) { + menu.height(submenuHeight - logo); delta = -menu.position().top; window.scrollTo(0, 0); positionMenu(); diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Cache.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Cache.php index 988614620e01b51334c734ea0a2e594487d8611f..be0e3f829e2eb6eb668972e7143aa8e4e4dc35cb 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Cache.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Cache.php @@ -59,7 +59,6 @@ class Cache extends Block public function flushCacheStorage() { $this->_rootElement->find($this->flushCacheStorageButton)->click(); - $this->browser->acceptAlert(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/FormPageActions.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/FormPageActions.php index 246c3113a8d176f05a2b226aab70d056f2effe50..302139354092fc6fdc2cb429056cbadfc1b016b3 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/FormPageActions.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/FormPageActions.php @@ -110,7 +110,6 @@ class FormPageActions extends PageActions public function delete() { $this->_rootElement->find($this->deleteButton)->click(); - $this->browser->acceptAlert(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php index 2dbbdd6fe04c8e4a7b57f1fc71316dd4e1c85023..281c4fbd7a08164f8801d52fce5576a2eb140baa 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php @@ -35,7 +35,6 @@ class PageActions extends AbstractPageActions { $this->_rootElement->find($this->scopeSelector, Locator::SELECTOR_CSS, 'liselectstore') ->setValue($websiteScope); - $this->browser->acceptAlert(); return $this; } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php index 8e1e7be0371373664c4deb588110301cd7f13182..65017b9c85d99fec33b811997c6aec9d17848d67 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php @@ -188,6 +188,13 @@ abstract class Grid extends Block */ protected $rowPattern = '//tbody/tr[%s]'; + /** + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + /** * Get backend abstract block * @@ -340,7 +347,10 @@ abstract class Grid extends Block { $this->_rootElement->find($this->massactionSubmit, Locator::SELECTOR_CSS)->click(); if ($acceptAlert) { - $this->browser->acceptAlert(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertStoreCanBeLocalized.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertStoreCanBeLocalized.php index ffd5e52d7eaa2e47792d8b04636b80198dac9fd3..fd241121f62fc88eaa86debe9df1aa86242f53b0 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertStoreCanBeLocalized.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertStoreCanBeLocalized.php @@ -38,6 +38,7 @@ class AssertStoreCanBeLocalized extends AbstractConstraint // Set locale options $systemConfig->open(); $systemConfig->getPageActions()->selectStore($store->getGroupId() . "/" . $store->getName()); + $systemConfig->getModalBlock()->acceptAlert(); $configGroup = $systemConfig->getForm()->getGroup('Locale Options'); $configGroup->open(); $configGroup->setValue('select-groups-locale-fields-code-value', $locale); diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/AdminCache.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/AdminCache.xml index bb9fc78299f5ddecdcc0f1baa66690879baef977..ed129a534adb77e2686f91a5dbd3723e39dbe7a4 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/AdminCache.xml +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/AdminCache.xml @@ -10,5 +10,6 @@ <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages .messages" strategy="css selector"/> <block name="actionsBlock" class="Magento\Backend\Test\Block\Cache" locator="div.page-actions" strategy="css selector"/> <block name="additionalBlock" class="Magento\Backend\Test\Block\Cache\Additional" locator="div.additional-cache-management" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/SystemConfig.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/SystemConfig.xml index 9b9a0f3a3093c1bded062e441827c8a43733fc94..4dbb6babb500ec6cb10e25b05b5dae7550c3f878 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/SystemConfig.xml +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/SystemConfig.xml @@ -6,9 +6,10 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="SystemConfig" area="Adminhtml" mca="admin/system_config" module="Magento_Backend"> - <block name="pageActions" class="Magento\Backend\Test\Block\System\Config\PageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="form" class="Magento\Backend\Test\Block\System\Config\Form" locator="#config-edit-form" strategy="css selector"/> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> - </page> + <page name="SystemConfig" area="Adminhtml" mca="admin/system_config" module="Magento_Backend"> + <block name="pageActions" class="Magento\Backend\Test\Block\System\Config\PageActions" locator=".page-main-actions" strategy="css selector"/> + <block name="form" class="Magento\Backend\Test\Block\System\Config\Form" locator="#config-edit-form" strategy="css selector"/> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php index 20688802c899c457d0d6723e00d1a1ec0afe8898..7f973d398b8d5b4c17ffe89b1d3265a3568b5e99 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php @@ -22,7 +22,7 @@ class Option extends Form * * @var string */ - protected $searchGridBlock = "ancestor::body//div[contains(@style,'display: block') and @role='dialog']"; + protected $searchGridBlock = "ancestor::body//aside[contains(@class,'_show') and @data-role='modal']"; /** * Added product row diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main.php index 47a2e261ba15fd602141d4e20f9cc5d73b7bf695..58128695cc34a41989502b51e65ff907a5906c9a 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main.php @@ -50,6 +50,13 @@ class Main extends Block */ protected $noteBlock = '.attribute-set .title'; + /** + * Selector for prompt. + * + * @var string + */ + protected $promptModal = '.prompt._show[data-role=modal]'; + /** * Move Attribute to Attribute Group * @@ -123,7 +130,10 @@ class Main extends Block public function addAttributeSetGroup($groupName) { $this->_rootElement->find($this->addGroupButton)->click(); - $this->browser->setAlertText($groupName); - $this->browser->acceptAlert(); + $element = $this->browser->find($this->promptModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->setAlertText($groupName); + $modal->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php index 6416c7c9c7a0672d9b8e147516de5de8a6d79867..9af022411c24bca0123ea9a720a736cc1686322c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php @@ -44,7 +44,7 @@ class Configure extends AbstractConfigureBlock * * @var string */ - protected $okButton = '.ui-button.action-primary'; + protected $okButton = '.action-primary[data-role="action"]'; /** * Backend abstract block. diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Options.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Options.php index e1524101cee79623cf454e1fbc94205a7982dba4..0cd45384360867851e78f7781e45779910c28b03 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Options.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Options.php @@ -51,7 +51,7 @@ class Options extends Tab * * @var string */ - protected $importGrid = "//ancestor::body/div[*[@id='import-container'] and contains(@style,'display: block')]"; + protected $importGrid = "//ancestor::body//aside[*//div[@id='import-container']]"; /** * Fill custom options form on tab diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Grid.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Grid.php index c23f96bef04d15ffdd348ba251f11174f09db5a2..c13742e661e3f7454cfe69dfebbd9ad910963017 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Grid.php @@ -27,37 +27,37 @@ class Grid extends DataGrid */ protected $filters = [ 'name' => [ - 'selector' => '[name="filters[name]"]', + 'selector' => '[name="name"]', ], 'sku' => [ - 'selector' => '[name="filters[sku]"]', + 'selector' => '[name="sku"]', ], 'type' => [ - 'selector' => '[name="filters[type_id]"]', + 'selector' => '[name="type_id"]', 'input' => 'select', ], 'price_from' => [ - 'selector' => '[name="filters[price][from]"]', + 'selector' => '[name="price[from]"]', ], 'price_to' => [ - 'selector' => '[name="filters[price][to]"]', + 'selector' => '[name="price[to]"]', ], 'qty_from' => [ - 'selector' => '[name="filters[qty][from]"]', + 'selector' => '[name="qty[from]"]', ], 'qty_to' => [ - 'selector' => '[name="filters[qty][to]"]', + 'selector' => '[name="qty[to]"]', ], 'visibility' => [ - 'selector' => '[name="filters[visibility]"]', + 'selector' => '[name="visibility"]', 'input' => 'select', ], 'status' => [ - 'selector' => '[name="filters[status]"]', + 'selector' => '[name="status"]', 'input' => 'select', ], 'set_name' => [ - 'selector' => '[name="filters[attribute_set_id]"]', + 'selector' => '[name="attribute_set_id"]', 'input' => 'select', ], ]; diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/Sidebar.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/Sidebar.php index ea1a27a09e26292c9a81f23f6cb9f7f07e4c407e..eec1be1fcf543149fbcc08a034fa02628c4065c2 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/Sidebar.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/Sidebar.php @@ -32,6 +32,13 @@ class Sidebar extends ListCompare */ protected $clearAll = '#compare-clear-all'; + /** + * Selector for alert. + * + * @var string + */ + protected $alertModal = '._show[data-role=modal]'; + /** * Get compare products block content. * @@ -79,6 +86,9 @@ class Sidebar extends ListCompare } ); $this->_rootElement->find($this->clearAll)->click(); - $this->browser->acceptAlert(); + $element = $this->browser->find($this->alertModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogCategoryEdit.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogCategoryEdit.xml index 6c94684f9931aa51bcd24d7ea2a59cd2a5201834..a9efc7486ed7a16fcf6b5b95ac675a8b728df48b 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogCategoryEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogCategoryEdit.xml @@ -6,9 +6,10 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="CatalogCategoryEdit" area="Adminhtml" mca="catalog/category/edit" module="Magento_Catalog"> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> - <block name="formPageActions" class="Magento\Catalog\Test\Block\Adminhtml\Category\Edit\PageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="editForm" class="Magento\Catalog\Test\Block\Adminhtml\Category\Edit\CategoryForm" locator="#category-edit-container" strategy="css selector"/> - </page> + <page name="CatalogCategoryEdit" area="Adminhtml" mca="catalog/category/edit" module="Magento_Catalog"> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> + <block name="formPageActions" class="Magento\Catalog\Test\Block\Adminhtml\Category\Edit\PageActions" locator=".page-main-actions" strategy="css selector"/> + <block name="editForm" class="Magento\Catalog\Test\Block\Adminhtml\Category\Edit\CategoryForm" locator="#category-edit-container" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductAttributeNew.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductAttributeNew.xml index 7340141c593ee3fd494b638beab71df8e12075c4..b53ec68704e7093111573610aab4e467d8f84b8a 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductAttributeNew.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductAttributeNew.xml @@ -6,9 +6,10 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="CatalogProductAttributeNew" area="Adminhtml" mca="catalog/product_attribute/new" module="Magento_Catalog"> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> - <block name="pageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="attributeForm" class="Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Edit\AttributeForm" locator="[id='page:main-container']" strategy="css selector"/> - </page> + <page name="CatalogProductAttributeNew" area="Adminhtml" mca="catalog/product_attribute/new" module="Magento_Catalog"> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> + <block name="pageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector"/> + <block name="attributeForm" class="Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Edit\AttributeForm" locator="[id='page:main-container']" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml index be45d688fbc5ab5315cea13690e3d2f717083054..318016cdd30355292c6ae10936b606b4fe3f7691 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml @@ -6,9 +6,10 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="CatalogProductSetEdit" area="Adminhtml" mca="catalog/product_set/edit" module="Magento_Catalog"> - <block name="pageActions" class="Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Set\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="attributeSetEditBlock" class="Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Set\Main" locator=".attribute-set" strategy="css selector"/> - <block name="attributeSetEditForm" class="Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Set\Main\EditForm" locator="#set_name" strategy="css selector"/> - </page> + <page name="CatalogProductSetEdit" area="Adminhtml" mca="catalog/product_set/edit" module="Magento_Catalog"> + <block name="pageActions" class="Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Set\FormPageActions" locator=".page-main-actions" strategy="css selector"/> + <block name="attributeSetEditBlock" class="Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Set\Main" locator=".attribute-set" strategy="css selector"/> + <block name="attributeSetEditForm" class="Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Set\Main\EditForm" locator="#set_name" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/DeleteCategoryEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/DeleteCategoryEntityTest.php index e6bafe0e25615211ce15857da2e2028cef3c4c33..ec77f237b21cfb95bd1a5202747d54aade59c27b 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/DeleteCategoryEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/DeleteCategoryEntityTest.php @@ -74,5 +74,6 @@ class DeleteCategoryEntityTest extends Injectable $this->catalogCategoryIndex->open(); $this->catalogCategoryIndex->getTreeCategories()->selectCategory($category); $this->catalogCategoryEdit->getFormPageActions()->delete(); + $this->catalogCategoryEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAssignedToTemplateProductAttributeTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAssignedToTemplateProductAttributeTest.php index b1994e6b362d3c5c753d98ebdf771fa44220c3e8..a3c0028f6e70c13d348e9db060bbf528c24209d8 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAssignedToTemplateProductAttributeTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAssignedToTemplateProductAttributeTest.php @@ -78,6 +78,7 @@ class DeleteAssignedToTemplateProductAttributeTest extends Injectable $this->attributeIndex->open(); $this->attributeIndex->getGrid()->searchAndOpen($filter); $this->attributeNew->getPageActions()->delete(); + $this->attributeNew->getModalBlock()->acceptAlert(); return ['productTemplate' => $productTemplate, 'attribute' => $attribute]; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAttributeSetTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAttributeSetTest.php index 4eb5df71d91d4c48024acec44d3ff42623edb512..d996e70adb41097c9c62ff5f37f52c5cfb7d4760 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAttributeSetTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAttributeSetTest.php @@ -93,6 +93,7 @@ class DeleteAttributeSetTest extends Injectable $this->productSetIndex->open(); $this->productSetIndex->getGrid()->searchAndOpen($filter); $this->productSetEdit->getPageActions()->delete(); + $this->productSetEdit->getModalBlock()->acceptAlert(); return ['product' => $product]; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteProductAttributeEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteProductAttributeEntityTest.php index b2803209bad71d700debd46f25397569d8f22cb5..0574f736acace9e35c1905d9ff349104efeeab17 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteProductAttributeEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteProductAttributeEntityTest.php @@ -53,5 +53,6 @@ class DeleteProductAttributeEntityTest extends Injectable $attributeIndex->open(); $attributeIndex->getGrid()->searchAndOpen(['frontend_label' => $attribute->getFrontendLabel()]); $attributeNew->getPageActions()->delete(); + $attributeNew->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php index 4b5c4403e8c873ba7e04bf1c8ee6a4ad67232506..934b2e185add6a32e4b14dbd5aa91e0c11e45f34 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php @@ -82,6 +82,7 @@ class DeleteUsedInConfigurableProductAttributeTest extends Injectable $this->attributeIndex->open(); $this->attributeIndex->getGrid()->searchAndOpen(['attribute_code' => $attribute->getAttributeCode()]); $this->attributeNew->getPageActions()->delete(); + $this->attributeNew->getModalBlock()->acceptAlert(); return ['attribute' => $attribute]; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/DeleteAttributeStep.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/DeleteAttributeStep.php index 8665338166eb949f6207668c975b9ee07af7967b..26db72b37ef72a51d534681cbfe241f2642c1b23 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/DeleteAttributeStep.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/DeleteAttributeStep.php @@ -67,6 +67,7 @@ class DeleteAttributeStep implements TestStepInterface if ($this->catalogProductAttributeIndex->getGrid()->isRowVisible($filter)) { $this->catalogProductAttributeIndex->getGrid()->searchAndOpen($filter); $this->catalogProductAttributeNew->getPageActions()->delete(); + $this->catalogProductAttributeNew->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Page/Adminhtml/CatalogRuleNew.xml b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Page/Adminhtml/CatalogRuleNew.xml index 5dd34d3be1a902e1ba907860806eb3362041fb12..af8118dc6be7fa44a66f48a0bf8c8d68cfd7d4d5 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Page/Adminhtml/CatalogRuleNew.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Page/Adminhtml/CatalogRuleNew.xml @@ -6,8 +6,9 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="CatalogRuleNew" area="Adminhtml" mca="catalog_rule/promo_catalog/new" module="Magento_CatalogRule"> - <block name="formPageActions" class="Magento\CatalogRule\Test\Block\Adminhtml\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="editForm" class="Magento\CatalogRule\Test\Block\Adminhtml\Promo\Catalog\Edit\PromoForm" locator="[id='page:main-container']" strategy="css selector"/> - </page> + <page name="CatalogRuleNew" area="Adminhtml" mca="catalog_rule/promo_catalog/new" module="Magento_CatalogRule"> + <block name="formPageActions" class="Magento\CatalogRule\Test\Block\Adminhtml\FormPageActions" locator=".page-main-actions" strategy="css selector"/> + <block name="editForm" class="Magento\CatalogRule\Test\Block\Adminhtml\Promo\Catalog\Edit\PromoForm" locator="[id='page:main-container']" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/DeleteCatalogPriceRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/DeleteCatalogPriceRuleEntityTest.php index 959edfcf46434fe1522a305970123c5c28509582..aaea841d414f4374b3a5d1b52612e829eae889eb 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/DeleteCatalogPriceRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/DeleteCatalogPriceRuleEntityTest.php @@ -82,5 +82,6 @@ class DeleteCatalogPriceRuleEntityTest extends Injectable $this->catalogRuleIndex->open(); $this->catalogRuleIndex->getCatalogRuleGrid()->searchAndOpen($filter); $this->catalogRuleNew->getFormPageActions()->delete(); + $this->catalogRuleNew->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/DeleteAllCatalogRulesStep.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/DeleteAllCatalogRulesStep.php index dcc06c224c0baafb2d9429ba256b7d922cbb6136..5a733e8224def1d91632c364e31a18c23769733f 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/DeleteAllCatalogRulesStep.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/DeleteAllCatalogRulesStep.php @@ -55,6 +55,7 @@ class DeleteAllCatalogRulesStep implements TestStepInterface while ($this->catalogRuleIndex->getCatalogRuleGrid()->isFirstRowVisible()) { $this->catalogRuleIndex->getCatalogRuleGrid()->openFirstRow(); $this->catalogRuleNew->getFormPageActions()->delete(); + $this->catalogRuleNew->getModalBlock()->acceptAlert(); $this->catalogRuleIndex->getSystemMessageDialog()->closePopup(); } } diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchEdit.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchEdit.xml index 87d6b0b791a79d52c91d0306a321760cfe2dc72a..0d20a2f4ac16b8f0fc89c7406e3fd7359e696563 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchEdit.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchEdit.xml @@ -6,8 +6,9 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="CatalogSearchEdit" area="Adminhtml" mca="search/term/edit" module="Magento_CatalogSearch"> - <block name="form" class="Magento\CatalogSearch\Test\Block\Adminhtml\Edit\SearchTermForm" locator="#edit_form" strategy="css selector"/> - <block name="formPageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - </page> + <page name="CatalogSearchEdit" area="Adminhtml" mca="search/term/edit" module="Magento_CatalogSearch"> + <block name="form" class="Magento\CatalogSearch\Test\Block\Adminhtml\Edit\SearchTermForm" locator="#edit_form" strategy="css selector"/> + <block name="formPageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/DeleteSearchTermEntityTest.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/DeleteSearchTermEntityTest.php index b8400504d031aeda63c0d132b266d69aa55e7c46..4c9cdecc2c323be8c36dfb6c06dbeb8d2a49a4c7 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/DeleteSearchTermEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/DeleteSearchTermEntityTest.php @@ -78,5 +78,6 @@ class DeleteSearchTermEntityTest extends Injectable $this->indexPage->open(); $this->indexPage->getGrid()->searchAndOpen(['search_query' => $searchText]); $this->editPage->getFormPageActions()->delete(); + $this->editPage->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Shipping.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Shipping.xml index b2b6b2290fb9a2ec4d3fe2762cc93c6c4ffb5f44..6056844a06473ef7cd7d8624841a8c8a7fb38cf7 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Shipping.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Shipping.xml @@ -6,7 +6,6 @@ */ --> <mapping strict="0"> - <wrapper>shippingAddress</wrapper> <fields> <country_id> <input>select</input> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar/Item.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar/Item.php index 7d0966f153598dcdd97c018ecf89f3cf5b0ae4d1..43dbd23499a0d866f2fdf999c086716d20d79a4d 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar/Item.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar/Item.php @@ -28,6 +28,13 @@ class Item extends Sidebar */ protected $editItem = '.action.edit'; + /** + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + /** * Remove product item from mini cart * @@ -36,7 +43,10 @@ class Item extends Sidebar public function removeItemFromMiniCart() { $this->_rootElement->find($this->removeItem)->click(); - $this->browser->acceptAlert(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping.xml index 1b99093b23eec0d7b598fd3fd902867fe2fa5f0a..a61ff0273b51dbf315739492e8a27e88b6f14389 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping.xml @@ -6,7 +6,6 @@ */ --> <mapping strict="0"> - <wrapper>shippingAddress</wrapper> <fields> <email> <selector>#customer-email</selector> @@ -15,7 +14,7 @@ <lastname /> <company /> <street> - <selector>[name='shippingAddress[street][0]']</selector> + <selector>input[name="street[0]"]</selector> </street> <city /> <region_id> @@ -25,8 +24,6 @@ <input>select</input> </country_id> <telephone /> - <postcode> - <selector>[name='shippingAddress[postcode]']</selector> - </postcode> + <postcode /> </fields> </mapping> diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Page/Adminhtml/CheckoutAgreementNew.xml b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Page/Adminhtml/CheckoutAgreementNew.xml index 401dac62e9c0a18d8e7845519006a65da12caa7d..05356444ea635cd7b1cf78c0d862acc356b68eb8 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Page/Adminhtml/CheckoutAgreementNew.xml +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Page/Adminhtml/CheckoutAgreementNew.xml @@ -9,5 +9,6 @@ <page name="CheckoutAgreementNew" area="Adminhtml" mca="checkout/agreement/new" module="Magento_CheckoutAgreements"> <block name="pageActionsBlock" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector"/> <block name="agreementsForm" class="Magento\CheckoutAgreements\Test\Block\Adminhtml\Block\Agreement\Edit\AgreementsForm" locator="#edit_form" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> </page> </config> \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteAllTermsEntityStep.php b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteAllTermsEntityStep.php index 3599882b174c192c6f0638b491a86937e7e39c8c..b40f50f32d2ba5b85354b5c7f88859b3d322fc8c 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteAllTermsEntityStep.php +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteAllTermsEntityStep.php @@ -56,6 +56,7 @@ class DeleteAllTermsEntityStep implements TestStepInterface while ($this->agreementIndex->getAgreementGridBlock()->isFirstRowVisible()) { $this->agreementIndex->getAgreementGridBlock()->openFirstRow(); $this->agreementNew->getPageActionsBlock()->delete(); + $this->agreementNew->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteTermEntityStep.php b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteTermEntityStep.php index d5b572db6ea2f8cd935667a2443ce334e99afe3e..34c352f39ea40b8735ac2e7e48b61fd8cc6240aa 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteTermEntityStep.php +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteTermEntityStep.php @@ -63,5 +63,6 @@ class DeleteTermEntityStep implements TestStepInterface { $this->agreementIndex->open()->getAgreementGridBlock()->searchAndOpen(['name' => $this->agreement->getName()]); $this->agreementNew->getPageActionsBlock()->delete(); + $this->agreementNew->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php index 4ca3fe0ead7b62c175f7452f3f52f921aeff78ca..1f4c5cfbd659be67e2849194278241068c38c47a 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php @@ -28,36 +28,36 @@ class CmsGrid extends DataGrid */ protected $filters = [ 'block_id_from' => [ - 'selector' => '[name="filters[block_id][from]"]', + 'selector' => '[name="block_id[from]"]', ], 'block_id_to' => [ - 'selector' => '[name="filters[block_id][to]"]', + 'selector' => '[name="block_id[to]"]', ], 'title' => [ - 'selector' => '[name="filters[title]"]', + 'selector' => '[name="title"]', ], 'identifier' => [ - 'selector' => '[name="filters[identifier]"]', + 'selector' => '[name="identifier"]', ], 'store_id' => [ - 'selector' => '[name="filters[store_id]"]', + 'selector' => '[name="store_id"]', 'input' => 'simplifiedselect' ], 'is_active' => [ - 'selector' => '[name="filters[is_active]"]', + 'selector' => '[name="is_active"]', 'input' => 'select', ], 'creation_time_from' => [ - 'selector' => '[name="filters[creation_time][from]"]', + 'selector' => '[name="creation_time[from]"]', ], 'creation_time_to' => [ - 'selector' => '[name="filters[creation_time][to]"]', + 'selector' => '[name="creation_time[to]"]', ], 'update_time_from' => [ - 'selector' => '[name="filters[update_time][from]"]', + 'selector' => '[name="update_time[from]"]', ], 'update_time_to' => [ - 'selector' => '[name="filters[update_time][to]"]', + 'selector' => '[name="update_time[to]"]', ], ]; diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php index 76415b59ed47ad9df9646ca6b42920c6abcf7945..8562232305382db9d419dfaa7d2baa59e6794509 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php @@ -29,43 +29,43 @@ class Grid extends DataGrid */ protected $filters = [ 'page_id_from' => [ - 'selector' => '[name="filters[page_id][from]"]', + 'selector' => '[name="page_id[from]"]', ], 'page_id_to' => [ - 'selector' => '[name="filters[page_id][to]"]', + 'selector' => '[name="page_id[to]"]', ], 'title' => [ - 'selector' => '[name="filters[title]"]', + 'selector' => '[name="title"]', ], 'identifier' => [ - 'selector' => '[name="filters[identifier]"]', + 'selector' => '[name="identifier"]', ], 'page_layout' => [ - 'selector' => '[name="filters[page_layout]"]', + 'selector' => '[name="page_layout"]', 'input' => 'select', ], 'store_id' => [ - 'selector' => '[name="filters[store_id]"]', + 'selector' => '[name="store_id"]', 'input' => 'selectstore' ], 'is_active' => [ - 'selector' => '[name="filters[is_active]"]', + 'selector' => '[name="is_active"]', 'input' => 'select', ], 'creation_time_from' => [ - 'selector' => '[name="filters[creation_time][from]"]', + 'selector' => '[name="creation_time[from]"]', ], 'creation_time_to' => [ - 'selector' => '[name="filters[creation_time][to]"]', + 'selector' => '[name="creation_time[to]"]', ], 'update_time_from' => [ - 'selector' => '[name="filters[update_time][from]"]', + 'selector' => '[name="update_time[from]"]', ], 'update_time_to' => [ - 'selector' => '[name="filters[update_time][to]"]', + 'selector' => '[name="update_time[to]"]', ], 'under_version_control' => [ - 'selector' => '[name="filters[under_version_control]"]', + 'selector' => '[name="under_version_control"]', ], ]; diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsBlockNew.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsBlockNew.xml index d37d3e1420419a36bb1c134e900889c80c5ba50b..a9089eeddc76073466aa542f0d8687a1d1eeb68e 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsBlockNew.xml +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsBlockNew.xml @@ -10,5 +10,6 @@ <block name="formPageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector" /> <block name="cmsForm" class="Magento\Cms\Test\Block\Adminhtml\Block\Edit\CmsForm" locator="[id='page:main-container']" strategy="css selector" /> <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector" /> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsPageNew.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsPageNew.xml index 252dc039121b9ae55c6b30b063170fee9114c9a6..fc93801cdc7ef5a32179fc2f643388022f320e72 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsPageNew.xml +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsPageNew.xml @@ -9,5 +9,6 @@ <page name="CmsPageNew" area="Adminhtml" mca="cms/page/new" module="Magento_Cms"> <block name="pageForm" class="Magento\Cms\Test\Block\Adminhtml\Page\Edit\PageForm" locator="[id='page:main-container']" strategy="css selector" /> <block name="pageMainActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector" /> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsBlockEntityTest.php b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsBlockEntityTest.php index 07f8d2dea4488bc90f697262bbaadf250022dde9..31f36c5eb25d627416f072aeb42a2bbe97306e31 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsBlockEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsBlockEntityTest.php @@ -77,5 +77,6 @@ class DeleteCmsBlockEntityTest extends Injectable $this->cmsBlockIndex->open(); $this->cmsBlockIndex->getCmsBlockGrid()->searchAndOpen($filter, true, false); $this->cmsBlockNew->getFormPageActions()->delete(); + $this->cmsBlockNew->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageEntityTest.php b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageEntityTest.php index 5801ba85ea504bfeab0d880713bb50a51780d201..17d47b6681c4c87f62b492f32f327411e1089ff9 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageEntityTest.php @@ -74,5 +74,6 @@ class DeleteCmsPageEntityTest extends Injectable $this->cmsPageIndex->open(); $this->cmsPageIndex->getCmsPageGridBlock()->searchAndOpen(['title' => $cmsPage->getTitle()]); $this->cmsPageNew->getPageMainActions()->delete(); + $this->cmsPageNew->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageUrlRewriteEntityTest.php b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageUrlRewriteEntityTest.php index 7d5364c7c6fe48279ef35c797ddce98eefa828c2..7ef7db00e0aa723a15fd04cd347ced2fb6bc48f3 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageUrlRewriteEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageUrlRewriteEntityTest.php @@ -77,5 +77,6 @@ class DeleteCmsPageUrlRewriteEntityTest extends Injectable $this->urlRewriteIndex->open(); $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen(['request_path' => $urlRewrite->getRequestPath()]); $this->urlRewriteEdit->getPageMainActions()->delete(); + $this->urlRewriteEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AttributesGrid.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AttributesGrid.php index 523ff4c9c377d560c074d62834fc98d9642a24ff..78e58b4926c514bf1f388d0c0ddc8f8d0a53bdea 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AttributesGrid.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AttributesGrid.php @@ -20,7 +20,7 @@ class AttributesGrid extends DataGrid */ protected $filters = [ 'frontend_label' => [ - 'selector' => '[name="filters[frontend_label]"]', + 'selector' => '[name="frontend_label"]', ], ]; } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesAdditional.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesAdditional.php index 89292194978865d58920ac9c5cadcc8b47c1b69f..9e316ceabeab7a7c3b2f500465ece437d0032136 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesAdditional.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesAdditional.php @@ -36,6 +36,13 @@ class AddressesAdditional extends Block */ protected $additionalAddressContent = '.block-content'; + /** + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + /** * Delete Additional Address * @@ -46,7 +53,10 @@ class AddressesAdditional extends Block { $this->_rootElement->find(sprintf($this->addressSelector, $address->getStreet()), Locator::SELECTOR_XPATH) ->find($this->deleteAddressLink)->click(); - $this->browser->acceptAlert(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.xml index bc70891ffa44c1c7dc73bdc6469b37fcd113c886..c4778125723fb2d2312f151e23a32ad03248d2c1 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.xml @@ -10,7 +10,7 @@ <class>\Magento\Backend\Test\Block\Widget\Tab</class> <selector>#tab_customer</selector> <strategy>css selector</strategy> - <wrapper>data[customer]</wrapper> + <wrapper>customer</wrapper> <fields> <website_id> <input>select</input> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerGroupNew.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerGroupNew.xml index 69db394b4cd959a1ed6c295872385ba49c86b0cf..72d8c4bf8231191d34e9337edc1bc90379eac86e 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerGroupNew.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerGroupNew.xml @@ -6,9 +6,10 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="CustomerGroupNew" area="Adminhtml" mca="customer/group/new" module="Magento_Customer"> - <block name="pageMainActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="pageMainForm" class="Magento\Customer\Test\Block\Adminhtml\Group\Edit\Form" locator="[id='page:main-container']" strategy="css selector"/> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> - </page> + <page name="CustomerGroupNew" area="Adminhtml" mca="customer/group/new" module="Magento_Customer"> + <block name="pageMainActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector"/> + <block name="pageMainForm" class="Magento\Customer\Test\Block\Adminhtml\Group\Edit\Form" locator="[id='page:main-container']" strategy="css selector"/> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml index 80bd928de60acd6954d2f443840b73a548cd2c49..7dfacbc495c1259f286bfca6677d7339e280503a 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml @@ -6,11 +6,12 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="CustomerIndexEdit" area="Adminhtml" mca="customer/index/edit" module="Magento_Customer"> - <block name="titleBlock" class="Magento\Theme\Test\Block\Html\Title" locator=".page-title-wrapper .page-title" strategy="css selector"/> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> - <block name="pageActionsBlock" class="Magento\Customer\Test\Block\Adminhtml\Edit\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="customerForm" class="Magento\Customer\Test\Block\Adminhtml\Edit\CustomerForm" locator="[id='page:main-container']" strategy="css selector"/> - <block name="configureProductBlock" class="Magento\Catalog\Test\Block\Adminhtml\Product\Composite\Configure" locator="//*[@role='dialog' and ./*[@id='product_composite_configure'] and contains(@style,'display: block')]" strategy="xpath"/> - </page> + <page name="CustomerIndexEdit" area="Adminhtml" mca="customer/index/edit" module="Magento_Customer"> + <block name="titleBlock" class="Magento\Theme\Test\Block\Html\Title" locator=".page-title-wrapper .page-title" strategy="css selector"/> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> + <block name="pageActionsBlock" class="Magento\Customer\Test\Block\Adminhtml\Edit\FormPageActions" locator=".page-main-actions" strategy="css selector"/> + <block name="customerForm" class="Magento\Customer\Test\Block\Adminhtml\Edit\CustomerForm" locator="[id='page:main-container']" strategy="css selector"/> + <block name="configureProductBlock" class="Magento\Catalog\Test\Block\Adminhtml\Product\Composite\Configure" locator="//*[@role='dialog' and ./*[@id='product_composite_configure'] and contains(@style,'display: block')]" strategy="xpath"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerBackendEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerBackendEntityTest.php index adb0c3fc6db5b4bdf5459ba0982afc63b350cc59..55193f4834afad1c48e987b460f3e834dd4f8836 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerBackendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerBackendEntityTest.php @@ -74,5 +74,6 @@ class DeleteCustomerBackendEntityTest extends Injectable $this->customerIndexPage->open(); $this->customerIndexPage->getCustomerGridBlock()->searchAndOpen($filter); $this->customerIndexEditPage->getPageActionsBlock()->delete(); + $this->customerIndexEditPage->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerGroupEntityTest.php index 7b3cfefbf139cc9d1c62c61f1cc96872a5da1a39..067e17a8d0e5945f342579371a6325436e014b60 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerGroupEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerGroupEntityTest.php @@ -80,5 +80,6 @@ class DeleteCustomerGroupEntityTest extends Injectable $this->customerGroupIndex->open(); $this->customerGroupIndex->getCustomerGroupGrid()->searchAndOpen($filter); $this->customerGroupNew->getPageMainActions()->delete(); + $this->customerGroupNew->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Integration/Test/Block/Adminhtml/Integration/IntegrationGrid.php b/dev/tests/functional/tests/app/Magento/Integration/Test/Block/Adminhtml/Integration/IntegrationGrid.php index fa5f9a0e4a2f82c9ebc6216d254390dbadde8964..73c66f0af0aa7d3ab65c1f10d8d6505267960090 100644 --- a/dev/tests/functional/tests/app/Magento/Integration/Test/Block/Adminhtml/Integration/IntegrationGrid.php +++ b/dev/tests/functional/tests/app/Magento/Integration/Test/Block/Adminhtml/Integration/IntegrationGrid.php @@ -74,6 +74,13 @@ class IntegrationGrid extends Grid */ protected $tokensPopupSelector = './/ancestor::body/div[descendant::fieldset[contains(@id,"integration_token")]]'; + /** + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + /** * Search and delete current item * @@ -84,13 +91,10 @@ class IntegrationGrid extends Grid { $this->search($item); $this->_rootElement->find($this->deleteLink)->click(); - - /** @var \Magento\Integration\Test\Block\Adminhtml\Integration\IntegrationGrid\DeleteDialog $deleteDialog */ - $deleteDialog = $this->blockFactory->create( - 'Magento\Integration\Test\Block\Adminhtml\Integration\IntegrationGrid\DeleteDialog', - ['element' => $this->_rootElement->find($this->deleteBlockSelector, Locator::SELECTOR_XPATH)] - ); - $deleteDialog->acceptDeletion(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertSetApprovedProductReview.php b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertSetApprovedProductReview.php index 1e627941bd767bda72fe440332592e03926229a6..ea33820808df7a4ec29e046b924ed061dceafcb2 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertSetApprovedProductReview.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertSetApprovedProductReview.php @@ -69,6 +69,7 @@ class AssertSetApprovedProductReview extends AbstractConstraint { $this->cachePage->open(); $this->cachePage->getActionsBlock()->flushCacheStorage(); + $this->cachePage->getModalBlock()->acceptAlert(); \PHPUnit_Framework_Assert::assertTrue( $this->cachePage->getActionsBlock()->isStorageCacheFlushed(), 'Cache is not flushed.' diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Page/Adminhtml/RatingEdit.xml b/dev/tests/functional/tests/app/Magento/Review/Test/Page/Adminhtml/RatingEdit.xml index 2f6ca2960091c5bd82bb7b4d7d53870d6e62705a..f5f44551d022211696f6414d012d7ae71c082980 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Page/Adminhtml/RatingEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Page/Adminhtml/RatingEdit.xml @@ -9,5 +9,6 @@ <page name="RatingEdit" area="Adminhtml" mca="review/rating/edit" module="Magento_Review"> <block name="pageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector" /> <block name="ratingForm" class="Magento\Review\Test\Block\Adminhtml\Rating\Edit\RatingForm" locator="[id='page:main-container']" strategy="css selector" /> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php index 9f826b41451c330ba04df0998bf884e2a757c4fd..bbfabc028edbfcf7f338079820e8d1eab1aa5efb 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php @@ -127,5 +127,6 @@ class CreateProductRatingEntityTest extends Injectable $this->ratingIndex->open(); $this->ratingIndex->getRatingGrid()->searchAndOpen($filter); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php index 937cca411d93bd0c63e1fa0781d3fb24a1160f90..961ab02b043db089113b5b9872d48e9635aefb0c 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php @@ -135,6 +135,7 @@ class CreateProductReviewBackendEntityTest extends Injectable foreach ($this->review->getRatings() as $rating) { $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php index d0635638f9ff22cd66dd9652799057e37202d706..406f4deef9c96938bcc1168594cff4ec68fa1bb4 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php @@ -128,6 +128,7 @@ class CreateProductReviewFrontendEntityTest extends Injectable foreach ($ratings as $rating) { $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/DeleteProductRatingEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/DeleteProductRatingEntityTest.php index 193c7307ab800639ce31252e6b9614b64c18238f..8b7d3bf5749d993c9b6af023813bb06e9f74af05 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/DeleteProductRatingEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/DeleteProductRatingEntityTest.php @@ -90,5 +90,6 @@ class DeleteProductRatingEntityTest extends Injectable $this->ratingIndex->open(); $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $productRating->getRatingCode()]); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php index f0a34008cf012d56b49cf4f91e3c721aa00a319f..b7d7b5b53f55c84b5e599a517dbb12866b49e212 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php @@ -208,6 +208,7 @@ class ManageProductReviewFromCustomerPageTest extends Injectable foreach ($this->reviewInitial->getRatings() as $rating) { $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php index f351eb72b7d9364a998b6c3e0edb9398ae3ca568..188ec0fa1e69df95095bd633a8d7c13a51fcfbc9 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php @@ -119,6 +119,7 @@ class MassActionsProductReviewEntityTest extends Injectable foreach ($this->review->getRatings() as $rating) { $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php index 7b6908ce0a0aeb502cb1954369d583de1ec36041..0a373da1808d8f3d1fa4b0de030cc9c0f0d5c5c7 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php @@ -178,6 +178,7 @@ class UpdateProductReviewEntityOnProductPageTest extends Injectable foreach ($this->reviewInitial->getRatings() as $rating) { $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php index f2ab71072a284343bb6b61dfa5c7fd8d1c0f7284..f3005a32db02202fbb7e12576727b1f64e1c01e4 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php @@ -132,6 +132,7 @@ class UpdateProductReviewEntityTest extends Injectable foreach ($this->review->getRatings() as $rating) { $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php index 4d5bf937f8f114d8b7aecfc572af2e91f6ddaff6..2a1942e9f7254b0ff6bfba751f5f17f073e160ca 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php @@ -113,6 +113,13 @@ class Actions extends Block */ protected $button = 'button[data-ui-id$="%s-button"]'; + /** + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + /** * Ship order * @@ -171,7 +178,10 @@ class Actions extends Block public function cancel() { $this->_rootElement->find($this->cancel)->click(); - $this->browser->acceptAlert(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php index 8ea2b8ea680f029d70a0edac657052ab90cbfb24..eafb045e43909796768abf263b75cfbe940e875d 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php @@ -21,39 +21,39 @@ class Grid extends DataGrid */ protected $filters = [ 'id' => [ - 'selector' => '[name="filters[increment_id]"]', + 'selector' => '[name="increment_id"]', ], 'status' => [ - 'selector' => '[name="filters[status]"]', + 'selector' => '[name="status"]', 'input' => 'select', ], 'purchase_date_from' => [ - 'selector' => '[name="filters[created_at][from]"]', + 'selector' => '[name="created_at[from]"]', ], 'purchase_date_to' => [ - 'selector' => '[name="filters[created_at][to]"]', + 'selector' => '[name="created_at[to]"]', ], 'base_grand_total_from' => [ - 'selector' => '[name="filters[base_grand_total][from]"]', + 'selector' => '[name="base_grand_total[from]"]', ], 'base_grand_total_to' => [ - 'selector' => '[name="filters[base_grand_total][to]"]', + 'selector' => '[name="base_grand_total[to]"]', ], 'purchased_gran_total_from' => [ - 'selector' => '[name="filters[grand_total][from]"]', + 'selector' => '[name="grand_total[from]"]', ], 'purchased_gran_total_to' => [ - 'selector' => '[name="filters[grand_total][to]"]', + 'selector' => '[name="grand_total[to]"]', ], 'purchase_point' => [ - 'selector' => '[name="filters[store_id]"]', + 'selector' => '[name="store_id"]', 'input' => 'selectstore' ], 'bill_to_name' => [ - 'selector' => '[name="filters[billing_name]"]' + 'selector' => '[name="billing_name"]' ], 'ship_to_name' => [ - 'selector' => '[name="filters[shipping_name]"]', + 'selector' => '[name="shipping_name"]', ] ]; diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderCreateIndex.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderCreateIndex.xml index 9ca28ac5ddd33341712eca9726bc6c2b62656946..cdfafdfa832440fa68a2891379cf88a96dd80613 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderCreateIndex.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderCreateIndex.xml @@ -13,6 +13,6 @@ <block name="actionsBlock" class="Magento\Backend\Test\Block\GridPageActions" locator=".page-main-actions" strategy="css selector"/> <block name="couponsBlock" class="Magento\Sales\Test\Block\Adminhtml\Order\Create\Coupons" locator="#order-coupons" strategy="css selector"/> <block name="customerActivitiesBlock" class="Magento\Sales\Test\Block\Adminhtml\Order\Create\CustomerActivities" locator=".customer-current-activity" strategy="css selector"/> - <block name="configureProductBlock" class="Magento\Catalog\Test\Block\Adminhtml\Product\Composite\Configure" locator="//*[@role='dialog' and ./*[@id='product_composite_configure'] and contains(@style,'display: block')]" strategy="xpath"/> + <block name="configureProductBlock" class="Magento\Catalog\Test\Block\Adminhtml\Product\Composite\Configure" locator="//*[@data-role='modal' and .//*[@id='product_composite_configure'] and contains(@class,'_show')]" strategy="xpath"/> </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteEdit.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteEdit.xml index 23b3fe8d67b3aa5d93acb24f2f156893daff2730..432d754fddf7ef133232e86840e61ba25ea4c035 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteEdit.xml +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteEdit.xml @@ -9,5 +9,6 @@ <page name="PromoQuoteEdit" area="Adminhtml" mca="sales_rule/promo_quote/edit" module="Magento_SalesRule"> <block name="formPageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector" /> <block name="salesRuleForm" class="Magento\SalesRule\Test\Block\Adminhtml\Promo\Quote\Edit\PromoQuoteForm" locator="[id='page:main-container']" strategy="css selector" /> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.php index 906a7b51a359b37337311d70edfde7d57a18c135..833752c00f609c80f4cd7666e1f0bb27f9d0c8d5 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.php @@ -142,5 +142,6 @@ class CreateSalesRuleEntityTest extends Injectable $this->promoQuoteIndex->open(); $this->promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen($filter); $this->promoQuoteEdit->getFormPageActions()->delete(); + $this->promoQuoteEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.php index 39acead1497ca0f54a8b88c0ab2991fb1b2e6ee5..354d27064be2eeedd4ad36ac9a7c0ff0f212c667 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.php @@ -75,5 +75,6 @@ class DeleteSalesRuleEntityTest extends Injectable $this->promoQuoteIndex->open(); $this->promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen(['name' => $salesRule->getName()]); $this->promoQuoteEdit->getFormPageActions()->delete(); + $this->promoQuoteEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.php index a1ef4b347fef4ddf8cf43643b7ac9723e34191cb..5ae2160bc42b3ab727644f984d089c4963c82118 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.php @@ -127,5 +127,6 @@ class UpdateSalesRuleEntityTest extends Injectable $this->promoQuoteIndex->open(); $this->promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen($filter); $this->promoQuoteEdit->getFormPageActions()->delete(); + $this->promoQuoteEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/DeleteAllSalesRuleStep.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/DeleteAllSalesRuleStep.php index 98bf51e84f7c37fa0c7cf86af5024e0f7ceefe72..db64010c1af084e6d9aa892612f0fe28e401f9bc 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/DeleteAllSalesRuleStep.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/DeleteAllSalesRuleStep.php @@ -54,6 +54,7 @@ class DeleteAllSalesRuleStep implements TestStepInterface while ($this->promoQuoteIndex->getPromoQuoteGrid()->isFirstRowVisible()) { $this->promoQuoteIndex->getPromoQuoteGrid()->openFirstRow(); $this->promoQuoteEdit->getFormPageActions()->delete(); + $this->promoQuoteEdit->getModalBlock()->acceptAlert(); $this->promoQuoteIndex->getSystemMessageDialog()->closePopup(); } } diff --git a/dev/tests/functional/tests/app/Magento/Sitemap/Test/Page/Adminhtml/SitemapEdit.xml b/dev/tests/functional/tests/app/Magento/Sitemap/Test/Page/Adminhtml/SitemapEdit.xml index 78ebe3f0f12dd0acebec5c13d7da02b3d7ad1b48..9f2d045ae61a873198f246971f3da1eb4ed3ef29 100644 --- a/dev/tests/functional/tests/app/Magento/Sitemap/Test/Page/Adminhtml/SitemapEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Sitemap/Test/Page/Adminhtml/SitemapEdit.xml @@ -6,7 +6,8 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="SitemapEdit" area="Adminhtml" mca="admin/sitemap/edit" module="Magento_Sitemap"> - <block name="formPageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - </page> + <page name="SitemapEdit" area="Adminhtml" mca="admin/sitemap/edit" module="Magento_Sitemap"> + <block name="formPageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/DeleteSitemapEntityTest.php b/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/DeleteSitemapEntityTest.php index 56371fb69ad3d0420eaade513e0efd1594a34b0a..9e62c9111a036bb42a1708148ab53f5b8c2aa3b3 100644 --- a/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/DeleteSitemapEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/DeleteSitemapEntityTest.php @@ -72,5 +72,6 @@ class DeleteSitemapEntityTest extends Injectable $this->sitemapIndex->open(); $this->sitemapIndex->getSitemapGrid()->searchAndOpen($filter); $this->sitemapEdit->getFormPageActions()->delete(); + $this->sitemapEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRateNew.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRateNew.xml index 0237379975c22bc99ffe1e1be0f486821e03efc7..9940b8cca862f7a0b1c62448bc9cb3bb76c74e89 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRateNew.xml +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRateNew.xml @@ -6,9 +6,10 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="TaxRateNew" area="Adminhtml" mca="tax/rate/add" module="Magento_Tax"> - <block name="formPageActions" class="Magento\Tax\Test\Block\Adminhtml\Rate\Edit\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="taxRateForm" class="Magento\Tax\Test\Block\Adminhtml\Rate\Edit\Form" locator="#rate-form" strategy="css selector"/> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> - </page> + <page name="TaxRateNew" area="Adminhtml" mca="tax/rate/add" module="Magento_Tax"> + <block name="formPageActions" class="Magento\Tax\Test\Block\Adminhtml\Rate\Edit\FormPageActions" locator=".page-main-actions" strategy="css selector"/> + <block name="taxRateForm" class="Magento\Tax\Test\Block\Adminhtml\Rate\Edit\Form" locator="#rate-form" strategy="css selector"/> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRuleNew.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRuleNew.xml index 3396503e1d46f35179b27fe6f7f9e39274d3ac8a..3806a2e36a130cd002e0c38914ccc6a12f59786e 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRuleNew.xml +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRuleNew.xml @@ -6,9 +6,10 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="TaxRuleNew" area="Adminhtml" mca="tax/rule/new" module="Magento_Tax"> - <block name="formPageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="taxRuleForm" class="Magento\Tax\Test\Block\Adminhtml\Rule\Edit\Form" locator="#edit_form" strategy="css selector"/> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> - </page> + <page name="TaxRuleNew" area="Adminhtml" mca="tax/rule/new" module="Magento_Tax"> + <block name="formPageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector"/> + <block name="taxRuleForm" class="Magento\Tax\Test\Block\Adminhtml\Rule\Edit\Form" locator="#edit_form" strategy="css selector"/> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRateEntityTest.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRateEntityTest.php index 4bbdfbe520493e9ce5e1eafb98f0598a2edf5f06..a83bfa60070df51611a05ef74aecb4b16a4e75ca 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRateEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRateEntityTest.php @@ -81,5 +81,6 @@ class DeleteTaxRateEntityTest extends Injectable $this->taxRateIndex->open(); $this->taxRateIndex->getTaxRateGrid()->searchAndOpen($filter); $this->taxRateNew->getFormPageActions()->delete(); + $this->taxRateNew->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRuleEntityTest.php index bef4c799b43f3a3603fb29b7706b12def4732cc0..de83384d07acc21f24b4926c4c9a187daf29915f 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRuleEntityTest.php @@ -89,5 +89,6 @@ class DeleteTaxRuleEntityTest extends Injectable $this->taxRuleIndexPage->open(); $this->taxRuleIndexPage->getTaxRuleGrid()->searchAndOpen(['code' => $taxRule->getCode()]); $this->taxRuleNewPage->getFormPageActions()->delete(); + $this->taxRuleNewPage->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/DeleteAllTaxRulesStep.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/DeleteAllTaxRulesStep.php index d24b2ca4c4de8cd5cb362704b3c78c2ad4905fb4..212d8beabc9568d25cfdabba0a00f75bd4c86e5b 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/DeleteAllTaxRulesStep.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/DeleteAllTaxRulesStep.php @@ -55,6 +55,7 @@ class DeleteAllTaxRulesStep implements TestStepInterface while ($this->taxRuleIndexPage->getTaxRuleGrid()->isFirstRowVisible()) { $this->taxRuleIndexPage->getTaxRuleGrid()->openFirstRow(); $this->taxRuleNewPage->getFormPageActions()->delete(); + $this->taxRuleNewPage->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php index f8091af4cc497cfc16cbef6222ec0e7e8c00c6d1..5757bf446e6eecf0bf13ea8c2e9253e3166ae137 100644 --- a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php +++ b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php @@ -121,6 +121,13 @@ class DataGrid extends Grid */ protected $noRecords = '[class$=no-data]'; + /** + * Selector for alert. + * + * @var string + */ + protected $alertModal = '._show[data-role=modal]'; + /** * Clear all applied Filters. * @@ -250,7 +257,10 @@ class DataGrid extends Grid ->find(sprintf($this->massActionToggleList, $actionType), Locator::SELECTOR_XPATH) ->click(); if ($acceptAlert) { - $this->browser->find($this->actionButton)->click(); + $element = $this->browser->find($this->alertModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/Modal.php b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/Modal.php new file mode 100644 index 0000000000000000000000000000000000000000..96ed46ae296cd0ec50cb90259929c9d87d068e5d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/Modal.php @@ -0,0 +1,94 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Ui\Test\Block\Adminhtml; + +use Magento\Mtf\Block\Block; + +/** + * Alert, confirm, prompt block. + */ +class Modal extends Block +{ + /** + * Locator value for accept button. + * + * @var string + */ + protected $acceptButtonSelector = '.action-accept'; + + /** + * Locator value for dismiss button. + * + * @var string + */ + protected $dismissButtonSelector = '.action-dismiss'; + + /** + * Locator value for close button. + * + * @var string + */ + protected $closeButtonSelector = '.action-close'; + + /** + * Locator value for prompt input. + * + * @var string + */ + protected $inputFieldSelector = '[data-role="promptField"]'; + + /** + * Press OK on an alert, confirm, prompt a dialog. + * + * @return void + */ + public function acceptAlert() + { + $this->_rootElement->find($this->acceptButtonSelector)->click(); + } + + /** + * Press Cancel on an alert, confirm, prompt a dialog. + * + * @return void + */ + public function dismissAlert() + { + $this->_rootElement->find($this->dismissButtonSelector)->click(); + } + + /** + * Press Close on an alert, confirm, prompt a dialog. + * + * @return void + */ + public function closeAlert() + { + $this->_rootElement->find($this->closeButtonSelector)->click(); + } + + /** + * Get the alert dialog text. + * + * @return string + */ + public function getAlertText() + { + return $this->_rootElement->find($this->inputFieldSelector)->getValue(); + } + + /** + * Set the text to a prompt popup. + * + * @param string $text + * @return void + */ + public function setAlertText($text) + { + $this->_rootElement->find($this->inputFieldSelector)->setValue($text); + } +} diff --git a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Page/Adminhtml/UrlRewriteEdit.xml b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Page/Adminhtml/UrlRewriteEdit.xml index 77022c54f4f7354855acb5fc1515f866b899faa5..96a0d514a30736d6aadcad8340e921fed9f5fbbb 100644 --- a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Page/Adminhtml/UrlRewriteEdit.xml +++ b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Page/Adminhtml/UrlRewriteEdit.xml @@ -6,13 +6,14 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="UrlRewriteEdit" area="Adminhtml" mca="admin/url_rewrite/edit" module="Magento_UrlRewrite"> - <block name="treeBlock" class="Magento\UrlRewrite\Test\Block\Adminhtml\Catalog\Category\Tree" locator="[id='page:main-container']" strategy="css selector"/> - <block name="formBlock" class="Magento\UrlRewrite\Test\Block\Adminhtml\Catalog\Edit\UrlRewriteForm" locator="[id='page:main-container']" strategy="css selector"/> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages .messages" strategy="css selector"/> - <block name="pageMainActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="productGridBlock" class="Magento\UrlRewrite\Test\Block\Adminhtml\Catalog\Product\Grid" locator="[id='productGrid']" strategy="css selector"/> - <block name="urlRewriteTypeSelectorBlock" class="Magento\UrlRewrite\Test\Block\Adminhtml\Selector" locator="[data-container-for='entity-type-selector']" strategy="css selector"/> - <block name="cmsGridBlock" class="Magento\UrlRewrite\Test\Block\Adminhtml\Cms\Page\Grid" locator="#cmsPageGrid" strategy="css selector"/> - </page> + <page name="UrlRewriteEdit" area="Adminhtml" mca="admin/url_rewrite/edit" module="Magento_UrlRewrite"> + <block name="treeBlock" class="Magento\UrlRewrite\Test\Block\Adminhtml\Catalog\Category\Tree" locator="[id='page:main-container']" strategy="css selector"/> + <block name="formBlock" class="Magento\UrlRewrite\Test\Block\Adminhtml\Catalog\Edit\UrlRewriteForm" locator="[id='page:main-container']" strategy="css selector"/> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages .messages" strategy="css selector"/> + <block name="pageMainActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector"/> + <block name="productGridBlock" class="Magento\UrlRewrite\Test\Block\Adminhtml\Catalog\Product\Grid" locator="[id='productGrid']" strategy="css selector"/> + <block name="urlRewriteTypeSelectorBlock" class="Magento\UrlRewrite\Test\Block\Adminhtml\Selector" locator="[data-container-for='entity-type-selector']" strategy="css selector"/> + <block name="cmsGridBlock" class="Magento\UrlRewrite\Test\Block\Adminhtml\Cms\Page\Grid" locator="#cmsPageGrid" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCategoryUrlRewriteEntityTest.php b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCategoryUrlRewriteEntityTest.php index 75365689598a48d2b2d548a4cc9d9c6451b2eab1..a7eebdeae3e29abbb8d58c9a5fa2c1b51b86f9bf 100644 --- a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCategoryUrlRewriteEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCategoryUrlRewriteEntityTest.php @@ -82,5 +82,6 @@ class DeleteCategoryUrlRewriteEntityTest extends Injectable } $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen($filter); $this->urlRewriteEdit->getPageMainActions()->delete(); + $this->urlRewriteEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCustomUrlRewriteEntityTest.php b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCustomUrlRewriteEntityTest.php index f5592e87abef014f261c7d6bcaef3f4a6557972c..d34485b7819e70a21a5828890f7bdcfdd5080cc2 100644 --- a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCustomUrlRewriteEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCustomUrlRewriteEntityTest.php @@ -78,5 +78,6 @@ class DeleteCustomUrlRewriteEntityTest extends Injectable $filter = ['request_path' => $urlRewrite->getRequestPath()]; $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen($filter); $this->urlRewriteEdit->getPageMainActions()->delete(); + $this->urlRewriteEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteProductUrlRewriteEntityTest.php b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteProductUrlRewriteEntityTest.php index c668f0512eabda5375eef8fb30e59bc2f203bc1c..5673b0ae5e35c56cb721052e22ad3cdef054a8e7 100644 --- a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteProductUrlRewriteEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteProductUrlRewriteEntityTest.php @@ -80,5 +80,6 @@ class DeleteProductUrlRewriteEntityTest extends Injectable $filter = ['request_path' => $productRedirect->getRequestPath()]; $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen($filter); $this->urlRewriteEdit->getPageMainActions()->delete(); + $this->urlRewriteEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/PageActions.php b/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/PageActions.php index c2cf7eaf643955c850940a7b7c78254aa710d881..4c75ccbc6e183f14f614ad94faf2641c600cd5d5 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/PageActions.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/PageActions.php @@ -21,6 +21,13 @@ class PageActions extends FormPageActions */ protected $forceSignIn = '#invalidate'; + /** + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + /** * Click on 'Force Sign-In' button. * @@ -29,6 +36,9 @@ class PageActions extends FormPageActions public function forceSignIn() { $this->_rootElement->find($this->forceSignIn)->click(); - $this->browser->acceptAlert(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserEdit.xml b/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserEdit.xml index 63f872991799bd133ff580c0ff246c5023fa420d..67a3334680817155db54376c80d3aba5bbb7dec2 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserEdit.xml +++ b/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserEdit.xml @@ -6,10 +6,11 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="UserEdit" area="Adminhtml" mca="admin/user/edit" module="Magento_User"> - <block name="pageActions" class="Magento\User\Test\Block\Adminhtml\User\Edit\PageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> - <block name="userForm" class="Magento\User\Test\Block\Adminhtml\User\UserForm" locator="[id='page:main-container']" strategy="css selector"/> - <block name="rolesGrid" class="Magento\User\Test\Block\Adminhtml\User\Tab\Role\Grid" locator="[id='permissionsUserRolesGrid']" strategy="css selector"/> - </page> + <page name="UserEdit" area="Adminhtml" mca="admin/user/edit" module="Magento_User"> + <block name="pageActions" class="Magento\User\Test\Block\Adminhtml\User\Edit\PageActions" locator=".page-main-actions" strategy="css selector"/> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> + <block name="userForm" class="Magento\User\Test\Block\Adminhtml\User\UserForm" locator="[id='page:main-container']" strategy="css selector"/> + <block name="rolesGrid" class="Magento\User\Test\Block\Adminhtml\User\Tab\Role\Grid" locator="[id='permissionsUserRolesGrid']" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserRoleEditRole.xml b/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserRoleEditRole.xml index 739a150f8a4842f11ff4deeba75ae08e8fb6acc3..4f30dddd026ccb065f3220129f1c136c195fb18c 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserRoleEditRole.xml +++ b/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserRoleEditRole.xml @@ -6,9 +6,10 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="UserRoleEditRole" area="Adminhtml" mca="admin/user_role/editrole" module="Magento_User"> - <block name="pageActions" class="Magento\User\Test\Block\Adminhtml\Role\PageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="roleFormTabs" class="Magento\User\Test\Block\Adminhtml\Role\RoleForm" locator="[id='page:main-container']" strategy="css selector"/> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> - </page> + <page name="UserRoleEditRole" area="Adminhtml" mca="admin/user_role/editrole" module="Magento_User"> + <block name="pageActions" class="Magento\User\Test\Block\Adminhtml\Role\PageActions" locator=".page-main-actions" strategy="css selector"/> + <block name="roleFormTabs" class="Magento\User\Test\Block\Adminhtml\Role\RoleForm" locator="[id='page:main-container']" strategy="css selector"/> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php index 662992062276a834232c280958d232c8bfc983fc..0e0c500fc5f125bcdee94ebcbace61ae262b7837 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php @@ -120,6 +120,7 @@ class DeleteAdminUserEntityTest extends Injectable $this->userIndex->open(); $this->userIndex->getUserGrid()->searchAndOpen($filter); $this->userEdit->getPageActions()->delete(); + $this->userEdit->getModalBlock()->acceptAlert(); } /** diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php index 22421a9557c82e3a7feb4f745ec5c92da61d59ee..8f66d93cc0831c81a4750c7a6503ed13ee810920 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php @@ -122,6 +122,7 @@ class DeleteUserRoleEntityTest extends Injectable $this->userRoleIndex->open(); $this->userRoleIndex->getRoleGrid()->searchAndOpen($filter); $this->userRoleEditRole->getPageActions()->delete(); + $this->userRoleEditRole->getModalBlock()->acceptAlert(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Variable/Test/Block/Adminhtml/System/Variable/FormPageActions.php b/dev/tests/functional/tests/app/Magento/Variable/Test/Block/Adminhtml/System/Variable/FormPageActions.php index 8fa7f1fc390d3a44fae5e75970962dec1d72711a..fab74ada1dcf7f6031dd7b1b658bbb3cb691d159 100644 --- a/dev/tests/functional/tests/app/Magento/Variable/Test/Block/Adminhtml/System/Variable/FormPageActions.php +++ b/dev/tests/functional/tests/app/Magento/Variable/Test/Block/Adminhtml/System/Variable/FormPageActions.php @@ -35,6 +35,13 @@ class FormPageActions extends AbstractFormPageActions */ protected $storeView = './/*/a[contains(text(),"%s")]'; + /** + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + /** * Select Store View. * @@ -56,7 +63,10 @@ class FormPageActions extends AbstractFormPageActions } else { throw new \Exception('Store View with name \'' . $storeName . '\' is not visible!'); } - $this->browser->acceptAlert(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); return null; } diff --git a/dev/tests/functional/tests/app/Magento/Variable/Test/Page/Adminhtml/SystemVariableNew.xml b/dev/tests/functional/tests/app/Magento/Variable/Test/Page/Adminhtml/SystemVariableNew.xml index 1ef12a76ebccb87e88c0a471733b5c256f06f123..294fbe0a1e9760fbdad9c19bc2bce5b082d493f2 100644 --- a/dev/tests/functional/tests/app/Magento/Variable/Test/Page/Adminhtml/SystemVariableNew.xml +++ b/dev/tests/functional/tests/app/Magento/Variable/Test/Page/Adminhtml/SystemVariableNew.xml @@ -6,8 +6,9 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="SystemVariableNew" area="Adminhtml" mca="admin/system_variable/new" module="Magento_Variable"> - <block name="formPageActions" class="Magento\Variable\Test\Block\Adminhtml\System\Variable\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="systemVariableForm" class="Magento\Variable\Test\Block\Adminhtml\System\Variable\Edit\VariableForm" locator="#edit_form" strategy="css selector"/> - </page> + <page name="SystemVariableNew" area="Adminhtml" mca="admin/system_variable/new" module="Magento_Variable"> + <block name="formPageActions" class="Magento\Variable\Test\Block\Adminhtml\System\Variable\FormPageActions" locator=".page-main-actions" strategy="css selector"/> + <block name="systemVariableForm" class="Magento\Variable\Test\Block\Adminhtml\System\Variable\Edit\VariableForm" locator="#edit_form" strategy="css selector"/> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Variable/Test/TestCase/DeleteCustomVariableEntityTest.php b/dev/tests/functional/tests/app/Magento/Variable/Test/TestCase/DeleteCustomVariableEntityTest.php index 48ae7608c568326d3cd3bcac38a21985d29bed1e..a52fdc02ca3c20d1e168bb144f9533a2995541d6 100644 --- a/dev/tests/functional/tests/app/Magento/Variable/Test/TestCase/DeleteCustomVariableEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Variable/Test/TestCase/DeleteCustomVariableEntityTest.php @@ -80,5 +80,6 @@ class DeleteCustomVariableEntityTest extends Injectable $this->systemVariableIndexPage->open(); $this->systemVariableIndexPage->getSystemVariableGrid()->searchAndOpen($filter); $this->systemVariableNewPage->getFormPageActions()->delete(); + $this->systemVariableNewPage->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Page/Adminhtml/WidgetInstanceEdit.xml b/dev/tests/functional/tests/app/Magento/Widget/Test/Page/Adminhtml/WidgetInstanceEdit.xml index ce17b52e6d47f0ab26bb8146f8f3f0372fa604d6..a91e0a5d3c3e48ee80edefe16ad73fbffb6bb6d4 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Page/Adminhtml/WidgetInstanceEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Page/Adminhtml/WidgetInstanceEdit.xml @@ -10,5 +10,6 @@ <block name="widgetForm" class="Magento\Widget\Test\Block\Adminhtml\Widget\Instance\Edit\WidgetForm" locator="[id='page:main-container']" strategy="css selector" /> <block name="pageActionsBlock" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector" /> <block name="templateBlock" class="Magento\Backend\Test\Block\Template" locator="body" strategy="css selector" /> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/DeleteWidgetEntityTest.php b/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/DeleteWidgetEntityTest.php index b89af1b2bc4e7aa6ee4347cc5370b759dc206c0d..076cc16f6fef7a43061ca835723389aebb639bb5 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/DeleteWidgetEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/DeleteWidgetEntityTest.php @@ -77,5 +77,6 @@ class DeleteWidgetEntityTest extends Injectable $this->widgetInstanceIndex->open(); $this->widgetInstanceIndex->getWidgetGrid()->searchAndOpen($filter); $this->widgetInstanceEdit->getPageActionsBlock()->delete(); + $this->widgetInstanceEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/TestStep/DeleteAllWidgetsStep.php b/dev/tests/functional/tests/app/Magento/Widget/Test/TestStep/DeleteAllWidgetsStep.php index fd5825cb022ec3c7a45323949345efcb467ef580..f3d8184eea17df7a2748b6933b104d034d7423bb 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/TestStep/DeleteAllWidgetsStep.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/TestStep/DeleteAllWidgetsStep.php @@ -55,6 +55,7 @@ class DeleteAllWidgetsStep implements TestStepInterface $this->widgetInstanceIndex->getWidgetGrid()->openFirstRow(); $this->widgetInstanceEdit->getTemplateBlock()->waitLoader(); $this->widgetInstanceEdit->getPageActionsBlock()->delete(); + $this->widgetInstanceEdit->getModalBlock()->acceptAlert(); $this->widgetInstanceIndex->getSystemMessageDialog()->closePopup(); } } diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php index e7147535ce163d374438d18904e87cf26202bc9c..a13e0feda852349ec6d3182b80853c5282b41f57 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php @@ -57,6 +57,13 @@ class Grid extends \Magento\Backend\Test\Block\Widget\Grid */ protected $rowTemplateStrict = 'td[contains(.,normalize-space("%s"))]'; + /** + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + /** * Delete product * @@ -65,7 +72,10 @@ class Grid extends \Magento\Backend\Test\Block\Widget\Grid protected function delete() { $this->_rootElement->find($this->rowItem . ' ' . $this->deleteLink)->click(); - $this->browser->acceptAlert(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } /** diff --git a/dev/tests/js/JsTestDriver/jsTestDriverOrder.php b/dev/tests/js/JsTestDriver/jsTestDriverOrder.php index b12aef10f57a3c4eea9993b1fa2092e7c5848e56..6314b1dbd16f5bda8d499c7b4e2a02b2fd85ccbe 100644 --- a/dev/tests/js/JsTestDriver/jsTestDriverOrder.php +++ b/dev/tests/js/JsTestDriver/jsTestDriverOrder.php @@ -21,6 +21,5 @@ return [ '/lib/web/mage/decorate.js', '/lib/web/jquery/jquery.validate.js', '/lib/web/jquery/jquery.metadata.js', - '/lib/web/mage/translate.js', - '/lib/web/mage/requirejs/plugin/id-normalizer.js', + '/lib/web/mage/translate.js' ]; diff --git a/dev/tests/js/JsTestDriver/testsuite/mage/requirejs/plugin/id-normalizer-test.js b/dev/tests/js/JsTestDriver/testsuite/mage/requirejs/plugin/id-normalizer-test.js deleted file mode 100644 index a52466bda124dec6a16b15e2ba7df362abf90408..0000000000000000000000000000000000000000 --- a/dev/tests/js/JsTestDriver/testsuite/mage/requirejs/plugin/id-normalizer-test.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*jshint globalstrict: true*/ - -"use strict"; - -/*jshint undef: false, newcap: false*/ -var IdNormalizerTest = TestCase('IdNormalizerTest'); - -IdNormalizerTest.prototype.setUp = function() { - var defineArgs = jsunit.requirejsUtil.getDefineArgsInScript('lib/web/mage/requirejs/plugin/id-normalizer.js'); - assertNotUndefined('There expected to be a define() call', defineArgs); - assertEquals('Wrong number of arguments in the define() call', 1, defineArgs.length); - - this.normalizer = defineArgs[0]; - assertObject(this.normalizer); - assertFunction(this.normalizer.normalize); - assertFunction(this.normalizer.load); -}; - -IdNormalizerTest.prototype.testNormalize = function () { - var actual = this.normalizer.normalize('Magento_Catalog::foo/bar.js'); - assertEquals('Magento_Catalog/foo/bar.js', actual); -}; - -IdNormalizerTest.prototype.testLoad = function () { - // Check that load() is just a proxy - var modulePassed, onloadPassed; - var parentRequire = function (moduleIn, onloadIn) { - modulePassed = moduleIn; - onloadPassed = onloadIn; - }; - var onload = function (){}; - - this.normalizer.load('module', parentRequire, onload); - - assertEquals('module', modulePassed); - assertSame(onload, onloadPassed); -}; - diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js index a39203675c280520e4f5d457537697bca38e7c9a..f2edf7f7065c3efda6c93cd7b903e7fbfabcb3c5 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js @@ -4,7 +4,7 @@ */ define([ 'underscore', - 'Magento_Ui/js/core/renderer/layout' + 'uiLayout' ], function (_, layout) { 'use strict'; diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/column.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/column.test.js index ce954310178c078b18b213f4c5415e82556b8f2e..3d1e7dcfe0dbe416b13b13bdc796fa5ba99b6290 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/column.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/column.test.js @@ -24,17 +24,17 @@ define([ describe('sort method', function () { it('apply sorting first time', function () { column.sort(true); - expect(column.sorting()).toBe('asc'); + expect(column.sorting).toBe('asc'); }); it('apply sorting in other direction', function () { column.sort(true).sort(true); - expect(column.sorting()).toBe('desc'); + expect(column.sorting).toBe('desc'); }); it('remove sorting', function () { column.sort(false); - expect(column.sorting()).toBeFalsy(); + expect(column.sorting).toBeFalsy(); }); }); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/group.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/range.test.js similarity index 95% rename from dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/group.test.js rename to dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/range.test.js index 59e46e213d7c783c7332fe9a408da5e42c49419c..29267c110c52e82574e35789775526fa251bd918 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/group.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/range.test.js @@ -5,11 +5,11 @@ define([ 'underscore', - 'Magento_Ui/js/grid/filters/group' + 'Magento_Ui/js/grid/filters/range' ], function (_, Group) { 'use strict'; - describe('ui/js/grid/filters/filters', function () { + describe('ui/js/grid/filters/range', function () { var group; beforeEach(function () { diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/paging/paging.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/paging/paging.test.js index 43df680002775664e8cdc4bcd344368ca253f63f..ef72deab470d0456fc9019d2b68b533d049c5132 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/paging/paging.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/paging/paging.test.js @@ -17,7 +17,7 @@ define([ paging = new Paging({ pageSize: 2 }); - paging.totalRecords(7); + paging.totalRecords = 7; }); describe('Normalize method', function () { @@ -42,73 +42,73 @@ define([ describe('countPages method', function () { it('correct number of pages', function () { paging.countPages(); - expect(paging.pages()).toBe(4); + expect(paging.pages).toBe(4); }); it('if no records', function () { - paging.totalRecords(0); + paging.totalRecords = 0; paging.countPages(); - expect(paging.pages()).toBe(1); + expect(paging.pages).toBe(1); }); }); describe('page manipualations', function () { it('setPage method', function () { paging.setPage(2); - expect(paging.current()).toBe(2); + expect(paging.current).toBe(2); }); it('next', function () { - paging.current(1); + paging.current = 1; paging.next(); - expect(paging.current()).toBe(2); + expect(paging.current).toBe(2); }); it('next out of boundary', function () { - paging.current(4); + paging.current = 4; paging.next(); - expect(paging.current()).toBe(4); + expect(paging.current).toBe(4); }); it('prev', function () { - paging.current(4); + paging.current = 4; paging.prev(); - expect(paging.current()).toBe(3); + expect(paging.current).toBe(3); }); it('prev out of boundary', function () { - paging.current(1); + paging.current = 1; paging.prev(); - expect(paging.current()).toBe(1); + expect(paging.current).toBe(1); }); it('goFirst', function () { paging.goFirst(); - expect(paging.current()).toBe(1); + expect(paging.current).toBe(1); }); it('goLast', function () { paging.goLast(); - expect(paging.current()).toBe(4); + expect(paging.current).toBe(4); }); it('isFirst for 1st page', function () { - paging.current(1); + paging.current = 1; expect(paging.isFirst()).toBeTruthy(); }); it('isFirst for 2nd page', function () { - paging.current(2); + paging.current = 2; expect(paging.isFirst()).toBeFalsy(); }); it('isLast for last page', function () { - paging.current(4); + paging.current = 4; expect(paging.isLast()).toBeTruthy(); }); it('isLast for first page', function () { - paging.current(1); + paging.current = 1; expect(paging.isLast()).toBeFalsy(); }); }); @@ -116,22 +116,22 @@ define([ describe('countPages method', function () { it('correct number of pages', function () { paging.countPages(); - expect(paging.pages()).toBe(4); + expect(paging.pages).toBe(4); }); it('if no records', function () { - paging.totalRecords(0); + paging.totalRecords = 0; paging.countPages(); - expect(paging.pages()).toBe(1); + expect(paging.pages).toBe(1); }); }); describe('onPagesChange method', function () { it('pages amount became less than current', function () { - paging.current(4); - expect(paging.current()).toBe(4); + paging.current = 4; + expect(paging.current).toBe(4); paging.onPagesChange(2); - expect(paging.current()).toBe(2); + expect(paging.current).toBe(2); }); }); @@ -141,7 +141,7 @@ define([ }); it('read from _current', function () { - paging.current(2); + paging.current = 2; expect(paging._current()).toBe(2); }); @@ -149,7 +149,7 @@ define([ spyOn(paging, 'normalize').and.callThrough(); spyOn(paging._current, 'notifySubscribers'); paging._current(4); - expect(paging.current()).toBe(4); + expect(paging.current).toBe(4); expect(paging._current.notifySubscribers).toHaveBeenCalledWith(4); }); }); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js index 04b7f0ebe5a7ed09b3b422ccaa2f2cd1349171df..90e17a46a65e1af4be488992e1d788f28b362301 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js @@ -3,11 +3,11 @@ * See COPYING.txt for license details. */ define([ - 'Magento_Ui/js/lib/component/links' + 'Magento_Ui/js/lib/core/element/links' ], function (links) { 'use strict'; - describe('Magento_Ui/js/lib/component/links', function () { + describe('Magento_Ui/js/lib/core/element/links', function () { var linksObj, returnedValue; diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/events.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/events.test.js index bc2f08748f45e25f476cd2b0494f988b9f2bf41f..4ae9b2121426e0f82c9bc785a455064ccaadd976 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/events.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/events.test.js @@ -4,13 +4,13 @@ */ define([ - 'Magento_Ui/js/lib/events' + 'Magento_Ui/js/lib/core/events' ], function (EventBus) { 'use strict'; var EVENT = 'testEvent'; - describe('Magento_Ui/js/lib/events', function () { + describe('Magento_Ui/js/lib/core/events', function () { describe('"on" method', function () { afterEach(function () { EventBus.off(EVENT); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js index 196bdd121dcf32495dbe471af8087bb4349969f7..ac02100dffa90c995e1a10a000576c52c2b165e8 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js @@ -6,7 +6,7 @@ /*eslint max-nested-callbacks: 0*/ define([ - 'Magento_Ui/js/lib/registry/registry' + 'uiRegistry' ], function (registry) { 'use strict'; diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/alert.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/alert.test.js new file mode 100644 index 0000000000000000000000000000000000000000..548d093942f5833332661788add865065f5acd40 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/alert.test.js @@ -0,0 +1,27 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'jquery', + 'Magento_Ui/js/modal/alert' +], function ($) { + 'use strict'; + + describe('ui/js/modal/alert', function () { + var element = $('<div>some element</div>'), + alert = element.alert({}); + + it('Check for modal definition', function () { + expect(alert).toBeDefined(); + }); + it('Show/hide function check', function () { + expect(element.trigger('openModal')).toBe(element); + expect(element.trigger('closeModal')).toBe(element); + }); + it('Integration: modal created on page', function () { + expect(alert.length).toEqual(1); + }); + }); +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/confirm.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/confirm.test.js new file mode 100644 index 0000000000000000000000000000000000000000..922a14f54f924827829a2f1a77c65053b2da5795 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/confirm.test.js @@ -0,0 +1,27 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'jquery', + 'Magento_Ui/js/modal/confirm' +], function ($) { + 'use strict'; + + describe('ui/js/modal/confirm', function () { + var element = $('<div>some element</div>'), + confirm = element.confirm({}); + + it('Check for modal definition', function () { + expect(confirm).toBeDefined(); + }); + it('Show/hide function check', function () { + expect(element.trigger('openModal')).toBe(element); + expect(element.trigger('closeModal')).toBe(element); + }); + it('Integration: modal created on page', function () { + expect(confirm.length).toEqual(1); + }); + }); +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/modal.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/modal.test.js index 2b1496d56e270fc471db20303cbea7582f748550..a8f4a13979d06a6ffdc5ebd05425a61cb5762c0a 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/modal.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/modal.test.js @@ -17,8 +17,11 @@ define([ expect(modal).toBeDefined(); }); it('Show/hide function check', function () { - expect(element.trigger('openDialog')).toBe(element); - expect(element.trigger('closeDialog')).toBe(element); + expect(element.trigger('openModal')).toBe(element); + expect(element.trigger('closeModal')).toBe(element); + }); + it('Integration: modal created on page', function () { + expect($(modal).length).toEqual(1); }); }); }); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/prompt.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/prompt.test.js new file mode 100644 index 0000000000000000000000000000000000000000..1d61f4c7354049cad1e61c73093ddfd90cce7eb8 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/prompt.test.js @@ -0,0 +1,27 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'jquery', + 'Magento_Ui/js/modal/prompt' +], function ($) { + 'use strict'; + + describe('ui/js/modal/prompt', function () { + var element = $('<div>some element</div>'), + prompt = element.prompt({}); + + it('Check for modal definition', function () { + expect(prompt).toBeDefined(); + }); + it('Show/hide function check', function () { + expect(element.trigger('openModal')).toBe(element); + expect(element.trigger('closeModal')).toBe(element); + }); + it('Integration: modal created on page', function () { + expect(prompt.length).toEqual(1); + }); + }); +}); diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt index 30b6cb91bf29ad8b67664146a90f519880cbf892..02aa8c3d20512a666f0a1d817c1bf30f99e1c0cd 100644 --- a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt @@ -384,99 +384,37 @@ app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js app/code/Magento/Ui/view/base/web/js/core/renderer/types.js app/code/Magento/Ui/view/base/web/js/form/adapter.js app/code/Magento/Ui/view/base/web/js/form/client.js -app/code/Magento/Ui/view/base/web/js/form/components/area.js app/code/Magento/Ui/view/base/web/js/form/components/collection.js -app/code/Magento/Ui/view/base/web/js/form/components/collection/item.js -app/code/Magento/Ui/view/base/web/js/form/components/fieldset.js -app/code/Magento/Ui/view/base/web/js/form/components/group.js app/code/Magento/Ui/view/base/web/js/form/components/html.js -app/code/Magento/Ui/view/base/web/js/form/components/tab_group.js app/code/Magento/Ui/view/base/web/js/form/components/tab.js app/code/Magento/Ui/view/base/web/js/form/element/abstract.js -app/code/Magento/Ui/view/base/web/js/form/element/boolean.js -app/code/Magento/Ui/view/base/web/js/form/element/date.js app/code/Magento/Ui/view/base/web/js/form/element/helpers/options.js -app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js app/code/Magento/Ui/view/base/web/js/form/element/post-code.js app/code/Magento/Ui/view/base/web/js/form/element/region.js app/code/Magento/Ui/view/base/web/js/form/element/select.js -app/code/Magento/Ui/view/base/web/js/form/element/textarea.js app/code/Magento/Ui/view/base/web/js/form/element/ui-select.js app/code/Magento/Ui/view/base/web/js/form/form.js app/code/Magento/Ui/view/base/web/js/form/provider.js -app/code/Magento/Ui/view/base/web/js/grid/columns/actions.js -app/code/Magento/Ui/view/base/web/js/grid/columns/column.js -app/code/Magento/Ui/view/base/web/js/grid/columns/date.js -app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js -app/code/Magento/Ui/view/base/web/js/grid/columns/select.js app/code/Magento/Ui/view/base/web/js/grid/columns/thumbnail.js -app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/bookmarks.js app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/storage.js -app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/view.js -app/code/Magento/Ui/view/base/web/js/grid/controls/columns.js -app/code/Magento/Ui/view/base/web/js/grid/dnd.js -app/code/Magento/Ui/view/base/web/js/grid/editing/bulk.js -app/code/Magento/Ui/view/base/web/js/grid/editing/client.js -app/code/Magento/Ui/view/base/web/js/grid/editing/editor-view.js -app/code/Magento/Ui/view/base/web/js/grid/editing/editor.js -app/code/Magento/Ui/view/base/web/js/grid/editing/record.js app/code/Magento/Ui/view/base/web/js/grid/export.js -app/code/Magento/Ui/view/base/web/js/grid/filters/chips.js -app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js -app/code/Magento/Ui/view/base/web/js/grid/filters/group.js -app/code/Magento/Ui/view/base/web/js/grid/massactions.js -app/code/Magento/Ui/view/base/web/js/grid/paging/paging.js -app/code/Magento/Ui/view/base/web/js/grid/paging/sizes.js -app/code/Magento/Ui/view/base/web/js/grid/provider.js app/code/Magento/Ui/view/base/web/js/grid/resize.js -app/code/Magento/Ui/view/base/web/js/grid/search/search.js app/code/Magento/Ui/view/base/web/js/grid/sticky/sticky.js -app/code/Magento/Ui/view/base/web/js/grid/tree-massactions.js -app/code/Magento/Ui/view/base/web/js/lib/class.js -app/code/Magento/Ui/view/base/web/js/lib/collapsible.js -app/code/Magento/Ui/view/base/web/js/lib/component/core.js -app/code/Magento/Ui/view/base/web/js/lib/component/links.js -app/code/Magento/Ui/view/base/web/js/lib/component/main.js -app/code/Magento/Ui/view/base/web/js/lib/component/manip.js -app/code/Magento/Ui/view/base/web/js/lib/component/provider.js -app/code/Magento/Ui/view/base/web/js/lib/component/traversal.js -app/code/Magento/Ui/view/base/web/js/lib/events.js +app/code/Magento/Ui/view/base/web/js/lib/core/element/links.js app/code/Magento/Ui/view/base/web/js/lib/key-codes.js -app/code/Magento/Ui/view/base/web/js/lib/ko/bind/after-render.js -app/code/Magento/Ui/view/base/web/js/lib/ko/bind/class.js -app/code/Magento/Ui/view/base/web/js/lib/ko/bind/collapsible.js app/code/Magento/Ui/view/base/web/js/lib/ko/bind/datepicker.js app/code/Magento/Ui/view/base/web/js/lib/ko/bind/fadeVisible.js app/code/Magento/Ui/view/base/web/js/lib/ko/bind/i18n.js app/code/Magento/Ui/view/base/web/js/lib/ko/bind/keyboard.js app/code/Magento/Ui/view/base/web/js/lib/ko/bind/mage-init.js app/code/Magento/Ui/view/base/web/js/lib/ko/bind/optgroup.js -app/code/Magento/Ui/view/base/web/js/lib/ko/bind/outer_click.js -app/code/Magento/Ui/view/base/web/js/lib/ko/bind/scope.js -app/code/Magento/Ui/view/base/web/js/lib/ko/bind/stop_propagation.js -app/code/Magento/Ui/view/base/web/js/lib/ko/extender/bound-nodes.js app/code/Magento/Ui/view/base/web/js/lib/ko/extender/observable_array.js -app/code/Magento/Ui/view/base/web/js/lib/ko/initialize.js -app/code/Magento/Ui/view/base/web/js/lib/ko/template/engine.js -app/code/Magento/Ui/view/base/web/js/lib/ko/template/observable_source.js -app/code/Magento/Ui/view/base/web/js/lib/loader.js -app/code/Magento/Ui/view/base/web/js/lib/registry/events.js -app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js -app/code/Magento/Ui/view/base/web/js/lib/registry/storage.js -app/code/Magento/Ui/view/base/web/js/lib/renderer/renderer.js app/code/Magento/Ui/view/base/web/js/lib/spinner.js app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js -app/code/Magento/Ui/view/base/web/js/lib/storage.js app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js app/code/Magento/Ui/view/base/web/js/lib/validation/utils.js app/code/Magento/Ui/view/base/web/js/lib/validation/validator.js -app/code/Magento/Ui/view/base/web/js/lib/view/utils/async.js -app/code/Magento/Ui/view/base/web/js/lib/view/utils/bindings.js -app/code/Magento/Ui/view/base/web/js/lib/view/utils/dom-observer.js app/code/Magento/Ui/view/base/web/js/lib/view/utils/raf.js -app/code/Magento/Ui/view/base/web/js/modal/alert.js -app/code/Magento/Ui/view/base/web/js/modal/confirm.js -app/code/Magento/Ui/view/base/web/js/modal/modal.js app/code/Magento/Ui/view/base/web/js/modal/modalToggle.js app/code/Magento/Ui/view/frontend/web/js/model/messageList.js app/code/Magento/Ui/view/frontend/web/js/model/messages.js @@ -543,7 +481,7 @@ dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/v dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/columns.test.js dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/editing/bulk.test.js dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/filters.test.js -dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/group.test.js +dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/range.test.js dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/paging/paging.test.js dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/resize.test.js dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/search/search.test.js @@ -623,10 +561,7 @@ lib/web/mage/mage.js lib/web/mage/menu.js lib/web/mage/popup-window.js lib/web/mage/redirect-url.js -lib/web/mage/requirejs/mixins.js -lib/web/mage/requirejs/plugin/id-normalizer.js lib/web/mage/requirejs/resolver.js -lib/web/mage/requirejs/static.js lib/web/mage/smart-keyboard-handler.js lib/web/mage/sticky.js lib/web/mage/storage.js @@ -640,13 +575,7 @@ lib/web/mage/translate-inline.js lib/web/mage/translate.js lib/web/mage/url.js lib/web/mage/utils/arrays.js -lib/web/mage/utils/compare.js -lib/web/mage/utils/main.js lib/web/mage/utils/misc.js -lib/web/mage/utils/objects.js -lib/web/mage/utils/strings.js -lib/web/mage/utils/template.js -lib/web/mage/utils/wrapper.js lib/web/mage/validation.js lib/web/mage/validation/validation.js lib/web/mage/view/composite.js @@ -1153,4 +1082,4 @@ vendor/magento/module-wishlist/view/frontend/web/wishlist.js vendor/magento/theme-adminhtml-backend/web/js/theme.js vendor/magento/theme-frontend-blank/web/js/navigation-menu.js vendor/magento/theme-frontend-blank/web/js/responsive.js -vendor/magento/theme-frontend-blank/web/js/theme.js \ No newline at end of file +vendor/magento/theme-frontend-blank/web/js/theme.js diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php index 1d9461b25df16a2e5bcb292a7b64e5a9d0218dfa..cf42cd0950a7a806535e76d213079ad68a03a6ee 100755 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -3946,6 +3946,8 @@ return [ ['Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Renderer\Inventory'], ['Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Renderer\Checkbox'], ['Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Filter\Inventory'], + ['Magento\Catalog\Ui\Component\Listing\Filters'], + ['Magento\Customer\Ui\Component\Listing\Filters'], ['Magento\Catalog\Block\Product\TemplateSelector'], ['Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\SuggestProductTemplates'], ['Magento\Bundle\Controller\Adminhtml\Bundle\Product\Edit\SuggestProductTemplates'], diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Editor.php b/lib/internal/Magento/Framework/Data/Form/Element/Editor.php index a5b5c41168bf0f7867cf3f53a47e8828fa210de6..9b33d71b7ca3bd79ed917ccabd7a53578f57df9f 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Editor.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Editor.php @@ -385,14 +385,14 @@ class Editor extends Textarea protected function _wrapIntoContainer($html) { if (!$this->getConfig('use_container')) { - return $html; + return '<div class="admin__control-wysiwig">' .$html . '</div>'; } $html = '<div id="editor' . $this->getHtmlId() . '"' . ($this->getConfig( 'no_display' ) ? ' style="display:none;"' : '') . ($this->getConfig( 'container_class' - ) ? ' class="' . $this->getConfig( + ) ? ' class="admin__control-wysiwig ' . $this->getConfig( 'container_class' ) . '"' : '') . '>' . $html . '</div>'; diff --git a/lib/internal/Magento/Framework/Ui/etc/ui_components.xsd b/lib/internal/Magento/Framework/Ui/etc/ui_components.xsd index 3790dec48e07bbcb9d6661d3ce09551e4cc75f19..f57cee5918faf2e1492be91f8c4107c82b619da7 100644 --- a/lib/internal/Magento/Framework/Ui/etc/ui_components.xsd +++ b/lib/internal/Magento/Framework/Ui/etc/ui_components.xsd @@ -114,6 +114,25 @@ <xs:extension base="input"/> </xs:complexContent> </xs:complexType> + <xs:complexType name="component"> + <xs:complexContent> + <xs:extension base="ui_element"> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:group ref="configurable"/> + </xs:choice> + </xs:extension> + </xs:complexContent> + </xs:complexType> + <xs:complexType name="actionsColumn"> + <xs:complexContent> + <xs:extension base="column"/> + </xs:complexContent> + </xs:complexType> + <xs:complexType name="selectionsColumn"> + <xs:complexContent> + <xs:extension base="column"/> + </xs:complexContent> + </xs:complexType> <xs:complexType name="container"> <xs:complexContent> <xs:extension base="ui_element"> diff --git a/lib/internal/Magento/Framework/Ui/etc/ui_configuration.xsd b/lib/internal/Magento/Framework/Ui/etc/ui_configuration.xsd index 2cf581c0e9bb621808dab7569ef9bab3e99cc42d..9cdf10564944662f5ee6cafa29c88c7c3ee28917 100644 --- a/lib/internal/Magento/Framework/Ui/etc/ui_configuration.xsd +++ b/lib/internal/Magento/Framework/Ui/etc/ui_configuration.xsd @@ -34,6 +34,9 @@ <xs:element type="argumentType" name="argument"/> <xs:element type="bookmark" name="bookmark"/> <xs:element name="filterSearch" type="filterSearch" /> + <xs:element name="component" type="component" /> + <xs:element name="actionsColumn" type="actionsColumn" /> + <xs:element name="selectionsColumn" type="selectionsColumn" /> <xs:element type="exportButton" name="exportButton"/> </xs:choice> </xs:extension> @@ -80,6 +83,8 @@ <xs:extension base="columns"> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="column" type="column" /> + <xs:element name="actionsColumn" type="actionsColumn" /> + <xs:element name="selectionsColumn" type="selectionsColumn" /> </xs:choice> </xs:extension> </xs:complexContent> diff --git a/lib/internal/Magento/Framework/Ui/etc/ui_definition.xsd b/lib/internal/Magento/Framework/Ui/etc/ui_definition.xsd index 75b710a0e8bf406a3d649a5ad6c4be26ff253ef0..78cd48d5f43a23f8cf7cac6ed860108fa330fe3b 100644 --- a/lib/internal/Magento/Framework/Ui/etc/ui_definition.xsd +++ b/lib/internal/Magento/Framework/Ui/etc/ui_definition.xsd @@ -48,11 +48,15 @@ <xs:element type="dataTypeMedia" name="image"/> <xs:element type="dataTypeDate" name="date"/> <xs:element type="dataTypeEmail" name="email"/> + <xs:element type="dataTypeMedia" name="file"/> <xs:element type="nav" name="nav"/> <xs:element type="actions" name="actions"/> <xs:element type="bookmark" name="bookmark"/> <xs:element type="exportButton" name="exportButton"/> <xs:element type="action" name="action"/> + <xs:element name="component" type="component" /> + <xs:element name="actionsColumn" type="actionsColumn" /> + <xs:element name="selectionsColumn" type="selectionsColumn" /> </xs:all> </xs:complexType> <!-- Custom configuration --> diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php b/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php index 1dd81a187c7508f516dbd37f9d77ec239eb6812e..3ea8c49a43d6180decaa0a42ee34f06d2c256566 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php @@ -7,6 +7,7 @@ namespace Magento\Framework\View\Element\UiComponent; use Magento\Framework\UrlInterface; use Magento\Framework\App\RequestInterface; +use Magento\Framework\View\Element\UiComponent\Processor; use Magento\Framework\View\Element\UiComponentInterface; use Magento\Framework\View\Element\UiComponent\Control\ActionPoolFactory; use Magento\Framework\View\Element\UiComponent\Control\ActionPoolInterface; @@ -84,6 +85,11 @@ class Context implements ContextInterface */ protected $urlBuilder; + /** + * @var Processor + */ + protected $processor; + /** * @param PageLayoutInterface $pageLayout * @param RequestInterface $request @@ -91,8 +97,9 @@ class Context implements ContextInterface * @param ActionPoolFactory $actionPoolFactory * @param ContentTypeFactory $contentTypeFactory * @param UrlInterface $urlBuilder + * @param Processor $processor * @param DataProviderInterface|null $dataProvider - * @param string $namespace + * @param null $namespace */ public function __construct( PageLayoutInterface $pageLayout, @@ -101,6 +108,7 @@ class Context implements ContextInterface ActionPoolFactory $actionPoolFactory, ContentTypeFactory $contentTypeFactory, UrlInterface $urlBuilder, + Processor $processor, DataProviderInterface $dataProvider = null, $namespace = null ) { @@ -112,7 +120,7 @@ class Context implements ContextInterface $this->actionPool = $actionPoolFactory->create(['context' => $this]); $this->contentTypeFactory = $contentTypeFactory; $this->urlBuilder = $urlBuilder; - + $this->processor = $processor; $this->setAcceptType(); } @@ -362,4 +370,12 @@ class Context implements ContextInterface } $data = $component->prepareDataSource($data); } + + /** + * @inheritDoc + */ + public function getProcessor() + { + return $this->processor; + } } diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/ContextInterface.php b/lib/internal/Magento/Framework/View/Element/UiComponent/ContextInterface.php index 55ed8e0d0657d2a7dc784bdf33f34782d8afe3e9..bd89985dc14905ebdfbec190796dcbd80075fd8f 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/ContextInterface.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/ContextInterface.php @@ -5,6 +5,7 @@ */ namespace Magento\Framework\View\Element\UiComponent; +use Magento\Framework\View\Element\UiComponent\Processor; use Magento\Framework\View\Element\UiComponentInterface; use Magento\Framework\View\Element\UiComponent\ContentType\ContentTypeInterface; use Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface; @@ -136,4 +137,11 @@ interface ContextInterface * @return string */ public function getUrl($route = '', $params = []); + + /** + * Get component processor + * + * @return Processor + */ + public function getProcessor(); } diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/ObserverInterface.php b/lib/internal/Magento/Framework/View/Element/UiComponent/ObserverInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..b9cbce56acb0f35dfe9d63ce0c1f5bb8c818dc66 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/ObserverInterface.php @@ -0,0 +1,22 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\View\Element\UiComponent; + +use Magento\Framework\View\Element\UiComponentInterface; + +/** + * Interface ObserverInterface + */ +interface ObserverInterface +{ + /** + * Update component according to $component + * + * @param UiComponentInterface $component + * @return void + */ + public function update(UiComponentInterface $component); +} diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/PoolInterface.php b/lib/internal/Magento/Framework/View/Element/UiComponent/PoolInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..c265025925d8e30689571a2c2937b9ecb9b3801c --- /dev/null +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/PoolInterface.php @@ -0,0 +1,29 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\View\Element\UiComponent; + +use Magento\Framework\View\Element\UiComponentInterface; + +/** + * Interface PoolInterface + */ +interface PoolInterface +{ + /** + * Register component at pool + * + * @param UiComponentInterface $component + * @return void + */ + public function register(UiComponentInterface $component); + + /** + * Retrieve components pool + * + * @return UiComponentInterface[] + */ + public function getComponents(); +} diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/Processor.php b/lib/internal/Magento/Framework/View/Element/UiComponent/Processor.php new file mode 100644 index 0000000000000000000000000000000000000000..4e7bb9d9932b0815394b77b0ef0ec3f82ef81422 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/Processor.php @@ -0,0 +1,106 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\View\Element\UiComponent; + +use Magento\Framework\View\Element\UiComponentInterface; + +/** + * Class Processor + */ +class Processor implements PoolInterface, SubjectInterface +{ + /** + * @var UiComponentInterface[] + */ + protected $components = []; + + /** + * Array of observers + * + * [ + * 'component_type1' => ObserverInterface[], + * 'component_type2' => ObserverInterface[], + * ] + * + * @var array + */ + protected $observers = []; + + + /** + * @inheritDoc + */ + public function register(UiComponentInterface $component) + { + $this->components[] = $component; + } + + /** + * @inheritDoc + */ + public function getComponents() + { + return $this->components; + } + + /** + * @inheritDoc + */ + public function attach($type, ObserverInterface $observer) + { + $this->observers[$type][] = $observer; + } + + /** + * @inheritDoc + */ + public function detach($type, ObserverInterface $observer) + { + if (!isset($this->observers[$type])) { + return; + } + + $key = array_search($observer, $this->observers[$type], true); + if ($key !== false) { + unset($this->observers[$type][$key]); + } + } + + /** + * @inheritDoc + */ + public function notify($type) + { + $componentType = $this->normalizeType($type); + if (!isset($this->observers[$componentType])) { + return; + } + + /** @var UiComponentInterface $component */ + foreach ($this->getComponents() as $component) { + if ($component->getComponentName() != $type) { + continue; + } + + /** @var ObserverInterface $observer */ + foreach ($this->observers[$componentType] as $observer) { + $observer->update($component); + } + } + } + + /** + * Normalize type to component type + * + * @param string $type + * @return string + */ + protected function normalizeType($type) + { + $componentType = (strpos($type, '.') !== false) ? substr($type, 0, strpos($type, '.')) : $type; + return $componentType; + } +} diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/SubjectInterface.php b/lib/internal/Magento/Framework/View/Element/UiComponent/SubjectInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..6b16644405389a649d0bb78df719ec4f7b5ffffa --- /dev/null +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/SubjectInterface.php @@ -0,0 +1,35 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\View\Element\UiComponent; + +/** + * Interface SubjectInterface + */ +interface SubjectInterface +{ + /** + * Attach an observer by type + * @param string $type + * @param ObserverInterface $observer + * @return void + */ + public function attach($type, ObserverInterface $observer); + + /** + * Detach an observer by type + * @param string $type + * @param ObserverInterface $observer + * @return void + */ + public function detach($type, ObserverInterface $observer); + + /** + * Notify an observer(s) by type + * @param string $type + * @return void + */ + public function notify($type); +} diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/ProcessorTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/ProcessorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c10d6fe61c3aa76af239c1afb77f87f12c9d3bff --- /dev/null +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/ProcessorTest.php @@ -0,0 +1,78 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +/** + * Test for view Messages model + */ +namespace Magento\Framework\View\Test\Unit\Element\UiComponent; + +use Magento\Framework\View\Element\UiComponent\Processor; +use Magento\Framework\View\Element\UiComponentInterface; +use Magento\Framework\View\Element\UiComponent\ObserverInterface; + +class ProcessorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var UiComponentInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $component; + + /** + * @var ObserverInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $observer; + + /** + * @var Processor + */ + protected $processor; + + protected function setUp() + { + $this->component = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface') + ->getMockForAbstractClass(); + $this->observer = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ObserverInterface') + ->getMockForAbstractClass(); + $this->processor = new Processor(); + } + + public function testRegisterGetComponents() + { + $this->assertCount(0, $this->processor->getComponents()); + $this->processor->register($this->component); + $this->assertCount(1, $this->processor->getComponents()); + } + + public function testAttachAndNotify() + { + $type = 'test_type'; + $this->component->expects($this->any()) + ->method('getComponentName') + ->willReturn($type); + $this->observer->expects($this->any()) + ->method('update') + ->with($this->component); + /** @var UiComponentInterface $component2 */ + $component2 = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface') + ->getMockForAbstractClass(); + $component2->expects($this->any()) + ->method('getComponentName') + ->willReturn('other_type'); + + $this->processor->register($this->component); + $this->processor->register($component2); + $this->processor->attach($type, $this->observer); + $this->processor->notify($type); + } + + public function testDetach() + { + $this->processor->detach('unexists_type', $this->observer); + $this->processor->attach('some_type', $this->observer); + $this->processor->notify('unexists_type'); + $this->processor->detach('some_type', $this->observer); + } +} diff --git a/lib/web/css/source/components/_modals.less b/lib/web/css/source/components/_modals.less index 005b0ff36c95e641b57f6757e2386bd30171d933..7bf5699bbfb405f06e3d38ef6bae693c6a97d94c 100644 --- a/lib/web/css/source/components/_modals.less +++ b/lib/web/css/source/components/_modals.less @@ -201,7 +201,7 @@ body { .lib-vendor-prefix-flex-shrink(0); } .modal-header { - padding-bottom: @modal-popup__padding; + padding-bottom: @modal-popup__padding / 2.5; padding-top: @modal-popup__padding; } .modal-footer { @@ -212,36 +212,6 @@ body { .modal-footer-actions { text-align: right; } - &.confirm { - .modal-inner-wrap { - left: 50%; - margin-left: -(@modal-popup-confirm__width/2); - width: @modal-popup-confirm__width; - } - .modal-footer { - text-align: right; - } - } - &._image-box { - .modal-inner-wrap { - margin: 5rem auto; - max-width: @modal-popup-image-box__max-width; - position: static; - } - .thumbnail-preview { - padding-bottom: @indent__l; - text-align: center; - .thumbnail-preview-image-block { - border: 1px solid @modal-popup-image-box__border-color; - margin: 0 auto @indent__base; - max-width: @modal-popup-image-box-preview__max-width; - padding: @indent__base; - } - .thumbnail-preview-image { - max-height: @modal-popup-image-box-preview-image__max-height; - } - } - } } // diff --git a/lib/web/css/source/lib/variables/_popups.less b/lib/web/css/source/lib/variables/_popups.less index bd574bd093003036538169eb3fbfd7a9afac9c5f..7769ae923a90c66bfbd64a9c2c2951e5089c2130 100644 --- a/lib/web/css/source/lib/variables/_popups.less +++ b/lib/web/css/source/lib/variables/_popups.less @@ -7,7 +7,7 @@ // Popup variables // _____________________________________________ -@popup__width: auto; +@popup__width: 100%; @popup__height: auto; @popup__padding: 22px; @popup__background: @color-white; diff --git a/lib/web/knockoutjs/knockout-es5.js b/lib/web/knockoutjs/knockout-es5.js new file mode 100644 index 0000000000000000000000000000000000000000..899edd79aa3e30417689ee52c173007ceb0149f4 --- /dev/null +++ b/lib/web/knockoutjs/knockout-es5.js @@ -0,0 +1,468 @@ +/*! + * Knockout ES5 plugin - https://github.com/SteveSanderson/knockout-es5 + * Copyright (c) Steve Sanderson + * MIT license + */ + +(function(global, undefined) { + 'use strict'; + + var ko; + + // Model tracking + // -------------- + // + // This is the central feature of Knockout-ES5. We augment model objects by converting properties + // into ES5 getter/setter pairs that read/write an underlying Knockout observable. This means you can + // use plain JavaScript syntax to read/write the property while still getting the full benefits of + // Knockout's automatic dependency detection and notification triggering. + // + // For comparison, here's Knockout ES3-compatible syntax: + // + // var firstNameLength = myModel.user().firstName().length; // Read + // myModel.user().firstName('Bert'); // Write + // + // ... versus Knockout-ES5 syntax: + // + // var firstNameLength = myModel.user.firstName.length; // Read + // myModel.user.firstName = 'Bert'; // Write + + // `ko.track(model)` converts each property on the given model object into a getter/setter pair that + // wraps a Knockout observable. Optionally specify an array of property names to wrap; otherwise we + // wrap all properties. If any of the properties are already observables, we replace them with + // ES5 getter/setter pairs that wrap your original observable instances. In the case of readonly + // ko.computed properties, we simply do not define a setter (so attempted writes will be ignored, + // which is how ES5 readonly properties normally behave). + // + // By design, this does *not* recursively walk child object properties, because making literally + // everything everywhere independently observable is usually unhelpful. When you do want to track + // child object properties independently, define your own class for those child objects and put + // a separate ko.track call into its constructor --- this gives you far more control. + /** + * @param {object} obj + * @param {object|array.<string>} propertyNamesOrSettings + * @param {boolean} propertyNamesOrSettings.deep Use deep track. + * @param {array.<string>} propertyNamesOrSettings.fields Array of property names to wrap. + * todo: @param {array.<string>} propertyNamesOrSettings.exclude Array of exclude property names to wrap. + * todo: @param {function(string, *):boolean} propertyNamesOrSettings.filter Function to filter property + * names to wrap. A function that takes ... params + * @return {object} + */ + function track(obj, propertyNamesOrSettings) { + if (!obj || typeof obj !== 'object') { + throw new Error('When calling ko.track, you must pass an object as the first parameter.'); + } + + var propertyNames; + + if ( isPlainObject(propertyNamesOrSettings) ) { + // defaults + propertyNamesOrSettings.deep = propertyNamesOrSettings.deep || false; + propertyNamesOrSettings.fields = propertyNamesOrSettings.fields || Object.getOwnPropertyNames(obj); + propertyNamesOrSettings.lazy = propertyNamesOrSettings.lazy || false; + + wrap(obj, propertyNamesOrSettings.fields, propertyNamesOrSettings); + } else { + propertyNames = propertyNamesOrSettings || Object.getOwnPropertyNames(obj); + wrap(obj, propertyNames, {}); + } + + return obj; + } + + // fix for ie + var rFunctionName = /^function\s*([^\s(]+)/; + function getFunctionName( ctor ){ + if (ctor.name) { + return ctor.name; + } + return (ctor.toString().trim().match( rFunctionName ) || [])[1]; + } + + function canTrack(obj) { + return obj && typeof obj === 'object' && getFunctionName(obj.constructor) === 'Object'; + } + + function createPropertyDescriptor(originalValue, prop, map) { + var isObservable = ko.isObservable(originalValue); + var isArray = !isObservable && Array.isArray(originalValue); + var observable = isObservable ? originalValue + : isArray ? ko.observableArray(originalValue) + : ko.observable(originalValue); + + map[prop] = function () { return observable; }; + + // add check in case the object is already an observable array + if (isArray || (isObservable && 'push' in observable)) { + notifyWhenPresentOrFutureArrayValuesMutate(ko, observable); + } + + return { + configurable: true, + enumerable: true, + get: observable, + set: ko.isWriteableObservable(observable) ? observable : undefined + }; + } + + function createLazyPropertyDescriptor(originalValue, prop, map) { + if (ko.isObservable(originalValue)) { + // no need to be lazy if we already have an observable + return createPropertyDescriptor(originalValue, prop, map); + } + + var observable; + + function getOrCreateObservable(value, writing) { + if (observable) { + return writing ? observable(value) : observable; + } + + if (Array.isArray(value)) { + observable = ko.observableArray(value); + notifyWhenPresentOrFutureArrayValuesMutate(ko, observable); + return observable; + } + + return (observable = ko.observable(value)); + } + + map[prop] = function () { return getOrCreateObservable(originalValue); }; + return { + configurable: true, + enumerable: true, + get: function () { return getOrCreateObservable(originalValue)(); }, + set: function (value) { getOrCreateObservable(value, true); } + }; + } + + function wrap(obj, props, options) { + if (!props.length) { + return; + } + + var allObservablesForObject = getAllObservablesForObject(obj, true); + var descriptors = {}; + + props.forEach(function (prop) { + // Skip properties that are already tracked + if (prop in allObservablesForObject) { + return; + } + + // Skip properties where descriptor can't be redefined + if (Object.getOwnPropertyDescriptor(obj, prop).configurable === false){ + return; + } + + var originalValue = obj[prop]; + descriptors[prop] = (options.lazy ? createLazyPropertyDescriptor : createPropertyDescriptor) + (originalValue, prop, allObservablesForObject); + + if (options.deep && canTrack(originalValue)) { + wrap(originalValue, Object.keys(originalValue), options); + } + }); + + Object.defineProperties(obj, descriptors); + } + + function isPlainObject( obj ){ + return !!obj && typeof obj === 'object' && obj.constructor === Object; + } + + // Lazily created by `getAllObservablesForObject` below. Has to be created lazily because the + // WeakMap factory isn't available until the module has finished loading (may be async). + var objectToObservableMap; + + // Gets or creates the hidden internal key-value collection of observables corresponding to + // properties on the model object. + function getAllObservablesForObject(obj, createIfNotDefined) { + if (!objectToObservableMap) { + objectToObservableMap = weakMapFactory(); + } + + var result = objectToObservableMap.get(obj); + if (!result && createIfNotDefined) { + result = {}; + objectToObservableMap.set(obj, result); + } + return result; + } + + // Removes the internal references to observables mapped to the specified properties + // or the entire object reference if no properties are passed in. This allows the + // observables to be replaced and tracked again. + function untrack(obj, propertyNames) { + if (!objectToObservableMap) { + return; + } + + if (arguments.length === 1) { + objectToObservableMap['delete'](obj); + } else { + var allObservablesForObject = getAllObservablesForObject(obj, false); + if (allObservablesForObject) { + propertyNames.forEach(function(propertyName) { + delete allObservablesForObject[propertyName]; + }); + } + } + } + + // Computed properties + // ------------------- + // + // The preceding code is already sufficient to upgrade ko.computed model properties to ES5 + // getter/setter pairs (or in the case of readonly ko.computed properties, just a getter). + // These then behave like a regular property with a getter function, except they are smarter: + // your evaluator is only invoked when one of its dependencies changes. The result is cached + // and used for all evaluations until the next time a dependency changes). + // + // However, instead of forcing developers to declare a ko.computed property explicitly, it's + // nice to offer a utility function that declares a computed getter directly. + + // Implements `ko.defineProperty` + function defineComputedProperty(obj, propertyName, evaluatorOrOptions) { + var ko = this, + computedOptions = { owner: obj, deferEvaluation: true }; + + if (typeof evaluatorOrOptions === 'function') { + computedOptions.read = evaluatorOrOptions; + } else { + if ('value' in evaluatorOrOptions) { + throw new Error('For ko.defineProperty, you must not specify a "value" for the property. ' + + 'You must provide a "get" function.'); + } + + if (typeof evaluatorOrOptions.get !== 'function') { + throw new Error('For ko.defineProperty, the third parameter must be either an evaluator function, ' + + 'or an options object containing a function called "get".'); + } + + computedOptions.read = evaluatorOrOptions.get; + computedOptions.write = evaluatorOrOptions.set; + } + + obj[propertyName] = ko.computed(computedOptions); + track.call(ko, obj, [propertyName]); + return obj; + } + + // Array handling + // -------------- + // + // Arrays are special, because unlike other property types, they have standard mutator functions + // (`push`/`pop`/`splice`/etc.) and it's desirable to trigger a change notification whenever one of + // those mutator functions is invoked. + // + // Traditionally, Knockout handles this by putting special versions of `push`/`pop`/etc. on observable + // arrays that mutate the underlying array and then trigger a notification. That approach doesn't + // work for Knockout-ES5 because properties now return the underlying arrays, so the mutator runs + // in the context of the underlying array, not any particular observable: + // + // // Operates on the underlying array value + // myModel.someCollection.push('New value'); + // + // To solve this, Knockout-ES5 detects array values, and modifies them as follows: + // 1. Associates a hidden subscribable with each array instance that it encounters + // 2. Intercepts standard mutators (`push`/`pop`/etc.) and makes them trigger the subscribable + // Then, for model properties whose values are arrays, the property's underlying observable + // subscribes to the array subscribable, so it can trigger a change notification after mutation. + + // Given an observable that underlies a model property, watch for any array value that might + // be assigned as the property value, and hook into its change events + function notifyWhenPresentOrFutureArrayValuesMutate(ko, observable) { + var watchingArraySubscription = null; + ko.computed(function () { + // Unsubscribe to any earlier array instance + if (watchingArraySubscription) { + watchingArraySubscription.dispose(); + watchingArraySubscription = null; + } + + // Subscribe to the new array instance + var newArrayInstance = observable(); + if (newArrayInstance instanceof Array) { + watchingArraySubscription = startWatchingArrayInstance(ko, observable, newArrayInstance); + } + }); + } + + // Listens for array mutations, and when they happen, cause the observable to fire notifications. + // This is used to make model properties of type array fire notifications when the array changes. + // Returns a subscribable that can later be disposed. + function startWatchingArrayInstance(ko, observable, arrayInstance) { + var subscribable = getSubscribableForArray(ko, arrayInstance); + return subscribable.subscribe(observable); + } + + // Lazily created by `getSubscribableForArray` below. Has to be created lazily because the + // WeakMap factory isn't available until the module has finished loading (may be async). + var arraySubscribablesMap; + + // Gets or creates a subscribable that fires after each array mutation + function getSubscribableForArray(ko, arrayInstance) { + if (!arraySubscribablesMap) { + arraySubscribablesMap = weakMapFactory(); + } + + var subscribable = arraySubscribablesMap.get(arrayInstance); + if (!subscribable) { + subscribable = new ko.subscribable(); + arraySubscribablesMap.set(arrayInstance, subscribable); + + var notificationPauseSignal = {}; + wrapStandardArrayMutators(arrayInstance, subscribable, notificationPauseSignal); + addKnockoutArrayMutators(ko, arrayInstance, subscribable, notificationPauseSignal); + } + + return subscribable; + } + + // After each array mutation, fires a notification on the given subscribable + function wrapStandardArrayMutators(arrayInstance, subscribable, notificationPauseSignal) { + ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'].forEach(function(fnName) { + var origMutator = arrayInstance[fnName]; + arrayInstance[fnName] = function() { + var result = origMutator.apply(this, arguments); + if (notificationPauseSignal.pause !== true) { + subscribable.notifySubscribers(this); + } + return result; + }; + }); + } + + // Adds Knockout's additional array mutation functions to the array + function addKnockoutArrayMutators(ko, arrayInstance, subscribable, notificationPauseSignal) { + ['remove', 'removeAll', 'destroy', 'destroyAll', 'replace'].forEach(function(fnName) { + // Make it a non-enumerable property for consistency with standard Array functions + Object.defineProperty(arrayInstance, fnName, { + enumerable: false, + value: function() { + var result; + + // These additional array mutators are built using the underlying push/pop/etc. + // mutators, which are wrapped to trigger notifications. But we don't want to + // trigger multiple notifications, so pause the push/pop/etc. wrappers and + // delivery only one notification at the end of the process. + notificationPauseSignal.pause = true; + try { + // Creates a temporary observableArray that can perform the operation. + result = ko.observableArray.fn[fnName].apply(ko.observableArray(arrayInstance), arguments); + } + finally { + notificationPauseSignal.pause = false; + } + subscribable.notifySubscribers(arrayInstance); + return result; + } + }); + }); + } + + // Static utility functions + // ------------------------ + // + // Since Knockout-ES5 sets up properties that return values, not observables, you can't + // trivially subscribe to the underlying observables (e.g., `someProperty.subscribe(...)`), + // or tell them that object values have mutated, etc. To handle this, we set up some + // extra utility functions that can return or work with the underlying observables. + + // Returns the underlying observable associated with a model property (or `null` if the + // model or property doesn't exist, or isn't associated with an observable). This means + // you can subscribe to the property, e.g.: + // + // ko.getObservable(model, 'propertyName') + // .subscribe(function(newValue) { ... }); + function getObservable(obj, propertyName) { + if (!obj || typeof obj !== 'object') { + return null; + } + + var allObservablesForObject = getAllObservablesForObject(obj, false); + if (allObservablesForObject && propertyName in allObservablesForObject) { + return allObservablesForObject[propertyName](); + } + + return null; + } + + // Returns a boolean indicating whether the property on the object has an underlying + // observables. This does the check in a way not to create an observable if the + // object was created with lazily created observables + function isTracked(obj, propertyName) { + if (!obj || typeof obj !== 'object') { + return false; + } + + var allObservablesForObject = getAllObservablesForObject(obj, false); + return !!allObservablesForObject && propertyName in allObservablesForObject; + } + + // Causes a property's associated observable to fire a change notification. Useful when + // the property value is a complex object and you've modified a child property. + function valueHasMutated(obj, propertyName) { + var observable = getObservable(obj, propertyName); + + if (observable) { + observable.valueHasMutated(); + } + } + + // Module initialisation + // --------------------- + // + // When this script is first evaluated, it works out what kind of module loading scenario + // it is in (Node.js or a browser `<script>` tag), stashes a reference to its dependencies + // (currently that's just the WeakMap shim), and then finally attaches itself to whichever + // instance of Knockout.js it can find. + + // A function that returns a new ES6-compatible WeakMap instance (using ES5 shim if needed). + // Instantiated by prepareExports, accounting for which module loader is being used. + var weakMapFactory; + + // Extends a Knockout instance with Knockout-ES5 functionality + function attachToKo(ko) { + ko.track = track; + ko.untrack = untrack; + ko.getObservable = getObservable; + ko.valueHasMutated = valueHasMutated; + ko.defineProperty = defineComputedProperty; + + // todo: test it, maybe added it to ko. directly + ko.es5 = { + getAllObservablesForObject: getAllObservablesForObject, + notifyWhenPresentOrFutureArrayValuesMutate: notifyWhenPresentOrFutureArrayValuesMutate, + isTracked: isTracked + }; + } + + // Determines which module loading scenario we're in, grabs dependencies, and attaches to KO + function prepareExports() { + if (typeof exports === 'object' && typeof module === 'object') { + // Node.js case - load KO and WeakMap modules synchronously + ko = require('knockout'); + var WM = require('../lib/weakmap'); + attachToKo(ko); + weakMapFactory = function() { return new WM(); }; + module.exports = ko; + } else if (typeof define === 'function' && define.amd) { + define(['knockout'], function(koModule) { + ko = koModule; + attachToKo(koModule); + weakMapFactory = function() { return new global.WeakMap(); }; + return koModule; + }); + } else if ('ko' in global) { + // Non-module case - attach to the global instance, and assume a global WeakMap constructor + ko = global.ko; + attachToKo(global.ko); + weakMapFactory = function() { return new global.WeakMap(); }; + } + } + + prepareExports(); + +})(this); \ No newline at end of file diff --git a/lib/web/knockoutjs/knockout-fast-foreach.js b/lib/web/knockoutjs/knockout-fast-foreach.js new file mode 100644 index 0000000000000000000000000000000000000000..7289d46d1c2a6c666748a42c87a340789a2dc73a --- /dev/null +++ b/lib/web/knockoutjs/knockout-fast-foreach.js @@ -0,0 +1,331 @@ +/*! + Knockout Fast Foreach v0.4.1 (2015-07-17T14:06:15.974Z) + By: Brian M Hunt (C) 2015 + License: MIT + + Adds `fastForEach` to `ko.bindingHandlers`. +*/ +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define(['knockout'], factory); + } else if (typeof exports === 'object') { + module.exports = factory(require('knockout')); + } else { + root.KnockoutFastForeach = factory(root.ko); + } +}(this, function (ko) { + "use strict"; +// index.js +// -------- +// Fast For Each +// +// Employing sound techniques to make a faster Knockout foreach binding. +// -------- + +// Utilities + +// from https://github.com/jonschlinkert/is-plain-object +function isPlainObject(o) { + return !!o && typeof o === 'object' && o.constructor === Object; +} + +// From knockout/src/virtualElements.js +var commentNodesHaveTextProperty = document && document.createComment("test").text === "<!--test-->"; +var startCommentRegex = commentNodesHaveTextProperty ? /^<!--\s*ko(?:\s+([\s\S]+))?\s*-->$/ : /^\s*ko(?:\s+([\s\S]+))?\s*$/; +var supportsDocumentFragment = document && typeof document.createDocumentFragment === "function"; +function isVirtualNode(node) { + return (node.nodeType === 8) && startCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue); +} + + +// Get a copy of the (possibly virtual) child nodes of the given element, +// put them into a container, then empty the given node. +function makeTemplateNode(sourceNode) { + var container = document.createElement("div"); + var parentNode; + if (sourceNode.content) { + // For e.g. <template> tags + parentNode = sourceNode.content; + } else if (sourceNode.tagName === 'SCRIPT') { + parentNode = document.createElement("div"); + parentNode.innerHTML = sourceNode.text; + } else { + // Anything else e.g. <div> + parentNode = sourceNode; + } + ko.utils.arrayForEach(ko.virtualElements.childNodes(parentNode), function (child) { + // FIXME - This cloneNode could be expensive; we may prefer to iterate over the + // parentNode children in reverse (so as not to foul the indexes as childNodes are + // removed from parentNode when inserted into the container) + if (child) { + container.insertBefore(child.cloneNode(true), null); + } + }); + return container; +} + +function insertAllAfter(containerNode, nodeOrNodeArrayToInsert, insertAfterNode) { + var frag, len, i; + // poor man's node and array check, should be enough for this + if (typeof nodeOrNodeArrayToInsert.nodeType !== "undefined" && typeof nodeOrNodeArrayToInsert.length === "undefined") { + throw new Error("Expected a single node or a node array"); + } + + if (typeof nodeOrNodeArrayToInsert.nodeType !== "undefined") { + ko.virtualElements.insertAfter(containerNode, nodeOrNodeArrayToInsert, insertAfterNode); + return; + } + + if (nodeOrNodeArrayToInsert.length === 1) { + ko.virtualElements.insertAfter(containerNode, nodeOrNodeArrayToInsert[0], insertAfterNode); + return; + } + + if (supportsDocumentFragment) { + frag = document.createDocumentFragment(); + + for (i = 0, len = nodeOrNodeArrayToInsert.length; i !== len; ++i) { + frag.appendChild(nodeOrNodeArrayToInsert[i]); + } + ko.virtualElements.insertAfter(containerNode, frag, insertAfterNode); + } else { + // Nodes are inserted in reverse order - pushed down immediately after + // the last node for the previous item or as the first node of element. + for (i = nodeOrNodeArrayToInsert.length - 1; i >= 0; --i) { + var child = nodeOrNodeArrayToInsert[i]; + if (!child) { + return; + } + ko.virtualElements.insertAfter(containerNode, child, insertAfterNode); + } + } +} + +// Mimic a KO change item 'add' +function valueToChangeAddItem(value, index) { + return { + status: 'added', + value: value, + index: index + }; +} + +function isAdditionAdjacentToLast(changeIndex, arrayChanges) { + return changeIndex > 0 && + changeIndex < arrayChanges.length && + arrayChanges[changeIndex].status === "added" && + arrayChanges[changeIndex - 1].status === "added" && + arrayChanges[changeIndex - 1].index === arrayChanges[changeIndex].index - 1; +} + +function FastForEach(spec) { + this.element = spec.element; + this.container = isVirtualNode(this.element) ? + this.element.parentNode : this.element; + this.$context = spec.$context; + this.data = spec.data; + this.as = spec.as; + this.noContext = spec.noContext; + this.templateNode = makeTemplateNode( + spec.name ? document.getElementById(spec.name).cloneNode(true) : spec.element + ); + this.afterQueueFlush = spec.afterQueueFlush; + this.beforeQueueFlush = spec.beforeQueueFlush; + this.changeQueue = []; + this.lastNodesList = []; + this.indexesToDelete = []; + this.rendering_queued = false; + + // Remove existing content. + ko.virtualElements.emptyNode(this.element); + + // Prime content + var primeData = ko.unwrap(this.data); + if (primeData.map) { + this.onArrayChange(primeData.map(valueToChangeAddItem)); + } + + // Watch for changes + if (ko.isObservable(this.data)) { + if (!this.data.indexOf) { + // Make sure the observable is trackable. + this.data = this.data.extend({trackArrayChanges: true}); + } + this.changeSubs = this.data.subscribe(this.onArrayChange, this, 'arrayChange'); + } +} + + +FastForEach.animateFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || window.msRequestAnimationFrame || + function(cb) { return window.setTimeout(cb, 1000 / 60); }; + + +FastForEach.prototype.dispose = function () { + if (this.changeSubs) { + this.changeSubs.dispose(); + } +}; + + +// If the array changes we register the change. +FastForEach.prototype.onArrayChange = function (changeSet) { + var self = this; + var changeMap = { + added: [], + deleted: [] + }; + for (var i = 0, len = changeSet.length; i < len; i++) { + // the change is appended to a last change info object when both are 'added' and have indexes next to each other + // here I presume that ko is sending changes in monotonic order (in index variable) which happens to be true, tested with push and splice with multiple pushed values + if (isAdditionAdjacentToLast(i, changeSet)) { + var batchValues = changeMap.added[changeMap.added.length - 1].values; + if (!batchValues) { + // transform the last addition into a batch addition object + var lastAddition = changeMap.added.pop(); + var batchAddition = { + isBatch: true, + status: 'added', + index: lastAddition.index, + values: [lastAddition.value] + }; + batchValues = batchAddition.values; + changeMap.added.push(batchAddition); + } + batchValues.push(changeSet[i].value); + } else { + changeMap[changeSet[i].status].push(changeSet[i]); + } + } + if (changeMap.deleted.length > 0) { + this.changeQueue.push.apply(this.changeQueue, changeMap.deleted); + this.changeQueue.push({status: 'clearDeletedIndexes'}); + } + this.changeQueue.push.apply(this.changeQueue, changeMap.added); + // Once a change is registered, the ticking count-down starts for the processQueue. + if (this.changeQueue.length > 0 && !this.rendering_queued) { + this.rendering_queued = true; + FastForEach.animateFrame.call(window, function () { self.processQueue(); }); + } +}; + + +// Reflect all the changes in the queue in the DOM, then wipe the queue. +FastForEach.prototype.processQueue = function () { + var self = this; + + // Callback so folks can do things before the queue flush. + if (typeof this.beforeQueueFlush === 'function') { + this.beforeQueueFlush(this.changeQueue); + } + + ko.utils.arrayForEach(this.changeQueue, function (changeItem) { + // console.log(self.data(), "CI", JSON.stringify(changeItem, null, 2), JSON.stringify($(self.element).text())) + self[changeItem.status](changeItem); + // console.log(" ==> ", JSON.stringify($(self.element).text())) + }); + this.rendering_queued = false; + // Callback so folks can do things. + if (typeof this.afterQueueFlush === 'function') { + this.afterQueueFlush(this.changeQueue); + } + this.changeQueue = []; +}; + + +// Process a changeItem with {status: 'added', ...} +FastForEach.prototype.added = function (changeItem) { + var index = changeItem.index; + var valuesToAdd = changeItem.isBatch ? changeItem.values : [changeItem.value]; + var referenceElement = this.lastNodesList[index - 1] || null; + // gather all childnodes for a possible batch insertion + var allChildNodes = []; + + for (var i = 0, len = valuesToAdd.length; i < len; ++i) { + var templateClone = this.templateNode.cloneNode(true); + var childContext; + + if (this.noContext) { + childContext = this.$context.extend({ + '$item': valuesToAdd[i] + }); + } else { + childContext = this.$context.createChildContext(valuesToAdd[i], this.as || null); + } + + // apply bindings first, and then process child nodes, because bindings can add childnodes + ko.applyBindingsToDescendants(childContext, templateClone); + + var childNodes = ko.virtualElements.childNodes(templateClone); + // Note discussion at https://github.com/angular/angular.js/issues/7851 + allChildNodes.push.apply(allChildNodes, Array.prototype.slice.call(childNodes)); + this.lastNodesList.splice(index + i, 0, childNodes[childNodes.length - 1]); + } + + insertAllAfter(this.element, allChildNodes, referenceElement); +}; + + +// Process a changeItem with {status: 'deleted', ...} +FastForEach.prototype.deleted = function (changeItem) { + var index = changeItem.index; + var ptr = this.lastNodesList[index], + // We use this.element because that will be the last previous node + // for virtual element lists. + lastNode = this.lastNodesList[index - 1] || this.element; + do { + ptr = ptr.previousSibling; + ko.removeNode((ptr && ptr.nextSibling) || ko.virtualElements.firstChild(this.element)); + } while (ptr && ptr !== lastNode); + // The "last node" in the DOM from which we begin our delets of the next adjacent node is + // now the sibling that preceded the first node of this item. + this.lastNodesList[index] = this.lastNodesList[index - 1]; + this.indexesToDelete.push(index); +}; + + +// We batch our deletion of item indexes in our parallel array. +// See brianmhunt/knockout-fast-foreach#6/#8 +FastForEach.prototype.clearDeletedIndexes = function () { + // We iterate in reverse on the presumption (following the unit tests) that KO's diff engine + // processes diffs (esp. deletes) monotonically ascending i.e. from index 0 -> N. + for (var i = this.indexesToDelete.length - 1; i >= 0; --i) { + this.lastNodesList.splice(this.indexesToDelete[i], 1); + } + this.indexesToDelete = []; +}; + + +ko.bindingHandlers.fastForEach = { + // Valid valueAccessors: + // [] + // ko.observable([]) + // ko.observableArray([]) + // ko.computed + // {data: array, name: string, as: string} + init: function init(element, valueAccessor, bindings, vm, context) { + var value = valueAccessor(), + ffe; + if (isPlainObject(value)) { + value.element = value.element || element; + value.$context = context; + ffe = new FastForEach(value); + } else { + ffe = new FastForEach({ + element: element, + data: ko.unwrap(context.$rawData) === value ? context.$rawData : value, + $context: context + }); + } + ko.utils.domNodeDisposal.addDisposeCallback(element, function () { + ffe.dispose(); + }); + return {controlsDescendantBindings: true}; + }, + + // Export for testing, debugging, and overloading. + FastForEach: FastForEach +}; + +ko.virtualElements.allowedBindings.fastForEach = true; +})); \ No newline at end of file diff --git a/lib/web/knockoutjs/knockout-repeat.js b/lib/web/knockoutjs/knockout-repeat.js new file mode 100644 index 0000000000000000000000000000000000000000..3bebceb9252be4f03dfcf7b73b408fc359e1a1a3 --- /dev/null +++ b/lib/web/knockoutjs/knockout-repeat.js @@ -0,0 +1,216 @@ +// REPEAT binding for Knockout http://knockoutjs.com/ +// (c) Michael Best +// License: MIT (http://www.opensource.org/licenses/mit-license.php) +// Version 2.1.0 + +(function(factory) { + if (typeof define === 'function' && define.amd) { + // [1] AMD anonymous module + define(['knockout'], factory); + } else if (typeof exports === 'object') { + // [2] commonJS + factory(require('knockout')); + } else { + // [3] No module loader (plain <script> tag) - put directly in global namespace + factory(window.ko); + } +})(function(ko) { + +if (!ko.virtualElements) + throw Error('Repeat requires at least Knockout 2.1'); + +var ko_bindingFlags = ko.bindingFlags || {}; +var ko_unwrap = ko.utils.unwrapObservable; + +var koProtoName = '__ko_proto__'; + +if (ko.version >= "3.0.0") { + // In Knockout 3.0.0, use the node preprocessor to replace a node with a repeat binding with a virtual element + var provider = ko.bindingProvider.instance, previousPreprocessFn = provider.preprocessNode; + provider.preprocessNode = function(node) { + var newNodes, nodeBinding; + if (!previousPreprocessFn || !(newNodes = previousPreprocessFn.call(this, node))) { + if (node.nodeType === 1 && (nodeBinding = node.getAttribute('data-bind'))) { + if (/^\s*repeat\s*:/.test(nodeBinding)) { + var leadingComment = node.ownerDocument.createComment('ko ' + nodeBinding), + trailingComment = node.ownerDocument.createComment('/ko'); + node.parentNode.insertBefore(leadingComment, node); + node.parentNode.insertBefore(trailingComment, node.nextSibling); + node.removeAttribute('data-bind'); + newNodes = [leadingComment, node, trailingComment]; + } + } + } + return newNodes; + }; +} + +ko.virtualElements.allowedBindings.repeat = true; +ko.bindingHandlers.repeat = { + flags: ko_bindingFlags.contentBind | ko_bindingFlags.canUseVirtual, + init: function(element, valueAccessor, allBindingsAccessor, xxx, bindingContext) { + + // Read and set fixed options--these options cannot be changed + var repeatParam = ko_unwrap(valueAccessor()); + if (repeatParam && typeof repeatParam == 'object' && !('length' in repeatParam)) { + var repeatIndex = repeatParam.index, + repeatData = repeatParam.item, + repeatStep = repeatParam.step, + repeatReversed = repeatParam.reverse, + repeatBind = repeatParam.bind, + repeatInit = repeatParam.init, + repeatUpdate = repeatParam.update; + } + // Set default values for options that need it + repeatIndex = repeatIndex || '$index'; + repeatData = repeatData || ko.bindingHandlers.repeat.itemName || '$item'; + repeatStep = repeatStep || 1; + repeatReversed = repeatReversed || false; + + var parent = element.parentNode, placeholder; + if (element.nodeType == 8) { // virtual element + // Extract the "children" and find the single element node + var childNodes = ko.utils.arrayFilter(ko.virtualElements.childNodes(element), function(node) { return node.nodeType == 1;}); + if (childNodes.length !== 1) { + throw Error("Repeat binding requires a single element to repeat"); + } + ko.virtualElements.emptyNode(element); + + // The placeholder is the closing comment normally, or the opening comment if reversed + placeholder = repeatReversed ? element : element.nextSibling; + // The element to repeat is the contained element + element = childNodes[0]; + } else { // regular element + // First clean the element node and remove node's binding + var origBindString = element.getAttribute('data-bind'); + ko.cleanNode(element); + element.removeAttribute('data-bind'); + + // Original element is no longer needed: delete it and create a placeholder comment + placeholder = element.ownerDocument.createComment('ko_repeatplaceholder ' + origBindString); + parent.replaceChild(placeholder, element); + } + + // extract and remove a data-repeat-bind attribute, if present + if (!repeatBind) { + repeatBind = element.getAttribute('data-repeat-bind'); + if (repeatBind) { + element.removeAttribute('data-repeat-bind'); + } + } + + // Make a copy of the element node to be copied for each repetition + var cleanNode = element.cloneNode(true); + if (typeof repeatBind == "string") { + cleanNode.setAttribute('data-bind', repeatBind); + repeatBind = null; + } + + // Set up persistent data + var lastRepeatCount = 0, + notificationObservable = ko.observable(), + repeatArray, arrayObservable; + + if (repeatInit) { + repeatInit(parent); + } + + var subscribable = ko.computed(function() { + function makeArrayItemAccessor(index) { + var f = function(newValue) { + var item = repeatArray[index]; + // Reading the value of the item + if (!arguments.length) { + notificationObservable(); // for dependency tracking + return ko_unwrap(item); + } + // Writing a value to the item + if (ko.isObservable(item)) { + item(newValue); + } else if (arrayObservable && arrayObservable.splice) { + arrayObservable.splice(index, 1, newValue); + } else { + repeatArray[index] = newValue; + } + return this; + }; + // Pretend that our accessor function is an observable + f[koProtoName] = ko.observable; + return f; + } + + function makeBinding(item, index, context) { + return repeatArray + ? function() { return repeatBind.call(bindingContext.$data, item, index, context); } + : function() { return repeatBind.call(bindingContext.$data, index, context); } + } + + // Read and set up variable options--these options can change and will update the binding + var paramObservable = valueAccessor(), repeatParam = ko_unwrap(paramObservable), repeatCount = 0; + if (repeatParam && typeof repeatParam == 'object') { + if ('length' in repeatParam) { + repeatArray = repeatParam; + repeatCount = repeatArray.length; + } else { + if ('foreach' in repeatParam) { + repeatArray = ko_unwrap(paramObservable = repeatParam.foreach); + if (repeatArray && typeof repeatArray == 'object' && 'length' in repeatArray) { + repeatCount = repeatArray.length || 0; + } else { + repeatCount = repeatArray || 0; + repeatArray = null; + } + } + // If a count value is provided (>0), always output that number of items + if ('count' in repeatParam) + repeatCount = ko_unwrap(repeatParam.count) || repeatCount; + // If a limit is provided, don't output more than the limit + if ('limit' in repeatParam) + repeatCount = Math.min(repeatCount, ko_unwrap(repeatParam.limit)) || repeatCount; + } + arrayObservable = repeatArray && ko.isObservable(paramObservable) ? paramObservable : null; + } else { + repeatCount = repeatParam || 0; + } + + // Remove nodes from end if array is shorter + for (; lastRepeatCount > repeatCount; lastRepeatCount-=repeatStep) { + ko.removeNode(repeatReversed ? placeholder.nextSibling : placeholder.previousSibling); + } + + // Notify existing nodes of change + notificationObservable.notifySubscribers(); + + // Add nodes to end if array is longer (also initially populates nodes) + for (; lastRepeatCount < repeatCount; lastRepeatCount+=repeatStep) { + // Clone node and add to document + var newNode = cleanNode.cloneNode(true); + parent.insertBefore(newNode, repeatReversed ? placeholder.nextSibling : placeholder); + newNode.setAttribute('data-repeat-index', lastRepeatCount); + + // Apply bindings to inserted node + if (repeatArray && repeatData == '$data') { + var newContext = bindingContext.createChildContext(makeArrayItemAccessor(lastRepeatCount)); + } else { + var newContext = bindingContext.extend(); + if (repeatArray) + newContext[repeatData] = makeArrayItemAccessor(lastRepeatCount); + } + newContext[repeatIndex] = lastRepeatCount; + if (repeatBind) { + var result = ko.applyBindingsToNode(newNode, makeBinding(newContext[repeatData], lastRepeatCount, newContext), newContext, true), + shouldBindDescendants = result && result.shouldBindDescendants; + } + if (!repeatBind || (result && shouldBindDescendants !== false)) { + ko.applyBindings(newContext, newNode); + } + } + if (repeatUpdate) { + repeatUpdate(parent); + } + }, null, {disposeWhenNodeIsRemoved: placeholder}); + + return { controlsDescendantBindings: true, subscribable: subscribable }; + } +}; +}); \ No newline at end of file diff --git a/lib/web/ko/ko.js b/lib/web/knockoutjs/knockout.js similarity index 100% rename from lib/web/ko/ko.js rename to lib/web/knockoutjs/knockout.js diff --git a/lib/web/mage/adminhtml/backup.js b/lib/web/mage/adminhtml/backup.js index f8dde89519d821795d3c530420f833a066c27faf..fece6796d291d96e5a4b2aa0247effbb1d117ee5 100644 --- a/lib/web/mage/adminhtml/backup.js +++ b/lib/web/mage/adminhtml/backup.js @@ -4,6 +4,7 @@ */ define([ "jquery", + "Magento_Ui/js/modal/modal", "mage/mage", "prototype" ], function(jQuery){ @@ -97,7 +98,6 @@ define([ }, submitBackup: function () { - this.hidePopups(); var data = { 'type': this.type, 'maintenance_mode': $('backup_maintenance_mode').checked ? 1 : 0, @@ -105,6 +105,8 @@ define([ 'exclude_media': $('exclude_media').checked ? 1 : 0 }; + this.modal.modal('closeModal'); + new Ajax.Request(this.backupUrl, { onSuccess: function(transport) { this.processResponse(transport, 'backup-options'); @@ -160,17 +162,78 @@ define([ data['type'] = this.type; return data; }, - + backupConfig: { + 'backup-warning': { + title: jQuery.mage.__('Backup options'), + content: function () { + return jQuery('#backup-options .popup-content').html(); + }, + actionOk: function () { + this.modal.find('#backup-form').validation({ + submitHandler: jQuery.proxy(this.submitBackup, this) + }); + this.modal.find('#backup-form').submit(); + }, + opened: function () { + this.modal.find(':hidden').show(); + } + }, + 'rollback-warning': { + title: jQuery.mage.__('Warning'), + content: function () { + return jQuery('#rollback-warning .message.message-warning').html(); + }, + actionOk: function () { + this.modal.modal('closeModal'); + this.requestPassword(); + } + }, + 'rollback-request-password': { + title: jQuery.mage.__('Backup options'), + content: function () { + return jQuery('#rollback-request-password .popup-content').html(); + }, + actionOk: function () { + this.modal.find('#rollback-request-password').validation({ + submitHandler: jQuery.proxy(this.submitRollback, this) + }); + this.modal.find('#rollback-request-password').submit(); + }, + opened: function () { + this.modal.find('*:hidden').show(); + } + } + }, showPopup: function(divId) { - $(divId).show().setStyle({ - 'marginTop': -$(divId).getDimensions().height / 2 + 'px' + var self = this; + + this.modal = jQuery('<div/>').html(this.backupConfig[divId].content()).modal({ + modalClass: 'magento', + title: this.backupConfig[divId].title, + type: 'slide', + closed: function(e, modal){ + modal.modal.remove(); + }, + opened: function () { + if (self.backupConfig[divId].opened) { + self.backupConfig[divId].opened.call(self); + } + }, + buttons: [{ + text: jQuery.mage.__('Cancel'), + 'class': 'action cancel', + click: function () { + this.closeModal(); + } + }, { + text: jQuery.mage.__('Ok'), + 'class': 'action primary', + click: function () { + self.backupConfig[divId].actionOk.call(self); + } + }] }); - var mask = $('popup-window-mask'); - if (mask) { - $('popup-window-mask').setStyle({ - height: $('html-body').getHeight() + 'px' - }).show(); - } + this.modal.modal('openModal'); }, hidePopups: function() { diff --git a/lib/web/mage/adminhtml/browser.js b/lib/web/mage/adminhtml/browser.js index 2abf3a9b02237b65205001dc9feecaee13fa3e7e..51629ce2e7cfc6f258e5740bcfc197d9bb7773a0 100644 --- a/lib/web/mage/adminhtml/browser.js +++ b/lib/web/mage/adminhtml/browser.js @@ -6,10 +6,14 @@ define([ "jquery", "tinymce", + "Magento_Ui/js/modal/prompt", + "Magento_Ui/js/modal/confirm", + "Magento_Ui/js/modal/alert", + "Magento_Ui/js/modal/modal", "jquery/ui", "jquery/jstree/jquery.jstree", "mage/mage" -], function($, tinyMCE){ +], function($, tinyMCEm, prompt, confirm, alert){ MediabrowserUtility = { windowId: 'modal_dialog_message', @@ -27,44 +31,32 @@ define([ }, openDialog: function(url, width, height, title, options) { var windowId = this.windowId, - content = '<div class="popup-window magento_message" id="' + windowId + '"></div>'; - $(content).dialog($.extend({ - autoOpen: true, - title: title || 'Insert File...', - modal: true, - resizable: false, - width: width || 1000, - height: height || 600, - position: { - my: 'left top', - at: 'center top', - of: 'body' - }, - open: function() { - $(this).closest('.ui-dialog').addClass('ui-dialog-active'); + content = '<div class="popup-window magento_message" "id="' + windowId + '"></div>', + self = this; - var topMargin = $(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 35; - $(this).closest('.ui-dialog').css('margin-top', topMargin); + if (this.modal) { + this.modal.html($(content).html()); + } else { + this.modal = $(content).modal({ + title: title || 'Insert File...', + modalClass: 'magento', + type: 'slide', + buttons: [] + }); + } + this.modal.modal('openModal'); + $.ajax({ + url: url, + type: 'get', + context: $(this), + showLoader: true - $.ajax({ - url: url, - type: 'get', - context: $(this), - showLoader: true - }).done(function(data) { - this.html(data).trigger('contentUpdated'); - }); - }, - close: function(event, ui) { - $(this).closest('.ui-dialog').removeClass('ui-dialog-active'); - $(this).dialog('destroy'); - $('#' + windowId).remove(); - } - }, options)); + }).done(function(data) { + self.modal.html(data).trigger('contentUpdated'); + }); }, - closeDialog: function(win) { - win = win || window; - win.jQuery('#' + this.windowId).dialog('close'); + closeDialog: function() { + this.modal.modal('closeModal'); } }; @@ -256,71 +248,95 @@ define([ }, newFolder: function() { - var folderName = prompt(this.options.newFolderPrompt, ''); - if (!folderName) { - return false; - } - return $.ajax({ - url: this.options.newFolderUrl, - dataType: 'json', - data: { - name: folderName, - node: this.activeNode.id, - store: this.options.storeId, - form_key: FORM_KEY - }, - context: this.element, - showLoader: true - }).done($.proxy(function(data) { - if (data.error) { - window.alert(data.message); - } else { - this.tree.jstree('refresh', this.element.find('[data-id="' + this.activeNode.id + '"]')); + var self = this; + + prompt({ + title: this.options.newFolderPrompt, + actions: { + confirm: function (folderName) { + return $.ajax({ + url: self.options.newFolderUrl, + dataType: 'json', + data: { + name: folderName, + node: self.activeNode.id, + store: self.options.storeId, + form_key: FORM_KEY + }, + context: self.element, + showLoader: true + }).done($.proxy(function(data) { + if (data.error) { + alert({ + content: data.message + }); + } else { + self.tree.jstree('refresh', self.element.find('[data-id="' + self.activeNode.id + '"]')); + } + }, this)); + } } - }, this)); + }); }, deleteFolder: function() { - if (!confirm(this.options.deleteFolderConfirmationMessage)) { - return false; - } + var self = this; - return $.ajax({ - url: this.options.deleteFolderUrl, - dataType: 'json', - data: { - node: this.activeNode.id, - store: this.options.storeId, - form_key: FORM_KEY - }, - context: this.element, - showLoader: true - }).done($.proxy(function(data) { - this.tree.jstree('refresh', this.activeNode.id); - }, this)); + confirm({ + content: this.options.deleteFolderConfirmationMessage, + actions: { + confirm: function () { + return $.ajax({ + url: self.options.deleteFolderUrl, + dataType: 'json', + data: { + node: self.activeNode.id, + store: self.options.storeId, + form_key: FORM_KEY + }, + context: self.element, + showLoader: true + }).done($.proxy(function(data) { + self.tree.jstree('refresh', self.activeNode.id); + }, this)); + }, + cancel: function () { + return false; + } + } + }); }, deleteFiles: function() { - if (!confirm(this.options.deleteFileConfirmationMessage)) { - return false; - } - var selectedFiles = this.element.find('[data-row=file].selected'); - var ids = selectedFiles.map(function(index, file) { - return $(this).attr('id'); - }).toArray(); + var self = this; - return $.ajax({ - url: this.options.deleteFilesUrl, - data: { - files: ids, - store: this.options.storeId, - form_key: FORM_KEY - }, - context: this.element, - showLoader: true - }).done($.proxy(function(data) { - this.reload(); - }, this)); + confirm({ + content: this.options.deleteFileConfirmationMessage, + actions: { + confirm: function () { + var selectedFiles = self.element.find('[data-row=file].selected'); + var ids = selectedFiles.map(function(index, file) { + return $(this).attr('id'); + }).toArray(); + + return $.ajax({ + url: self.options.deleteFilesUrl, + data: { + files: ids, + store: self.options.storeId, + form_key: FORM_KEY + }, + context: self.element, + showLoader: true + }).done($.proxy(function(data) { + self.reload(); + }, this)); + }, + cancel: function () { + return false; + } + } + }); }, drawBreadcrumbs: function(data) { diff --git a/lib/web/mage/adminhtml/events.js b/lib/web/mage/adminhtml/events.js index c342714812d55b49676de1ce46845c84b81fe3ff..d64f09f2e97f3433c4e5b234ef6c5112c7a65b57 100644 --- a/lib/web/mage/adminhtml/events.js +++ b/lib/web/mage/adminhtml/events.js @@ -3,8 +3,9 @@ * See COPYING.txt for license details. */ define([ + 'Magento_Ui/js/modal/alert', 'prototype' -], function(){ +], function(alert){ // from http://www.someelement.com/2007/03/eventpublisher-custom-events-la-pubsub.html varienEvents = Class.create(); @@ -105,10 +106,14 @@ define([ } catch (e) { if (this.id){ - alert("error: error in " + this.id + ".fireEvent():\n\nevent name: " + eventName + "\n\nerror message: " + e.message); + alert({ + content: "error: error in " + this.id + ".fireEvent():\n\nevent name: " + eventName + "\n\nerror message: " + e.message + }); } else { - alert("error: error in [unknown object].fireEvent():\n\nevent name: " + eventName + "\n\nerror message: " + e.message); + alert({ + content: "error: error in [unknown object].fireEvent():\n\nevent name: " + eventName + "\n\nerror message: " + e.message + }); } } } diff --git a/lib/web/mage/adminhtml/globals.js b/lib/web/mage/adminhtml/globals.js index de0e06295e05ba3e8f2f4ae7710f9e84067ba95c..1933b73e0c7c44ea74a80c49a4becf0a2b0a2340 100644 --- a/lib/web/mage/adminhtml/globals.js +++ b/lib/web/mage/adminhtml/globals.js @@ -2,7 +2,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -define([], function () { +define([ + 'Magento_Ui/js/modal/confirm' +], function (confirm) { 'use strict'; /** @@ -20,10 +22,23 @@ define([], function () { * @returns {boolean} */ window.deleteConfirm = function (message, url) { - if (confirm(message)) { - setLocation(url); - } + confirm({ + content: message, + actions: { + confirm: function () { + setLocation(url); + } + } + }); return false; }; + + /** + * Helper for onclick action. + * @param {String} message + * @param {String} url + * @returns {boolean} + */ + window.confirmSetLocation = window.deleteConfirm; }); diff --git a/lib/web/mage/adminhtml/grid.js b/lib/web/mage/adminhtml/grid.js index 684f8358df001c09c64c67d5b6565d3d580f7de7..44d61e001aa0a5a2f890ff255602f14771586e55 100644 --- a/lib/web/mage/adminhtml/grid.js +++ b/lib/web/mage/adminhtml/grid.js @@ -7,11 +7,13 @@ define([ 'jquery', 'mage/template', + 'Magento_Ui/js/modal/alert', + 'Magento_Ui/js/modal/confirm', 'mage/mage', 'prototype', 'mage/adminhtml/form', 'mage/adminhtml/events' -], function (jQuery, mageTemplate) { +], function (jQuery, mageTemplate, alert, confirm) { window.varienGrid = new Class.create(); @@ -158,7 +160,9 @@ varienGrid.prototype = { if (transport.responseText.isJSON()) { var response = transport.responseText.evalJSON() if (response.error) { - alert(response.message); + alert({ + content: response.message + }); } if (response.ajaxExpired && response.ajaxRedirect) { setLocation(response.ajaxRedirect); @@ -641,10 +645,15 @@ varienGridMassaction.prototype = { } }, apply: function() { + var self = this; + if(varienStringArray.count(this.checkedString) == 0) { - alert(this.errorText); - return; - } + alert({ + content: this.errorText + }); + + return; + } var item = this.getSelectedItem(); if(!item) { @@ -653,12 +662,19 @@ varienGridMassaction.prototype = { } this.currentItem = item; var fieldName = (item.field ? item.field : this.formFieldName); - var fieldsHtml = ''; - if(this.currentItem.confirm && !window.confirm(this.currentItem.confirm)) { - return; + if (this.currentItem.confirm) { + confirm({ + content: this.currentItem.confirm, + actions: { + confirm: this.onConfirm.bind(this, fieldName, item) + } + }); + } else { + this.onConfirm(fieldName, item); } - + }, + onConfirm: function(fieldName, item) { this.formHiddens.update(''); new Insertion.Bottom(this.formHiddens, this.fieldTemplate({ name: fieldName, @@ -669,17 +685,17 @@ varienGridMassaction.prototype = { value: fieldName })); - if(!jQuery(this.form).valid()) { + if (!jQuery(this.form).valid()) { return; } - if(this.useAjax && item.url) { + if (this.useAjax && item.url) { new Ajax.Request(item.url, { 'method': 'post', 'parameters': this.form.serialize(true), 'onComplete': this.onMassactionComplete.bind(this) }); - } else if(item.url) { + } else if (item.url) { this.form.action = item.url; this.form.submit(); } diff --git a/lib/web/mage/adminhtml/wysiwyg/widget.js b/lib/web/mage/adminhtml/wysiwyg/widget.js index 354e7e4381d1d4f89540566d8cb81b0eef3825d9..202124d9a29a8928f237a016ccf64a0e5ed8ad0c 100644 --- a/lib/web/mage/adminhtml/wysiwyg/widget.js +++ b/lib/web/mage/adminhtml/wysiwyg/widget.js @@ -6,13 +6,15 @@ define([ "jquery", "tinymce", + 'Magento_Ui/js/modal/alert', "jquery/ui", "mage/translate", "mage/mage", "mage/validation", "mage/adminhtml/events", - "prototype" -], function(jQuery, tinyMCE){ + "prototype", + 'Magento_Ui/js/modal/modal' +], function(jQuery, tinyMCE, alert){ var widgetTools = { getDivHtml: function(id, html) { @@ -51,39 +53,24 @@ define([ return } var oThis = this; - this.dialogWindow = jQuery('<div/>').dialog({ - autoOpen: false, - title: jQuery.mage.__('Insert Widget...'), - modal: true, - resizable: false, - width: '75%', - dialogClass: 'popup-window', - position: { - my: 'left top', - at: 'center top', - of: 'body' - }, - open: function () { + this.dialogWindow = jQuery('<div/>').modal({ + title: jQuery.mage.__('Insert Widget...'), + type: 'slide', + buttons: [], + opened: function () { var dialog = jQuery(this).addClass('loading magento_message') new Ajax.Updater($(this), widgetUrl, {evalScripts: true, onComplete: function () { dialog.removeClass('loading'); } }); - jQuery(this).closest('.ui-dialog').addClass('ui-dialog-active'); - - var topMargin = jQuery(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 35; - jQuery(this).closest('.ui-dialog').css('margin-top', topMargin); - - jQuery(this).addClass('admin__scope-old'); // ToDo UI: remove with old styles removal }, - close: function(event, ui) { - jQuery(this).closest('.ui-dialog').removeClass('ui-dialog-active'); - jQuery(this).dialog('destroy').remove(); + closed: function (e, modal) { + modal.modal.remove(); oThis.dialogOpened = false; } }); this.dialogOpened = true; - this.dialogWindow.dialog('open'); + this.dialogWindow.modal('openModal'); } }; @@ -208,7 +195,9 @@ define([ this.switchOptionsContainer(optionsContainerId); } } catch(e) { - alert(e.message); + alert({ + content: e.message + }); } }.bind(this) } @@ -257,7 +246,7 @@ define([ onComplete: function(transport) { try { widgetTools.onAjaxSuccess(transport); - widgetTools.dialogWindow.dialog('close'); + widgetTools.dialogWindow.modal('closeModal'); if (typeof(tinyMCE) != "undefined" && tinyMCE.activeEditor) { tinyMCE.activeEditor.focus(); @@ -268,7 +257,9 @@ define([ this.updateContent(transport.responseText); } catch(e) { - alert(e.message); + alert({ + content: e.message + }); } }.bind(this) }); @@ -369,52 +360,34 @@ define([ this.dialogContent = widgetTools.getDivHtml(responseContainerId, transport.responseText); this.openDialogWindow(this.dialogContent); } catch(e) { - alert(e.message); + alert({ + content: e.message + }); } }.bind(this) } ); }, - openDialogWindow: function(content) { - this.dialogWindow = jQuery('<div/>').dialog({ - autoOpen: false, - title: this.config.buttons.open, - modal: true, - resizable: false, - width: '75%', - dialogClass: 'popup-window', - position: { - my: 'left top', - at: 'center top', - of: 'body' - }, - open: function () { - jQuery(this).closest('.ui-dialog').addClass('ui-dialog-active'); + openDialogWindow: function (content) { + this.dialogWindow = jQuery('<div/>').modal({ + title: this.config.buttons.open, + type: 'slide', + buttons: [], + opened: function () { jQuery(this).addClass('magento_message'); - - var topMargin = jQuery(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() - 30; - jQuery(this).closest('.ui-dialog').css('margin-top', topMargin); - - jQuery(this).addClass('admin__scope-old'); // ToDo UI: remove with old styles removal }, - close: function(event, ui) { - jQuery(this).closest('.ui-dialog').removeClass('ui-dialog-active'); - jQuery(this).dialog('destroy').remove(); + closed: function (e, modal) { + modal.modal.remove(); + this.dialogWindow = null; } }); - this.dialogWindow.dialog('open').append(content); + this.dialogWindow.modal('openModal').append(content); }, - closeDialogWindow: function(dialogWindow) { - if (!dialogWindow) { - dialogWindow = this.dialogWindow; - } - if (dialogWindow) { - this.dialogWindow.dialog('destroy').remove(); - } - this.dialogWindow = null; + closeDialogWindow: function () { + this.dialogWindow.modal('closeModal').remove(); }, getElementValue: function(value) { diff --git a/lib/web/mage/backend/editablemultiselect.js b/lib/web/mage/backend/editablemultiselect.js index 6ae8d935ddebc29cc2566c1f40a109eabe997856..ab4679bbe165225c7b7f18b67c25f452812de9ce 100644 --- a/lib/web/mage/backend/editablemultiselect.js +++ b/lib/web/mage/backend/editablemultiselect.js @@ -4,9 +4,11 @@ */ define([ "jquery", + 'Magento_Ui/js/modal/alert', + 'Magento_Ui/js/modal/confirm', "jquery/editableMultiselect/js/jquery.editable", "jquery/editableMultiselect/js/jquery.multiselect" -], function($){ +], function($, alert, confirm){ /** @@ -162,7 +164,9 @@ define([ $(this).html(result[entityValueName].escapeHTML()); } } else { - alert(result.error_message); + alert({ + content: result.error_message + }); } } }); @@ -223,7 +227,9 @@ define([ options.mselectInputClass + ''; sectionBlock.find(inputSelector).trigger('blur'); } else { - alert(result.error_message); + alert({ + content: result.error_message + }); } } }; @@ -236,33 +242,43 @@ define([ * @param options */ EditableMultiselect.prototype.deleteEntity = function(options) { - if (!confirm(this.deleteConfirmMessage) || !options.delete_button) { - return; - } - // Button that has been clicked - var deleteButton = $(options.delete_button), - index = deleteButton.parent().index(), - select = deleteButton.closest('.mselect-list').prev(), - entityId = select.find('option').eq(index).val(), - entityInfo = {}; - entityInfo[this.entityIdName] = entityId; - var postData = $.extend(entityInfo, this.submitData); + var self = this; - var ajaxOptions = { - type: 'POST', - data: postData, - dataType: 'json', - url: this.deleteUrl, - success: function(result, status) { - if (result.success) { - deleteButton.parent().remove(); - select.find('option').eq(index).remove(); - } else { - alert(result.error_message); + if (options.delete_button) { + confirm({ + content: this.deleteConfirmMessage, + actions: { + confirm: function() { + // Button that has been clicked + var deleteButton = $(options.delete_button), + index = deleteButton.parent().index(), + select = deleteButton.closest('.mselect-list').prev(), + entityId = select.find('option').eq(index).val(), + entityInfo = {}; + entityInfo[self.entityIdName] = entityId; + var postData = $.extend(entityInfo, self.submitData); + + var ajaxOptions = { + type: 'POST', + data: postData, + dataType: 'json', + url: self.deleteUrl, + success: function(result, status) { + if (result.success) { + deleteButton.parent().remove(); + select.find('option').eq(index).remove(); + } else { + alert({ + content: result.error_message + }); + } + } + }; + $.ajax(ajaxOptions); + } } - } - }; - $.ajax(ajaxOptions); + }); + } }; }; }); \ No newline at end of file diff --git a/lib/web/mage/backend/suggest.js b/lib/web/mage/backend/suggest.js index f4efd12693997985cdc08232778491db37a74848..cc9184d33dd62a81c0a31f0071eae3fbb9966521 100644 --- a/lib/web/mage/backend/suggest.js +++ b/lib/web/mage/backend/suggest.js @@ -235,6 +235,9 @@ } break; case keyCode.ESCAPE: + if (this.isDropdownShown()) { + event.stopPropagation(); + } this.close(event); this._blurItem(); break; @@ -445,6 +448,7 @@ */ open: function (e) { if (!this.isDropdownShown()) { + this.element.addClass('_suggest-dropdown-open'); this.dropdown.show(); this._trigger('open', e); } @@ -459,6 +463,7 @@ this._renderedContext = null; if (this.dropdown.length) { + this.element.removeClass('_suggest-dropdown-open'); this.dropdown.hide().empty(); } diff --git a/lib/web/mage/backend/validation.js b/lib/web/mage/backend/validation.js index 122a8159f5863a611742e59c50eeb7a3184ae18b..58f14f8cd46a052f391e60edf71759efeb85bfe2 100644 --- a/lib/web/mage/backend/validation.js +++ b/lib/web/mage/backend/validation.js @@ -9,6 +9,7 @@ define([ "jquery", "underscore", + 'Magento_Ui/js/modal/alert', "jquery/ui", "jquery/validate", "mage/translate", @@ -17,7 +18,7 @@ } else { factory(jQuery); } -}(function ($, _) { +}(function ($, _, alert) { "use strict"; $.extend(true, $.validator.prototype, { @@ -247,8 +248,10 @@ newFileContainer = elmParent.find('.new-file'); if (!alertAlreadyDisplayed && (newFileContainer.empty() || newFileContainer.is(':visible'))) { alertAlreadyDisplayed = true; - alert($.mage.__('There are files that were selected but not uploaded yet. ' + - 'Please upload or remove them first')); + alert({ + content: $.mage.__('There are files that were selected but not uploaded yet. ' + + 'Please upload or remove them first') + }); } return false; } diff --git a/lib/web/mage/cookies.js b/lib/web/mage/cookies.js index d30b49924a22cf95d230df0b3920e3a60ff45bc1..d4b98a23e641b28023d4eba124c4f0369f86fe09 100644 --- a/lib/web/mage/cookies.js +++ b/lib/web/mage/cookies.js @@ -44,7 +44,7 @@ * @return {Date|null} Calculated cookie expiration date or null if no lifetime provided. * @private */ - function lifetimeToExpires(options) { + function lifetimeToExpires(options, defaults) { var expires, lifetime; @@ -52,6 +52,7 @@ if (lifetime && lifetime > 0) { expires = options.expires || new Date(); + return new Date(expires.getTime() + lifetime * 1000); } @@ -71,7 +72,7 @@ secure; options = $.extend({}, this.defaults, options || {}); - expires = lifetimeToExpires(options) || options.expires; + expires = lifetimeToExpires(options, this.defaults) || options.expires; path = options.path; domain = options.domain; secure = options.secure; diff --git a/lib/web/mage/gallery/gallery.js b/lib/web/mage/gallery/gallery.js index 2f38ea505aa10cf32549912cbddf9c00ca343313..245f08f824bd9cb0ab063778b0b328e1d96a59a2 100644 --- a/lib/web/mage/gallery/gallery.js +++ b/lib/web/mage/gallery/gallery.js @@ -9,7 +9,7 @@ define([ 'matchMedia', 'mage/template', 'text!mage/gallery/gallery.html', - 'Magento_Ui/js/lib/class', + 'uiClass', 'mage/translate' ], function ($, fotorama, _, mediaCheck, template, galleryTpl, Class, $t) { 'use strict'; diff --git a/lib/web/mage/requirejs/mixins.js b/lib/web/mage/requirejs/mixins.js index c3cc36a4adf4a6406a6a2ee1a208f73b47924da8..89baa7933749f89753774a751fc5d64ec471d86f 100644 --- a/lib/web/mage/requirejs/mixins.js +++ b/lib/web/mage/requirejs/mixins.js @@ -89,6 +89,7 @@ define('mixins', [ } return { + /** * Loads specified module along with its' mixins. * diff --git a/lib/web/mage/requirejs/plugin/id-normalizer.js b/lib/web/mage/requirejs/plugin/id-normalizer.js deleted file mode 100644 index b9c44c68e33259d6c9347f0179607fa791ba0400..0000000000000000000000000000000000000000 --- a/lib/web/mage/requirejs/plugin/id-normalizer.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*jshint globalstrict: true*/ -/*global define: false*/ -"use strict"; - -/** - * This is simple normalization plugin for RequireJS, which converts Magento modular references to normalized paths. - * E.g. 'Magento_Catalog::js/scripts.js' -> 'Magento_Catalog/js/scripts.js'. - */ -define({ - /** - * Normalize Magento modular ID - */ - normalize: function (name, normalize) { - return name.replace('::', '/'); - }, - - /** - * load() is not needed for this plugin, but is required by RequireJS. - * So it is just proxy over default implementation. - */ - load: function (name, parentRequire, onload, config) { - parentRequire([name], onload); - } -}); diff --git a/lib/web/mage/requirejs/static.js b/lib/web/mage/requirejs/static.js index cb579e80ece6820b87c6defe33ed9b3d3cbd63fb..a2ee644942a036102b8f3bcfbb451cabdee1d183 100644 --- a/lib/web/mage/requirejs/static.js +++ b/lib/web/mage/requirejs/static.js @@ -158,6 +158,7 @@ define('statistician', [ } return { + /** * Stores keys of 'modules' object to localStorage under 'all' namespace. * diff --git a/lib/web/mage/utils/compare.js b/lib/web/mage/utils/compare.js index 38ec53b205d842ba34132c44b5945f700e9db160..2cae7362a2109dc86c5f403b3ea661a8913ef38f 100644 --- a/lib/web/mage/utils/compare.js +++ b/lib/web/mage/utils/compare.js @@ -185,9 +185,11 @@ define([ addChange(ns, name, 'update', current, old); } } + /*eslint-enable max-depth*/ return { + /** * * @returns {Object} diff --git a/lib/web/mage/utils/misc.js b/lib/web/mage/utils/misc.js index 8885679a61c9334ec5435d2f0e49acb0728c7aa2..afbdf70ae4590a7945390c1d775f99e949e898d9 100644 --- a/lib/web/mage/utils/misc.js +++ b/lib/web/mage/utils/misc.js @@ -7,7 +7,15 @@ define([ ], function (_) { 'use strict'; - var map = { + var defaultAttributes, + map; + + defaultAttributes = { + method: 'post', + enctype: 'multipart/form-data' + }; + + map = { 'D': 'DDD', 'dd': 'DD', 'd': 'D', @@ -106,15 +114,21 @@ define([ * @param {Object} options - Options object that consists of * a 'url' and 'data' properties. */ - submit: function (options) { - var form = document.createElement('form'), - data = this.serialize(options.data), + submit: function (options, attrs) { + var form = document.createElement('form'), + data = this.serialize(options.data), + attributes = _.extend({}, defaultAttributes, attrs || {}), field; - data.form_key = FORM_KEY; + if (!attributes.action) { + attributes.action = options.url; + } + + data.form_key = window.FORM_KEY; - form.setAttribute('action', options.url); - form.setAttribute('method', 'post'); + _.each(attributes, function (value, name) { + form.setAttribute(name, value); + }); _.each(data, function (value, name) { field = document.createElement('input'); diff --git a/lib/web/mage/utils/objects.js b/lib/web/mage/utils/objects.js index 92b49508b4908312c4c677235d9278793e1f46a2..4ea214f0dca36c1dabe845a3d82d3426daa13748 100644 --- a/lib/web/mage/utils/objects.js +++ b/lib/web/mage/utils/objects.js @@ -326,8 +326,6 @@ define([ * @param {Number} [maxDepth=7] - Max recursion depth. */ forEachRecursive: function (data, action, maxDepth) { - var prop; - maxDepth = typeof maxDepth === 'number' && !isNaN(maxDepth) ? maxDepth - 1 : 7; if (!_.isFunction(action) || _.isFunction(data) || maxDepth < 0) { diff --git a/lib/web/mage/utils/strings.js b/lib/web/mage/utils/strings.js index 89a9109f99e7a433c38aaf456c8032c65bdcb256..8c6f8d329f6619e7ebd0943c04c4d778780f02cd 100644 --- a/lib/web/mage/utils/strings.js +++ b/lib/web/mage/utils/strings.js @@ -10,6 +10,7 @@ define([ var jsonRe = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/; return { + /** * Attempts to convert string to one of the primitive values, * or to parse it as a valid json object. @@ -95,7 +96,7 @@ define([ return prefix ? prefix + '.' + part : part; }, - /** + /** * Splits incoming string and returns its' part specified by offset. * * @param {String} parts diff --git a/lib/web/mage/utils/template.js b/lib/web/mage/utils/template.js index 85f2aeb5b037420e25f26bd6687bb00c3c3af7fa..9f0e5f656c96367ea7872526904382b2fa7284b9 100644 --- a/lib/web/mage/utils/template.js +++ b/lib/web/mage/utils/template.js @@ -30,6 +30,7 @@ define([ })(); if (hasStringTmpls) { + /*eslint-disable no-unused-vars, no-eval*/ /** * Evaluates template string using ES6 templates. @@ -41,8 +42,10 @@ define([ template = function (tmpl, $) { return eval('`' + tmpl + '`'); }; + /*eslint-enable no-unused-vars, no-eval*/ } else { + /** * Fallback function used when ES6 templates are not supported. * Uses underscore templates renderer. @@ -106,6 +109,7 @@ define([ } return { + /** * Applies provided data to the template. * diff --git a/lib/web/mage/utils/wrapper.js b/lib/web/mage/utils/wrapper.js index 51985cae41531c915ebacce392d37631c036f0e7..4a0253701aee32768d793439b76a458c0db1f9aa 100644 --- a/lib/web/mage/utils/wrapper.js +++ b/lib/web/mage/utils/wrapper.js @@ -43,6 +43,7 @@ define([ var superReg = /\b_super\b/; return { + /** * Wraps target function with a specified wrapper, which will recieve * reference to the original function as a first argument. diff --git a/lib/web/mage/validation/url.js b/lib/web/mage/validation/url.js new file mode 100644 index 0000000000000000000000000000000000000000..5361d9522787650bd470d9941153527b192ff781 --- /dev/null +++ b/lib/web/mage/validation/url.js @@ -0,0 +1,50 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([], function () { + 'use strict'; + + return { + + /** + * Redirects to the url if it is considered safe + * + * @param {String} path - url to be redirected to + */ + redirect: function (path) { + path = this.sanitize(path); + + if (this.validate(path)) { + window.location.href = path; + } + }, + + /** + * Validates url + * + * @param {Object} path - url to be validated + * @returns {Boolean} + */ + validate: function (path) { + var hostname = window.location.hostname; + + if (path.indexOf(hostname) === -1 || + path.indexOf('javascript:') !== -1 || + path.indexOf('vbscript:') !== -1) { + return false; + } + }, + + /** + * Sanitize url, replacing disallowed chars + * + * @param {Sring} path - url to be normalized + * @returns {String} + */ + sanitize: function (path) { + return path.Replace('[^-A-Za-z0-9+&@#/%?=~_|!:,.;\(\)]', ''); + } + }; +});