lanes 0.1.9.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Rakefile +1 -1
- data/client/lanes/Boot.cjsx +3 -3
- data/client/lanes/Config.coffee +38 -3
- data/client/lanes/access/Extension.coffee +1 -1
- data/client/lanes/access/LoginDialog.cjsx +57 -47
- data/client/lanes/access/Roles.coffee +2 -2
- data/client/lanes/access/User.coffee +4 -3
- data/client/lanes/access/screens/user-management/UserManagement.cjsx +12 -11
- data/client/lanes/components/calendar/Calendar.cjsx +16 -0
- data/client/lanes/components/calendar/index.js +3 -0
- data/client/lanes/components/calendar/styles.scss +3 -0
- data/client/lanes/components/grid/Body.cjsx +86 -0
- data/client/lanes/components/grid/CellStyles.coffee +20 -0
- data/client/lanes/components/grid/EditingMixin.cjsx +84 -24
- data/client/lanes/components/grid/Editor.cjsx +45 -0
- data/client/lanes/components/grid/Grid.cjsx +62 -104
- data/client/lanes/components/grid/Header.cjsx +35 -0
- data/client/lanes/components/grid/PopOverMixin.cjsx +19 -9
- data/client/lanes/components/grid/PopoverEditor.cjsx +7 -1
- data/client/lanes/components/grid/RowEditor.cjsx +1 -1
- data/client/lanes/components/grid/Selections.cjsx +39 -0
- data/client/lanes/components/grid/Toolbar.cjsx +24 -5
- data/client/lanes/components/grid/editors.scss +22 -50
- data/client/lanes/components/grid/index.js +0 -1
- data/client/lanes/components/grid/row-editor.scss +68 -0
- data/client/lanes/components/grid/styles.scss +79 -3
- data/client/lanes/components/modal/Modal.cjsx +64 -24
- data/client/lanes/components/modal/styles.scss +12 -0
- data/client/lanes/components/record-finder/Clause.cjsx +11 -4
- data/client/lanes/components/record-finder/Dialog.cjsx +23 -24
- data/client/lanes/components/record-finder/RecordFinder.cjsx +45 -14
- data/client/lanes/components/record-finder/styles.scss +9 -6
- data/client/lanes/components/select-field/SelectField.cjsx +108 -53
- data/client/lanes/components/select-field/styles.scss +19 -0
- data/client/lanes/components/shared/ControlLabel.cjsx +45 -0
- data/client/lanes/components/shared/DateTime.cjsx +48 -0
- data/client/lanes/components/shared/DisplayValue.cjsx +16 -0
- data/client/lanes/components/shared/FieldMixin.cjsx +54 -23
- data/client/lanes/components/shared/FieldSet.cjsx +12 -35
- data/client/lanes/components/shared/FieldWrapper.cjsx +13 -0
- data/client/lanes/components/shared/FormGroup.cjsx +37 -0
- data/client/lanes/components/shared/Icon.cjsx +20 -0
- data/client/lanes/components/shared/ImageSaver.cjsx +33 -0
- data/client/lanes/components/shared/Input.cjsx +19 -0
- data/client/lanes/components/shared/InputFieldMixin.cjsx +48 -0
- data/client/lanes/components/shared/JobProgress.cjsx +27 -0
- data/client/lanes/components/shared/NetworkActivityOverlay.cjsx +58 -0
- data/client/lanes/components/shared/NumberInput.cjsx +29 -0
- data/client/lanes/components/shared/ResizeSensor.cjsx +11 -0
- data/client/lanes/components/shared/ScreenWrapper.cjsx +13 -0
- data/client/lanes/components/shared/Throbber.cjsx +3 -0
- data/client/lanes/components/shared/ToggleField.cjsx +33 -0
- data/client/lanes/components/shared/Tooltip.cjsx +2 -2
- data/client/lanes/components/shared/fields.scss +75 -13
- data/client/lanes/components/shared/fieldset.scss +3 -5
- data/client/lanes/components/shared/image-saver.scss +38 -0
- data/client/lanes/components/shared/index.js +2 -0
- data/client/lanes/{styles/plugins → components/shared}/overlay.scss +17 -4
- data/client/lanes/components/shared/resize-sensor.scss +30 -0
- data/client/lanes/components/shared/styles.scss +13 -0
- data/client/lanes/components/shared/throbber.scss +53 -0
- data/client/lanes/components/toolbar/RemoteChangeSets.cjsx +21 -48
- data/client/lanes/components/toolbar/SaveButton.cjsx +24 -0
- data/client/lanes/components/toolbar/Toolbar.cjsx +24 -37
- data/client/lanes/components/toolbar/changes-notification.scss +10 -6
- data/client/lanes/components/toolbar/styles.scss +29 -9
- data/client/lanes/extension/Base.coffee +4 -5
- data/client/lanes/index.js +0 -1
- data/client/lanes/index.scss.erb +10 -1
- data/client/lanes/lib/HotReload.coffee +13 -15
- data/client/lanes/lib/MakeBaseClass.coffee +6 -1
- data/client/lanes/lib/development.coffee +2 -0
- data/client/lanes/lib/dom-polyfills.coffee +5 -0
- data/client/lanes/lib/dom.coffee +38 -9
- data/client/lanes/lib/format.coffee +11 -0
- data/client/lanes/lib/index.js.erb +2 -0
- data/client/lanes/lib/production.coffee +6 -0
- data/client/lanes/lib/utilFunctions.coffee +50 -15
- data/client/lanes/models/AssociationMap.coffee +122 -46
- data/client/lanes/models/AssociationProxy.coffee +147 -0
- data/client/lanes/models/Base.coffee +97 -85
- data/client/lanes/models/ChangeMonitor.coffee +7 -3
- data/client/lanes/models/ChangeSet.coffee +2 -2
- data/client/lanes/models/Collection.coffee +49 -6
- data/client/lanes/models/JobStatus.coffee +32 -0
- data/client/lanes/models/PubSub.coffee +7 -5
- data/client/lanes/models/Query.coffee +115 -34
- data/client/lanes/models/ServerCache.coffee +67 -52
- data/client/lanes/models/State.coffee +97 -0
- data/client/lanes/models/Sync.coffee +18 -13
- data/client/lanes/models/SystemSettings.coffee +0 -0
- data/client/lanes/models/index.js +1 -0
- data/client/lanes/models/mixins/FileSupport.coffee +60 -0
- data/client/lanes/models/mixins/HasCodeField.coffee +13 -6
- data/client/lanes/models/query/ArrayResult.coffee +188 -0
- data/client/lanes/models/query/CollectionResult.coffee +71 -0
- data/client/lanes/models/query/Result.coffee +9 -0
- data/client/lanes/react/Component.coffee +7 -3
- data/client/lanes/react/PubSub.coffee +7 -7
- data/client/lanes/react/Root.cjsx +1 -4
- data/client/lanes/react/Screen.coffee +1 -0
- data/client/lanes/react/TypeValidators.coffee +3 -3
- data/client/lanes/react/Viewport.coffee +41 -7
- data/client/lanes/react/index.js +0 -1
- data/client/lanes/react/mixins/Access.coffee +4 -1
- data/client/lanes/react/mixins/Data.coffee +40 -25
- data/client/lanes/react/mixins/FieldErrors.coffee +27 -0
- data/client/lanes/react/mixins/RelayEditingState.coffee +4 -0
- data/client/lanes/react/mixins/Screen.coffee +14 -0
- data/client/lanes/react/mixins/Viewport.coffee +9 -3
- data/client/lanes/screens/ChangeListener.coffee +3 -3
- data/client/lanes/screens/Commands.coffee +14 -7
- data/client/lanes/screens/CommonComponents.cjsx +20 -0
- data/client/lanes/screens/Definitions.coffee +64 -20
- data/client/lanes/screens/SystemSettings.cjsx +56 -0
- data/client/lanes/screens/UserPreferences.cjsx +38 -0
- data/client/lanes/screens/index.js +3 -0
- data/client/lanes/screens/styles.scss +2 -1
- data/client/lanes/styles/fonts.scss +1 -0
- data/client/lanes/styles/global.scss +2 -1
- data/client/lanes/styles/global/flexbox.scss +16 -0
- data/client/lanes/styles/global/styles.scss +1 -0
- data/client/lanes/styles/mixins/_dropdown.scss +21 -0
- data/client/lanes/styles/mixins/_flexbox.scss +394 -0
- data/client/lanes/styles/mixins/all.scss +2 -0
- data/client/lanes/styles/variables.scss +28 -0
- data/client/lanes/testing/BeforeEach.coffee +15 -14
- data/client/lanes/testing/Helpers.coffee +14 -5
- data/client/lanes/testing/TestObjects.coffee +10 -2
- data/client/lanes/testing/index.js +1 -0
- data/client/lanes/testing/jasmine-react.js +125 -0
- data/client/lanes/vendor/base.js +56049 -74987
- data/client/lanes/vendor/calendar.js +17301 -0
- data/client/lanes/vendor/calendar.scss +303 -0
- data/client/lanes/vendor/commons.js +14990 -15847
- data/client/lanes/vendor/development.js +4912 -1952
- data/client/lanes/vendor/grid.js +14246 -5551
- data/client/lanes/vendor/grid.scss +876 -335
- data/client/lanes/vendor/index.js +1 -0
- data/client/lanes/vendor/message-bus-ajax.js +44 -0
- data/client/lanes/vendor/message-bus.js +414 -0
- data/client/lanes/vendor/rw-widgets.eot +0 -0
- data/client/lanes/vendor/rw-widgets.svg +18 -0
- data/client/lanes/vendor/rw-widgets.ttf +0 -0
- data/client/lanes/vendor/rw-widgets.woff +0 -0
- data/client/lanes/vendor/toggle.js +345 -0
- data/client/lanes/vendor/toggle.scss +138 -0
- data/client/lanes/vendor/widgets.js +21245 -6839
- data/client/lanes/vendor/widgets.scss +83 -67
- data/client/lanes/workspace/Layout.cjsx +18 -8
- data/client/lanes/workspace/Modal.cjsx +47 -0
- data/client/lanes/workspace/Navbar.cjsx +16 -2
- data/client/lanes/workspace/ScreenView.cjsx +10 -3
- data/client/lanes/workspace/ScreensMenu.cjsx +23 -7
- data/client/lanes/workspace/Tabs.cjsx +55 -0
- data/client/lanes/workspace/UIState.coffee +7 -8
- data/client/lanes/workspace/index.js +2 -1
- data/client/lanes/workspace/mixin.coffee +11 -0
- data/client/lanes/workspace/mixins/UIState.coffee +8 -0
- data/client/lanes/workspace/mixins/index.js +3 -0
- data/client/lanes/workspace/styles.scss +2 -1
- data/client/lanes/workspace/styles/header.scss +23 -1
- data/client/lanes/workspace/styles/layout.scss +26 -24
- data/client/lanes/workspace/styles/screens.scss +0 -4
- data/client/lanes/workspace/styles/tabs.scss +3 -10
- data/config/routes.rb +10 -4
- data/config/screens.rb +25 -0
- data/db/migrate/01_create_system_settings.rb +10 -0
- data/docs/todo-example-part-1.md +18 -20
- data/lanes.gemspec +15 -6
- data/lib/lanes.rb +4 -2
- data/lib/lanes/access/config/routes.rb +5 -3
- data/lib/lanes/access/config/screens.rb +1 -0
- data/lib/lanes/access/db/migrate/20140615031600_create_lanes_users.rb +1 -1
- data/lib/lanes/access/user.rb +1 -1
- data/lib/lanes/api.rb +2 -1
- data/lib/lanes/api/controller.rb +32 -71
- data/lib/lanes/api/default_routes.rb +10 -8
- data/lib/lanes/api/formatted_reply.rb +53 -0
- data/lib/lanes/api/handlers/file.rb +26 -0
- data/lib/lanes/api/helper_methods.rb +29 -5
- data/lib/lanes/api/javascript_processor.rb +36 -17
- data/lib/lanes/api/pub_sub.rb +6 -9
- data/lib/lanes/api/request_wrapper.rb +1 -2
- data/lib/lanes/api/root.rb +11 -43
- data/lib/lanes/api/routing.rb +63 -0
- data/lib/lanes/api/sprockets_extension.rb +15 -7
- data/lib/lanes/api/updates.rb +1 -2
- data/lib/lanes/command.rb +0 -1
- data/lib/lanes/command/app.rb +6 -5
- data/lib/lanes/command/console.rb +1 -0
- data/lib/lanes/command/generate.rb +3 -0
- data/lib/lanes/command/generate_migration.rb +33 -0
- data/lib/lanes/command/generate_model.rb +4 -26
- data/lib/lanes/command/migration_support.rb +29 -0
- data/lib/lanes/command/update_model.rb +14 -5
- data/lib/lanes/concerns/all.rb +2 -0
- data/lib/lanes/concerns/api_path.rb +4 -2
- data/lib/lanes/concerns/association_extensions.rb +1 -1
- data/lib/lanes/concerns/attr_accessor_with_default.rb +3 -1
- data/lib/lanes/concerns/code_identifier.rb +1 -1
- data/lib/lanes/concerns/image_uploader.rb +42 -0
- data/lib/lanes/concerns/pub_sub.rb +0 -1
- data/lib/lanes/concerns/queries.rb +2 -2
- data/lib/lanes/concerns/set_attribute_data.rb +4 -13
- data/lib/lanes/concerns/sorting_expressions.rb +34 -0
- data/lib/lanes/configuration.rb +48 -9
- data/lib/lanes/extension.rb +16 -7
- data/lib/lanes/extension/definition.rb +8 -2
- data/lib/lanes/job.rb +78 -0
- data/lib/lanes/job/failure_logger.rb +33 -0
- data/lib/lanes/model.rb +4 -0
- data/lib/lanes/rake_tasks.rb +6 -0
- data/lib/lanes/redis.rb +13 -0
- data/lib/lanes/screen.rb +34 -18
- data/lib/lanes/system_settings.rb +66 -0
- data/lib/lanes/version.rb +1 -1
- data/lib/lanes/workspace/extension.rb +1 -1
- data/npm-build/base.js +10 -3
- data/npm-build/calendar.js +6 -0
- data/npm-build/development.js +4 -5
- data/npm-build/grid.js +3 -5
- data/npm-build/package.json +40 -29
- data/npm-build/react-toggle.js +5 -0
- data/npm-build/react-widgets.js +6 -0
- data/npm-build/update-dayz +14 -0
- data/npm-build/webpack.config.js +5 -2
- data/spec/command-reference-files/initial/Gemfile +1 -1
- data/spec/command-reference-files/initial/config/routes.rb +2 -0
- data/spec/command-reference-files/initial/lib/appy-app.rb +4 -0
- data/spec/command-reference-files/initial/lib/appy-app/extension.rb +2 -0
- data/spec/command-reference-files/initial/spec/server/{spec_helpers.rb → spec_helper.rb} +0 -0
- data/spec/command-reference-files/model/config/routes.rb +2 -0
- data/spec/command-reference-files/model/spec/server/test_test_spec.rb +1 -1
- data/spec/command-reference-files/screen/client/appy-app/screens/ready-set-go/ReadySetGo.cjsx +6 -4
- data/spec/command-reference-files/screen/client/appy-app/screens/ready-set-go/index.scss +4 -3
- data/spec/command-reference-files/screen/config/screens.rb +4 -2
- data/spec/command-reference-files/screen/spec/appy-app/screens/ready-set-go/ReadySetGoSpec.coffee +1 -1
- data/spec/fixtures/system_settings.yml +1 -0
- data/spec/lanes/components/grid/GridSpec.coffee +56 -31
- data/spec/lanes/components/grid/RowEditorSpec.coffee +96 -0
- data/spec/lanes/components/select-field/SelectFieldSpec.coffee +99 -0
- data/spec/lanes/components/shared/NetworkActivityOverlaySpec.coffee +34 -0
- data/spec/lanes/models/AssociationMapSpec.coffee +36 -2
- data/spec/lanes/models/AssociationProxySpec.coffee +77 -0
- data/spec/lanes/models/BaseSpec.coffee +37 -4
- data/spec/lanes/models/CollectionSpec.coffee +11 -17
- data/spec/lanes/models/PubSubSpec.coffee +1 -1
- data/spec/lanes/models/ServerCacheSpec.coffee +65 -0
- data/spec/server/api/coffeescript_processor_spec.rb +1 -1
- data/spec/server/concerns/pub_sub_spec.rb +9 -10
- data/spec/server/concerns/sorting_expressions_spec.rb +34 -0
- data/spec/server/configuration_spec.rb +3 -3
- data/spec/server/job_spec.rb +54 -0
- data/spec/server/spec_helper.rb +0 -5
- data/spec/server/system_settings_spec.rb +23 -0
- data/templates/client/screens/Screen.cjsx +6 -4
- data/templates/client/screens/styles.scss +4 -3
- data/templates/config/routes.rb +2 -0
- data/templates/config/screen.rb +4 -2
- data/templates/lib/namespace.rb +4 -0
- data/templates/lib/namespace/extension.rb +2 -0
- data/templates/spec/client/Screen.coffee +1 -1
- data/templates/spec/server/model_spec.rb +1 -1
- data/templates/spec/server/{spec_helpers.rb → spec_helper.rb} +0 -0
- data/views/lanes_root_view.erb +70 -0
- data/views/specs.erb +2 -2
- metadata +207 -68
- data/client/images/lanes/dataTables/Sorting icons.psd +0 -0
- data/client/images/lanes/dataTables/back_disabled.png +0 -0
- data/client/images/lanes/dataTables/back_enabled.png +0 -0
- data/client/images/lanes/dataTables/back_enabled_hover.png +0 -0
- data/client/images/lanes/dataTables/favicon.ico +0 -0
- data/client/images/lanes/dataTables/forward_disabled.png +0 -0
- data/client/images/lanes/dataTables/forward_enabled.png +0 -0
- data/client/images/lanes/dataTables/forward_enabled_hover.png +0 -0
- data/client/images/lanes/dataTables/loading-background.png +0 -0
- data/client/images/lanes/dataTables/sort_asc.png +0 -0
- data/client/images/lanes/dataTables/sort_asc_disabled.png +0 -0
- data/client/images/lanes/dataTables/sort_both.png +0 -0
- data/client/images/lanes/dataTables/sort_desc.png +0 -0
- data/client/images/lanes/dataTables/sort_desc_disabled.png +0 -0
- data/client/lanes/components/shared/Resize.cjsx +0 -152
- data/client/lanes/components/shared/TextArea.cjsx +0 -19
- data/client/lanes/components/shared/TextField.cjsx +0 -25
- data/client/lanes/models/Bootstrap.coffee +0 -5
- data/client/lanes/models/QueryResults.coffee +0 -93
- data/client/lanes/react/FormBindings.coffee +0 -103
- data/client/lanes/react/Router.cjsx +0 -18
- data/client/lanes/styles/dataTables.scss +0 -4
- data/client/lanes/styles/plugins/all.scss +0 -2
- data/client/lanes/styles/plugins/resize-sensor.scss +0 -24
- data/client/lanes/vendor/jquery-2.js +0 -9190
- data/client/lanes/vendor/jquery.tap.js +0 -401
- data/client/lanes/vendor/magicsuggest.js +0 -1565
- data/client/lanes/vendor/message-bus.coffee +0 -264
- data/client/lanes/workspace/ActiveScreenSwitcher.cjsx +0 -38
- data/client/lanes/workspace/styles/toolbar.scss +0 -4
- data/lib/lanes/api/eco.js +0 -516
- data/lib/lanes/api/sprockets_compressor.rb +0 -39
- data/spec/command-reference-files/model/lib/appy-app.rb +0 -11
- data/views/index.erb +0 -19
@@ -0,0 +1,20 @@
|
|
1
|
+
class Lanes.Components.Grid.CellStyles
|
2
|
+
|
3
|
+
constructor: (fields) ->
|
4
|
+
@styles = []
|
5
|
+
@classes = []
|
6
|
+
@visibleIndexes = []
|
7
|
+
@props = []
|
8
|
+
|
9
|
+
for f, i in fields.models
|
10
|
+
continue unless f.visible
|
11
|
+
|
12
|
+
@styles[i] = {flex: f.flex}
|
13
|
+
if f.fixedWidth
|
14
|
+
@styles[i].flexBasis = f.fixedWidth
|
15
|
+
@styles[i].flexGrow = 0
|
16
|
+
|
17
|
+
@classes[i] = _.classnames( 'c', f.textAlign )
|
18
|
+
@visibleIndexes.push(i)
|
19
|
+
|
20
|
+
@props[i] = { className: @classes[i], style: @styles[i] }
|
@@ -1,64 +1,124 @@
|
|
1
1
|
Lanes.Components.Grid.EditingMixin = {
|
2
2
|
|
3
3
|
propTypes:
|
4
|
-
topOffset: React.PropTypes.number.isRequired
|
5
4
|
rowIndex: React.PropTypes.number.isRequired
|
6
|
-
rowHeight: React.PropTypes.number.isRequired
|
7
5
|
onSave: React.PropTypes.func.isRequired
|
6
|
+
onCancel: React.PropTypes.func.isRequired
|
8
7
|
model: Lanes.PropTypes.State.isRequired
|
9
8
|
query: Lanes.PropTypes.State.isRequired
|
10
9
|
editors: React.PropTypes.object
|
11
|
-
|
10
|
+
beforeSave: React.PropTypes.func
|
11
|
+
afterSave: React.PropTypes.func
|
12
|
+
allowDelete: React.PropTypes.bool
|
13
|
+
syncImmediatly: React.PropTypes.oneOfType([
|
14
|
+
React.PropTypes.bool, React.PropTypes.func
|
15
|
+
])
|
16
|
+
editorTypes:
|
17
|
+
text: (props) ->
|
18
|
+
<input type="text" {...props}
|
19
|
+
onChange={_.partial(@onFieldChange, _, props.field)} />
|
20
|
+
bigdec: (props) ->
|
21
|
+
<LC.NumberInput unstyled {...props} />
|
22
|
+
date: (props) ->
|
23
|
+
<LC.DateTime {...props} inputOnly step={15}
|
24
|
+
onChange={_.partial(@onDateFieldChange, _, props.field)} />
|
12
25
|
|
13
|
-
|
14
|
-
|
26
|
+
displayTypes:
|
27
|
+
bigdec: (props) ->
|
28
|
+
<span>{props.value.toFixed(2)}</span>
|
29
|
+
text: (props) ->
|
30
|
+
<span>{props.value}</span>
|
31
|
+
|
32
|
+
listenNetworkEvents: true
|
33
|
+
getDefaultProps: -> editors: {}
|
15
34
|
|
16
35
|
renderControls: ->
|
36
|
+
if @props.allowDelete
|
37
|
+
deleteBtn =
|
38
|
+
<button type="button" className="btn delete" onClick={@deleteRecord}>
|
39
|
+
<i className="icon icon-trash" />Delete
|
40
|
+
</button>
|
41
|
+
|
17
42
|
<div className="controls">
|
18
43
|
<div className="buttons">
|
19
|
-
<button type="button" className="btn cancel" onClick={@
|
44
|
+
<button type="button" className="btn cancel" onClick={@onCancel}>
|
20
45
|
<i className="icon icon-refresh" /> Cancel
|
21
46
|
</button>
|
47
|
+
{deleteBtn}
|
22
48
|
<button type="button" className="btn save" onClick={@saveRecord}>
|
23
49
|
<i className="icon icon-save" />Save
|
24
50
|
</button>
|
25
51
|
</div>
|
26
52
|
</div>
|
27
53
|
|
28
|
-
getFieldValue: (
|
29
|
-
@props.model[
|
54
|
+
getFieldValue: (field) ->
|
55
|
+
@props.model[field.id]
|
30
56
|
|
31
|
-
|
32
|
-
@props.model[
|
57
|
+
onDateFieldChange: (date, field) ->
|
58
|
+
@props.model[field.id] = date
|
59
|
+
onFieldChange: (ev, field) ->
|
60
|
+
@props.model[field.id] = ev.target.value
|
33
61
|
|
34
62
|
renderFields: ->
|
35
|
-
@props.query.fields.visible
|
63
|
+
for field, index in @props.query.fields.models when field.visible
|
64
|
+
@renderField(field, index)
|
36
65
|
|
37
66
|
renderEditingBody: ->
|
38
67
|
if _.isFunction(@renderBody)
|
39
68
|
@renderBody()
|
40
69
|
else
|
41
|
-
<div className="body">
|
70
|
+
<div className="editing-body">
|
42
71
|
<div className="fields">
|
43
72
|
{@renderFields()}
|
44
73
|
</div>
|
45
74
|
{@renderControls()}
|
46
75
|
</div>
|
47
76
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
77
|
+
renderEditValue: (props) ->
|
78
|
+
( @props.editors[props.field.id] ||
|
79
|
+
@editorTypes[props.field.type] ||
|
80
|
+
@editorTypes['text']
|
81
|
+
).call(this, props)
|
82
|
+
|
83
|
+
renderDisplayValue: (props) ->
|
84
|
+
( @displayTypes[props.field.type] || @displayTypes['text'] ).call(this, props)
|
85
|
+
|
86
|
+
renderField: (field, index) ->
|
87
|
+
props = _.extend( {
|
88
|
+
index, field, props: @props, name: field.id, value: @getFieldValue(field)
|
89
|
+
}, _.pick(@props, 'model', 'query', 'rowIndex') )
|
90
|
+
control = if field.editable then @renderEditValue(props) else
|
91
|
+
@renderDisplayValue(props)
|
92
|
+
|
93
|
+
<div key={field.id}
|
94
|
+
style = {@props.cellStyles.styles[index]}
|
95
|
+
className = {_.classnames('field', @props.cellStyles.classes[index])}
|
96
|
+
>
|
97
|
+
<label>{field.title}</label>
|
58
98
|
{control}
|
59
99
|
</div>
|
60
100
|
|
101
|
+
onCancel: ->
|
102
|
+
@props.onCancel(@props.model)
|
103
|
+
|
104
|
+
shouldPerformSync: ->
|
105
|
+
!!Lanes.u.resultsFor(@props, 'syncImmediatly', @props.model)
|
106
|
+
|
61
107
|
saveRecord: ->
|
62
|
-
@props.
|
63
|
-
|
108
|
+
return if false == @props.beforeSave?(@props.model, @props.rowIndex)
|
109
|
+
if @shouldPerformSync()
|
110
|
+
@props.model.save().then (model) =>
|
111
|
+
@props.onSave(model)
|
112
|
+
@props.afterEdit?(model, @props.rowIndex)
|
113
|
+
else
|
114
|
+
@props.onSave(@props.model)
|
115
|
+
@props.afterEdit?(@props.model, @props.rowIndex)
|
116
|
+
|
117
|
+
deleteRecord: ->
|
118
|
+
if @shouldPerformSync()
|
119
|
+
@props.model.destroy().then (model) =>
|
120
|
+
@props.onSave(model, true)
|
121
|
+
else
|
122
|
+
@props.onSave(@props.model, true)
|
123
|
+
|
64
124
|
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Lanes.Components.Grid.Editor extends Lanes.React.BaseComponent
|
2
|
+
|
3
|
+
propTypes:
|
4
|
+
onCancel: React.PropTypes.func.isRequired
|
5
|
+
|
6
|
+
getInitialState: ->
|
7
|
+
selectedModel: false
|
8
|
+
|
9
|
+
onEditCancel: (model) ->
|
10
|
+
@props.onCancel(model)
|
11
|
+
|
12
|
+
onEditSave: (model, isDeleted = false) ->
|
13
|
+
if (isDeleted)
|
14
|
+
@props.query.results.removeRow(@state.selectedIndex)
|
15
|
+
else
|
16
|
+
@props.query.results.saveModelChanges(model, @state.selectedIndex)
|
17
|
+
this.hideEditor()
|
18
|
+
|
19
|
+
componentWillReceiveProps: (nextProps) ->
|
20
|
+
if nextProps.editingRowIndex?
|
21
|
+
@setState(
|
22
|
+
selectedIndex: nextProps.editingRowIndex
|
23
|
+
selectedModel: @props.query.results.modelAt(nextProps.editingRowIndex)?.clone()
|
24
|
+
)
|
25
|
+
|
26
|
+
render: ->
|
27
|
+
return null unless @props.editing
|
28
|
+
|
29
|
+
Editor = if true == @props.editor
|
30
|
+
Lanes.Components.Grid.RowEditor
|
31
|
+
else
|
32
|
+
@props.editor
|
33
|
+
<Editor
|
34
|
+
{...@props.editing}
|
35
|
+
{...@props.editorProps}
|
36
|
+
query = {@props.query}
|
37
|
+
model = {@props.editing.model}
|
38
|
+
onCancel = {@onEditCancel}
|
39
|
+
onSave = {@onEditSave}
|
40
|
+
cellStyles = {@props.cellStyles}
|
41
|
+
editors = {@props.columEditors}
|
42
|
+
rowIndex = {@props.editing.index}
|
43
|
+
rowHeight = {@props.rowHeight}
|
44
|
+
allowDelete = {@props.allowDelete and @props.commands?.isEditing()}
|
45
|
+
/>
|
@@ -1,7 +1,12 @@
|
|
1
1
|
##= require_self
|
2
2
|
##= require ./Toolbar
|
3
3
|
##= require ./RowEditor
|
4
|
+
##= require ./PopOverMixin
|
4
5
|
##= require ./PopoverEditor
|
6
|
+
##= require ./CellStyles
|
7
|
+
##= require ./Header
|
8
|
+
##= require ./Body
|
9
|
+
##= require ./Selections
|
5
10
|
|
6
11
|
class Lanes.Components.Grid extends Lanes.React.Component
|
7
12
|
|
@@ -13,10 +18,17 @@ class Lanes.Components.Grid extends Lanes.React.Component
|
|
13
18
|
query: 'props'
|
14
19
|
|
15
20
|
bindDataEvents:
|
16
|
-
query: 'change
|
21
|
+
query: 'load change sort'
|
22
|
+
|
23
|
+
getInitialState: ->
|
24
|
+
{}
|
25
|
+
|
26
|
+
componentWillReceiveProps: (nextProps) ->
|
27
|
+
if nextProps.autoLoadQuery and nextProps.query isnt @props.query
|
28
|
+
nextProps.query.ensureLoaded()
|
17
29
|
|
18
30
|
propTypes:
|
19
|
-
query:
|
31
|
+
query: React.PropTypes.instanceOf(Lanes.Models.Query).isRequired
|
20
32
|
width: React.PropTypes.number
|
21
33
|
height: React.PropTypes.number
|
22
34
|
editor: React.PropTypes.oneOfType([
|
@@ -25,115 +37,61 @@ class Lanes.Components.Grid extends Lanes.React.Component
|
|
25
37
|
])
|
26
38
|
allowCreate: React.PropTypes.bool
|
27
39
|
columEditors: React.PropTypes.object
|
40
|
+
onColumnClick: React.PropTypes.func
|
28
41
|
onSelectionChange: React.PropTypes.func
|
42
|
+
autoLoadQuery: React.PropTypes.bool
|
43
|
+
toolbarChildren: React.PropTypes.oneOfType([
|
44
|
+
React.PropTypes.element,
|
45
|
+
React.PropTypes.arrayOf(React.PropTypes.element)
|
46
|
+
])
|
29
47
|
|
30
48
|
getDefaultProps: ->
|
31
|
-
|
32
|
-
|
33
|
-
getInitialState: ->
|
34
|
-
columnWidths: {}, toolbar: !!@props.allowCreate
|
49
|
+
editorProps: {}, autoLoadQuery: true
|
35
50
|
|
36
51
|
componentWillMount: ->
|
37
|
-
@query.
|
38
|
-
|
39
|
-
renderColumns: ->
|
40
|
-
@query.fields.visible.map (f, i) =>
|
41
|
-
<Lanes.Vendor.Grid.Column
|
42
|
-
dataKey={i}
|
43
|
-
columnData={f}
|
44
|
-
align={f.textAlign}
|
45
|
-
isResizable={true}
|
46
|
-
flexGrow={f.flex}
|
47
|
-
label={f.title}
|
48
|
-
width={@state.columnWidths[i] || 10}
|
49
|
-
key={i}
|
50
|
-
/>
|
51
|
-
|
52
|
-
onRowClick: (ev, index) ->
|
53
|
-
newIndex = (if @state.selIndex == index then null else index)
|
54
|
-
el = Lanes.u.closestEl(ev.target, 'public_fixedDataTableCell_main')
|
55
|
-
@setState(selIndex: newIndex, editingEl: el)
|
56
|
-
@props.onSelectionChange?(
|
57
|
-
if newIndex? then @query.results.modelAt(newIndex) else null
|
58
|
-
)
|
59
|
-
|
60
|
-
headerHeight: ->
|
61
|
-
@props.headerHeight + ( if @state.toolbar then @props.headerHeight else 0 )
|
52
|
+
@query.ensureLoaded() if @props.autoLoadQuery
|
62
53
|
|
63
54
|
onSortChange: (sortInfo) ->
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
@
|
69
|
-
|
70
|
-
|
71
|
-
@
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
@
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
renderToolbar: ->
|
91
|
-
props = _.clone(@props)
|
92
|
-
props.onAddRecord = =>
|
93
|
-
@query.results.addBlankRow()
|
94
|
-
@setState(selIndex: 0)
|
95
|
-
<Lanes.Components.Grid.Toolbar {...props} />
|
96
|
-
|
97
|
-
renderEditor: ->
|
98
|
-
editor = if true == @props.editor
|
99
|
-
Lanes.Components.Grid.RowEditor
|
55
|
+
for sortConfig in sortInfo
|
56
|
+
sort = @query.fields.at(sortConfig.name).sortBy
|
57
|
+
sortConfig.fn = sort if sort
|
58
|
+
|
59
|
+
@setState(sortInfo: sortInfo, selectedIndex: undefined, selectedModel: undefined)
|
60
|
+
|
61
|
+
startEdit: (editingRowIndex = 0) ->
|
62
|
+
@setState({editingRowIndex})
|
63
|
+
_.defer => @setState({editingRowIndex: null})
|
64
|
+
|
65
|
+
cancelEdit: ->
|
66
|
+
if @state.editing?.model.isNew()
|
67
|
+
@props.query.results.removeRow(@state.editing.index)
|
68
|
+
@setState(editing: null)
|
69
|
+
|
70
|
+
onRowClick: (selectedModel, selectedIndex, position) ->
|
71
|
+
set = (attrs = {}) =>
|
72
|
+
if @props.editor and false isnt @props.commands?.isEditing()
|
73
|
+
@setState(_.extend(attrs, editing: {index: selectedIndex, model: selectedModel, position}))
|
74
|
+
if @props.onSelectionChange
|
75
|
+
osc = @props.onSelectionChange(selectedModel, selectedIndex)
|
76
|
+
if _.isPromise(osc)
|
77
|
+
@setState(is_loading: true)
|
78
|
+
osc.then -> set(is_loading: false)
|
79
|
+
else
|
80
|
+
set()
|
100
81
|
else
|
101
|
-
|
102
|
-
React.createElement(editor, _.extend({
|
103
|
-
topOffset : @headerHeight()
|
104
|
-
grid : this
|
105
|
-
query : @query
|
106
|
-
model : @getSelected()
|
107
|
-
hideEditor : @hideEditor
|
108
|
-
onSave : @onEditSave
|
109
|
-
editingEl : @state.editingEl
|
110
|
-
editors : @props.columEditors
|
111
|
-
rowHeight : @props.rowHeight
|
112
|
-
rowIndex : @state.selIndex
|
113
|
-
}, @props.editorProps))
|
114
|
-
|
115
|
-
renderLoading: ->
|
116
|
-
<div className="grid-component">
|
117
|
-
<div className="loading">Loading ...</div>
|
118
|
-
</div>
|
82
|
+
set()
|
119
83
|
|
120
84
|
render: ->
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
height={@height()}
|
135
|
-
>
|
136
|
-
{@renderColumns()}
|
137
|
-
</Lanes.Vendor.Grid>
|
138
|
-
</div>
|
139
|
-
</LC.Resize>
|
85
|
+
cellStyles = new Lanes.Components.Grid.CellStyles(@query.fields)
|
86
|
+
<div className='grid-component'>
|
87
|
+
<Lanes.Components.Grid.Toolbar {...@props} startEdit={@startEdit} />
|
88
|
+
<Lanes.Components.Grid.Header {...@props} cellStyles={cellStyles} />
|
89
|
+
<Lanes.Components.Grid.Body
|
90
|
+
{...@props}
|
91
|
+
editing={@state.editing}
|
92
|
+
onEditCancel={@cancelEdit}
|
93
|
+
isLoading={@state.isLoading}
|
94
|
+
cellStyles={cellStyles}
|
95
|
+
onRowClick={@onRowClick if @props.editor or @props.onSelectionChange}
|
96
|
+
/>
|
97
|
+
</div>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Lanes.Components.Grid.Header extends Lanes.React.BaseComponent
|
2
|
+
|
3
|
+
propTypes:
|
4
|
+
query: React.PropTypes.instanceOf(Lanes.Models.Query).isRequired
|
5
|
+
cellStyles: React.PropTypes.object.isRequired
|
6
|
+
onColumnClick: React.PropTypes.func
|
7
|
+
|
8
|
+
onColumnClick: (f) ->
|
9
|
+
@props.query.setSortField(f)
|
10
|
+
@props.onColumnClick?(f)
|
11
|
+
@forceUpdate()
|
12
|
+
|
13
|
+
renderHeader: (f, i) ->
|
14
|
+
return unless @props.cellStyles.props[i]
|
15
|
+
sorted = f.sortable and @props.query.sortField is f
|
16
|
+
classNames = _.classnames(
|
17
|
+
sort: f.sortable
|
18
|
+
asc: sorted and @props.query.sortAscending
|
19
|
+
desc: sorted and not @props.query.sortAscending
|
20
|
+
@props.cellStyles.props[i].className
|
21
|
+
)
|
22
|
+
<div key={i}
|
23
|
+
{...@props.cellStyles.props[i]}
|
24
|
+
onClick={_.partial(@onColumnClick, f)}
|
25
|
+
className={classNames}
|
26
|
+
>
|
27
|
+
<span className='l'>{f.title}</span>
|
28
|
+
</div>
|
29
|
+
|
30
|
+
render: ->
|
31
|
+
columns = @props.query.fields.map @renderHeader
|
32
|
+
|
33
|
+
<div className="header">
|
34
|
+
{columns}
|
35
|
+
</div>
|