volt 0.5.1 → 0.5.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30b0c69987c064b09b40e3b87f548ebf79804b45
4
- data.tar.gz: fad83883f99c44fb884a32bf4b63c9f65f52b911
3
+ metadata.gz: c74190b05a5b42b727d604da7f629b80a6ebf3e4
4
+ data.tar.gz: ffa0259324ef491269df57363e032efe6af6faf6
5
5
  SHA512:
6
- metadata.gz: bb00336e8a30d6e3922e403149ffd621b098adff303d130b57cce654ce4464cbe922e540dc11eb47d072a9cf49d87130cad05a1fbdc6e973707e33349beabeda
7
- data.tar.gz: 9623ba45ae061ec34e326ce3a6311bed0308e5dcedb2cd022fd1257ee8a68a0e933609388859741146231eae209f1267237aaebae1b963ebd6333f3ffd2e49a9
6
+ metadata.gz: 86c8aeffbf38fc0493171e41af44740e99e42bc169d2402c555cb7c9f3ca24fd5d26a3b777d6c6553be2bc3b72838967ee6b7147b83455dbc612813fa58862d0
7
+ data.tar.gz: 6cffee5934e2017a8adaeddb03602d9af33e4356a72bb1957ed9bd6cdabfbb97c53f1e2f70cab6a72ca04d19f978a4e68e8e6c807f9ee1655414fdf6b0f1d3fa
data/Readme.md CHANGED
@@ -346,6 +346,7 @@ Above I mentioned that Volt comes with many default collection models accessable
346
346
  | store | store syncs the data to the backend database and provides query methods. |
347
347
  | session | values will be stored in a session cookie. |
348
348
  | params | values will be stored in the params and url. Routes can be setup to change how params are shown in the url. (See routes for more info) |
349
+ | flash | any strings assigned will be shown at the top of the page and cleared as the user navigates between pages. |
349
350
  | controller| a model for the current controller |
350
351
 
351
352
  **more storage locations are planned**
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
@@ -1,7 +1,7 @@
1
1
  .notices {
2
- position: absolute;
2
+ position: fixed;
3
3
  width: 600px;
4
- top: 0px;
4
+ top: 3px;
5
5
  margin-left: -300px;
6
6
  left: 50%;
7
7
  z-index: 1000;
@@ -2,10 +2,15 @@
2
2
  {#if page._reloading}
3
3
  <div class="notices alert alert-info">Reloading...</div>
4
4
  {/}
5
- {#if channel.status == :closed}
5
+ {#if !channel.connected?}
6
6
  <div class="notices alert alert-info">
7
7
  Connection Lost... {channel.error}...
8
8
  {#if channel.reconnect_interval} Reconnecting in {(channel.reconnect_interval / 1000.0).round} sec{/}
9
9
  </div>
10
10
  {/}
11
+ {#if !flash.empty?}
12
+ <div class="notices alert alert-info">
13
+ <p>{flash._notice}</p>
14
+ </div>
15
+ {/}
11
16
  </:body>
@@ -38,6 +38,10 @@ class ModelController
38
38
  $page.store
39
39
  end
40
40
 
41
+ def flash
42
+ $page.flash
43
+ end
44
+
41
45
  def params
42
46
  $page.params
43
47
  end
@@ -84,6 +84,20 @@ class Model
84
84
  @persistor.removed(args[0]) if @persistor
85
85
  end
86
86
 
87
+ tag_method(:clear) do
88
+ destructive!
89
+ end
90
+ def clear
91
+ attributes.each_pair do |key,value|
92
+ __clear_element(key)
93
+ end
94
+
95
+ attributes.clear
96
+ trigger!('changed')
97
+
98
+ @persistor.removed(nil) if @persistor
99
+ end
100
+
87
101
  tag_all_methods do
88
102
  pass_reactive! do |method_name|
89
103
  method_name[0] == '_' && method_name[-1] == '='
@@ -32,7 +32,7 @@ require 'volt/page/draw_cycle'
32
32
  require 'volt/page/tasks'
33
33
 
34
34
  class Page
35
- attr_reader :url, :params, :page, :store, :templates, :routes, :draw_cycle
35
+ attr_reader :url, :params, :page, :store, :flash, :templates, :routes, :draw_cycle
36
36
 
37
37
  def initialize
38
38
 
@@ -42,6 +42,7 @@ class Page
42
42
 
43
43
  # Run the code to setup the page
44
44
  @page = ReactiveValue.new(Model.new)
45
+ @flash = ReactiveValue.new(Model.new)
45
46
  @store = ReactiveValue.new(Model.new({}, persistor: Persistors::StoreFactory.new(tasks)))
46
47
 
47
48
  @url = ReactiveValue.new(URL.new)
@@ -83,6 +84,9 @@ class Page
83
84
  host = `document.location.host`
84
85
  @url.parse("http://#{host}" + url)
85
86
  end
87
+
88
+ # Clear the flash
89
+ flash.clear
86
90
  end
87
91
 
88
92
  # We provide a binding_name, so we can bind events on the document
@@ -62,7 +62,7 @@ class ReactiveValue < BasicObject
62
62
  if last_char == '=' && method_name[-2] != '='
63
63
  # Method is an assignment (and not a comparator ==)
64
64
  return true
65
- elsif last_char == '!' || last_char == '<'
65
+ elsif method_name.size > 1 && last_char == '!' || last_char == '<'
66
66
  # Method is tagged as destructive, or is a push ( << )
67
67
  return true
68
68
  elsif ::DestructiveMethods.might_be_destructive?(method_name)
@@ -3,8 +3,6 @@
3
3
  </:title>
4
4
 
5
5
  <:body>
6
- <:volt:notices />
7
-
8
6
  <div class="container">
9
7
  <div class="header">
10
8
  <ul class="nav nav-pills pull-right">
@@ -14,6 +12,8 @@
14
12
  <h3 class="text-muted">Project name</h3>
15
13
  </div>
16
14
 
15
+ <:volt:notices />
16
+
17
17
  {#template params._view.or('home')}
18
18
 
19
19
  <div class="footer">
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Stout