Mandarin.Designer (mandarin v0.7.0)

Convenience functions to design an application (paramsbase, schemas, contexts and HTML) in a programmatic way.

This is equivalent to using the Phoenix and Mandarin generators, but with a nicer API which allows you to use the full power of the Elixir language to run the generators instead of relying on custom bash scripts or manually running the generators.

Link to this section Summary

Functions

Generate a mandarin context (without generating a web interface)

Generate a mandarin context (without generating a web interface).

Generate mandarin web interfaces (schemas, context and the web part) for a list of params.

Generate a mandarin schema (without generating a context or any web interface).

Install Mandarin into the given context.

Create a foreign key reference

Tag a field as unique.

Update the options for a list

Run a function (fun) which may create migration files and add marker files to migrations path to delimit which migrations were generated. This makes it easier to see which migrations were generated as a group.

Link to this section Functions

Link to this function

drop_migrations_if_already_exist(migration_path \\ "priv/repo/migrations", tag)

Link to this function

generate_mandarin_context(params, migrations_path \\ "priv/repo/migrations")

Specs

generate_mandarin_context(Mandarin.Designer.Params.t(), String.t()) :: :ok

Generate a mandarin context (without generating a web interface)

Link to this function

generate_mandarin_html(params, migrations_path \\ "priv/repo/migrations")

Specs

generate_mandarin_html(Mandarin.Designer.Params.t(), String.t()) :: :ok

Generate a mandarin context (without generating a web interface).

If the params belong to a join_through table, this is the same as running generate_mandarin_schema(params).

Link to this function

generate_mandarin_html_for_all(list_of_params, tag, migrations_path \\ "priv/repo/migrations")

Generate mandarin web interfaces (schemas, context and the web part) for a list of params.

If the any params belong to a join_through table, this will run generate_mandarin_schema(params) for those params.

Link to this function

generate_mandarin_schema(params, migrations_path \\ "priv/repo/migrations")

Specs

generate_mandarin_schema(Mandarin.Designer.Params.t(), String.t()) :: :ok

Generate a mandarin schema (without generating a context or any web interface).

This might be useful for schemas that are meant to act only as join_through tables for many-to-many relations. These schemas don't require a context or a web interface. In fact, the user is not meant to interact with them directly. Ecto will be capable of using them when required if the schemas are configured correctly.

Link to this function

install_mandarin(context)

Specs

install_mandarin(String.t()) :: :ok

Install Mandarin into the given context.

The context should be an upper case plural string (this function doesn't take a )

Example

install_mandarin("Admin")
Link to this function

references(foreign_table)

Create a foreign key reference

Tag a field as unique.

Link to this function

update_options(list_of_params, options)

Specs

update_options([Mandarin.Designer.Params.t()], Keyword.t()) :: [
  Mandarin.Designer.Params.t()
]

Update the options for a list

Link to this function

with_ecto_design_markers(tag, migrations_path \\ "priv/repo/migrations", fun)

Run a function (fun) which may create migration files and add marker files to migrations path to delimit which migrations were generated. This makes it easier to see which migrations were generated as a group.

The migration files will contain the tag in the file name, so you may want to make it descriptive.