Created
November 4, 2013 19:00
-
-
Save alecperkins/7307518 to your computer and use it in GitHub Desktop.
Doodad extensibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Extend the Components as a way to provide defaults or add extra capability. | |
class TitleField extends StringField | |
placeholder : 'Title' | |
label : 'Title' | |
char_limit : 70 | |
getValue: -> | |
value = super() | |
# do something with the value | |
return value | |
# Extend Container components for a more declarative way of assembling the interface. | |
# Imperitive method still available when more logic is necessary. | |
class CustomForm extends Form | |
layout: """ | |
title,subtitle cover:200 | |
description save_button | |
""" | |
# Called when initializing the form. Provides the form instance for use | |
# by the components. | |
fields: (form) -> | |
title : new TitleField() | |
subtitle : new StringField | |
char_limit: 100 | |
description : new StringField | |
type: 'multiline' | |
char_limit: '~300' | |
cover : new ImageField() | |
save_button: new Button | |
on: click: -> | |
form.save() | |
new CustomForm | |
model: issue_model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment