Skip to content

Instantly share code, notes, and snippets.

@gilvaju
Created November 14, 2017 02:41
Show Gist options
  • Save gilvaju/fa3b7a7fbb8a90597dda2871680c1e4e to your computer and use it in GitHub Desktop.
Save gilvaju/fa3b7a7fbb8a90597dda2871680c1e4e to your computer and use it in GitHub Desktop.
import model from 'genesis/support/model/index'
import { resource } from 'genesis/infra/services/http/resource'
/**
* @type {string}
*/
export const icon = 'lock_outline'
/**
* @type {string}
*/
export const label = 'Tipos de Projetos - Label'
/**
* @type {string}
*/
export const title = 'Tipos de Projetos - Title'
/**
* @type {string}
*/
export const tooltip = 'Tipos para Projetos'
/**
* @type {string}
*/
export const api = '/general/category'
/**
* @type {string}
*/
export const id = 'id'
/**
* @type {string}
*/
export const path = '/dashboard/project/types'
/**
* @type {string}
*/
export const namespace = 'project.types'
/**
* @type {Resource}
*/
export const service = resource(api)
/**
* @type {Object}
*/
export const meta = model.meta(icon, label, title, tooltip)
/**
* @type {Function}
*/
export const menu = model.menu(icon, label, path, false)
/**
* @param {string} scope
* @param {Route} route
* @returns {Object}
*/
export const grid = (scope, route) => {
return {
service,
path,
paginate: true,
schemas: fields(scope, route),
debug: true
}
}
/**
* @param {string} scope
* @param {Route} route
* @returns {Object}
*/
export const form = (scope, route) => {
return {
service,
path,
scope: scope,
schemas: fields(scope),
debug: true
}
}
/**
* @param {string} scope
* @param {Route} route
* @returns {Array}
*/
export const fields = (scope, route = null) => {
return model.filter(
[
model.field('id', 'Código').$in('index').$grid({width: 10}).$link(path + '/{id}').$render(),
model.field('name', 'Nome').$form({icon: 'home', helper: 'Help me!', count: 100}).$validate('required').$render(),
model.field('~', 'Dados').$separator().$render(),
model.field('email', 'E-mail').$filter().$grid({width: 20}).$validate('required').$render(),
model.field('telephone', 'Telefone').$phone().$grid({width: 10}).$form({width: 50}).$validate('required').$render(),
model.field('amount', 'Valor').$money().$grid({width: 10}).$form({width: 50}).$validate('required').$render()
],
scope
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment