Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into PR-4
Browse files Browse the repository at this point in the history
  • Loading branch information
Natalia Momotenko committed Nov 27, 2015
2 parents 349d7aa + 1feb9f4 commit 395d85f
Show file tree
Hide file tree
Showing 16 changed files with 1,043 additions and 740 deletions.
Expand Up @@ -14,4 +14,25 @@ class Text extends AbstractSwatch
* @var string
*/
protected $_template = 'Magento_Swatches::catalog/product/attribute/text.phtml';

/**
* Return json config for text option JS initialization
*
* @return array
*/
public function getJsonConfig()
{
$values = [];
foreach ($this->getOptionValues() as $value) {
$values[] = $value->getData();
}

$data = [
'attributesData' => $values,
'isSortable' => (int)(!$this->getReadOnly() && !$this->canManageOptionDefaultOnly()),
'isReadOnly' => (int)$this->getReadOnly()
];

return json_encode($data);
}
}
Expand Up @@ -52,6 +52,28 @@ protected function createStoreValues($storeId, $optionId)
return $value;
}

/**
* Return json config for visual option JS initialization
*
* @return array
*/
public function getJsonConfig()
{
$values = [];
foreach ($this->getOptionValues() as $value) {
$values[] = $value->getData();
}

$data = [
'attributesData' => $values,
'uploadActionUrl' => $this->getUrl('swatches/iframe/show'),
'isSortable' => (int)(!$this->getReadOnly() && !$this->canManageOptionDefaultOnly()),
'isReadOnly' => (int)$this->getReadOnly()
];

return json_encode($data);
}

/**
* Parse swatch labels for template
*
Expand Down
Expand Up @@ -10,7 +10,6 @@
<css src="Magento_Swatches::css/swatches.css"/>
<css src="jquery/colorpicker/css/colorpicker.css"/>
<link src="jquery/colorpicker/js/colorpicker.js"/>
<link src="Magento_Swatches::js/TypeChanger.js"/>
</head>
<body>
<referenceContainer name="main">
Expand Down
Expand Up @@ -10,7 +10,6 @@
<css src="Magento_Swatches::css/swatches.css"/>
<css src="jquery/colorpicker/css/colorpicker.css"/>
<link src="jquery/colorpicker/js/colorpicker.js"/>
<link src="Magento_Swatches::js/TypeChanger.js"/>
</head>
<body>
<referenceContainer name="form">
Expand Down
13 changes: 13 additions & 0 deletions app/code/Magento/Swatches/view/adminhtml/requirejs-config.js
@@ -0,0 +1,13 @@
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

var config = {
map: {
'*': {
swatchesProductAttributes: 'Magento_Swatches/js/product-attributes',
swatchesTypeChange: 'Magento_Swatches/js/type-change'
}
}
};

0 comments on commit 395d85f

Please sign in to comment.