scrivito_advanced_editors 0.0.7 → 0.0.8

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: 281329f4466cfb6f2d6445372103294be31a35af
4
- data.tar.gz: 75af3d9293b46a6d343e07da108108d8c0783888
3
+ metadata.gz: c8987ece4796972dad54d5cfb8a023c5b6896a79
4
+ data.tar.gz: 52afb057c120ce7d8440e99a2900061e74001059
5
5
  SHA512:
6
- metadata.gz: 986981d6e891775a2cf76464fc81989511a5f9a7f9d71343f82f27cd6afdc7107484024178160b3d1be323a418a6e62a35d08325a459603c76ad1643699005a8
7
- data.tar.gz: 17b6dc8d41af9936d4ea4643dd65439f08a555b5cc47bb27dba2795acd47b6400b13d4cc951ff0afe9341117c82db83cbf8b3a03e8d104dd11988ddf74786c28
6
+ metadata.gz: 8df9c7408cb4381463f0af49abd7ff65f2a73f3462bf52c37271a1503dd6c85623b5e2cd64b5b26ec15425c89cc592301d77fab2e8d0133ae51f9d8b23573c4a
7
+ data.tar.gz: c62225183df650bda205b17ff62dcce9263db22d27e419f70a271896929177ce0d1607a1c07564b1b1665da883257f0183f1a06538bf6a71e310e6ef73ee138d
@@ -0,0 +1,32 @@
1
+ $(function() {
2
+ return scrivito.on('content', function() {
3
+ var elements = $('.create_obj');
4
+
5
+ return elements.each(function(index, element) {
6
+ var elem = $(element);
7
+ var obj_class = elem.data('obj-class');
8
+ var obj_path = elem.data('obj-path');
9
+ var with_date = elem.data('with-date')
10
+
11
+ return elem.on('submit', function() {
12
+ var name = elem.find('input').val();
13
+ var now = new Date();
14
+ var isoDate = now.toISOString().replace(/[^0-9]/g, '');
15
+
16
+ var options = {
17
+ _obj_class: obj_class,
18
+ _path: (obj_path + "/") + isoDate,
19
+ title: name || (obj_class + "_" + isoDate)
20
+ }
21
+
22
+ if(with_date != "") {
23
+ jQuery.extend({with_date: now}, options)
24
+ }
25
+
26
+ return scrivito.create_obj(options).done(function(data) {
27
+ return $('body').trigger("scrivito_reload");
28
+ });
29
+ });
30
+ });
31
+ });
32
+ });
@@ -32,3 +32,9 @@
32
32
  .details-view abbr:after {
33
33
  content: "?";
34
34
  }
35
+
36
+ .details-view .alert {
37
+ margin: 0px -15px;
38
+ border: none;
39
+ border-radius: 0;
40
+ }
@@ -28,7 +28,7 @@ module ScrivitoAdvancedEditors
28
28
  end
29
29
 
30
30
  def enum_list(obj, attribute)
31
- Scrivito::ObjClass.find(obj.class.to_s).attributes[attribute].values
31
+ obj.attribute_definitions[attribute].values
32
32
  end
33
33
 
34
34
  def css_class(elem, active)
@@ -1,5 +1,5 @@
1
1
  <% if scrivito_in_editable_view? %>
2
- <form class="create_obj" data-obj-class="<%= obj_class %>" data-obj-path="<%= obj_path %>">
2
+ <form class="create_obj" data-with-date="<%= with_date %>" data-obj-class="<%= obj_class %>" data-obj-path="<%= obj_path %>">
3
3
  <input type="text" name="title" class="create_obj_name form-control" placeholder="Name for new obj (optional)">
4
4
  <button class="btn btn-primary">
5
5
  <%= "Create new #{obj_class}" %>
@@ -1,3 +1,3 @@
1
1
  module ScrivitoAdvancedEditors
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrivito_advanced_editors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scrivito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-25 00:00:00.000000000 Z
11
+ date: 2015-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -75,7 +75,7 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - LICENSE
77
77
  - Rakefile
78
- - app/assets/javascripts/scripts/create_obj.js.coffee
78
+ - app/assets/javascripts/scripts/create_obj.js
79
79
  - app/assets/javascripts/scripts/jquery.caret.min.js
80
80
  - app/assets/javascripts/scripts/jquery.tag-editor.min.js
81
81
  - app/assets/javascripts/scripts/scrivito_list_editor.js
@@ -1,24 +0,0 @@
1
- $ ->
2
- scrivito.on 'content', ->
3
- elements = $('.create_obj')
4
-
5
- elements.each (index, element) ->
6
- elem = $(element)
7
-
8
- obj_class = elem.data('obj-class')
9
- obj_path = elem.data('obj-path')
10
-
11
-
12
- elem.on 'submit', ->
13
- name = elem.find('input').val()
14
- now = new Date()
15
- isoDate = now.toISOString().replace(/[^0-9]/g, '')
16
-
17
- scrivito
18
- .create_obj
19
- _obj_class: obj_class
20
- _path: "#{obj_path}/" + isoDate
21
- title: name || "#{obj_class}_#{isoDate}"
22
- published_at: now
23
- .done (data) ->
24
- $('body').trigger("scrivito_reload")