rails_admin_json_editor 0.0.13 → 0.0.14

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: 044a05b13bf7ef1de3de2554c352b192643acaef
4
- data.tar.gz: 26ccfa525f5dca5e3f1d2a06bc80599c03212bf7
3
+ metadata.gz: 0aa4afd9f01c476433ebae3221d370a416dc649e
4
+ data.tar.gz: 5dad5a0d49dfc8a562b5681dc8d07a4b351651be
5
5
  SHA512:
6
- metadata.gz: 5ce78613ba4364d1212970ffc8e633d16a69c7736333cf965de72272551025c6cb7fa941a2c5f6f1e699cfc707502e7d688c50ab1b20906d3e837dc65899bfdb
7
- data.tar.gz: 166f73977a13fe90d85cfe0ddcd5ee1097cdab5ca05a582e78028aaec2d4b9676ea8dc695153eee30a4d26ba2c6efc46e1e949182d24d64a530fd0b79733c0e0
6
+ metadata.gz: 547b6cc3da9459664881963d7941c0ee704c4b1cc4a29debfae5b4f4f58d044f96b3f3ffe6da3dedb3c6de09723c87c314e3b000f7368a9524a7ebebda2b74a4
7
+ data.tar.gz: f7ea15755b4baa12c8923a38f79b17dd8e97457f83c2fe3e47094f8dc9cc74537b6fefbf4338e221bc7e8743722a03524d08ff452e390210ddd0ef191997042a
@@ -16,7 +16,7 @@ $(document).on('rails_admin.dom_ready', function() {
16
16
  }
17
17
 
18
18
  Vue.filter('markdown', function(value) {
19
- return markdown.toHTML(value);
19
+ return value ? markdown.toHTML(value) : '';
20
20
  });
21
21
 
22
22
  // Setup templates for models
@@ -65,13 +65,17 @@
65
65
  <input type="checkbox" v-model="component.properties.<%= f.name %>" class="form-control">
66
66
  <% end %>
67
67
 
68
+ <% if f.type == :enum %>
69
+ <%= select_tag(nil, options_for_select(f.enum_options), include_blank: true, class: "form-control", "v-model" => "component.properties.#{f.name}") %>
70
+ <% end %>
71
+
68
72
  <% if f.type == :picker %>
69
73
  <select v-on="change: onChangePicker($event, '<%= f.name %>')" class="form-control record-picker">
70
74
  <option value=""></option>
71
75
  <%
72
- records = Rails.cache.fetch("record-picker-#{f.picker_model_name}") {
76
+ records = Rails.cache.fetch("record-picker-#{f.picker_model_name}") do
73
77
  f.picker_model_name.constantize.send(:all)
74
- }
78
+ end
75
79
  %>
76
80
  <% records.each do |record| %>
77
81
  <option
@@ -92,32 +96,34 @@
92
96
  </div>
93
97
  </div>
94
98
 
95
- <!-- Add nested component -- one model allowed -->
96
- <% if f.list_model_names.count == 1 %>
97
- <a href="#"
98
- class="btn btn-info"
99
- v-repeat="model: $root.scheme.models"
100
- v-show="nestedModelIsAllowed(model, <%= f.list_model_names %>)"
101
- v-on="click: addComponent($event, '<%= f.name %>', model)">
102
- Add {{ model.label | lowercase }}
103
- </a>
104
- <% end %>
105
-
106
- <!-- Add nested component -- multiple models allowed -->
107
- <% if f.list_model_names.count > 1 %>
108
- <div class="dropdown">
109
- <a class="dropdown-toggle btn btn-info" data-toggle="dropdown" href="#">Add component <b class="caret"></b></a>
110
- <ul class="dropdown-menu">
111
- <li v-repeat="model: $root.scheme.models">
112
- <a href="#"
113
- v-if="nestedModelIsAllowed(model, <%= f.list_model_names %>)"
114
- v-on="click: addComponent($event, '<%= f.name %>', model)">
115
- {{ model.label }}
116
- </a>
117
- </li>
118
- </ul>
119
- </div>
120
- <% end %>
99
+ <div v-show="!component.properties.<%= f.name %> || component.properties.<%= f.name %>.length < <%= f.list_max_length.nil? ? 999999 : f.list_max_length %>">
100
+ <!-- Add nested component -- one model allowed -->
101
+ <% if f.list_model_names.count == 1 %>
102
+ <a href="#"
103
+ class="btn btn-info"
104
+ v-repeat="model: $root.scheme.models"
105
+ v-show="nestedModelIsAllowed(model, <%= f.list_model_names %>)"
106
+ v-on="click: addComponent($event, '<%= f.name %>', model)">
107
+ Add {{ model.label | lowercase }}
108
+ </a>
109
+ <% end %>
110
+
111
+ <!-- Add nested component -- multiple models allowed -->
112
+ <% if f.list_model_names.count > 1 %>
113
+ <div class="dropdown">
114
+ <a class="dropdown-toggle btn btn-info" data-toggle="dropdown" href="#">Add component <b class="caret"></b></a>
115
+ <ul class="dropdown-menu">
116
+ <li v-repeat="model: $root.scheme.models">
117
+ <a href="#"
118
+ v-if="nestedModelIsAllowed(model, <%= f.list_model_names %>)"
119
+ v-on="click: addComponent($event, '<%= f.name %>', model)">
120
+ {{ model.label }}
121
+ </a>
122
+ </li>
123
+ </ul>
124
+ </div>
125
+ <% end %>
126
+ </div>
121
127
  <% end %>
122
128
 
123
129
  <%= content_tag :p, f.help, class: "help-block" unless f.help.nil? %>
@@ -74,7 +74,10 @@ module RailsAdmin
74
74
  attr_accessor :picker_label,
75
75
  :picker_model_name
76
76
 
77
- attr_accessor :list_model_names
77
+ attr_accessor :list_model_names,
78
+ :list_max_length
79
+
80
+ attr_accessor :enum_options
78
81
 
79
82
  def initialize(name, type, options = {})
80
83
  @name = name
@@ -99,8 +102,13 @@ module RailsAdmin
99
102
  @picker_model_name = options[:model].name
100
103
  end
101
104
 
102
- def list(models)
105
+ def list(models, options = {})
103
106
  @list_model_names = Array(models).map { |m| m.name.gsub("::","___") }
107
+ @list_max_length = options[:max_length]
108
+ end
109
+
110
+ def enum(options)
111
+ @enum_options = options
104
112
  end
105
113
  end
106
114
  end
@@ -1,3 +1,3 @@
1
1
  module RailsAdminJsonEditor
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_json_editor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jasper Haggenburg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-30 00:00:00.000000000 Z
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler