sproutcore 1.7.1.beta → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +44 -0
- data/README.rdoc +20 -20
- data/VERSION.yml +3 -3
- data/lib/Buildfile +1 -1
- data/lib/buildtasks/build.rake +5 -0
- data/lib/buildtasks/manifest.rake +19 -1
- data/lib/frameworks/sproutcore/Buildfile +19 -17
- data/lib/frameworks/sproutcore/CHANGELOG.md +163 -29
- data/lib/frameworks/sproutcore/README.md +29 -8
- data/lib/frameworks/sproutcore/apps/statechart_routing/Buildfile +12 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/controllers/login_controller.js +11 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/controllers/main_controller.js +7 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/controllers/statechart_controller.js +17 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/core.js +25 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/main.js +15 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/_theme.css +18 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/bar_page.js +14 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/foo_page.js +14 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/loading.rhtml +9 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/login_page.js +61 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/main_page.js +46 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/statechart.js +76 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/theme.js +27 -0
- data/lib/frameworks/sproutcore/apps/tests/controllers/targets.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/states/no_targets.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/states/ready_detail.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/states/ready_empty.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/states/ready_list.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/states/ready_no_tests.js +1 -1
- data/lib/frameworks/sproutcore/apps/welcome/controllers/targets.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +14 -1
- data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +15 -15
- data/lib/frameworks/sproutcore/frameworks/ajax/tests/system/request.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/animation/core.js +8 -5
- data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +302 -70
- data/lib/frameworks/sproutcore/frameworks/bootstrap/system/loader.js +19 -14
- data/lib/frameworks/sproutcore/frameworks/bootstrap/tests/system/browser.js +471 -149
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/object.js +42 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/run_loop.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/string.js +7 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/action_support.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/delegate_support.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/responder_context.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/selection_support.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/body_overflow.js +63 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/keyboard.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/layout.js +37 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/main.js +28 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +10 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/sparse_array_delegate.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/browser.js +66 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/builder.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/cursor.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +58 -57
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js.orig +445 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/platform.js +51 -31
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/ready.js +5 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/render_context.js +53 -69
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/responder.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +98 -72
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/string.js +37 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/timer.js +7 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/array/array_case.js +21 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/object/content_destroyed.js +7 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/string.js +23 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/browser.js +66 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/event.js +22 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/locale.js +11 -11
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/end.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/escape_html.js +41 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/helpers_className.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/helpers_style.js +8 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/update.js +17 -16
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/selection_set/remove.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/build_children.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/class_name_bindings_test.js +15 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/createChildViews.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +50 -30
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/acceleration.js +46 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +1 -43
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +8 -34
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +10 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +6 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +22 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/data_source.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/mixins/relationship_support.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/models/child_attribute.js +0 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/models/children_attribute.js +35 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +46 -19
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +23 -9
- data/lib/frameworks/sproutcore/frameworks/datastore/models/single_attribute.js +2 -3
- data/lib/frameworks/sproutcore/frameworks/datastore/system/many_array.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +294 -302
- data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js.orig +1531 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +14 -11
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/integration/many_array.js +63 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/many_attribute.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array.js +50 -10
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array_complex.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_complex.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/destroy.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/single_attribute.js +114 -67
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/commitChangesFromNestedStore.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/readDataHash.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/compare.js +54 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/evaluation.js +29 -9
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/parse.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/core_methods.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/flush.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/cancelRecord.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitChangesFromNestedStore.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitRecord.js +37 -45
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/find.js +127 -127
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/pushChanges.js +16 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/pushRelationships.js +42 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/readDataHash.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +13 -7
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/tests/system/datetime.js +8 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/resources/strings.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/system/datetime.js +1 -0
- data/lib/frameworks/sproutcore/frameworks/debug/core.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/core.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_row_delegate.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_view_delegate.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +1 -4
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +19 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/modal.js +30 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/palette.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +24 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +121 -28
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/sheet.js +15 -15
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_data_source.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drop_target.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/responder.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/button.js +39 -15
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/collection.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/disclosure.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/image_button.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/panel.js +14 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/popup_button.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/progress.js +11 -11
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segment.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segmented.js +1 -51
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/slider.js +11 -16
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-error-48.png +0 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/slider.css +0 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/system/undo_manager.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/alert/ui.js +9 -9
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/button/content.js +11 -11
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/button/ui.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/reload.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/date_field/ui.js +107 -81
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowDelegate.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/progress/ui.js +68 -60
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/radio/methods.js +57 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/integration.js +21 -19
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroller.js +5 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select/ui.js +32 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/split/methods.js +12 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/stacked/ui_comments.js +12 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/tab/methods.js +0 -8
- data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +77 -132
- data/lib/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +5 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +16 -15
- data/lib/frameworks/sproutcore/frameworks/desktop/views/date_field.js +52 -52
- data/lib/frameworks/sproutcore/frameworks/desktop/views/disclosure.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/grid.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list.js +147 -147
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +11 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/views/popup_button.js +22 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/views/radio.js +13 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scene.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +462 -441
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroller.js +48 -62
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segment.js +22 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +150 -32
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select.js +104 -45
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_button.js +42 -20
- data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +24 -24
- data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +148 -154
- data/lib/frameworks/sproutcore/frameworks/desktop/views/stacked.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/tab.js +8 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/web.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/Buildfile +2 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/controllers/files.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/controllers/library.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/controllers/targets.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/controllers/view_configs.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/mixins/drop_down.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/states/ready.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/views/plist_item.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/views/web.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/controllers/page_design.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/css/css_style_sheet.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/designers/object_designer.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/designers/view_designer.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/mixins/snap_lines.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/views/designer_drop_target.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/views/drawing.js +21 -21
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/views/page_item_view.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form.js +59 -53
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroll.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/tests/models/polymorphism/simple.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroll.js +6 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroll.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroll.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu.js +14 -10
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu_item.js +17 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/popup_button.js +38 -14
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/select.js +5 -13
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_child.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_thumb.js +5 -3
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/tests/children.js +19 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/tests/methods.js +20 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/tests/split_thumb.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/views/split.js +35 -12
- data/lib/frameworks/sproutcore/frameworks/formatters/README +6 -0
- data/lib/frameworks/sproutcore/frameworks/formatters/english.lproj/strings.js +174 -0
- data/lib/frameworks/sproutcore/frameworks/formatters/formatters/date_formatter.js +351 -0
- data/lib/frameworks/sproutcore/frameworks/formatters/tests/date_formatter.js +517 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/core.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +345 -138
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/button.js +5 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_value_support.js +176 -42
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/editable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/flowed_layout.js +137 -105
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/gestureable.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editable.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editor.js +16 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/static_layout.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/validatable.js +47 -47
- data/lib/frameworks/sproutcore/frameworks/foundation/private/tree_item_observer.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/helpers/sizing.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/label.js +28 -6
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/render_delegate.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/benchmark.css +0 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/bootstrap.rhtml +34 -19
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/button_view.css +0 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/label.css +1 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +8 -9
- data/lib/frameworks/sproutcore/frameworks/foundation/system/benchmark.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/system/module.js +179 -47
- data/lib/frameworks/sproutcore/frameworks/foundation/system/task_queue.js +34 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/system/text_selection.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/system/user_defaults.js +26 -12
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/misc.js +7 -7
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/string_measurement.js +12 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/string_metric_optimization.js +202 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_value_support/content.js +77 -8
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/flowed_layout/tests.js +1 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editable/beginEditing.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editable/commitEditing.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editable/discardEditing.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editor/beginEditing.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editor/commitEditing.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editor/discardEditing.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/utils/pointInElement.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/label/ui.js +0 -8
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +163 -149
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/credit_card.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/date.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/date_time.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/password.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/validator.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/views/field.js +16 -43
- data/lib/frameworks/sproutcore/frameworks/foundation/views/image.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/views/inline_text_field.js +67 -54
- data/lib/frameworks/sproutcore/frameworks/foundation/views/label.js +49 -38
- data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +285 -242
- data/lib/frameworks/sproutcore/frameworks/jquery/jquery-buffer.js +13 -13
- data/lib/frameworks/sproutcore/frameworks/jquery/jquery-buffered.js +19 -22
- data/lib/frameworks/sproutcore/frameworks/jquery/jquery-sc.js +9 -3
- data/lib/frameworks/sproutcore/frameworks/jquery/jquery.js +231 -186
- data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +145 -143
- data/lib/frameworks/sproutcore/frameworks/media/views/video.js +156 -154
- data/lib/frameworks/sproutcore/frameworks/qunit/qunit/qunit.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js.orig +540 -0
- data/lib/frameworks/sproutcore/frameworks/routing/tests/system/routes.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +15 -8
- data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/base.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/replace.js +12 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/function.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/copyable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +7 -7
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +98 -32
- data/lib/frameworks/sproutcore/frameworks/runtime/private/chain_observer.js +7 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/private/observer_queue.js +14 -3
- data/lib/frameworks/sproutcore/frameworks/runtime/private/observer_set.js +98 -13
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +8 -14
- data/lib/frameworks/sproutcore/frameworks/runtime/system/enumerator.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/error.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +23 -6
- data/lib/frameworks/sproutcore/frameworks/runtime/system/logger.js +69 -18
- data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +57 -31
- data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +189 -14
- data/lib/frameworks/sproutcore/frameworks/runtime/system/string.js +82 -22
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/chained.js +20 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/observable.js +125 -4
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/index_set/rangeStartForIndex.js +37 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/index_set/remove.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/logger.js +16 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/run_loop.js +75 -4
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/string.js +41 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/mixins/statechart_delegate.js +113 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/private/state_path_matcher.js +312 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/system/async.js +18 -22
- data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +508 -131
- data/lib/frameworks/sproutcore/frameworks/statechart/system/state_route_handler_context.js +78 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +265 -44
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/event_handling/basic/with_concurrent_states.js +16 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/event_handling/responder/responder_chain.js +11 -3
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/private/state_path_matcher.js +116 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/add_substate.js +108 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/find_first_relative_current_state/with_concurrent.js +179 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/find_first_relative_current_state/without_concurrent.js +74 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/get_state.js +141 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/get_substate.js +340 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/route_triggered.js +161 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/try_to_handle_event.js +288 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/history_state/standard/without_concurrent_states/context.js +5 -33
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/routing/with_concurrent_states/basic.js +213 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/routing/without_concurrent_states/basic.js +212 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/standard/without_concurrent_states/core.js +8 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/{state/namespacing.js → statechart/methods/get_state.js} +3 -41
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/statechart/{invoke_state_method.js → methods/invoke_state_method.js} +1 -1
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/{event_handling/advanced → statechart}/respond_to_event.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/system/state_route_handler_context/methods/retry.js +64 -0
- data/lib/frameworks/sproutcore/frameworks/table/core.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/controls/button.js +0 -1
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars.js +29 -5
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars/bind.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars/collection.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars/localization.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars/view.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{handlebars → template_view}/handlebars.js +493 -357
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/mixins/template_helpers/checkbox_support.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/mixins/template_helpers/text_field_support.js +13 -2
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/panes/template.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/controls/button.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/mixins/template_helpers/checkbox_support.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/mixins/template_helpers/text_field_support.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/panes/template.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/views/template/collection.js +39 -14
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/views/template/core.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/views/template/handlebars.js +57 -6
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/views/bindable_span.js +21 -6
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/views/template.js +9 -3
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/views/template_collection.js +55 -26
- data/lib/frameworks/sproutcore/frameworks/testing/system/equiv.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/testing/system/plan.js +122 -122
- data/lib/frameworks/sproutcore/frameworks/testing/system/runner.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/testing/system/suite.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/yuireset/resources/base.css +1 -1
- data/lib/frameworks/sproutcore/frameworks/yuireset/resources/reset.css +0 -1
- data/lib/frameworks/sproutcore/frameworks/yuireset/resources/view.css +4 -4
- data/lib/frameworks/sproutcore/lib/index.rhtml +55 -32
- data/lib/frameworks/sproutcore/license.js +2 -4
- data/lib/frameworks/sproutcore/themes/ace/resources/body.css +5 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/18px/button.css +2 -2
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/24px/button.css +21 -13
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/30px/button.css +17 -10
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/44px/button.css +4 -3
- data/lib/frameworks/sproutcore/themes/ace/resources/button/dark/24px/button.css +20 -12
- data/lib/frameworks/sproutcore/themes/ace/resources/button/dark/30px/button.css +16 -8
- data/lib/frameworks/sproutcore/themes/ace/resources/button/dark/jumbo/button.css +17 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/button/dark/small/button.css +17 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/disclosure/ace/disclosure.css +2 -2
- data/lib/frameworks/sproutcore/themes/ace/resources/master-detail/master-detail.css +2 -2
- data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/popover.css +5 -3
- data/lib/frameworks/sproutcore/themes/iphone_theme/english.lproj/core.css +1 -1
- data/lib/frameworks/sproutcore/themes/legacy_theme/english.lproj/toolbar.css +1 -1
- data/lib/gen/app/USAGE +17 -4
- data/lib/gen/language/Buildfile +4 -4
- data/lib/gen/language/USAGE +4 -4
- data/lib/gen/page/templates/pages/@target_name@/Buildfile +7 -7
- data/lib/gen/{html_app → statechart_app}/Buildfile +0 -0
- data/lib/gen/{html_app → statechart_app}/README +0 -0
- data/lib/gen/statechart_app/USAGE +21 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/Buildfile +9 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/core.js +24 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/main.js +26 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/resources/_theme.css +18 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/resources/loading.rhtml +9 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/resources/main_page.js +21 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/statechart.js +8 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/states/ready_state.js +12 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/theme.js +24 -0
- data/lib/sproutcore/builders.rb +1 -0
- data/lib/sproutcore/builders/base.rb +19 -1
- data/lib/sproutcore/builders/chance_file.rb +6 -1
- data/lib/sproutcore/builders/handlebars.rb +1 -9
- data/lib/sproutcore/builders/javascript.rb +1 -10
- data/lib/sproutcore/builders/json.rb +25 -0
- data/lib/sproutcore/builders/less.rb +1 -1
- data/lib/sproutcore/builders/sass.rb +1 -1
- data/lib/sproutcore/builders/stylesheet.rb +1 -9
- data/lib/sproutcore/helpers/html5_manifest.rb +1 -1
- data/lib/sproutcore/helpers/static_helper.rb +42 -0
- data/lib/sproutcore/rack/proxy.rb +21 -3
- data/lib/sproutcore/rack/service.rb +3 -2
- data/lib/sproutcore/tools.rb +18 -25
- data/lib/sproutcore/tools/gen.rb +10 -3
- data/lib/sproutcore/tools/init.rb +11 -10
- data/spec/buildtasks/manifest/prepare_build_tasks/json_spec.rb +62 -0
- data/spec/fixtures/builder_tests/apps/handlebars_test/Buildfile +1 -1
- data/spec/fixtures/builder_tests/apps/json_test/sc_static.json +2 -0
- data/spec/lib/builders/json_spec.rb +53 -0
- data/sproutcore.gemspec +2 -2
- data/vendor/chance/lib/chance/parser.rb +1 -1
- metadata +222 -177
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/datetime.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/debug/invoke_once_last_debugging.js +0 -259
- data/lib/frameworks/sproutcore/frameworks/documentation/core.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/system/chance.js +0 -69
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/editable/ui.js +0 -44
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/ui.js +0 -64
- data/lib/frameworks/sproutcore/frameworks/mini/license.js +0 -30
- data/lib/gen/html_app/USAGE +0 -15
- data/lib/gen/html_app/templates/apps/@target_name@/@target_name@.js +0 -11
- data/lib/gen/html_app/templates/apps/@target_name@/resources/images/.gitkeep +0 -0
- data/lib/gen/html_app/templates/apps/@target_name@/resources/stylesheets/@target_name@.css +0 -6
- data/lib/gen/html_app/templates/apps/@target_name@/resources/templates/@target_name@.handlebars +0 -1
- data/lib/gen/html_project/Buildfile +0 -45
- data/lib/gen/html_project/INIT +0 -3
- data/lib/gen/html_project/README +0 -1
- data/lib/gen/html_project/USAGE +0 -2
- data/lib/gen/html_project/templates/@filename@/Buildfile +0 -5
- data/lib/gen/html_project/templates/@filename@/README +0 -4
|
@@ -279,7 +279,7 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
|
|
279
279
|
|
|
280
280
|
/**
|
|
281
281
|
Adds the specified record to the record array if it is not already part
|
|
282
|
-
of the array. Provided for
|
|
282
|
+
of the array. Provided for compatibility with `SC.Set`.
|
|
283
283
|
|
|
284
284
|
@param {SC.Record} record
|
|
285
285
|
@returns {SC.RecordArray} receiver
|
|
@@ -551,7 +551,9 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
|
|
551
551
|
// otherwise, lookup all storeKeys for the named recordType...
|
|
552
552
|
} else if (recordType = query.get('expandedRecordTypes')) {
|
|
553
553
|
sourceKeys = SC.IndexSet.create();
|
|
554
|
-
|
|
554
|
+
recordType.forEach(function(cur) {
|
|
555
|
+
sourceKeys.addEach(store.storeKeysFor(cur));
|
|
556
|
+
});
|
|
555
557
|
}
|
|
556
558
|
|
|
557
559
|
// loop through storeKeys to determine if it belongs in this query or
|
|
@@ -487,7 +487,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
|
487
487
|
dataHashDidChange: function(storeKeys, rev, statusOnly, key) {
|
|
488
488
|
|
|
489
489
|
// update the revision for storeKey. Use generateStoreKey() because that
|
|
490
|
-
//
|
|
490
|
+
// guarantees a universally (to this store hierarchy anyway) unique
|
|
491
491
|
// key value.
|
|
492
492
|
if (!rev) rev = SC.Store.generateStoreKey();
|
|
493
493
|
var isArray, len, idx, storeKey;
|
|
@@ -678,7 +678,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
|
678
678
|
|
|
679
679
|
/** @private
|
|
680
680
|
Called by a nested store on a parent store to commit any changes from the
|
|
681
|
-
store. This will copy any changed dataHashes as well as any
|
|
681
|
+
store. This will copy any changed dataHashes as well as any persistent
|
|
682
682
|
change logs.
|
|
683
683
|
|
|
684
684
|
If the parentStore detects a conflict with the optimistic locking, it will
|
|
@@ -1120,7 +1120,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
|
1120
1120
|
|
|
1121
1121
|
// add dataHash and setup initial status -- also save recordType
|
|
1122
1122
|
this.writeDataHash(storeKey, (dataHash ? dataHash : {}), K.READY_NEW);
|
|
1123
|
-
|
|
1123
|
+
|
|
1124
1124
|
SC.Store.replaceRecordTypeFor(storeKey, recordType);
|
|
1125
1125
|
this.dataHashDidChange(storeKey);
|
|
1126
1126
|
|
|
@@ -1136,7 +1136,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
|
1136
1136
|
}
|
|
1137
1137
|
|
|
1138
1138
|
// Finally return materialized record, after we propagate the status to
|
|
1139
|
-
// any
|
|
1139
|
+
// any aggregate records.
|
|
1140
1140
|
ret = this.materializeRecord(storeKey);
|
|
1141
1141
|
if (ret) ret.propagateToAggregates();
|
|
1142
1142
|
return ret;
|
|
@@ -1416,7 +1416,9 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
|
1416
1416
|
var children = this.parentRecords[storeKey] || {};
|
|
1417
1417
|
if (SC.none(func)) return;
|
|
1418
1418
|
for (var key in children) {
|
|
1419
|
-
|
|
1419
|
+
// for .. in makes the key a String, but be sure to pass a Number to the
|
|
1420
|
+
// function.
|
|
1421
|
+
if (children.hasOwnProperty(key)) func(parseInt(key, 10));
|
|
1420
1422
|
}
|
|
1421
1423
|
},
|
|
1422
1424
|
|
|
@@ -1714,7 +1716,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
|
1714
1716
|
@param {String} id to id of the record to load
|
|
1715
1717
|
@param {SC.Record} recordType the expected record type
|
|
1716
1718
|
@param {Number} storeKey (optional) optional store key
|
|
1717
|
-
@param {Function} callback (optional) when refresh
|
|
1719
|
+
@param {Function} callback (optional) when refresh completes
|
|
1718
1720
|
@returns {Boolean} YES if the retrieval was a success.
|
|
1719
1721
|
*/
|
|
1720
1722
|
refreshRecord: function(recordType, id, storeKey, callback) {
|
|
@@ -1729,7 +1731,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
|
1729
1731
|
@param {SC.Record|Array} recordTypes class or array of classes
|
|
1730
1732
|
@param {Array} ids ids to destroy
|
|
1731
1733
|
@param {Array} storeKeys (optional) store keys to destroy
|
|
1732
|
-
@param {Function} callback (optional) when refresh
|
|
1734
|
+
@param {Function} callback (optional) when refresh completes
|
|
1733
1735
|
@returns {Boolean} YES if the retrieval was a success.
|
|
1734
1736
|
*/
|
|
1735
1737
|
refreshRecords: function(recordTypes, ids, storeKeys, callback) {
|
|
@@ -1789,7 +1791,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
|
1789
1791
|
// collect status and process
|
|
1790
1792
|
status = this.readStatus(storeKey);
|
|
1791
1793
|
|
|
1792
|
-
if (
|
|
1794
|
+
if (status == K.ERROR) {
|
|
1793
1795
|
throw K.NOT_FOUND_ERROR ;
|
|
1794
1796
|
}
|
|
1795
1797
|
else {
|
|
@@ -1811,7 +1813,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
|
1811
1813
|
} else if (status==K.DESTROYED_CLEAN) {
|
|
1812
1814
|
this.dataHashDidChange(storeKey, rev, YES);
|
|
1813
1815
|
}
|
|
1814
|
-
// ignore K.READY_CLEAN, K.BUSY_LOADING, K.BUSY_CREATING, K.BUSY_COMMITTING,
|
|
1816
|
+
// ignore K.EMPTY, K.READY_CLEAN, K.BUSY_LOADING, K.BUSY_CREATING, K.BUSY_COMMITTING,
|
|
1815
1817
|
// K.BUSY_REFRESH_CLEAN, K_BUSY_REFRESH_DIRTY, KBUSY_DESTROYING
|
|
1816
1818
|
}
|
|
1817
1819
|
}
|
|
@@ -1821,7 +1823,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
|
1821
1823
|
ret = source.commitRecords.call(source, this, retCreate, retUpdate, retDestroy, params);
|
|
1822
1824
|
}
|
|
1823
1825
|
|
|
1824
|
-
//remove all
|
|
1826
|
+
//remove all committed changes from changelog
|
|
1825
1827
|
if (ret && !recordTypes && !ids) {
|
|
1826
1828
|
if (storeKeys === this.changelog) {
|
|
1827
1829
|
this.changelog = null;
|
|
@@ -1844,7 +1846,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
|
1844
1846
|
@param {SC.Record} recordType the expected record type
|
|
1845
1847
|
@param {String} id the id of the record to commit
|
|
1846
1848
|
@param {Number} storeKey the storeKey of the record to commit
|
|
1847
|
-
@param {Hash} params optional
|
|
1849
|
+
@param {Hash} params optional additional params that will passed down
|
|
1848
1850
|
to the data source
|
|
1849
1851
|
@param {Function|Array} callback function or array of functions
|
|
1850
1852
|
@returns {Boolean} if the action was successful.
|
|
@@ -2258,6 +2260,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
|
2258
2260
|
if(dataHash===undefined) this.writeStatus(storeKey, status) ;
|
|
2259
2261
|
else this.writeDataHash(storeKey, dataHash, status) ;
|
|
2260
2262
|
|
|
2263
|
+
if (id && this.idFor(storeKey) !== id) SC.Store.replaceIdFor(storeKey, id);
|
|
2261
2264
|
this.dataHashDidChange(storeKey);
|
|
2262
2265
|
|
|
2263
2266
|
return storeKey;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// ==========================================================================
|
|
2
|
+
// Project: SproutCore - JavaScript Application Framework
|
|
3
|
+
// Copyright: ©2006-2011 Strobe Inc. and contributors.
|
|
4
|
+
// Portions ©2008-2011 Apple Inc. All rights reserved.
|
|
5
|
+
// License: Licensed under MIT license (see license.js)
|
|
6
|
+
// ==========================================================================
|
|
7
|
+
|
|
8
|
+
var MyDataSource = SC.DataSource.extend({
|
|
9
|
+
retrieveRecordsArguments: [],
|
|
10
|
+
|
|
11
|
+
retrieveRecords: function(store, storeKeys) {
|
|
12
|
+
this.get('retrieveRecordsArguments').push(storeKeys);
|
|
13
|
+
sc_super();
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
var MyApp = {};
|
|
18
|
+
|
|
19
|
+
MyApp.Todo = SC.Record.extend({
|
|
20
|
+
title: SC.Record.attr(String),
|
|
21
|
+
project: SC.Record.toOne("MyApp.Project", {
|
|
22
|
+
inverse: "todos", isMaster: NO
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
MyApp.Project = SC.Record.extend({
|
|
27
|
+
name: SC.Record.attr(String),
|
|
28
|
+
todos: SC.Record.toMany("MyApp.Todo", {
|
|
29
|
+
inverse: "project", isMaster: YES
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
module("SC.Record.toMany array with data source", {
|
|
34
|
+
setup: function() {
|
|
35
|
+
window.MyApp = MyApp;
|
|
36
|
+
window.MyDataSource = MyDataSource;
|
|
37
|
+
},
|
|
38
|
+
teardown: function() {
|
|
39
|
+
window.MyApp = null;
|
|
40
|
+
window.MyDataSource = null;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("when retrieving records with toMany association, it should call retrieveRecords once instead of calling retrieveRecord multiple times", function() {
|
|
45
|
+
var store = SC.Store.create().from("MyDataSource");
|
|
46
|
+
SC.RunLoop.begin();
|
|
47
|
+
store.loadRecords(MyApp.Project, [
|
|
48
|
+
{
|
|
49
|
+
guid: 1,
|
|
50
|
+
name: 'SproutCore',
|
|
51
|
+
todos: [1, 2, 3]
|
|
52
|
+
}
|
|
53
|
+
]);
|
|
54
|
+
SC.RunLoop.end();
|
|
55
|
+
|
|
56
|
+
SC.RunLoop.begin();
|
|
57
|
+
var todos = store.find(MyApp.Project, 1).get('todos').toArray();
|
|
58
|
+
SC.RunLoop.end();
|
|
59
|
+
|
|
60
|
+
same(todos.length, 3);
|
|
61
|
+
// retrieveRecords should be called only once
|
|
62
|
+
same(store.get('dataSource').get('retrieveRecordsArguments').length, 1);
|
|
63
|
+
});
|
|
@@ -332,7 +332,7 @@ test("adding a record to a many-to-many; bar side", function() {
|
|
|
332
332
|
|
|
333
333
|
bar3.get('fooToMany').pushObject(foo2);
|
|
334
334
|
|
|
335
|
-
// v-- since bar3 is added
|
|
335
|
+
// v-- since bar3 is added through inverse, it should follow orderBy
|
|
336
336
|
equals(foo2.get('barToMany').indexOf(bar3), 1, 'foo1.barToMany should contain bar1');
|
|
337
337
|
ok(bar3.get('fooToMany').indexOf(foo2) >= 0, 'bar1.fooToMany should contain foo1');
|
|
338
338
|
|
data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js
CHANGED
|
@@ -80,7 +80,7 @@ module("Basic SC.Record Functions w/ Parent > Child", {
|
|
|
80
80
|
store = null;
|
|
81
81
|
childData1 = null;
|
|
82
82
|
NestedRecord = null;
|
|
83
|
-
delete(window.NestedRecord);
|
|
83
|
+
//delete(window.NestedRecord);
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
|
|
@@ -164,7 +164,7 @@ test("Basic Read", function() {
|
|
|
164
164
|
ok(storeRef, 'checking that the store has the instance of the child record with proper primary key');
|
|
165
165
|
equals(cr, storeRef, "checking the parent reference is the same as the direct store reference");
|
|
166
166
|
|
|
167
|
-
// Check to see if the attributes of a Child Record match the
|
|
167
|
+
// Check to see if the attributes of a Child Record match the reference of the parent
|
|
168
168
|
same(storeRef.get('attributes'), testParent.readAttribute('info'), "check that the ChildRecord's attributes are the same as the ParentRecord's readAttribute for the reference");
|
|
169
169
|
|
|
170
170
|
// Duplication check
|
|
@@ -211,7 +211,7 @@ test("Basic Write As a Hash", function() {
|
|
|
211
211
|
ok(cr.get('status') & SC.Record.DIRTY, 'check that the child record is dirty');
|
|
212
212
|
ok(testParent.get('status') & SC.Record.DIRTY, 'check that the parent record is dirty');
|
|
213
213
|
var newCR = testParent.get('info');
|
|
214
|
-
same(newCR, cr, "after a set('name', <new>) on child, checking to see that the parent has
|
|
214
|
+
same(newCR, cr, "after a set('name', <new>) on child, checking to see that the parent has received the changes from the child record");
|
|
215
215
|
same(testParent.readAttribute('info'), cr.get('attributes'), "after a set('name', <new>) on child, readAttribute on the parent should be correct for info child attributes");
|
|
216
216
|
});
|
|
217
217
|
|
|
@@ -248,7 +248,7 @@ test("Basic Write As a Child Record", function() {
|
|
|
248
248
|
ok(cr.get('status') & SC.Record.DIRTY, 'check that the child record is dirty');
|
|
249
249
|
ok(testParent.get('status') & SC.Record.DIRTY, 'check that the parent record is dirty');
|
|
250
250
|
var newCR = testParent.get('info');
|
|
251
|
-
same(newCR, cr, "after a set('name', <new>) on child, checking to see that the parent has
|
|
251
|
+
same(newCR, cr, "after a set('name', <new>) on child, checking to see that the parent has received the changes from the child record");
|
|
252
252
|
same(testParent.readAttribute('info'), cr.get('attributes'), "after a set('name', <new>) on child, readAttribute on the parent should be correct for info child attributes");
|
|
253
253
|
|
|
254
254
|
// Make sure you can set the child to null.
|
|
@@ -10,13 +10,6 @@
|
|
|
10
10
|
var NestedRecord, store, testParent, testParent2;
|
|
11
11
|
|
|
12
12
|
var initModels = function(){
|
|
13
|
-
NestedRecord.ParentRecordTest = SC.Record.extend({
|
|
14
|
-
/** Child Record Namespace */
|
|
15
|
-
nestedRecordNamespace: NestedRecord,
|
|
16
|
-
|
|
17
|
-
name: SC.Record.attr(String),
|
|
18
|
-
elements: SC.Record.toMany('SC.Record', { nested: true })
|
|
19
|
-
});
|
|
20
13
|
|
|
21
14
|
NestedRecord.ChildRecordTest1 = SC.Record.extend({
|
|
22
15
|
name: SC.Record.attr(String),
|
|
@@ -28,8 +21,39 @@ var initModels = function(){
|
|
|
28
21
|
info: SC.Record.attr(String),
|
|
29
22
|
value: SC.Record.attr(String)
|
|
30
23
|
});
|
|
24
|
+
|
|
25
|
+
NestedRecord.ParentRecordTest = SC.Record.extend({
|
|
26
|
+
/** Child Record Namespace */
|
|
27
|
+
nestedRecordNamespace: NestedRecord,
|
|
28
|
+
|
|
29
|
+
name: SC.Record.attr(String),
|
|
30
|
+
elements: SC.Record.toMany('SC.Record', { nested: true }),
|
|
31
|
+
|
|
32
|
+
defaultElements: SC.Record.toMany(NestedRecord.ChildRecordTest1, {
|
|
33
|
+
isNested: true,
|
|
34
|
+
defaultValue: function(record, key) {
|
|
35
|
+
var array = [];
|
|
36
|
+
array.pushObject(record.createNestedRecord(NestedRecord.ChildRecordTest1));
|
|
37
|
+
return array;
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
|
|
41
|
+
defaultPolymorphicElements: SC.Record.toMany('SC.Record', {
|
|
42
|
+
isNested: true,
|
|
43
|
+
defaultValue: function(record, key) {
|
|
44
|
+
var array = [];
|
|
45
|
+
array.pushObject(record.createNestedRecord(SC.Record, {
|
|
46
|
+
type: 'ChildRecordTest1',
|
|
47
|
+
name: 'Default Child 1',
|
|
48
|
+
value: 'burninate'
|
|
49
|
+
}));
|
|
50
|
+
return array;
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
});
|
|
31
54
|
};
|
|
32
55
|
|
|
56
|
+
|
|
33
57
|
// ..........................................................
|
|
34
58
|
// Basic SC.Record with an Array of Children
|
|
35
59
|
//
|
|
@@ -162,7 +186,23 @@ test("Basic Read", function() {
|
|
|
162
186
|
var cr = arrayOfCRs.objectAt(0);
|
|
163
187
|
ok(SC.kindOf(cr, SC.Record), "check that first ChildRecord from the get() creates an actual instance that is a kind of a SC.Record Object");
|
|
164
188
|
ok(SC.instanceOf(cr, NestedRecord.ChildRecordTest1), "check that first ChildRecord from the get() creates an actual instance of a ChildRecordTest1 Object");
|
|
165
|
-
|
|
189
|
+
|
|
190
|
+
// Test Default Child Record creation
|
|
191
|
+
var arrayOfDRs = testParent.get('defaultElements');
|
|
192
|
+
ok(SC.instanceOf(arrayOfDRs, SC.ChildArray), "check that get() creates an actual instance of a SC.ChildArray");
|
|
193
|
+
equals(arrayOfDRs.get('length'), 1, "check that the length of the array of default records is 1");
|
|
194
|
+
var dr = arrayOfDRs.objectAt(0);
|
|
195
|
+
ok(SC.kindOf(dr, SC.Record), "check that first default ChildRecord from the get() creates an actual instance that is a kind of a SC.Record Object");
|
|
196
|
+
ok(SC.instanceOf(dr, NestedRecord.ChildRecordTest1), "check that first default ChildRecord from the get() creates an actual instance of a ChildRecordTest1 Object");
|
|
197
|
+
|
|
198
|
+
// Test Default Polymorphic Child Record creation
|
|
199
|
+
var arrayOfDPRs = testParent.get('defaultPolymorphicElements');
|
|
200
|
+
ok(SC.instanceOf(arrayOfDPRs, SC.ChildArray), "check that get() creates an actual instance of a SC.ChildArray");
|
|
201
|
+
equals(arrayOfDPRs.get('length'), 1, "check that the length of the array of default records is 1");
|
|
202
|
+
var dpr = arrayOfDPRs.objectAt(0);
|
|
203
|
+
ok(SC.kindOf(dpr, SC.Record), "check that first default polymorphic ChildRecord from the get() creates an actual instance that is a kind of a SC.Record Object");
|
|
204
|
+
ok(SC.instanceOf(dpr, NestedRecord.ChildRecordTest1), "check that first default polymorphic ChildRecord from the get() creates an actual instance of a ChildRecordTest1 Object");
|
|
205
|
+
|
|
166
206
|
// Check reference information
|
|
167
207
|
var pm = cr.get('primaryKey');
|
|
168
208
|
var key = cr.get(pm);
|
|
@@ -170,7 +210,7 @@ test("Basic Read", function() {
|
|
|
170
210
|
ok(storeRef, 'check that first ChildRecord that the store has the instance of the child record with proper primary key');
|
|
171
211
|
equals(cr, storeRef, "check the parent reference to the first child is the same as the direct store reference");
|
|
172
212
|
|
|
173
|
-
// Check to see if the attributes of a Child Record match the
|
|
213
|
+
// Check to see if the attributes of a Child Record match the reference of the parent
|
|
174
214
|
var parentArray = testParent.readAttribute('elements');
|
|
175
215
|
ok(!SC.instanceOf(parentArray, SC.ChildArray), "check that get() creates an actual instance of a SC.ChildArray");
|
|
176
216
|
same(parentArray[0], storeRef.get('attributes'), "check that the ChildRecord's attributes are the same as the ParentRecord's readAttribute for the reference");
|
|
@@ -234,7 +274,7 @@ test("Basic Write: reference tests", function() {
|
|
|
234
274
|
ok(testParent.get('status') & SC.Record.DIRTY, 'check that the parent record is dirty');
|
|
235
275
|
newElems = testParent.get('elements');
|
|
236
276
|
var newCR = newElems.objectAt(0);
|
|
237
|
-
same(newCR, cr, "after a set('name', <new>) on child, checking to see that the parent has
|
|
277
|
+
same(newCR, cr, "after a set('name', <new>) on child, checking to see that the parent has received the changes from the child record");
|
|
238
278
|
var readAttrsArray = testParent.readAttribute('elements');
|
|
239
279
|
ok(readAttrsArray, "checks to make sure the readAttibute works with a change to the name in the first child.");
|
|
240
280
|
equals(readAttrsArray.length, 4, "after set() on parent, check that the length of the attribute array of child records is 4");
|
|
@@ -118,7 +118,7 @@ module("Complex SC.Record: Parent > Array of Children > Array of Children", {
|
|
|
118
118
|
delete NestedRecord.Group;
|
|
119
119
|
delete NestedRecord.Person;
|
|
120
120
|
delete NestedRecord.Address;
|
|
121
|
-
delete window.NestedRecord;
|
|
121
|
+
//delete window.NestedRecord;
|
|
122
122
|
NestedRecord = null;
|
|
123
123
|
testParent = null;
|
|
124
124
|
peopleData1 = null;
|
|
@@ -196,7 +196,7 @@ test("Basic Read, Testing the First Child Array", function() {
|
|
|
196
196
|
ok(pStore, 'check that first ChildRecord that the store has the instance of the child record with proper primary key');
|
|
197
197
|
equals(p, pStore, "check the parent reference to the first child is the same as the direct store reference");
|
|
198
198
|
|
|
199
|
-
// Check to see if the attributes of a Child Record match the
|
|
199
|
+
// Check to see if the attributes of a Child Record match the reference of the parent
|
|
200
200
|
pplAttr = testParent.readAttribute('people');
|
|
201
201
|
ok(!SC.instanceOf(pplAttr, SC.ChildArray), "check that readAttribute() does not create an actual instance of a SC.ChildArray");
|
|
202
202
|
same(pplAttr[0], pStore.get('attributes'), "check that the ChildRecord's attributes are the same as the ParentRecord's readAttribute for the reference");
|
|
@@ -237,7 +237,7 @@ test("Basic Read, Testing the Second Child Array", function() {
|
|
|
237
237
|
ok(aStore, 'check that first ChildRecord that the store has the instance of the child record with proper primary key');
|
|
238
238
|
equals(a, aStore, "check the parent reference to the first child is the same as the direct store reference");
|
|
239
239
|
|
|
240
|
-
// Check to see if the attributes of a Child Record match the
|
|
240
|
+
// Check to see if the attributes of a Child Record match the reference of the parent
|
|
241
241
|
addrsAttr = p.readAttribute('addresses');
|
|
242
242
|
ok(!SC.instanceOf(addrsAttr, SC.ChildArray), "check that readAttribute() does not create an actual instance of a SC.ChildArray");
|
|
243
243
|
same(addrsAttr[0], aStore.get('attributes'), "check that the ChildRecord's attributes are the same as the ParentRecord's readAttribute for the reference");
|
|
@@ -274,7 +274,7 @@ test("Basic Write: Testing the First Child Array", function() {
|
|
|
274
274
|
ok(SC.kindOf(p, SC.Record), "check that first ChildRecord from the get() creates an actual instance that is a kind of a SC.Record Object");
|
|
275
275
|
ok(SC.instanceOf(p, NestedRecord.Person), "check that first ChildRecord from the get() creates an actual instance of a Person Object");
|
|
276
276
|
|
|
277
|
-
// TODO: [EG] Add test to make sure the number of ChildRecords in store is correct when we add store
|
|
277
|
+
// TODO: [EG] Add test to make sure the number of ChildRecords in store is correct when we add store record clearing
|
|
278
278
|
|
|
279
279
|
// Check reference information
|
|
280
280
|
pm = p.get('primaryKey');
|
|
@@ -66,7 +66,7 @@ module("Basic SC.Record Functions w/ a Parent > Child > Child", {
|
|
|
66
66
|
delete NestedRecord.ParentRecordTest;
|
|
67
67
|
delete NestedRecord.Person;
|
|
68
68
|
delete NestedRecord.Address;
|
|
69
|
-
delete window.NestedRecord;
|
|
69
|
+
//delete window.NestedRecord;
|
|
70
70
|
NestedRecord = null;
|
|
71
71
|
testParent = null;
|
|
72
72
|
store = null;
|
|
@@ -278,14 +278,14 @@ function() {
|
|
|
278
278
|
ok(testParent.get('status') & SC.Record.DIRTY, 'check that the parent record is dirty');
|
|
279
279
|
oldP = p;
|
|
280
280
|
p = testParent.get('person');
|
|
281
|
-
same(p, oldP, "after a set('name', <new>) on child, checking to see that the parent has
|
|
281
|
+
same(p, oldP, "after a set('name', <new>) on child, checking to see that the parent has received the changes from the child record");
|
|
282
282
|
same(testParent.readAttribute('person'), p.get('attributes'), "after a set('name', <new>) on child, readAttribute on the parent should be correct for info child attributes");
|
|
283
283
|
|
|
284
284
|
// Check changes on the address
|
|
285
285
|
a = testParent.getPath('person.address');
|
|
286
286
|
a.set('street', '321 Nutty Professor Lane');
|
|
287
287
|
parentAttrs = testParent.readAttribute('person');
|
|
288
|
-
same(a.get('attributes'), parentAttrs.address, "after a set('street', <new>) on address child, checking to see that the parent has
|
|
288
|
+
same(a.get('attributes'), parentAttrs.address, "after a set('street', <new>) on address child, checking to see that the parent has received the changes from the child record");
|
|
289
289
|
});
|
|
290
290
|
|
|
291
291
|
test("Basic normalize()", function() {
|
|
@@ -23,7 +23,7 @@ module("SC.Record#destroy", {
|
|
|
23
23
|
|
|
24
24
|
MyApp.foo = MyApp.store.createRecord(MyApp.Foo, MyApp.json);
|
|
25
25
|
|
|
26
|
-
// modify store so that
|
|
26
|
+
// modify store so that every time refreshRecords() is called it updates
|
|
27
27
|
// callInfo
|
|
28
28
|
callInfo = null ;
|
|
29
29
|
MyApp.store.__orig = MyApp.store.destroyRecord;
|
|
@@ -23,7 +23,7 @@ module("SC.Record#refresh", {
|
|
|
23
23
|
|
|
24
24
|
MyApp.foo = MyApp.store.createRecord(MyApp.Foo, MyApp.json);
|
|
25
25
|
|
|
26
|
-
// modify store so that
|
|
26
|
+
// modify store so that every time refreshRecords() is called it updates
|
|
27
27
|
// callInfo
|
|
28
28
|
callInfo = null ;
|
|
29
29
|
MyApp.store.refreshRecord = function(records) {
|
|
@@ -138,7 +138,7 @@ test("pass-through should return builtin value" ,function() {
|
|
|
138
138
|
equals(rec.get('firstName'), 'John', 'reading prop should get attr value');
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
-
test("returns default value if
|
|
141
|
+
test("returns default value if underlying value is empty", function() {
|
|
142
142
|
equals(rec.get('defaultValue'), 'default', 'reading prop should return default value');
|
|
143
143
|
});
|
|
144
144
|
|
|
@@ -14,9 +14,9 @@ module("SC.RecordAttribute core methods", {
|
|
|
14
14
|
MyApp = SC.Object.create({
|
|
15
15
|
store: SC.Store.create()
|
|
16
16
|
});
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
MyApp.Foo = SC.Record.extend({
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
// test toOne relationships
|
|
21
21
|
relatedTo: SC.Record.toOne('MyApp.Foo'),
|
|
22
22
|
|
|
@@ -24,93 +24,93 @@ module("SC.RecordAttribute core methods", {
|
|
|
24
24
|
readOnlyRelatedTo: SC.Record.toOne('MyApp.Bar', {
|
|
25
25
|
isEditable: NO
|
|
26
26
|
}),
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
// test toOne relationship with computed type
|
|
29
29
|
relatedToComputed: SC.Record.toOne(function() {
|
|
30
|
-
// not using .get() to avoid another transform which will
|
|
30
|
+
// not using .get() to avoid another transform which will
|
|
31
31
|
// trigger an infinite loop
|
|
32
32
|
return (this.readAttribute('relatedToComputed').indexOf("foo")===0) ? MyApp.Foo : MyApp.Bar;
|
|
33
33
|
}),
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
bar: SC.Record.toOne('MyApp.Bar', { inverse: 'foo' }),
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
barKeyed: SC.Record.toOne('MyApp.Bar', { key: 'barId' })
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
});
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
MyApp.Bar = SC.Record.extend({
|
|
42
42
|
foo: SC.Record.toOne('MyApp.Foo', { inverse: 'bar', isMaster: NO })
|
|
43
43
|
});
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
SC.RunLoop.begin();
|
|
46
46
|
storeKeys = MyApp.store.loadRecords(MyApp.Foo, [
|
|
47
|
-
{
|
|
48
|
-
guid: 'foo1',
|
|
49
|
-
firstName: "John",
|
|
50
|
-
lastName: "Doe",
|
|
47
|
+
{
|
|
48
|
+
guid: 'foo1',
|
|
49
|
+
firstName: "John",
|
|
50
|
+
lastName: "Doe",
|
|
51
51
|
date: "2009-03-01T20:30-08:00",
|
|
52
52
|
anArray: ['one', 'two', 'three'],
|
|
53
53
|
anObject: { 'key1': 'value1', 'key2': 'value2' },
|
|
54
54
|
bar: "bar1"
|
|
55
55
|
},
|
|
56
|
-
|
|
57
|
-
{
|
|
58
|
-
guid: 'foo2',
|
|
59
|
-
firstName: "Jane",
|
|
60
|
-
lastName: "Doe",
|
|
56
|
+
|
|
57
|
+
{
|
|
58
|
+
guid: 'foo2',
|
|
59
|
+
firstName: "Jane",
|
|
60
|
+
lastName: "Doe",
|
|
61
61
|
relatedTo: 'foo1',
|
|
62
62
|
anArray: 'notAnArray',
|
|
63
63
|
anObject: 'notAnObject',
|
|
64
64
|
nonIsoDate: "2009/06/10 8:55:50 +0000"
|
|
65
65
|
},
|
|
66
|
-
|
|
67
|
-
{
|
|
68
|
-
guid: 'foo3',
|
|
69
|
-
firstName: "Alex",
|
|
70
|
-
lastName: "Doe",
|
|
66
|
+
|
|
67
|
+
{
|
|
68
|
+
guid: 'foo3',
|
|
69
|
+
firstName: "Alex",
|
|
70
|
+
lastName: "Doe",
|
|
71
71
|
relatedToComputed: 'bar1',
|
|
72
72
|
anArray: ['one', 'two', 'three'],
|
|
73
73
|
anObject: { 'key1': 'value1', 'key2': 'value2' },
|
|
74
74
|
bar: "bar2"
|
|
75
75
|
},
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
{
|
|
78
78
|
guid: 'foo4',
|
|
79
79
|
firstName: 'Joe',
|
|
80
80
|
lastName: 'Schmo',
|
|
81
81
|
barId: 'bar1'
|
|
82
82
|
},
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
guid: 'foo5',
|
|
86
|
-
firstName: "Jane",
|
|
87
|
-
lastName: "Doe",
|
|
83
|
+
|
|
84
|
+
{
|
|
85
|
+
guid: 'foo5',
|
|
86
|
+
firstName: "Jane",
|
|
87
|
+
lastName: "Doe",
|
|
88
88
|
readOnlyRelatedTo: 'bar1'
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
]);
|
|
92
|
-
|
|
92
|
+
|
|
93
93
|
MyApp.store.loadRecords(MyApp.Bar, [
|
|
94
94
|
{ guid: 'bar1', city: "Chicago", foo: "foo1" },
|
|
95
95
|
{ guid: "bar2", city: "New York", foo: 'foo3' }
|
|
96
96
|
]);
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
SC.RunLoop.end();
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
rec = MyApp.store.find(MyApp.Foo, 'foo1');
|
|
101
101
|
rec2 = MyApp.store.find(MyApp.Foo, 'foo2');
|
|
102
|
-
|
|
102
|
+
|
|
103
103
|
bar = MyApp.store.find(MyApp.Bar, 'bar1');
|
|
104
104
|
bar2 = MyApp.store.find(MyApp.Bar, 'bar2');
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
equals(rec.storeKey, storeKeys[0], 'should find record');
|
|
107
|
-
|
|
107
|
+
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
// ..........................................................
|
|
112
112
|
// READING
|
|
113
|
-
//
|
|
113
|
+
//
|
|
114
114
|
|
|
115
115
|
test("getting toOne relationship should map guid to a real record", function() {
|
|
116
116
|
var rec2 = MyApp.store.find(MyApp.Foo, 'foo2');
|
|
@@ -126,7 +126,7 @@ test("getting toOne relationship from computed attribute should map guid to a re
|
|
|
126
126
|
|
|
127
127
|
test("reading an inverse relationship", function() {
|
|
128
128
|
equals(rec.get('bar'), bar, 'foo1.bar should == bar');
|
|
129
|
-
equals(bar.get('foo'), rec, 'bar.foo should == foo1');
|
|
129
|
+
equals(bar.get('foo'), rec, 'bar.foo should == foo1');
|
|
130
130
|
});
|
|
131
131
|
|
|
132
132
|
test("reading a keyed relationship", function(){
|
|
@@ -136,7 +136,7 @@ test("reading a keyed relationship", function(){
|
|
|
136
136
|
|
|
137
137
|
// ..........................................................
|
|
138
138
|
// WRITING
|
|
139
|
-
//
|
|
139
|
+
//
|
|
140
140
|
|
|
141
141
|
test("writing to a to-one relationship should update set guid", function() {
|
|
142
142
|
var rec2 = MyApp.store.find(MyApp.Foo, 'foo2');
|
|
@@ -147,7 +147,7 @@ test("writing to a to-one relationship should update set guid", function() {
|
|
|
147
147
|
rec2.set('relatedTo', rec2);
|
|
148
148
|
|
|
149
149
|
equals(rec2.readAttribute('relatedTo'), 'foo2', 'should write ID for set record to relatedTo attribute');
|
|
150
|
-
|
|
150
|
+
|
|
151
151
|
equals(rec2.get('relatedTo'), rec2, 'should get foo record that was just set');
|
|
152
152
|
|
|
153
153
|
});
|
|
@@ -156,14 +156,14 @@ test("writing to a to-one computed relationship should update set guid", functio
|
|
|
156
156
|
var rec3 = MyApp.store.find(MyApp.Foo, 'foo3');
|
|
157
157
|
equals(rec3.get('id'), 'foo3', 'precond - should find record 2');
|
|
158
158
|
equals(rec3.get('relatedToComputed'), bar, 'precond - should get bar1 instance for rec3.relatedToComputed');
|
|
159
|
-
|
|
159
|
+
|
|
160
160
|
rec3.set('relatedToComputed', rec);
|
|
161
161
|
equals(rec3.readAttribute('relatedToComputed'), 'foo1', 'should write ID for set record to relatedTo attribute');
|
|
162
162
|
});
|
|
163
163
|
|
|
164
164
|
test("clearing a toOne relationship", function() {
|
|
165
165
|
ok(rec2.get('relatedTo') !== null, 'precond - rec.relatedTo should have a value');
|
|
166
|
-
|
|
166
|
+
|
|
167
167
|
rec2.set('relatedTo', null);
|
|
168
168
|
equals(rec2.get('relatedTo'), null, 'rec.relatedTo should be null');
|
|
169
169
|
equals(rec2.readAttribute('relatedTo'), null, 'rec.relatedTo attribute should be null');
|
|
@@ -175,69 +175,69 @@ test("clearing a toOne relationship with an inverse - foo isMaster", function()
|
|
|
175
175
|
|
|
176
176
|
equals(rec.get('status'), SC.Record.READY_CLEAN, 'precond - foo1.status should be READY_CLEAN');
|
|
177
177
|
equals(bar.get('status'), SC.Record.READY_CLEAN, 'precond - bar1.status should be READY_CLEAN');
|
|
178
|
-
|
|
178
|
+
|
|
179
179
|
rec.set('bar', null);
|
|
180
|
-
|
|
180
|
+
|
|
181
181
|
equals(rec.get('bar'), null, 'foo1.bar should be null after change');
|
|
182
182
|
equals(bar.get('foo'), null, 'bar.foo should also be null after change');
|
|
183
|
-
|
|
183
|
+
|
|
184
184
|
equals(rec.get('status'), SC.Record.READY_DIRTY, 'foo1.status should be READY_DIRTY');
|
|
185
185
|
equals(bar.get('status'), SC.Record.READY_CLEAN, 'bar1.status should be READY_CLEAN');
|
|
186
|
-
|
|
186
|
+
|
|
187
187
|
});
|
|
188
188
|
|
|
189
189
|
test("modifying a toOne relationship with an inverse from null", function() {
|
|
190
190
|
equals(rec.get('bar'), bar, 'precond - foo1.bar should eq bar');
|
|
191
191
|
equals(bar.get('foo'), rec, 'precond - bar.foo should eq foo1');
|
|
192
192
|
equals(rec2.get('bar'), null, 'precond - foo2.bar should eq null');
|
|
193
|
-
|
|
193
|
+
|
|
194
194
|
[rec, rec2, bar].forEach(function(r) {
|
|
195
195
|
equals(r.get('status'), SC.Record.READY_CLEAN, 'precond - %@.status should be READY_CLEAN'.fmt(r.get('id')));
|
|
196
196
|
}, this);
|
|
197
|
-
|
|
197
|
+
|
|
198
198
|
bar.set('foo', rec2);
|
|
199
|
-
|
|
199
|
+
|
|
200
200
|
equals(rec.get('bar'), null, 'foo1.bar should be null after change');
|
|
201
201
|
equals(bar.get('foo'), rec2, 'bar.foo should eq foo2 after change');
|
|
202
202
|
equals(rec2.get('bar'), bar, 'foo2.bar should eq bar after change');
|
|
203
|
-
|
|
203
|
+
|
|
204
204
|
equals(rec.get('status'), SC.Record.READY_DIRTY, 'foo1.status should be READY_DIRTY');
|
|
205
205
|
equals(rec2.get('status'), SC.Record.READY_DIRTY, 'foo1.status should be READY_DIRTY');
|
|
206
206
|
equals(bar.get('status'), SC.Record.READY_CLEAN, 'bar1.status should be READY_CLEAN');
|
|
207
|
-
|
|
207
|
+
|
|
208
208
|
});
|
|
209
209
|
|
|
210
210
|
test("modifying a toOne relationship with an inverse from other", function() {
|
|
211
|
-
|
|
212
|
-
var foo1 = rec,
|
|
211
|
+
|
|
212
|
+
var foo1 = rec,
|
|
213
213
|
foo3 = MyApp.store.find(MyApp.Foo, 'foo3'),
|
|
214
214
|
bar1 = bar;
|
|
215
|
-
|
|
215
|
+
|
|
216
216
|
equals(foo1.get('bar'), bar1, 'precond - foo1.bar should eq bar1');
|
|
217
217
|
equals(bar1.get('foo'), foo1, 'precond - bar.foo should eq foo1');
|
|
218
|
-
|
|
218
|
+
|
|
219
219
|
equals(foo3.get('bar'), bar2, 'precond - foo3.bar should eq null');
|
|
220
220
|
equals(bar2.get('foo'), foo3, 'precond - bar2.foo should eq foo3');
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
|
|
222
|
+
|
|
223
223
|
[foo1, foo3, bar1, bar2].forEach(function(r) {
|
|
224
224
|
equals(r.get('status'), SC.Record.READY_CLEAN, 'precond - %@.status should be READY_CLEAN'.fmt(r.get('id')));
|
|
225
225
|
}, this);
|
|
226
|
-
|
|
226
|
+
|
|
227
227
|
bar1.set('foo', foo3);
|
|
228
|
-
|
|
228
|
+
|
|
229
229
|
equals(foo1.get('bar'), null, 'foo1.bar should be null after change');
|
|
230
230
|
equals(bar1.get('foo'), foo3, 'bar.foo should eq foo3 after change');
|
|
231
231
|
|
|
232
232
|
equals(foo3.get('bar'), bar1, 'foo3.bar should be bar after change');
|
|
233
233
|
equals(bar2.get('foo'), null, 'bar2.foo should eq null after change');
|
|
234
|
-
|
|
234
|
+
|
|
235
235
|
equals(foo1.get('status'), SC.Record.READY_DIRTY, 'foo1.status should be READY_DIRTY');
|
|
236
236
|
equals(foo1.get('status'), SC.Record.READY_DIRTY, 'foo1.status should be READY_DIRTY');
|
|
237
237
|
|
|
238
238
|
equals(bar1.get('status'), SC.Record.READY_CLEAN, 'bar1.status should be READY_CLEAN');
|
|
239
239
|
equals(bar2.get('status'), SC.Record.READY_CLEAN, 'bar1.status should be READY_CLEAN');
|
|
240
|
-
|
|
240
|
+
|
|
241
241
|
});
|
|
242
242
|
|
|
243
243
|
test("modifying a keyed toOne relationship", function(){
|
|
@@ -255,9 +255,9 @@ test("isEditable NO should not allow editing", function() {
|
|
|
255
255
|
|
|
256
256
|
equals(rec5.get('readOnlyRelatedTo'), bar1, 'precond - should find bar1');
|
|
257
257
|
equals(rec5.get('status'), SC.Record.READY_CLEAN, 'precond - foo5 should be READY_CLEAN');
|
|
258
|
-
|
|
258
|
+
|
|
259
259
|
rec5.set('readOnlyRelatedTo', bar2);
|
|
260
|
-
|
|
260
|
+
|
|
261
261
|
equals(rec5.get('readOnlyRelatedTo'), bar1, 'should still find bar1 after setting');
|
|
262
262
|
equals(rec5.get('status'), SC.Record.READY_CLEAN, 'foo5 status is still READY_CLEAN');
|
|
263
263
|
});
|
|
@@ -268,17 +268,17 @@ test("isEditable NO should not fire property change observer", function() {
|
|
|
268
268
|
var rec5 = MyApp.store.find(MyApp.Foo, 'foo5');
|
|
269
269
|
|
|
270
270
|
equals(rec5.get('readOnlyRelatedTo'), bar1, 'precond - should find bar1');
|
|
271
|
-
|
|
271
|
+
|
|
272
272
|
var readOnlyWasModified = NO;
|
|
273
273
|
var modifierListener = function() {
|
|
274
274
|
readOnlyWasModified = YES;
|
|
275
275
|
};
|
|
276
276
|
rec5.addObserver('readOnlyRelatedTo', modifierListener);
|
|
277
|
-
|
|
277
|
+
|
|
278
278
|
rec5.set('readOnlyRelatedTo', bar2);
|
|
279
|
-
|
|
279
|
+
|
|
280
280
|
equals(readOnlyWasModified, NO, 'property change observer should not have fired');
|
|
281
|
-
|
|
281
|
+
|
|
282
282
|
rec5.removeObserver('readOnlyRelatedTo', modifierListener);
|
|
283
283
|
});
|
|
284
284
|
|
|
@@ -308,3 +308,50 @@ test("adding toMany pointing to non existing class should throw error", function
|
|
|
308
308
|
same(message, 'Attempted to create toMany attribute with undefined recordType. Did you forget to sc_require a dependency?');
|
|
309
309
|
});
|
|
310
310
|
|
|
311
|
+
module("modifying a keyed toOne relationship via the inverse", {
|
|
312
|
+
setup: function() {
|
|
313
|
+
MyApp = SC.Object.create({ store: SC.Store.create() });
|
|
314
|
+
|
|
315
|
+
MyApp.Foo = SC.Record.extend({
|
|
316
|
+
bar: SC.Record.toOne('MyApp.Bar', {
|
|
317
|
+
isMaster: YES, inverse: 'foo'
|
|
318
|
+
})
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
MyApp.Bar = SC.Record.extend({
|
|
322
|
+
foo: SC.Record.toOne('MyApp.Foo', {
|
|
323
|
+
isMaster: NO, key: 'foo_id', inverse: 'bar'
|
|
324
|
+
})
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
test("creating an association", function() {
|
|
330
|
+
var foo1, bar1;
|
|
331
|
+
|
|
332
|
+
MyApp.store.loadRecords(MyApp.Foo, [{guid: 'foo1', bar: null}]);
|
|
333
|
+
|
|
334
|
+
foo1 = MyApp.store.find(MyApp.Foo, 'foo1');
|
|
335
|
+
bar1 = MyApp.store.createRecord(MyApp.Bar, {guid: 'bar1'});
|
|
336
|
+
|
|
337
|
+
foo1.set('bar', bar1);
|
|
338
|
+
|
|
339
|
+
equals(bar1.get('foo'), foo1, 'bar1.foo relationship should be established');
|
|
340
|
+
equals(bar1.get('attributes').foo_id, 'foo1', 'correct key should be set in attributes');
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
test("destroying an association", function() {
|
|
344
|
+
var foo1, bar1;
|
|
345
|
+
|
|
346
|
+
MyApp.store.loadRecords(MyApp.Foo, [{guid: 'foo1', bar: 'bar1'}]);
|
|
347
|
+
MyApp.store.loadRecords(MyApp.Bar, [{guid: 'bar1', foo_id: 'foo1'}]);
|
|
348
|
+
|
|
349
|
+
foo1 = MyApp.store.find(MyApp.Foo, 'foo1');
|
|
350
|
+
bar1 = MyApp.store.find(MyApp.Bar, 'bar1');
|
|
351
|
+
|
|
352
|
+
equals(foo1.get('bar'), bar1, 'foo1.bar relationship should be established');
|
|
353
|
+
foo1.set('bar', null);
|
|
354
|
+
equals(bar1.get('foo'), null, 'bar.foo relationship should be destroyed');
|
|
355
|
+
equals(bar1.get('attributes').foo_id, null, 'correct key should be set in attributes');
|
|
356
|
+
});
|
|
357
|
+
|