sproutcore 1.10.3.1 → 1.11.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG +4 -8
- data/VERSION.yml +2 -2
- data/lib/frameworks/sproutcore/Buildfile +5 -4
- data/lib/frameworks/sproutcore/CHANGELOG.md +274 -40
- data/lib/frameworks/sproutcore/CONTRIBUTORS.md +133 -0
- data/lib/frameworks/sproutcore/README.md +31 -144
- data/lib/frameworks/sproutcore/apps/showcase/controllers/source_tree_controller.js +9 -4
- data/lib/frameworks/sproutcore/apps/showcase/resources/stylesheet.css +5 -0
- data/lib/frameworks/sproutcore/apps/showcase/system/views_item_content.js +1 -1
- data/lib/frameworks/sproutcore/apps/showcase/views/split_views.js +15 -2
- data/lib/frameworks/sproutcore/apps/showcase/views/stacked_views.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/english.lproj/main_page.js +11 -1
- data/lib/frameworks/sproutcore/frameworks/ajax/mixins/websocket_delegate.js +90 -0
- data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +81 -5
- data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +23 -4
- data/lib/frameworks/sproutcore/frameworks/ajax/system/websocket.js +475 -0
- data/lib/frameworks/sproutcore/frameworks/ajax/tests/system/request.js +149 -26
- data/lib/frameworks/sproutcore/frameworks/ajax/tests/system/websocket.js +197 -0
- data/lib/frameworks/sproutcore/frameworks/ajax/tests/system/xhr_response_test.js +65 -0
- data/lib/frameworks/sproutcore/frameworks/bootstrap/system/loader.js +4 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/horizontal_stack_layout.js +232 -52
- data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/vertical_stack_layout.js +235 -49
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +23 -13
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/object.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/core.js +81 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/english.lproj/ordinal.js +17 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/string.js +7 -0
- data/lib/frameworks/sproutcore/frameworks/{desktop/tests/views/disclosure/methods.js → core_foundation/french.lproj/ordinal.js} +7 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/layout.js +2 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/main.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +104 -69
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane_statechart.js +6 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/child_view_layout_protocol.js +59 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/view_transition_protocol.js +18 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/application.js +192 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/bezier_curves.js +52 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/color.js +384 -64
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/core_query.js +6 -14
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/device.js +21 -35
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +72 -36
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +90 -34
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/platform.js +55 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/render_context.js +20 -15
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/req_anim_frame.js +9 -10
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +763 -542
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/selection_set.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +1 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/string.js +14 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/touch.js +538 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/utils/rect.js +56 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/array/array_case.js +99 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/object/single_case.js +25 -19
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/core_tests.js +75 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/ext/number_test.js +81 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/action_support.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/responder_context.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/string.js +19 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/color.js +36 -20
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/design_modes_test.js +83 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/makeMainPane.js +7 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/mouse_events.js +338 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/root_responder.js +14 -89
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/touch.js +106 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/sparse_array.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/touch.js +136 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/utils/rect.js +42 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/append_remove.js +11 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/child_view.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/design_mode_test.js +457 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/sendEvent.js +36 -10
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/background_color.js +44 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/border_frame_test.js +51 -24
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/childViewLayout_test.js +176 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/clippingFrame.js +46 -16
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/convertFrames.js +69 -15
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/didAppendToDocument.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout.js +7 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutDidChange.js +30 -10
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +376 -71
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/static_layout.js +0 -10
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/viewDidResize.js +117 -34
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view_states_test.js +52 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +656 -42
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +159 -38
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/cursor.js +0 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/design_mode.js +206 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/enabled.js +0 -28
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +21 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +372 -450
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +28 -13
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +22 -51
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/statechart.js +59 -30
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +0 -29
- data/lib/frameworks/sproutcore/frameworks/datastore/mixins/relationship_support.js +22 -10
- data/lib/frameworks/sproutcore/frameworks/datastore/models/children_attribute.js +42 -36
- data/lib/frameworks/sproutcore/frameworks/datastore/models/many_attribute.js +54 -3
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +178 -59
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/system/child_array.js +206 -132
- data/lib/frameworks/sproutcore/frameworks/datastore/system/many_array.js +214 -118
- data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +96 -13
- data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +14 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +82 -42
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +272 -177
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/integration/store_interaction_test.js +54 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/datetime_recordattribute.js +24 -16
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/many_attribute.js +6 -3
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/data_store.js +267 -35
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js +57 -46
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array.js +150 -53
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array_complex.js +57 -17
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_complex.js +13 -9
- data/lib/frameworks/sproutcore/frameworks/{experimental/frameworks/polymorphism → datastore}/tests/models/polymorphism/many.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/{experimental/frameworks/polymorphism → datastore}/tests/models/polymorphism/simple.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{experimental/frameworks/polymorphism → datastore}/tests/models/polymorphism/single.js +12 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/writeAttribute.js +20 -15
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +9 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/many_array/core_methods.js +80 -14
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/autonomous_dataSourceCallbacks.js +280 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/autonomous_pushChanges.js +232 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/chain.js +31 -5
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/parse.js +16 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/core_methods.js +60 -40
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/materializeRecord.js +78 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +13 -1
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/tests/system/datetime.js +20 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/{resources → english.lproj}/strings.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/french.lproj/strings.js +45 -0
- data/lib/frameworks/sproutcore/frameworks/designer/designers/object_designer.js +7 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_row_delegate.js +125 -44
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +139 -48
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/draggable.js +202 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +59 -56
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/palette.js +13 -49
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +466 -305
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_source.js +49 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/slider.js +79 -21
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/split.js +12 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/menu_item_view.css +8 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/overlay-scroller.css +187 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +94 -30
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/alert/ui.js +163 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/methods.js +97 -78
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/ui.js +61 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/methods.js +7 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/ui.js +47 -22
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/picker/methods.js +66 -9
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/picker/ui.js +21 -11
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/sheet/ui.js +12 -18
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/button/methods.js +17 -14
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/button/ui.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/methods.js +9 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/collection_fast_path.js +54 -21
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/content.js +52 -20
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/itemViewForContentIndex.js +94 -4
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/keyboard.js +177 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/layerIdFor.js +13 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/length.js +9 -9
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/mouse.js +18 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/date_field/methods.js +104 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/disclosure/ui.js +48 -49
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/grid/drag_and_drop.js +22 -18
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/grid/methods.js +17 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/link_view_test.js +136 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/contentIndexesInRect.js +77 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/drag_and_drop.js +53 -16
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/layoutForContentIndex.js +41 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowDelegate.js +25 -25
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowOffsetForContentIndex.js +102 -27
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/{rowHeightForContentIndex.js → rowSizeForContentIndex.js} +7 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/ui_outline.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/ui_row_heights.js +70 -75
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/ui_simple.js +29 -30
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list_item.js +57 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/menu_scroll_view/menu_scroll_view_test.js +206 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/progress/ui.js +15 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/radio/methods.js +15 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/integration.js +16 -11
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/methods.js +164 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/scale.js +387 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/touch.js +549 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/ui.js +214 -45
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroller.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/methods.js +73 -22
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +88 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select/methods.js +8 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/slider/methods.js +16 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/slider/ui.js +54 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/split/dividers.js +21 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/static_content.js +31 -25
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/tab/methods.js +109 -29
- data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +10 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +3 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +779 -603
- data/lib/frameworks/sproutcore/frameworks/desktop/views/date_field.js +106 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/link_view.js +406 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list.js +437 -245
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +13 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +124 -62
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +176 -597
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroller_view.js +206 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/popup_button.js +3 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/progress.js +5 -4
- data/lib/frameworks/sproutcore/frameworks/desktop/views/radio.js +3 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scene.js +56 -158
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll_view.js +2560 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroller.js +458 -242
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +117 -54
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select.js +18 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +162 -34
- data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +30 -15
- data/lib/frameworks/sproutcore/frameworks/desktop/views/split_divider.js +33 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +22 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/tab.js +47 -22
- data/lib/frameworks/sproutcore/frameworks/experimental/Buildfile +0 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form_row.js +21 -21
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu.js +14 -3
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/mixins/select_view_menu.js +24 -10
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/ext/menu_resizing.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/bindings.js +7 -4
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/check_selected.js +7 -9
- data/lib/frameworks/sproutcore/frameworks/{desktop/tests/panes/select_button/methods.js → experimental/frameworks/select_view/tests/views/select/method.js} +54 -76
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/select/selected_item.js +35 -0
- data/lib/frameworks/sproutcore/frameworks/{desktop/tests/panes/select_button → experimental/frameworks/select_view/tests/views/select}/ui.js +107 -36
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/select.js +225 -66
- data/lib/frameworks/sproutcore/frameworks/foundation/controllers/tree.js +39 -38
- data/lib/frameworks/sproutcore/frameworks/foundation/core.js +5 -18
- data/lib/frameworks/sproutcore/frameworks/foundation/debug/control_test_pane.js +12 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/english.lproj/inflections.js +84 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/french.lproj/inflections.js +41 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_mixin.js +1 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +7 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_display.js +3 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/flowed_layout.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/private/tree_item_observer.js +408 -239
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/canvas_image.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +2 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/spanish.lproj/inflections.js +38 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/system/benchmark.js +104 -76
- data/lib/frameworks/sproutcore/frameworks/foundation/system/string.js +20 -94
- data/lib/frameworks/sproutcore/frameworks/foundation/system/text_selection.js +33 -22
- data/lib/frameworks/sproutcore/frameworks/foundation/system/undo_manager.js +475 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/auto_resize_test.js +163 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/flowed_layout/tests.js +41 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/staticLayout.js +2 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/private/tree_item_observer/methods.js +268 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/undo_manager.js +231 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/ui.js +16 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/image/ui.js +27 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/methods.js +24 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +135 -6
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/fade_transition.js +6 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/pop_transition.js +7 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/scale_transition.js +6 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/slide_transition.js +4 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/swap_dissolve_transition.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/credit_card.js +21 -21
- data/lib/frameworks/sproutcore/frameworks/foundation/views/container.js +65 -15
- data/lib/frameworks/sproutcore/frameworks/foundation/views/image.js +4 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/views/label.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +193 -213
- data/lib/frameworks/sproutcore/frameworks/jquery/{jquery-1.8.3-patched.js → jquery-1.11.1.js} +7507 -6684
- data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js +28 -11
- data/lib/frameworks/sproutcore/frameworks/routing/tests/system/routes.js +26 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +54 -25
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/array.js +0 -6
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/number.js +36 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/window.js +25 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +156 -66
- data/lib/frameworks/sproutcore/frameworks/runtime/private/observer_set.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +150 -65
- data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +57 -11
- data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +68 -49
- data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +14 -6
- data/lib/frameworks/sproutcore/frameworks/runtime/system/string.js +23 -23
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/ext/number_test.js +44 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js +0 -10
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/enumerable/enumerable.js +340 -285
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +104 -3
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/observer_set.js +14 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/string.js +15 -2
- data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +21 -18
- data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +52 -19
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/event_handling/responder/pane.js +27 -24
- data/lib/frameworks/sproutcore/frameworks/template_view/controls/button.js +30 -0
- data/lib/frameworks/sproutcore/frameworks/template_view/ext/handlebars/bind.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/template_view/ext/handlebars/collection.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/template_view/ext/handlebars/view.js +1 -0
- data/lib/frameworks/sproutcore/frameworks/template_view/tests/mixins/template_helpers/checkbox_support.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/template_view/tests/views/template/handlebars.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/template_view/views/bindable_span.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/template_view/views/template_collection.js +16 -14
- data/lib/frameworks/sproutcore/frameworks/testing/core.js +5 -3
- data/lib/frameworks/sproutcore/frameworks/testing/system/plan.js +13 -0
- data/lib/frameworks/sproutcore/lib/index.rhtml +2 -2
- data/lib/frameworks/sproutcore/phantomjs/test_runner.js +28 -7
- data/lib/frameworks/sproutcore/scripts/run_sc_server_master.sh +1 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/_variables.css +2 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/disclosure/ace/disclosure.css +1 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/popover.css +3 -4
- data/lib/frameworks/sproutcore/themes/ace/resources/scroller/horizontal/horizontal.css +15 -15
- data/lib/frameworks/sproutcore/themes/ace/resources/scroller/horizontal/horizontal_overlay.css +74 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/scroller/vertical/vertical.css +11 -13
- data/lib/frameworks/sproutcore/themes/ace/resources/scroller/vertical/vertical_overlay.css +74 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/knob-active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/knob-active@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/knob.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/knob@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/{22px → jumbo}/slider.css +9 -4
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/track.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/track@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/knob-active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/knob-active@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/knob.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/knob@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/slider.css +32 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/track.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/track@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/slider.css +13 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/knob-active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/knob-active@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/knob.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/knob@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/slider.css +32 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/track.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/track@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/split/split.css +2 -3
- data/lib/sproutcore/builders/chance_file.rb +3 -3
- data/lib/sproutcore/helpers/minifier.rb +1 -0
- data/vendor/chance/lib/chance/instance.rb +34 -34
- data/vendor/chance/lib/chance/instance/spriting.rb +21 -16
- metadata +81 -58
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/visibility.js +0 -17
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_fast_path.js +0 -710
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/scrollable.js +0 -267
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/touch-scroller.css +0 -196
- data/lib/frameworks/sproutcore/frameworks/desktop/system/undo_manager.js +0 -224
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select_field/methods.js +0 -163
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select_field/ui.js +0 -177
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +0 -2053
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_button.js +0 -1024
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_field.js +0 -404
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/render_delegates/menu_scroller.js +0 -28
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/tests/menu/scroll.js +0 -235
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroll.js +0 -363
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroller.js +0 -250
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/README.md +0 -47
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/models/record.js +0 -134
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/desktop_scroller.js +0 -92
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/native_scroll.js +0 -25
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/scroll.js +0 -33
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/touch_scroller.js +0 -76
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/integration.js +0 -25
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/methods.js +0 -143
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/ui.js +0 -256
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroll.js +0 -1164
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroller.js +0 -332
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroll.js +0 -236
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroller.js +0 -347
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/scroll.js +0 -15
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/scroller.js +0 -10
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroll.js +0 -804
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroller.js +0 -133
- data/lib/frameworks/sproutcore/frameworks/foundation/tasks/preload_bundle.js +0 -41
- data/lib/frameworks/sproutcore/themes/ace/resources/scroller/horizontal/horizontal_touch.css +0 -91
- data/lib/frameworks/sproutcore/themes/ace/resources/scroller/vertical/vertical_touch.css +0 -92
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/14px/knob.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/14px/knob_active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/14px/slider.css +0 -27
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/16px/knob.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/16px/knob_active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/16px/slider.css +0 -27
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/22px/knob.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/22px/knob_active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/22px/track.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/track.png +0 -0
@@ -141,6 +141,51 @@ SC.NestedStore = SC.Store.extend(
|
|
141
141
|
return this ;
|
142
142
|
},
|
143
143
|
|
144
|
+
/**
|
145
|
+
Propagate this store's successful changes to its parent (if exists). At the end, it clears the
|
146
|
+
local, private status of the committed records therefore the method can be called several times
|
147
|
+
until the full transaction is successful or editing is abandoned
|
148
|
+
|
149
|
+
@param {Boolean} force if YES, does not check for conflicts first
|
150
|
+
@returns {SC.Store} receiver
|
151
|
+
*/
|
152
|
+
commitSuccessfulChanges: function(force) {
|
153
|
+
if (this.get('hasChanges') && this.chainedChanges) {
|
154
|
+
var chainedChanges = this.chainedChanges,
|
155
|
+
dataHashes = this.dataHashes,
|
156
|
+
revisions = this.revisions,
|
157
|
+
statuses = this.statuses,
|
158
|
+
editables = this.editables,
|
159
|
+
locks = this.locks;
|
160
|
+
var successfulChanges = chainedChanges.filter( function(storeKey) {
|
161
|
+
var state = this.readStatus(storeKey);
|
162
|
+
|
163
|
+
return state===SC.Record.READY_CLEAN || state===SC.Record.DESTROYED_CLEAN;
|
164
|
+
}, this );
|
165
|
+
var pstore = this.get('parentStore');
|
166
|
+
|
167
|
+
pstore.commitChangesFromNestedStore(this, successfulChanges, force);
|
168
|
+
|
169
|
+
// remove the local status so these records that have been successfully committed on the server
|
170
|
+
// are no longer retrieved from this nested store but from the parent
|
171
|
+
successfulChanges.forEach(function(storeKey)
|
172
|
+
{
|
173
|
+
if (dataHashes && dataHashes.hasOwnProperty(storeKey))
|
174
|
+
delete dataHashes[storeKey];
|
175
|
+
if (revisions && revisions.hasOwnProperty(storeKey))
|
176
|
+
delete revisions[storeKey];
|
177
|
+
if (editables) delete editables[storeKey];
|
178
|
+
if (locks) delete locks[storeKey];
|
179
|
+
if (statuses && statuses.hasOwnProperty(storeKey))
|
180
|
+
delete statuses[storeKey];
|
181
|
+
chainedChanges.remove( storeKey );
|
182
|
+
}, this );
|
183
|
+
|
184
|
+
}
|
185
|
+
|
186
|
+
return this;
|
187
|
+
},
|
188
|
+
|
144
189
|
/**
|
145
190
|
Discard the changes made to this store and reset the store.
|
146
191
|
|
@@ -250,6 +295,11 @@ SC.NestedStore = SC.Store.extend(
|
|
250
295
|
return parentStore ? parentStore.readQueryError(query) : null;
|
251
296
|
},
|
252
297
|
|
298
|
+
/** @private - adapt for nested store */
|
299
|
+
chainAutonomousStore: function(attrs, newStoreClass) {
|
300
|
+
throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
|
301
|
+
},
|
302
|
+
|
253
303
|
// ..........................................................
|
254
304
|
// CORE ATTRIBUTE API
|
255
305
|
//
|
@@ -482,7 +532,7 @@ SC.NestedStore = SC.Store.extend(
|
|
482
532
|
an error if the record is dirty. We'll otherwise avoid setting our status
|
483
533
|
because that can disconnect us from upper and/or lower stores.
|
484
534
|
*/
|
485
|
-
retrieveRecords: function(recordTypes, ids, storeKeys, isRefresh) {
|
535
|
+
retrieveRecords: function(recordTypes, ids, storeKeys, isRefresh, callbacks) {
|
486
536
|
var pstore = this.get('parentStore'), idx, storeKey, newStatus,
|
487
537
|
len = (!storeKeys) ? ids.length : storeKeys.length,
|
488
538
|
K = SC.Record, status;
|
@@ -536,27 +586,39 @@ SC.NestedStore = SC.Store.extend(
|
|
536
586
|
}
|
537
587
|
}
|
538
588
|
|
539
|
-
return pstore.retrieveRecords(recordTypes, ids, storeKeys, isRefresh);
|
589
|
+
return pstore.retrieveRecords(recordTypes, ids, storeKeys, isRefresh, callbacks);
|
540
590
|
},
|
541
591
|
|
542
592
|
/** @private - adapt for nested store */
|
543
593
|
commitRecords: function(recordTypes, ids, storeKeys) {
|
544
|
-
|
594
|
+
if( this.get( "dataSource" ) )
|
595
|
+
return sc_super();
|
596
|
+
else
|
597
|
+
throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
|
545
598
|
},
|
546
599
|
|
547
600
|
/** @private - adapt for nested store */
|
548
601
|
commitRecord: function(recordType, id, storeKey) {
|
549
|
-
|
602
|
+
if( this.get( "dataSource" ) )
|
603
|
+
return sc_super();
|
604
|
+
else
|
605
|
+
throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
|
550
606
|
},
|
551
607
|
|
552
608
|
/** @private - adapt for nested store */
|
553
609
|
cancelRecords: function(recordTypes, ids, storeKeys) {
|
554
|
-
|
610
|
+
if( this.get( "dataSource" ) )
|
611
|
+
return sc_super();
|
612
|
+
else
|
613
|
+
throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
|
555
614
|
},
|
556
615
|
|
557
616
|
/** @private - adapt for nested store */
|
558
617
|
cancelRecord: function(recordType, id, storeKey) {
|
559
|
-
|
618
|
+
if( this.get( "dataSource" ) )
|
619
|
+
return sc_super();
|
620
|
+
else
|
621
|
+
throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
|
560
622
|
},
|
561
623
|
|
562
624
|
// ..........................................................
|
@@ -566,22 +628,34 @@ SC.NestedStore = SC.Store.extend(
|
|
566
628
|
|
567
629
|
/** @private - adapt for nested store */
|
568
630
|
dataSourceDidCancel: function(storeKey) {
|
569
|
-
|
631
|
+
if( this.get( "dataSource" ) )
|
632
|
+
return sc_super();
|
633
|
+
else
|
634
|
+
throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
|
570
635
|
},
|
571
636
|
|
572
637
|
/** @private - adapt for nested store */
|
573
638
|
dataSourceDidComplete: function(storeKey, dataHash, newId) {
|
574
|
-
|
639
|
+
if( this.get( "dataSource" ) )
|
640
|
+
return sc_super();
|
641
|
+
else
|
642
|
+
throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
|
575
643
|
},
|
576
644
|
|
577
645
|
/** @private - adapt for nested store */
|
578
646
|
dataSourceDidDestroy: function(storeKey) {
|
579
|
-
|
647
|
+
if( this.get( "dataSource" ) )
|
648
|
+
return sc_super();
|
649
|
+
else
|
650
|
+
throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
|
580
651
|
},
|
581
652
|
|
582
653
|
/** @private - adapt for nested store */
|
583
654
|
dataSourceDidError: function(storeKey, error) {
|
584
|
-
|
655
|
+
if( this.get( "dataSource" ) )
|
656
|
+
return sc_super();
|
657
|
+
else
|
658
|
+
throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
|
585
659
|
},
|
586
660
|
|
587
661
|
// ..........................................................
|
@@ -590,17 +664,26 @@ SC.NestedStore = SC.Store.extend(
|
|
590
664
|
|
591
665
|
/** @private - adapt for nested store */
|
592
666
|
pushRetrieve: function(recordType, id, dataHash, storeKey) {
|
593
|
-
|
667
|
+
if( this.get( "dataSource" ) )
|
668
|
+
return sc_super();
|
669
|
+
else
|
670
|
+
throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
|
594
671
|
},
|
595
672
|
|
596
673
|
/** @private - adapt for nested store */
|
597
674
|
pushDestroy: function(recordType, id, storeKey) {
|
598
|
-
|
675
|
+
if( this.get( "dataSource" ) )
|
676
|
+
return sc_super();
|
677
|
+
else
|
678
|
+
throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
|
599
679
|
},
|
600
680
|
|
601
681
|
/** @private - adapt for nested store */
|
602
682
|
pushError: function(recordType, id, error, storeKey) {
|
603
|
-
|
683
|
+
if( this.get( "dataSource" ) )
|
684
|
+
return sc_super();
|
685
|
+
else
|
686
|
+
throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
|
604
687
|
}
|
605
688
|
|
606
689
|
}) ;
|
@@ -1186,10 +1186,20 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
1186
1186
|
if (l.length == 1) l = l[0];
|
1187
1187
|
else error.push('string did not resolve to a single tree');
|
1188
1188
|
|
1189
|
-
// error
|
1190
|
-
if (error.length > 0)
|
1191
|
-
|
1192
|
-
|
1189
|
+
// If we have errors, return an error object.
|
1190
|
+
if (error.length > 0) {
|
1191
|
+
return {
|
1192
|
+
error: error.join(',\n'),
|
1193
|
+
tree: l,
|
1194
|
+
// Conform to SC.Error.
|
1195
|
+
isError: YES,
|
1196
|
+
errorVal: function() { return this.error }
|
1197
|
+
};
|
1198
|
+
}
|
1199
|
+
// Otherwise the token list is now a tree and can be returned.
|
1200
|
+
else {
|
1201
|
+
return l;
|
1202
|
+
}
|
1193
1203
|
|
1194
1204
|
},
|
1195
1205
|
|
@@ -10,42 +10,53 @@ sc_require('models/record');
|
|
10
10
|
/**
|
11
11
|
@class
|
12
12
|
|
13
|
-
A `RecordArray`
|
14
|
-
|
15
|
-
convert the `storeKeys` into actual `SC.Record` objects that the rest of
|
16
|
-
your application can work with.
|
13
|
+
A `RecordArray` is a managed list of records (instances of your `SC.Record`
|
14
|
+
model classes).
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
Using RecordArrays
|
17
|
+
---
|
18
|
+
|
19
|
+
Most often, RecordArrays contain the results of a `SC.Query`. You will generally not
|
20
|
+
create or modify record arrays yourselves, instead using the ones returned from calls
|
21
|
+
to `SC.Store#find` with either a record type or a query.
|
22
|
+
|
23
|
+
The membership of these query-backed record arrays is managed by the store, which
|
24
|
+
searches already-loaded records for local queries, and defers to your data source
|
25
|
+
for remote ones (see `SC.Query` documentation for more details). Since membership
|
26
|
+
in these record arrays is managed by the store, you will not generally add, remove
|
27
|
+
or rearrange them here (see `isEditable` below).
|
22
28
|
|
23
|
-
|
24
|
-
|
25
|
-
|
29
|
+
Query-backed record arrays have a status property which reflects the store's progress
|
30
|
+
in fulfilling the query. See notes on `status` below.
|
31
|
+
|
32
|
+
(Note that instances of `SC.Query` are dumb descriptor objects which do not have a
|
33
|
+
status or results of their own. References to a query's status or results should be
|
34
|
+
understood to refer to those of its record array.)
|
26
35
|
|
27
36
|
Internal Notes
|
28
37
|
---
|
29
38
|
|
30
|
-
|
31
|
-
|
32
|
-
of `storeKeys`. The underlying array can be a real array or it may be a
|
33
|
-
`SparseArray`, which is how you implement incremental loading.
|
39
|
+
This section is about `RecordArray` internals, and is only intended for those
|
40
|
+
who need to extend this class to do something special.
|
34
41
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
changes. It will also ask the `Query` to refresh the `storeKeys` whenever
|
40
|
-
records change in the store.
|
42
|
+
A `RecordArray` wraps an array of store keys, listed on its `storeKeys`
|
43
|
+
property. If you request a record from the array, e.g. via `objectAt`,
|
44
|
+
the `RecordArray` will convert the requested store key to a record
|
45
|
+
suitable for public use.
|
41
46
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
The list of store keys is usually managed by the store. If you are using
|
48
|
+
your `RecordArray` with a query, you should manage the results via the
|
49
|
+
store, and not try to directly manipulate the results via the array. If you
|
50
|
+
are managing the array's store keys yourself, then any array-like operation
|
51
|
+
will be translated into similar calls on the underlying `storeKeys` array.
|
52
|
+
This underlying array can be a real array, or, if you wish to implement
|
53
|
+
incremental loading, it may be a `SparseArray`.
|
48
54
|
|
55
|
+
If the record array is created with an `SC.Query` object (as is almost always the
|
56
|
+
case), then the record array will also consult the query for various delegate
|
57
|
+
operations such as determining if the record array should update automatically
|
58
|
+
whenever records in the store changes. It will also ask the query to refresh the
|
59
|
+
`storeKeys` list whenever records change in the store.
|
49
60
|
|
50
61
|
@extends SC.Object
|
51
62
|
@extends SC.Enumerable
|
@@ -66,7 +77,7 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
|
66
77
|
query = this.get('query'),
|
67
78
|
length = this.get('length');
|
68
79
|
|
69
|
-
return "%@({\n query: %@,\n storeKeys: [%@],\n length: %@,\n … }) %@".fmt(
|
80
|
+
return "%@({\n query: %@,\n storeKeys: [%@],\n length: %@,\n … }) %@".fmt(sc_super(), query, storeKeys, length, statusString);
|
70
81
|
},
|
71
82
|
|
72
83
|
/** @private */
|
@@ -97,7 +108,7 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
|
97
108
|
store: null,
|
98
109
|
|
99
110
|
/**
|
100
|
-
The `Query` object this record array is based upon. All record arrays
|
111
|
+
The `SC.Query` object this record array is based upon. All record arrays
|
101
112
|
**MUST** have an associated query in order to function correctly. You
|
102
113
|
cannot change this property once it has been set.
|
103
114
|
|
@@ -115,17 +126,35 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
|
115
126
|
*/
|
116
127
|
storeKeys: null,
|
117
128
|
|
129
|
+
/** @private The cache of previous store keys so that we can avoid unnecessary updates. */
|
130
|
+
_prevStoreKeys: null,
|
131
|
+
|
118
132
|
/**
|
119
|
-
|
120
|
-
|
133
|
+
Reflects the store's current status in fulfilling the record array's query. Note
|
134
|
+
that this status is not directly related to the status of the array's records:
|
135
|
+
|
136
|
+
- The store returns local queries immediately, regardless of any first-time loading
|
137
|
+
they may trigger. (Note that by default, local queries are limited to 100ms
|
138
|
+
processing time per run loop, so very complex queries may take several run loops
|
139
|
+
to return to `READY` status. You can edit `SC.RecordArray.QUERY_MATCHING_THRESHOLD`
|
140
|
+
to change this duration.)
|
141
|
+
- The store fulfills remote queries by passing them to your data source's `fetch`
|
142
|
+
method. While fetching, it sets your array's status to `BUSY_LOADING` or
|
143
|
+
`BUSY_REFRESHING`. Once your data source has finished fetching (successfully or
|
144
|
+
otherwise), it will call the appropriate store methods (e.g. `dataSourceDidFetchQuery`
|
145
|
+
or `dataSourceDidErrorQuery`), which will update the query's array's status.
|
146
|
+
|
147
|
+
Thus, a record array may have a `READY` status while records are still loading (if
|
148
|
+
a local query triggers a call to `SC.DataSource#fetch`), and will not reflect the
|
149
|
+
`DIRTY` status of any of its records.
|
121
150
|
|
122
151
|
@type Number
|
123
152
|
*/
|
124
153
|
status: SC.Record.EMPTY,
|
125
154
|
|
126
155
|
/**
|
127
|
-
The current editable state
|
128
|
-
|
156
|
+
The current editable state of the query. If this record array is not backed by a
|
157
|
+
query, it is assumed to be editable.
|
129
158
|
|
130
159
|
@property
|
131
160
|
@type Boolean
|
@@ -255,7 +284,7 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
|
255
284
|
},
|
256
285
|
|
257
286
|
/**
|
258
|
-
Returns YES if the passed can be found in the record array. This is
|
287
|
+
Returns YES if the passed record can be found in the record array. This is
|
259
288
|
provided for compatibility with SC.Set.
|
260
289
|
|
261
290
|
@param {SC.Record} record
|
@@ -274,7 +303,10 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
|
274
303
|
*/
|
275
304
|
indexOf: function(record, startAt) {
|
276
305
|
if (!SC.kindOf(record, SC.Record)) {
|
277
|
-
|
306
|
+
//@if(debug)
|
307
|
+
SC.Logger.warn("Developer Warning: Used SC.RecordArray's `indexOf` on %@, which is not an SC.Record. SC.RecordArray only works with records.".fmt(record));
|
308
|
+
SC.Logger.trace();
|
309
|
+
//@endif
|
278
310
|
return -1; // only takes records
|
279
311
|
}
|
280
312
|
|
@@ -295,7 +327,10 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
|
295
327
|
*/
|
296
328
|
lastIndexOf: function(record, startAt) {
|
297
329
|
if (!SC.kindOf(record, SC.Record)) {
|
298
|
-
|
330
|
+
//@if(debug)
|
331
|
+
SC.Logger.warn("Developer Warning: Using SC.RecordArray's `lastIndexOf` on %@, which is not an SC.Record. SC.RecordArray only works with records.".fmt(record));
|
332
|
+
SC.Logger.trace();
|
333
|
+
//@endif
|
299
334
|
return -1; // only takes records
|
300
335
|
}
|
301
336
|
|
@@ -363,11 +398,12 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
|
363
398
|
},
|
364
399
|
|
365
400
|
/**
|
366
|
-
Will recompute the results
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
into
|
401
|
+
Will recompute the results of the attached `SC.Query`. Useful if your query
|
402
|
+
is based on computed properties that might have changed.
|
403
|
+
|
404
|
+
This method is for local use only, operating only on records that have already
|
405
|
+
been loaded into your store. If you wish to re-fetch a remote query via your
|
406
|
+
data source, use `refresh()` instead.
|
371
407
|
|
372
408
|
@returns {SC.RecordArray} receiver
|
373
409
|
*/
|
@@ -616,6 +652,11 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
|
616
652
|
// clear set of changed store keys
|
617
653
|
if (changed) changed.clear();
|
618
654
|
|
655
|
+
// Clear the flushing flag.
|
656
|
+
// NOTE: Do this now, because any observers of storeKeys could trigger a call
|
657
|
+
// to flush (ex. by calling get('length') on the RecordArray).
|
658
|
+
this._insideFlush = NO;
|
659
|
+
|
619
660
|
// only resort and update if we did change
|
620
661
|
if (didChange) {
|
621
662
|
|
@@ -630,7 +671,6 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
|
630
671
|
}
|
631
672
|
}
|
632
673
|
|
633
|
-
this._insideFlush = NO;
|
634
674
|
return this;
|
635
675
|
},
|
636
676
|
|
@@ -56,7 +56,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
56
56
|
/**
|
57
57
|
This type of store is not nested.
|
58
58
|
|
59
|
-
|
59
|
+
@default NO
|
60
60
|
@type Boolean
|
61
61
|
*/
|
62
62
|
isNested: NO,
|
@@ -64,7 +64,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
64
64
|
/**
|
65
65
|
This type of store is not nested.
|
66
66
|
|
67
|
-
|
67
|
+
@default NO
|
68
68
|
@type Boolean
|
69
69
|
*/
|
70
70
|
commitRecordsAutomatically: NO,
|
@@ -84,13 +84,13 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
84
84
|
@param {SC.DataSource|String} dataSource the data source
|
85
85
|
@returns {SC.Store} receiver
|
86
86
|
*/
|
87
|
-
from: function
|
87
|
+
from: function(dataSource) {
|
88
88
|
this.set('dataSource', dataSource);
|
89
89
|
return this ;
|
90
90
|
},
|
91
91
|
|
92
92
|
// lazily convert data source to real object
|
93
|
-
_getDataSource: function
|
93
|
+
_getDataSource: function() {
|
94
94
|
var ret = this.get('dataSource');
|
95
95
|
if (typeof ret === SC.T_STRING) {
|
96
96
|
ret = SC.requiredObjectForPropertyPath(ret);
|
@@ -108,7 +108,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
108
108
|
@param {SC.DataSource...} dataSource one or more data source arguments
|
109
109
|
@returns {SC.Store} receiver
|
110
110
|
*/
|
111
|
-
cascade: function
|
111
|
+
cascade: function(dataSource) {
|
112
112
|
var dataSources = SC.A(arguments) ;
|
113
113
|
dataSource = SC.CascadeDataSource.create({
|
114
114
|
dataSources: dataSources
|
@@ -134,7 +134,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
134
134
|
@param {Class} newStoreClass optional the class of the newly-created nested store (defaults to SC.NestedStore)
|
135
135
|
@returns {SC.NestedStore} new nested store chained to receiver
|
136
136
|
*/
|
137
|
-
chain: function
|
137
|
+
chain: function(attrs, newStoreClass) {
|
138
138
|
if (!attrs) attrs = {};
|
139
139
|
attrs.parentStore = this;
|
140
140
|
|
@@ -159,6 +159,51 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
159
159
|
return ret ;
|
160
160
|
},
|
161
161
|
|
162
|
+
/**
|
163
|
+
Creates an autonomous nested store that is connected to the data source.
|
164
|
+
Use this kind of nested store to ensure that all records that are committed into main store are first of all committed on the server.
|
165
|
+
|
166
|
+
ns = store.chainAutonomousStore();
|
167
|
+
... perform changes into the nested store
|
168
|
+
ns.commitRecords( ...,callback );
|
169
|
+
or...
|
170
|
+
newRecord.commitRecord( ..., callback );
|
171
|
+
|
172
|
+
into the callback method:
|
173
|
+
A. If using a transaction model: "all or nothing" where all rows are handled into a single transaction
|
174
|
+
|
175
|
+
if the transaction is successful, commit the successful changes into the main store and destroy:
|
176
|
+
ns.commitSuccessfulChanges();
|
177
|
+
ns.destroy();
|
178
|
+
|
179
|
+
if not successful, handle the error, allow corrections if needed, etc.
|
180
|
+
|
181
|
+
B. If using a transaction model: "independent rows" where the edited rows are independent and committed separately into the backend database
|
182
|
+
When only some of them have been accepted by the server, the overall transaction is only partially
|
183
|
+
successful therefore the nested store will contain rows with different statuses.
|
184
|
+
In such case, into the callback method only the accepted rows should be pushed to the main store using commitSuccessfulChanges()
|
185
|
+
|
186
|
+
ns.commitSuccessfulChanges();
|
187
|
+
...
|
188
|
+
if some of the rows were not accepted by the backend, allow corrections, attempt another commit, etc.:
|
189
|
+
ns.commitRecords( ...,callback );
|
190
|
+
... the callback will be invoked again
|
191
|
+
|
192
|
+
Important note: In the case of such configuration, in order to preserve the consistency of the main store with
|
193
|
+
the backend database, it is recommended to systematically call commitSuccessfulChanges() when receiving the answer from the server.
|
194
|
+
|
195
|
+
@param {Hash} attrs optional attributes to set on new store
|
196
|
+
@param {Class} newStoreClass optional the class of the newly-created nested store (defaults to SC.NestedStore)
|
197
|
+
@returns {SC.NestedStore} new nested store chained to receiver
|
198
|
+
*/
|
199
|
+
chainAutonomousStore: function(attrs, newStoreClass) {
|
200
|
+
var newAttrs = attrs ? SC.clone( attrs ) : {};
|
201
|
+
var source = this._getDataSource();
|
202
|
+
|
203
|
+
newAttrs.dataSource = source;
|
204
|
+
return this.chain( newAttrs, newStoreClass );
|
205
|
+
},
|
206
|
+
|
162
207
|
/** @private
|
163
208
|
|
164
209
|
Called by a nested store just before it is destroyed so that the parent
|
@@ -166,7 +211,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
166
211
|
|
167
212
|
@returns {SC.Store} receiver
|
168
213
|
*/
|
169
|
-
willDestroyNestedStore: function
|
214
|
+
willDestroyNestedStore: function(nestedStore) {
|
170
215
|
if (this.nestedStores) {
|
171
216
|
this.nestedStores.removeObject(nestedStore);
|
172
217
|
}
|
@@ -180,7 +225,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
180
225
|
@param {SC.Store} store store instance
|
181
226
|
@returns {Boolean} YES if belongs
|
182
227
|
*/
|
183
|
-
hasNestedStore: function
|
228
|
+
hasNestedStore: function(store) {
|
184
229
|
while(store && (store !== this)) store = store.get('parentStore');
|
185
230
|
return store === this ;
|
186
231
|
},
|
@@ -287,14 +332,14 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
287
332
|
// to use these methods.
|
288
333
|
|
289
334
|
/**
|
290
|
-
Returns the current edit status of a
|
335
|
+
Returns the current edit status of a store key. May be one of
|
291
336
|
`EDITABLE` or `LOCKED`. Used mostly for unit testing.
|
292
337
|
|
293
338
|
@param {Number} storeKey the store key
|
294
339
|
@returns {Number} edit status
|
295
340
|
*/
|
296
|
-
storeKeyEditState: function
|
297
|
-
var editables = this.editables
|
341
|
+
storeKeyEditState: function(storeKey) {
|
342
|
+
var editables = this.editables;
|
298
343
|
return (editables && editables[storeKey]) ? SC.Store.EDITABLE : SC.Store.LOCKED ;
|
299
344
|
},
|
300
345
|
|
@@ -306,7 +351,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
306
351
|
@param {Number} storeKey key to retrieve
|
307
352
|
@returns {Hash} data hash or null
|
308
353
|
*/
|
309
|
-
readDataHash: function
|
354
|
+
readDataHash: function(storeKey) {
|
310
355
|
return this.dataHashes[storeKey];
|
311
356
|
},
|
312
357
|
|
@@ -321,7 +366,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
321
366
|
@param {Number} storeKey the store key to retrieve
|
322
367
|
@returns {Hash} the attributes hash
|
323
368
|
*/
|
324
|
-
readEditableDataHash: function
|
369
|
+
readEditableDataHash: function(storeKey) {
|
325
370
|
// read the value - if there is no hash just return; nothing to do
|
326
371
|
var ret = this.dataHashes[storeKey];
|
327
372
|
if (!ret) return ret ; // nothing to do.
|
@@ -346,7 +391,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
346
391
|
@param {String} propertyName property to read
|
347
392
|
@returns {Object} editable property value
|
348
393
|
*/
|
349
|
-
readEditableProperty: function
|
394
|
+
readEditableProperty: function(storeKey, propertyName) {
|
350
395
|
var hash = this.readEditableDataHash(storeKey),
|
351
396
|
editables = this.editables[storeKey], // get editable info...
|
352
397
|
ret = hash[propertyName];
|
@@ -382,7 +427,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
382
427
|
@param {String} status the new hash status
|
383
428
|
@returns {SC.Store} receiver
|
384
429
|
*/
|
385
|
-
writeDataHash: function
|
430
|
+
writeDataHash: function(storeKey, hash, status) {
|
386
431
|
|
387
432
|
// update dataHashes and optionally status.
|
388
433
|
if (hash) this.dataHashes[storeKey] = hash;
|
@@ -393,15 +438,14 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
393
438
|
if (!editables) editables = this.editables = [];
|
394
439
|
editables[storeKey] = 1 ; // use number for dense array support
|
395
440
|
|
441
|
+
var processedPaths={};
|
396
442
|
// Update the child record hashes in place.
|
397
443
|
if (!SC.none(this.parentRecords) ) {
|
398
444
|
var children = this.parentRecords[storeKey] || {},
|
399
445
|
childHash;
|
400
446
|
|
401
447
|
for (var key in children) {
|
402
|
-
|
403
448
|
if (children.hasOwnProperty(key)) {
|
404
|
-
|
405
449
|
if (hash) {
|
406
450
|
var childPath = children[key];
|
407
451
|
childPath = childPath.split('.');
|
@@ -411,7 +455,24 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
411
455
|
childHash = hash[childPath[0]];
|
412
456
|
}
|
413
457
|
|
414
|
-
|
458
|
+
if (!processedPaths[hash[childPath[0]]]){
|
459
|
+
// update data hash: required to push changes beyond the first nesting level
|
460
|
+
this.writeDataHash(key, childHash, status);
|
461
|
+
}
|
462
|
+
|
463
|
+
if (childPath.length > 1 && ! processedPaths[hash[childPath[0]]]) {
|
464
|
+
// save it so that we don't processed it over and over
|
465
|
+
processedPaths[hash[childPath[0]]]=true;
|
466
|
+
|
467
|
+
// force fetching of all children records by invoking the children_attribute wrapper code
|
468
|
+
// and then interating the list in an empty loop
|
469
|
+
// Ugly, but there's basically no other way to do it at the moment, other than
|
470
|
+
// leaving this broken as it was before
|
471
|
+
var that = this;
|
472
|
+
this.invokeLast(function() {
|
473
|
+
that.records[storeKey].get(childPath[0]).forEach(function (it) {});
|
474
|
+
});
|
475
|
+
}
|
415
476
|
} else {
|
416
477
|
this.writeDataHash(key, null, status);
|
417
478
|
}
|
@@ -419,7 +480,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
419
480
|
}
|
420
481
|
}
|
421
482
|
|
422
|
-
return this;
|
483
|
+
return this ;
|
423
484
|
},
|
424
485
|
|
425
486
|
/**
|
@@ -439,7 +500,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
439
500
|
@param {String} status optional new status
|
440
501
|
@returns {SC.Store} receiver
|
441
502
|
*/
|
442
|
-
removeDataHash: function
|
503
|
+
removeDataHash: function(storeKey, status) {
|
443
504
|
// don't use delete -- that will allow parent dataHash to come through
|
444
505
|
this.dataHashes[storeKey] = null;
|
445
506
|
this.statuses[storeKey] = status || SC.Record.EMPTY;
|
@@ -458,7 +519,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
458
519
|
@param {Number} storeKey the store key
|
459
520
|
@returns {Number} status
|
460
521
|
*/
|
461
|
-
readStatus: function
|
522
|
+
readStatus: function(storeKey) {
|
462
523
|
// use readDataHash to handle optimistic locking. this could be inlined
|
463
524
|
// but for now this minimized copy-and-paste code.
|
464
525
|
this.readDataHash(storeKey);
|
@@ -473,7 +534,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
473
534
|
@param {Number} storeKey the store key
|
474
535
|
@returns {Number} status
|
475
536
|
*/
|
476
|
-
peekStatus: function
|
537
|
+
peekStatus: function(storeKey) {
|
477
538
|
return this.statuses[storeKey] || SC.Record.EMPTY;
|
478
539
|
},
|
479
540
|
|
@@ -487,10 +548,16 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
487
548
|
@param {SC.Error} error optional error object
|
488
549
|
@returns {SC.Store} receiver
|
489
550
|
*/
|
490
|
-
writeStatus: function
|
551
|
+
writeStatus: function(storeKey, newStatus) {
|
552
|
+
var that = this,
|
553
|
+
ret;
|
491
554
|
// use writeDataHash for now to handle optimistic lock. maximize code
|
492
555
|
// reuse.
|
493
|
-
|
556
|
+
ret = this.writeDataHash(storeKey, null, newStatus);
|
557
|
+
this._propagateToChildren(storeKey, function(storeKey) {
|
558
|
+
that.writeStatus(storeKey, newStatus);
|
559
|
+
});
|
560
|
+
return ret;
|
494
561
|
},
|
495
562
|
|
496
563
|
/**
|
@@ -505,8 +572,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
505
572
|
@param {String} key that changed (optional)
|
506
573
|
@returns {SC.Store} receiver
|
507
574
|
*/
|
508
|
-
dataHashDidChange: function
|
509
|
-
|
575
|
+
dataHashDidChange: function(storeKeys, rev, statusOnly, key) {
|
510
576
|
// update the revision for storeKey. Use generateStoreKey() because that
|
511
577
|
// guarantees a universally (to this store hierarchy anyway) unique
|
512
578
|
// key value.
|
@@ -527,7 +593,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
527
593
|
this.revisions[storeKey] = rev;
|
528
594
|
this._notifyRecordPropertyChange(storeKey, statusOnly, key);
|
529
595
|
|
530
|
-
this._propagateToChildren(storeKey, function
|
596
|
+
this._propagateToChildren(storeKey, function(storeKey){
|
531
597
|
that.dataHashDidChange(storeKey, null, statusOnly, key);
|
532
598
|
});
|
533
599
|
}
|
@@ -539,7 +605,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
539
605
|
Will push all changes to a the recordPropertyChanges property
|
540
606
|
and execute `flush()` once at the end of the runloop.
|
541
607
|
*/
|
542
|
-
_notifyRecordPropertyChange: function
|
608
|
+
_notifyRecordPropertyChange: function(storeKey, statusOnly, key) {
|
543
609
|
|
544
610
|
var records = this.records,
|
545
611
|
nestedStores = this.get('nestedStores'),
|
@@ -620,7 +686,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
620
686
|
|
621
687
|
@returns {SC.Store} receiver
|
622
688
|
*/
|
623
|
-
flush: function
|
689
|
+
flush: function() {
|
624
690
|
if (!this.recordPropertyChanges) return this;
|
625
691
|
|
626
692
|
var changes = this.recordPropertyChanges,
|
@@ -629,9 +695,9 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
629
695
|
records = changes.records,
|
630
696
|
propertyForStoreKeys = changes.propertyForStoreKeys,
|
631
697
|
recordTypes = SC.CoreSet.create(),
|
632
|
-
rec, recordType, statusOnly,
|
698
|
+
rec, recordType, statusOnly, keys;
|
633
699
|
|
634
|
-
storeKeys.forEach(function
|
700
|
+
storeKeys.forEach(function(storeKey) {
|
635
701
|
if (records.contains(storeKey)) {
|
636
702
|
statusOnly = hasDataChanges.contains(storeKey) ? NO : YES;
|
637
703
|
rec = this.records[storeKey];
|
@@ -670,12 +736,15 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
670
736
|
|
671
737
|
@returns {SC.Store} receiver
|
672
738
|
*/
|
673
|
-
reset: function
|
739
|
+
reset: function() {
|
674
740
|
|
675
741
|
// create a new empty data store
|
676
742
|
this.dataHashes = {} ;
|
677
743
|
this.revisions = {} ;
|
678
744
|
this.statuses = {} ;
|
745
|
+
this.records = {};
|
746
|
+
this.childRecords = {};
|
747
|
+
this.parentRecords = {};
|
679
748
|
|
680
749
|
// also reset temporary objects and errors
|
681
750
|
this.chainedChanges = this.locks = this.editables = null;
|
@@ -697,7 +766,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
697
766
|
// Also reset all pre-created recordArrays.
|
698
767
|
var ra, raList = this.get('recordArrays');
|
699
768
|
if (raList) {
|
700
|
-
while (ra = raList.pop()) {
|
769
|
+
while ((ra = raList.pop())) {
|
701
770
|
ra.destroy();
|
702
771
|
}
|
703
772
|
raList.clear();
|
@@ -723,7 +792,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
723
792
|
@param {Boolean} force
|
724
793
|
@returns {SC.Store} receiver
|
725
794
|
*/
|
726
|
-
commitChangesFromNestedStore: function
|
795
|
+
commitChangesFromNestedStore: function(nestedStore, changes, force) {
|
727
796
|
// first, check for optimistic locking problems
|
728
797
|
if (!force) this._verifyLockRevisions(changes, nestedStore.locks);
|
729
798
|
|
@@ -787,7 +856,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
787
856
|
@param {SC.Set} locks the locks to verify
|
788
857
|
@returns {SC.Store} receiver
|
789
858
|
*/
|
790
|
-
_verifyLockRevisions: function
|
859
|
+
_verifyLockRevisions: function(changes, locks) {
|
791
860
|
var len = changes.length, revs = this.revisions, i, storeKey, lock, rev ;
|
792
861
|
if (locks && revs) {
|
793
862
|
for(i=0;i<len;i++) {
|
@@ -869,7 +938,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
869
938
|
@param {String} id the id to load
|
870
939
|
@returns {SC.Record} record instance or null
|
871
940
|
*/
|
872
|
-
find: function
|
941
|
+
find: function(recordType, id) {
|
873
942
|
|
874
943
|
// if recordType is passed as string, find object
|
875
944
|
if (SC.typeOf(recordType)===SC.T_STRING) {
|
@@ -891,7 +960,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
891
960
|
},
|
892
961
|
|
893
962
|
/** @private */
|
894
|
-
_findQuery: function
|
963
|
+
_findQuery: function(query, createIfNeeded, refreshIfNew) {
|
895
964
|
|
896
965
|
// lookup the local RecordArray for this query.
|
897
966
|
var cache = this._scst_recordArraysByQuery,
|
@@ -917,7 +986,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
917
986
|
},
|
918
987
|
|
919
988
|
/** @private */
|
920
|
-
_findRecord: function
|
989
|
+
_findRecord: function(recordType, id) {
|
921
990
|
|
922
991
|
var storeKey ;
|
923
992
|
|
@@ -931,7 +1000,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
931
1000
|
// as well.
|
932
1001
|
} else storeKey = id ? recordType.storeKeyFor(id) : null;
|
933
1002
|
|
934
|
-
if (storeKey && (this.
|
1003
|
+
if (storeKey && (this.peekStatus(storeKey) === SC.Record.EMPTY)) {
|
935
1004
|
storeKey = this.retrieveRecord(recordType, id);
|
936
1005
|
}
|
937
1006
|
|
@@ -953,7 +1022,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
953
1022
|
@param {SC.RecordArray} recordArray the record array
|
954
1023
|
@returns {SC.Store} receiver
|
955
1024
|
*/
|
956
|
-
recordArrayWillDestroy: function
|
1025
|
+
recordArrayWillDestroy: function(recordArray) {
|
957
1026
|
var cache = this._scst_recordArraysByQuery,
|
958
1027
|
set = this.get('recordArrays');
|
959
1028
|
|
@@ -973,7 +1042,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
973
1042
|
@param {SC.Query} query the record array query to refresh
|
974
1043
|
@returns {SC.Store} receiver
|
975
1044
|
*/
|
976
|
-
refreshQuery: function
|
1045
|
+
refreshQuery: function(query) {
|
977
1046
|
if (!query) throw new Error("refreshQuery() requires a query");
|
978
1047
|
|
979
1048
|
var cache = this._scst_recordArraysByQuery,
|
@@ -996,11 +1065,11 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
996
1065
|
@param {SC.Set} recordTypes
|
997
1066
|
@returns {SC.Store} receiver
|
998
1067
|
*/
|
999
|
-
_notifyRecordArrays: function
|
1068
|
+
_notifyRecordArrays: function(storeKeys, recordTypes) {
|
1000
1069
|
var recordArrays = this.get('recordArrays');
|
1001
1070
|
if (!recordArrays) return this;
|
1002
1071
|
|
1003
|
-
recordArrays.forEach(function
|
1072
|
+
recordArrays.forEach(function(recArray) {
|
1004
1073
|
if (recArray) recArray.storeDidChangeStoreKeys(storeKeys, recordTypes);
|
1005
1074
|
}, this);
|
1006
1075
|
|
@@ -1021,7 +1090,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1021
1090
|
@param {SC.Record} recordType the record type
|
1022
1091
|
@returns {SC.Array} array instance - usually SC.RecordArray
|
1023
1092
|
*/
|
1024
|
-
recordsFor: function
|
1093
|
+
recordsFor: function(recordType) {
|
1025
1094
|
var storeKeys = [],
|
1026
1095
|
storeKeysById = recordType.storeKeysById(),
|
1027
1096
|
id, storeKey, ret;
|
@@ -1041,7 +1110,10 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1041
1110
|
},
|
1042
1111
|
|
1043
1112
|
/** @private */
|
1044
|
-
|
1113
|
+
_CACHED_REC_ATTRS: {},
|
1114
|
+
|
1115
|
+
/** @private */
|
1116
|
+
_CACHED_REC_INIT: function() {},
|
1045
1117
|
|
1046
1118
|
/**
|
1047
1119
|
Given a `storeKey`, return a materialized record. You will not usually
|
@@ -1056,11 +1128,8 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1056
1128
|
@param {Number} storeKey The storeKey for the dataHash.
|
1057
1129
|
@returns {SC.Record} Returns a record instance.
|
1058
1130
|
*/
|
1059
|
-
materializeRecord: function
|
1131
|
+
materializeRecord: function(storeKey) {
|
1060
1132
|
var records = this.records,
|
1061
|
-
//@if(debug)
|
1062
|
-
updatingRecords = this.updatingRecords,
|
1063
|
-
//@endif
|
1064
1133
|
ret, recordType, attrs;
|
1065
1134
|
|
1066
1135
|
// look up in cached records
|
@@ -1072,28 +1141,26 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1072
1141
|
recordType = SC.Store.recordTypeFor(storeKey);
|
1073
1142
|
if (!recordType) return null; // not recordType registered, nothing to do
|
1074
1143
|
|
1075
|
-
|
1144
|
+
// Populate the attributes.
|
1145
|
+
attrs = this._CACHED_REC_ATTRS ;
|
1076
1146
|
attrs.storeKey = storeKey ;
|
1077
1147
|
attrs.store = this ;
|
1078
1148
|
|
1079
|
-
|
1080
|
-
//
|
1081
|
-
//
|
1082
|
-
//
|
1083
|
-
//
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
//@if(debug)
|
1095
|
-
updatingRecords[storeKey] = null;
|
1096
|
-
//@endif
|
1149
|
+
// We do a little gymnastics here to prevent record initialization before we've
|
1150
|
+
// received and cached a copy of the object. This is because if initialization
|
1151
|
+
// triggers downstream effects which call materializeRecord for the same record,
|
1152
|
+
// we won't have a copy of it cached yet, causing another copy to be created
|
1153
|
+
// and resulting in a stack overflow at best and a really hard-to-diagnose bug
|
1154
|
+
// involving two instances of the same record floating around at worst.
|
1155
|
+
|
1156
|
+
// Override _object_init to prevent premature initialization.
|
1157
|
+
var _object_init = recordType.prototype._object_init;
|
1158
|
+
recordType.prototype._object_init = this._CACHED_REC_INIT;
|
1159
|
+
// Create the record (but don't init it).
|
1160
|
+
ret = records[storeKey] = recordType.create();
|
1161
|
+
// Repopulate the _object_init method and run initialization.
|
1162
|
+
recordType.prototype._object_init = ret._object_init = _object_init;
|
1163
|
+
ret._object_init([attrs]);
|
1097
1164
|
|
1098
1165
|
return ret ;
|
1099
1166
|
},
|
@@ -1141,7 +1208,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1141
1208
|
|
1142
1209
|
@returns {SC.Record} Returns the created record
|
1143
1210
|
*/
|
1144
|
-
createRecord: function
|
1211
|
+
createRecord: function(recordType, dataHash, id) {
|
1145
1212
|
var primaryKey, prototype, storeKey, status, K = SC.Record, changelog, defaultVal, ret;
|
1146
1213
|
|
1147
1214
|
//initialize dataHash if necessary
|
@@ -1249,7 +1316,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1249
1316
|
@param {Array} ids (optional) ids to assign to records
|
1250
1317
|
@returns {Array} array of materialized record instances.
|
1251
1318
|
*/
|
1252
|
-
createRecords: function
|
1319
|
+
createRecords: function(recordTypes, dataHashes, ids) {
|
1253
1320
|
var ret = [], recordType, id, isArray, len = dataHashes.length, idx ;
|
1254
1321
|
isArray = SC.typeOf(recordTypes) === SC.T_ARRAY;
|
1255
1322
|
if (!isArray) recordType = recordTypes;
|
@@ -1273,7 +1340,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1273
1340
|
@param {Number} storeKey (optional) if passed, ignores recordType and id
|
1274
1341
|
@returns {SC.Store} receiver
|
1275
1342
|
*/
|
1276
|
-
unloadRecord: function
|
1343
|
+
unloadRecord: function(recordType, id, storeKey, newStatus) {
|
1277
1344
|
if (storeKey === undefined) storeKey = recordType.storeKeyFor(id);
|
1278
1345
|
var status = this.readStatus(storeKey), K = SC.Record;
|
1279
1346
|
newStatus = newStatus || K.EMPTY;
|
@@ -1288,16 +1355,23 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1288
1355
|
// otherwise, destroy in dirty state
|
1289
1356
|
} else status = newStatus ;
|
1290
1357
|
|
1291
|
-
// remove the data hash, set new status
|
1358
|
+
// remove the data hash, set the new status and remove the cached record.
|
1292
1359
|
this.removeDataHash(storeKey, status);
|
1293
1360
|
this.dataHashDidChange(storeKey);
|
1361
|
+
delete this.records[storeKey];
|
1294
1362
|
|
1295
|
-
//
|
1363
|
+
// If this record is a parent record, unregister all of its child records.
|
1296
1364
|
var that = this;
|
1297
1365
|
this._propagateToChildren(storeKey, function (storeKey) {
|
1298
|
-
that.
|
1366
|
+
that.unregisterChildFromParent(storeKey);
|
1299
1367
|
});
|
1300
1368
|
|
1369
|
+
// If this record is a parent record, its child records have been cleared so also clear the
|
1370
|
+
// cached reference as well.
|
1371
|
+
if (this.parentRecords) {
|
1372
|
+
delete this.parentRecords[storeKey];
|
1373
|
+
}
|
1374
|
+
|
1301
1375
|
return this ;
|
1302
1376
|
},
|
1303
1377
|
|
@@ -1321,7 +1395,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1321
1395
|
@param {Array} storeKeys (optional) store keys to unload
|
1322
1396
|
@returns {SC.Store} receiver
|
1323
1397
|
*/
|
1324
|
-
unloadRecords: function
|
1398
|
+
unloadRecords: function(recordTypes, ids, storeKeys, newStatus) {
|
1325
1399
|
var len, isArray, idx, id, recordType, storeKey;
|
1326
1400
|
|
1327
1401
|
if (storeKeys === undefined) {
|
@@ -1364,7 +1438,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1364
1438
|
@param {Number} storeKey (optional) if passed, ignores recordType and id
|
1365
1439
|
@returns {SC.Store} receiver
|
1366
1440
|
*/
|
1367
|
-
destroyRecord: function
|
1441
|
+
destroyRecord: function(recordType, id, storeKey) {
|
1368
1442
|
if (storeKey === undefined) storeKey = recordType.storeKeyFor(id);
|
1369
1443
|
var status = this.readStatus(storeKey), changelog, K = SC.Record;
|
1370
1444
|
|
@@ -1396,7 +1470,8 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1396
1470
|
changelog = this.changelog;
|
1397
1471
|
if (!changelog) changelog = this.changelog = SC.Set.create();
|
1398
1472
|
|
1399
|
-
(
|
1473
|
+
if (status & K.DIRTY) { changelog.add(storeKey); }
|
1474
|
+
else { changelog.remove(storeKey); }
|
1400
1475
|
this.changelog=changelog;
|
1401
1476
|
|
1402
1477
|
// if commit records is enabled
|
@@ -1405,7 +1480,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1405
1480
|
}
|
1406
1481
|
|
1407
1482
|
var that = this;
|
1408
|
-
this._propagateToChildren(storeKey, function
|
1483
|
+
this._propagateToChildren(storeKey, function(storeKey){
|
1409
1484
|
that.destroyRecord(null, null, storeKey);
|
1410
1485
|
});
|
1411
1486
|
|
@@ -1432,7 +1507,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1432
1507
|
@param {Array} storeKeys (optional) store keys to destroy
|
1433
1508
|
@returns {SC.Store} receiver
|
1434
1509
|
*/
|
1435
|
-
destroyRecords: function
|
1510
|
+
destroyRecords: function(recordTypes, ids, storeKeys) {
|
1436
1511
|
var len, isArray, idx, id, recordType, storeKey;
|
1437
1512
|
if(storeKeys===undefined){
|
1438
1513
|
len = ids.length;
|
@@ -1456,7 +1531,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1456
1531
|
/**
|
1457
1532
|
register a Child Record to the parent
|
1458
1533
|
*/
|
1459
|
-
registerChildToParent: function
|
1534
|
+
registerChildToParent: function(parentStoreKey, childStoreKey, path){
|
1460
1535
|
var parentRecords, childRecords, oldPk, oldChildren, pkRef;
|
1461
1536
|
|
1462
1537
|
// Check the child to see if it has a parent
|
@@ -1465,7 +1540,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1465
1540
|
|
1466
1541
|
// first rid of the old parent
|
1467
1542
|
oldPk = childRecords[childStoreKey];
|
1468
|
-
if (oldPk)
|
1543
|
+
if (oldPk){
|
1469
1544
|
oldChildren = parentRecords[oldPk];
|
1470
1545
|
delete oldChildren[childStoreKey];
|
1471
1546
|
// this.recordDidChange(null, null, oldPk, key);
|
@@ -1484,35 +1559,55 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1484
1559
|
/**
|
1485
1560
|
Unregister the Child Record from its Parent. This will cause the Child
|
1486
1561
|
Record to be removed from the store.
|
1562
|
+
|
1563
|
+
@param {Number} childStoreKey storeKey to unregister
|
1487
1564
|
*/
|
1488
|
-
unregisterChildFromParent: function
|
1489
|
-
var childRecords, oldPk
|
1565
|
+
unregisterChildFromParent: function(childStoreKey) {
|
1566
|
+
var childRecords, oldPk, storeKeys,
|
1567
|
+
recordType = this.recordTypeFor(childStoreKey),
|
1568
|
+
id = this.idFor(childStoreKey),
|
1569
|
+
that = this;
|
1490
1570
|
|
1491
1571
|
// Check the child to see if it has a parent
|
1492
1572
|
childRecords = this.childRecords;
|
1493
1573
|
|
1494
|
-
// Remove the parent's connection to the child. This doesn't remove the
|
1495
|
-
// parent store key from the cache of parent store keys if the parent
|
1496
|
-
// no longer has any other registered children, because the amount of effort
|
1497
|
-
// to determine that would not be worth the miniscule memory savings.
|
1498
|
-
oldPk = childRecords[childStoreKey];
|
1499
|
-
if (oldPk) {
|
1500
|
-
delete this.parentRecords[oldPk][childStoreKey];
|
1501
|
-
}
|
1502
|
-
|
1503
1574
|
// Remove the child.
|
1504
1575
|
// 1. from the cache of data hashes
|
1505
1576
|
// 2. from the cache of record objects
|
1506
1577
|
// 3. from the cache of child record store keys
|
1507
1578
|
this.removeDataHash(childStoreKey);
|
1508
|
-
|
1509
|
-
|
1579
|
+
if (this.records) {
|
1580
|
+
delete this.records[childStoreKey];
|
1581
|
+
}
|
1582
|
+
|
1583
|
+
if (childRecords) {
|
1584
|
+
// Remove the parent's connection to the child. This doesn't remove the
|
1585
|
+
// parent store key from the cache of parent store keys if the parent
|
1586
|
+
// no longer has any other registered children, because the amount of effort
|
1587
|
+
// to determine that would not be worth the miniscule memory savings.
|
1588
|
+
oldPk = childRecords[childStoreKey];
|
1589
|
+
if (oldPk) {
|
1590
|
+
delete this.parentRecords[oldPk][childStoreKey];
|
1591
|
+
}
|
1592
|
+
|
1593
|
+
delete childRecords[childStoreKey];
|
1594
|
+
}
|
1595
|
+
|
1596
|
+
// 4. from the cache of ids
|
1597
|
+
// 5. from the cache of store keys
|
1598
|
+
delete SC.Store.idsByStoreKey[childStoreKey];
|
1599
|
+
storeKeys = recordType.storeKeysById();
|
1600
|
+
delete storeKeys[id];
|
1601
|
+
|
1602
|
+
this._propagateToChildren(childStoreKey, function(storeKey) {
|
1603
|
+
that.unregisterChildFromParent(storeKey);
|
1604
|
+
});
|
1510
1605
|
},
|
1511
1606
|
|
1512
1607
|
/**
|
1513
1608
|
materialize the parent when passing in a store key for the child
|
1514
1609
|
*/
|
1515
|
-
materializeParentRecord: function
|
1610
|
+
materializeParentRecord: function(childStoreKey){
|
1516
1611
|
var pk, crs;
|
1517
1612
|
if (SC.none(childStoreKey)) return null;
|
1518
1613
|
crs = this.childRecords;
|
@@ -1525,9 +1620,9 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1525
1620
|
/**
|
1526
1621
|
function for retrieving a parent record key
|
1527
1622
|
|
1528
|
-
|
1623
|
+
@param {Number} storeKey The store key of the parent
|
1529
1624
|
*/
|
1530
|
-
parentStoreKeyExists: function
|
1625
|
+
parentStoreKeyExists: function(storeKey){
|
1531
1626
|
if (SC.none(storeKey)) return ;
|
1532
1627
|
var crs = this.childRecords || {};
|
1533
1628
|
return crs[storeKey];
|
@@ -1536,7 +1631,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1536
1631
|
/**
|
1537
1632
|
function that propagates a function call to all children
|
1538
1633
|
*/
|
1539
|
-
_propagateToChildren: function
|
1634
|
+
_propagateToChildren: function(storeKey, func){
|
1540
1635
|
// Handle all the child Records
|
1541
1636
|
if ( SC.none(this.parentRecords) ) return;
|
1542
1637
|
var children = this.parentRecords[storeKey] || {};
|
@@ -1560,7 +1655,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1560
1655
|
@param {Boolean} if the change is to statusOnly (optional)
|
1561
1656
|
@returns {SC.Store} receiver
|
1562
1657
|
*/
|
1563
|
-
recordDidChange: function
|
1658
|
+
recordDidChange: function(recordType, id, storeKey, key, statusOnly) {
|
1564
1659
|
if (storeKey === undefined) storeKey = recordType.storeKeyFor(id);
|
1565
1660
|
var status = this.readStatus(storeKey), changelog, K = SC.Record;
|
1566
1661
|
|
@@ -1577,7 +1672,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1577
1672
|
// otherwise, make new status READY_DIRTY unless new.
|
1578
1673
|
// K.READY_CLEAN, K.READY_DIRTY, ignore K.READY_NEW
|
1579
1674
|
} else {
|
1580
|
-
if (status
|
1675
|
+
if (status !== K.READY_NEW) this.writeStatus(storeKey, K.READY_DIRTY);
|
1581
1676
|
}
|
1582
1677
|
|
1583
1678
|
// record data hash change
|
@@ -1617,7 +1712,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1617
1712
|
@param {Array} storeKeys (optional) store keys to destroy
|
1618
1713
|
@returns {SC.Store} receiver
|
1619
1714
|
*/
|
1620
|
-
recordsDidChange: function
|
1715
|
+
recordsDidChange: function(recordTypes, ids, storeKeys) {
|
1621
1716
|
var len, isArray, idx, id, recordType, storeKey;
|
1622
1717
|
if(storeKeys===undefined){
|
1623
1718
|
len = ids.length;
|
@@ -1657,7 +1752,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1657
1752
|
@param {Function|Array} callback function or array of functions
|
1658
1753
|
@returns {Array} storeKeys to be retrieved
|
1659
1754
|
*/
|
1660
|
-
retrieveRecords: function
|
1755
|
+
retrieveRecords: function(recordTypes, ids, storeKeys, isRefresh, callbacks) {
|
1661
1756
|
|
1662
1757
|
var source = this._getDataSource(),
|
1663
1758
|
isArray = SC.typeOf(recordTypes) === SC.T_ARRAY,
|
@@ -1687,7 +1782,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1687
1782
|
status = this.readStatus(storeKey);
|
1688
1783
|
|
1689
1784
|
// K.EMPTY, K.ERROR, K.DESTROYED_CLEAN - initial retrieval
|
1690
|
-
if ((status
|
1785
|
+
if ((status === K.EMPTY) || (status === K.ERROR) || (status === K.DESTROYED_CLEAN)) {
|
1691
1786
|
this.writeStatus(storeKey, K.BUSY_LOADING);
|
1692
1787
|
this.dataHashDidChange(storeKey, rev, YES);
|
1693
1788
|
ret.push(storeKey);
|
@@ -1701,11 +1796,11 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1701
1796
|
ret.push(storeKey);
|
1702
1797
|
this._setCallbackForStoreKey(storeKey, callback, hasCallbackArray, storeKeys);
|
1703
1798
|
// K.BUSY_DESTROYING, K.BUSY_COMMITTING, K.BUSY_CREATING
|
1704
|
-
} else if ((status
|
1799
|
+
} else if ((status === K.BUSY_DESTROYING) || (status === K.BUSY_CREATING) || (status === K.BUSY_COMMITTING)) {
|
1705
1800
|
throw K.BUSY_ERROR ;
|
1706
1801
|
|
1707
1802
|
// K.DESTROY_DIRTY, bad state...
|
1708
|
-
} else if (status
|
1803
|
+
} else if (status === K.DESTROYED_DIRTY) {
|
1709
1804
|
throw K.BAD_STATE_ERROR ;
|
1710
1805
|
|
1711
1806
|
// ignore K.BUSY_LOADING, K.BUSY_REFRESH_CLEAN, K.BUSY_REFRESH_DIRTY
|
@@ -1713,7 +1808,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1713
1808
|
}
|
1714
1809
|
}
|
1715
1810
|
|
1716
|
-
// now retrieve
|
1811
|
+
// now retrieve storeKeys from dataSource. if there is no dataSource,
|
1717
1812
|
// then act as if we couldn't retrieve.
|
1718
1813
|
ok = NO;
|
1719
1814
|
if (source) ok = source.retrieveRecords.call(source, this, ret, ids);
|
@@ -1749,17 +1844,18 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1749
1844
|
@private
|
1750
1845
|
stores the callbacks for the storeKeys that are inflight
|
1751
1846
|
**/
|
1752
|
-
_setCallbackForStoreKey: function
|
1847
|
+
_setCallbackForStoreKey: function(storeKey, callback, hasCallbackArray, storeKeys){
|
1753
1848
|
var queue = this._callback_queue;
|
1754
1849
|
if(hasCallbackArray) queue[storeKey] = {callback: callback, otherKeys: storeKeys};
|
1755
1850
|
else queue[storeKey] = callback;
|
1756
1851
|
},
|
1852
|
+
|
1757
1853
|
/**
|
1758
1854
|
@private
|
1759
|
-
|
1760
|
-
|
1855
|
+
Retrieves and calls callback for `storeKey` if exists, also handles if a single callback is
|
1856
|
+
needed for one key..
|
1761
1857
|
**/
|
1762
|
-
|
1858
|
+
_retrieveCallbackForStoreKey: function(storeKey){
|
1763
1859
|
var queue = this._callback_queue,
|
1764
1860
|
callback = queue[storeKey],
|
1765
1861
|
allFinished, keys;
|
@@ -1768,16 +1864,16 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1768
1864
|
callback.call(); //args?
|
1769
1865
|
delete queue[storeKey]; //cleanup
|
1770
1866
|
}
|
1771
|
-
else if(SC.typeOf(callback)
|
1867
|
+
else if(SC.typeOf(callback) === SC.T_HASH){
|
1772
1868
|
callback.completed = YES;
|
1773
1869
|
keys = callback.storeKeys;
|
1774
|
-
keys.forEach(function
|
1870
|
+
keys.forEach(function(key){
|
1775
1871
|
if(!queue[key].completed) allFinished = YES;
|
1776
1872
|
});
|
1777
1873
|
if(allFinished){
|
1778
1874
|
callback.callback.call(); // args?
|
1779
1875
|
//cleanup
|
1780
|
-
keys.forEach(function
|
1876
|
+
keys.forEach(function(key){
|
1781
1877
|
delete queue[key];
|
1782
1878
|
});
|
1783
1879
|
}
|
@@ -1790,7 +1886,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1790
1886
|
@private
|
1791
1887
|
|
1792
1888
|
*/
|
1793
|
-
_cancelCallback: function
|
1889
|
+
_cancelCallback: function(storeKey){
|
1794
1890
|
var queue = this._callback_queue;
|
1795
1891
|
if(queue[storeKey]){
|
1796
1892
|
delete queue[storeKey];
|
@@ -1816,7 +1912,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1816
1912
|
@param {Function} callback (optional)
|
1817
1913
|
@returns {Number} storeKey that was retrieved
|
1818
1914
|
*/
|
1819
|
-
retrieveRecord: function
|
1915
|
+
retrieveRecord: function(recordType, id, storeKey, isRefresh, callback) {
|
1820
1916
|
var array = this._TMP_RETRIEVE_ARRAY,
|
1821
1917
|
ret;
|
1822
1918
|
|
@@ -1845,7 +1941,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1845
1941
|
@param {Function} callback (optional) when refresh completes
|
1846
1942
|
@returns {Boolean} YES if the retrieval was a success.
|
1847
1943
|
*/
|
1848
|
-
refreshRecord: function
|
1944
|
+
refreshRecord: function(recordType, id, storeKey, callback) {
|
1849
1945
|
return !!this.retrieveRecord(recordType, id, storeKey, YES, callback);
|
1850
1946
|
},
|
1851
1947
|
|
@@ -1860,7 +1956,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1860
1956
|
@param {Function} callback (optional) when refresh completes
|
1861
1957
|
@returns {Boolean} YES if the retrieval was a success.
|
1862
1958
|
*/
|
1863
|
-
refreshRecords: function
|
1959
|
+
refreshRecords: function(recordTypes, ids, storeKeys, callback) {
|
1864
1960
|
var ret = this.retrieveRecords(recordTypes, ids, storeKeys, YES, callback);
|
1865
1961
|
return ret && ret.length>0;
|
1866
1962
|
},
|
@@ -1882,14 +1978,14 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1882
1978
|
|
1883
1979
|
@returns {Boolean} if the action was succesful.
|
1884
1980
|
*/
|
1885
|
-
commitRecords: function
|
1981
|
+
commitRecords: function(recordTypes, ids, storeKeys, params, callbacks) {
|
1886
1982
|
var source = this._getDataSource(),
|
1887
1983
|
isArray = SC.typeOf(recordTypes) === SC.T_ARRAY,
|
1888
1984
|
hasCallbackArray = SC.typeOf(callbacks) === SC.T_ARRAY,
|
1889
1985
|
retCreate= [], retUpdate= [], retDestroy = [],
|
1890
1986
|
rev = SC.Store.generateStoreKey(),
|
1891
1987
|
K = SC.Record,
|
1892
|
-
recordType, idx, storeKey, status,
|
1988
|
+
recordType, idx, storeKey, status, ret, len, callback;
|
1893
1989
|
|
1894
1990
|
// If no params are passed, look up storeKeys in the changelog property.
|
1895
1991
|
// Remove any committed records from changelog property.
|
@@ -1917,26 +2013,26 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1917
2013
|
// collect status and process
|
1918
2014
|
status = this.readStatus(storeKey);
|
1919
2015
|
|
1920
|
-
if (status
|
2016
|
+
if (status === K.ERROR) {
|
1921
2017
|
throw K.NOT_FOUND_ERROR ;
|
1922
2018
|
}
|
1923
2019
|
else {
|
1924
|
-
if(status
|
2020
|
+
if(status === K.READY_NEW) {
|
1925
2021
|
this.writeStatus(storeKey, K.BUSY_CREATING);
|
1926
2022
|
this.dataHashDidChange(storeKey, rev, YES);
|
1927
2023
|
retCreate.push(storeKey);
|
1928
2024
|
this._setCallbackForStoreKey(storeKey, callback, hasCallbackArray, storeKeys);
|
1929
|
-
} else if (status
|
2025
|
+
} else if (status === K.READY_DIRTY) {
|
1930
2026
|
this.writeStatus(storeKey, K.BUSY_COMMITTING);
|
1931
2027
|
this.dataHashDidChange(storeKey, rev, YES);
|
1932
2028
|
retUpdate.push(storeKey);
|
1933
2029
|
this._setCallbackForStoreKey(storeKey, callback, hasCallbackArray, storeKeys);
|
1934
|
-
} else if (status
|
2030
|
+
} else if (status === K.DESTROYED_DIRTY) {
|
1935
2031
|
this.writeStatus(storeKey, K.BUSY_DESTROYING);
|
1936
2032
|
this.dataHashDidChange(storeKey, rev, YES);
|
1937
2033
|
retDestroy.push(storeKey);
|
1938
2034
|
this._setCallbackForStoreKey(storeKey, callback, hasCallbackArray, storeKeys);
|
1939
|
-
} else if (status
|
2035
|
+
} else if (status === K.DESTROYED_CLEAN) {
|
1940
2036
|
this.dataHashDidChange(storeKey, rev, YES);
|
1941
2037
|
}
|
1942
2038
|
// ignore K.EMPTY, K.READY_CLEAN, K.BUSY_LOADING, K.BUSY_CREATING, K.BUSY_COMMITTING,
|
@@ -1944,7 +2040,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1944
2040
|
}
|
1945
2041
|
}
|
1946
2042
|
|
1947
|
-
// now commit
|
2043
|
+
// now commit storeKeys to dataSource
|
1948
2044
|
if (source && (len>0 || params)) {
|
1949
2045
|
ret = source.commitRecords.call(source, this, retCreate, retUpdate, retDestroy, params);
|
1950
2046
|
}
|
@@ -1977,7 +2073,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
1977
2073
|
@param {Function|Array} callback function or array of functions
|
1978
2074
|
@returns {Boolean} if the action was successful.
|
1979
2075
|
*/
|
1980
|
-
commitRecord: function
|
2076
|
+
commitRecord: function(recordType, id, storeKey, params, callback) {
|
1981
2077
|
var array = this._TMP_RETRIEVE_ARRAY,
|
1982
2078
|
ret ;
|
1983
2079
|
if (id === undefined && storeKey === undefined ) return NO;
|
@@ -2005,7 +2101,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2005
2101
|
@param {Array} storeKeys (optional) store keys to destroy
|
2006
2102
|
@returns {SC.Store} the store.
|
2007
2103
|
*/
|
2008
|
-
cancelRecords: function
|
2104
|
+
cancelRecords: function(recordTypes, ids, storeKeys) {
|
2009
2105
|
var source = this._getDataSource(),
|
2010
2106
|
isArray = SC.typeOf(recordTypes) === SC.T_ARRAY,
|
2011
2107
|
K = SC.Record,
|
@@ -2027,7 +2123,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2027
2123
|
if(storeKey) {
|
2028
2124
|
status = this.readStatus(storeKey);
|
2029
2125
|
|
2030
|
-
if ((status
|
2126
|
+
if ((status === K.EMPTY) || (status === K.ERROR)) {
|
2031
2127
|
throw K.NOT_FOUND_ERROR ;
|
2032
2128
|
}
|
2033
2129
|
ret.push(storeKey);
|
@@ -2050,7 +2146,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2050
2146
|
@param {Array} storeKeys (optional) store keys to destroy
|
2051
2147
|
@returns {SC.Store} the store.
|
2052
2148
|
*/
|
2053
|
-
cancelRecord: function
|
2149
|
+
cancelRecord: function(recordType, id, storeKey) {
|
2054
2150
|
var array = this._TMP_RETRIEVE_ARRAY,
|
2055
2151
|
ret ;
|
2056
2152
|
|
@@ -2093,7 +2189,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2093
2189
|
@param {Array} id optional. if not passed lookup on the hash
|
2094
2190
|
@returns {String} store keys assigned to these id
|
2095
2191
|
*/
|
2096
|
-
loadRecord: function
|
2192
|
+
loadRecord: function(recordType, dataHash, id) {
|
2097
2193
|
var K = SC.Record,
|
2098
2194
|
ret, primaryKey, storeKey;
|
2099
2195
|
|
@@ -2139,12 +2235,11 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2139
2235
|
@param {Array} ids optional array of ids. if not passed lookup on hashes
|
2140
2236
|
@returns {Array} store keys assigned to these ids
|
2141
2237
|
*/
|
2142
|
-
loadRecords: function
|
2238
|
+
loadRecords: function(recordTypes, dataHashes, ids) {
|
2143
2239
|
var isArray = SC.typeOf(recordTypes) === SC.T_ARRAY,
|
2144
2240
|
len = dataHashes.get('length'),
|
2145
2241
|
ret = [],
|
2146
|
-
|
2147
|
-
recordType, id, primaryKey, idx, dataHash, storeKey;
|
2242
|
+
recordType, id, primaryKey, idx, dataHash;
|
2148
2243
|
|
2149
2244
|
// save lookup info
|
2150
2245
|
if (!isArray) {
|
@@ -2175,7 +2270,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2175
2270
|
|
2176
2271
|
@returns {SC.Error} SC.Error or undefined if no error associated with the record.
|
2177
2272
|
*/
|
2178
|
-
readError: function
|
2273
|
+
readError: function(storeKey) {
|
2179
2274
|
var errors = this.recordErrors ;
|
2180
2275
|
return errors ? errors[storeKey] : undefined ;
|
2181
2276
|
},
|
@@ -2187,7 +2282,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2187
2282
|
|
2188
2283
|
@returns {SC.Error} SC.Error or undefined if no error associated with the query.
|
2189
2284
|
*/
|
2190
|
-
readQueryError: function
|
2285
|
+
readQueryError: function(query) {
|
2191
2286
|
var errors = this.queryErrors ;
|
2192
2287
|
return errors ? errors[SC.guidFor(query)] : undefined ;
|
2193
2288
|
},
|
@@ -2204,7 +2299,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2204
2299
|
@param {Number} storeKey record store key to cancel
|
2205
2300
|
@returns {SC.Store} receiver
|
2206
2301
|
*/
|
2207
|
-
dataSourceDidCancel: function
|
2302
|
+
dataSourceDidCancel: function(storeKey) {
|
2208
2303
|
var status = this.readStatus(storeKey),
|
2209
2304
|
K = SC.Record;
|
2210
2305
|
|
@@ -2260,7 +2355,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2260
2355
|
@param {Object} newId optional new id to replace the old one
|
2261
2356
|
@returns {SC.Store} receiver
|
2262
2357
|
*/
|
2263
|
-
dataSourceDidComplete: function
|
2358
|
+
dataSourceDidComplete: function(storeKey, dataHash, newId) {
|
2264
2359
|
var status = this.readStatus(storeKey), K = SC.Record, statusOnly;
|
2265
2360
|
|
2266
2361
|
// EMPTY, ERROR, READY_CLEAN, READY_NEW, READY_DIRTY, DESTROYED_CLEAN,
|
@@ -2270,7 +2365,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2270
2365
|
}
|
2271
2366
|
|
2272
2367
|
// otherwise, determine proper state transition
|
2273
|
-
if(status===K.BUSY_DESTROYING) {
|
2368
|
+
if(status === K.BUSY_DESTROYING) {
|
2274
2369
|
throw K.BAD_STATE_ERROR ;
|
2275
2370
|
} else status = K.READY_CLEAN ;
|
2276
2371
|
|
@@ -2283,11 +2378,11 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2283
2378
|
|
2284
2379
|
// Force record to refresh its cached properties based on store key
|
2285
2380
|
var record = this.materializeRecord(storeKey);
|
2286
|
-
if (record
|
2381
|
+
if (record !== null) {
|
2287
2382
|
record.notifyPropertyChange('status');
|
2288
2383
|
}
|
2289
2384
|
//update callbacks
|
2290
|
-
this.
|
2385
|
+
this._retrieveCallbackForStoreKey(storeKey);
|
2291
2386
|
|
2292
2387
|
return this ;
|
2293
2388
|
},
|
@@ -2299,7 +2394,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2299
2394
|
@param {Number} storeKey record store key to cancel
|
2300
2395
|
@returns {SC.Store} receiver
|
2301
2396
|
*/
|
2302
|
-
dataSourceDidDestroy: function
|
2397
|
+
dataSourceDidDestroy: function(storeKey) {
|
2303
2398
|
var status = this.readStatus(storeKey), K = SC.Record;
|
2304
2399
|
|
2305
2400
|
// EMPTY, ERROR, READY_CLEAN, READY_NEW, READY_DIRTY, DESTROYED_CLEAN,
|
@@ -2316,11 +2411,11 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2316
2411
|
|
2317
2412
|
// Force record to refresh its cached properties based on store key
|
2318
2413
|
var record = this.materializeRecord(storeKey);
|
2319
|
-
if (record
|
2414
|
+
if (record !== null) {
|
2320
2415
|
record.notifyPropertyChange('status');
|
2321
2416
|
}
|
2322
2417
|
|
2323
|
-
this.
|
2418
|
+
this._retrieveCallbackForStoreKey(storeKey);
|
2324
2419
|
|
2325
2420
|
return this ;
|
2326
2421
|
},
|
@@ -2332,7 +2427,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2332
2427
|
@param {SC.Error} error [optional] an SC.Error instance to associate with storeKey
|
2333
2428
|
@returns {SC.Store} receiver
|
2334
2429
|
*/
|
2335
|
-
dataSourceDidError: function
|
2430
|
+
dataSourceDidError: function(storeKey, error) {
|
2336
2431
|
var status = this.readStatus(storeKey), errors = this.recordErrors, K = SC.Record;
|
2337
2432
|
|
2338
2433
|
// EMPTY, ERROR, READY_CLEAN, READY_NEW, READY_DIRTY, DESTROYED_CLEAN,
|
@@ -2353,11 +2448,11 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2353
2448
|
|
2354
2449
|
// Force record to refresh its cached properties based on store key
|
2355
2450
|
var record = this.materializeRecord(storeKey);
|
2356
|
-
if (record
|
2451
|
+
if (record) {
|
2357
2452
|
record.notifyPropertyChange('status');
|
2358
2453
|
}
|
2359
2454
|
|
2360
|
-
this.
|
2455
|
+
this._retrieveCallbackForStoreKey(storeKey);
|
2361
2456
|
return this ;
|
2362
2457
|
},
|
2363
2458
|
|
@@ -2375,15 +2470,15 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2375
2470
|
@param {Number} storeKey optional store key.
|
2376
2471
|
@returns {Number|Boolean} storeKey if push was allowed, NO if not
|
2377
2472
|
*/
|
2378
|
-
pushRetrieve: function
|
2473
|
+
pushRetrieve: function(recordType, id, dataHash, storeKey) {
|
2379
2474
|
var K = SC.Record, status;
|
2380
2475
|
|
2381
|
-
if
|
2476
|
+
if(storeKey===undefined) storeKey = recordType.storeKeyFor(id);
|
2382
2477
|
status = this.readStatus(storeKey);
|
2383
|
-
if
|
2478
|
+
if(status === K.EMPTY || status === K.ERROR || status === K.READY_CLEAN || status === K.DESTROYED_CLEAN) {
|
2384
2479
|
|
2385
2480
|
status = K.READY_CLEAN;
|
2386
|
-
if
|
2481
|
+
if(dataHash === undefined) this.writeStatus(storeKey, status) ;
|
2387
2482
|
else this.writeDataHash(storeKey, dataHash, status) ;
|
2388
2483
|
|
2389
2484
|
if (id && this.idFor(storeKey) !== id) SC.Store.replaceIdFor(storeKey, id);
|
@@ -2404,14 +2499,14 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2404
2499
|
@param {Number} storeKey optional store key.
|
2405
2500
|
@returns {Number|Boolean} storeKey if push was allowed, NO if not
|
2406
2501
|
*/
|
2407
|
-
pushDestroy: function
|
2502
|
+
pushDestroy: function(recordType, id, storeKey) {
|
2408
2503
|
var K = SC.Record, status;
|
2409
2504
|
|
2410
2505
|
if(storeKey===undefined){
|
2411
2506
|
storeKey = recordType.storeKeyFor(id);
|
2412
2507
|
}
|
2413
2508
|
status = this.readStatus(storeKey);
|
2414
|
-
if(status
|
2509
|
+
if(status === K.EMPTY || status === K.ERROR || status === K.READY_CLEAN || status === K.DESTROYED_CLEAN){
|
2415
2510
|
status = K.DESTROYED_CLEAN;
|
2416
2511
|
this.removeDataHash(storeKey, status) ;
|
2417
2512
|
this.dataHashDidChange(storeKey);
|
@@ -2431,13 +2526,13 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2431
2526
|
@param {Number} storeKey optional store key.
|
2432
2527
|
@returns {Number|Boolean} storeKey if push was allowed, NO if not
|
2433
2528
|
*/
|
2434
|
-
pushError: function
|
2529
|
+
pushError: function(recordType, id, error, storeKey) {
|
2435
2530
|
var K = SC.Record, status, errors = this.recordErrors;
|
2436
2531
|
|
2437
2532
|
if(storeKey===undefined) storeKey = recordType.storeKeyFor(id);
|
2438
2533
|
status = this.readStatus(storeKey);
|
2439
2534
|
|
2440
|
-
if(status
|
2535
|
+
if(status === K.EMPTY || status === K.ERROR || status === K.READY_CLEAN || status === K.DESTROYED_CLEAN){
|
2441
2536
|
status = K.ERROR;
|
2442
2537
|
|
2443
2538
|
// Add the error to the array of record errors (for lookup later on if necessary).
|
@@ -2469,7 +2564,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2469
2564
|
@param {SC.Array} storeKeys array of store keys
|
2470
2565
|
@returns {SC.Store} receiver
|
2471
2566
|
*/
|
2472
|
-
loadQueryResults: function
|
2567
|
+
loadQueryResults: function(query, storeKeys) {
|
2473
2568
|
//@if(debug)
|
2474
2569
|
if (query.get('location') === SC.Query.LOCAL) {
|
2475
2570
|
throw new Error("Developer Error: You should not call loadQueryResults with a local query. You need to use dataSourceDidFetchQuery instead.");
|
@@ -2545,11 +2640,11 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2545
2640
|
if (recArray) recArray.storeDidFetchQuery(query);
|
2546
2641
|
|
2547
2642
|
// notify nested stores
|
2548
|
-
while
|
2643
|
+
while(--loc >= 0) {
|
2549
2644
|
nestedStores[loc]._scstore_dataSourceDidFetchQuery(query);
|
2550
2645
|
}
|
2551
2646
|
|
2552
|
-
return this;
|
2647
|
+
return this ;
|
2553
2648
|
},
|
2554
2649
|
|
2555
2650
|
/**
|
@@ -2560,11 +2655,11 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2560
2655
|
@param {SC.Query} query the query you cancelled
|
2561
2656
|
@returns {SC.Store} receiver
|
2562
2657
|
*/
|
2563
|
-
dataSourceDidCancelQuery: function
|
2658
|
+
dataSourceDidCancelQuery: function(query) {
|
2564
2659
|
return this._scstore_dataSourceDidCancelQuery(query, YES);
|
2565
2660
|
},
|
2566
2661
|
|
2567
|
-
_scstore_dataSourceDidCancelQuery: function
|
2662
|
+
_scstore_dataSourceDidCancelQuery: function(query, createIfNeeded) {
|
2568
2663
|
var recArray = this._findQuery(query, createIfNeeded, NO),
|
2569
2664
|
nestedStores = this.get('nestedStores'),
|
2570
2665
|
loc = nestedStores ? nestedStores.get('length') : 0;
|
@@ -2589,7 +2684,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2589
2684
|
@param {SC.Error} error [optional] an SC.Error instance to associate with query
|
2590
2685
|
@returns {SC.Store} receiver
|
2591
2686
|
*/
|
2592
|
-
dataSourceDidErrorQuery: function
|
2687
|
+
dataSourceDidErrorQuery: function(query, error) {
|
2593
2688
|
var errors = this.queryErrors;
|
2594
2689
|
|
2595
2690
|
// Add the error to the array of query errors (for lookup later on if necessary).
|
@@ -2601,7 +2696,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2601
2696
|
return this._scstore_dataSourceDidErrorQuery(query, YES);
|
2602
2697
|
},
|
2603
2698
|
|
2604
|
-
_scstore_dataSourceDidErrorQuery: function
|
2699
|
+
_scstore_dataSourceDidErrorQuery: function(query, createIfNeeded) {
|
2605
2700
|
var recArray = this._findQuery(query, createIfNeeded, NO),
|
2606
2701
|
nestedStores = this.get('nestedStores'),
|
2607
2702
|
loc = nestedStores ? nestedStores.get('length') : 0;
|
@@ -2622,13 +2717,13 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2622
2717
|
//
|
2623
2718
|
|
2624
2719
|
/** @private */
|
2625
|
-
init: function
|
2720
|
+
init: function() {
|
2626
2721
|
sc_super();
|
2627
2722
|
this.reset();
|
2628
2723
|
},
|
2629
2724
|
|
2630
2725
|
|
2631
|
-
toString: function
|
2726
|
+
toString: function() {
|
2632
2727
|
// Include the name if the client has specified one.
|
2633
2728
|
var name = this.get('name');
|
2634
2729
|
if (!name) {
|
@@ -2651,7 +2746,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2651
2746
|
@param {Number} storeKey the store key
|
2652
2747
|
@returns {String} primaryKey value
|
2653
2748
|
*/
|
2654
|
-
idFor: function
|
2749
|
+
idFor: function(storeKey) {
|
2655
2750
|
return SC.Store.idFor(storeKey);
|
2656
2751
|
},
|
2657
2752
|
|
@@ -2661,7 +2756,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2661
2756
|
@param {Number} storeKey the store key
|
2662
2757
|
@returns {SC.Record} record instance
|
2663
2758
|
*/
|
2664
|
-
recordTypeFor: function
|
2759
|
+
recordTypeFor: function(storeKey) {
|
2665
2760
|
return SC.Store.recordTypeFor(storeKey) ;
|
2666
2761
|
},
|
2667
2762
|
|
@@ -2673,7 +2768,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2673
2768
|
@param {String} primaryKey the primary key
|
2674
2769
|
@returns {Number} storeKey
|
2675
2770
|
*/
|
2676
|
-
storeKeyFor: function
|
2771
|
+
storeKeyFor: function(recordType, primaryKey) {
|
2677
2772
|
return recordType.storeKeyFor(primaryKey);
|
2678
2773
|
},
|
2679
2774
|
|
@@ -2686,7 +2781,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2686
2781
|
@param {String} primaryKey the primary key
|
2687
2782
|
@returns {Number} a storeKey.
|
2688
2783
|
*/
|
2689
|
-
storeKeyExists: function
|
2784
|
+
storeKeyExists: function(recordType, primaryKey) {
|
2690
2785
|
return recordType.storeKeyExists(primaryKey);
|
2691
2786
|
},
|
2692
2787
|
|
@@ -2697,7 +2792,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2697
2792
|
@param {SC.Record} recordType
|
2698
2793
|
@returns {Array} set of storeKeys
|
2699
2794
|
*/
|
2700
|
-
storeKeysFor: function
|
2795
|
+
storeKeysFor: function(recordType) {
|
2701
2796
|
var ret = [],
|
2702
2797
|
isEnum = recordType && recordType.isEnumerable,
|
2703
2798
|
recType, storeKey, isMatch ;
|
@@ -2722,13 +2817,13 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2722
2817
|
|
2723
2818
|
@returns {Array} set of storeKeys
|
2724
2819
|
*/
|
2725
|
-
storeKeys: function
|
2820
|
+
storeKeys: function() {
|
2726
2821
|
var ret = [], storeKey;
|
2727
2822
|
if(!this.statuses) return ret;
|
2728
2823
|
|
2729
2824
|
for(storeKey in this.statuses) {
|
2730
2825
|
// if status is not empty
|
2731
|
-
if(this.statuses[storeKey]
|
2826
|
+
if(this.statuses[storeKey] !== SC.Record.EMPTY) {
|
2732
2827
|
ret.push(parseInt(storeKey, 10));
|
2733
2828
|
}
|
2734
2829
|
}
|
@@ -2742,7 +2837,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
|
|
2742
2837
|
@param {Number} storeKey
|
2743
2838
|
@returns {String}
|
2744
2839
|
*/
|
2745
|
-
statusString: function
|
2840
|
+
statusString: function(storeKey) {
|
2746
2841
|
var rec = this.materializeRecord(storeKey);
|
2747
2842
|
return rec.statusString();
|
2748
2843
|
}
|
@@ -2840,7 +2935,7 @@ SC.Store.mixin(/** @scope SC.Store.prototype */{
|
|
2840
2935
|
|
2841
2936
|
@type Number
|
2842
2937
|
*/
|
2843
|
-
generateStoreKey: function
|
2938
|
+
generateStoreKey: function() { return this.nextStoreKey++; },
|
2844
2939
|
|
2845
2940
|
/**
|
2846
2941
|
Given a `storeKey` returns the `primaryKey` associated with the key.
|
@@ -2849,7 +2944,7 @@ SC.Store.mixin(/** @scope SC.Store.prototype */{
|
|
2849
2944
|
@param {Number} storeKey the store key
|
2850
2945
|
@returns {String} the primary key or null
|
2851
2946
|
*/
|
2852
|
-
idFor: function
|
2947
|
+
idFor: function(storeKey) {
|
2853
2948
|
return this.idsByStoreKey[storeKey] ;
|
2854
2949
|
},
|
2855
2950
|
|
@@ -2860,7 +2955,7 @@ SC.Store.mixin(/** @scope SC.Store.prototype */{
|
|
2860
2955
|
@param {Number} storeKey the store key
|
2861
2956
|
@returns {SC.Query} query query object
|
2862
2957
|
*/
|
2863
|
-
queryFor: function
|
2958
|
+
queryFor: function(storeKey) {
|
2864
2959
|
return this.queriesByStoreKey[storeKey];
|
2865
2960
|
},
|
2866
2961
|
|
@@ -2874,7 +2969,7 @@ SC.Store.mixin(/** @scope SC.Store.prototype */{
|
|
2874
2969
|
@param {Number} storeKey the store key
|
2875
2970
|
@returns {SC.Record} the record type
|
2876
2971
|
*/
|
2877
|
-
recordTypeFor: function
|
2972
|
+
recordTypeFor: function(storeKey) {
|
2878
2973
|
return this.recordTypesByStoreKey[storeKey];
|
2879
2974
|
},
|
2880
2975
|
|
@@ -2887,7 +2982,7 @@ SC.Store.mixin(/** @scope SC.Store.prototype */{
|
|
2887
2982
|
@param {String} newPrimaryKey the new primary key
|
2888
2983
|
@returns {SC.Store} receiver
|
2889
2984
|
*/
|
2890
|
-
replaceIdFor: function
|
2985
|
+
replaceIdFor: function(storeKey, newId) {
|
2891
2986
|
var oldId = this.idsByStoreKey[storeKey],
|
2892
2987
|
recordType, storeKeys;
|
2893
2988
|
|
@@ -2920,7 +3015,7 @@ SC.Store.mixin(/** @scope SC.Store.prototype */{
|
|
2920
3015
|
@param {SC.Record} recordType a record class
|
2921
3016
|
@returns {SC.Store} receiver
|
2922
3017
|
*/
|
2923
|
-
replaceRecordTypeFor: function
|
3018
|
+
replaceRecordTypeFor: function(storeKey, recordType) {
|
2924
3019
|
this.recordTypesByStoreKey[storeKey] = recordType;
|
2925
3020
|
return this ;
|
2926
3021
|
}
|