active_list 6.4.2 → 6.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd4c696233d13bcef30aa85cda9210d53024d198
4
- data.tar.gz: 9a0305880cb9867f59340984dedb177fb7a6bb7c
3
+ metadata.gz: 62f9715d2a989965c32be8b5dc855624cfd5f4de
4
+ data.tar.gz: a482a5e3779df10b04c5a1b15db26affe3684e5e
5
5
  SHA512:
6
- metadata.gz: 11f71004fd328c21857cc4d5e6b63f49607119de9ac4f7c4b5d8e21331d63526c5c8ad9e1740a75d360ac51d1c22f336f5ec5ecefa6755dac1ec813564e419fc
7
- data.tar.gz: b9552f9f186e45bebd4d369d8644cc739fbf2eccb6f6dde51d3469bc7664eb86f8a5e6e7eb7bb90b7d0c0e765883e26e17dbbda07cb90afdb28a82a49254de1d
6
+ metadata.gz: f44d8554fd100f5fa4415ce9b15b7cca6b7bd6c9d77bb8b6ab5ee9fe2911f47dfb498d8b98390a0ee532761317574a06425d1ce6147abb2050ffabb5319ade06
7
+ data.tar.gz: 7ed6adda88560c0461fb9c983fd56a9dc0eb8a0ee422a9dd407c798e9c3e05215455b444b1b8fed6ce9b624ee4b25f2960cfb33ff2db555d9f0d1e11e577b37a
@@ -4,9 +4,8 @@ ActiveList = {}
4
4
  "use strict"
5
5
 
6
6
  # Main function which reload table with specified data parameters
7
- AL.refresh = (element, options) ->
8
- list = element.closest("div[data-list-source]")
9
- table = element.find("table[data-current-page]").first()
7
+ AL.refresh = (list, options) ->
8
+ table = list.find("table[data-current-page]").first()
10
9
  parameters =
11
10
  sort: table.data("list-sort-by")
12
11
  dir: table.data("list-sort-dir")
@@ -14,14 +13,24 @@ ActiveList = {}
14
13
  per_page: table.data("list-page-size")
15
14
  only: "content"
16
15
  redirect: list.data("list-redirect")
17
-
16
+ list_id = list.attr('id')
18
17
  $.extend parameters, options
19
18
  url = list.data("list-source")
20
19
  $.ajax url,
21
20
  data: parameters
22
21
  dataType: "html"
23
22
  success: (data, status, request) ->
24
- list.html data
23
+ content = $(data)
24
+ console.log content
25
+ list_data = content.find(".list-data")
26
+ list_control = content.find(".list-control")
27
+ for type in ["actions", "pagination", "settings"]
28
+ $("*[data-list-ref='#{list_id}'].list-#{type}").html list_control.find(".list-#{type}")
29
+
30
+ console.log list_data
31
+ list.find(".list-data").html(list_data)
32
+
33
+ # list.html data
25
34
  selection = list.prop('selection')
26
35
  if selection?
27
36
  for id in selection
@@ -37,16 +46,16 @@ ActiveList = {}
37
46
 
38
47
 
39
48
  # Select a row of "many" buttons
40
- AL.select = (element) ->
41
- list = element.closest('div[data-list-source]')
42
- row = element.closest('tr')
49
+ AL.select = (checkbox) ->
50
+ list = checkbox.closest('*[data-list-source]')
51
+ row = checkbox.closest('tr')
43
52
  if list.prop('selection')?
44
53
  selection = list.prop('selection')
45
54
  else
46
55
  selection = []
47
- key = element.data('list-selector')
56
+ key = checkbox.data('list-selector')
48
57
  index = selection.indexOf(key)
49
- if element.is ":checked"
58
+ if checkbox.is ":checked"
50
59
  if index < 0
51
60
  selection.push(key)
52
61
  row.addClass("selected")
@@ -59,16 +68,18 @@ ActiveList = {}
59
68
 
60
69
 
61
70
  # Hide/show needed global buttons
62
- AL.checkGlobalButtons = (element) ->
63
- list = element.closest('div[data-list-source]')
71
+ AL.checkGlobalButtons = (list) ->
64
72
  selection = list.prop('selection')
73
+ list_id = list.attr('id')
74
+ actions = $("*[data-list-ref='#{list_id}']")
65
75
  if selection.length > 0
66
- list.find('*[data-list-actioner="none"]:visible').hide()
67
- list.find('*[data-list-actioner="many"]:hidden').show()
76
+ actions.find("*[data-list-actioner='none']:visible").hide()
77
+ actions.find("*[data-list-actioner='none']:visible").hide()
78
+ actions.find("*[data-list-actioner='many']:hidden").show()
68
79
  else
69
- list.find('*[data-list-actioner="none"]:hidden').show()
70
- list.find('*[data-list-actioner="many"]:visible').hide()
71
- list.find('a[data-list-actioner="many"]').each (index) ->
80
+ actions.find("*[data-list-actioner='none']:hidden").show()
81
+ actions.find("*[data-list-actioner='many']:visible").hide()
82
+ actions.find("*[data-list-actioner='many']").each (index) ->
72
83
  button = $(this)
73
84
  unless button.prop('hrefPattern')?
74
85
  button.prop('hrefPattern', button.attr('href'))
@@ -77,63 +88,85 @@ ActiveList = {}
77
88
  button.attr("href", url)
78
89
 
79
90
 
91
+ # # Move to given page
92
+ # AL.moveToPage = (element, page) ->
93
+ # page_attr = undefined
94
+ # page = element.data("list-move-to-page") if !page? or page is ""
95
+ # alert "Cannot define which page to load: " + page if !page? or page is ""
96
+ # if isNaN(page)
97
+ # page_attr = page
98
+ # page = element.attr(page_attr)
99
+ # alert "Cannot define which page to load with attribute #{page_attr}: #{page}" if isNaN(page)
100
+ # AL.refresh element,
101
+ # page: page
102
+ # false
103
+
80
104
  # Move to given page
81
- AL.moveToPage = (element, page) ->
82
- page_attr = undefined
83
- page = element.data("list-move-to-page") if !page? or page is ""
84
- alert "Cannot define which page to load: " + page if !page? or page is ""
105
+ AL.moveToPage = (list, page) ->
85
106
  if isNaN(page)
86
- page_attr = page
87
- page = element.attr(page_attr)
88
- alert "Cannot define which page to load with attribute #{page_attr}: #{page}" if isNaN(page)
89
- AL.refresh element,
107
+ console.error "Cannot move to page #{page}. A number is expected"
108
+ AL.refresh list,
90
109
  page: page
91
110
  false
92
111
 
93
112
  # Sort by one column
94
- $(document).on "click", "div[data-list-source] th[data-list-column][data-list-column-sort]", (event) ->
113
+ $(document).on "click", "*[data-list-source] th[data-list-column][data-list-column-sort]", (event) ->
95
114
  sorter = $(this)
96
- AL.refresh sorter,
115
+ list = sorter.closest("*[data-list-source]")
116
+ AL.refresh list,
97
117
  sort: sorter.data("list-column")
98
118
  dir: sorter.data("list-column-sort")
99
119
  false
100
120
 
121
+
122
+ # Select row
123
+ $(document).on "click", "*[data-list-source] input[data-list-selector]", (event) ->
124
+ AL.select $(this)
125
+ true
126
+
127
+ # Adds title attribute based on link name
128
+ $(document).on "hover", "*[data-list-source] tbody tr td.act a", (event) ->
129
+ element = $(this)
130
+ title = element.attr("title")
131
+ element.attr "title", element.html() unless title?
132
+ return
133
+
101
134
 
102
135
  # Change number of item per page
103
- $(document).on "click", "div[data-list-source] li[data-list-change-page-size]", (event) ->
136
+ $(document).on "click", "*[data-list-ref] *[data-list-change-page-size]", (event) ->
104
137
  sizer = $(this)
105
138
  per_page = sizer.data("list-change-page-size")
106
139
  if isNaN(per_page)
107
- alert "@list-change-page-size attribute is not a number: #{per_page}"
140
+ console.error "@list-change-page-size attribute is not a number: #{per_page}"
108
141
  else
109
- AL.refresh sizer,
142
+ list = $("##{sizer.closest('*[data-list-ref]').data('list-ref')}")
143
+ AL.refresh list,
110
144
  per_page: per_page
111
145
  false
112
146
 
113
147
 
114
148
  # Toggle visibility of a column
115
- $(document).on "click", "div[data-list-source] li[data-list-toggle-column]", (event) ->
116
- element = $(this)
149
+ $(document).on "click", "*[data-list-ref] *[data-list-toggle-column]", (event) ->
150
+ toggler = $(this)
117
151
  visibility = ""
118
- columnId = element.data("list-toggle-column")
119
- list = element.closest("div[data-list-source]")
152
+ columnId = toggler.data("list-toggle-column")
153
+ list = $("##{toggler.closest('*[data-list-ref]').data('list-ref')}")
120
154
  column = list.find("th[data-list-column=\"#{columnId}\"]")
121
155
 
122
- #$('#'+columnId);
123
156
  className = column.data("list-column-cells")
124
157
  className = columnId unless className?
125
158
  search = ".#{className}"
126
159
  if column.hasClass("hidden")
127
- $(search).removeClass "hidden"
160
+ list.find(search).removeClass "hidden"
128
161
  column.removeClass "hidden"
129
- element.removeClass "unchecked"
130
- element.addClass "checked"
162
+ toggler.removeClass "unchecked"
163
+ toggler.addClass "checked"
131
164
  visibility = "shown"
132
165
  else
133
- $(search).addClass "hidden"
166
+ list.find(search).addClass "hidden"
134
167
  column.addClass "hidden"
135
- element.removeClass "checked"
136
- element.addClass "unchecked"
168
+ toggler.removeClass "checked"
169
+ toggler.addClass "unchecked"
137
170
  visibility = "hidden"
138
171
  $.ajax list.data("list-source"),
139
172
  dataType: "html"
@@ -142,47 +175,37 @@ ActiveList = {}
142
175
  column: columnId
143
176
  false
144
177
 
145
-
146
- # Select row
147
- $(document).on "click", "div[data-list-source] input[data-list-selector]", (event) ->
148
- AL.select $(this)
149
- true
150
-
151
178
 
152
179
  # Change page of table on link clicks
153
- $(document).on "click", "div[data-list-source] a[data-list-move-to-page]", (event) ->
154
- AL.moveToPage $(this)
180
+ $(document).on "click", "*[data-list-ref] a[data-list-move-to-page]", (event) ->
181
+ pager = $(this)
182
+ list = $("##{pager.closest('*[data-list-ref]').data('list-ref')}")
183
+ AL.moveToPage list, pager.data("list-move-to-page")
155
184
  false
156
185
 
157
-
158
- # Change page of table on link clicks
159
- $(document).on "mouseovessr", "div[data-list-source] a[data-list-actioner='many']", (event) ->
160
- element = $(this)
161
- list = element.closest("div[data-list-source]")
162
- selection = list.prop('selection')
163
- if selection?
164
- unless element.prop('hrefPattern')?
165
- element.prop('hrefPattern', element.attr('href'))
166
- pattern = element.prop('hrefPattern')
167
- url = pattern.replace(encodeURIComponent("##IDS##"), selection.join(','), 'g')
168
- console.log url
169
- element.attr("href", url)
170
- console.log url
171
- true
172
-
173
-
174
186
  # Change page of table on input changes
175
- $(document).on "change", "div[data-list-source] input[data-list-move-to-page]", (event) ->
176
- AL.moveToPage $(this)
187
+ $(document).on "change", "*[data-list-ref] input[data-list-move-to-page]", (event) ->
188
+ pager = $(this)
189
+ list = $("##{pager.closest('*[data-list-ref]').data('list-ref')}")
190
+ AL.moveToPage list, pager.data("list-move-to-page")
177
191
  false
178
192
 
179
193
 
180
- # Adds title attribute based on link name
181
- $(document).on "hover", "div[data-list-source] tbody tr td.act a", (event) ->
182
- element = $(this)
183
- title = element.attr("title")
184
- element.attr "title", element.html() unless title?
185
- return
194
+ # #
195
+ # $(document).on "mouseovessr", "*[data-list-ref] a[data-list-actioner='many']", (event) ->
196
+ # element = $(this)
197
+ # list = element.closest("*[data-list-source]")
198
+ # selection = list.prop('selection')
199
+ # if selection?
200
+ # unless element.prop('hrefPattern')?
201
+ # element.prop('hrefPattern', element.attr('href'))
202
+ # pattern = element.prop('hrefPattern')
203
+ # url = pattern.replace(encodeURIComponent("##IDS##"), selection.join(','), 'g')
204
+ # console.log url
205
+ # element.attr("href", url)
206
+ # console.log url
207
+ # true
208
+
186
209
 
187
210
  return
188
211
  ) jQuery, ActiveList
@@ -1,73 +1,73 @@
1
1
  // Minimal style to get a working ActiveList
2
2
 
3
3
  div[data-list-source] {
4
- table.list {
5
- thead {
6
- tr {
7
- th {
8
- &[data-list-column-sort] {
9
- cursor: pointer;
10
- }
11
- &.hidden {
12
- display: none;
13
- }
14
- }
15
- }
16
- }
17
- tbody {
18
- tr {
19
- td.hidden {
20
- display: none;
21
- }
22
- }
23
- }
24
- }
4
+ table.list {
5
+ thead {
6
+ tr {
7
+ th {
8
+ &[data-list-column-sort] {
9
+ cursor: pointer;
10
+ }
11
+ &.hidden {
12
+ display: none;
13
+ }
14
+ }
15
+ }
16
+ }
17
+ tbody {
18
+ tr {
19
+ td.hidden {
20
+ display: none;
21
+ }
22
+ }
23
+ }
24
+ }
25
+ }
25
26
 
26
- .pagination {
27
- a[data-list-move-to-page] {
28
- cursor: pointer;
29
- }
30
- a[data-list-move-to-page][disabled] {
31
- cursor: default;
32
- }
33
- }
34
27
 
35
- .settings {
36
- position: relative;
37
- a { cursor: pointer; }
38
- &:hover {
39
- .settings-start { z-index: 5000; position: relative; top: 0px; }
40
- & > ul { display: block; }
41
- }
42
- ul {
43
- display: none;
44
- position: absolute;
45
- top: 20px;
46
- margin: 0;
47
- & { right: 0px;}
48
- html[dir="rtl"] & { left: 0px;}
49
- li {
50
- &[data-list-change-page-size], &[data-list-toggle-column] {
51
- cursor: pointer;
52
- display: block;
53
- }
54
- list-style-type: none;
55
- width: 25ex;
56
- position: relative;
57
- a {
58
- display: block;
59
- }
60
- ul {
61
- position: relative;
62
- top: -1em;
63
- & { right: 25ex; }
64
- html[dir="rtl"] & { left: 25ex; }
65
- &:hover { display:block; }
66
- }
67
- &:hover ul { display:block; }
68
- }
69
- }
70
- }
28
+ .list-pagination {
29
+ a[data-list-move-to-page] {
30
+ cursor: pointer;
31
+ }
32
+ a[data-list-move-to-page][disabled] {
33
+ cursor: default;
34
+ }
35
+ }
71
36
 
72
37
 
38
+ .list-settings {
39
+ position: relative;
40
+ a { cursor: pointer; }
41
+ &:hover {
42
+ .settings-start { z-index: 5000; position: relative; top: 0px; }
43
+ & > ul { display: block; }
44
+ }
45
+ ul {
46
+ display: none;
47
+ position: absolute;
48
+ top: 20px;
49
+ margin: 0;
50
+ & { right: 0px;}
51
+ html[dir="rtl"] & { left: 0px;}
52
+ li {
53
+ &[data-list-change-page-size], &[data-list-toggle-column] {
54
+ cursor: pointer;
55
+ display: block;
56
+ }
57
+ list-style-type: none;
58
+ width: 25ex;
59
+ position: relative;
60
+ a {
61
+ display: block;
62
+ }
63
+ ul {
64
+ position: relative;
65
+ top: -1em;
66
+ & { right: 25ex; }
67
+ html[dir="rtl"] & { left: 25ex; }
68
+ &:hover { display:block; }
69
+ }
70
+ &:hover ul { display:block; }
71
+ }
72
+ }
73
73
  }
@@ -5,183 +5,183 @@
5
5
 
6
6
  // Because Compass sprites do not seems to work well in gems
7
7
  @mixin active-list-sprite($name, $size: 16px) {
8
- background-image: image-url("active_list.png");
9
- background-repeat: no-repeat;
10
- height: $size;
11
- width: $size;
12
- $i: 0;
13
- @each $icon in menu check columns export pages first-page previous-page previous-line next-line next-page last-page sort sort-down sort-up true false {
14
- @if $icon == $name {
15
- background-position: (-$i * $size) 0;
16
- }
17
- $i: $i + 1;
18
- }
8
+ background-image: image-url("active_list.png");
9
+ background-repeat: no-repeat;
10
+ height: $size;
11
+ width: $size;
12
+ $i: 0;
13
+ @each $icon in menu check columns export pages first-page previous-page previous-line next-line next-page last-page sort sort-down sort-up true false {
14
+ @if $icon == $name {
15
+ background-position: (-$i * $size) 0;
16
+ }
17
+ $i: $i + 1;
18
+ }
19
19
  }
20
20
 
21
21
 
22
22
  @mixin active-list-theme($theme-color: #777777) {
23
- $default-border-color: mix($theme-color, #FFF, 30%);
24
- $menu-width: 250px;
25
- table.list {
26
- border-collapse: collapse;
27
- width: 100%;
28
- border: 1px solid $default-border-color;
29
- z-index: 2;
30
- @include box-shadow(0 0 7px rgba(0, 0, 0, 0.15));
31
- thead {
32
- th {
33
- border: 1px solid $default-border-color;
34
- padding: 2px 3px;
35
- @include background($theme-color linear-gradient(top, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.8)));
36
- &[data-list-column-sort] {
37
- i {
38
- @include active-list-sprite(sort);
39
- @include inline-block;
40
- margin: 0 2px;
41
- }
42
- &.sor[data-list-column-sort="desc"] i {
43
- @include active-list-sprite(sort-down); }
44
- &.sor[data-list-column-sort="asc"] i {
45
- @include active-list-sprite(sort-up); }
46
- }
47
- & { text-align: left; }
48
- html[dir="rtl"] & { text-align: right; }
49
- }
23
+ $default-border-color: mix($theme-color, #FFF, 30%);
24
+ $menu-width: 250px;
25
+ table.list {
26
+ border-collapse: collapse;
27
+ width: 100%;
28
+ border: 1px solid $default-border-color;
29
+ z-index: 2;
30
+ @include box-shadow(0 0 7px rgba(0, 0, 0, 0.15));
31
+ thead {
32
+ th {
33
+ border: 1px solid $default-border-color;
34
+ padding: 2px 3px;
35
+ @include background($theme-color linear-gradient(top, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.8)));
36
+ &[data-list-column-sort] {
37
+ i {
38
+ @include active-list-sprite(sort);
39
+ @include inline-block;
40
+ margin: 0 2px;
41
+ }
42
+ &.sor[data-list-column-sort="desc"] i {
43
+ @include active-list-sprite(sort-down); }
44
+ &.sor[data-list-column-sort="asc"] i {
45
+ @include active-list-sprite(sort-up); }
46
+ }
47
+ & { text-align: left; }
48
+ html[dir="rtl"] & { text-align: right; }
50
49
  }
51
- tbody {
52
- tr {
53
- td {
54
- padding: 2px 3px;
55
- border-top: 1px solid mix($theme-color, #FFF, 10%);
56
- border-bottom: none;
57
- border-left: none;
58
- border-right: none;
59
- &.chk,&.act, &.dld, &.bln, &.dat, &.web { text-align:center }
60
- &.dec, &.flt, &.int {
61
- & { text-align: right; }
62
- html[dir="rtl"] & { text-align: left; }
63
- }
64
- &.country { white-space: nowrap; }
65
- &.color { color: white; text-shadow: 0 0 2px #000; width: 6ex; text-align: center; }
66
- }
67
- &:first-child td {
68
- border-top: none;
69
- }
70
- }
50
+ }
51
+ tbody {
52
+ tr {
53
+ td {
54
+ padding: 2px 3px;
55
+ border-top: 1px solid mix($theme-color, #FFF, 10%);
56
+ border-bottom: none;
57
+ border-left: none;
58
+ border-right: none;
59
+ &.chk,&.act, &.dld, &.bln, &.dat, &.web { text-align:center }
60
+ &.dec, &.flt, &.int {
61
+ & { text-align: right; }
62
+ html[dir="rtl"] & { text-align: left; }
63
+ }
64
+ &.country { white-space: nowrap; }
65
+ &.color { color: white; text-shadow: 0 0 2px #000; width: 6ex; text-align: center; }
66
+ }
67
+ &:first-child td {
68
+ border-top: none;
69
+ }
71
70
  }
71
+ }
72
72
 
73
- @include list-colors(#FFFFFF);
74
- }
73
+ @include list-colors(#FFFFFF);
74
+ }
75
75
 
76
- .list-control {
77
- z-index: 0;
78
- @include background(transparentize(mix($theme-color, #FFF, 40%), 0.7));
79
- }
76
+ .list-control {
77
+ z-index: 0;
78
+ @include background(transparentize(mix($theme-color, #FFF, 40%), 0.7));
79
+ }
80
80
 
81
- .pagination {
82
- & { text-align: left; }
83
- html[dir="rtl"] & { text-align: right; }
84
- & > * {
85
- margin: 0 2px;
86
- }
87
- .first-page, .previous-page, .next-page, .last-page {
88
- @include inline-block;
89
- @include squish-text;
90
- }
91
- html[dir="rtl"] & .last-page, & .first-page {
92
- @include active-list-sprite(first-page);
93
- }
94
- html[dir="rtl"] & .first-page, & .last-page {
95
- @include active-list-sprite(last-page);
96
- }
97
- html[dir="rtl"] & .next-page, & .previous-page {
98
- @include active-list-sprite(previous-page);
99
- }
100
- html[dir="rtl"] & .previous-page, & .next-page {
101
- @include active-list-sprite(next-page);
102
- }
103
- .separator {
104
- @include inline-block;
105
- width: 2px;
106
- height: 1.2em;
107
- background: transparentize($theme-color, 0.7);
108
- }
109
- }
81
+ .list-pagination {
82
+ & { text-align: left; }
83
+ html[dir="rtl"] & { text-align: right; }
84
+ & > * {
85
+ margin: 0 2px;
86
+ }
87
+ .first-page, .previous-page, .next-page, .last-page {
88
+ @include inline-block;
89
+ @include squish-text;
90
+ }
91
+ html[dir="rtl"] & .last-page, & .first-page {
92
+ @include active-list-sprite(first-page);
93
+ }
94
+ html[dir="rtl"] & .first-page, & .last-page {
95
+ @include active-list-sprite(last-page);
96
+ }
97
+ html[dir="rtl"] & .next-page, & .previous-page {
98
+ @include active-list-sprite(previous-page);
99
+ }
100
+ html[dir="rtl"] & .previous-page, & .next-page {
101
+ @include active-list-sprite(next-page);
102
+ }
103
+ .separator {
104
+ @include inline-block;
105
+ width: 2px;
106
+ height: 1.2em;
107
+ background: transparentize($theme-color, 0.7);
108
+ }
109
+ }
110
110
 
111
111
 
112
- .settings {
113
- position: relative;
114
- background: none;
115
- .list-menu-start {
116
- padding: 2px;
117
- width: 16px;
118
- height: 16px;
119
- font-size: 0;
120
- i {
121
- @include active-list-sprite(menu);
122
- display: block;
123
- }
112
+ .list-settings {
113
+ position: relative;
114
+ background: none;
115
+ .list-menu-start {
116
+ padding: 2px;
117
+ width: 16px;
118
+ height: 16px;
119
+ font-size: 0;
120
+ i {
121
+ @include active-list-sprite(menu);
122
+ display: block;
124
123
  }
125
- &:hover {
126
- .settings {
127
- background-color: white;
128
- z-index:5000;
129
- }
124
+ }
125
+ &:hover {
126
+ .settings {
127
+ background-color: white;
128
+ z-index:5000;
130
129
  }
131
- ul {
132
- width: $menu-width;
133
- border: 1px solid $default-border-color;
134
- background: #FFF;
135
- @include box-shadow(0 0 5px rgba(0, 0, 0, 0.3));
136
- li {
137
- width: $menu-width;
138
- padding: 0;
139
- ul {
140
- & { right: $menu-width; }
141
- html[dir="rtl"] & { left: $menu-width; }
142
- }
143
- }
130
+ }
131
+ ul {
132
+ width: $menu-width;
133
+ border: 1px solid $default-border-color;
134
+ background: #FFF;
135
+ @include box-shadow(0 0 5px rgba(0, 0, 0, 0.3));
136
+ li {
137
+ width: $menu-width;
138
+ padding: 0;
139
+ ul {
140
+ & { right: $menu-width; }
141
+ html[dir="rtl"] & { left: $menu-width; }
142
+ }
144
143
  }
145
- & > ul {
146
- top: 19px;
144
+ }
145
+ & > ul {
146
+ top: 19px;
147
+ }
148
+ li {
149
+ padding: 0;
150
+ display: block;
151
+ a {
152
+ display: block;
153
+ padding: 2px;
154
+ line-height: 18px;
155
+ font-weight: normal;
156
+ i {
157
+ height:16px;
158
+ width: 16px;
159
+ & { margin-right: 4px; }
160
+ html[dir="rtl"] & { margin-left: 4px; }
161
+ }
162
+ & * {
163
+ vertical-align: middle;
164
+ }
165
+ &.pages i { @include active-list-sprite(pages); }
166
+ &.columns i { @include active-list-sprite(columns); }
147
167
  }
148
- li {
149
- padding: 0;
150
- display: block;
151
- a {
152
- display: block;
153
- padding: 2px;
154
- line-height: 18px;
155
- font-weight: normal;
156
- i {
157
- height:16px;
158
- width: 16px;
159
- & { margin-right: 4px; }
160
- html[dir="rtl"] & { margin-left: 4px; }
161
- }
162
- & * {
163
- vertical-align: middle;
164
- }
165
- &.pages i { @include active-list-sprite(pages); }
166
- &.columns i { @include active-list-sprite(columns); }
167
- }
168
- &.export i { @include active-list-sprite(export); }
169
- &.check i { @include active-list-sprite(check); }
170
- &.checked i { @include active-list-sprite(true); }
171
- &.unchecked i { @include active-list-sprite(false); }
172
- &:hover {
173
- text-decoration: none;
174
- background: mix($theme-color, #FFF, 10%);
175
- }
176
- &.separator {
177
- padding: 0;
178
- height: 1px;
179
- width: $menu-width - 6px;
180
- margin: 3px;
181
- background: $default-border-color;
182
- }
168
+ &.export i { @include active-list-sprite(export); }
169
+ &.check i { @include active-list-sprite(check); }
170
+ &.checked i { @include active-list-sprite(true); }
171
+ &.unchecked i { @include active-list-sprite(false); }
172
+ &:hover {
173
+ text-decoration: none;
174
+ background: mix($theme-color, #FFF, 10%);
175
+ }
176
+ &.separator {
177
+ padding: 0;
178
+ height: 1px;
179
+ width: $menu-width - 6px;
180
+ margin: 3px;
181
+ background: $default-border-color;
183
182
  }
184
- }
183
+ }
184
+ }
185
185
 
186
186
 
187
187
  }
@@ -51,6 +51,10 @@ module ActiveList
51
51
  return false
52
52
  end
53
53
 
54
+ def state_machine?
55
+ return false
56
+ end
57
+
54
58
  def numeric?
55
59
  [:decimal, :integer, :float, :numeric].include? self.datatype
56
60
  end
@@ -36,7 +36,7 @@ module ActiveList
36
36
  helper_method = "_#{kontroller.controller_name}_#{__method__}_#{name || kontroller.controller_name}_tag".to_sym
37
37
  kontroller = kontroller.superclass
38
38
  end until self.respond_to?(helper_method)
39
- return self.send(helper_method, &block)
39
+ return self.send(helper_method, options, &block)
40
40
  end
41
41
 
42
42
  end
@@ -43,7 +43,7 @@ module ActiveList
43
43
 
44
44
  # colgroup = columns_definition_code
45
45
  header = header_code
46
- extras = extras_code
46
+ extras = extras_codes
47
47
 
48
48
  code = generator.select_data_code
49
49
  code << "#{var_name(:tbody)} = '<tbody data-total=\"' + #{var_name(:count)}.to_s + '\""
@@ -82,7 +82,19 @@ module ActiveList
82
82
 
83
83
  # Build content
84
84
  code << "#{var_name(:content)} = ''\n"
85
- code << "#{var_name(:content)} << #{extras}\n" unless extras.blank?
85
+ if extras.any?
86
+ # code << "#{var_name(:content)} << #{extras}\n" unless extras.blank?
87
+ code << "options[:content_for] ||= {}\n"
88
+ code << "#{var_name(:extras)} = ''\n"
89
+ extras.each do |name, ecode|
90
+ code << "if options[:content_for][:#{name}]\n"
91
+ code << " content_for(options[:content_for][:#{name}], (#{ecode}).html_safe)\n"
92
+ code << "else\n"
93
+ code << " #{var_name(:extras)} << #{ecode}\n"
94
+ code << "end\n"
95
+ end
96
+ code << "#{var_name(:content)} << content_tag(:div, (#{var_name(:extras)}).html_safe, class: 'list-control') unless #{var_name(:extras)}.blank?\n"
97
+ end
86
98
  code << "#{var_name(:content)} << '<div class=\"list-data\"><table class=\"list\""
87
99
  if table.paginate?
88
100
  code << " data-list-current-page=\"' + #{var_name(:page)}.to_s + '\" data-list-page-size=\"' + #{var_name(:limit)}.to_s + '\""
@@ -95,10 +107,10 @@ module ActiveList
95
107
  code << "end\n"
96
108
  code << "#{var_name(:content)} << #{var_name(:tbody)}\n"
97
109
  code << "#{var_name(:content)} << '</table></div>'\n"
98
- code << "return #{var_name(:content)}.html_safe if options[:only] == 'content'\n"
110
+ # code << "return #{var_name(:content)}.html_safe if options[:only] == 'content'\n"
99
111
 
100
112
  # Build whole
101
- code << "return ('<div id=\"#{table.name}\" data-list-source=\"'+h(url_for(options.merge(:action => '#{generator.controller_method_name}')))+'\" data-list-redirect=\"' + params[:redirect].to_s + '\" class=\"active-list\">' + #{var_name(:content)} + '</div>').html_safe\n"
113
+ code << "return ('<div id=\"#{self.uid}\" data-list-source=\"'+h(url_for(options.merge(:action => '#{generator.controller_method_name}')))+'\" data-list-redirect=\"' + params[:redirect].to_s + '\" class=\"active-list\">' + #{var_name(:content)} + '</div>').html_safe\n"
102
114
  return code
103
115
  end
104
116
 
@@ -221,7 +233,7 @@ module ActiveList
221
233
 
222
234
  # Produces main menu code
223
235
  def menu_code
224
- menu = "<span class=\"settings\">"
236
+ menu = "<span class=\"list-settings\" data-list-ref=\"#{self.uid}\">"
225
237
  menu << "<a class=\"settings-start\"><i></i>' + h('list.menu'.t) + '</a>"
226
238
  menu << "<ul>"
227
239
  if table.paginate?
@@ -279,49 +291,49 @@ module ActiveList
279
291
  end
280
292
 
281
293
  # Produces the code to create bottom menu and pagination
282
- def extras_code
294
+ def extras_codes
283
295
  code = []
284
296
 
297
+ codes = {}
285
298
  if table.global_action_columns.any?
286
- actioner = ""
287
- actioner << "<span class=\"actioner\">'"
299
+
300
+ actions = ""
301
+ actions << "<span class=\"list-actions\" data-list-ref=\"#{self.uid}\">'"
288
302
  for column in table.global_action_columns
289
- actioner << " + link_to(content_tag(:i) + h(' ' + :#{column.name.to_s}.t(scope: 'rest.actions')), #{column.default_url.inspect}, class: 'btn btn-#{column.name}'#{', style: "display: none"' unless column.use_none?}#{', method: "' + column.options[:method].to_s + '"' if column.options[:method]}, data: {list_actioner: :#{column.use_none? ? 'none' : 'many'}#{', confirm: :' + column.options[:confirm].to_s + '.t(scope: "labels")' if column.options[:confirm]}})"
303
+ actions << " + link_to(content_tag(:i) + h(' ' + :#{column.name.to_s}.t(scope: 'rest.actions')), #{column.default_url.inspect}, class: 'btn btn-#{column.name}'#{', style: "display: none"' unless column.use_none?}#{', method: "' + column.options[:method].to_s + '"' if column.options[:method]}, data: {list_actioner: :#{column.use_none? ? 'none' : 'many'}#{', confirm: :' + column.options[:confirm].to_s + '.t(scope: "labels")' if column.options[:confirm]}})"
290
304
  end
291
- actioner << " + '</span>"
292
- code << "'#{actioner}'"
305
+ actions << " + '</span>"
306
+ code << "'#{actions}'"
307
+
308
+ codes[:actions] = "'#{actions}'"
293
309
  end
294
310
 
295
311
  code << "'#{menu_code}'"
312
+ codes[:settings] = "'#{menu_code}'"
296
313
 
297
314
  if table.paginate?
298
315
  pagination = ""
299
316
  current_page = "#{var_name(:page)}"
300
317
  last_page = "#{var_name(:last)}"
301
318
 
302
- pagination << "<span class=\"pagination\">"
319
+ pagination << "<span class=\"list-pagination\" data-list-ref=\"#{self.uid}\">"
303
320
  pagination << "<span class=\"status\">' + 'list.pagination.x_to_y_of_total'.t(x: (#{var_name(:offset)} + (#{var_name(:count)} > 0 ? 1 : 0)), y: ((#{var_name(:last)} == #{var_name(:page)}) ? #{var_name(:count)} : #{var_name(:offset)} + #{var_name(:limit)}), total: #{var_name(:count)}) + '</span>"
304
321
 
305
322
  pagination << "<span class=\"paginator\">"
306
- # pagination << "<a href=\"#\" data-list-move-to-page=\"1\" class=\"btn first-page\"' + (#{current_page} != 1 ? '' : ' disabled=\"true\"') + '><i></i>' + ::I18n.translate('list.pagination.first') + '</a>"
307
323
  pagination << "<a href=\"#\" data-list-move-to-page=\"' + (#{current_page} - 1).to_s + '\" class=\"btn previous-page\"' + (#{current_page} != 1 ? '' : ' disabled=\"true\"') + '><i></i>' + ::I18n.translate('list.pagination.previous') + '</a>"
308
324
 
309
325
  x = '@@PAGE-NUMBER@@'
310
326
  y = '@@PAGE-COUNT@@'
311
- # pagination << "<span class=\"paginator\">'+::I18n.translate('list.page_x_on_y', :default => '%{x} / %{y}', :x => '#{x}', :y => '#{y}').html_safe.gsub('#{x}', ('<input type=\"number\" size=\"4\" data-list-move-to-page=\"value\" value=\"'+#{var_name(:page)}.to_s+'\">').html_safe).gsub('#{y}', #{var_name(:last)}.to_s) + '</span>"
312
- # pagination << "<input type=\"number\" size=\"4\" data-list-move-to-page=\"value\" value=\"' + #{var_name(:page)}.to_s + '\">"
313
327
 
314
328
  pagination << "<a href=\"#\" data-list-move-to-page=\"' + (#{current_page} + 1).to_s + '\" class=\"btn next-page\"' + (#{current_page} != #{last_page} ? '' : ' disabled=\"true\"') + '><i></i>' + ::I18n.translate('list.pagination.next')+'</a>"
315
- # pagination << "<a href=\"#\" data-list-move-to-page=\"' + (#{last_page}).to_s + '\" class=\"btn last-page\"' + (#{current_page} != #{last_page} ? '' : ' disabled=\"true\"') + '><i></i>' + ::I18n.translate('list.pagination.last')+'</a>"
316
329
  pagination << "</span>"
317
330
 
318
331
  pagination << "</span>"
319
332
 
320
- # pagination << "<span class=\"separator\"></span>"
321
-
322
-
323
333
  code << "'#{pagination}'"
334
+ codes[:pagination] = "'#{pagination}'"
324
335
  end
336
+ return codes
325
337
 
326
338
  unless code.empty?
327
339
  code = "content_tag(:div, (#{code.join(' + ')}).html_safe, class: 'list-control')"
@@ -330,6 +342,10 @@ module ActiveList
330
342
  return code
331
343
  end
332
344
 
345
+ def uid
346
+ "#{table.name}-list"
347
+ end
348
+
333
349
 
334
350
  # # Not used
335
351
  # def columns_definition_code
@@ -1,5 +1,5 @@
1
1
  module ActiveList
2
2
 
3
- VERSION = "6.4.2"
3
+ VERSION = "6.5.0"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,103 +1,103 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.4.2
4
+ version: 6.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brice Texier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-11 00:00:00.000000000 Z
11
+ date: 2015-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.2'
20
- - - <
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '5'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: '3.2'
30
- - - <
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: arel
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - '>='
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: 5.0.0
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - '>='
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: 5.0.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: code_string
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - '>='
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: 0.0.0
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - '>='
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: 0.0.0
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rubyzip
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - '>='
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '1.0'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - '>='
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '1.0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: i18n-complements
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - '>='
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - '>='
86
+ - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: sqlite3
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - '>='
93
+ - - ">="
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - '>='
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  description: Generates action methods to provide clean tables.
@@ -218,12 +218,12 @@ require_paths:
218
218
  - lib
219
219
  required_ruby_version: !ruby/object:Gem::Requirement
220
220
  requirements:
221
- - - '>='
221
+ - - ">="
222
222
  - !ruby/object:Gem::Version
223
223
  version: 1.9.3
224
224
  required_rubygems_version: !ruby/object:Gem::Requirement
225
225
  requirements:
226
- - - '>='
226
+ - - ">="
227
227
  - !ruby/object:Gem::Version
228
228
  version: '0'
229
229
  requirements: []