Conditions | 1 |
Paths | 1 |
Total Lines | 47 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | define(function(require) { |
||
2 | 'use strict'; |
||
3 | |||
4 | var VariantFieldsView; |
||
5 | var $ = require('jquery'); |
||
6 | var _ = require('underscore'); |
||
7 | var BaseView = require('oroui/js/app/views/base/view'); |
||
8 | require('jquery-ui'); |
||
9 | |||
10 | VariantFieldsView = BaseView.extend({ |
||
11 | events: { |
||
12 | 'click a.add-list-item': 'reindexValues' |
||
13 | }, |
||
14 | |||
15 | /** |
||
16 | * @inheritDoc |
||
17 | */ |
||
18 | constructor: function VariantFieldsView() { |
||
19 | VariantFieldsView.__super__.constructor.apply(this, arguments); |
||
20 | }, |
||
21 | |||
22 | render: function() { |
||
23 | this.initSortable(); |
||
24 | this.reindexValues(); |
||
25 | return this; |
||
26 | }, |
||
27 | |||
28 | reindexValues: function() { |
||
29 | var index = 1; |
||
30 | this.$('[name$="[priority]"]').each(function() { |
||
31 | $(this).val(index++); |
||
32 | }); |
||
33 | }, |
||
34 | |||
35 | initSortable: function() { |
||
36 | this.$('[data-name="field__variant-fields"]').sortable({ |
||
37 | handle: '[data-name="sortable-handle"]', |
||
38 | tolerance: 'pointer', |
||
39 | delay: 100, |
||
40 | containment: 'parent', |
||
41 | stop: _.bind(this.reindexValues, this) |
||
42 | }); |
||
43 | } |
||
44 | }); |
||
45 | |||
46 | return VariantFieldsView; |
||
47 | }); |
||
48 |