Skip to content

Instantly share code, notes, and snippets.

@xdougx
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xdougx/6737e32267ebc6c6a023 to your computer and use it in GitHub Desktop.
Save xdougx/6737e32267ebc6c6a023 to your computer and use it in GitHub Desktop.
class @ButtonsFactory
# recebe os dados do botão como href, id, class, text e html
constructor: (params) ->
button = $("<a>")
for (key, value) in params
button.attr(key, value)
button
@deveRenderizar = (entrega, conditions) ->
boolean = true
for condition in conditions
if not entrega[condition]
boolean = false
boolean
class @EntregaViewModule
constructor: (entrega) ->
container = $("#todos-buttons");
buttons = []
buttons.push ButtonsFactory.new(
ref: '#'
id: 'cancelar_entrega'
text: 'Cancelar'
)
buttons.push ButtonsFactory.new(
ref: "/pizzas/entregas/#{entrega.id}"
id: 'editar_entrega'
text: 'Editar'
)
for botao in buttons
if deveRenderizar(entrega, ['pendente', 'dadosIncompletos'])
container.append(botao)
# metodo para verificar se precisa renderizar o elemento deveRenderizar(entrega, ['pendente', 'dadosIncompletos'])
@deveRenderizar = (entrega, conditions) ->
ButtonsFactory.deveRenderizar(entrega, constions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment