angular-table 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/angular-table/version.rb +1 -1
- data/vendor/assets/javascripts/angular-table.js.coffee +51 -40
- 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: 0300b2bec8da95a7c4f5bb5b8355f49dad326d18
|
4
|
+
data.tar.gz: 68aee2657f079eddb91d28480908c2f258b9032d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46a472c4ddb98017d75f3d3a8aa892f8c4db07edb7ae8c78fdf313ae78b3ef6df215513f7de83b714de8d937e419d8ff3367ed3393f4148dd0207ff378b45622
|
7
|
+
data.tar.gz: a2a270d4de0e8d5b8aa2a7807fef71a3faffcbd6df600c87bfe91c3680f06613ea3412105d1b6df4f6c0d7e631d58bea10a90a4bcc17ede1220e35ef288c13f7
|
@@ -23,41 +23,38 @@ angular.module("angular-table").service "attributeExtractor", () ->
|
|
23
23
|
angular.module("angular-table").directive "atTable", ["attributeExtractor", (attributeExtractor) ->
|
24
24
|
|
25
25
|
capitaliseFirstLetter = (string) ->
|
26
|
-
string.charAt(0).toUpperCase() + string.slice(1)
|
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
|
-
tr.append(th)
|
59
|
-
|
60
|
-
thead.append tr
|
26
|
+
if string then string.charAt(0).toUpperCase() + string.slice(1) else ""
|
27
|
+
|
28
|
+
|
29
|
+
constructHeader = (thead, tds) ->
|
30
|
+
tr = thead.find "tr"
|
31
|
+
existingThMarkup = {}
|
32
|
+
for th in tr.find "th"
|
33
|
+
th = angular.element(th)
|
34
|
+
existingThMarkup[th.attr("attribute")] = th.html()
|
35
|
+
|
36
|
+
tr.remove()
|
37
|
+
tr = angular.element("<tr></tr>")
|
38
|
+
|
39
|
+
for td in tds
|
40
|
+
td = angular.element(td)
|
41
|
+
attribute = attributeExtractor.extractAttribute(td)
|
42
|
+
th = angular.element("<th style='cursor: pointer;'></th>")
|
43
|
+
title = existingThMarkup[attribute] || capitaliseFirstLetter(attributeExtractor.extractTitle(td))
|
44
|
+
th.html("#{title}")
|
45
|
+
|
46
|
+
sortable = td[0].attributes.sortable || attributeExtractor.isSortable(td.attr("class"))
|
47
|
+
if sortable
|
48
|
+
th.attr("ng-click", "predicate = '#{attribute}'; descending = !descending;")
|
49
|
+
icon = angular.element("<i style='margin-left: 10px;'></i>")
|
50
|
+
icon.attr("ng-class", "getSortIcon('#{attribute}')")
|
51
|
+
th.append(icon)
|
52
|
+
|
53
|
+
width = attributeExtractor.extractWidth(td.attr("class"))
|
54
|
+
th.attr("width", width)
|
55
|
+
tr.append(th)
|
56
|
+
|
57
|
+
thead.append tr
|
61
58
|
|
62
59
|
validateInput = (attributes) ->
|
63
60
|
if attributes.pagination and attributes.list
|
@@ -72,8 +69,11 @@ angular.module("angular-table").directive "atTable", ["attributeExtractor", (att
|
|
72
69
|
tbody
|
73
70
|
|
74
71
|
|
72
|
+
orderByExpression = "| orderBy:predicate:descending"
|
73
|
+
limitToExpression = "| limitTo:fromPage() | limitTo:toPage()"
|
74
|
+
|
75
75
|
StandardSetup = (attributes) ->
|
76
|
-
@repeatString = "item in #{attributes.list}
|
76
|
+
@repeatString = "item in #{attributes.list} #{orderByExpression}"
|
77
77
|
@compile = (element, attributes, transclude) ->
|
78
78
|
setupTr element, @repeatString
|
79
79
|
|
@@ -81,7 +81,15 @@ angular.module("angular-table").directive "atTable", ["attributeExtractor", (att
|
|
81
81
|
return
|
82
82
|
|
83
83
|
PaginationSetup = (attributes) ->
|
84
|
-
|
84
|
+
|
85
|
+
sortContext = attributes.sortContext || "global"
|
86
|
+
|
87
|
+
if sortContext == "global"
|
88
|
+
@repeatString = "item in #{attributes.pagination}.list #{orderByExpression} #{limitToExpression}"
|
89
|
+
else if sortContext == "page"
|
90
|
+
@repeatString = "item in #{attributes.pagination}.list #{limitToExpression} #{orderByExpression} "
|
91
|
+
else
|
92
|
+
throw "Invalid sort-context: #{sortContext}."
|
85
93
|
|
86
94
|
@compile = (element, attributes, transclude) ->
|
87
95
|
tbody = setupTr element, @repeatString
|
@@ -90,7 +98,7 @@ angular.module("angular-table").directive "atTable", ["attributeExtractor", (att
|
|
90
98
|
tds = element.find("td")
|
91
99
|
tdString = ""
|
92
100
|
for td in tds
|
93
|
-
tdString += "<td
|
101
|
+
tdString += "<td> </td>"
|
94
102
|
|
95
103
|
fillerTr = angular.element("<tr>#{tdString}</tr>")
|
96
104
|
fillerTr.attr("ng-repeat", "item in #{attributes.pagination}.getFillerArray() ")
|
@@ -120,7 +128,11 @@ angular.module("angular-table").directive "atTable", ["attributeExtractor", (att
|
|
120
128
|
scope: true
|
121
129
|
compile: (element, attributes, transclude) ->
|
122
130
|
setup = createSetup attributes
|
123
|
-
|
131
|
+
|
132
|
+
thead = element.find "thead"
|
133
|
+
tds = element.find "td"
|
134
|
+
constructHeader(thead, tds) if thead[0]
|
135
|
+
|
124
136
|
setup.compile(element, attributes, transclude)
|
125
137
|
{
|
126
138
|
post: ($scope, $element, $attributes) ->
|
@@ -196,7 +208,6 @@ angular.module("angular-table").directive "atPagination", ["attributeExtractor",
|
|
196
208
|
else
|
197
209
|
[]
|
198
210
|
|
199
|
-
|
200
211
|
$scope.goToPage = (page) ->
|
201
212
|
page = Math.max(0, page)
|
202
213
|
page = Math.min($scope.numberOfPages - 1, page)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: angular-table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Mueller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|