Git Product home page Git Product logo

carnival's Introduction

#Carnival By Vizir.

Vizir Logo

Carnival is an easy-to-use and extensible Rails Engine to speed up the development of data management interfaces.

When you use Carnival you can benefit from made features that are already done. If you need to change anything, you can write your own version of the method, using real Ruby code without worrying about the syntax of the engine.

##Features

  • Easy way to CRUD any data;
  • Search data easily;
  • Advanced searches in a minute. You can specify which fields you want to search for;
  • Fancy time filter, based on Toggl design;
  • Authentication and CRUD of users based on Devise;
  • Facebook and Google authentication;
  • Nice default layout, ready to use.
  • User notification engine.
  • New and Edit forms are easily configured. If you do ot like, you can write your own views.

##Based of the Gems we are used to

  • Devise for authentication;
  • OmniAuth for Facebook and Google;
  • Inherited Resources on our controllers;
  • SimpleForm for new and edit forms;
  • WickedPDF for PDF generation;

##How it works In some words, Carnival provides a managing infra-structure for your application. All the data related to Carnival will be located under the /admin namespace.

Getting started

Carnival works with Rails 4.0 onwards. You can add it to your Gemfile with:

gem 'carnival'

Run bundle install

Execute rails generate carnival:install after you install Carnival to copy migrations and generate the initializer.

If you already have created your database with rake db:create, just run rake db:migrate to execute the Carnival migrations.

Usage

Model

module Admin
  class Company < ActiveRecord::Base

    include Carnival::ModelHelper
    self.table_name = "companies"

  end
end

Controller

module Admin
  class CompaniesController < Carnival::BaseAdminController
    layout "carnival/admin"

    def permitted_params
      params.permit(admin_company: [:name])
    end
  end
end

Presenter

module Admin
  class CompanyPresenter < Carnival::BaseAdminPresenter
    field :id,
          :actions => [:index, :show], :sortable => false,
          :searchable => true,
          :advanced_search => {:operator => :equal}
    field :name,
          :actions => [:index, :new, :edit, :show],
          :searchable => true,
          :advanced_search => {:operator => :like}
    field :created_at, :actions => [:index, :show]

    action :show
    action :edit
    action :destroy
    action :new

  end
end

Dependent Selects

This feature is used when you have dependent selects like Country, State and City to fill an Address or a Location, because Cities Select only can be filled withe the oprions when a State is selected, and the State when de Country is selected, to implement this kind of behavior in a form, just use the option :depends_on in the dependent field with the symbol of the dependency, follows an example bellow:

field :country,
      :actions => [:index, :csv, :pdf, :new, :edit, :show]
field :state,
      :actions => [:index, :csv, :pdf, :new, :edit, :show]
      :depends_on => :country
field :city,
      :actions => [:index, :csv, :pdf, :new, :edit, :show]
      :depends_on => :state

Menu

The menu of the carnival can be configured in the carnival_initializers.rb file

Ex:

config.menu =
{
  :city => {
    :label => "city",
    :class => "",
    :link => 'admin_cities_path', #You can use the route name as String to define the link
    :subs => [
      {
      :label => "custom_city",
      :class => "",
      :link => 'admin/custom/cities', #Or you can use the full path
      },
      {
        :label => 'google',
        :class => "",
        :link => 'http://www.google.com'
      }
    ]
  },
  ...
}

Configurations

Custom AdminUser

If you want to have your own AdminUser class or need to add methods to that class, you need to do the following steps:

  • Configure the ar_admin_user_class in the carnival_initializers.rb file
Carnival::Config.ar_admin_user_class = MyAdminClass
  • Your class need to inheritance from ActiveRecord::Base

Custom Root Action

Carnival::Config.root_action = 'my_controller#my_action'

Custom Translations

You can add custom translations for the actions [:new, :show, :edit, :destroy]

  company:
    new: Create New company
    show: Show company

##TODO

  • create has many association input data

carnival's People

Contributors

antonioams avatar diegonakamashi avatar tiagogoncalves89 avatar apantaliao avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.