sortablelabel-js 1.1 → 1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sortablelabel/js/version.rb +1 -1
- data/vendor/assets/javascripts/sortable_label.coffee +40 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7deccf7a6fdb6dd6a39a7d32c168b48aae562b2
|
4
|
+
data.tar.gz: 849222eeb0d982cdf5bcd50a199d16f2b941209e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5500f3041bbb7d4aa87ac3d2972caeb5308f66df4e18468451626f8a4bdfcb04970114687bc5113d310c9ba0a4bff96d55938f14028f23809cc5bef8ade7fbae
|
7
|
+
data.tar.gz: 719a82ab093534fc6ca30216c04eaff27aa2957a2e8b9dedf0df7516664aec5e56b49f35cc0e30fcbf9bbfcf89a2b8fd1c60e2a97d760e5a99929e2a870a5652
|
@@ -14,6 +14,7 @@ class @SortableLabel
|
|
14
14
|
@target = scope
|
15
15
|
@targetId = @options['fieldName'] || @target.attr('id')
|
16
16
|
@stop_callback = @options["stop"]
|
17
|
+
@initSortByPosition()
|
17
18
|
@calInitStepLable()
|
18
19
|
|
19
20
|
$(document).on("nested:fieldAdded:#{@targetId}", (event) =>
|
@@ -41,12 +42,50 @@ class @SortableLabel
|
|
41
42
|
$(this).find('.ui-state-highlight').css('height', $(ui.item).css('height'))
|
42
43
|
stop: =>
|
43
44
|
@calStepLable()
|
45
|
+
if typeof(@stop_callback) == 'function'
|
46
|
+
@stop_callback()
|
44
47
|
)
|
45
48
|
|
46
49
|
@target.on('sortableLabel:disable', =>
|
47
50
|
@target.sortable('disable')
|
48
51
|
)
|
49
52
|
|
53
|
+
# 1. ascending sort if all position fields are not provided
|
54
|
+
# 2. ascending sort field elements which part of them are no provided position
|
55
|
+
initSortByPosition: () ->
|
56
|
+
all_fields = $(@target).find(@options['sortableItem'])
|
57
|
+
_positionTarget = @options['positionTarget']
|
58
|
+
all_fields_info = []
|
59
|
+
maxium_position = 1
|
60
|
+
|
61
|
+
if all_fields.length > 0
|
62
|
+
all_fields.each((index, field_item) ->
|
63
|
+
_position = $(field_item).find(_positionTarget).val()
|
64
|
+
if _position && _position != '' && typeof _position != 'undefined'
|
65
|
+
_position = parseInt(_position, 10)
|
66
|
+
if _position >= maxium_position
|
67
|
+
maxium_position = _position
|
68
|
+
)
|
69
|
+
all_fields.each((index, field_item) ->
|
70
|
+
_position = parseInt($(field_item).find(_positionTarget).val(), 10)
|
71
|
+
if typeof(_position) == 'undefined'
|
72
|
+
_position = maxium_position
|
73
|
+
maxium_position += 1
|
74
|
+
all_fields_info.push({
|
75
|
+
position: _position,
|
76
|
+
j_element: field_item
|
77
|
+
})
|
78
|
+
)
|
79
|
+
|
80
|
+
if all_fields_info.length > 0
|
81
|
+
all_fields_info.sort((a, b) ->
|
82
|
+
return a.position - b.position
|
83
|
+
)
|
84
|
+
_target = @target
|
85
|
+
all_fields_info.forEach((item, index) ->
|
86
|
+
_target.append(item.j_element)
|
87
|
+
)
|
88
|
+
|
50
89
|
calInitStepLable: ->
|
51
90
|
this.calLabel(this.options['removeField']+'[value=false]')
|
52
91
|
if this.options['weekGroupLabelTarget']
|
@@ -85,6 +124,7 @@ class @SortableLabel
|
|
85
124
|
if typeof(@stop_callback) == 'function'
|
86
125
|
@stop_callback();
|
87
126
|
|
127
|
+
|
88
128
|
calWeekGroupLabel: (target) ->
|
89
129
|
_this = this
|
90
130
|
week_group_label_list = []
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sortablelabel-js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|