-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature register pages #758
Conversation
It goes like: ActiveAdmin.page "My Page" do content do h2 "Hey, this is a custom page" para "Awesome!" end end
Note: The documentation says that when registering a resource you can set its name doing: ``` ActiveAdmin.register Post, :as => "Article" ``` The code however was made so that the :as resource would get a plural. For instance: ``` ActiveAdmin.register Post, :as => "Articles" ``` I fixed this. It might be worth mentioning in the release notes.
@@ -5,23 +5,15 @@ require 'active_admin/resource_controller/callbacks' | |||
require 'active_admin/resource_controller/collection' | |||
require 'active_admin/resource_controller/filters' | |||
require 'active_admin/resource_controller/form' | |||
require 'active_admin/resource_controller/menu' | |||
require 'active_admin/resource_controller/page_configurations' | |||
require 'active_admin/resource_controller/scoping' | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it might be worth writing some documentation on what a ResourceController is for vs. a PageController
@mattvague Thanks for reviewing this! :) |
@@ -117,6 +117,10 @@ module ActiveAdmin | |||
controller.set_page_config :show, options, &block | |||
end | |||
|
|||
def content(options = {}, &block) | |||
controller.set_page_config :index, options, &block | |||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of parsing the config through DSL class. There are only two methods that are relavent to a Page, #content and #menu. I wonder if instead of using the DSL, we could just assume that the block is the content and the hash options can include the menu options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now have PageDSL and ContentDSL. They both inherit from DSL.
I want customisation common to both DSL (such as menu or controller) similar.
Tested against a "real" rails app revealed a few regressions that I fixed. Also renamed #page method to #register_page and splitted DSL into ResourceDSL and PageDSL. This feature is ready to be merged in. An other thing we could do before releasing 0.4.0 is grouping classes by types in directories: controller, dsl, config. |
"This pull request cannot be automatically merged." Feck! |
This feature must be merged! |
Hi |
line number is false actually. Error appears in "register_resource_controller" function |
I'll get this merged over the weekend. It's next on my list to merge :) |
@meskallito I didn't get what the issue is. What do you mean by non Latin translation? |
@gregbell I can fix the merge conflict if you want! |
Functions in module "Naming" (class Resource < Config), that were rewritten by you in commit [f5c662f], provide resource names for controller_name in class Config. The problem occurs if I have models names translations in locales (for example in Chinese), because in that case "register_page_controller" tries to create controllers with non-latin names. is it clear? |
Ok, that makes a lot of sense! So the user facing names (resource.name and resource.plural_name) should For now you can't register pages with non-latin names then. I will try to fix this before 11am GMT+1 ( |
@meskallito said: Functions in module "Naming" (class Resource < Config), that were rewritten by you in commit [f5c662f], provide resource names for controller_name in class Config. The problem occurs if I have models names translations in locales (for example in Chinese), because in that case "register_page_controller" tries to create controllers with non-latin names. is it clear? |
Ok, that makes a lot of sense! So the user facing names (resource.name and resource.plural_name) should use i18n while the "system" ones (camelcased and underscored) should use... the resource one? For now you can't register pages with non-latin names then. I will try to fix this before 11am GMT+1 (http://thatz.at/Nov-27-2011-11-00-GMT+1-DST) so that this can get merged into master before we release 0.4.0. |
@gregbell I merged this branch into the current master and resolved 4 straight forward merge conflict. It's available here: https://github.com/pcreux/active_admin/tree/merge-feature-register-pages The feature registering_page does not pass though: http://travis-ci.org/#!/pcreux/active_admin/builds/344890
I let you taking care of this today. I won't have time to work on that this week-end. FYI:
|
Yes you are right. In addition, this functions affects the process of creating a common active_admin resources. Even if I dont init any page I'll get problems in register_resource_controller' cause it uses the same config.controller_name and in router.rb (it uses underscored_resource_name). I can prepapre pull request into your branch if you want |
@meskallito Sure, please do! |
@pcreux ok, I'll do in an hour or two |
I just had to clean up my test env to get the spec to pass. And I won't fix the non-latin support this week-end. |
I rebased the branch off master and then merged it in. There are definitely some things I would like to add before releasing this with 0.4.0 such as documentation, sidebar items, action items and the issue that @meskallito is having. Nice work @pcreux! This is an awesome feature. |
Hey @gregbell,
This branch is ready for review. Could you approve the refactorings I made?
I might add more scenarios to the feature
registering_pages
.Cheers!