maglevcms 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/maglev/fetchers_concern.rb +1 -0
- data/app/controllers/concerns/maglev/standalone_sections_concern.rb +6 -0
- data/app/frontend/editor/components/dynamic-form/dynamic-input.vue +1 -0
- data/app/frontend/editor/components/kit/collection-item-input.vue +5 -2
- data/app/frontend/editor/misc/utils.js +17 -0
- data/app/models/maglev/section/setting.rb +5 -0
- data/app/services/concerns/maglev/get_page_sections/transform_collection_item_concern.rb +1 -1
- data/app/services/maglev/fetch_collection_items.rb +6 -2
- data/db/migrate/20210830085101_create_maglev_page_paths.rb +1 -1
- data/db/migrate/20210906102712_add_canonical_to_pages.rb +1 -1
- data/db/migrate/20211008064437_add_locales_to_sites.rb +1 -1
- data/db/migrate/20211013210954_translate_section_content.rb +1 -1
- data/db/migrate/20211101205001_add_lock_version_to_maglev_pages.rb +1 -1
- data/db/migrate/20211116161121_better_page_path_canonical_indices.rb +1 -1
- data/db/migrate/20211124101005_fix_page_path_indices.rb +1 -1
- data/db/migrate/20211203224112_add_open_graph_tags_to_pages.rb +1 -1
- data/db/migrate/20220612092235_add_style_to_sites.rb +1 -1
- data/lib/generators/maglev/section_generator.rb +1 -0
- data/lib/generators/maglev/templates/section/app/theme/sections/%category%/%file_name%.yml.tt +4 -0
- data/lib/maglev/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6ebce98e16aca2b48cc0029e9c9168602b29f8bcd320261904c634b4d97132d
|
4
|
+
data.tar.gz: 463986303bb445fdc237f1089186055284ff29cb62773a878a7f4ae1d90ab7a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6d853c3d35076069a0ba22053b8828a8e837eabaf3c715e4ac9955ac2f38663cd6cad9d86b55f759b310633e564b19c8373d2fd06df8c3b6a05b2bb8eeaf026
|
7
|
+
data.tar.gz: f3e2b09342501025517ef5a11ce16f8e2f213fd1b99fb760312edf99b321220cf2e65ea73c3feabf12c6706f27b5dede2482adb0686d160537558334daa76cd7
|
@@ -15,6 +15,8 @@ module Maglev
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def fetch_maglev_site_scoped_sections
|
18
|
+
return if within_maglev_engine?
|
19
|
+
|
18
20
|
fetch_maglev_site
|
19
21
|
fetch_maglev_theme
|
20
22
|
fetch_maglev_dummy_page
|
@@ -24,5 +26,9 @@ module Maglev
|
|
24
26
|
def fetch_maglev_dummy_page
|
25
27
|
@fetch_maglev_page = ::Maglev::Page.new(title: 'DummyPage', sections: fetch_maglev_site.sections)
|
26
28
|
end
|
29
|
+
|
30
|
+
def within_maglev_engine?
|
31
|
+
controller_path.starts_with?('maglev/')
|
32
|
+
end
|
27
33
|
end
|
28
34
|
end
|
@@ -10,7 +10,7 @@
|
|
10
10
|
:searchEnabled="true"
|
11
11
|
:searchPlaceholder="$t(`collectionItemInput.select.searchPlaceholder`)"
|
12
12
|
:emptyLabel="$t(`collectionItemInput.select.emptyLabel`)"
|
13
|
-
:fetchList="(q) => services.collectionItem.findAll(
|
13
|
+
:fetchList="(q) => services.collectionItem.findAll(collectionId, { q })"
|
14
14
|
:clearEnabled="true"
|
15
15
|
buttonClass="h-10"
|
16
16
|
v-model="selectedCollectionItem"
|
@@ -42,18 +42,21 @@
|
|
42
42
|
</template>
|
43
43
|
|
44
44
|
<script>
|
45
|
+
import { camelizeKeys } from '@/misc/utils'
|
46
|
+
|
45
47
|
export default {
|
46
48
|
name: 'CollectionItemInput',
|
47
49
|
props: {
|
48
50
|
label: { type: String, default: 'Label' },
|
49
51
|
name: { type: String, default: 'image' },
|
50
52
|
value: { default: () => null },
|
53
|
+
collectionId: { type: String },
|
51
54
|
isFocused: { type: Boolean, default: false },
|
52
55
|
},
|
53
56
|
computed: {
|
54
57
|
selectedCollectionItem: {
|
55
58
|
get() {
|
56
|
-
return this.value
|
59
|
+
return camelizeKeys(this.value)
|
57
60
|
},
|
58
61
|
set(collectionItem) {
|
59
62
|
this.$emit('input', collectionItem ? { ...collectionItem } : null)
|
@@ -8,11 +8,28 @@ export const isBlank = (object) => {
|
|
8
8
|
}
|
9
9
|
|
10
10
|
export const camelize = (str) => {
|
11
|
+
if (!str.includes('_')) return str
|
11
12
|
return str
|
12
13
|
.toLowerCase()
|
13
14
|
.replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase())
|
14
15
|
}
|
15
16
|
|
17
|
+
export const camelizeKeys = (obj) => {
|
18
|
+
if (Array.isArray(obj)) {
|
19
|
+
return obj.map(v => camelizeKeys(v));
|
20
|
+
} else if (obj != null && obj.constructor === Object) {
|
21
|
+
return Object.keys(obj).reduce(
|
22
|
+
(result, key) => ({
|
23
|
+
...result,
|
24
|
+
[camelize(key)]: camelizeKeys(obj[key]),
|
25
|
+
}),
|
26
|
+
{},
|
27
|
+
);
|
28
|
+
}
|
29
|
+
return obj;
|
30
|
+
}
|
31
|
+
|
32
|
+
|
16
33
|
export const numberToHumanSize = (size, i18n) => {
|
17
34
|
if (isBlank(size)) return null
|
18
35
|
|
@@ -21,6 +21,7 @@ class Maglev::Section::Setting
|
|
21
21
|
when :image then build_default_image_content(default)
|
22
22
|
when :link then build_default_link_content(default)
|
23
23
|
when :checkbox then build_default_checkbox_content(default)
|
24
|
+
when :collection_item then build_default_collection_item_content(default)
|
24
25
|
else
|
25
26
|
default || label
|
26
27
|
end
|
@@ -42,6 +43,10 @@ class Maglev::Section::Setting
|
|
42
43
|
default.presence || false
|
43
44
|
end
|
44
45
|
|
46
|
+
def build_default_collection_item_content(default)
|
47
|
+
{ id: default }
|
48
|
+
end
|
49
|
+
|
45
50
|
## class methods ##
|
46
51
|
def self.build(hash)
|
47
52
|
attributes = hash.slice('id', 'label', 'type', 'default')
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# rubocop:disable Style/ClassAndModuleChildren
|
4
4
|
module Maglev::GetPageSections::TransformCollectionItemConcern
|
5
5
|
def transform_collection_item_content_setting(content, setting)
|
6
|
-
item_id = content
|
6
|
+
item_id = content&.dig('value', 'id')
|
7
7
|
return if item_id.blank?
|
8
8
|
|
9
9
|
item = fetch_collection_items.call(
|
@@ -33,7 +33,7 @@ module Maglev
|
|
33
33
|
|
34
34
|
def fetch_item
|
35
35
|
build_item(
|
36
|
-
fetch_original_items.find_by(id: id)
|
36
|
+
id == 'any' ? fetch_original_items.first : fetch_original_items.find_by(id: id)
|
37
37
|
)
|
38
38
|
end
|
39
39
|
|
@@ -78,7 +78,11 @@ module Maglev
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def collection
|
81
|
-
config.collections[collection_id.to_sym]
|
81
|
+
config.collections[collection_id.to_sym].tap do |collection|
|
82
|
+
next if collection
|
83
|
+
|
84
|
+
raise "[Maglev] unregistered '#{collection_id}' collection in the Maglev configuration."
|
85
|
+
end
|
82
86
|
end
|
83
87
|
|
84
88
|
def build_item(original_item)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddCanonicalToPages < ActiveRecord::Migration[6.
|
1
|
+
class AddCanonicalToPages < ActiveRecord::Migration[6.0]
|
2
2
|
def change
|
3
3
|
add_column :maglev_page_paths, :canonical, :boolean, null: true, default: true
|
4
4
|
add_index :maglev_page_paths, %i[canonical maglev_page_id locale], unique: true, name: 'canonical_uniqueness'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class BetterPagePathCanonicalIndices < ActiveRecord::Migration[6.
|
1
|
+
class BetterPagePathCanonicalIndices < ActiveRecord::Migration[6.0]
|
2
2
|
def change
|
3
3
|
remove_index :maglev_page_paths, [:value, :locale], unique: true
|
4
4
|
remove_index :maglev_page_paths, %i[canonical maglev_page_id locale], unique: true, name: 'canonical_uniqueness'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class FixPagePathIndices < ActiveRecord::Migration[6.
|
1
|
+
class FixPagePathIndices < ActiveRecord::Migration[6.0]
|
2
2
|
def change
|
3
3
|
remove_index :maglev_page_paths, %i[canonical maglev_page_id locale value], unique: true, name: 'canonical_uniqueness'
|
4
4
|
add_index :maglev_page_paths, %i[canonical maglev_page_id locale], name: 'scoped_canonical_speed'
|
data/lib/generators/maglev/templates/section/app/theme/sections/%category%/%file_name%.yml.tt
CHANGED
@@ -40,6 +40,8 @@ settings:
|
|
40
40
|
value: option_2
|
41
41
|
<%- when 'color' -%>
|
42
42
|
presets: ['#E5E7EB', '#FECACA', '#FDE68A', '#A7F3D0', '#BFDBFE']
|
43
|
+
<%- when 'collection_item' -%>
|
44
|
+
collection_id: products # check your config/initializers/maglev.rb to register your collection
|
43
45
|
<%- end -%>
|
44
46
|
<% if setting.value? -%>default: <%= setting.default %><% end -%>
|
45
47
|
|
@@ -69,6 +71,8 @@ blocks: <%- if blocks.blank? -%>[]
|
|
69
71
|
value: option_1
|
70
72
|
- label: Option 2
|
71
73
|
value: option_2
|
74
|
+
<%- when 'collection_item' -%>
|
75
|
+
collection_id: products # check your config/initializers/maglev.rb to register your collection
|
72
76
|
<%- end -%>
|
73
77
|
<%- if setting.value? -%>
|
74
78
|
default: <%= setting.default %>
|
data/lib/maglev/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maglevcms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Didier Lafforgue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11
|
11
|
+
date: 2022-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jbuilder
|