Skip to content

Commit f94e2ef

Browse files
authored
Merge pull request #5746 from spryker/bugfix/cc-4629-disable-product-attributes-without-management-entry
CC-4629 Product Management: Disable attributes without management entry
2 parents de50dcf + 0628bfd commit f94e2ef

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

assets/Zed/js/modules/product-attribute.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,9 @@ function updateAttributeInputsWithAutoComplete() {
297297
$('[data-allow_input=""],[data-allow_input="false"],[data-allow_input="0"]').each(function(key, value) {
298298
var input = $(value);
299299
var is_super = castToBoolean(input.attr('data-is_super'));
300+
var is_read_only = castToBoolean(input.attr('data-is_read_only'));
300301

301-
if (!is_super) {
302+
if (!is_super && !is_read_only) {
302303
input
303304
.on('focus click', function(event, ui) {
304305
$(this).autocomplete('search', '');
@@ -310,9 +311,9 @@ function updateAttributeInputsWithAutoComplete() {
310311
var input = $(value);
311312
var id = input.attr('data-id_attribute') || null;
312313
var locale_code = input.attr('data-locale_code') || null;
313-
var is_super = castToBoolean(input.attr('data-is_super'));
314+
var is_read_only = castToBoolean(input.attr('data-is_read_only'));
314315

315-
if (!is_super) {
316+
if (!is_read_only) {
316317
input.on('dblclick', function(event, ui) {
317318
$(this).autocomplete('search', '');
318319
});

src/Spryker/Zed/ProductAttributeGui/Presentation/View/_partials/attribute-table.twig

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
{% set allowInput = metaAttributes[key]['allow_input'] %}
2323
{% set isSuper = metaAttributes[key]['is_super'] %}
2424

25-
{% set readOnly = '' %}
26-
{% if isSuper %}
27-
{% set readOnly = 'readonly="readonly"' %}
25+
{% set isReadOnly = false %}
26+
{% if isSuper or idAttribute is empty %}
27+
{% set isReadOnly = true %}
28+
{% set allowInput = false %}
2829
{% endif %}
2930
<tr {% if isSuper %} {{ 'style="display: none"' }} {% endif %}>
3031
<td style="vertical-align: middle;">
@@ -50,14 +51,17 @@
5051
{% set attributeValue = productAttributes[localeCode][key] %}
5152
<td>
5253
<input
53-
{{ readOnly }}
54+
{% if isReadOnly %}
55+
readonly="readonly"
56+
{% endif %}
5457
id="{{ inputId }}"
5558
name="{{ inputName }}"
5659
type="text"
5760
class="spryker-form-autocomplete form-control ui-autocomplete-input kv_attribute_autocomplete"
5861
value="{{ attributeValue }}"
5962
data-allow_input="{{ allowInput }}"
6063
data-is_super="{{ isSuper }}"
64+
data-is_read_only="{{ isReadOnly }}"
6165
data-attribute_key="{{ key }}"
6266
data-is_attribute_input
6367
data-id_attribute="{{ idAttribute }}"
@@ -67,14 +71,17 @@
6771
{% else %}
6872
<td>
6973
<input
70-
{{ readOnly }}
74+
{% if isReadOnly %}
75+
readonly="readonly"
76+
{% endif %}
7177
id="{{ inputId }}"
7278
name="{{ inputName }}"
7379
type="text"
7480
class="spryker-form-autocomplete form-control ui-autocomplete-input kv_attribute_autocomplete"
7581
value=""
7682
data-allow_input="{{ allowInput }}"
7783
data-is_super="{{ isSuper }}"
84+
data-is_read_only="{{ isReadOnly }}"
7885
data-attribute_key="{{ key }}"
7986
data-is_attribute_input
8087
data-id_attribute="{{ idAttribute }}"

0 commit comments

Comments
 (0)