Skip to content

Commit

Permalink
Merge pull request #288 from magento-fearless-kiwis/FearlessKiwis-MAG…
Browse files Browse the repository at this point in the history
…ETWO-54779-Watermarks-cant-be-set-mainline

[Fearless Kiwis] MAGETWO-54779: Watermarks cannot be set
  • Loading branch information
heyitsroberthe authored Aug 26, 2016
2 parents 9a4a7eb + c17970c commit 8063845
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ Image,Image
"Allowed file types: jpeg, gif, png.","Allowed file types: jpeg, gif, png."
"Image Opacity","Image Opacity"
"Example format: 200x300.","Example format: 200x300."
"This value does not follow the specified format (for example, 200X300).","This value does not follow the specified format (for example, 200X300)."
"Image Position","Image Position"
Small,Small
"Attribute Label","Attribute Label"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@
<field name="watermark_image_size">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Catalog/component/image-size-field</item>
<item name="label" xsi:type="string" translate="true">Image Size</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">input</item>
<item name="dataScope" xsi:type="string">watermark_image_size</item>
<item name="validation" xsi:type="array">
<item name="validate-digits" xsi:type="boolean">true</item>
<item name="validate-image-size-range" xsi:type="boolean">true</item>
</item>
<item name="notice" xsi:type="string" translate="true">Example format: 200x300.</item>
</item>
Expand Down Expand Up @@ -118,12 +119,13 @@
<field name="watermark_thumbnail_size">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Catalog/component/image-size-field</item>
<item name="label" xsi:type="string" translate="true">Image Size</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">input</item>
<item name="dataScope" xsi:type="string">watermark_thumbnail_size</item>
<item name="validation" xsi:type="array">
<item name="validate-digits" xsi:type="boolean">true</item>
<item name="validate-image-size-range" xsi:type="boolean">true</item>
</item>
<item name="notice" xsi:type="string" translate="true">Example format: 200x300.</item>
</item>
Expand Down Expand Up @@ -181,12 +183,13 @@
<field name="watermark_small_image_size">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Catalog/component/image-size-field</item>
<item name="label" xsi:type="string" translate="true">Image Size</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">input</item>
<item name="dataScope" xsi:type="string">watermark_small_image_size</item>
<item name="validation" xsi:type="array">
<item name="validate-digits" xsi:type="boolean">true</item>
<item name="validate-image-size-range" xsi:type="boolean">true</item>
</item>
<item name="notice" xsi:type="string" translate="true">Example format: 200x300.</item>
</item>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

define([
'jquery',
'Magento_Ui/js/lib/validation/utils',
'Magento_Ui/js/form/element/abstract',
'Magento_Ui/js/lib/validation/validator'
], function ($, utils, Abstract, validator) {
'use strict';

validator.addRule(
'validate-image-size-range',
function (value) {
var dataAttrRange = /^(\d+)x(\d+)$/,
m;

if (utils.isEmptyNoTrim(value)) {
return true;
}

m = dataAttrRange.exec(value);

return !!(m && m[1] > 0 && m[2] > 0);
},
$.mage.__('This value does not follow the specified format (for example, 200X300).')
);

return Abstract.extend({

/**
* Checks for relevant value
*
* @returns {Boolean}
*/
isRangeCorrect: function () {
return validator('validate-image-size-range', this.value()).passed;
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@
<field name="watermark_swatch_image_size">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Catalog/component/image-size-field</item>
<item name="label" xsi:type="string" translate="true">Image Size</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">input</item>
<item name="dataScope" xsi:type="string">watermark_swatch_image_size</item>
<item name="validation" xsi:type="array">
<item name="validate-digits" xsi:type="boolean">true</item>
<item name="validate-image-size-range" xsi:type="boolean">true</item>
</item>
<item name="notice" xsi:type="string" translate="true">Example format: 200x300.</item>
</item>
Expand Down

0 comments on commit 8063845

Please sign in to comment.