Skip to content

Commit 80dbfb5

Browse files
committed
feat: create the section repository model + update the persist_page service (WIP)
1 parent af8c63c commit 80dbfb5

File tree

5 files changed

+91
-0
lines changed

5 files changed

+91
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module Maglev
2+
class SectionRepository < ApplicationRecord
3+
## concerns ##
4+
include Maglev::Translatable
5+
include Maglev::SectionsConcern
6+
7+
## translations ##
8+
translates :sections
9+
10+
## validations ##
11+
validates :name, presence: true
12+
end
13+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class CreateMaglevSectionRepositories < ActiveRecord::Migration[8.0]
2+
def change
3+
create_table :maglev_section_repositories do |t|
4+
t.string :name
5+
6+
t.jsonb :sections_translations, default: {}
7+
8+
t.timestamps
9+
end
10+
end
11+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Name of the section displayed in the editor UI
2+
name: Ads
3+
4+
# Category of the section in the editor UI (header, features, testimonials, ...etc)
5+
category: features
6+
7+
scope: 'shoes' # will create a SectionRepository with the value as the name
8+
9+
# Definition of the settings:
10+
# A setting type can be one of the following values: text, image, checkbox, link and color.
11+
# Please visit: https://docs.maglev.dev/concepts/setting for more explanation.
12+
settings:
13+
- label: "Title"
14+
id: title
15+
type: text
16+
# html: true
17+
# line_break: true
18+
default: "My work"
19+
20+
# Definition of the blocks.
21+
# You can define as many types of blocks as you want.
22+
blocks: []
23+
24+
# By default, in the editor UI, blocks will be listed below the "Content" title.
25+
# The title can be changed with the following property:
26+
# blocks_label: "My list of items"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FactoryBot.define do
2+
factory :maglev_section_repository, class: 'Maglev::SectionRepository' do
3+
name { 'top_sidebar' }
4+
5+
trait :with_navbar do
6+
sections do
7+
[
8+
{
9+
type: 'navbar',
10+
id: 'yyy',
11+
settings: [
12+
{ id: :logo, value: 'mynewlogo.png' }
13+
],
14+
blocks: [
15+
{
16+
type: 'menu_item',
17+
id: 'zzz',
18+
settings: [
19+
{ id: 'label', value: 'Home' },
20+
{
21+
id: 'link',
22+
value: {
23+
link_type: 'url', open_new_window: true, href: 'https://www.nocoffee.fr'
24+
}
25+
}
26+
]
27+
}
28+
]
29+
}
30+
]
31+
end
32+
end
33+
end
34+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'rails_helper'
2+
3+
module Maglev
4+
RSpec.describe Maglev::SectionRepository, type: :model do
5+
pending "add some examples to (or delete) #{__FILE__}"
6+
end
7+
end

0 commit comments

Comments
 (0)