lanes 0.5.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -2
  3. data/client/lanes/Config.coffee +6 -5
  4. data/client/lanes/access/LoginDialog.cjsx +4 -2
  5. data/client/lanes/access/Roles.coffee +3 -0
  6. data/client/lanes/access/screens/user-management/Editor.cjsx +1 -1
  7. data/client/lanes/components/grid/Body.cjsx +4 -3
  8. data/client/lanes/components/grid/Grid.cjsx +4 -3
  9. data/client/lanes/components/grid/Header.cjsx +1 -1
  10. data/client/lanes/components/grid/PopOverMixin.cjsx +6 -6
  11. data/client/lanes/components/grid/Selections.cjsx +16 -6
  12. data/client/lanes/components/grid/Toolbar.cjsx +1 -1
  13. data/client/lanes/components/grid/styles.scss +21 -5
  14. data/client/lanes/components/modal/Modal.cjsx +18 -9
  15. data/client/lanes/components/record-finder/Clause.cjsx +1 -2
  16. data/client/lanes/components/record-finder/Dialog.cjsx +11 -3
  17. data/client/lanes/components/record-finder/RecordFinder.cjsx +14 -7
  18. data/client/lanes/components/record-finder/styles.scss +1 -0
  19. data/client/lanes/components/select-field/SelectField.cjsx +36 -10
  20. data/client/lanes/components/select-field/styles.scss +7 -0
  21. data/client/lanes/components/shared/Checkbox.cjsx +34 -0
  22. data/client/lanes/components/shared/DateTime.cjsx +3 -2
  23. data/client/lanes/components/shared/ErrorDisplay.cjsx +1 -1
  24. data/client/lanes/components/shared/FieldMixin.cjsx +26 -15
  25. data/client/lanes/components/shared/FieldSet.cjsx +1 -1
  26. data/client/lanes/components/shared/FieldWrapper.cjsx +2 -2
  27. data/client/lanes/components/shared/FormGroup.cjsx +2 -2
  28. data/client/lanes/components/shared/Icon.cjsx +31 -4
  29. data/client/lanes/components/shared/IconButton.cjsx +8 -0
  30. data/client/lanes/components/shared/ImageAsset.cjsx +8 -5
  31. data/client/lanes/components/shared/IndeterminateCheckbox.cjsx +19 -0
  32. data/client/lanes/components/shared/InputFieldMixin.cjsx +6 -0
  33. data/client/lanes/components/shared/JobProgress.cjsx +4 -3
  34. data/client/lanes/components/shared/NetworkActivityOverlay.cjsx +1 -1
  35. data/client/lanes/components/shared/ScreenWrapper.cjsx +1 -1
  36. data/client/lanes/components/shared/ToggleField.cjsx +2 -1
  37. data/client/lanes/components/shared/Tooltip.cjsx +10 -2
  38. data/client/lanes/components/shared/fields.scss +7 -2
  39. data/client/lanes/components/toolbar/RemoteChangeSets.cjsx +10 -7
  40. data/client/lanes/components/toolbar/SaveButton.cjsx +5 -4
  41. data/client/lanes/components/toolbar/Toolbar.cjsx +18 -19
  42. data/client/lanes/components/toolbar/changes-notification.scss +3 -1
  43. data/client/lanes/components/toolbar/styles.scss +6 -3
  44. data/client/lanes/lib/HotReload.coffee +1 -1
  45. data/client/lanes/lib/all.js +1 -1
  46. data/client/lanes/lib/dom.coffee +14 -1
  47. data/client/lanes/lib/format.coffee +3 -0
  48. data/client/lanes/lib/loader.coffee +0 -2
  49. data/client/lanes/lib/{dom-polyfills.coffee → polyfills.coffee} +3 -0
  50. data/client/lanes/lib/utilFunctions.coffee +5 -7
  51. data/client/lanes/models/Asset.coffee +33 -20
  52. data/client/lanes/models/AssociationMap.coffee +5 -6
  53. data/client/lanes/models/Base.coffee +5 -2
  54. data/client/lanes/models/Collection.coffee +23 -2
  55. data/client/lanes/models/PubSub.coffee +51 -13
  56. data/client/lanes/models/Query.coffee +53 -42
  57. data/client/lanes/models/State.coffee +5 -4
  58. data/client/lanes/models/Sync.coffee +5 -3
  59. data/client/lanes/models/index.js +1 -1
  60. data/client/lanes/models/mixins/TrackCollectionRemovals.coffee +17 -0
  61. data/client/lanes/models/query/ArrayResult.coffee +16 -17
  62. data/client/lanes/models/query/CollectionResult.coffee +4 -4
  63. data/client/lanes/react/Component.coffee +14 -13
  64. data/client/lanes/react/Root.cjsx +1 -1
  65. data/client/lanes/react/Screen.coffee +1 -0
  66. data/client/lanes/react/Viewport.coffee +52 -16
  67. data/client/lanes/react/mixins/Access.coffee +5 -0
  68. data/client/lanes/react/mixins/Data.coffee +52 -144
  69. data/client/lanes/react/mixins/MonitorSize.coffee +1 -1
  70. data/client/lanes/react/mixins/ReadEditingState.coffee +3 -0
  71. data/client/lanes/screens/Commands.coffee +1 -1
  72. data/client/lanes/screens/CommonComponents.cjsx +2 -2
  73. data/client/lanes/screens/Definitions.coffee +3 -1
  74. data/client/lanes/screens/SystemSettings.cjsx +13 -18
  75. data/client/lanes/screens/UserPreferences.cjsx +1 -1
  76. data/client/lanes/styles/fonts.scss +2 -3
  77. data/client/lanes/styles/global/styles.scss +2 -1
  78. data/client/lanes/testing/TestObjects.coffee +6 -2
  79. data/client/lanes/vendor/action_cable.js +590 -0
  80. data/client/lanes/vendor/development/calendar.js +56 -56
  81. data/client/lanes/vendor/development/commons.js +7819 -6690
  82. data/client/lanes/vendor/development/data.js +1877 -1455
  83. data/client/lanes/vendor/development/helpers.js +39 -82
  84. data/client/lanes/vendor/development/toggle.js +20 -20
  85. data/client/lanes/vendor/development/ui.js +14629 -14261
  86. data/client/lanes/vendor/development/widgets.js +3146 -2173
  87. data/client/lanes/vendor/index.js +1 -2
  88. data/client/lanes/vendor/production/calendar.js +56 -56
  89. data/client/lanes/vendor/production/commons.js +6352 -6185
  90. data/client/lanes/vendor/production/data.js +1871 -1456
  91. data/client/lanes/vendor/production/toggle.js +20 -20
  92. data/client/lanes/vendor/production/ui.js +14694 -14286
  93. data/client/lanes/vendor/production/widgets.js +3139 -2166
  94. data/client/lanes/vendor/standalone/index.js +5666 -4586
  95. data/client/lanes/vendor/styles/widgets.scss +5 -5
  96. data/client/lanes/workspace/Layout.cjsx +1 -10
  97. data/client/lanes/workspace/Navbar.cjsx +8 -13
  98. data/client/lanes/workspace/ScreenView.cjsx +3 -4
  99. data/client/lanes/workspace/ScreensMenu.cjsx +8 -19
  100. data/client/lanes/workspace/Tabs.cjsx +6 -14
  101. data/db/migrate/02_create_assets.rb +1 -3
  102. data/lanes.gemspec +16 -11
  103. data/lib/lanes/access/test_fixture_extensions.rb +6 -10
  104. data/lib/lanes/access/track_modifications.rb +24 -0
  105. data/lib/lanes/api/cable.rb +49 -0
  106. data/lib/lanes/api/controller_base.rb +52 -9
  107. data/lib/lanes/api/default_routes.rb +9 -0
  108. data/lib/lanes/api/generic_controller.rb +2 -9
  109. data/lib/lanes/api/handlers/asset.rb +5 -6
  110. data/lib/lanes/api/helper_methods.rb +3 -2
  111. data/lib/lanes/api/javascript_processor.rb +6 -5
  112. data/lib/lanes/api/pub_sub.rb +14 -32
  113. data/lib/lanes/api/request_wrapper.rb +1 -1
  114. data/lib/lanes/api/root.rb +4 -7
  115. data/lib/lanes/api/routing.rb +3 -3
  116. data/lib/lanes/api/sprockets_extension.rb +1 -1
  117. data/lib/lanes/api.rb +4 -0
  118. data/lib/lanes/asset.rb +25 -25
  119. data/lib/lanes/concerns/asset_uploader.rb +25 -47
  120. data/lib/lanes/concerns/export_scope.rb +5 -7
  121. data/lib/lanes/concerns/queries.rb +7 -3
  122. data/lib/lanes/concerns/set_attribute_data.rb +12 -6
  123. data/lib/lanes/configuration.rb +4 -7
  124. data/lib/lanes/db.rb +3 -1
  125. data/lib/lanes/guard_tasks.rb +2 -1
  126. data/lib/lanes/hot_reload_plugin.rb +2 -1
  127. data/lib/lanes/job.rb +0 -1
  128. data/lib/lanes/logger.rb +3 -3
  129. data/lib/lanes/model.rb +0 -3
  130. data/lib/lanes/spec_helper.rb +1 -1
  131. data/lib/lanes/system_settings.rb +8 -14
  132. data/lib/lanes/version.rb +1 -1
  133. data/npm-build/data.js +1 -0
  134. data/npm-build/package.json +21 -19
  135. data/npm-build/ui.js +3 -0
  136. data/npm-build/update-dayz +2 -2
  137. data/npm-build/update-model-bindings.js +5 -0
  138. data/spec/command-reference-files/initial/Gemfile +1 -1
  139. data/spec/command-reference-files/initial/config/database.yml +1 -0
  140. data/spec/command-reference-files/initial/config/lanes.rb +3 -3
  141. data/spec/command-reference-files/screen/spec/appy-app/screens/ready-set-go/ReadySetGoSpec.coffee +1 -1
  142. data/spec/lanes/components/grid/GridSpec.coffee +2 -2
  143. data/spec/lanes/components/grid/PopoverEditorSpec.coffee +11 -12
  144. data/spec/lanes/components/select-field/SelectFieldSpec.coffee +6 -4
  145. data/spec/lanes/components/shared/NetworkActivityOverlaySpec.coffee +1 -1
  146. data/spec/lanes/models/PubSubSpec.coffee +6 -8
  147. data/spec/lanes/models/QuerySpec.coffee +19 -0
  148. data/spec/lanes/react/mixins/DataSpec.coffee +18 -16
  149. data/spec/server/api/coffeescript_processor_spec.rb +1 -1
  150. data/spec/server/api/controller_base_spec.rb +77 -0
  151. data/spec/server/api/pub_sub_spec.rb +9 -0
  152. data/spec/server/asset_spec.rb +23 -18
  153. data/spec/server/concerns/export_scope_spec.rb +2 -1
  154. data/spec/server/concerns/exported_limits_spec.rb +14 -9
  155. data/spec/server/concerns/set_attribute_data_spec.rb +17 -0
  156. data/spec/server/spec_helper.rb +29 -11
  157. data/templates/config/database.yml +1 -0
  158. data/templates/spec/client/Screen.coffee +1 -1
  159. data/views/specs.erb +4 -1
  160. metadata +138 -89
  161. data/client/lanes/vendor/message-bus-ajax.js +0 -44
  162. data/client/lanes/vendor/message-bus.js +0 -414
@@ -1,414 +0,0 @@
1
- /*jshint bitwise: false*/
2
- (function(global, document, undefined) {
3
- 'use strict';
4
- var previousMessageBus = global.MessageBus;
5
-
6
- // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
7
- var callbacks, clientId, failCount, shouldLongPoll, queue, responseCallbacks, uniqueId, baseUrl;
8
- var me, started, stopped, longPoller, pollTimeout, paused, later, jQuery, interval, chunkedBackoff;
9
-
10
- uniqueId = function() {
11
- return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
12
- var r, v;
13
- r = Math.random() * 16 | 0;
14
- v = c === 'x' ? r : (r & 0x3 | 0x8);
15
- return v.toString(16);
16
- });
17
- };
18
-
19
- clientId = uniqueId();
20
- responseCallbacks = {};
21
- callbacks = [];
22
- queue = [];
23
- interval = null;
24
- failCount = 0;
25
- baseUrl = "/";
26
- paused = false;
27
- later = [];
28
- chunkedBackoff = 0;
29
- jQuery = global.jQuery;
30
- var hiddenProperty;
31
-
32
- (function(){
33
- var prefixes = ["","webkit","ms","moz"];
34
- for(var i=0; i<prefixes.length; i++) {
35
- var prefix = prefixes[i];
36
- var check = prefix + (prefix === "" ? "hidden" : "Hidden");
37
- if(document[check] !== undefined ){
38
- hiddenProperty = check;
39
- }
40
- }
41
- })();
42
-
43
- var isHidden = function() {
44
- if (hiddenProperty !== undefined){
45
- return document[hiddenProperty];
46
- } else {
47
- return !document.hasFocus;
48
- }
49
- };
50
-
51
- var hasonprogress = (new XMLHttpRequest()).onprogress === null;
52
- var allowChunked = function(){
53
- return me.enableChunkedEncoding && hasonprogress;
54
- };
55
-
56
- shouldLongPoll = function() {
57
- return me.alwaysLongPoll || !isHidden();
58
- };
59
-
60
- var totalAjaxFailures = 0;
61
- var totalAjaxCalls = 0;
62
- var lastAjax;
63
-
64
- var processMessages = function(messages) {
65
- var gotData = false;
66
- if (!messages) return false; // server unexpectedly closed connection
67
-
68
- for (var i=0; i<messages.length; i++) {
69
- var message = messages[i];
70
- gotData = true;
71
- for (var j=0; j<callbacks.length; j++) {
72
- var callback = callbacks[j];
73
- if (callback.channel === message.channel) {
74
- callback.last_id = message.message_id;
75
- try {
76
- callback.func(message.data);
77
- }
78
- catch(e){
79
- if(console.log) {
80
- console.log("MESSAGE BUS FAIL: callback " + callback.channel + " caused exception " + e.message);
81
- }
82
- }
83
- }
84
- if (message.channel === "/__status") {
85
- if (message.data[callback.channel] !== undefined) {
86
- callback.last_id = message.data[callback.channel];
87
- }
88
- }
89
- }
90
- }
91
-
92
- return gotData;
93
- };
94
-
95
- var reqSuccess = function(messages) {
96
- failCount = 0;
97
- if (paused) {
98
- if (messages) {
99
- for (var i=0; i<messages.length; i++) {
100
- later.push(messages[i]);
101
- }
102
- }
103
- } else {
104
- return processMessages(messages);
105
- }
106
- return false;
107
- };
108
-
109
- longPoller = function(poll,data){
110
- var gotData = false;
111
- var aborted = false;
112
- lastAjax = new Date();
113
- totalAjaxCalls += 1;
114
- data.__seq = totalAjaxCalls;
115
-
116
- var longPoll = shouldLongPoll() && me.enableLongPolling;
117
- var chunked = longPoll && allowChunked();
118
- if (chunkedBackoff > 0) {
119
- chunkedBackoff--;
120
- chunked = false;
121
- }
122
-
123
- var headers = {
124
- 'X-SILENCE-LOGGER': 'true'
125
- };
126
-
127
- if (!chunked){
128
- headers["Dont-Chunk"] = 'true';
129
- }
130
-
131
- var dataType = chunked ? "text" : "json";
132
-
133
- var handle_progress = function(payload, position) {
134
-
135
- var separator = "\r\n|\r\n";
136
- var endChunk = payload.indexOf(separator, position);
137
-
138
- if (endChunk === -1) {
139
- return position;
140
- }
141
-
142
- var chunk = payload.substring(position, endChunk);
143
- chunk = chunk.replace(/\r\n\|\|\r\n/g, separator);
144
-
145
- try {
146
- reqSuccess(JSON.parse(chunk));
147
- } catch(e) {
148
- if (console.log) {
149
- console.log("FAILED TO PARSE CHUNKED REPLY");
150
- console.log(data);
151
- }
152
- }
153
-
154
- return handle_progress(payload, endChunk + separator.length);
155
- }
156
-
157
- var disableChunked = function(){
158
- if (me.longPoll) {
159
- me.longPoll.abort();
160
- chunkedBackoff = 30;
161
- }
162
- };
163
-
164
- var setOnProgressListener = function(xhr) {
165
- var position = 0;
166
- // if it takes longer than 3000 ms to get first chunk, we have some proxy
167
- // this is messing with us, so just backoff from using chunked for now
168
- var chunkedTimeout = setTimeout(disableChunked,3000);
169
- xhr.onprogress = function () {
170
- clearTimeout(chunkedTimeout);
171
- if(xhr.getResponseHeader('Content-Type') === 'application/json; charset=utf-8') {
172
- // not chunked we are sending json back
173
- chunked = false;
174
- return;
175
- }
176
- position = handle_progress(xhr.responseText, position);
177
- }
178
- };
179
- if (!me.ajax){
180
- throw new Error("Either jQuery or the ajax adapter must be loaded");
181
- }
182
- var req = me.ajax({
183
- url: me.baseUrl + "message-bus/" + me.clientId + "/poll" + (!longPoll ? "?dlp=t" : ""),
184
- data: data,
185
- cache: false,
186
- dataType: dataType,
187
- type: 'POST',
188
- headers: headers,
189
- messageBus: {
190
- chunked: chunked,
191
- onProgressListener: function(xhr) {
192
- var position = 0;
193
- // if it takes longer than 3000 ms to get first chunk, we have some proxy
194
- // this is messing with us, so just backoff from using chunked for now
195
- var chunkedTimeout = setTimeout(disableChunked,3000);
196
- return xhr.onprogress = function () {
197
- clearTimeout(chunkedTimeout);
198
- if(xhr.getResponseHeader('Content-Type') === 'application/json; charset=utf-8') {
199
- chunked = false; // not chunked, we are sending json back
200
- } else {
201
- position = handle_progress(xhr.responseText, position);
202
- }
203
- }
204
- }
205
- },
206
- xhr: function() {
207
- var xhr = jQuery.ajaxSettings.xhr();
208
- if (!chunked) {
209
- return xhr;
210
- }
211
- this.messageBus.onProgressListener(xhr);
212
- return xhr;
213
- },
214
- success: function(messages) {
215
- if (!chunked) {
216
- // we may have requested text so jQuery will not parse
217
- if (typeof(messages) === "string") {
218
- messages = JSON.parse(messages);
219
- }
220
- gotData = reqSuccess(messages);
221
- }
222
- },
223
- error: function(xhr, textStatus, err) {
224
- if(textStatus === "abort") {
225
- aborted = true;
226
- } else {
227
- failCount += 1;
228
- totalAjaxFailures += 1;
229
- }
230
- },
231
- complete: function() {
232
- var interval;
233
- try {
234
- if (gotData || aborted) {
235
- interval = 100;
236
- } else {
237
- interval = me.callbackInterval;
238
- if (failCount > 2) {
239
- interval = interval * failCount;
240
- } else if (!shouldLongPoll()) {
241
- interval = me.backgroundCallbackInterval;
242
- }
243
- if (interval > me.maxPollInterval) {
244
- interval = me.maxPollInterval;
245
- }
246
-
247
- interval -= (new Date() - lastAjax);
248
-
249
- if (interval < 100) {
250
- interval = 100;
251
- }
252
- }
253
- } catch(e) {
254
- if(console.log && e.message) {
255
- console.log("MESSAGE BUS FAIL: " + e.message);
256
- }
257
- }
258
-
259
- pollTimeout = setTimeout(function(){pollTimeout=null; poll();}, interval);
260
- me.longPoll = null;
261
- }
262
- });
263
-
264
- return req;
265
- };
266
-
267
- me = {
268
- enableChunkedEncoding: true,
269
- enableLongPolling: true,
270
- callbackInterval: 15000,
271
- backgroundCallbackInterval: 60000,
272
- maxPollInterval: 3 * 60 * 1000,
273
- callbacks: callbacks,
274
- clientId: clientId,
275
- alwaysLongPoll: false,
276
- baseUrl: baseUrl,
277
- ajax: (jQuery && jQuery.ajax),
278
- noConflict: function(){
279
- global.MessageBus = global.MessageBus.previousMessageBus;
280
- return this;
281
- },
282
- diagnostics: function(){
283
- console.log("Stopped: " + stopped + " Started: " + started);
284
- console.log("Current callbacks");
285
- console.log(callbacks);
286
- console.log("Total ajax calls: " + totalAjaxCalls + " Recent failure count: " + failCount + " Total failures: " + totalAjaxFailures);
287
- console.log("Last ajax call: " + (new Date() - lastAjax) / 1000 + " seconds ago") ;
288
- },
289
-
290
- pause: function() {
291
- paused = true;
292
- },
293
-
294
- resume: function() {
295
- paused = false;
296
- processMessages(later);
297
- later = [];
298
- },
299
-
300
- stop: function() {
301
- stopped = true;
302
- started = false;
303
- },
304
-
305
- // Start polling
306
- start: function() {
307
- var poll, delayPollTimeout;
308
-
309
- if (started) return;
310
- started = true;
311
- stopped = false;
312
-
313
- poll = function() {
314
- var data;
315
-
316
- if(stopped) {
317
- return;
318
- }
319
-
320
- if (callbacks.length === 0) {
321
- if(!delayPollTimeout) {
322
- delayPollTimeout = setTimeout(function(){ delayPollTimeout = null; poll();}, 500);
323
- }
324
- return;
325
- }
326
-
327
- data = {};
328
- for (var i=0;i<callbacks.length;i++) {
329
- data[callbacks[i].channel] = callbacks[i].last_id;
330
- }
331
-
332
- me.longPoll = longPoller(poll,data);
333
- };
334
-
335
-
336
- // monitor visibility, issue a new long poll when the page shows
337
- if(document.addEventListener && 'hidden' in document){
338
- me.visibilityEvent = global.document.addEventListener('visibilitychange', function(){
339
- if(!document.hidden && !me.longPoll && pollTimeout){
340
- clearTimeout(pollTimeout);
341
- pollTimeout = null;
342
- poll();
343
- }
344
- });
345
- }
346
-
347
- poll();
348
- },
349
-
350
- // Subscribe to a channel
351
- subscribe: function(channel, func, lastId) {
352
-
353
- if(!started && !stopped){
354
- me.start();
355
- }
356
-
357
- if (typeof(lastId) !== "number" || lastId < -1){
358
- lastId = -1;
359
- }
360
- callbacks.push({
361
- channel: channel,
362
- func: func,
363
- last_id: lastId
364
- });
365
- if (me.longPoll) {
366
- me.longPoll.abort();
367
- }
368
-
369
- return func;
370
- },
371
-
372
- // Unsubscribe from a channel
373
- unsubscribe: function(channel, func) {
374
- // TODO allow for globbing in the middle of a channel name
375
- // like /something/*/something
376
- // at the moment we only support globbing /something/*
377
- var glob;
378
- if (channel.indexOf("*", channel.length - 1) !== -1) {
379
- channel = channel.substr(0, channel.length - 1);
380
- glob = true;
381
- }
382
-
383
- var removed = false;
384
-
385
- for (var i=callbacks.length-1; i>=0; i--) {
386
-
387
- var callback = callbacks[i];
388
- var keep;
389
-
390
- if (glob) {
391
- keep = callback.channel.substr(0, channel.length) !== channel;
392
- } else {
393
- keep = callback.channel !== channel;
394
- }
395
-
396
- if(!keep && func && callback.func !== func){
397
- keep = true;
398
- }
399
-
400
- if (!keep) {
401
- callbacks.splice(i,1);
402
- removed = true;
403
- }
404
- }
405
-
406
- if (removed && me.longPoll) {
407
- me.longPoll.abort();
408
- }
409
-
410
- return removed;
411
- }
412
- };
413
- global.MessageBus = me;
414
- })(window, document);