Closed userz58 closed 5 years ago
Existing field type "custom_entity/field/custom-entity-select", not works with import/export job forms. Pls, add that field to your bundle:
pimcustomentity/js/field/job-custom-entity-select.js:
'use strict'; define( [ 'jquery', 'underscore', 'oro/translator', 'pim/fetcher-registry', 'pim/job/common/edit/field/select', 'pim/common/property' ], function ($, _, __, FetcherRegistry, SelectField, propertyAccessor ) { return SelectField.extend({ configure() { let fetcher = null; if (this.config.isCustomEntity) { fetcher = FetcherRegistry.getFetcher('custom_entity').fetchAllByType(this.config.entityName); } else { fetcher = FetcherRegistry.getFetcher(this.config.entityName).fetchAll(); } return $.when( fetcher, SelectField.prototype.configure.apply(this, arguments) ).then(function (items) { if (_.isEmpty(items)) { this.config.readOnly = true; this.config.choices = { 'NO OPTION': __('pim_custom_entity.import.csv.entity_name.no_reference_data') }; } else { let choices = {}; const nameProp = this.config.choiceNameField; const valueProp = this.config.choiceValueField; items.forEach(function (item) { choices[item[nameProp]] = item[valueProp]; }); this.config.options = choices; } }.bind(this)); }, render: function () { if (!this.config.value) { this.config.value = _.first(_.keys(this.config.options)); const data = propertyAccessor.updateProperty( this.getFormData(), this.getFieldCode(), this.config.value ); this.setData(data); } SelectField.prototype.render.apply(this, arguments); } }); });
Hello @userz58 ,
What about doing yourself the PR and we could study it together?
Regards, JM
Closed for inactivity.
Existing field type "custom_entity/field/custom-entity-select", not works with import/export job forms. Pls, add that field to your bundle:
pimcustomentity/js/field/job-custom-entity-select.js: