Skip to content

Commit 8c7960c

Browse files
author
Sergey Semenov
committed
MAGETWO-58651: Refactor saveFormHandler() method
1 parent f1dc91b commit 8c7960c

File tree

1 file changed

+26
-6
lines changed
  • app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations

1 file changed

+26
-6
lines changed

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,7 @@ define([
383383
* Chose action for the form save button
384384
*/
385385
saveFormHandler: function () {
386-
this.source.data['configurable-matrix-serialized'] =
387-
JSON.stringify(this.source.data['configurable-matrix']);
388-
delete this.source.data['configurable-matrix'];
389-
this.source.data['associated_product_ids_serialized'] =
390-
JSON.stringify(this.source.data['associated_product_ids']);
391-
delete this.source.data['associated_product_ids'];
386+
this.serializeData();
392387

393388
if (this.checkForNewAttributes()) {
394389
this.formSaveParams = arguments;
@@ -398,6 +393,31 @@ define([
398393
}
399394
},
400395

396+
/**
397+
* Serialize data for specific form fields
398+
*
399+
* Get data from outdated fields, serialize it and produce new form fields.
400+
*
401+
* Outdated fields:
402+
* - configurable-matrix;
403+
* - associated_product_ids.
404+
*
405+
* New fields:
406+
* - configurable-matrix-serialized;
407+
* - associated_product_ids_serialized.
408+
*/
409+
serializeData: function () {
410+
this.source.data['configurable-matrix-serialized'] =
411+
JSON.stringify(this.source.data['configurable-matrix']);
412+
413+
delete this.source.data['configurable-matrix'];
414+
415+
this.source.data['associated_product_ids_serialized'] =
416+
JSON.stringify(this.source.data['associated_product_ids']);
417+
418+
delete this.source.data['associated_product_ids'];
419+
},
420+
401421
/**
402422
* Check for newly added attributes
403423
* @returns {Boolean}

0 commit comments

Comments
 (0)