sunrise-cms 1.0.0.rc3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/app/assets/javascripts/sunrise/manage.js.coffee +20 -0
- data/app/assets/stylesheets/sunrise/customize.css +5 -0
- data/app/views/sunrise/manager/_field.html.erb +8 -0
- data/app/views/sunrise/manager/_nested_field.html.erb +6 -0
- data/lib/sunrise/config/field.rb +8 -2
- data/lib/sunrise/config/nested_field.rb +27 -0
- data/lib/sunrise/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2819a7488e62a5f523822bdca65a69cb2f5fd6e7
|
4
|
+
data.tar.gz: 0bec11e0682db1e225acc930db2c9d51ebfa4d5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86b59f3ff4fc1276e849d80e19afe0b5b03d54caf5c414fd2f06d2b4e5ce69900495b4f0e89a2b813cc4a889e6fd6d9a4a457798963fb80632cf68af38931b9c
|
7
|
+
data.tar.gz: 2bad669260567f6e11729ffeca563e55da0e5270ece2cfec22138a9d34e96e1e923fe893db96382820e2c82112aca271c09ea92795768ddae1d9da8aa56cfee8
|
data/README.md
CHANGED
@@ -99,6 +99,11 @@ class SunriseProduct < Sunrise::AbstractModel
|
|
99
99
|
field :total_stock, :html => { :style => 'width:100%;clear:both;' }
|
100
100
|
field :item_model_id, :collection => lambda { ItemModel.all }, :include_blank => false
|
101
101
|
end
|
102
|
+
|
103
|
+
nested_attributes :project_fields, multiply: true, sort: true do
|
104
|
+
field :name
|
105
|
+
field :value
|
106
|
+
end
|
102
107
|
|
103
108
|
field :picture, :as => :uploader
|
104
109
|
end
|
@@ -166,6 +166,26 @@ class Sunrise
|
|
166
166
|
|
167
167
|
$(link).closest("div.nested_item").hide()
|
168
168
|
|
169
|
+
initSortFields: (dom_id) ->
|
170
|
+
container = $(dom_id)
|
171
|
+
|
172
|
+
container.sortable
|
173
|
+
cursor: 'move'
|
174
|
+
handle: '.nested_input_handle'
|
175
|
+
items: '.nested_item'
|
176
|
+
opacity: 0.8
|
177
|
+
update: (event, ui) =>
|
178
|
+
this.updateSortField(event, ui)
|
179
|
+
|
180
|
+
container.disableSelection()
|
181
|
+
|
182
|
+
updateSortField: (event, ui) ->
|
183
|
+
element = $(ui.item)
|
184
|
+
container = element.parents('div.nested')
|
185
|
+
|
186
|
+
container.find(".nested_item").each (index, item) ->
|
187
|
+
$(item).find(".nested_input_sort").val(index)
|
188
|
+
|
169
189
|
$(document).ready ->
|
170
190
|
window['sunrise'] ?= new Sunrise(window.location.pathname)
|
171
191
|
window['sunrise'].setup()
|
@@ -14,6 +14,14 @@
|
|
14
14
|
<%= manage_add_child_link t('manage.buttons.add_nested_field'), form, field, {:partial=>"nested_field"} %>
|
15
15
|
</div>
|
16
16
|
<% end -%>
|
17
|
+
|
18
|
+
<% if field.sort? %>
|
19
|
+
<script type="text/javascript">
|
20
|
+
$(document).ready(function(){
|
21
|
+
window['sunrise'].initSortFields("#<%= field.dom_id %>");
|
22
|
+
});
|
23
|
+
</script>
|
24
|
+
<% end -%>
|
17
25
|
</div>
|
18
26
|
<% elsif field.association? -%>
|
19
27
|
<%= form.association field.name.to_sym, field.input_options.merge(options) %>
|
@@ -1,4 +1,10 @@
|
|
1
1
|
<div class="nested_item">
|
2
2
|
<%= manage_remove_child_link('', form, :class => "close-but") if field.multiply? %>
|
3
|
+
|
4
|
+
<% if field.sort? %>
|
5
|
+
<%= image_tag 'sunrise/tree_dnd1.png', :class => "nested_input_handle" %>
|
6
|
+
<%= form.hidden_field field.sort_column, :class => "nested_input_sort" if field.sort_hidden_field? %>
|
7
|
+
<% end -%>
|
8
|
+
|
3
9
|
<%= render :partial => 'field', :collection => field.fields, :locals => {:form => form} %>
|
4
10
|
</div>
|
data/lib/sunrise/config/field.rb
CHANGED
@@ -12,6 +12,8 @@ module Sunrise
|
|
12
12
|
attr_reader :unless_condition
|
13
13
|
|
14
14
|
def initialize(abstract_model, parent, options = {})
|
15
|
+
options = {:multiply => false, :sort => false}.merge(options)
|
16
|
+
|
15
17
|
super(abstract_model, parent, options)
|
16
18
|
|
17
19
|
# Build conditionals
|
@@ -36,7 +38,7 @@ module Sunrise
|
|
36
38
|
css << "grey-but" if input_options[:boolean]
|
37
39
|
css << "tags-edit" if association?
|
38
40
|
|
39
|
-
{:class => css}.merge(input_options[:html] || {})
|
41
|
+
{:class => css, :id => dom_id}.merge(input_options[:html] || {})
|
40
42
|
end
|
41
43
|
|
42
44
|
def association?
|
@@ -50,7 +52,11 @@ module Sunrise
|
|
50
52
|
def nested?
|
51
53
|
false
|
52
54
|
end
|
53
|
-
|
55
|
+
|
56
|
+
def dom_id
|
57
|
+
@dom_id ||= "#{name}_field"
|
58
|
+
end
|
59
|
+
|
54
60
|
protected
|
55
61
|
|
56
62
|
# Verifies that the conditionals for this field evaluate to true for the
|
@@ -22,6 +22,33 @@ module Sunrise
|
|
22
22
|
def multiply?
|
23
23
|
@config_options[:multiply] != false
|
24
24
|
end
|
25
|
+
|
26
|
+
def sort?
|
27
|
+
@config_options[:sort] != false
|
28
|
+
end
|
29
|
+
|
30
|
+
def sort_hidden_field?
|
31
|
+
sort? && sort_options[:hidden_field]
|
32
|
+
end
|
33
|
+
|
34
|
+
def sort_column
|
35
|
+
sort_options[:column]
|
36
|
+
end
|
37
|
+
|
38
|
+
def sort_options
|
39
|
+
@sort_options ||= build_sort_options
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
def build_sort_options
|
45
|
+
options = (@config_options[:sort].is_a?(Hash) ? @config_options[:sort] : {}).symbolize_keys
|
46
|
+
|
47
|
+
{
|
48
|
+
:column => :sort_order,
|
49
|
+
:hidden_field => true
|
50
|
+
}.merge(options)
|
51
|
+
end
|
25
52
|
end
|
26
53
|
end
|
27
54
|
end
|
data/lib/sunrise/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunrise-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Galeta
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -722,9 +722,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
722
722
|
version: '0'
|
723
723
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
724
724
|
requirements:
|
725
|
-
- - '
|
725
|
+
- - '>='
|
726
726
|
- !ruby/object:Gem::Version
|
727
|
-
version:
|
727
|
+
version: '0'
|
728
728
|
requirements: []
|
729
729
|
rubyforge_project: sunrise-cms
|
730
730
|
rubygems_version: 2.1.11
|