luca 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +49 -0
- data/Gemfile +8 -1
- data/Gemfile.lock +97 -53
- data/Guardfile +3 -25
- data/README.md +5 -16
- data/ROADMAP +15 -9
- data/Rakefile +24 -75
- data/app.rb +10 -42
- data/app/assets/javascripts/luca/basic.coffee +1 -1
- data/app/assets/javascripts/luca/components/application.coffee +187 -104
- data/app/assets/javascripts/luca/components/collection_view.coffee +115 -51
- data/app/assets/javascripts/luca/components/controller.coffee +87 -10
- data/app/assets/javascripts/luca/components/fields/base.coffee +74 -13
- data/app/assets/javascripts/luca/components/fields/button_field.coffee +60 -13
- data/app/assets/javascripts/luca/components/fields/checkbox_array.coffee +12 -7
- data/app/assets/javascripts/luca/components/fields/select_field.coffee +82 -23
- data/app/assets/javascripts/luca/components/fields/text_area_field.coffee +25 -10
- data/app/assets/javascripts/luca/components/fields/text_field.coffee +9 -3
- data/app/assets/javascripts/luca/components/form_view.coffee +105 -33
- data/app/assets/javascripts/luca/components/grid_layout_view.coffee +42 -0
- data/app/assets/javascripts/luca/components/index.coffee +6 -0
- data/app/assets/javascripts/luca/components/nav_bar.coffee +60 -6
- data/app/assets/javascripts/luca/components/page.coffee +70 -0
- data/app/assets/javascripts/luca/components/simple_collection_view.coffee +10 -0
- data/app/assets/javascripts/luca/components/table_view.coffee +7 -3
- data/app/assets/javascripts/luca/components/table_view_scrollable.coffee +23 -0
- data/app/assets/javascripts/luca/concerns/collection_event_bindings.coffee +4 -1
- data/app/assets/javascripts/luca/concerns/development_tool_helpers.coffee +23 -14
- data/app/assets/javascripts/luca/concerns/dom_helpers.coffee +2 -2
- data/app/assets/javascripts/luca/concerns/filterable.coffee +8 -11
- data/app/assets/javascripts/luca/concerns/form_model_bindings.coffee +20 -0
- data/app/assets/javascripts/luca/concerns/modal_view.coffee +40 -15
- data/app/assets/javascripts/luca/concerns/query_collection_bindings.coffee +7 -1
- data/app/assets/javascripts/luca/concerns/state_model.coffee +40 -26
- data/app/assets/javascripts/luca/concerns/templating.coffee +3 -1
- data/app/assets/javascripts/luca/config.coffee +5 -0
- data/app/assets/javascripts/luca/containers/card_view.coffee +87 -52
- data/app/assets/javascripts/luca/containers/container.coffee +305 -108
- data/app/assets/javascripts/luca/containers/modal_view.coffee +9 -9
- data/app/assets/javascripts/luca/containers/page_controller.coffee +25 -0
- data/app/assets/javascripts/luca/containers/panel_toolbar.coffee +5 -6
- data/app/assets/javascripts/luca/containers/tab_view.coffee +19 -10
- data/app/assets/javascripts/luca/containers/viewport.coffee +12 -16
- data/app/assets/javascripts/luca/core/collection.coffee +19 -5
- data/app/assets/javascripts/luca/core/events.coffee +5 -5
- data/app/assets/javascripts/luca/core/model.coffee +1 -1
- data/app/assets/javascripts/luca/core/panel.coffee +18 -6
- data/app/assets/javascripts/luca/core/registry/component_definition.coffee +2 -1
- data/app/assets/javascripts/luca/core/registry/meta_data.coffee +2 -0
- data/app/assets/javascripts/luca/core/registry/registry.coffee +14 -11
- data/app/assets/javascripts/luca/core/templates.coffee +5 -1
- data/app/assets/javascripts/luca/core/view.coffee +200 -47
- data/app/assets/javascripts/luca/dependencies.coffee +2 -0
- data/app/assets/javascripts/luca/development/code_sync_manager.coffee +173 -0
- data/app/assets/javascripts/luca/development/component.coffee +76 -0
- data/app/assets/javascripts/luca/development/components.coffee +57 -0
- data/app/assets/javascripts/luca/development/console.coffee +1 -1
- data/app/assets/javascripts/luca/development/index.coffee +4 -1
- data/app/assets/javascripts/luca/framework.coffee +7 -3
- data/app/assets/javascripts/luca/index.coffee +2 -1
- data/app/assets/javascripts/luca/managers/collection_manager.coffee +2 -3
- data/app/assets/javascripts/luca/managers/index.coffee +1 -1
- data/app/assets/javascripts/luca/managers/socket_manager.coffee +31 -8
- data/app/assets/javascripts/luca/templates/components/nav_bar.jst.ejs +16 -1
- data/app/assets/javascripts/luca/templates/containers/tab_view.jst.ejs +1 -1
- data/app/assets/javascripts/luca/util/index.coffee +1 -0
- data/app/assets/javascripts/luca/util/keybindings.coffee +24 -0
- data/app/assets/javascripts/luca/util/logging.coffee +15 -0
- data/app/assets/javascripts/luca/util/luca.coffee +9 -1
- data/app/assets/stylesheets/luca/components/table_view.scss +85 -0
- data/app/assets/stylesheets/luca/components/viewport.scss +0 -4
- data/app/assets/stylesheets/luca/containers/container.scss +8 -0
- data/app/assets/stylesheets/luca/index.css +2 -2
- data/bin/luca +14 -0
- data/config.ru +1 -2
- data/docs/framework.json +1 -0
- data/docs/luca-framework-documentation.js +1 -0
- data/docs/{application.md → old/application.md} +0 -0
- data/docs/{collection.md → old/collection.md} +0 -0
- data/docs/{collection_manager.md → old/collection_manager.md} +0 -0
- data/docs/{container_philosophy.md → old/container_philosophy.md} +0 -0
- data/docs/{event_binding_helpers.md → old/event_binding_helpers.md} +0 -0
- data/docs/{method_caching_and_computed_properties.md → old/method_caching_and_computed_properties.md} +0 -0
- data/docs/{view.md → old/view.md} +0 -0
- data/lib/generators/luca/application/templates/javascripts/dependencies.coffee +2 -5
- data/lib/guard/luca.rb +84 -0
- data/lib/luca.rb +25 -1
- data/lib/luca/asset_compiler.rb +117 -0
- data/lib/luca/cli.rb +68 -0
- data/lib/luca/cli/generate.rb +37 -0
- data/lib/luca/cli/server.rb +20 -0
- data/lib/luca/cli/sync.rb +40 -0
- data/lib/luca/cli/watch.rb +16 -0
- data/lib/luca/collection.rb +64 -0
- data/lib/luca/collection/endpoint.rb +38 -0
- data/lib/luca/collection/file_backend.rb +121 -0
- data/lib/luca/collection/redis_backend.rb +153 -0
- data/lib/luca/compiled_asset.rb +61 -0
- data/lib/luca/component_definition.rb +356 -0
- data/lib/luca/luca_application.rb +258 -0
- data/lib/luca/project.rb +73 -0
- data/lib/luca/project_harness.rb +96 -0
- data/lib/luca/rails.rb +5 -3
- data/lib/luca/rails/engine.rb +8 -0
- data/lib/luca/rails/version.rb +1 -2
- data/lib/luca/server.rb +7 -0
- data/lib/luca/stylesheet.rb +35 -0
- data/lib/luca/template.rb +2 -0
- data/lib/luca/template_asset.rb +64 -0
- data/lib/luca/version.rb +3 -0
- data/lib/luca/watcher.rb +72 -0
- data/lib/railties/luca/tasks.rake +7 -0
- data/site/.bundle/config +2 -0
- data/site/.gitignore +5 -0
- data/site/.rvmrc +1 -0
- data/site/CHANGELOG.md +41 -0
- data/site/DOCS.md +41 -0
- data/site/Gemfile +8 -0
- data/site/Gemfile.lock +134 -0
- data/site/LICENSE.md +19 -0
- data/site/config.rb +84 -0
- data/site/helpers/site_helpers.rb +20 -0
- data/site/html5bp-docs/README.md +38 -0
- data/site/html5bp-docs/contribute.md +104 -0
- data/site/html5bp-docs/crossdomain.md +21 -0
- data/site/html5bp-docs/css.md +135 -0
- data/site/html5bp-docs/extend.md +507 -0
- data/site/html5bp-docs/faq.md +77 -0
- data/site/html5bp-docs/htaccess.md +323 -0
- data/site/html5bp-docs/html.md +170 -0
- data/site/html5bp-docs/js.md +31 -0
- data/site/html5bp-docs/misc.md +25 -0
- data/site/html5bp-docs/usage.md +109 -0
- data/site/readme.md +47 -0
- data/site/source/.htaccess +540 -0
- data/site/source/404.html +157 -0
- data/site/source/app/assets/javascripts/dependencies.js.coffee +6 -0
- data/site/source/app/assets/javascripts/docs-docs.js +1 -0
- data/site/source/app/assets/javascripts/docs/application.coffee +64 -0
- data/site/source/app/assets/javascripts/docs/collections/docs_documentation.coffee +17 -0
- data/site/source/app/assets/javascripts/docs/collections/github_repositories.coffee +7 -0
- data/site/source/app/assets/javascripts/docs/collections/index.coffee +1 -0
- data/site/source/app/assets/javascripts/docs/collections/luca_documentation.coffee +17 -0
- data/site/source/app/assets/javascripts/docs/collections/public_gists.coffee +4 -0
- data/site/source/app/assets/javascripts/docs/config.coffee +5 -0
- data/site/source/app/assets/javascripts/docs/index.coffee +12 -0
- data/site/source/app/assets/javascripts/docs/lib/router.coffee +3 -0
- data/{spec/components/application_spec.coffee → site/source/app/assets/javascripts/docs/lib/util.coffee} +0 -0
- data/site/source/app/assets/javascripts/docs/models/component.coffee +99 -0
- data/site/source/app/assets/javascripts/docs/models/github_repository.coffee +3 -0
- data/site/source/app/assets/javascripts/docs/models/index.coffee +1 -0
- data/site/source/app/assets/javascripts/docs/templates/component_documentation.jst.ejs +55 -0
- data/site/source/app/assets/javascripts/docs/templates/examples_browser/overview.jst.ejs +4 -0
- data/site/source/app/assets/javascripts/docs/templates/examples_browser/selector.jst.ejs +11 -0
- data/site/source/app/assets/javascripts/docs/templates/github_repository.jst.ejs +4 -0
- data/site/source/app/assets/javascripts/docs/templates/layouts/main.jst.ejs +4 -0
- data/site/source/app/assets/javascripts/docs/templates/left_navigation.jst.ejs +5 -0
- data/site/source/app/assets/javascripts/docs/templates/pages/getting_started.jst.ejs +78 -0
- data/site/source/app/assets/javascripts/docs/templates/pages/home.jst.ejs +57 -0
- data/site/source/app/assets/javascripts/docs/views/components/code_editor.coffee +45 -0
- data/{spec/components/collection_loader_view_spec.coffee → site/source/app/assets/javascripts/docs/views/components/code_editor/index.coffee} +0 -0
- data/site/source/app/assets/javascripts/docs/views/components/component_documentation.coffee +72 -0
- data/site/source/app/assets/javascripts/docs/views/index.coffee +3 -0
- data/site/source/app/assets/javascripts/docs/views/pages/browse_source.coffee +46 -0
- data/site/source/app/assets/javascripts/docs/views/pages/browse_source/details.coffee +37 -0
- data/site/source/app/assets/javascripts/docs/views/pages/browse_source/list.coffee +31 -0
- data/site/source/app/assets/javascripts/docs/views/pages/component_editor.coffee +10 -0
- data/site/source/app/assets/javascripts/docs/views/pages/examples_browser.coffee +102 -0
- data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/docs.coffee +12 -0
- data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/source.coffee +13 -0
- data/site/source/app/assets/javascripts/docs/views/pages/home.coffee +10 -0
- data/site/source/app/assets/javascripts/docs/views/views/api_browser/index.coffee +43 -0
- data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/grid_layout_view_example.coffee +14 -0
- data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/table_view_example.coffee +39 -0
- data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/basic_example.coffee +38 -0
- data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/complex_layout.coffee +110 -0
- data/site/source/app/assets/javascripts/docs/views/views/top_navigation.coffee +6 -0
- data/site/source/app/assets/javascripts/luca-docs.js +1 -0
- data/site/source/app/assets/javascripts/luca-framework-documentation.js +1 -0
- data/site/source/app/assets/javascripts/site.js.coffee +4 -0
- data/site/source/app/assets/javascripts/vendor/codemirror.js +4786 -0
- data/site/source/app/assets/javascripts/vendor/coffeescript.js +346 -0
- data/site/source/app/assets/javascripts/vendor/css.js +465 -0
- data/site/source/app/assets/javascripts/vendor/htmlmixed.js +84 -0
- data/site/source/app/assets/javascripts/vendor/javascript.js +422 -0
- data/site/source/app/assets/javascripts/vendor/js-beautify.js +1353 -0
- data/site/source/app/assets/javascripts/vendor/modernizr-2.6.1.min.js +4 -0
- data/site/source/app/assets/javascripts/vendor/vim.js +2511 -0
- data/site/source/app/assets/stylesheets/docs/api-browser.css.scss +5 -0
- data/site/source/app/assets/stylesheets/docs/application.css.scss +35 -0
- data/site/source/app/assets/stylesheets/docs/browse-source.css.scss +5 -0
- data/site/source/app/assets/stylesheets/docs/scrollable-table.css.scss +5 -0
- data/site/source/app/assets/stylesheets/site.css.scss +2 -0
- data/site/source/app/assets/stylesheets/vendor/codemirror.css +240 -0
- data/site/source/app/assets/stylesheets/vendor/prettify-tomorrow-night-bright.css +160 -0
- data/site/source/app/assets/stylesheets/vendor/twilight.css +26 -0
- data/site/source/crossdomain.xml +15 -0
- data/site/source/documentation.html.haml +1 -0
- data/site/source/favicon_base.png +0 -0
- data/site/source/humans.txt +15 -0
- data/site/source/images/background.png +0 -0
- data/site/source/images/middleman.png +0 -0
- data/site/source/index.html.haml +1 -0
- data/site/source/layouts/layout.haml +55 -0
- data/site/source/readme.md +63 -0
- data/site/source/robots.txt +3 -0
- data/spec/{components/grid_view_spec.coffee → javascripts/components/application_spec.coffee} +0 -0
- data/spec/{components/pagination_control_spec.coffee → javascripts/components/collection_loader_view_spec.coffee} +0 -0
- data/spec/{components → javascripts/components}/collection_view_spec.coffee +1 -1
- data/spec/{components → javascripts/components}/controller_spec.coffee +0 -0
- data/spec/{components → javascripts/components}/fields/checkbox_array_spec.coffee +0 -0
- data/spec/javascripts/components/form_view_spec.coffee +162 -0
- data/spec/{components/record_manager_spec.coffee → javascripts/components/grid_view_spec.coffee} +0 -0
- data/spec/{components → javascripts/components}/multi_collection_view_spec.coffee +0 -0
- data/spec/{components/template_spec.coffee → javascripts/components/pagination_control_spec.coffee} +0 -0
- data/spec/{concerns/paginatable_spec.coffee → javascripts/components/record_manager_spec.coffee} +0 -0
- data/spec/{components → javascripts/components}/table_view_spec.coffee +0 -0
- data/spec/{containers/modal_view_spec.coffee → javascripts/components/template_spec.coffee} +0 -0
- data/spec/{concerns → javascripts/concerns}/collection_event_bindings_spec.coffee +0 -0
- data/spec/{concerns → javascripts/concerns}/dom_helpers_spec.coffee +0 -0
- data/spec/{concerns → javascripts/concerns}/filterable_spec.coffee +0 -0
- data/spec/{concerns → javascripts/concerns}/model_presenter_spec.coffee +0 -0
- data/spec/{containers/panel_view_spec.coffee → javascripts/concerns/paginatable_spec.coffee} +0 -0
- data/spec/{concerns → javascripts/concerns}/state_model_spec.coffee +5 -0
- data/spec/javascripts/containers/card_view_spec.coffee +108 -0
- data/spec/{containers/tab_view_spec.coffee → javascripts/containers/modal_view_spec.coffee} +0 -0
- data/spec/{containers/viewport_spec.coffee → javascripts/containers/panel_view_spec.coffee} +0 -0
- data/spec/{core/observer_spec.coffee → javascripts/containers/tab_view_spec.coffee} +0 -0
- data/spec/{managers/socket_manager_spec.coffee → javascripts/containers/viewport_spec.coffee} +0 -0
- data/spec/{core → javascripts/core}/collection_spec.coffee +1 -1
- data/spec/{core → javascripts/core}/concerns_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/container_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/define_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/events_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/field_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/framework_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/model_spec.coffee +0 -0
- data/spec/javascripts/core/observer_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/util_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/view_spec.coffee +51 -39
- data/spec/{dependencies → javascripts/dependencies}/index.coffee +0 -0
- data/spec/{dependencies → javascripts/dependencies}/jasmine-html.js +0 -0
- data/spec/{dependencies → javascripts/dependencies}/jasmine.js +0 -0
- data/spec/{dependencies → javascripts/dependencies}/sinon.js +0 -0
- data/spec/{helper.coffee → javascripts/helper.coffee} +0 -0
- data/spec/{managers → javascripts/managers}/collection_manager_spec.coffee +0 -0
- data/spec/javascripts/managers/socket_manager_spec.coffee +0 -0
- data/spec/lib/component_definition_spec.rb +63 -0
- data/spec/lib/input_compiler_spec.rb +9 -0
- data/spec/lib/luca_application_spec.rb +30 -0
- data/spec/support/fixtures/application.coffee +45 -0
- data/spec/support/fixtures/component.coffee +34 -0
- data/tutorials/component-definitions.md +0 -0
- data/tutorials/component-definitions/01_intro.md +0 -0
- data/tutorials/component-driven-design.md +140 -0
- data/tutorials/structure-of-a-project.md +63 -0
- data/vendor/assets/javascripts/backbone-min.js +37 -33
- data/vendor/assets/javascripts/backbone-query.min.js +1 -1
- data/vendor/assets/javascripts/hogan.js +707 -0
- data/vendor/assets/javascripts/jquery.js +5 -4
- data/vendor/assets/javascripts/keymaster.min.js +4 -0
- data/vendor/assets/javascripts/luca-dependencies.min.js +8 -0
- data/vendor/assets/javascripts/luca-development.min.js +1 -0
- data/vendor/assets/javascripts/luca-spec.js +6 -6
- data/vendor/assets/javascripts/luca-ui.js +7386 -0
- data/vendor/assets/javascripts/luca-ui.min.js +5 -0
- data/vendor/assets/javascripts/luca.full.min.js +12 -0
- data/vendor/assets/javascripts/luca.min.js +5 -0
- data/vendor/assets/javascripts/underscore-min.js +1 -5
- data/vendor/assets/javascripts/underscore-string.min.js +1 -1
- data/vendor/assets/stylesheets/luca-components.css +202 -0
- data/vendor/assets/stylesheets/luca-development.css +23 -0
- data/vendor/assets/stylesheets/luca-ui.css +198 -0
- metadata +324 -94
- data/app/assets/javascripts/luca/components/base_toolbar.coffee +0 -17
- data/app/assets/javascripts/luca/components/form_button_toolbar.coffee +0 -28
- data/app/assets/javascripts/luca/components/grid_view.coffee +0 -269
- data/app/assets/javascripts/luca/components/page_controller.coffee +0 -7
- data/app/assets/javascripts/luca/components/template.coffee +0 -5
- data/app/assets/javascripts/luca/components/toolbar_dialog.coffee +0 -25
- data/lib/luca/code_browser.rb +0 -55
- data/lib/luca/command_line.rb +0 -69
- data/lib/luca/component_documentation.rb +0 -72
- data/site/assets/bootstrap.min.js +0 -7
- data/site/assets/dependencies.js +0 -94
- data/site/assets/glyphicons-halflings-white.png +0 -0
- data/site/assets/glyphicons-halflings.png +0 -0
- data/site/assets/luca-ui-bootstrap.css +0 -1331
- data/site/assets/luca-ui-bootstrap.js +0 -9
- data/site/assets/luca-ui-development-tools.css +0 -234
- data/site/assets/luca-ui-development-tools.js +0 -18561
- data/site/assets/luca-ui-development-tools.min.js +0 -15
- data/site/assets/luca-ui-full.min.js +0 -8
- data/site/assets/luca-ui.min.js +0 -4
- data/site/assets/sandbox.css +0 -62
- data/site/assets/sandbox.js +0 -469
- data/site/docs/application.html +0 -41
- data/site/docs/caching.html +0 -43
- data/site/docs/collection.html +0 -75
- data/site/docs/collection_manager.html +0 -71
- data/site/docs/containers.html +0 -118
- data/site/docs/events.html +0 -153
- data/site/docs/view.html +0 -128
- data/site/img/glyphicons-halflings-white.png +0 -0
- data/site/img/glyphicons-halflings.png +0 -0
- data/site/index.html +0 -20
- data/site/source-map.js +0 -1
- data/spec/components/form_view_spec.coffee +0 -84
- data/spec/containers/card_view_spec.coffee +0 -50
- data/spec/luca-spec.coffee +0 -9
@@ -1,3 +1,9 @@
|
|
1
|
+
# The `Luca.fields.ButtonField` provides an easy way to generate
|
2
|
+
# a button element, with an optional icon. Supports all of the
|
3
|
+
# available bootstrap icons, and color states.
|
4
|
+
#
|
5
|
+
# The `Luca.fields.ButtonField` component will typically be used as
|
6
|
+
# part of a `Luca.components.FormView` or a `Luca.components.PanelToolbar`.
|
1
7
|
buttonField = Luca.register "Luca.fields.ButtonField"
|
2
8
|
|
3
9
|
buttonField.extends "Luca.core.Field"
|
@@ -5,27 +11,62 @@ buttonField.extends "Luca.core.Field"
|
|
5
11
|
buttonField.triggers "button:click"
|
6
12
|
|
7
13
|
buttonField.publicConfiguration
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
+
# Which size should this button be? Valid options are:
|
15
|
+
# - none ( default )
|
16
|
+
# - large
|
17
|
+
# - mini
|
18
|
+
# - small
|
19
|
+
buttonSize: undefined
|
20
|
+
|
21
|
+
# Which bootstrap color class should we apply to this button?
|
22
|
+
# Valid options are any css button class, or the defaults which
|
23
|
+
# ship with bootstrap:
|
24
|
+
#
|
25
|
+
# - btn-primary
|
26
|
+
# - btn-info
|
27
|
+
# - btn-success
|
28
|
+
# - btn-warning
|
29
|
+
# - btn-danger
|
30
|
+
# - btn-inverse
|
31
|
+
# - btn-link
|
32
|
+
class: undefined
|
33
|
+
|
34
|
+
# specifies the bootstrap icon class you want to use for this button
|
35
|
+
# you can use 'icon-ok-sign' or just 'ok-sign'
|
36
|
+
icon_class: undefined
|
37
|
+
|
38
|
+
# specifies the text value of the button
|
39
|
+
label: undefined
|
40
|
+
|
41
|
+
# an alias for label, or input_value. controls which text
|
42
|
+
# displays inside of the button
|
43
|
+
text: undefined
|
44
|
+
|
45
|
+
# should we render the white icon?
|
46
|
+
white: false
|
47
|
+
|
48
|
+
buttonField.privateConfiguration
|
49
|
+
readOnly: true
|
50
|
+
input_value: undefined
|
51
|
+
input_type: "button"
|
52
|
+
icon_class: undefined
|
53
|
+
input_name: undefined
|
54
|
+
buttonClasses: ""
|
14
55
|
|
15
56
|
buttonField.privateConfiguration
|
16
57
|
isButton: true
|
58
|
+
autoBindEventHandlers: true
|
17
59
|
template: "fields/button_field"
|
18
60
|
events:
|
19
|
-
"click input" : "
|
61
|
+
"click input" : "clickHandler"
|
20
62
|
|
21
|
-
buttonField.
|
22
|
-
|
63
|
+
buttonField.privateMethods
|
64
|
+
clickHandler: (e)->
|
23
65
|
me = my = $( e.currentTarget )
|
24
66
|
@trigger "button:click"
|
25
67
|
|
26
68
|
initialize: (@options={})->
|
27
|
-
_.extend @options
|
28
|
-
_.bindAll @, "click_handler"
|
69
|
+
_.extend @, @options
|
29
70
|
|
30
71
|
Luca.core.Field::initialize.apply @, arguments
|
31
72
|
|
@@ -35,10 +76,16 @@ buttonField.privateInterface
|
|
35
76
|
@input_id ||= _.uniqueId('button')
|
36
77
|
@input_name ||= @name ||= @input_id
|
37
78
|
@input_value ||= @label ||= @text
|
38
|
-
@input_class ||= @class
|
79
|
+
@input_class ||= @class ||= @buttonClasses
|
80
|
+
|
81
|
+
if @buttonSize?.length > 0
|
82
|
+
@input_class += " #{ buttonSize.replace(/btn-/,'') }"
|
83
|
+
|
39
84
|
@icon_class ||= ""
|
40
85
|
@icon_class = "icon-#{ @icon_class }" if @icon_class.length and !@icon_class.match(/^icon-/)
|
41
86
|
@icon_class += " icon-white" if @white
|
42
87
|
|
43
|
-
setValue: ()->
|
88
|
+
setValue: ()->
|
89
|
+
true
|
44
90
|
|
91
|
+
buttonField.register()
|
@@ -1,11 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# The `Luca.fields.CheckboxArray` renders an array of values
|
2
|
+
# into checkbox controls. This is for fields which can have
|
3
|
+
# a list of values associated with them.
|
3
4
|
checkboxArray = Luca.register "Luca.fields.CheckboxArray"
|
4
5
|
checkboxArray.extends "Luca.core.Field"
|
5
6
|
|
6
|
-
checkboxArray.
|
7
|
-
version: 2
|
8
|
-
|
7
|
+
checkboxArray.privateConfiguration
|
9
8
|
template: "fields/checkbox_array"
|
10
9
|
|
11
10
|
className: "luca-ui-checkbox-array"
|
@@ -15,6 +14,7 @@ checkboxArray.defines
|
|
15
14
|
|
16
15
|
selectedItems: []
|
17
16
|
|
17
|
+
checkboxArray.privateMethods
|
18
18
|
initialize: (@options={})->
|
19
19
|
_.extend @, @options
|
20
20
|
_.extend @, Luca.concerns.Deferrable
|
@@ -65,8 +65,8 @@ checkboxArray.defines
|
|
65
65
|
label = model.get(@displayField)
|
66
66
|
input_id = _.uniqueId("#{ @cid }_checkbox")
|
67
67
|
|
68
|
-
inputElement = make("input",type:"checkbox",class:"array-checkbox",name:@input_name,value:value,id: input_id)
|
69
|
-
element = make("label", {for:input_id}, inputElement)
|
68
|
+
inputElement = @make("input",type:"checkbox",class:"array-checkbox",name:@input_name,value:value,id: input_id)
|
69
|
+
element = @make("label", {for:input_id}, inputElement)
|
70
70
|
|
71
71
|
$( element ).append(" #{ label }")
|
72
72
|
@controls().append( element )
|
@@ -80,6 +80,9 @@ checkboxArray.defines
|
|
80
80
|
allFields: ()->
|
81
81
|
@controls().find("input[type='checkbox']")
|
82
82
|
|
83
|
+
checkboxArray.publicMethods
|
84
|
+
# Check the selected items. Expects an array of values
|
85
|
+
# for boxes you would like to see checked.
|
83
86
|
checkSelected: (items)->
|
84
87
|
@selectedItems = items if items?
|
85
88
|
|
@@ -91,6 +94,8 @@ checkboxArray.defines
|
|
91
94
|
|
92
95
|
@selectedItems
|
93
96
|
|
97
|
+
# Gets an array of values for the checkboxes in this array
|
98
|
+
# which are checked.
|
94
99
|
getValue: ()->
|
95
100
|
@$(field).val() for field in @allFields() when @$(field).prop('checked')
|
96
101
|
|
@@ -2,40 +2,86 @@ selectField = Luca.register "Luca.fields.SelectField"
|
|
2
2
|
|
3
3
|
selectField.extends "Luca.core.Field"
|
4
4
|
|
5
|
-
selectField.triggers "after:select"
|
5
|
+
selectField.triggers "after:select",
|
6
|
+
"on:change"
|
6
7
|
|
7
|
-
selectField.
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
template: "fields/select_field"
|
8
|
+
selectField.publicConfiguration
|
9
|
+
# Enables multi-select UI element.
|
10
|
+
allowMultiple: false
|
12
11
|
|
12
|
+
# Includes a blank option in addition to all of the items
|
13
|
+
# in the underlying collection. Defaults to `true`
|
13
14
|
includeBlank: true
|
14
15
|
|
16
|
+
# determines which value is sent when
|
17
|
+
# the blank option is selected?
|
15
18
|
blankValue: ''
|
16
19
|
|
20
|
+
# Determines the text displayed when
|
21
|
+
# the blank option is selected
|
17
22
|
blankText: 'Select One'
|
18
23
|
|
24
|
+
# Specifying a value for maxDisplayLength will truncate
|
25
|
+
# values displayed in the select field when they reach
|
26
|
+
# past a certain point, using the _.str truncate method.
|
27
|
+
# Leave at 0 if you want to keep this feature disabled.
|
28
|
+
maxDisplayLength: 0
|
29
|
+
|
30
|
+
# When the underlying collection is reset and we re-render
|
31
|
+
# the options elements, should we keep the value that was set
|
32
|
+
# on this field prior to that? Defaults to `true` unless otherwise
|
33
|
+
# specified.
|
34
|
+
retainValue: undefined
|
35
|
+
|
36
|
+
# Determines which value is rendered in the label element that gets
|
37
|
+
# rendered along with this control group.
|
38
|
+
label: undefined
|
39
|
+
|
40
|
+
selectField.privateConfiguration
|
41
|
+
template: "fields/select_field"
|
42
|
+
events:
|
43
|
+
"change select" : "change_handler"
|
44
|
+
|
45
|
+
selectField.publicMethods
|
46
|
+
# sets the value of this select field.
|
47
|
+
setValue: (value)->
|
48
|
+
@currentValue = value
|
49
|
+
Luca.core.Field::setValue.apply @, arguments
|
50
|
+
|
51
|
+
# returns the value of the select field. runs
|
52
|
+
# the value through the getParsedValue method which
|
53
|
+
# enforces the valueType type conversion.
|
54
|
+
getValue: ()->
|
55
|
+
raw = @getInputElement()?.val()
|
56
|
+
|
57
|
+
if @allowMultiple
|
58
|
+
_.map raw, (value)=>
|
59
|
+
@getParsedValue(value)
|
60
|
+
else
|
61
|
+
@getParsedValue(raw)
|
62
|
+
|
63
|
+
selectField.privateMethods
|
19
64
|
initialize: (@options={})->
|
20
65
|
_.extend @, @options
|
21
66
|
_.extend @, Luca.concerns.Deferrable
|
22
|
-
_.bindAll @, "change_handler"
|
67
|
+
_.bindAll @, "change_handler"
|
23
68
|
|
24
69
|
if _.isArray(@collection)
|
25
70
|
@collection = data: @collection
|
26
|
-
|
71
|
+
|
27
72
|
Luca.core.Field::initialize.apply @, arguments
|
28
73
|
|
29
74
|
@input_id ||= _.uniqueId('field')
|
30
75
|
@input_name ||= @name
|
31
76
|
@valueType ||= Luca.config.idAttributeType if @valueField is "id"
|
32
77
|
@label ||= @name
|
33
|
-
@retainValue = true
|
78
|
+
@retainValue = true unless @retainValue?
|
34
79
|
|
35
80
|
afterInitialize: ()->
|
36
81
|
if @collection?.data
|
37
82
|
@valueField ||= "id"
|
38
83
|
@displayField ||= "name"
|
84
|
+
@sortOptionsBy ||= @displayField
|
39
85
|
@parseData()
|
40
86
|
|
41
87
|
try
|
@@ -43,8 +89,8 @@ selectField.defines
|
|
43
89
|
catch e
|
44
90
|
console.log "Error Configuring Collection", @, e.message
|
45
91
|
|
46
|
-
@collection?.bind "before:fetch", @beforeFetch
|
47
|
-
@collection?.bind "reset", @populateOptions
|
92
|
+
@collection?.bind "before:fetch", @beforeFetch, @
|
93
|
+
@collection?.bind "reset", @populateOptions, @
|
48
94
|
|
49
95
|
# if the select field is configured with a data property
|
50
96
|
# then parse that data into the proper format. either
|
@@ -69,10 +115,6 @@ selectField.defines
|
|
69
115
|
else
|
70
116
|
@collection?.trigger("reset")
|
71
117
|
|
72
|
-
setValue: (value)->
|
73
|
-
@currentValue = value
|
74
|
-
Luca.core.Field::setValue.apply @, arguments
|
75
|
-
|
76
118
|
beforeFetch: ()->
|
77
119
|
@resetOptions()
|
78
120
|
|
@@ -82,19 +124,36 @@ selectField.defines
|
|
82
124
|
resetOptions: ()->
|
83
125
|
@getInputElement().html('')
|
84
126
|
|
85
|
-
if @
|
127
|
+
if @allowMultiple
|
128
|
+
@getInputElement().attr(multiple: true)
|
129
|
+
else if @includeBlank
|
86
130
|
@getInputElement().append("<option value='#{ @blankValue }'>#{ @blankText }</option>")
|
87
131
|
|
88
132
|
populateOptions: ()->
|
89
133
|
@resetOptions()
|
90
134
|
|
91
|
-
if @collection?.
|
92
|
-
@
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
135
|
+
if @collection?.length > 0
|
136
|
+
if @sortOptionsBy?
|
137
|
+
models = @collection.sortBy (model)=>
|
138
|
+
if model.read?
|
139
|
+
model.read( @sortOptionsBy )
|
140
|
+
else
|
141
|
+
model.get( @sortOptionsBy )
|
142
|
+
else
|
143
|
+
models = @collection.models
|
144
|
+
|
145
|
+
for model in models
|
146
|
+
v = model.read?( @valueField ) || model.get(@valueField)
|
147
|
+
d = model.read?( @displayField ) || model.get(@displayField)
|
148
|
+
|
149
|
+
if @maxDisplayLength and @maxDisplayLength > 0
|
150
|
+
d = _.str.truncate(d, @maxDisplayLength)
|
151
|
+
|
152
|
+
selected = "selected" if @selected and v is @selected
|
153
|
+
option = "<option #{ selected } value='#{ v }'>#{ d }</option>"
|
97
154
|
@getInputElement().append( option )
|
98
155
|
|
99
156
|
@trigger "after:populate:options", @
|
100
|
-
@setValue( @currentValue )
|
157
|
+
@setValue( @currentValue )
|
158
|
+
|
159
|
+
selectField.register()
|
@@ -1,17 +1,19 @@
|
|
1
|
-
|
1
|
+
textArea = Luca.register "Luca.fields.TextAreaField"
|
2
|
+
textArea.extends "Luca.core.Field"
|
3
|
+
textArea.defines
|
4
|
+
autoBindEventHandlers: true
|
2
5
|
|
3
6
|
events:
|
4
|
-
"
|
5
|
-
"
|
6
|
-
"focus input" : "focus_handler"
|
7
|
+
"blur textarea" : "blur_handler"
|
8
|
+
"focus textarea" : "focus_handler"
|
7
9
|
|
8
10
|
template: 'fields/text_area_field'
|
9
11
|
|
10
12
|
height: "200px"
|
11
13
|
width: "90%"
|
14
|
+
keyEventThrottle: 300
|
12
15
|
|
13
16
|
initialize: (@options={})->
|
14
|
-
_.bindAll @, "keydown_handler"
|
15
17
|
|
16
18
|
@input_id ||= _.uniqueId('field')
|
17
19
|
@input_name ||= @name
|
@@ -23,6 +25,13 @@ _.def('Luca.fields.TextAreaField').extends('Luca.core.Field').with
|
|
23
25
|
|
24
26
|
Luca.core.Field::initialize.apply @, arguments
|
25
27
|
|
28
|
+
if @enableKeyEvents is true
|
29
|
+
@keyup_handler = _.debounce(@keyup_handler, @keyEventThrottle || 10)
|
30
|
+
|
31
|
+
console.log "Registering Key Events"
|
32
|
+
@registerEvent("keyup textarea","keyup_handler")
|
33
|
+
@registerEvent("keydown textarea","keyup_handler")
|
34
|
+
|
26
35
|
setValue: (value)->
|
27
36
|
$( @field() ).val(value)
|
28
37
|
|
@@ -30,13 +39,19 @@ _.def('Luca.fields.TextAreaField').extends('Luca.core.Field').with
|
|
30
39
|
$( @field() ).val()
|
31
40
|
|
32
41
|
field: ()->
|
33
|
-
@input =
|
42
|
+
@input = @$("textarea")
|
34
43
|
|
35
|
-
|
36
|
-
|
44
|
+
keyup_handler: (e)->
|
45
|
+
# TODO: Should ignore certain keyup events
|
46
|
+
# which would not indicate a change
|
47
|
+
@trigger "on:change", @, e
|
48
|
+
@trigger "on:keyup", @, e
|
37
49
|
|
38
50
|
blur_handler: (e)->
|
39
|
-
|
51
|
+
@trigger "on:blur", @, e
|
40
52
|
|
41
53
|
focus_handler: (e)->
|
42
|
-
|
54
|
+
@trigger "on:focus", @, e
|
55
|
+
|
56
|
+
change_handler: (e)->
|
57
|
+
@trigger "on:change", @, e
|
@@ -2,7 +2,7 @@ textField = Luca.register 'Luca.fields.TextField'
|
|
2
2
|
textField.extends 'Luca.core.Field'
|
3
3
|
|
4
4
|
textField.defines
|
5
|
-
|
5
|
+
_inheritEvents:
|
6
6
|
"blur input" : "blur_handler"
|
7
7
|
"focus input" : "focus_handler"
|
8
8
|
"change input" : "change_handler"
|
@@ -17,6 +17,9 @@ textField.defines
|
|
17
17
|
|
18
18
|
initialize: (@options={})->
|
19
19
|
if @enableKeyEvents
|
20
|
+
if @keyEventThrottle
|
21
|
+
@keyup_handler = _.debounce(@keyup_handler, @keyEventThrottle)
|
22
|
+
|
20
23
|
@registerEvent("keyup input","keyup_handler")
|
21
24
|
|
22
25
|
@input_id ||= _.uniqueId('field')
|
@@ -26,11 +29,11 @@ textField.defines
|
|
26
29
|
@input_value ||= @value || ""
|
27
30
|
|
28
31
|
if @prepend
|
29
|
-
@$el.addClass
|
32
|
+
@$el.addClass 'input-prepend'
|
30
33
|
@addOn = @prepend
|
31
34
|
|
32
35
|
if @append
|
33
|
-
@$el.addClass
|
36
|
+
@$el.addClass 'input-append'
|
34
37
|
@addOn = @append
|
35
38
|
|
36
39
|
@placeHolder ||= ""
|
@@ -38,6 +41,9 @@ textField.defines
|
|
38
41
|
Luca.core.Field::initialize.apply @, arguments
|
39
42
|
|
40
43
|
keyup_handler: (e)->
|
44
|
+
# TODO: Should ignore certain keyup events
|
45
|
+
# which would not indicate a change
|
46
|
+
@trigger "on:change", @, e
|
41
47
|
@trigger "on:keyup", @, e
|
42
48
|
|
43
49
|
blur_handler: (e)->
|
@@ -3,12 +3,13 @@
|
|
3
3
|
#
|
4
4
|
# The FormView component integrates well with Luca.Models and can control
|
5
5
|
# the attributes on that model, respond to validations, and submit changes
|
6
|
-
# to an API.
|
6
|
+
# to an API.
|
7
7
|
formView = Luca.register "Luca.components.FormView"
|
8
8
|
|
9
9
|
formView.extends "Luca.Container"
|
10
10
|
|
11
|
-
formView.mixesIn "LoadMaskable"
|
11
|
+
formView.mixesIn "LoadMaskable",
|
12
|
+
"FormModelBindings"
|
12
13
|
|
13
14
|
formView.triggers "before:submit",
|
14
15
|
"before:reset",
|
@@ -22,11 +23,20 @@ formView.triggers "before:submit",
|
|
22
23
|
"after:load:existing",
|
23
24
|
"after:submit:success",
|
24
25
|
"after:submit:fatal_error",
|
25
|
-
"after:submit:error"
|
26
|
+
"after:submit:error",
|
27
|
+
"state:change:dirty"
|
26
28
|
|
27
29
|
|
28
30
|
|
29
31
|
formView.publicConfiguration
|
32
|
+
# track dirty state will bind to change events
|
33
|
+
# on all of the underlying fields, and set a
|
34
|
+
# flag whenever one of them changes
|
35
|
+
trackDirtyState: false
|
36
|
+
|
37
|
+
# don't setup two way binding to the model
|
38
|
+
trackModelChanges: false
|
39
|
+
|
30
40
|
# should the label display above, or to the
|
31
41
|
# side of the fields
|
32
42
|
labelAlign: undefined
|
@@ -62,7 +72,7 @@ formView.publicConfiguration
|
|
62
72
|
|
63
73
|
# Applies the twitter bootstrap well class to this form.
|
64
74
|
# @$el.addClass('well') if @well
|
65
|
-
well: false
|
75
|
+
well: false
|
66
76
|
|
67
77
|
# Applies the twitter bootstrap form-search class to this form.
|
68
78
|
# @$el.addClass('form-search') if @searchForm
|
@@ -82,15 +92,24 @@ formView.publicConfiguration
|
|
82
92
|
|
83
93
|
formView.privateConfiguration
|
84
94
|
tagName: 'form'
|
85
|
-
|
86
|
-
events
|
95
|
+
|
96
|
+
# These events will get registered on the component
|
97
|
+
# but still leave the @events property open to extend
|
98
|
+
# for any component which inherits from us.
|
99
|
+
_inheritEvents:
|
87
100
|
"click .submit-button" : "submitHandler"
|
88
101
|
"click .reset-button" : "resetHandler"
|
89
102
|
|
90
103
|
bodyClassName: "form-view-body"
|
91
104
|
|
105
|
+
stateful:
|
106
|
+
dirty: false
|
107
|
+
currentModel: undefined
|
108
|
+
|
92
109
|
formView.privateMethods
|
93
110
|
initialize: (@options={})->
|
111
|
+
form = @
|
112
|
+
|
94
113
|
@loadMask = Luca.config.enableBoostrap unless @loadMask?
|
95
114
|
|
96
115
|
Luca.Container::initialize.apply @, arguments
|
@@ -99,12 +118,26 @@ formView.privateMethods
|
|
99
118
|
|
100
119
|
_.bindAll @, "submitHandler", "resetHandler", "renderToolbars"
|
101
120
|
|
121
|
+
# have our events be internal to the view, and not
|
122
|
+
# part of the normal @events chain, so they can be inherited
|
123
|
+
for eventId, handler of @_inheritEvents
|
124
|
+
@registerEvent(eventId, handler)
|
125
|
+
|
126
|
+
if @trackDirtyState is true
|
127
|
+
@on "after:components", ()->
|
128
|
+
for field in @getFields()
|
129
|
+
field.on "on:change", @onFieldChange, form
|
130
|
+
, form
|
131
|
+
|
102
132
|
@setupHooks( @hooks )
|
103
133
|
|
104
134
|
@applyStyleClasses()
|
105
135
|
|
106
136
|
Luca.components.FormView.setupToolbar.call(@)
|
107
137
|
|
138
|
+
onFieldChange: (field, e)->
|
139
|
+
@trigger "field:change", field, e
|
140
|
+
@state.set('dirty', true)
|
108
141
|
|
109
142
|
getDefaultToolbar: ()->
|
110
143
|
config = @toolbarConfig || @defaultToolbar
|
@@ -127,13 +160,20 @@ formView.privateMethods
|
|
127
160
|
|
128
161
|
resetHandler: (e)->
|
129
162
|
me = my = $( e?.target )
|
130
|
-
|
163
|
+
if @beforeReset?
|
164
|
+
result = @beforeReset()
|
165
|
+
return if result is false
|
166
|
+
|
131
167
|
@reset()
|
132
168
|
@trigger "after:reset", @
|
133
169
|
|
134
170
|
submitHandler: (e)->
|
135
|
-
|
136
|
-
|
171
|
+
if @beforeSubmit?
|
172
|
+
result = @beforeSubmit()
|
173
|
+
return if result is false
|
174
|
+
else
|
175
|
+
@trigger "before:submit", @
|
176
|
+
|
137
177
|
@trigger "enable:loadmask", @ if @loadMask is true
|
138
178
|
@submit() if @hasModel()
|
139
179
|
|
@@ -142,7 +182,7 @@ formView.privateMethods
|
|
142
182
|
|
143
183
|
form = @
|
144
184
|
@eachField (field)->
|
145
|
-
field.getForm = ()=> form
|
185
|
+
field.getForm = ()=> form
|
146
186
|
field.getModel = ()=> form.currentModel()
|
147
187
|
|
148
188
|
eachField: (iterator)->
|
@@ -165,30 +205,33 @@ formView.privateMethods
|
|
165
205
|
|
166
206
|
fields
|
167
207
|
|
168
|
-
loadModel: (
|
208
|
+
loadModel: (model)->
|
169
209
|
form = @
|
170
210
|
fields = @getFields()
|
171
211
|
|
172
|
-
@
|
212
|
+
@state.set('dirty', false)
|
213
|
+
|
214
|
+
@trigger "before:load", @, model
|
173
215
|
|
174
|
-
if
|
175
|
-
|
216
|
+
if model
|
217
|
+
model.beforeFormLoad?.apply(model, @)
|
218
|
+
event = "before:load:#{ (if model.isNew() then "new" else "existing")}"
|
219
|
+
@trigger event, @, model
|
176
220
|
|
177
|
-
|
178
|
-
@trigger event, @, @current_model
|
221
|
+
@state.set('currentModel', model)
|
179
222
|
|
180
|
-
@setValues(
|
223
|
+
@setValues(model || {}, silent: true)
|
181
224
|
|
182
|
-
@trigger "after:load", @,
|
225
|
+
@trigger "after:load", @, model
|
183
226
|
|
184
|
-
if
|
185
|
-
@trigger "after:load:#{ (if
|
227
|
+
if model
|
228
|
+
@trigger "after:load:#{ (if model.isNew() then "new" else "existing")}", @, model
|
186
229
|
|
187
230
|
reset: ()->
|
188
|
-
@loadModel( @
|
231
|
+
@loadModel( @state.get('currentModel') )
|
189
232
|
|
190
233
|
clear: ()->
|
191
|
-
@
|
234
|
+
@state.set('currentModel', @defaultModel?() )
|
192
235
|
|
193
236
|
_( @getFields() ).each (field)=>
|
194
237
|
try
|
@@ -196,6 +239,9 @@ formView.privateMethods
|
|
196
239
|
catch e
|
197
240
|
console.log "Error Clearing", @, field
|
198
241
|
|
242
|
+
isDirty: ()->
|
243
|
+
!!@state.get('dirty')
|
244
|
+
|
199
245
|
# set the values on the form
|
200
246
|
# without syncing
|
201
247
|
setValues: (source, options={})->
|
@@ -205,16 +251,15 @@ formView.privateMethods
|
|
205
251
|
_( fields ).each (field) =>
|
206
252
|
field_name = field.input_name || field.name
|
207
253
|
|
208
|
-
if
|
209
|
-
|
210
|
-
value = value.apply(@)
|
254
|
+
if source?[field_name]
|
255
|
+
value = Luca.util.read( source[field_name] )
|
211
256
|
|
212
257
|
if !value and Luca.isBackboneModel(source)
|
213
258
|
value = source.get(field_name)
|
214
259
|
|
215
260
|
field?.setValue( value ) unless field.readOnly is true
|
216
261
|
|
217
|
-
@
|
262
|
+
@applyFormValuesToModel() unless options.silent? is true
|
218
263
|
|
219
264
|
# Public: returns a hash of values for the form fields in this view.
|
220
265
|
#
|
@@ -261,6 +306,26 @@ formView.privateMethods
|
|
261
306
|
|
262
307
|
values
|
263
308
|
|
309
|
+
removeErrors: ()->
|
310
|
+
@$('.alert.alert-error').remove()
|
311
|
+
@$el.removeClass('error')
|
312
|
+
|
313
|
+
for field in @getFields()
|
314
|
+
field.clearErrors()
|
315
|
+
|
316
|
+
displayErrors: (errors)->
|
317
|
+
has_errors = false
|
318
|
+
for field in @getFields()
|
319
|
+
for field_name, field_errors of errors when field_name is field.input_name
|
320
|
+
field.displayErrors(field_errors)
|
321
|
+
has_errors = true
|
322
|
+
|
323
|
+
if has_errors
|
324
|
+
@$el.addClass('error')
|
325
|
+
|
326
|
+
displayValidationErrorsMessage: ()->
|
327
|
+
@errorMessage('Please fix the fields with errors')
|
328
|
+
|
264
329
|
submit_success_handler: (model, response, xhr)->
|
265
330
|
@trigger "after:submit", @, model, response
|
266
331
|
@trigger "disable:loadmask", @ if @loadMask is true
|
@@ -274,27 +339,34 @@ formView.privateMethods
|
|
274
339
|
@trigger "after:submit", @, model, response
|
275
340
|
@trigger "after:submit:fatal_error", @, model, response
|
276
341
|
|
342
|
+
try
|
343
|
+
json = $.parseJSON(response.responseText)
|
344
|
+
if !json.success && json.errors?
|
345
|
+
@displayValidationErrorsMessage()
|
346
|
+
@displayErrors(json.errors)
|
347
|
+
|
277
348
|
submit: (save=true, saveOptions={})->
|
278
349
|
_.bindAll @, "submit_success_handler", "submit_fatal_error_handler"
|
279
350
|
|
280
351
|
saveOptions.success ||= @submit_success_handler
|
281
352
|
saveOptions.error ||= @submit_fatal_error_handler
|
282
353
|
|
283
|
-
@
|
354
|
+
@removeErrors()
|
355
|
+
@applyFormValuesToModel()
|
284
356
|
return unless save
|
285
|
-
@
|
357
|
+
@currentModel()?.save( @currentModel().toJSON(), saveOptions )
|
286
358
|
|
287
359
|
hasModel: ()->
|
288
|
-
@
|
360
|
+
@currentModel()?
|
289
361
|
|
290
362
|
currentModel: (options={})->
|
291
363
|
if options is true or options?.refresh is true
|
292
|
-
@
|
364
|
+
@applyFormValuesToModel()
|
293
365
|
|
294
|
-
@
|
366
|
+
@state.get('currentModel')
|
295
367
|
|
296
|
-
|
297
|
-
@
|
368
|
+
applyFormValuesToModel: (options)->
|
369
|
+
@currentModel()?.set( @getValues(), options )
|
298
370
|
|
299
371
|
setLegend: (@legend)->
|
300
372
|
$('fieldset legend', @el).first().html(@legend)
|