diff --git a/Gemfile b/Gemfile index 8255fe451..e37ced927 100644 --- a/Gemfile +++ b/Gemfile @@ -193,3 +193,5 @@ gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" + +gem "avo-meta", github: "avo-hq/avo-meta", branch: "main" diff --git a/Gemfile.lock b/Gemfile.lock index e166bf0e3..5715c0b15 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,6 +5,15 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) +GIT + remote: https://github.com/avo-hq/avo-meta.git + revision: 874345836c3e686c2d716a0ae542caaad3aa8cab + branch: main + specs: + avo-meta (0.1.0) + avo (~> 3) + store_model (~> 4.1) + GIT remote: https://github.com/rails/rails.git revision: b88d9af34fbc1c84ce2769ba02584eab2c28ac6e @@ -180,7 +189,7 @@ GEM backport (1.2.0) base64 (0.2.0) bcrypt (3.1.20) - benchmark (0.3.0) + benchmark (0.4.0) benchmark-ips (2.14.0) better_html (2.1.1) actionview (>= 6.0) @@ -369,7 +378,7 @@ GEM activesupport (>= 3.0) nokogiri (>= 1.6) io-console (0.7.2) - irb (1.14.0) + irb (1.14.1) rdoc (>= 4.0.0) reline (>= 0.4.2) iso (0.4.0) @@ -392,7 +401,7 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) logger (1.6.1) - loofah (2.22.0) + loofah (2.23.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -410,8 +419,8 @@ GEM mini_histogram (0.3.1) mini_magick (4.13.2) mini_mime (1.1.5) - mini_portile2 (2.8.7) - minitest (5.25.1) + mini_portile2 (2.8.8) + minitest (5.25.2) monetize (1.13.0) money (~> 6.12) money (6.19.0) @@ -438,7 +447,7 @@ GEM nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) orm_adapter (0.5.0) - pagy (9.0.9) + pagy (9.3.1) parallel (1.26.3) parser (3.3.5.0) ast (~> 2.4.1) @@ -451,20 +460,19 @@ GEM prettier_print (1.2.1) prop_initializer (0.2.0) zeitwerk (>= 2.6.18) - psych (5.1.2) + psych (5.2.0) stringio public_suffix (6.0.1) puma (6.4.3) nio4r (~> 2.0) racc (1.8.1) - rack (3.1.7) + rack (3.1.8) rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rackup (2.1.0) + rackup (2.2.1) rack (>= 3) - webrick (~> 1.8) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -489,7 +497,7 @@ GEM rb-inotify (0.11.1) ffi (~> 1.0) rbs (2.8.4) - rdoc (6.7.0) + rdoc (6.8.1) psych (>= 4.0.0) redis (5.3.0) redis-client (>= 0.22.0) @@ -501,7 +509,7 @@ GEM rainbow (>= 2.0, < 4.0) rexml (~> 3.1) regexp_parser (2.9.2) - reline (0.5.10) + reline (0.5.11) io-console (~> 0.5) responders (3.1.1) actionpack (>= 5.2) @@ -567,7 +575,7 @@ GEM simplecov (>= 0.22.0) tty-which (~> 0.5.0) virtus (~> 2.0) - securerandom (0.3.1) + securerandom (0.3.2) sexp_processor (4.17.2) simplecov (0.22.0) docile (~> 1.1) @@ -621,7 +629,9 @@ GEM standard-performance (1.4.0) lint_roller (~> 1.1) rubocop-performance (~> 1.21.0) - stringio (3.1.1) + store_model (4.1.0) + activerecord (>= 7.0) + stringio (3.1.2) syntax_tree (6.2.0) prettier_print (>= 1.2.0) terminal-table (3.0.2) @@ -630,9 +640,9 @@ GEM thor (1.3.2) thread_safe (0.3.6) tilt (2.4.0) - timeout (0.4.1) + timeout (0.4.2) tty-which (0.5.0) - turbo-rails (2.0.10) + turbo-rails (2.0.11) actionpack (>= 6.0.0) railties (>= 6.0.0) turbo_power (0.6.2) @@ -641,10 +651,10 @@ GEM concurrent-ruby (~> 1.0) unaccent (0.4.0) unicode-display_width (2.6.0) - uri (0.13.1) + uri (1.0.2) useragent (0.16.10) - view_component (3.17.0) - activesupport (>= 5.2.0, < 8.0) + view_component (3.20.0) + activesupport (>= 5.2.0, < 8.1) concurrent-ruby (~> 1.0) method_source (~> 1.0) virtus (2.0.0) @@ -662,14 +672,14 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - webrick (1.8.2) + webrick (1.9.0) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) yard (0.9.37) - zeitwerk (2.6.18) + zeitwerk (2.7.1) PLATFORMS ruby @@ -687,6 +697,7 @@ DEPENDENCIES annotate appraisal avo! + avo-meta! avo-money_field avo-record_link_field aws-sdk-s3 diff --git a/spec/dummy/app/avo/resources/post.rb b/spec/dummy/app/avo/resources/post.rb index e99173b74..d5f3c4ab4 100644 --- a/spec/dummy/app/avo/resources/post.rb +++ b/spec/dummy/app/avo/resources/post.rb @@ -63,6 +63,8 @@ def fields # suggestions_max_items: 2, help: "The only allowed values here are `one`, `two`, and `three`" + meta_panel + field :cover_photo_attachment, as: :has_one field :comments, as: :has_many, use_resource: Avo::Resources::PhotoComment diff --git a/spec/dummy/app/avo/resources/user.rb b/spec/dummy/app/avo/resources/user.rb index cfb603cc6..91029e8c4 100644 --- a/spec/dummy/app/avo/resources/user.rb +++ b/spec/dummy/app/avo/resources/user.rb @@ -54,6 +54,8 @@ def fields user_information_panel + meta_panel + first_tabs_group second_tabs_group diff --git a/spec/dummy/app/models/post.rb b/spec/dummy/app/models/post.rb index 96b9b36a1..845f67a2a 100644 --- a/spec/dummy/app/models/post.rb +++ b/spec/dummy/app/models/post.rb @@ -14,6 +14,8 @@ # slug :string # class Post < ApplicationRecord + include Avo::Metaable + if Gem::Version.new(Rails.version) >= Gem::Version.new("7.3.0") enum :status, [:draft, :published, :archived] else diff --git a/spec/dummy/app/models/user.rb b/spec/dummy/app/models/user.rb index f57b85937..014d177d0 100644 --- a/spec/dummy/app/models/user.rb +++ b/spec/dummy/app/models/user.rb @@ -22,7 +22,9 @@ class User < ApplicationRecord ACCOUNT_STRUCT = Struct.new(:id, :name) unless const_defined?(:ACCOUNT_STRUCT) + include Avo::Metaable extend FriendlyId + # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable devise :database_authenticatable, :registerable, diff --git a/spec/dummy/config/routes.rb b/spec/dummy/config/routes.rb index 29dcb07d2..eb47b5e97 100644 --- a/spec/dummy/config/routes.rb +++ b/spec/dummy/config/routes.rb @@ -10,6 +10,7 @@ get "custom_tool", to: "avo/tools#custom_tool", as: :custom_tool end + mount Avo::Meta::Engine, at: "#{Avo.configuration.root_path}/avo_meta/" mount Avo::Engine, at: Avo.configuration.root_path # Uncomment to test constraints /123/en/admin # scope ":course", constraints: {course: /\w+(-\w+)*/} do diff --git a/spec/dummy/db/migrate/20241030100735_add_meta_to_users.rb b/spec/dummy/db/migrate/20241030100735_add_meta_to_users.rb new file mode 100644 index 000000000..fa0916768 --- /dev/null +++ b/spec/dummy/db/migrate/20241030100735_add_meta_to_users.rb @@ -0,0 +1,5 @@ +class AddMetaToUsers < ActiveRecord::Migration[8.0] + def change + add_column :users, :meta, :json + end +end diff --git a/spec/dummy/db/migrate/20241111104026_create_avo_meta_schemas.avo_meta.rb b/spec/dummy/db/migrate/20241111104026_create_avo_meta_schemas.avo_meta.rb new file mode 100644 index 000000000..068b0f0e5 --- /dev/null +++ b/spec/dummy/db/migrate/20241111104026_create_avo_meta_schemas.avo_meta.rb @@ -0,0 +1,13 @@ +# This migration comes from avo_meta (originally 20241111092303) +class CreateAvoMetaSchemas < ActiveRecord::Migration[7.2] + def change + create_table :avo_meta_schemas do |t| + t.string :resource_name + t.json :schema_entries + + t.timestamps + end + + add_index :avo_meta_schemas, :resource_name, unique: true + end +end diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb index 4dfeba42c..d1bb75e5b 100644 --- a/spec/dummy/db/schema.rb +++ b/spec/dummy/db/schema.rb @@ -12,7 +12,7 @@ ActiveRecord::Schema[8.0].define(version: 2024_11_14_165947) do # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" + enable_extension "pg_catalog.plpgsql" create_table "action_text_rich_texts", force: :cascade do |t| t.string "name", null: false @@ -52,6 +52,26 @@ t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true end + create_table "avo_meta_schemas", force: :cascade do |t| + t.string "resource_name" + t.json "schema_entries" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["resource_name"], name: "index_avo_meta_schemas_on_resource_name", unique: true + end + + create_table "avo_resources", force: :cascade do |t| + t.string "name", null: false + t.json "fields", null: false + t.json "includes" + t.json "attachments" + t.json "single_includes" + t.json "single_attachments" + t.json "meta", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "cities", force: :cascade do |t| t.string "name" t.integer "population" @@ -172,7 +192,7 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "price_cents", default: 0, null: false - t.string "price_currency", default: "'USD'::character varying", null: false + t.string "price_currency", default: "USD", null: false end create_table "projects", force: :cascade do |t| @@ -290,6 +310,7 @@ t.datetime "updated_at", null: false t.boolean "active", default: true t.string "slug" + t.json "meta" t.index ["email"], name: "index_users_on_email", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true t.index ["slug"], name: "index_users_on_slug", unique: true