cm_page_builder-rails 0.1.2 → 0.1.3
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0502276d651000f9403732368e1f91f776620506e5f33e661038ea021cc6d098
|
4
|
+
data.tar.gz: 69e14401f555d7cf169a1a98ffd5e4e182d9deb7e07e7277cfa24738f2ec8fce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1fb86f34c7c2d029047beede39dab80462a8ea6296f47abf958c7f8179bbd8a52e359c61fb520e4c2d2c97e44f8f495e811afe58927026cf47fba42aeacd1ab
|
7
|
+
data.tar.gz: 5f5b17a4bc9ccf015bb67d59ddd7930e8adaa96c2536516bb4f9b262b45586566ae522ea765bc5ead2a3d826ac76e71d64bf6164c69a9237a18bcdb3c13d3544
|
data/README.md
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# CmPageBuilder::Rails
|
2
|
-
|
2
|
+
This gem's purpose is to allow easy integration between the Commutatus react package cm-page-builder and any rails applications created by
|
3
3
|
|
4
4
|
## Usage
|
5
|
-
|
5
|
+
To activate this module, add `include CmPageBuilder::Rails::HasCmContent` on top of any model file that should have an associated rich text field.
|
6
6
|
|
7
7
|
## Installation
|
8
|
-
|
8
|
+
|
9
9
|
|
10
10
|
```ruby
|
11
|
+
gem 'react-rails', '~> 2.6.0'
|
11
12
|
gem 'cm_page_builder-rails'
|
12
13
|
```
|
13
14
|
|
@@ -16,10 +17,11 @@ And then execute:
|
|
16
17
|
$ bundle
|
17
18
|
```
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
Follow all react-rails installation instructions
|
21
|
+
|
22
|
+
Then run `rails cm_page_builder_rails:install:migrations`
|
23
|
+
|
24
|
+
In `config/routes.rb`, mount the endpoint with the line `mount CmPageBuilder::Rails::Engine => "/cm_page_builder"`
|
23
25
|
|
24
26
|
### Setting up CORS for aws
|
25
27
|
Do this or the direct upload capabilities won't work
|
@@ -6,10 +6,13 @@ module CmPageBuilder::Rails
|
|
6
6
|
accepts_nested_attributes_for :page_components, allow_destroy: true
|
7
7
|
|
8
8
|
def get_components
|
9
|
-
self.page_components.select(:id, :component_type, :position, :content).map do |component|
|
9
|
+
self.page_components.with_attached_component_attachment.select(:id, :uuid, :component_type, :position, :content).map do |component|
|
10
10
|
json_component = component.as_json.transform_keys! {|key| key.camelize(:lower)}
|
11
11
|
attachment = component.component_attachment.attachment
|
12
|
+
pp component.component_attachment
|
12
13
|
pp attachment
|
14
|
+
pp "======"
|
15
|
+
json_component["id"] = component[:uuid]
|
13
16
|
json_component["component_attachment"] = if attachment
|
14
17
|
{
|
15
18
|
filename: attachment.filename.to_s,
|
@@ -23,18 +26,18 @@ module CmPageBuilder::Rails
|
|
23
26
|
def save_content(component_json)
|
24
27
|
components = JSON.parse component_json
|
25
28
|
deleted_components = self.page_components.where.not(
|
26
|
-
|
29
|
+
uuid: components.map {|c| c["id"] } )
|
27
30
|
deleted_components.delete_all
|
28
31
|
components.each do |component|
|
29
|
-
page_component = self.page_components.find_or_initialize_by(
|
30
|
-
page_component.update!(
|
31
|
-
content: component["content"],
|
32
|
-
position: component["position"],
|
33
|
-
component_type: component["componentType"]
|
34
|
-
)
|
32
|
+
page_component = self.page_components.find_or_initialize_by(uuid: component["id"])
|
35
33
|
signed_id = component.dig("component_attachment", "signed_id")
|
36
|
-
|
37
|
-
|
34
|
+
component_data = {
|
35
|
+
content: component["content"],
|
36
|
+
position: component["position"],
|
37
|
+
component_type: component["componentType"]
|
38
|
+
}
|
39
|
+
component_data[:component_attachment] = signed_id if signed_id
|
40
|
+
page_component.update!(component_data)
|
38
41
|
end
|
39
42
|
|
40
43
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class ChangePageComponentPrimaryKey < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
rename_column :cm_page_builder_rails_page_components, :id, :uuid
|
4
|
+
CmPageBuilder::Rails::PageComponent.connection.execute(
|
5
|
+
<<~SQL
|
6
|
+
ALTER TABLE cm_page_builder_rails_page_components DROP CONSTRAINT cm_page_builder_rails_page_components_pkey;
|
7
|
+
SQL
|
8
|
+
)
|
9
|
+
add_column :cm_page_builder_rails_page_components, :id, :primary_key
|
10
|
+
end
|
11
|
+
end
|
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.3
|
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-
|
11
|
+
date: 2019-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- config/routes.rb
|
94
94
|
- db/migrate/20190816103148_create_cm_page_builder_rails_pages.rb
|
95
95
|
- db/migrate/20190816105056_create_cm_page_builder_rails_page_components.rb
|
96
|
+
- db/migrate/20190903110322_change_page_component_primary_key.rb
|
96
97
|
- lib/cm_page_builder/rails.rb
|
97
98
|
- lib/cm_page_builder/rails/application_helper.rb
|
98
99
|
- lib/cm_page_builder/rails/engine.rb
|