cortex 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.babelrc +18 -0
- data/.codeclimate.yml +43 -0
- data/.csslintrc +2 -0
- data/.editorconfig +9 -0
- data/.eslintignore +1 -0
- data/.eslintrc.yml +277 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +47 -0
- data/.gitignore +82 -0
- data/.npmignore +34 -0
- data/.postcssrc.yml +3 -0
- data/.rspec +3 -0
- data/.rubocop.yml +1156 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/CONTRIBUTING.md +58 -0
- data/Gemfile +101 -0
- data/Gemfile.lock +604 -0
- data/Guardfile +23 -0
- data/LICENSE.md +201 -0
- data/README.md +239 -0
- data/Rakefile +22 -0
- data/app/assets/config/cortex_manifest.js +4 -0
- data/app/assets/fonts/cortex/Montserrat-Light.otf +0 -0
- data/app/assets/fonts/cortex/Montserrat-Medium.otf +0 -0
- data/app/assets/fonts/cortex/Montserrat-Regular.otf +0 -0
- data/app/assets/fonts/cortex/Montserrat-SemiBold.otf +0 -0
- data/app/assets/images/cortex/favicon.ico +0 -0
- data/app/assets/images/cortex/icons/add.svg +59 -0
- data/app/assets/images/cortex/icons/blog.png +0 -0
- data/app/assets/images/cortex/icons/media.png +0 -0
- data/app/assets/images/cortex/logo.svg +43 -0
- data/app/assets/javascripts/cortex/application.js +17 -0
- data/app/assets/javascripts/cortex/authentication.js +6 -0
- data/app/assets/javascripts/cortex/base.js +6 -0
- data/app/assets/javascripts/cortex/datepicker_init.js +29 -0
- data/app/assets/javascripts/cortex/flash.js +7 -0
- data/app/assets/javascripts/cortex/form.js +6 -0
- data/app/assets/javascripts/cortex/media_dialogs.js +40 -0
- data/app/assets/javascripts/cortex/quick_links.js +13 -0
- data/app/assets/stylesheets/cortex/application.scss +34 -0
- data/app/assets/stylesheets/cortex/authentication.scss +34 -0
- data/app/assets/stylesheets/cortex/base.scss +4 -0
- data/app/assets/stylesheets/cortex/bootstrap-namespaced.scss +57 -0
- data/app/assets/stylesheets/cortex/components/card.scss +9 -0
- data/app/assets/stylesheets/cortex/components/dialog.scss +67 -0
- data/app/assets/stylesheets/cortex/components/flash.scss +60 -0
- data/app/assets/stylesheets/cortex/components/form.scss +45 -0
- data/app/assets/stylesheets/cortex/components/header.scss +53 -0
- data/app/assets/stylesheets/cortex/components/index.scss +28 -0
- data/app/assets/stylesheets/cortex/components/jumbo-button.scss +41 -0
- data/app/assets/stylesheets/cortex/components/loaders.scss +76 -0
- data/app/assets/stylesheets/cortex/components/notes.scss +26 -0
- data/app/assets/stylesheets/cortex/components/sidebar.scss +120 -0
- data/app/assets/stylesheets/cortex/components/table.scss +7 -0
- data/app/assets/stylesheets/cortex/components/tenant-switcher.scss +209 -0
- data/app/assets/stylesheets/cortex/components/ui.scss +119 -0
- data/app/assets/stylesheets/cortex/demo.scss +140 -0
- data/app/assets/stylesheets/cortex/directives/aspect-ratio.scss +9 -0
- data/app/assets/stylesheets/cortex/helpers.scss +1701 -0
- data/app/assets/stylesheets/cortex/layout.scss +21 -0
- data/app/assets/stylesheets/cortex/material-icons.scss +13 -0
- data/app/assets/stylesheets/cortex/variables/_colors.scss +46 -0
- data/app/assets/stylesheets/cortex/variables/_material-overrides.scss +1 -0
- data/app/assets/stylesheets/cortex/variables/_typography.scss +114 -0
- data/app/cells/cortex/application_cell.rb +8 -0
- data/app/cells/cortex/content_type/nav.haml +5 -0
- data/app/cells/cortex/content_type_cell.rb +10 -0
- data/app/cells/cortex/field_cell.rb +35 -0
- data/app/cells/cortex/index/content_item/column.haml +4 -0
- data/app/cells/cortex/index/content_item_cell.rb +37 -0
- data/app/cells/cortex/index/index.haml +5 -0
- data/app/cells/cortex/index/table_body.haml +11 -0
- data/app/cells/cortex/index/table_headers.haml +5 -0
- data/app/cells/cortex/index_cell.rb +53 -0
- data/app/cells/cortex/wizard/column/show.haml +10 -0
- data/app/cells/cortex/wizard/column_cell.rb +21 -0
- data/app/cells/cortex/wizard/field/show.haml +30 -0
- data/app/cells/cortex/wizard/field_cell.rb +29 -0
- data/app/cells/cortex/wizard/plugin/show.haml +1 -0
- data/app/cells/cortex/wizard/plugin_cell.rb +28 -0
- data/app/cells/cortex/wizard/show.haml +1 -0
- data/app/cells/cortex/wizard/step/show.haml +2 -0
- data/app/cells/cortex/wizard/step_cell.rb +17 -0
- data/app/cells/cortex/wizard_cell.rb +15 -0
- data/app/containers/cortex/transaction_container.rb +23 -0
- data/app/controllers/concerns/cortex/decoratable.rb +16 -0
- data/app/controllers/cortex/admin_controller.rb +7 -0
- data/app/controllers/cortex/application_controller.rb +19 -0
- data/app/controllers/cortex/authentication/passwords_controller.rb +3 -0
- data/app/controllers/cortex/authentication/sessions_controller.rb +3 -0
- data/app/controllers/cortex/content_items_controller.rb +75 -0
- data/app/controllers/cortex/content_types_controller.rb +19 -0
- data/app/controllers/cortex/dashboards_controller.rb +7 -0
- data/app/controllers/cortex/graphql_controller.rb +40 -0
- data/app/controllers/cortex/tenants_controller.rb +12 -0
- data/app/devise/cortex/authentication_failure.rb +12 -0
- data/app/graphql/cortex/cortex_schema.rb +8 -0
- data/app/graphql/cortex/interfaces/.keep +0 -0
- data/app/graphql/cortex/mutations/.keep +0 -0
- data/app/graphql/cortex/types/content_item_type.rb +31 -0
- data/app/graphql/cortex/types/content_type_type.rb +23 -0
- data/app/graphql/cortex/types/contract_type.rb +10 -0
- data/app/graphql/cortex/types/date_time_type.rb +8 -0
- data/app/graphql/cortex/types/field_item_type.rb +15 -0
- data/app/graphql/cortex/types/field_type.rb +18 -0
- data/app/graphql/cortex/types/mutation_type.rb +5 -0
- data/app/graphql/cortex/types/query_type.rb +45 -0
- data/app/graphql/cortex/types/tenant_type.rb +19 -0
- data/app/graphql/cortex/types/user_type.rb +20 -0
- data/app/helpers/cortex/application_helper.rb +75 -0
- data/app/helpers/cortex/cells/association_helper.rb +25 -0
- data/app/helpers/cortex/content_item_helper.rb +106 -0
- data/app/helpers/cortex/dashboard_helper.rb +19 -0
- data/app/helpers/cortex/popup_helper.rb +27 -0
- data/app/jobs/cortex/application_job.rb +4 -0
- data/app/mailers/cortex/application_mailer.rb +6 -0
- data/app/mailers/cortex/password_reset_mailer.rb +13 -0
- data/app/models/concerns/cortex/belongs_to_tenant.rb +13 -0
- data/app/models/concerns/cortex/has_firstname_lastname.rb +11 -0
- data/app/models/concerns/cortex/has_gravatar.rb +18 -0
- data/app/models/concerns/cortex/searchable.rb +11 -0
- data/app/models/concerns/cortex/searchable_content_item.rb +31 -0
- data/app/models/concerns/cortex/searchable_content_item_for_content_type.rb +52 -0
- data/app/models/concerns/cortex/searchable_content_type.rb +11 -0
- data/app/models/cortex/application_record.rb +17 -0
- data/app/models/cortex/content_item.rb +71 -0
- data/app/models/cortex/content_type.rb +27 -0
- data/app/models/cortex/contentable_decorator.rb +8 -0
- data/app/models/cortex/contract.rb +12 -0
- data/app/models/cortex/decorator.rb +13 -0
- data/app/models/cortex/field.rb +36 -0
- data/app/models/cortex/field_item.rb +54 -0
- data/app/models/cortex/field_type.rb +44 -0
- data/app/models/cortex/permission.rb +11 -0
- data/app/models/cortex/role.rb +12 -0
- data/app/models/cortex/tenant.rb +41 -0
- data/app/models/cortex/user.rb +77 -0
- data/app/operations/cortex/database_transact_operation.rb +17 -0
- data/app/operations/cortex/execute_content_item_state_change_operation.rb +16 -0
- data/app/operations/cortex/parse_content_item_field_items_operation.rb +18 -0
- data/app/operations/cortex/persist_content_item_operation.rb +12 -0
- data/app/policies/cortex/application_policy.rb +55 -0
- data/app/policies/cortex/content_item_policy.rb +49 -0
- data/app/policies/cortex/content_type_policy.rb +38 -0
- data/app/transactions/concerns/cortex/content_itemable.rb +15 -0
- data/app/transactions/concerns/cortex/field_item_transactor.rb +28 -0
- data/app/transactions/concerns/cortex/widget_parsable.rb +19 -0
- data/app/transactions/cortex/application_transaction.rb +5 -0
- data/app/transactions/cortex/create_content_item_transaction.rb +35 -0
- data/app/transactions/cortex/get_content_item_transaction.rb +4 -0
- data/app/transactions/cortex/get_content_items_for_content_type_transaction.rb +34 -0
- data/app/transactions/cortex/get_publish_state_transaction.rb +28 -0
- data/app/transactions/cortex/new_field_item_transaction.rb +16 -0
- data/app/transactions/cortex/update_content_item_transaction.rb +45 -0
- data/app/transactions/cortex/update_field_item_transaction.rb +23 -0
- data/app/types/cortex/application_types.rb +21 -0
- data/app/types/cortex/content_item_transaction_type.rb +10 -0
- data/app/types/cortex/core_types.rb +5 -0
- data/app/types/cortex/transaction_type.rb +5 -0
- data/app/views/cortex/authentication/passwords/new.html.haml +13 -0
- data/app/views/cortex/authentication/sessions/new.html.haml +20 -0
- data/app/views/cortex/authentication/shared/_links.html.haml +19 -0
- data/app/views/cortex/content_items/_form.html.haml +13 -0
- data/app/views/cortex/content_items/_grid.html.haml +1 -0
- data/app/views/cortex/content_items/edit.html.haml +2 -0
- data/app/views/cortex/content_items/index.html.haml +4 -0
- data/app/views/cortex/content_items/new.html.haml +2 -0
- data/app/views/cortex/content_types/index.html.haml +2 -0
- data/app/views/cortex/content_types/new.html.haml +0 -0
- data/app/views/cortex/dashboards/index.html.haml +6 -0
- data/app/views/cortex/graphql/ide.haml +1 -0
- data/app/views/cortex/partials/_breadcrumb.html.haml +2 -0
- data/app/views/cortex/partials/_cortex_redux_state.html.haml +1 -0
- data/app/views/cortex/partials/_flash.html.haml +25 -0
- data/app/views/cortex/partials/_media_dialogs.html.haml +13 -0
- data/app/views/cortex/partials/_navigation.html.haml +15 -0
- data/app/views/cortex/partials/_notes.html.haml +17 -0
- data/app/views/cortex/partials/_quick_links.html.haml +22 -0
- data/app/views/cortex/partials/_sidebar.html.haml +7 -0
- data/app/views/cortex/partials/_topbar.html.haml +5 -0
- data/app/views/cortex/partials/_user_control.html.haml +7 -0
- data/app/views/cortex/partials/authentication/_header.html.haml +4 -0
- data/app/views/cortex/partials/trackers/_google_analytics.html.haml +10 -0
- data/app/views/cortex/partials/trackers/_qualtrics.html.haml +10 -0
- data/app/views/cortex/password_reset_mailer/send_password_reset.html.erb +5 -0
- data/app/views/cortex/password_reset_mailer/send_password_reset.text.erb +5 -0
- data/app/views/layouts/cortex/application.html.haml +30 -0
- data/app/views/layouts/cortex/devise.html.haml +19 -0
- data/app/views/layouts/cortex/mailer.html.erb +13 -0
- data/app/views/layouts/cortex/mailer.text.erb +1 -0
- data/bin/rails +25 -0
- data/config/config.yml +22 -0
- data/config/initializers/devise.rb +35 -0
- data/config/initializers/elasticsearch.rb +3 -0
- data/config/initializers/filter_parameter_logging.rb +4 -0
- data/config/initializers/flipper.rb +16 -0
- data/config/initializers/graphiql.rb +51 -0
- data/config/initializers/inflections.rb +16 -0
- data/config/initializers/load_config.rb +16 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/initializers/plugins.rb +17 -0
- data/config/initializers/react_on_rails.rb +15 -0
- data/config/initializers/rolify.rb +9 -0
- data/config/initializers/tag_parsers.rb +5 -0
- data/config/locales/devise.en.yml +64 -0
- data/config/routes.rb +41 -0
- data/cortex.gemspec +84 -0
- data/db/migrate/0_enable_pgcrypto_extension.rb +5 -0
- data/db/migrate/10_create_fields.rb +15 -0
- data/db/migrate/11_create_content_items.rb +14 -0
- data/db/migrate/12_create_field_items.rb +12 -0
- data/db/migrate/13_create_field_types.rb +5 -0
- data/db/migrate/1_create_users.rb +14 -0
- data/db/migrate/2_create_tenants.rb +26 -0
- data/db/migrate/3_add_devise_to_users.rb +49 -0
- data/db/migrate/4_create_roles.rb +15 -0
- data/db/migrate/5_create_permissions.rb +16 -0
- data/db/migrate/6_create_flipper_tables.rb +20 -0
- data/db/migrate/7_create_contracts.rb +11 -0
- data/db/migrate/8_create_decorators.rb +21 -0
- data/db/migrate/9_create_content_types.rb +17 -0
- data/db/seeds.rb +40 -0
- data/db/seeds.yml +33 -0
- data/lib/assets/.keep +0 -0
- data/lib/breadcrumbs/title_builder.rb +12 -0
- data/lib/cortex.rb +4 -0
- data/lib/cortex/engine.rb +41 -0
- data/lib/cortex/version.rb +3 -0
- data/lib/helpers/utility_helper.rb +7 -0
- data/lib/tasks/cortex_tasks.rake +13 -0
- data/lib/tasks/elasticsearch_tasks.rake +1 -0
- data/node_package/.babelrc +26 -0
- data/node_package/src/components/side_bar/environment_flag.jsx +21 -0
- data/node_package/src/components/side_bar/tenant_list.jsx +65 -0
- data/node_package/src/components/wizard/column.jsx +29 -0
- data/node_package/src/components/wizard/field.jsx +22 -0
- data/node_package/src/components/wizard/step.jsx +20 -0
- data/node_package/src/constants/tenant_switcher.jsx +17 -0
- data/node_package/src/constants/type_constants.jsx +12 -0
- data/node_package/src/constants/wizard.jsx +9 -0
- data/node_package/src/containers/layout.jsx +33 -0
- data/node_package/src/containers/tenant_switcher_container.jsx +115 -0
- data/node_package/src/containers/wizard_container.jsx +28 -0
- data/node_package/src/elements/loaders.jsx +7 -0
- data/node_package/src/helpers/formatting.jsx +5 -0
- data/node_package/src/helpers/tenant_ancestry.jsx +14 -0
- data/node_package/src/helpers/tenant_lookup.jsx +23 -0
- data/node_package/src/index.jsx +21 -0
- data/node_package/src/reducers/index.jsx +13 -0
- data/node_package/src/reducers/rails_context_reducer.jsx +5 -0
- data/node_package/src/reducers/tenant_switcher_reducer.jsx +74 -0
- data/node_package/src/reducers/wizard_reducer.jsx +32 -0
- data/node_package/src/services/rails_api_service.jsx +13 -0
- data/node_package/src/store/store.jsx +15 -0
- data/package.json +66 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/config/manifest.js +4 -0
- data/spec/dummy/app/assets/javascripts/application.js +2 -0
- data/spec/dummy/app/assets/stylesheets/application.scss +2 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/javascript/packs/application.js +8 -0
- data/spec/dummy/app/javascript/packs/cortex.jsx +1 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.haml +11 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +105 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/rspec +17 -0
- data/spec/dummy/bin/setup +38 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/bin/webpack +29 -0
- data/spec/dummy/bin/webpack-dev-server +29 -0
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config.ru +7 -0
- data/spec/dummy/config/apollo_engine_proxy.yml +23 -0
- data/spec/dummy/config/application.rb +21 -0
- data/spec/dummy/config/boot.rb +11 -0
- data/spec/dummy/config/cable.yml +9 -0
- data/spec/dummy/config/config.yml +22 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +74 -0
- data/spec/dummy/config/environments/production.rb +103 -0
- data/spec/dummy/config/environments/staging.rb +103 -0
- data/spec/dummy/config/environments/test.rb +65 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/load_config.rb +9 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/react_on_rails.rb +41 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/sentry.rb +6 -0
- data/spec/dummy/config/initializers/session_store.rb +7 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +8 -0
- data/spec/dummy/config/newrelic.yml +224 -0
- data/spec/dummy/config/puma.rb +47 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/config/secrets.yml +32 -0
- data/spec/dummy/config/sidekiq.yml +9 -0
- data/spec/dummy/config/webpack/development.js +3 -0
- data/spec/dummy/config/webpack/environment.js +3 -0
- data/spec/dummy/config/webpack/production.js +3 -0
- data/spec/dummy/config/webpack/test.js +3 -0
- data/spec/dummy/config/webpacker.yml +66 -0
- data/spec/dummy/db/migrate/20180118233001_enable_pgcrypto_extension.cortex.rb +6 -0
- data/spec/dummy/db/migrate/20180118233002_create_users.cortex.rb +15 -0
- data/spec/dummy/db/migrate/20180118233003_create_tenants.cortex.rb +27 -0
- data/spec/dummy/db/migrate/20180118233004_add_devise_to_users.cortex.rb +50 -0
- data/spec/dummy/db/migrate/20180118233005_create_roles.cortex.rb +16 -0
- data/spec/dummy/db/migrate/20180118233006_create_permissions.cortex.rb +17 -0
- data/spec/dummy/db/migrate/20180118233007_create_flipper_tables.cortex.rb +21 -0
- data/spec/dummy/db/migrate/20180118233008_create_contracts.cortex.rb +12 -0
- data/spec/dummy/db/migrate/20180118233009_create_decorators.cortex.rb +22 -0
- data/spec/dummy/db/migrate/20180118233010_create_content_types.cortex.rb +18 -0
- data/spec/dummy/db/migrate/20180118233011_create_fields.cortex.rb +16 -0
- data/spec/dummy/db/migrate/20180118233012_create_content_items.cortex.rb +15 -0
- data/spec/dummy/db/migrate/20180118233013_create_field_items.cortex.rb +13 -0
- data/spec/dummy/db/migrate/20180118233014_create_field_types.cortex.rb +6 -0
- data/spec/dummy/db/schema.rb +258 -0
- data/spec/dummy/db/seeds.rb +1 -0
- data/spec/dummy/lib/tasks/content_types_tasks.rake +31 -0
- data/spec/dummy/lib/tasks/employer/blog_tasks.rake +345 -0
- data/spec/dummy/package.json +28 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/dummy/spec/javascripts/support/jasmine.yml +50 -0
- data/spec/dummy/yarn.lock +6615 -0
- data/spec/rails_helper.rb +57 -0
- data/spec/spec_helper.rb +96 -0
- data/yarn.lock +6032 -0
- metadata +1061 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
module Cortex
|
2
|
+
Types::FieldItemType = GraphQL::ObjectType.define do
|
3
|
+
name 'FieldItem'
|
4
|
+
description 'Individual fields storing content that make up a ContentItem'
|
5
|
+
|
6
|
+
field :id, !types.ID
|
7
|
+
field :data, !types.String
|
8
|
+
field :field, !Cortex::Types::FieldType
|
9
|
+
field :content_item, !Cortex::Types::ContentItemType
|
10
|
+
|
11
|
+
field :created_at, !Cortex::Types::DateTimeType
|
12
|
+
field :updated_at, !Cortex::Types::DateTimeType
|
13
|
+
field :deleted_at, Cortex::Types::DateTimeType
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Cortex
|
2
|
+
Types::FieldType = GraphQL::ObjectType.define do
|
3
|
+
name 'Field'
|
4
|
+
description 'Configured FieldTypes that make up a ContentType'
|
5
|
+
|
6
|
+
field :id, !types.ID
|
7
|
+
field :name, !types.String
|
8
|
+
field :name_id, !types.String
|
9
|
+
field :field_type, !types.String
|
10
|
+
field :metadata, !types.String
|
11
|
+
field :validations, !types.String
|
12
|
+
field :content_type, !Cortex::Types::ContentTypeType
|
13
|
+
|
14
|
+
field :created_at, !Cortex::Types::DateTimeType
|
15
|
+
field :updated_at, !Cortex::Types::DateTimeType
|
16
|
+
field :deleted_at, Cortex::Types::DateTimeType
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Cortex
|
2
|
+
Types::QueryType = GraphQL::ObjectType.define do
|
3
|
+
name 'Query'
|
4
|
+
|
5
|
+
# TODO: After migration to class-based schemas, move these methods to a concern
|
6
|
+
def all_field_for_content_type(content_type)
|
7
|
+
field(field_name('all', content_type), types[Cortex::Types::ContentItemType]) do
|
8
|
+
argument :page, types.Int
|
9
|
+
argument :limit, types.Int
|
10
|
+
argument :tenant_id, types.ID # TODO: check that tenant_id within active_tenant and authorize. Which layer should this occur in?
|
11
|
+
|
12
|
+
description content_type.description
|
13
|
+
|
14
|
+
resolve -> (_obj, args, ctx) {
|
15
|
+
params = { args: args, active_tenant: ctx[:current_user].active_tenant, content_type: content_type }
|
16
|
+
Cortex::GetContentItemsForContentTypeTransaction.new.call(params).value!
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def field_name(prefix, content_type) # TODO: extract
|
22
|
+
prefix + content_type.name_id.camelize.pluralize
|
23
|
+
end
|
24
|
+
|
25
|
+
field :currentUser, !Cortex::Types::UserType do
|
26
|
+
resolve ->(_obj, _args, ctx) {
|
27
|
+
ctx[:current_user]
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
field :allUsers, types[Cortex::Types::UserType] do
|
32
|
+
resolve -> (_obj, _args, _ctx) {
|
33
|
+
# TODO: scope to tenant; allow tenant argument
|
34
|
+
Cortex::User.all
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# TODO: extract to class
|
39
|
+
Cortex::ContentType.find_each do |content_type|
|
40
|
+
all_field_for_content_type(content_type)
|
41
|
+
# field_for_content_type(content_type)
|
42
|
+
# ...
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Cortex
|
2
|
+
Types::TenantType = GraphQL::ObjectType.define do
|
3
|
+
name 'Tenant'
|
4
|
+
description 'Tenants segregate and nest users and content'
|
5
|
+
|
6
|
+
field :id, !types.ID
|
7
|
+
field :name, !types.String
|
8
|
+
field :name_id, !types.String
|
9
|
+
field :description, !types.String
|
10
|
+
field :parent, types[Cortex::Types::TenantType]
|
11
|
+
field :children, types[Cortex::Types::TenantType]
|
12
|
+
field :owner, !types[Cortex::Types::UserType]
|
13
|
+
field :created_at, !Cortex::Types::DateTimeType
|
14
|
+
field :updated_at, !Cortex::Types::DateTimeType
|
15
|
+
field :deleted_at, Cortex::Types::DateTimeType
|
16
|
+
|
17
|
+
# TODO: Owned ContentItems, etc
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Cortex
|
2
|
+
Types::UserType = GraphQL::ObjectType.define do
|
3
|
+
name 'User'
|
4
|
+
description 'Cortex administrator or content creator'
|
5
|
+
|
6
|
+
field :id, !types.ID
|
7
|
+
field :firstname, !types.String
|
8
|
+
field :lastname, !types.String
|
9
|
+
field :locale, !types.String
|
10
|
+
field :timezone, !types.String
|
11
|
+
field :created_at, !Cortex::Types::DateTimeType
|
12
|
+
field :updated_at, !Cortex::Types::DateTimeType
|
13
|
+
field :deleted_at, Cortex::Types::DateTimeType
|
14
|
+
|
15
|
+
field :tenants, !types[Cortex::Types::TenantType]
|
16
|
+
field :active_tenant, !types[Cortex::Types::TenantType]
|
17
|
+
|
18
|
+
# TODO: Owned ContentItems, etc
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'breadcrumbs/title_builder'
|
2
|
+
|
3
|
+
module Cortex
|
4
|
+
module ApplicationHelper
|
5
|
+
def title
|
6
|
+
title = 'Cortex Administration'
|
7
|
+
title += " | #{render_breadcrumbs builder: TitleBuilder}" if render_breadcrumbs
|
8
|
+
title
|
9
|
+
end
|
10
|
+
|
11
|
+
def extra_config
|
12
|
+
Cortex.config[:extra]
|
13
|
+
end
|
14
|
+
|
15
|
+
def user_session_props
|
16
|
+
{
|
17
|
+
environment: environment,
|
18
|
+
active_tenant: current_user.active_tenant,
|
19
|
+
current_user: current_user,
|
20
|
+
tenants: current_user.tenants_with_children,
|
21
|
+
csrf_token: form_authenticity_token,
|
22
|
+
sidebarExpanded: (current_page? cortex.root_path),
|
23
|
+
environment_abbreviated: environment_abbreviated
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def wizard_props
|
28
|
+
if @wizard
|
29
|
+
@wizard.data.merge({
|
30
|
+
content_type: @content_type,
|
31
|
+
content_item: @content_item,
|
32
|
+
fields: @content_type.fields
|
33
|
+
})
|
34
|
+
else
|
35
|
+
{}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def index_props
|
40
|
+
@index || {}
|
41
|
+
end
|
42
|
+
|
43
|
+
def cortex_props
|
44
|
+
user_session_props.merge({
|
45
|
+
wizard: wizard_props,
|
46
|
+
index: index_props
|
47
|
+
})
|
48
|
+
end
|
49
|
+
|
50
|
+
def qualtrics_domain
|
51
|
+
extra_config[:qualtrics_id].delete('_').downcase
|
52
|
+
end
|
53
|
+
|
54
|
+
def flag_enabled?(flag_name)
|
55
|
+
Flipper.enabled?(flag_name, current_user, request)
|
56
|
+
end
|
57
|
+
|
58
|
+
def environment
|
59
|
+
request.local? ? :local : Rails.env
|
60
|
+
end
|
61
|
+
|
62
|
+
def environment_abbreviated
|
63
|
+
case environment
|
64
|
+
when 'production'
|
65
|
+
:prd
|
66
|
+
when 'staging'
|
67
|
+
:stg
|
68
|
+
when 'development'
|
69
|
+
:dev
|
70
|
+
else
|
71
|
+
:loc
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Cortex
|
2
|
+
module Cells
|
3
|
+
module AssociationHelper
|
4
|
+
def associated_content_item
|
5
|
+
@options[:associated_content_item]
|
6
|
+
end
|
7
|
+
|
8
|
+
def associated_primary_field
|
9
|
+
@options[:associated_primary_field]
|
10
|
+
end
|
11
|
+
|
12
|
+
def associated_primary_field_type_class
|
13
|
+
@options[:associated_primary_field_type_class]
|
14
|
+
end
|
15
|
+
|
16
|
+
def associated_primary_field_item
|
17
|
+
@options[:associated_primary_field_item]
|
18
|
+
end
|
19
|
+
|
20
|
+
def associated_content_item_title
|
21
|
+
@options[:associated_content_item_title]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module Cortex
|
2
|
+
module ContentItemHelper
|
3
|
+
def content_type
|
4
|
+
@content_type ||= Cortex::ContentType.find_by_id(params[:content_type_id])
|
5
|
+
end
|
6
|
+
|
7
|
+
def create_content_item
|
8
|
+
CreateContentItemTransaction.new
|
9
|
+
.with_step_args(
|
10
|
+
execute_content_item_state_change: [state: params[:content_item][:state]]
|
11
|
+
)
|
12
|
+
.call(id: params[:id], content_type: content_type,
|
13
|
+
content_item_params: content_item_params, current_user: current_user)
|
14
|
+
.value!
|
15
|
+
end
|
16
|
+
|
17
|
+
def update_content_item
|
18
|
+
UpdateContentItemTransaction.new
|
19
|
+
.with_step_args(
|
20
|
+
execute_content_item_state_change: [state: params[:content_item][:state]]
|
21
|
+
)
|
22
|
+
.call(id: params[:id], content_type: content_type,
|
23
|
+
content_item_params: content_item_params, current_user: current_user)
|
24
|
+
.value!
|
25
|
+
end
|
26
|
+
|
27
|
+
def content_item_reload(content_item)
|
28
|
+
@content_item = content_item
|
29
|
+
content_type.fields.each do |field|
|
30
|
+
@content_item.field_items << Cortex::FieldItem.new(field: field, data: field_item_param_data(params_lookup[field.id]))
|
31
|
+
end
|
32
|
+
@content_item
|
33
|
+
end
|
34
|
+
|
35
|
+
def content_item_params
|
36
|
+
params.require(:content_item).permit(
|
37
|
+
:creator_id,
|
38
|
+
:content_type_id,
|
39
|
+
field_items_attributes: field_items_attributes_params,
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def field_items_attributes_params
|
44
|
+
field_items_attributes_as_array = params['content_item']['field_items_attributes'].values
|
45
|
+
|
46
|
+
permitted_keys = {}
|
47
|
+
field_items_attributes_as_array.each {|hash| hash.each_key {|key| permitted_keys[key.to_s] = []}}
|
48
|
+
|
49
|
+
permit_attribute_params(field_items_attributes_as_array, permitted_keys)
|
50
|
+
end
|
51
|
+
|
52
|
+
def permit_attribute_params(param_array, permitted_keys)
|
53
|
+
param_array.each do |param_hash|
|
54
|
+
permitted_keys.keys.each do |key|
|
55
|
+
if param_hash[key].is_a?(Hash)
|
56
|
+
permitted_keys[key] << permit_param(param_hash[key])
|
57
|
+
end
|
58
|
+
permitted_keys[key].flatten!
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
sanitize_parameters(permitted_keys)
|
63
|
+
end
|
64
|
+
|
65
|
+
def permit_param(param)
|
66
|
+
if param.values[0].is_a?(Hash)
|
67
|
+
{param.keys[0].to_sym => param.values[0].keys}
|
68
|
+
else
|
69
|
+
param.keys
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def sanitize_parameters(permitted_keys)
|
74
|
+
permitted_keys.map do |key, value|
|
75
|
+
if value.empty?
|
76
|
+
key
|
77
|
+
else
|
78
|
+
{key => value.uniq}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def index_parameters
|
84
|
+
@index_parameters = {}
|
85
|
+
params['content_item']['field_items_attributes'].each do |param|
|
86
|
+
@index_parameters[params['content_item']['field_items_attributes'][param]['field_id']] = params['content_item']['field_items_attributes'][param]
|
87
|
+
end
|
88
|
+
@index_parameters
|
89
|
+
end
|
90
|
+
|
91
|
+
def params_lookup
|
92
|
+
@params_lookup ||= index_parameters
|
93
|
+
end
|
94
|
+
|
95
|
+
def field_item_param_data(field_item_params)
|
96
|
+
return {} unless field_item_params
|
97
|
+
params_hash = field_item_params.to_unsafe_h
|
98
|
+
params_hash['data'] || {}
|
99
|
+
end
|
100
|
+
|
101
|
+
def validation_message(base_message)
|
102
|
+
msg_array = base_message.gsub('Validation failed:', '').gsub('Field items', '').split(',')
|
103
|
+
msg_array.map {|message| message.strip.titleize}
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Cortex
|
2
|
+
module DashboardHelper
|
3
|
+
def news_feed
|
4
|
+
[] # need to re-implement this feature using Beta Cortex blogposts
|
5
|
+
end
|
6
|
+
|
7
|
+
def news_feed_tenant
|
8
|
+
@news_feed_tenant ||= Tenant.find_by_id(Cortex.config[:cortex][:news_feed][:tenant])
|
9
|
+
end
|
10
|
+
|
11
|
+
def media_content_type
|
12
|
+
@media_content_type ||= current_user.active_tenant.search_up_organization_for(Cortex::ContentType, :name, 'Media').first
|
13
|
+
end
|
14
|
+
|
15
|
+
def employer_blog_content_type
|
16
|
+
@employer_blog_content_type ||= current_user.active_tenant.search_up_organization_for(Cortex::ContentType, :name, 'Employer Blog').first
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Cortex
|
2
|
+
module PopupHelper
|
3
|
+
# TODO: This needs to be in a plugin
|
4
|
+
|
5
|
+
def media_content_type
|
6
|
+
@media_content_type ||= current_user.active_tenant.search_up_organization_for(Cortex::ContentType, :name, 'Media').first
|
7
|
+
end
|
8
|
+
|
9
|
+
def media_content_items
|
10
|
+
@media_content_items ||= media_content_type.content_items
|
11
|
+
end
|
12
|
+
|
13
|
+
def media_asset_field
|
14
|
+
@media_asset_field ||= media_content_type.fields.find_by_name('Asset')
|
15
|
+
end
|
16
|
+
|
17
|
+
def media_image_content_items
|
18
|
+
@media_image_content_items ||= media_content_items.select do |content_item|
|
19
|
+
MimeMagic.new(content_item.field_items.find_by_field_id(media_asset_field).data['asset']['versions']['original']['mime_type']).mediatype == 'image'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def media_index
|
24
|
+
@media_index ||= media_content_type.decorators.find_by_name('Index')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Cortex
|
2
|
+
class PasswordResetMailer < Cortex::ApplicationMailer
|
3
|
+
# Subject can be set in your I18n file at config/locales/en.yml
|
4
|
+
# with the following lookup:
|
5
|
+
#
|
6
|
+
# en.password_reset_mailer.send_password_reset.subject
|
7
|
+
#
|
8
|
+
def send_password_reset(params = {})
|
9
|
+
@password = params[:password]
|
10
|
+
mail to: params[:email], subject: "Cortex CMS Password Reset"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|