Module: Trestle
- Defined in:
- lib/trestle.rb,
lib/trestle/tab.rb,
lib/trestle/form.rb,
lib/trestle/hook.rb,
lib/trestle/lazy.rb,
lib/trestle/admin.rb,
lib/trestle/table.rb,
lib/trestle/engine.rb,
lib/trestle/scopes.rb,
lib/trestle/builder.rb,
lib/trestle/display.rb,
lib/trestle/options.rb,
lib/trestle/toolbar.rb,
lib/trestle/version.rb,
lib/trestle/adapters.rb,
lib/trestle/hook/set.rb,
lib/trestle/registry.rb,
lib/trestle/reloader.rb,
lib/trestle/resource.rb,
lib/trestle/attribute.rb,
lib/trestle/table/row.rb,
lib/trestle/breadcrumb.rb,
lib/trestle/form/field.rb,
lib/trestle/model_name.rb,
lib/trestle/navigation.rb,
lib/trestle/form/fields.rb,
lib/trestle/configurable.rb,
lib/trestle/debug_errors.rb,
lib/trestle/form/builder.rb,
lib/trestle/hook/helpers.rb,
lib/trestle/scopes/block.rb,
lib/trestle/scopes/scope.rb,
lib/trestle/table/column.rb,
lib/trestle/toolbar/item.rb,
lib/trestle/toolbar/menu.rb,
lib/trestle/admin/builder.rb,
lib/trestle/configuration.rb,
lib/trestle/form/renderer.rb,
lib/trestle/table/builder.rb,
lib/trestle/form/automatic.rb,
lib/trestle/navigation/item.rb,
lib/trestle/table/automatic.rb,
lib/trestle/toolbar/builder.rb,
lib/trestle/toolbar/context.rb,
lib/trestle/adapters/adapter.rb,
lib/trestle/navigation/block.rb,
lib/trestle/navigation/group.rb,
lib/trestle/resource/builder.rb,
lib/trestle/resource/toolbar.rb,
lib/trestle/scopes/definition.rb,
app/helpers/trestle/tab_helper.rb,
app/helpers/trestle/url_helper.rb,
lib/trestle/evaluation_context.rb,
lib/trestle/form/fields/select.rb,
app/helpers/trestle/card_helper.rb,
app/helpers/trestle/form_helper.rb,
app/helpers/trestle/grid_helper.rb,
app/helpers/trestle/hook_helper.rb,
app/helpers/trestle/i18n_helper.rb,
app/helpers/trestle/icon_helper.rb,
app/helpers/trestle/sort_helper.rb,
lib/trestle/resource/collection.rb,
lib/trestle/table/select_column.rb,
app/helpers/trestle/flash_helper.rb,
app/helpers/trestle/table_helper.rb,
app/helpers/trestle/title_helper.rb,
lib/trestle/table/actions_column.rb,
app/helpers/trestle/avatar_helper.rb,
app/helpers/trestle/format_helper.rb,
app/helpers/trestle/layout_helper.rb,
app/helpers/trestle/params_helper.rb,
app/helpers/trestle/status_helper.rb,
lib/trestle/form/fields/check_box.rb,
app/helpers/trestle/display_helper.rb,
lib/trestle/form/fields/file_field.rb,
lib/trestle/form/fields/form_group.rb,
lib/trestle/form/fields/tag_select.rb,
app/helpers/trestle/headings_helper.rb,
app/helpers/trestle/toolbars_helper.rb,
lib/trestle/adapters/draper_adapter.rb,
lib/trestle/adapters/sequel_adapter.rb,
lib/trestle/form/fields/date_select.rb,
lib/trestle/form/fields/range_field.rb,
lib/trestle/form/fields/time_select.rb,
app/helpers/trestle/container_helper.rb,
app/helpers/trestle/timestamp_helper.rb,
lib/trestle/form/fields/form_control.rb,
lib/trestle/form/fields/radio_button.rb,
lib/trestle/form/fields/static_field.rb,
lib/trestle/resource/adapter_methods.rb,
app/helpers/trestle/navigation_helper.rb,
app/helpers/trestle/pagination_helper.rb,
lib/trestle/form/fields/datetime_select.rb,
lib/trestle/form/fields/time_zone_select.rb,
lib/trestle/form/fields/check_box_helpers.rb,
lib/trestle/form/fields/collection_select.rb,
lib/trestle/adapters/active_record_adapter.rb,
lib/generators/trestle/admin/admin_generator.rb,
lib/trestle/form/fields/radio_button_helpers.rb,
lib/trestle/form/fields/collection_check_boxes.rb,
lib/generators/trestle/install/install_generator.rb,
lib/trestle/form/fields/collection_radio_buttons.rb,
app/controllers/concerns/trestle/controller/title.rb,
lib/trestle/form/fields/grouped_collection_select.rb,
app/controllers/concerns/trestle/controller/dialog.rb,
app/controllers/concerns/trestle/controller/layout.rb,
lib/generators/trestle/resource/resource_generator.rb,
app/controllers/concerns/trestle/controller/helpers.rb,
app/controllers/concerns/trestle/controller/location.rb,
app/controllers/concerns/trestle/controller/toolbars.rb,
app/controllers/concerns/trestle/controller/callbacks.rb,
app/controllers/concerns/trestle/controller/breadcrumbs.rb,
app/controllers/concerns/trestle/resource/controller/actions.rb,
app/controllers/concerns/trestle/resource/controller/toolbar.rb,
app/controllers/concerns/trestle/resource/controller/redirection.rb,
app/controllers/concerns/trestle/resource/controller/data_methods.rb
Defined Under Namespace
Modules: Adapters, AvatarHelper, CardHelper, Configurable, ContainerHelper, Controller, DisplayHelper, EvaluationContext, FlashHelper, FormHelper, FormatHelper, Generators, GridHelper, HeadingsHelper, HookHelper, I18nHelper, IconHelper, LayoutHelper, Lazy, NavigationHelper, PaginationHelper, ParamsHelper, SortHelper, StatusHelper, TabHelper, TableHelper, TimestampHelper, TitleHelper, ToolbarsHelper, UrlHelper Classes: Admin, AdminController, ApplicationController, Attribute, Breadcrumb, Builder, Configuration, DashboardController, DebugErrors, Display, Engine, Form, Hook, ModelName, Navigation, Options, Registry, Reloader, Resource, ResourceController, Scopes, Tab, Table, Toolbar
Constant Summary collapse
- VERSION =
"0.9.8"
Class Method Summary collapse
-
.admin(name, **options, &block) ⇒ Object
Builds and registers a new plain admin.
-
.config ⇒ Object
Configuration methods.
- .configure(&block) ⇒ Object
-
.i18n_fallbacks(locale = I18n.locale) ⇒ Object
Returns the I18n fallbacks for the given locale.
-
.navigation(context) ⇒ Object
Builds the global navigation by combining the menu options from the Trestle configuration along with menu blocks from admin resources.
-
.resource(name, register_model: true, **options, &block) ⇒ Object
Builds and registers a new admin resource.
Class Method Details
.admin(name, **options, &block) ⇒ Object
Builds and registers a new plain admin
41 42 43 |
# File 'lib/trestle.rb', line 41 def self.admin(name, **, &block) register(Admin::Builder.create(name, , &block)) end |
.config ⇒ Object
Configuration methods
52 53 54 |
# File 'lib/trestle.rb', line 52 def self.config @configuration ||= Configuration.new end |
.configure(&block) ⇒ Object
56 57 58 |
# File 'lib/trestle.rb', line 56 def self.configure(&block) config.configure(&block) end |
.i18n_fallbacks(locale = I18n.locale) ⇒ Object
Returns the I18n fallbacks for the given locale.
This is used from within a Sprockets asset (JavaScript) to determine which locale files to include.
Examples
Trestle.i18n_fallbacks("pt-BR") => ["pt-BR", "pt"]
Trestle.i18n_fallbacks("ca") => ["ca", "es-ES", "es"] %>
Returns an array of locale Strings.
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/trestle.rb', line 78 def self.i18n_fallbacks(locale=I18n.locale) if I18n.respond_to?(:fallbacks) I18n.fallbacks[locale].map(&:to_s) elsif locale.to_s.include?("-") fallback = locale.to_s.split("-").first [locale, fallback] else [locale] end end |
.navigation(context) ⇒ Object
Builds the global navigation by combining the menu options from the Trestle configuration along with menu blocks from admin resources.
62 63 64 65 |
# File 'lib/trestle.rb', line 62 def self.(context) blocks = config. + registry.map(&:menu).compact Navigation.build(blocks, context) end |