Skip to content
mbrookes edited this page Oct 5, 2014 · 15 revisions

Customizing views is pretty simple once you get the hang of it, but at first it can seem odd due to the fact that you need to figure out how Upmin Admin determines which partial to render. Because of this, the beginning of these docs is dedicated to how partials are chosen and rendered.

The up_render method

Upmin Admin uses a custom render method to render.. well pretty much anything. You can see the source for this file here: https://github.com/upmin/upmin-admin-ruby/blob/master/lib/upmin/railties/render.rb

In short, what this method does is determine what it is trying to render, calls the appropriate RenderHelpers method to determine the options and partials, and then iterates through the partials until it finds one that exists.

Overriding/Customizing any Controllers, Views, or Partials

Upmin Admin is a Rails engine, which means that you can override any controller, view, or partial in your own application, and the engine will use your file instead of the default file. This means that customizing any view or partial is just a matter of figuring out the directory structure, and creating a file with the same name, in the same directory, and it will be used. Keep this in mind and you shouldn't have any problems customizing things.

Actions

Actions are methods that you want to expose in your admin pages. For example, you might want to expose the Order#issue_refund method to your admin team. By default, Upmin Admin uses a single partial to render all associations, but tries several other partials before falling back on the default.

You can find the default partial for actions here and you can see how the partials list is generated in the RenderHelper class.

The directory for action partials is app/views/upmin/partials/actions.

Associations

Associations are models related to another model. For example, a User may have several Orders. By default, Upmin Admin uses a single partial to render all associations, but tries several other partials before falling back on the default.

You can find the default partial for associations here and you can see how the partials list is generated in the RenderHelper class.

The directory for association partials is app/views/upmin/partials/associations.

Attributes

Attributes are single pieces of data inside of a model. For example, name could be an attribute of the User class. If you would like to see a list of currently implemented attribute types, you can check here.

You can see how the partials list is generated in the RenderHelper class.

The directory for attribute partials is app/views/upmin/partials/attributes.

Models

Models are pretty self explanatory. These are things like a User, or an Order. There are two types of partials for these - one for creating new models, and one for editing existing ones. The names are always the same, but the partial for new models is always prefixed with _new.

You can find the default partial for models here and you can see how the partials list is generated in the RenderHelper class.

The directory for model partials is app/views/upmin/partials/models.

Parameters

Parameters are the names of arguments you will be passing into actions. For example, if a User has an issue_coupon(percent) method, percent would be a parameter for the issue_coupon action.

You can find the default partials for parameters here and you can see how the partials list is generated in the RenderHelper class.

The directory for parameter partials is app/views/upmin/partials/parameters.

Search Boxes

Search Boxes are the boxes shown to the right of the results on the search page. This dictates what you can search by. Customization for this is not heavily supported, so create an issue and let us know if you need more customization for it.

You can find the default partials for search boxes here and you can see how the partials list is generated in the RenderHelper class.

The directory for search box partials is app/views/upmin/partials/search_boxes.

Search Results

Search results are the results shown to the left of the search options on the search page.

You can find the default partials for search results here and you can see how the partials list is generated in the RenderHelper class.

The directory for search result partials is app/views/upmin/partials/search_results.

Clone this wiki locally