cm_page_builder-rails 0.1.0 → 0.1.1
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b499190f1a37b5e7814f23963ed1a1e4c91206c5b318766a08e800b00dd1b8e
|
4
|
+
data.tar.gz: 9e5036922867ebe90b64df0f70145132be417949d38116564912a4b30e295709
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22fcd8aaf9960982c8b85327c7f57facd5a0e1b2abcf237677fa6523247cf6cb814b7b847cb99497455ffc2e24f72ccd426e50303baaeeff24dce1952b92a90b
|
7
|
+
data.tar.gz: 5a861d9187ef9ef9ef7ff73921880767d64e7dc4545b7335df91ad256c4e16fcd0ddb2312495bf905eeb686edb10cd57ab3c1dff384736df54e03e405fb896fc
|
data/README.md
CHANGED
@@ -21,6 +21,10 @@ Or install it yourself as:
|
|
21
21
|
$ gem install cm_page_builder-rails
|
22
22
|
```
|
23
23
|
|
24
|
+
### Setting up CORS for aws
|
25
|
+
Do this or the direct upload capabilities won't work
|
26
|
+
https://keithpblog.org/post/active-storage-on-amazon-s3/
|
27
|
+
|
24
28
|
## Contributing
|
25
29
|
Contribution directions go here.
|
26
30
|
|
@@ -5,19 +5,36 @@ module CmPageBuilder::Rails
|
|
5
5
|
|
6
6
|
accepts_nested_attributes_for :page_components, allow_destroy: true
|
7
7
|
|
8
|
+
def get_components
|
9
|
+
self.page_components.select(:id, :component_type, :position, :content).map do |component|
|
10
|
+
json_component = component.as_json.transform_keys! {|key| key.camelize(:lower)}
|
11
|
+
attachment = component.component_attachment.attachment
|
12
|
+
pp attachment
|
13
|
+
json_component["component_attachment"] = if attachment
|
14
|
+
{
|
15
|
+
filename: attachment.filename.to_s,
|
16
|
+
url: attachment.service_url
|
17
|
+
}
|
18
|
+
end
|
19
|
+
json_component
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
8
23
|
def save_content(component_json)
|
9
24
|
components = JSON.parse component_json
|
10
25
|
deleted_components = self.page_components.where.not(
|
11
26
|
id: components.map {|c| c["id"] } )
|
12
27
|
deleted_components.delete_all
|
13
28
|
components.each do |component|
|
14
|
-
self.page_components
|
15
|
-
|
16
|
-
.update!(
|
29
|
+
page_component = self.page_components.find_or_initialize_by(id: component["id"])
|
30
|
+
page_component.update!(
|
17
31
|
content: component["content"],
|
18
32
|
position: component["position"],
|
19
33
|
component_type: component["componentType"]
|
20
34
|
)
|
35
|
+
signed_id = component.dig("component_attachment", "signed_id")
|
36
|
+
page_component.component_attachment = signed_id if signed_id
|
37
|
+
page_component.save!
|
21
38
|
end
|
22
39
|
|
23
40
|
end
|
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
.field
|
10
10
|
input type='hidden' id="content-editor" name="page[components]"
|
11
|
-
- components = @page.
|
11
|
+
- components = @page.get_components
|
12
12
|
= react_component("cm_content_manager/Content", {input: "content-editor", components: components})
|
13
13
|
|
14
14
|
.actions = f.submit
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cm_page_builder-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camilo Ernesto Forero Junco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|