Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | 167x 167x 492x 34x 458x 458x 248x 248x 248x 508x 508x 508x 248x 494x 492x 492x 19x | 'use strict'; /** * Price collection field * * @author Julien Sanchez <julien@akeneo.com> * @author Filips Alpe <filips@akeneo.com> * @copyright 2015 Akeneo SAS (http://www.akeneo.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ define([ 'jquery', 'pim/field', 'underscore', 'pim/fetcher-registry', 'pim/template/product/field/price-collection' ], function ($, Field, _, FetcherRegistry, fieldTemplate) { return Field.extend({ fieldTemplate: _.template(fieldTemplate), events: { 'change .field-input:first input[type="text"]': 'updateModel' }, renderInput: function (context) { if (undefined === context.value) { return null; } context.value.data = _.sortBy(context.value.data, 'currency'); return this.fieldTemplate(context); }, updateModel: function () { var prices = []; var inputs = this.$('.field-input:first .price-input input'); _.each(inputs, function (input) { var $input = $(input); var inputData = $input.val(); prices.push({ amount: '' === inputData ? null : inputData, currency: $input.data('currency') }); }.bind(this)); this.setCurrentValue(_.sortBy(prices, 'currency')); }, getTemplateContext: function () { return $.when( Field.prototype.getTemplateContext.apply(this, arguments), FetcherRegistry.getFetcher('currency').fetchAll() ).then(function (templateContext, currencies) { templateContext.currencies = currencies; return templateContext; }); }, setFocus: function () { this.$('input[type="text"]:first').focus(); } }); }); |