tomify 0.1.3 → 0.1.4

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: 34bf7184118f201d83d1ef89b98057bb1d41f53e
4
- data.tar.gz: ac949b2ec8b51179601e9ee09ae94902d41c590d
3
+ metadata.gz: d85803b12226321bb76440fc8efae058be5d9772
4
+ data.tar.gz: 3ce0217e98efeced7e3f22ff3abb980f308bfe67
5
5
  SHA512:
6
- metadata.gz: 3638b5741f85d2218f22ffcf61b52d4a211c2140e9e0623d3c104af6fcb780b4a4b8f0161678d227b3745bffece49b36c4a9eaf47efb0a9cd48f09fffdc212ea
7
- data.tar.gz: c2c8fb0eb2a8dfc5046aa1f74fefa24bf3b2ecfc52027fb9083656c4257fb8f709dfdc1367fe2822f5ce964ed268d0701e117d0d857713fce7ef01fdb9ce5d44
6
+ metadata.gz: 3d9363a21eefec8e5262e5361de0eb8f55fd9f53cb3648c7e1d100d7e10a0a5b08bbe525ad0ec5e59ee8a5ab5cf94878c7b4a66b20fc9495278a2c4946d5a3d9
7
+ data.tar.gz: 5d0bafb20a6461996c1f05fdd989c8e3e1f0d57192bc75439b1d488f9dfea2e6402e136415e178779d7b31b20a4902fd10b649199a18acd0568fc86f03b45b20
@@ -1,4 +1,6 @@
1
1
  Component.create "Index.Container",
2
+ getDefaultProps: -> { length: 5 }
3
+ getInitialState: -> { page: 1, currentRecords: [] }
2
4
  componentWillInitialize: ->
3
5
  @model = Model.findOrCreate @props.name
4
6
  @store = Store.findOrCreate "#{@props.name}.Index"
@@ -20,7 +22,9 @@ Component.create "Index.Container",
20
22
  modelDestroy: (response) ->
21
23
  @model.all() if response.type == "danger"
22
24
  setPage: (page) ->
23
- @setState(page: 1, currentRecords: @state.records[(page*10 - 10)..page*10])
25
+ finish = page * @props.length
26
+ start = finish - @props.length
27
+ @setState(page: page, currentRecords: @state.records[start...finish])
24
28
  actions: (record) ->
25
29
  actions = []
26
30
 
@@ -63,7 +67,7 @@ Component.create "Index.Container",
63
67
  <a className="btn btn-primary btn-xs" href="#" onClick={click}>New</a>
64
68
  }
65
69
  </h4>
66
- <Pagination page="1" total={@state.records.length} setPage={@setPage} />
70
+ <Pagination page={@state.page} total={@state.records.length} setPage={@setPage} length={@props.length} />
67
71
  </div>
68
72
  <div className="table-responsive">
69
73
  <table className="table table-bordered table-hover">
@@ -76,7 +80,7 @@ Component.create "Index.Container",
76
80
  </tr>
77
81
  </thead>
78
82
  <tbody>
79
- {for record, i in @state.records
83
+ {for record, i in @state.currentRecords
80
84
  <tr key={i}>
81
85
  {for field, j in @model.columns
82
86
  <td key={j}>{field.value?(record) ? record[field.name]}</td>
@@ -87,6 +91,10 @@ Component.create "Index.Container",
87
91
  </tbody>
88
92
  </table>
89
93
  </div>
94
+ <div className="panel-footer">
95
+ <Pagination page={@state.page} total={@state.records.length} setPage={@setPage} length={@props.length} />
96
+ <div className="clearfix" />
97
+ </div>
90
98
  </div>
91
99
  </div>
92
100
  </div>
@@ -1,29 +1,29 @@
1
1
  Component.create "Pagination",
2
2
  setPage: (page, e) ->
3
3
  e.preventDefault()
4
- @props.setPage(page)
4
+ @props.setPage(page) if page
5
5
  false
6
6
  render: ->
7
7
  first = 1
8
8
  prev = @props.page - 1
9
9
  next = @props.page + 1
10
- last = Math.ceil(@props.total / 10)
10
+ last = Math.ceil(@props.total / @props.length)
11
11
  prevDisabled = first > prev
12
12
  nextDisabled = next > last
13
13
  <ul className="pagination">
14
- <li className="pagination-first#{' disabled' if prevDisabled}">
15
- <a href="#" onClick={@setPage.bind(null, first)} className="fa fa-angle-double-left" />
14
+ <li className="pagination-first#{prevDisabled && ' disabled'}">
15
+ <a href="#" onClick={@setPage.bind(null, !prevDisabled && first)} className="fa fa-angle-double-left" />
16
16
  </li>
17
- <li className="pagination-prev#{' disabled' if prevDisabled}">
18
- <a href="#" onClick={@setPage.bind(null, prev)} className="fa fa-angle-left" />
17
+ <li className="pagination-prev#{prevDisabled && ' disabled'}">
18
+ <a href="#" onClick={@setPage.bind(null, !prevDisabled && prev)} className="fa fa-angle-left" />
19
19
  </li>
20
20
  <li className="pagination-link active">
21
21
  <a href="#" onClick={@setPage.bind(null, @props.page)}>{@props.page}</a>
22
22
  </li>
23
- <li className="pagination-next#{' disabled' if nextDisabled}">
24
- <a href="#" onClick={@setPage.bind(null, next)} className="fa fa-angle-right" />
23
+ <li className="pagination-next#{nextDisabled && ' disabled'}">
24
+ <a href="#" onClick={@setPage.bind(null, !nextDisabled && next)} className="fa fa-angle-right" />
25
25
  </li>
26
- <li className="pagination-last#{' disabled' if nextDisabled}">
27
- <a href="#" onClick={@setPage.bind(null, @props.total)} className="fa fa-angle-double-right" />
26
+ <li className="pagination-last#{nextDisabled && ' disabled'}">
27
+ <a href="#" onClick={@setPage.bind(null, !nextDisabled && last)} className="fa fa-angle-double-right" />
28
28
  </li>
29
29
  </ul>
@@ -23,7 +23,7 @@ Component.create "Public.Subscription",
23
23
  {if @state.subscription.active
24
24
  <div>
25
25
  <p>
26
- <strong>{@state.subscription.email}</strong> will be no longer recieve the majority of emails from {setting "name"}.
26
+ <strong>{@state.subscription.email}</strong> will no longer recieve the majority of emails from {setting "name"}.
27
27
  </p>
28
28
  <a href="#" onClick={@destroy} className="btn btn-danger" data-confirm="Are you sure?">Unsubscribe</a>
29
29
  </div>
@@ -32,7 +32,7 @@
32
32
  throw "Component: Invalid Store (#{value})" unless store?
33
33
  setupModels: ->
34
34
  @models = @convertToHash(@followModels?() || @followModels || [])
35
- for key, value of @models when not (value instanceof Store)
35
+ for key, value of @models when not (value instanceof Model)
36
36
  delete @models[key]
37
37
  store = @stores[key.camelize] = @store.findOrCreate value, []
38
38
  model = @models[key.camelize] = Model.findOrCreate(value)
@@ -1,5 +1,5 @@
1
1
  .pagination {
2
2
  float: right;
3
3
  margin-top: 2px;
4
- margin-bottom: 10px;
4
+ margin-bottom: 2px;
5
5
  }
@@ -1,3 +1,3 @@
1
1
  module Tomify
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tomify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Prats
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-16 00:00:00.000000000 Z
11
+ date: 2017-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails