lanes 0.1.9 → 0.1.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/client/fonts/fontawesome-webfont.woff +0 -0
- data/client/fonts/fontawesome-webfont.woff2 +0 -0
- data/client/lanes/Boot.cjsx +9 -0
- data/client/lanes/access/Extension.coffee +18 -4
- data/client/lanes/access/LoginDialog.cjsx +78 -0
- data/client/lanes/access/Roles.coffee +22 -28
- data/client/lanes/access/User.coffee +16 -16
- data/client/lanes/access/index.js +4 -5
- data/client/lanes/access/screens/user-management/Editor.cjsx +20 -0
- data/client/lanes/access/screens/user-management/UserManagement.cjsx +41 -0
- data/client/lanes/access/screens/user-management/index.js +0 -1
- data/client/lanes/components/grid/EditingMixin.cjsx +64 -0
- data/client/lanes/components/grid/Grid.cjsx +139 -0
- data/client/lanes/components/grid/PopOverMixin.cjsx +28 -0
- data/client/lanes/components/grid/PopoverEditor.cjsx +8 -0
- data/client/lanes/components/grid/RowEditor.cjsx +10 -0
- data/client/lanes/components/grid/Toolbar.cjsx +14 -0
- data/client/lanes/components/grid/config.json +1 -1
- data/client/lanes/components/grid/editors.scss +94 -53
- data/client/lanes/components/grid/index.js +2 -7
- data/client/lanes/components/grid/styles.scss +8 -296
- data/client/lanes/components/helpers.coffee +2 -0
- data/client/lanes/components/index.js +2 -1
- data/client/lanes/components/modal/Modal.cjsx +36 -0
- data/client/lanes/components/modal/index.js +1 -2
- data/client/lanes/components/modal/styles.scss +0 -19
- data/client/lanes/components/record-finder/Clause.cjsx +80 -0
- data/client/lanes/components/record-finder/Dialog.cjsx +54 -0
- data/client/lanes/components/record-finder/RecordFinder.cjsx +38 -0
- data/client/lanes/components/record-finder/config.json +1 -1
- data/client/lanes/components/record-finder/index.js +1 -2
- data/client/lanes/components/request-spinner/index.js +1 -0
- data/client/lanes/components/select-field/SelectField.cjsx +78 -0
- data/client/lanes/components/select-field/index.js +2 -1
- data/client/lanes/components/select-field/styles.scss +1 -0
- data/client/lanes/components/shared/CountBadge.cjsx +9 -0
- data/client/lanes/components/shared/ErrorDisplay.cjsx +21 -0
- data/client/lanes/components/shared/FieldMixin.cjsx +71 -0
- data/client/lanes/components/shared/FieldSet.cjsx +58 -0
- data/client/lanes/components/shared/GenericField.cjsx +5 -0
- data/client/lanes/components/shared/Helpers.coffee +9 -0
- data/client/lanes/components/shared/RadioField.cjsx +14 -0
- data/client/lanes/components/shared/Resize.cjsx +152 -0
- data/client/lanes/components/shared/TextArea.cjsx +19 -0
- data/client/lanes/components/shared/TextField.cjsx +25 -0
- data/client/lanes/components/shared/Tooltip.cjsx +10 -0
- data/client/lanes/components/shared/fields.scss +35 -0
- data/client/lanes/components/shared/fieldset.scss +29 -0
- data/client/lanes/components/shared/index.js +3 -0
- data/client/lanes/components/shared/styles.scss +32 -0
- data/client/lanes/components/toolbar/RemoteChangeSets.cjsx +75 -0
- data/client/lanes/components/toolbar/SaveButton.cjsx +3 -0
- data/client/lanes/components/toolbar/Toolbar.cjsx +58 -0
- data/client/lanes/{workspace/styles → components/toolbar}/changes-notification.scss +10 -23
- data/client/lanes/components/toolbar/index.js +3 -0
- data/client/lanes/components/toolbar/styles.scss +51 -0
- data/client/lanes/extension/Extensions.coffee +19 -10
- data/client/lanes/extension/LateLoaded.js.erb +4 -3
- data/client/lanes/index.js +3 -5
- data/client/lanes/index.scss.erb +6 -14
- data/client/lanes/lib/HotReload.coffee +35 -0
- data/client/lanes/lib/MakeBaseClass.coffee +10 -11
- data/client/lanes/lib/development.coffee +3 -0
- data/client/lanes/lib/dom.coffee +49 -0
- data/client/lanes/lib/el.coffee +23 -0
- data/client/lanes/lib/index.js.erb +16 -0
- data/client/lanes/lib/loader.coffee +34 -34
- data/client/lanes/lib/namespace.coffee +1 -1
- data/client/lanes/lib/objToParam.coffee +37 -0
- data/client/lanes/{access/views/.gitkeep → lib/production.coffee} +0 -0
- data/client/lanes/lib/utilFunctions.coffee +44 -26
- data/client/lanes/models/AssociationMap.coffee +51 -38
- data/client/lanes/models/Base.coffee +89 -88
- data/client/lanes/models/ChangeMonitor.coffee +10 -10
- data/client/lanes/models/ChangeSet.coffee +14 -24
- data/client/lanes/models/Collection.coffee +40 -41
- data/client/lanes/models/PubSub.coffee +28 -19
- data/client/lanes/models/Query.coffee +78 -45
- data/client/lanes/models/QueryResults.coffee +93 -0
- data/client/lanes/models/ServerCache.coffee +12 -12
- data/client/lanes/models/Sync.coffee +53 -50
- data/client/lanes/models/User.coffee +31 -17
- data/client/lanes/react/Component.coffee +31 -0
- data/client/lanes/react/DefaultComponentNotFound.cjsx +9 -0
- data/client/lanes/{views → react}/FormBindings.coffee +0 -0
- data/client/lanes/{views → react}/ModelObserver.coffee +0 -0
- data/client/lanes/{views → react}/ModelUpdate.coffee +0 -0
- data/client/lanes/{views → react}/PubSub.coffee +0 -0
- data/client/lanes/react/Root.cjsx +14 -0
- data/client/lanes/react/Router.cjsx +18 -0
- data/client/lanes/react/Screen.coffee +15 -0
- data/client/lanes/{views → react}/TimedHighlight.coffee +0 -0
- data/client/lanes/{views → react}/TimedMask.coffee +0 -0
- data/client/lanes/react/TypeValidators.coffee +21 -0
- data/client/lanes/{lib/create-namespace.js → react/Utils.coffee} +0 -0
- data/client/lanes/react/Viewport.coffee +30 -0
- data/client/lanes/react/index.js +8 -0
- data/client/lanes/react/mixins/Access.coffee +27 -0
- data/client/lanes/react/mixins/Component.coffee +4 -0
- data/client/lanes/react/mixins/Data.coffee +136 -0
- data/client/lanes/react/mixins/MonitorSize.coffee +11 -0
- data/client/lanes/react/mixins/ReadEditingState.coffee +11 -0
- data/client/lanes/react/mixins/RelayEditingState.coffee +17 -0
- data/client/lanes/react/mixins/RelayFieldChange.coffee +11 -0
- data/client/lanes/react/mixins/Screen.coffee +7 -0
- data/client/lanes/react/mixins/Viewport.coffee +11 -0
- data/client/lanes/screens/ChangeListener.coffee +3 -3
- data/client/lanes/screens/Commands.coffee +27 -0
- data/client/lanes/screens/Definitions.coffee +74 -65
- data/client/lanes/screens/all.js.erb +1 -1
- data/client/lanes/screens/index.js +1 -2
- data/client/lanes/screens/mixins/index.js +0 -1
- data/client/lanes/screens/register.js.erb +0 -1
- data/client/lanes/screens/styles.scss +7 -0
- data/client/lanes/styles/bootstrap-custom-grid.scss +67 -37
- data/client/lanes/styles/bootstrap.scss +4 -5
- data/client/lanes/styles/fonts.scss +10 -23
- data/client/lanes/styles/fonts/_animated.scss +34 -0
- data/client/lanes/styles/fonts/_bordered-pulled.scss +16 -0
- data/client/lanes/styles/fonts/_core.scss +13 -0
- data/client/lanes/styles/fonts/_fixed-width.scss +6 -0
- data/client/lanes/styles/fonts/_icons.scss +596 -0
- data/client/lanes/styles/fonts/_larger.scss +13 -0
- data/client/lanes/styles/fonts/_list.scss +19 -0
- data/client/lanes/styles/fonts/_mixins.scss +27 -0
- data/client/lanes/styles/fonts/_path.scss +10 -0
- data/client/lanes/styles/fonts/_rotated-flipped.scss +20 -0
- data/client/lanes/styles/fonts/_stacked.scss +20 -0
- data/client/lanes/styles/fonts/_variables.scss +606 -0
- data/client/lanes/styles/fonts/font-awesome.scss +16 -0
- data/client/lanes/styles/fonts/index.scss +2 -0
- data/client/lanes/styles/global.scss +2 -0
- data/client/lanes/styles/global/fancy-header.scss +14 -0
- data/client/lanes/testing/BeforeEach.coffee +15 -40
- data/client/lanes/testing/Helpers.coffee +27 -0
- data/client/lanes/testing/ModelSaver.coffee +14 -24
- data/client/lanes/testing/StubRouter.coffee +27 -0
- data/client/lanes/testing/TestObjects.coffee +27 -0
- data/client/lanes/testing/index.js +3 -1
- data/client/lanes/vendor/base.js +85256 -0
- data/client/lanes/vendor/commons.js +20579 -0
- data/client/lanes/vendor/development.js +2511 -0
- data/client/lanes/vendor/grid.js +6689 -0
- data/client/lanes/vendor/grid.scss +387 -0
- data/client/lanes/vendor/index.js +3 -0
- data/client/lanes/vendor/message-bus.coffee +264 -0
- data/client/lanes/vendor/widgets.js +8798 -0
- data/client/lanes/vendor/widgets.scss +723 -0
- data/client/lanes/workspace/ActiveScreenSwitcher.cjsx +38 -0
- data/client/lanes/workspace/Extension.coffee +6 -0
- data/client/lanes/workspace/Layout.cjsx +28 -0
- data/client/lanes/workspace/Navbar.cjsx +25 -0
- data/client/lanes/workspace/ScreenView.cjsx +27 -0
- data/client/lanes/workspace/ScreensMenu.cjsx +57 -0
- data/client/lanes/workspace/UIState.coffee +17 -16
- data/client/lanes/workspace/index.js +7 -2
- data/client/lanes/workspace/styles.scss +0 -3
- data/client/lanes/workspace/styles/forms.scss +2 -73
- data/client/lanes/workspace/styles/header.scss +0 -2
- data/client/lanes/workspace/styles/layout.scss +9 -2
- data/client/lanes/workspace/styles/screens.scss +0 -59
- data/client/lanes/workspace/styles/tabs.scss +16 -15
- data/coffeelint.json +49 -0
- data/config.ru +1 -0
- data/config/database.yml +2 -2
- data/config/routes.rb +7 -0
- data/docs/command.md +11 -8
- data/docs/model.md +2 -5
- data/docs/react.md +137 -0
- data/lanes.gemspec +1 -0
- data/lib/lanes.rb +1 -1
- data/lib/lanes/access/authentication_provider.rb +1 -0
- data/lib/lanes/access/config/routes.rb +2 -0
- data/lib/lanes/access/config/screens.rb +15 -12
- data/lib/lanes/access/extension.rb +2 -1
- data/lib/lanes/access/role.rb +8 -4
- data/lib/lanes/api.rb +4 -3
- data/lib/lanes/api/coffeescript_processor.rb +47 -6
- data/lib/lanes/api/controller.rb +4 -3
- data/lib/lanes/api/default_routes.rb +16 -0
- data/lib/lanes/api/javascript_processor.rb +14 -68
- data/lib/lanes/api/pub_sub.rb +17 -3
- data/lib/lanes/api/request_wrapper.rb +2 -2
- data/lib/lanes/api/root.rb +16 -13
- data/lib/lanes/api/routing.rb +0 -18
- data/lib/lanes/api/sprockets_extension.rb +10 -4
- data/lib/lanes/api/test_specs.rb +3 -3
- data/lib/lanes/cli.rb +6 -1
- data/lib/lanes/command/app.rb +7 -11
- data/lib/lanes/command/generate.rb +3 -3
- data/lib/lanes/command/generate_component.rb +28 -0
- data/lib/lanes/command/generate_component.usage +11 -0
- data/lib/lanes/command/generate_screen.rb +24 -7
- data/lib/lanes/command/generate_screen.usage +5 -8
- data/lib/lanes/configuration.rb +3 -2
- data/lib/lanes/extension.rb +12 -18
- data/lib/lanes/extension/definition.rb +20 -8
- data/lib/lanes/guard_tasks.rb +22 -5
- data/lib/lanes/hot_reload_plugin.rb +47 -0
- data/lib/lanes/logger.rb +41 -5
- data/lib/lanes/screen.rb +40 -16
- data/lib/lanes/spec_helper.rb +6 -3
- data/lib/lanes/version.rb +1 -1
- data/lib/lanes/workspace/extension.rb +1 -0
- data/npm-build/{template.js → base.js} +17 -17
- data/{client/lanes/workspace/tab.html → npm-build/common.js} +0 -0
- data/npm-build/compile.coffee +13 -4
- data/npm-build/development.js +7 -0
- data/npm-build/grid.js +11 -0
- data/npm-build/package.json +62 -58
- data/npm-build/react-widgets.js +5 -0
- data/npm-build/react-widgets.less +35 -0
- data/npm-build/webpack.config.js +39 -0
- data/spec/command-reference-files/component/client/appy-app/components/Big.cjsx +4 -0
- data/spec/command-reference-files/component/spec/appy-app/components/BigSpec.coffee +5 -0
- data/spec/command-reference-files/initial/.rubocop.yml +7 -0
- data/spec/command-reference-files/initial/Gemfile +1 -1
- data/spec/command-reference-files/initial/client/appy-app/Extension.coffee +17 -5
- data/spec/command-reference-files/initial/client/appy-app/components/Base.coffee +9 -0
- data/spec/command-reference-files/initial/client/appy-app/index.js +1 -3
- data/spec/command-reference-files/initial/client/appy-app/screens/Base.coffee +8 -2
- data/spec/command-reference-files/initial/coffeelint.json +49 -0
- data/spec/command-reference-files/initial/config.ru +2 -0
- data/spec/command-reference-files/initial/config/screens.rb +10 -0
- data/spec/command-reference-files/initial/lib/appy-app/extension.rb +7 -0
- data/spec/command-reference-files/model/client/appy-app/models/TestTest.coffee +0 -1
- data/spec/command-reference-files/screen/client/appy-app/Extension.coffee +34 -0
- data/spec/command-reference-files/screen/client/appy-app/screens/ready-set-go/ReadySetGo.cjsx +7 -0
- data/spec/command-reference-files/screen/config/screens.rb +19 -9
- data/spec/command-reference-files/screen/spec/appy-app/screens/ready-set-go/ReadySetGoSpec.coffee +3 -3
- data/spec/lanes/components/grid/GridSpec.coffee +26 -26
- data/spec/lanes/models/AssociationMapSpec.coffee +6 -6
- data/spec/lanes/models/BaseSpec.coffee +24 -35
- data/spec/lanes/models/CollectionSpec.coffee +19 -18
- data/spec/lanes/models/EnumMapSpec.coffee +1 -1
- data/spec/lanes/models/PubSubSpec.coffee +17 -15
- data/spec/lanes/models/SyncSpec.coffee +28 -0
- data/spec/lanes/models/UserSpec.coffee +17 -0
- data/spec/lanes/react/mixins/DataSpec.coffee +72 -0
- data/spec/lanes/screens/DefinitionsSpec.coffee +33 -0
- data/spec/lanes/views/BaseSpec.coffee +133 -133
- data/spec/lanes/views/FormBindingsSpec.coffee +30 -30
- data/spec/server/api/coffeescript_processor_spec.rb +2 -2
- data/spec/server/command_spec.rb +3 -3
- data/templates/client/Extension.coffee +17 -5
- data/templates/client/components/BaseComponent.coffee +9 -0
- data/templates/client/components/Component.cjsx +4 -0
- data/templates/client/{views → components}/template.html +0 -0
- data/templates/client/index.js +1 -3
- data/templates/client/models/Model.coffee +0 -1
- data/templates/client/screens/BaseScreen.coffee +9 -0
- data/templates/client/screens/Screen.cjsx +7 -0
- data/templates/config.ru +2 -0
- data/templates/config/screen.rb +10 -10
- data/templates/config/screens.rb +10 -0
- data/templates/lib/namespace/extension.rb +7 -0
- data/templates/spec/client/Screen.coffee +4 -4
- data/templates/spec/client/components/ComponentSpec.coffee +5 -0
- metadata +157 -201
- data/client/fonts/lanes/icomoon.eot +0 -0
- data/client/fonts/lanes/icomoon.svg +0 -160
- data/client/fonts/lanes/icomoon.ttf +0 -0
- data/client/fonts/lanes/icomoon.woff +0 -0
- data/client/fonts/lanes/selection.json +0 -3565
- data/client/lanes/Boot.coffee +0 -50
- data/client/lanes/access/LoginDialog.coffee +0 -46
- data/client/lanes/access/login-dialog.html +0 -16
- data/client/lanes/access/screens/user-management/GridUserEditor.coffee +0 -26
- data/client/lanes/access/screens/user-management/UserManagement.coffee +0 -23
- data/client/lanes/access/screens/user-management/grid-popover-editor.html +0 -33
- data/client/lanes/access/screens/user-management/screen.html +0 -7
- data/client/lanes/components/Base.coffee +0 -39
- data/client/lanes/components/ChoicesInput.coffee +0 -47
- data/client/lanes/components/grid/Editor.coffee +0 -62
- data/client/lanes/components/grid/Grid.coffee +0 -205
- data/client/lanes/components/grid/PopOverEditor.coffee +0 -29
- data/client/lanes/components/grid/RowEditor.coffee +0 -30
- data/client/lanes/components/grid/popover-editor.html +0 -18
- data/client/lanes/components/grid/row-editor.html +0 -16
- data/client/lanes/components/grid/template.html +0 -4
- data/client/lanes/components/grid/vendor/dataTables.scroller.js +0 -1262
- data/client/lanes/components/grid/vendor/index.js +0 -2
- data/client/lanes/components/grid/vendor/jquery.dataTables.js +0 -14839
- data/client/lanes/components/modal/ModalDialog.coffee +0 -68
- data/client/lanes/components/modal/template.html +0 -18
- data/client/lanes/components/multi-select/MultiSelect.coffee +0 -65
- data/client/lanes/components/popover/PopOver.coffee +0 -55
- data/client/lanes/components/popover/index.js +0 -2
- data/client/lanes/components/popover/styles.scss +0 -2
- data/client/lanes/components/popover/template.html +0 -5
- data/client/lanes/components/radio-group/RadioGroup.coffee +0 -47
- data/client/lanes/components/radio-group/index.js +0 -1
- data/client/lanes/components/radio-group/styles.scss +0 -1
- data/client/lanes/components/record-finder/Clause.coffee +0 -37
- data/client/lanes/components/record-finder/Dialog.coffee +0 -45
- data/client/lanes/components/record-finder/RecordFinder.coffee +0 -61
- data/client/lanes/components/record-finder/clause.html +0 -37
- data/client/lanes/components/record-finder/dialog.html +0 -4
- data/client/lanes/components/record-finder/field.html +0 -8
- data/client/lanes/components/select-field/SelectField.coffee +0 -63
- data/client/lanes/components/select2/Select2.coffee +0 -8
- data/client/lanes/components/select2/index.js +0 -2
- data/client/lanes/lib/Templates.coffee +0 -51
- data/client/lanes/lib/debounce.coffee +0 -15
- data/client/lanes/lib/defer.coffee +0 -7
- data/client/lanes/lib/el.js +0 -115
- data/client/lanes/lib/index.js +0 -5
- data/client/lanes/plugins/overlay.coffee +0 -41
- data/client/lanes/screens/Base.coffee +0 -35
- data/client/lanes/screens/Router.coffee +0 -4
- data/client/lanes/screens/mixins/Editing.coffee +0 -38
- data/client/lanes/styles/bootstrap/old/_alerts.scss +0 -68
- data/client/lanes/styles/bootstrap/old/_badges.scss +0 -57
- data/client/lanes/styles/bootstrap/old/_breadcrumbs.scss +0 -26
- data/client/lanes/styles/bootstrap/old/_button-groups.scss +0 -240
- data/client/lanes/styles/bootstrap/old/_buttons.scss +0 -157
- data/client/lanes/styles/bootstrap/old/_carousel.scss +0 -243
- data/client/lanes/styles/bootstrap/old/_close.scss +0 -35
- data/client/lanes/styles/bootstrap/old/_code.scss +0 -68
- data/client/lanes/styles/bootstrap/old/_component-animations.scss +0 -35
- data/client/lanes/styles/bootstrap/old/_dropdowns.scss +0 -215
- data/client/lanes/styles/bootstrap/old/_forms.scss +0 -538
- data/client/lanes/styles/bootstrap/old/_glyphicons.scss +0 -237
- data/client/lanes/styles/bootstrap/old/_grid.scss +0 -84
- data/client/lanes/styles/bootstrap/old/_input-groups.scss +0 -166
- data/client/lanes/styles/bootstrap/old/_jumbotron.scss +0 -48
- data/client/lanes/styles/bootstrap/old/_labels.scss +0 -66
- data/client/lanes/styles/bootstrap/old/_list-group.scss +0 -132
- data/client/lanes/styles/bootstrap/old/_media.scss +0 -56
- data/client/lanes/styles/bootstrap/old/_mixins.scss +0 -39
- data/client/lanes/styles/bootstrap/old/_modals.scss +0 -150
- data/client/lanes/styles/bootstrap/old/_navbar.scss +0 -659
- data/client/lanes/styles/bootstrap/old/_navs.scss +0 -242
- data/client/lanes/styles/bootstrap/old/_normalize.scss +0 -425
- data/client/lanes/styles/bootstrap/old/_pager.scss +0 -55
- data/client/lanes/styles/bootstrap/old/_pagination.scss +0 -88
- data/client/lanes/styles/bootstrap/old/_panels.scss +0 -243
- data/client/lanes/styles/bootstrap/old/_popovers.scss +0 -133
- data/client/lanes/styles/bootstrap/old/_print.scss +0 -101
- data/client/lanes/styles/bootstrap/old/_progress-bars.scss +0 -105
- data/client/lanes/styles/bootstrap/old/_responsive-embed.scss +0 -34
- data/client/lanes/styles/bootstrap/old/_responsive-utilities.scss +0 -174
- data/client/lanes/styles/bootstrap/old/_scaffolding.scss +0 -150
- data/client/lanes/styles/bootstrap/old/_tables.scss +0 -233
- data/client/lanes/styles/bootstrap/old/_theme.scss +0 -258
- data/client/lanes/styles/bootstrap/old/_thumbnails.scss +0 -38
- data/client/lanes/styles/bootstrap/old/_tooltip.scss +0 -95
- data/client/lanes/styles/bootstrap/old/_type.scss +0 -304
- data/client/lanes/styles/bootstrap/old/_utilities.scss +0 -57
- data/client/lanes/styles/bootstrap/old/_variables.scss +0 -850
- data/client/lanes/styles/bootstrap/old/_wells.scss +0 -29
- data/client/lanes/styles/bootstrap/old/bootstrap.scss +0 -50
- data/client/lanes/styles/bootstrap/old/mixins/_alerts.scss +0 -14
- data/client/lanes/styles/bootstrap/old/mixins/_background-variant.scss +0 -11
- data/client/lanes/styles/bootstrap/old/mixins/_border-radius.scss +0 -18
- data/client/lanes/styles/bootstrap/old/mixins/_buttons.scss +0 -50
- data/client/lanes/styles/bootstrap/old/mixins/_center-block.scss +0 -7
- data/client/lanes/styles/bootstrap/old/mixins/_clearfix.scss +0 -22
- data/client/lanes/styles/bootstrap/old/mixins/_forms.scss +0 -84
- data/client/lanes/styles/bootstrap/old/mixins/_gradients.scss +0 -58
- data/client/lanes/styles/bootstrap/old/mixins/_grid-framework.scss +0 -81
- data/client/lanes/styles/bootstrap/old/mixins/_grid.scss +0 -122
- data/client/lanes/styles/bootstrap/old/mixins/_hide-text.scss +0 -21
- data/client/lanes/styles/bootstrap/old/mixins/_image.scss +0 -34
- data/client/lanes/styles/bootstrap/old/mixins/_labels.scss +0 -12
- data/client/lanes/styles/bootstrap/old/mixins/_list-group.scss +0 -31
- data/client/lanes/styles/bootstrap/old/mixins/_nav-divider.scss +0 -10
- data/client/lanes/styles/bootstrap/old/mixins/_nav-vertical-align.scss +0 -9
- data/client/lanes/styles/bootstrap/old/mixins/_opacity.scss +0 -8
- data/client/lanes/styles/bootstrap/old/mixins/_pagination.scss +0 -23
- data/client/lanes/styles/bootstrap/old/mixins/_panels.scss +0 -24
- data/client/lanes/styles/bootstrap/old/mixins/_progress-bar.scss +0 -10
- data/client/lanes/styles/bootstrap/old/mixins/_reset-filter.scss +0 -8
- data/client/lanes/styles/bootstrap/old/mixins/_resize.scss +0 -6
- data/client/lanes/styles/bootstrap/old/mixins/_responsive-visibility.scss +0 -21
- data/client/lanes/styles/bootstrap/old/mixins/_size.scss +0 -10
- data/client/lanes/styles/bootstrap/old/mixins/_tab-focus.scss +0 -9
- data/client/lanes/styles/bootstrap/old/mixins/_table-row.scss +0 -28
- data/client/lanes/styles/bootstrap/old/mixins/_text-emphasis.scss +0 -11
- data/client/lanes/styles/bootstrap/old/mixins/_text-overflow.scss +0 -8
- data/client/lanes/styles/bootstrap/old/mixins/_vendor-prefixes.scss +0 -219
- data/client/lanes/styles/font-definitions.scss +0 -451
- data/client/lanes/testing/TestModels.coffee +0 -23
- data/client/lanes/vendor/bootstrap/affix.js +0 -162
- data/client/lanes/vendor/bootstrap/alert.js +0 -94
- data/client/lanes/vendor/bootstrap/button.js +0 -116
- data/client/lanes/vendor/bootstrap/carousel.js +0 -240
- data/client/lanes/vendor/bootstrap/collapse.js +0 -211
- data/client/lanes/vendor/bootstrap/dropdown.js +0 -161
- data/client/lanes/vendor/bootstrap/modal.js +0 -324
- data/client/lanes/vendor/bootstrap/popover.js +0 -119
- data/client/lanes/vendor/bootstrap/scrollspy.js +0 -175
- data/client/lanes/vendor/bootstrap/tab.js +0 -153
- data/client/lanes/vendor/bootstrap/tooltip.js +0 -478
- data/client/lanes/vendor/bootstrap/transition.js +0 -59
- data/client/lanes/vendor/message-bus.js +0 -285
- data/client/lanes/vendor/modern-stack.js +0 -27
- data/client/lanes/vendor/packaged.js +0 -19533
- data/client/lanes/views/Assets.coffee +0 -9
- data/client/lanes/views/Base.coffee +0 -426
- data/client/lanes/views/Functions.coffee +0 -13
- data/client/lanes/views/Helpers.coffee +0 -76
- data/client/lanes/views/Keys.coffee +0 -59
- data/client/lanes/views/RenderContext.coffee +0 -32
- data/client/lanes/views/SaveNotify.coffee +0 -32
- data/client/lanes/views/Viewport.coffee +0 -18
- data/client/lanes/views/_button.html +0 -3
- data/client/lanes/views/_toolbar.html +0 -23
- data/client/lanes/views/empty-span.html +0 -1
- data/client/lanes/views/index.js +0 -2
- data/client/lanes/views/model-update.html +0 -15
- data/client/lanes/workspace/ActiveScreensSwitcher.coffee +0 -112
- data/client/lanes/workspace/Layout.coffee +0 -29
- data/client/lanes/workspace/Navbar.coffee +0 -31
- data/client/lanes/workspace/Pages.coffee +0 -39
- data/client/lanes/workspace/ScreensMenu.coffee +0 -126
- data/client/lanes/workspace/WorkspaceView.coffee +0 -8
- data/client/lanes/workspace/layout.html +0 -4
- data/client/lanes/workspace/menu.html +0 -356
- data/client/lanes/workspace/menu_toggle.html +0 -9
- data/client/lanes/workspace/navbar.html +0 -17
- data/client/lanes/workspace/pages.html +0 -6
- data/client/lanes/workspace/screens-menu.html +0 -11
- data/client/lanes/workspace/screens-switcher.html +0 -7
- data/docs/view.md +0 -292
- data/lib/lanes/command/generate_view.rb +0 -38
- data/lib/lanes/command/generate_view.usage +0 -13
- data/spec/command-reference-files/initial/client/appy-app/Router.coffee +0 -4
- data/spec/command-reference-files/initial/client/appy-app/controllers/.gitkeep +0 -0
- data/spec/command-reference-files/initial/client/appy-app/views/.gitkeep +0 -0
- data/spec/command-reference-files/initial/client/appy-app/views/Base.coffee +0 -5
- data/spec/command-reference-files/initial/spec/appy-app/screens/Base.coffee +0 -5
- data/spec/command-reference-files/screen/client/appy-app/screens/ready-set-go/ReadySetGo.coffee +0 -6
- data/spec/command-reference-files/screen/client/appy-app/screens/ready-set-go/layout.html +0 -3
- data/spec/command-reference-files/view/client/appy-app/views/BigView.coffee +0 -10
- data/spec/command-reference-files/view/spec/appy-app/views/BigViewSpec.coffee +0 -5
- data/templates/client/Router.coffee +0 -4
- data/templates/client/components/Component.coffee +0 -1
- data/templates/client/screens/Base.coffee +0 -3
- data/templates/client/screens/Screen.coffee +0 -11
- data/templates/client/screens/layout.html +0 -3
- data/templates/client/views/.gitkeep +0 -0
- data/templates/client/views/BaseView.coffee +0 -5
- data/templates/client/views/View.coffee +0 -10
- data/templates/spec/client/views/ViewSpec.coffee +0 -5
@@ -19,31 +19,41 @@ class BaseModel
|
|
19
19
|
deps:['errors'], fn: ->
|
20
20
|
if !@errors then ''
|
21
21
|
else if @errors.exception then @errors.exception
|
22
|
-
else _.toSentence( _.map(@
|
22
|
+
else _.toSentence( _.map(@errors, (value, key) ->
|
23
|
+
_.titleize(_.humanize(key)) + ' ' + value
|
24
|
+
))
|
23
25
|
dataTypes:
|
26
|
+
code:
|
27
|
+
set: (newVal) ->
|
28
|
+
if _.isString(newVal)
|
29
|
+
val: newVal.toUpperCase(), type: 'code'
|
30
|
+
else
|
31
|
+
throw new TypeError('code must be a string')
|
32
|
+
default: -> ''
|
24
33
|
# Big decimal for attributes that need precision math
|
25
34
|
bigdec:
|
26
|
-
set: (newVal)->
|
35
|
+
set: (newVal) ->
|
27
36
|
val: new _.bigDecimal(newVal)
|
28
37
|
type: 'bigdec'
|
29
38
|
default: -> new _.bigDecimal(0)
|
39
|
+
|
30
40
|
integer:
|
31
|
-
set: (newVal)->
|
41
|
+
set: (newVal) ->
|
32
42
|
val: parseInt(newVal)
|
33
43
|
type: 'integer'
|
34
44
|
# Uses the "moment" lib to parse dates and coerce strings into the date type.
|
35
45
|
date:
|
36
|
-
get: (val)-> new Date(val)
|
46
|
+
get: (val) -> new Date(val)
|
37
47
|
default: -> return new Date()
|
38
|
-
set: (newVal)->
|
48
|
+
set: (newVal) ->
|
39
49
|
if _.isDate(newVal)
|
40
|
-
newType='date'
|
41
|
-
newVal = newVal.valueOf()
|
50
|
+
newType = 'date'
|
51
|
+
newVal = newVal.valueOf()
|
42
52
|
else
|
43
|
-
m=Lanes.Vendor.Moment(newVal)
|
53
|
+
m = Lanes.Vendor.Moment(newVal)
|
44
54
|
if m.isValid()
|
45
|
-
newType='date'
|
46
|
-
newVal=m.toDate()
|
55
|
+
newType = 'date'
|
56
|
+
newVal = m.toDate()
|
47
57
|
else
|
48
58
|
newType = typeof newVal;
|
49
59
|
return {
|
@@ -51,7 +61,7 @@ class BaseModel
|
|
51
61
|
type: newType
|
52
62
|
}
|
53
63
|
|
54
|
-
constructor: (attrs,options={})->
|
64
|
+
constructor: (attrs, options = {}) ->
|
55
65
|
super
|
56
66
|
@changeMonitor = new Lanes.Models.ChangeMonitor(this)
|
57
67
|
# The model was created with attributes and it did not originate from a XHR request
|
@@ -65,171 +75,153 @@ class BaseModel
|
|
65
75
|
|
66
76
|
# is the record saved
|
67
77
|
isPersistent: ->
|
68
|
-
!!( _.result(this,'api_path') && !this.isNew() )
|
78
|
+
!!( _.result(this, 'api_path') && !this.isNew() )
|
69
79
|
|
70
80
|
# used by PubSub to record a remote change to the model
|
71
|
-
addChangeSet: (change)->
|
72
|
-
|
73
|
-
change.
|
74
|
-
|
75
|
-
|
81
|
+
addChangeSet: (change) ->
|
82
|
+
change = new Lanes.Models.ChangeSet(change)
|
83
|
+
this.set( change.value(), silent: true )
|
84
|
+
for name, value of change.value()
|
85
|
+
this.trigger("remote-update:#{name}", "changeset", this, change)
|
86
|
+
this.triggerChangeSet(this, change)
|
87
|
+
|
88
|
+
triggerChangeSet: (triggered, change) ->
|
89
|
+
this.changes ||= new Lanes.Models.ChangeSet.Collection( parent: this )
|
90
|
+
this.changes.add(change)
|
91
|
+
this.trigger('remote-update', triggered, change)
|
92
|
+
@parent?.triggerChangeSet?(triggered, change)
|
76
93
|
|
77
94
|
api_path: ->
|
78
95
|
path = if this.FILE then _.last(this.FILE.path) else ''
|
79
96
|
_.pluralize(_.dasherize(path))
|
80
97
|
|
81
98
|
urlRoot: ->
|
82
|
-
Lanes.config.api_path + '/' + _.result(this,'api_path')
|
99
|
+
Lanes.config.api_path + '/' + _.result(this, 'api_path')
|
83
100
|
|
84
101
|
# Default URL for the model's representation on the server
|
85
102
|
url: ->
|
86
|
-
base = _.result(this, 'urlRoot') || _.result(this.collection, 'url') || Lanes.Models.Sync.urlError()
|
87
|
-
if this.isNew() then return base
|
103
|
+
base = _.result(this, 'urlRoot') || _.result(this.collection, 'url') || Lanes.Models.Sync.urlError()
|
104
|
+
if this.isNew() then return base
|
88
105
|
if base.charAt(base.length - 1) != '/'
|
89
|
-
|
106
|
+
base += "/"
|
90
107
|
return base + encodeURIComponent(this.getId())
|
91
108
|
|
92
109
|
|
93
|
-
# Ensures the assocations given in "
|
94
|
-
withAssociations: (names...,options={})->
|
110
|
+
# Ensures the assocations given in "names" are loaded
|
111
|
+
withAssociations: (names..., options = {}) ->
|
95
112
|
if _.isString(options)
|
96
|
-
names.push(options); options={}
|
97
|
-
|
98
|
-
needed = this.associations?.nonLoaded(this,names)
|
113
|
+
names.push(options); options = {}
|
114
|
+
needed = this.associations?.nonLoaded(this, names)
|
99
115
|
if _.isEmpty( needed )
|
100
|
-
|
101
|
-
options.complete.call(scope,this ) if options.complete
|
102
|
-
return _.Promise.resolve({record:this,reply:{}})
|
116
|
+
return _.Promise.resolve(this)
|
103
117
|
else
|
104
|
-
options['include']=needed
|
118
|
+
options['include'] = needed
|
105
119
|
this.fetch(options)
|
106
120
|
|
107
121
|
|
108
|
-
# Searches the PubSub idenity map for a record of the same type and matching id
|
109
|
-
# If one is found, it will update it with the given attributes and return it
|
110
|
-
# When not found, it will create a new record and return it.
|
111
|
-
# The newly created record will not be stored in the PubSub map,
|
112
|
-
# as only records bound to a view are stored there
|
113
|
-
@findOrCreate: (attrs, options={})->
|
114
|
-
if attrs.id && ( record = Lanes.Models.PubSub.instanceFor(this, attrs.id) )
|
115
|
-
record.set(attrs)
|
116
|
-
else
|
117
|
-
new this(attrs,options)
|
118
|
-
|
119
122
|
# Calls Ampersand State's set method, then sets any associations that are present as well
|
120
|
-
set: (key, value, options)->
|
123
|
+
set: (key, value, options) ->
|
121
124
|
# Handle both `"key", value` and `{key: value}` -style arguments.
|
122
125
|
if _.isObject(key) || key == null
|
123
|
-
attrs = key
|
124
|
-
options = value
|
126
|
+
attrs = key
|
127
|
+
options = value
|
125
128
|
else
|
126
129
|
attrs = {}
|
127
130
|
attrs[key] = value
|
128
131
|
super
|
129
|
-
this.associations.set(this,attrs) if this.associations
|
132
|
+
this.associations.set(this, attrs) if this.associations
|
130
133
|
this
|
131
134
|
|
132
135
|
# Loads records from the server that match query, returns a collection
|
133
|
-
@where: (query, options)->
|
136
|
+
@where: (query, options) ->
|
134
137
|
this.Collection.fetch( _.extend({query: query}, options) )
|
135
138
|
|
136
139
|
# Load a single record using an ID and the query options
|
137
|
-
@fetchById: (id, options={})->
|
140
|
+
@fetchById: (id, options = {}) ->
|
138
141
|
record = new this(id: id)
|
139
142
|
record.fetch(options)
|
140
143
|
record
|
141
144
|
|
142
145
|
# Sets the attribute data from a server respose
|
143
|
-
setFromServer: (data,options)->
|
144
|
-
|
145
|
-
|
146
|
+
setFromServer: (data, options) ->
|
147
|
+
data = if _.isArray(data) then data[0] else data
|
148
|
+
BaseModel.__super__.set.call(this, data )
|
149
|
+
this.associations.setFromServer(this, data) if this.associations
|
146
150
|
this.isDirty = false
|
147
151
|
|
148
152
|
# save the model's data to the server
|
149
153
|
# Only unsaved attributes will be sent unless
|
150
154
|
# the saveAll options is set to true
|
151
|
-
save: (options={})->
|
155
|
+
save: (options = {}) ->
|
152
156
|
options = _.clone(options)
|
153
|
-
|
154
|
-
options.saving=true
|
155
|
-
|
156
|
-
handlers = Lanes.Models.Sync.wrapRequest(this,options)
|
157
|
+
options.saving = true
|
157
158
|
|
158
159
|
method = if this.isNew()
|
159
160
|
'create'
|
160
161
|
else
|
161
162
|
if options.saveAll then 'update' else 'patch'
|
162
163
|
|
163
|
-
|
164
|
+
this.sync(method, this, options)
|
164
165
|
|
165
|
-
handlers.promise
|
166
166
|
|
167
167
|
# Fetch the model from the server. If the server's representation of the
|
168
168
|
# model differs from its current attributes, they will be overridden,
|
169
169
|
# triggering a `"change"` event.
|
170
|
-
fetch: (original_options={}) ->
|
170
|
+
fetch: (original_options = {}) ->
|
171
171
|
options = _.clone(original_options)
|
172
|
-
|
172
|
+
|
173
173
|
if this.cacheDuration && _.isEmpty(original_options)
|
174
174
|
Lanes.Models.ServerCache.fetchRecord(this, options)
|
175
175
|
else
|
176
|
-
_.extend(options,{limit:1,ignoreUnsaved:true})
|
176
|
+
_.extend(options, {limit:1, ignoreUnsaved:true})
|
177
177
|
this.sync('read', this, options)
|
178
|
-
handlers.promise
|
179
178
|
|
180
|
-
|
179
|
+
|
180
|
+
@fetch: (options = {}) ->
|
181
181
|
record = new this()
|
182
182
|
record.fetch(options)
|
183
183
|
|
184
184
|
# Removes the model's record from the server (if it is persistent)
|
185
185
|
# and then fires the "destroy" event
|
186
|
-
destroy: (options={})->
|
187
|
-
handlers = Lanes.Models.Sync.wrapRequest(this,options)
|
188
|
-
model = this
|
189
|
-
success = options.success
|
190
|
-
options.success = (reply, msg, options)->
|
191
|
-
model.trigger('destroy', model, model.collection, options)
|
192
|
-
if success then success(model, reply, options)
|
193
|
-
|
186
|
+
destroy: (options = {}) ->
|
194
187
|
if this.isNew()
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
188
|
+
_.Promise.resolve(this)
|
189
|
+
this.sync('delete', this, options).then (model) ->
|
190
|
+
model.trigger('destroy', model, model.collection, options)
|
191
|
+
model
|
199
192
|
|
200
193
|
# returns any attributes that have been set and not saved
|
201
194
|
unsavedAttributes: ->
|
202
|
-
attrs = {}
|
195
|
+
attrs = {}
|
203
196
|
_.extend(attrs, _.pick( this.getAttributes(props:true, true),
|
204
197
|
@changeMonitor.changedAttributes() ) )
|
205
|
-
unless _.isEmpty(attrs) or this.isNew()
|
206
|
-
attrs.id = this.getId()
|
207
198
|
attrs
|
208
199
|
|
209
200
|
# returns data to save to server. If options.saveAll is true,
|
210
201
|
# all data is returned. Otherwise only unsaved attributes (and associations)
|
211
202
|
# are returned.
|
212
|
-
dataForSave: (options={})->
|
203
|
+
dataForSave: (options = {}) ->
|
213
204
|
if options.saveAll || this.isNew()
|
214
205
|
data = this.getAttributes(props:true, true)
|
215
206
|
else
|
216
207
|
data = this.unsavedAttributes()
|
217
208
|
if this.associations && (!_.isEmpty(data) || !this.isNew())
|
209
|
+
data.id = this.getId() unless this.isNew()
|
218
210
|
_.extend(data, this.associations.dataForSave(this, options))
|
219
211
|
data
|
220
212
|
|
221
213
|
|
222
214
|
# True if the model has "name" as either a prop or session attribute
|
223
|
-
hasAttribute: (name)->
|
215
|
+
hasAttribute: (name) ->
|
224
216
|
!! (this._definition[name] || this._derived[name])
|
225
217
|
|
226
218
|
# Uses Lanes.Models.Sync by default
|
227
|
-
sync: (options...)->
|
228
|
-
Lanes.Models.Sync.
|
219
|
+
sync: (options...) ->
|
220
|
+
Lanes.Models.Sync.state(options...)
|
229
221
|
|
230
222
|
# When the model is extended it auto-creates the created_at and updated_at
|
231
223
|
# and sets up the AssociationMap
|
232
|
-
@extended: (klass)->
|
224
|
+
@extended: (klass) ->
|
233
225
|
return if klass::abstractClass
|
234
226
|
klass::props ||= {}
|
235
227
|
klass::session ||= {}
|
@@ -240,7 +232,7 @@ class BaseModel
|
|
240
232
|
if klass::associations
|
241
233
|
klass::associations = new Lanes.Models.AssocationMap(klass)
|
242
234
|
|
243
|
-
@afterExtended: (klass)->
|
235
|
+
@afterExtended: (klass) ->
|
244
236
|
return if klass::abstractClass
|
245
237
|
unless klass.Collection
|
246
238
|
@createDefaultCollectionFor(klass)
|
@@ -249,7 +241,7 @@ class BaseModel
|
|
249
241
|
klass::enums = new Lanes.Models.EnumMap(klass)
|
250
242
|
|
251
243
|
|
252
|
-
@createDefaultCollectionFor: (klass)->
|
244
|
+
@createDefaultCollectionFor: (klass) ->
|
253
245
|
name = "#{klass.name}Collection"
|
254
246
|
Collection = new Function("return function #{name}(){
|
255
247
|
#{name}.__super__.constructor.apply(this, arguments);
|
@@ -265,6 +257,15 @@ class BaseModel
|
|
265
257
|
|
266
258
|
class State
|
267
259
|
constructor: -> super
|
260
|
+
isState: true
|
261
|
+
|
262
|
+
# ## listenToAndRun
|
263
|
+
# Shortcut for registering a listener for a model
|
264
|
+
# and also triggering it right away.
|
265
|
+
listenToAndRun: (object, events, handler) ->
|
266
|
+
bound = _.bind(handler, this)
|
267
|
+
this.listenTo(object, events, bound)
|
268
|
+
bound()
|
268
269
|
|
269
270
|
Lanes.Models.State = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.State, State )
|
270
271
|
|
@@ -279,7 +280,7 @@ class BasicModel
|
|
279
280
|
|
280
281
|
# Check if an attribute named "name" can be set to "value"
|
281
282
|
# Returns an empty string if value, and an appropriate error message if not
|
282
|
-
checkValid: (name, value)->
|
283
|
+
checkValid: (name, value) ->
|
283
284
|
return '' unless def = this._definition[name]
|
284
285
|
if def.required && _.isEmpty(value)
|
285
286
|
"Cannot be empty"
|
@@ -288,11 +289,11 @@ class BasicModel
|
|
288
289
|
|
289
290
|
# sets the model from a user interaction
|
290
291
|
# subviews may override this to provide a custom implementation
|
291
|
-
setFromView: (key,value)->
|
292
|
-
this.set(key,value)
|
292
|
+
setFromView: (key, value) ->
|
293
|
+
this.set(key, value)
|
293
294
|
|
294
295
|
# True if the model has "name" as eitehr a prop or session attribute
|
295
|
-
hasAttribute: (name)->
|
296
|
+
hasAttribute: (name) ->
|
296
297
|
!! (this._definition[name] || this._derived[name])
|
297
298
|
|
298
299
|
Lanes.Models.BasicModel = State.extend( BasicModel )
|
@@ -4,29 +4,29 @@
|
|
4
4
|
# ------------------------------------------------------------------ #
|
5
5
|
|
6
6
|
class Lanes.Models.ChangeMonitor
|
7
|
-
constructor: (model)->
|
7
|
+
constructor: (model) ->
|
8
8
|
model.on('change', this.onChange, this)
|
9
|
-
model.on('change:isDirty', this.onDirtyChange, this)
|
10
9
|
|
11
|
-
onChange: (record,options)->
|
10
|
+
onChange: (record, options) ->
|
12
11
|
attrs = record.changedAttributes()
|
13
12
|
return if _.isEmpty(attrs)
|
14
|
-
|
15
|
-
|
13
|
+
if attrs.isDirty == false
|
14
|
+
delete @_unsaved
|
15
|
+
else
|
16
|
+
@_unsaved ||= {}
|
17
|
+
this.recordChanges(record, _.keys(attrs))
|
16
18
|
|
17
19
|
|
18
|
-
recordChanges: (record,names) ->
|
20
|
+
recordChanges: (record, names) ->
|
21
|
+
# console.log "Change: #{names}"
|
22
|
+
#console.log record.getAttributes(props:true, session: true)
|
19
23
|
for name in names
|
20
24
|
if name != record.idAttribute && record._definition[name] && !record._definition[name].session
|
21
25
|
record.isDirty = true
|
22
26
|
@_unsaved[ name ] = true
|
23
27
|
|
24
|
-
onDirtyChange: (record,isDirty)->
|
25
|
-
delete @_unsaved if !isDirty
|
26
|
-
|
27
28
|
changedAttributes: ->
|
28
29
|
_.keys(@_unsaved)
|
29
30
|
|
30
|
-
|
31
31
|
isDirty: ->
|
32
32
|
!_.isEmpty(@_unsaved)
|
@@ -1,49 +1,39 @@
|
|
1
1
|
class Lanes.Models.ChangeSet extends Lanes.Models.Base
|
2
2
|
|
3
|
-
|
4
3
|
constructor: ->
|
5
4
|
super
|
6
5
|
this.created_at = new Date
|
7
|
-
this.updateTimeAgo()
|
8
6
|
|
9
7
|
session:
|
10
8
|
update: 'object'
|
11
9
|
by: 'object'
|
12
|
-
record: 'model'
|
13
|
-
time_ago: 'string'
|
14
10
|
created_at: { type: 'date', setOnce: true }
|
15
11
|
|
16
12
|
derived:
|
13
|
+
record: { deps: ['collection'], fn: -> @collection.parent }
|
14
|
+
record_name: { deps: ['record'], fn: -> _.field2title @record.api_path() }
|
17
15
|
fields: { deps: ['update'], fn: -> _.keys(@update) }
|
18
16
|
displayed_fields: { deps:['fields'], fn: -> _.without(@fields, 'updated_by_id', 'updated_at') }
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
displayed_changes:
|
18
|
+
deps: ['displayed_fields'], fn: ->
|
19
|
+
_.map @displayed_fields, (field) =>
|
20
|
+
c = @update[field]
|
21
|
+
{ name: field, from: c[0], to: c[1] }
|
23
22
|
|
24
23
|
value: ->
|
25
|
-
set={}
|
24
|
+
set = {}
|
26
25
|
for field, change of @update
|
27
26
|
set[field] = change[1]
|
28
27
|
set
|
29
28
|
|
30
|
-
|
31
|
-
@time_ago = Lanes.Vendor.Moment( @created_at ).fromNow()
|
32
|
-
|
33
|
-
|
34
|
-
class Lanes.Models.ChangeSetCollection extends Lanes.Models.BasicCollection
|
29
|
+
class ChangeSetCollection extends Lanes.Models.BasicCollection
|
35
30
|
|
36
31
|
model: Lanes.Models.ChangeSet
|
37
32
|
|
38
|
-
constructor: (options)->
|
39
|
-
super([],options)
|
40
|
-
this.on("add", this.onAdd, this )
|
41
|
-
|
42
|
-
onAdd: (change)->
|
43
|
-
record = this.parent
|
44
|
-
while record
|
45
|
-
record.trigger('remote-update', record, change);
|
46
|
-
record = record.parent
|
33
|
+
constructor: (options) ->
|
34
|
+
super([], options)
|
47
35
|
|
48
|
-
comparator: (a,b)->
|
36
|
+
comparator: (a, b) ->
|
49
37
|
if b.created_at < a.created_at then -1 else if b.created_at > a.created_at then 1 else 0
|
38
|
+
|
39
|
+
Lanes.Models.ChangeSet.Collection = ChangeSetCollection
|
@@ -11,27 +11,28 @@ CommonMethods = {
|
|
11
11
|
found
|
12
12
|
|
13
13
|
# convenience method to create a new subCollection
|
14
|
-
subcollection: (options)->
|
14
|
+
subcollection: (options) ->
|
15
15
|
new Lanes.Models.SubCollection(this, options)
|
16
16
|
|
17
|
-
destroyAll: (options={})->
|
18
|
-
|
17
|
+
destroyAll: (options = {}) ->
|
18
|
+
existing = _.clone(this.models)
|
19
19
|
_.extend( options, {
|
20
|
-
data:
|
21
|
-
success: =>
|
22
|
-
for model in @models
|
23
|
-
model.trigger('destroy', model, model.collection, options)
|
24
|
-
success.apply(@,arguments) if success
|
20
|
+
data: _.map(existing, (m) -> {id: m.id})
|
25
21
|
})
|
26
|
-
Lanes.Models.Sync.
|
22
|
+
Lanes.Models.Sync.state('delete', this, options).then( ->
|
23
|
+
_.each(existing, (model) ->
|
24
|
+
model.trigger('destroy', model, model.collection, options)
|
25
|
+
)
|
26
|
+
return this
|
27
|
+
)
|
27
28
|
|
28
29
|
}
|
29
30
|
|
30
31
|
class ModelsCollection
|
31
32
|
|
32
33
|
constructor: ->
|
33
|
-
@_isLoaded=false
|
34
|
-
@errors=[]
|
34
|
+
@_isLoaded = false
|
35
|
+
@errors = []
|
35
36
|
Lanes.Vendor.Ampersand.Collection.apply(this, arguments)
|
36
37
|
this.on('add remove reset', this._triggerLengthEvent )
|
37
38
|
|
@@ -40,50 +41,52 @@ class ModelsCollection
|
|
40
41
|
|
41
42
|
# convenience method to instantiate a collection
|
42
43
|
# then call fetch on it with the options provided
|
43
|
-
@fetch: (options)->
|
44
|
+
@fetch: (options) ->
|
44
45
|
collection = new this
|
45
46
|
collection.fetch(options)
|
46
47
|
collection
|
47
48
|
|
48
49
|
# Fetch the a set of models for the collection, replacing all
|
49
50
|
# current models whith them when the call completes
|
50
|
-
fetch: (options={})->
|
51
|
-
handlers = Lanes.Models.Sync.wrapRequest(this,options)
|
51
|
+
fetch: (options = {}) ->
|
52
52
|
if this.cacheDuration
|
53
53
|
Lanes.Models.ServerCache.fetchCollection(this, options)
|
54
54
|
else
|
55
55
|
this.sync('read', this, options)
|
56
|
-
handlers.promise
|
57
56
|
|
58
|
-
ensureLoaded: (options={})->
|
59
|
-
handlers = Lanes.Models.Sync.wrapRequest(this,options)
|
57
|
+
ensureLoaded: (options = {}) ->
|
60
58
|
if options.force || (!@_isLoaded && !this.length )
|
61
59
|
this.fetch(options)
|
62
60
|
else
|
63
|
-
|
64
|
-
handlers.promise
|
61
|
+
_.Promise.resolve(this)
|
65
62
|
|
66
63
|
# Call the callback function when the current fetch succeeds
|
67
64
|
# If the collection is not currently being loaded,
|
68
65
|
# the callback is immediatly invoked
|
69
|
-
whenLoaded: (cb)->
|
66
|
+
whenLoaded: (cb) ->
|
70
67
|
if this.requestInProgress
|
71
|
-
cb(this)
|
72
|
-
else
|
73
68
|
this._loaded_callbacks ||= []
|
74
69
|
this._loaded_callbacks.push(cb)
|
70
|
+
else
|
71
|
+
cb(this)
|
75
72
|
this
|
76
73
|
|
77
74
|
# Sets the attribute data from a server respose
|
78
|
-
setFromServer: (data, options)->
|
75
|
+
setFromServer: (data, options, method) ->
|
79
76
|
@_isLoaded = true
|
80
|
-
|
81
|
-
|
77
|
+
if 'delete' == method
|
78
|
+
models = _.map(_.pluck(options.originalData, 'id'), (id) =>
|
79
|
+
@get(id)
|
80
|
+
)
|
81
|
+
this.remove(models)
|
82
|
+
else
|
83
|
+
update = if options.reset then 'reset' else 'set'
|
84
|
+
this[update](data, options)
|
82
85
|
if this._loaded_callbacks
|
83
86
|
cb(this) for cb in this._loaded_callbacks
|
84
87
|
delete this._loaded_callbacks
|
85
88
|
|
86
|
-
isLoaded
|
89
|
+
isLoaded: -> @_isLoaded
|
87
90
|
|
88
91
|
# true if any models have unsaved data
|
89
92
|
isDirty: ->
|
@@ -92,29 +95,22 @@ class ModelsCollection
|
|
92
95
|
url: -> @model::urlRoot()
|
93
96
|
|
94
97
|
# Uses Lanes.Models.Sync by default
|
95
|
-
sync: (options...)->
|
96
|
-
Lanes.Models.Sync.
|
98
|
+
sync: (options...) ->
|
99
|
+
Lanes.Models.Sync.state(options...)
|
97
100
|
|
98
|
-
save: (options)->
|
99
|
-
Lanes.Models.Sync.
|
101
|
+
save: (options) ->
|
102
|
+
Lanes.Models.Sync.state('update', this, options)
|
100
103
|
|
101
104
|
# returns data to save to server. If options.saveAll is true,
|
102
105
|
# all attributes from all models data is returned.
|
103
106
|
# Otherwise only unsaved attributes are returned.
|
104
|
-
dataForSave: (options)->
|
107
|
+
dataForSave: (options) ->
|
105
108
|
unsaved = []
|
106
109
|
for model in @models
|
107
110
|
if options.saveAll || model.isDirty
|
108
111
|
unsaved.push( model.dataForSave(options) )
|
109
112
|
unsaved
|
110
113
|
|
111
|
-
_prepareModel: (attrs, options={})->
|
112
|
-
options.collection = this;
|
113
|
-
if this.isModel(attrs)
|
114
|
-
attrs
|
115
|
-
else
|
116
|
-
this.model.findOrCreate(attrs, options)
|
117
|
-
|
118
114
|
mixins:[
|
119
115
|
CommonMethods
|
120
116
|
]
|
@@ -143,6 +139,9 @@ class SubCollection
|
|
143
139
|
filter: ->
|
144
140
|
this._runFilters()
|
145
141
|
|
142
|
+
setFromServer: (data, options, type) ->
|
143
|
+
@collection.setFromServer(data, options, type)
|
144
|
+
|
146
145
|
Lanes.Models.SubCollection = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.SubCollection, SubCollection )
|
147
146
|
|
148
147
|
Lanes.Models.BasicCollection = Lanes.lib.MakeBaseClass(
|
@@ -156,17 +155,17 @@ Lanes.Models.Collection = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.RestCo
|
|
156
155
|
## Override a few methods on the standard collection to ensure that
|
157
156
|
# models are fetched correctly and have the fk set when they're created
|
158
157
|
class Lanes.Models.AssociationCollection extends Lanes.Models.Collection
|
159
|
-
constructor: (models,options)->
|
158
|
+
constructor: (models, options) ->
|
160
159
|
@model = options.model
|
161
160
|
@associationFilter = options.filter
|
162
161
|
super
|
163
162
|
|
164
|
-
_prepareModel: (attrs, options={})->
|
163
|
+
_prepareModel: (attrs, options = {}) ->
|
165
164
|
model = super
|
166
165
|
model.set(@associationFilter)
|
167
166
|
model
|
168
167
|
|
169
|
-
fetch: (options)->
|
168
|
+
fetch: (options) ->
|
170
169
|
options.query ||= {}
|
171
170
|
_.extend(options.query, @associationFilter)
|
172
171
|
super(options)
|