netzke-basepack 0.10.0.rc2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile +1 -3
- data/README.md +1 -1
- data/lib/netzke/basepack/data_adapters/abstract_adapter.rb +0 -5
- data/lib/netzke/basepack/data_adapters/active_record_adapter.rb +2 -7
- data/lib/netzke/basepack/grid/endpoints.rb +2 -13
- data/lib/netzke/basepack/grid/javascripts/event_handling.js +5 -13
- data/lib/netzke/basepack/grid/javascripts/extensions.js +29 -0
- data/lib/netzke/basepack/grid/javascripts/grid.js +28 -116
- data/lib/netzke/basepack/grid/javascripts/remember_selection.js +3 -2
- data/lib/netzke/basepack/grid/services.rb +12 -8
- data/lib/netzke/basepack/grid.rb +41 -16
- data/lib/netzke/basepack/version.rb +1 -1
- metadata +38 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65f02f29084160b91fc8a810c748bba7a6f65595
|
4
|
+
data.tar.gz: 8cb001038dd3d5e6af08b09c0b05af1f8e203578
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f86ab4e65bf34230049cbc629b000a4eb5f270380222376cddda280f09284a8103cde7e61376f14924f77b43988a0a90c3fe283b283cd91b596edaa3b0019cc
|
7
|
+
data.tar.gz: dd3e00b0397c1fb9fbc78b663c36527c0098b60c93fc1c6543d019acd4dc5ae3febeb15329285f6513ca60c8224b7ccbdd7fae9a5c5f6a6ebc0f0e14ca128bd6
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -9,8 +9,6 @@ gemspec
|
|
9
9
|
|
10
10
|
gem 'carrierwave'
|
11
11
|
|
12
|
-
gem 'protected_attributes'
|
13
|
-
|
14
12
|
# This partial duplication of gemspec is required for rails_app to run
|
15
13
|
group :test do
|
16
14
|
gem 'rspec'
|
@@ -20,7 +18,7 @@ group :test do
|
|
20
18
|
gem 'cucumber-rails', require: false
|
21
19
|
gem 'database_cleaner'
|
22
20
|
gem 'rspec-rails'
|
23
|
-
gem 'netzke-testing', '0.10.0
|
21
|
+
gem 'netzke-testing', '0.10.0'
|
24
22
|
end
|
25
23
|
|
26
24
|
group :test, :development do
|
data/README.md
CHANGED
@@ -101,7 +101,7 @@ If you feel particularily generous, you can donate a couple of bucks weekly at [
|
|
101
101
|
* [Twitter](http://twitter.com/netzke) - latest news about the framework
|
102
102
|
|
103
103
|
---
|
104
|
-
Copyright (c) 2008-
|
104
|
+
Copyright (c) 2008-2014 [Max Gorin](https://twitter.com/mxgrn), released under the MIT license (see LICENSE).
|
105
105
|
|
106
106
|
**Note** that Ext JS is licensed [differently](http://www.sencha.com/products/extjs/license/), and you may need to
|
107
107
|
purchase a commercial license in order to use it in your projects.
|
@@ -181,11 +181,6 @@ module Netzke::Basepack::DataAdapters
|
|
181
181
|
record.errors.to_a
|
182
182
|
end
|
183
183
|
|
184
|
-
# Whether an attribute is mass assignable. As second argument optionally takes the role.
|
185
|
-
def attribute_mass_assignable?(attr_name, role = :default)
|
186
|
-
true
|
187
|
-
end
|
188
|
-
|
189
184
|
# Whether an attribute (by name) is an association one
|
190
185
|
def association_attr?(attr_name)
|
191
186
|
!!attr_name.to_s.index("__")
|
@@ -255,7 +255,7 @@ module Netzke::Basepack::DataAdapters
|
|
255
255
|
|
256
256
|
if a[:setter]
|
257
257
|
a[:setter].call(r, v)
|
258
|
-
elsif r.respond_to?("#{a[:name]}=")
|
258
|
+
elsif r.respond_to?("#{a[:name]}=")
|
259
259
|
r.send("#{a[:name]}=", v)
|
260
260
|
elsif association_attr?(a)
|
261
261
|
split = a[:name].to_s.split(/\.|__/)
|
@@ -283,7 +283,7 @@ module Netzke::Basepack::DataAdapters
|
|
283
283
|
|
284
284
|
# set the foreign key to the passed value
|
285
285
|
# not that if a negative value is passed, we reset the association (set it to nil)
|
286
|
-
r.send("#{assoc.foreign_key}=", v.to_i < 0 ? nil : v)
|
286
|
+
r.send("#{assoc.foreign_key}=", v.to_i < 0 ? nil : v)
|
287
287
|
end
|
288
288
|
else
|
289
289
|
logger.warn "Netzke: Association #{assoc} is not known for class #{@data_class}"
|
@@ -420,11 +420,6 @@ module Netzke::Basepack::DataAdapters
|
|
420
420
|
end
|
421
421
|
end
|
422
422
|
|
423
|
-
# Whether an attribute is mass assignable. As second argument optionally takes the role.
|
424
|
-
def attribute_mass_assignable?(attr_name, role = :default)
|
425
|
-
@model_class.accessible_attributes(role).empty? ? !@model_class.protected_attributes(role).include?(attr_name.to_s) : @model_class.accessible_attributes(role).include?(attr_name.to_s)
|
426
|
-
end
|
427
|
-
|
428
423
|
private
|
429
424
|
|
430
425
|
def logger
|
@@ -17,19 +17,8 @@ module Netzke
|
|
17
17
|
attempt_operation(:update, data, this)
|
18
18
|
end
|
19
19
|
|
20
|
-
endpoint :server_delete do |
|
21
|
-
|
22
|
-
destroyed_ids, errors = destroy(ids)
|
23
|
-
|
24
|
-
feedback = errors
|
25
|
-
if destroyed_ids.present?
|
26
|
-
feedback << I18n.t('netzke.basepack.grid.deleted_n_records', :count => destroyed_ids.size)
|
27
|
-
on_data_changed
|
28
|
-
end
|
29
|
-
this.netzke_feedback(feedback)
|
30
|
-
else
|
31
|
-
this.netzke_feedback I18n.t('netzke.basepack.grid.cannot_delete')
|
32
|
-
end
|
20
|
+
endpoint :server_delete do |data, this|
|
21
|
+
attempt_operation(:destroy, data, this)
|
33
22
|
end
|
34
23
|
|
35
24
|
endpoint :server_save_columns do |cols, this|
|
@@ -11,27 +11,19 @@
|
|
11
11
|
|
12
12
|
this.getStore().add(r);
|
13
13
|
|
14
|
-
this.
|
14
|
+
this.netzkeTryStartEditing(r);
|
15
15
|
}
|
16
16
|
},
|
17
17
|
|
18
18
|
onDel: function() {
|
19
19
|
Ext.Msg.confirm(this.i18n.confirmation, this.i18n.areYouSure, function(btn){
|
20
20
|
if (btn == 'yes') {
|
21
|
-
var ids = [];
|
21
|
+
var ids = [], records = [];
|
22
22
|
this.getSelectionModel().selected.each(function(r){
|
23
|
-
|
24
|
-
// this record is not know to server - simply remove from store
|
25
|
-
this.store.remove(r);
|
26
|
-
} else {
|
27
|
-
ids.push(r.getId());
|
28
|
-
}
|
23
|
+
this.store.remove(r);
|
29
24
|
}, this);
|
30
25
|
|
31
|
-
|
32
|
-
this.serverDelete(ids);
|
33
|
-
this.getStore().reload();
|
34
|
-
}
|
26
|
+
this.store.sync();
|
35
27
|
}
|
36
28
|
}, this);
|
37
29
|
},
|
@@ -82,7 +74,7 @@
|
|
82
74
|
onEdit: function(){
|
83
75
|
var row = this.getSelectionModel().selected.first();
|
84
76
|
if (row){
|
85
|
-
this.
|
77
|
+
this.netzkeTryStartEditing(row);
|
86
78
|
}
|
87
79
|
},
|
88
80
|
|
@@ -32,6 +32,35 @@ Ext.define('Netzke.classes.Basepack.Grid.Proxy', {
|
|
32
32
|
}
|
33
33
|
},
|
34
34
|
|
35
|
+
destroy: function(op, callback, scope) {
|
36
|
+
var data = Ext.Array.map(op.getRecords(), function(r) { return r.getData().id; });
|
37
|
+
var store = this.grid.getStore();
|
38
|
+
this.grid.serverDelete(data, function(res){
|
39
|
+
var errors = [];
|
40
|
+
for (id in res) {
|
41
|
+
var error;
|
42
|
+
if (error = res[id].error) {
|
43
|
+
errors.push(error);
|
44
|
+
store.getRemovedRecords().forEach(function(record, i){
|
45
|
+
if (record.getId() == id) {
|
46
|
+
store.insert(record.index, record);
|
47
|
+
}
|
48
|
+
});
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
// clear store state
|
53
|
+
store.commitChanges();
|
54
|
+
|
55
|
+
if (errors.length > 0) {
|
56
|
+
this.grid.netzkeFeedback([errors]);
|
57
|
+
}
|
58
|
+
|
59
|
+
this.grid.getStore().load();
|
60
|
+
|
61
|
+
}, this);
|
62
|
+
},
|
63
|
+
|
35
64
|
create: function(op, callback, scope) {
|
36
65
|
var data = Ext.Array.map(op.getRecords(), function(r) { return Ext.apply(r.getData(), {internal_id: r.internalId}); });
|
37
66
|
|
@@ -6,28 +6,6 @@
|
|
6
6
|
componentLoadMask: {msg: "Loading..."},
|
7
7
|
multiSelect: true,
|
8
8
|
|
9
|
-
/** Public methods (can be called by endpoints) **/
|
10
|
-
|
11
|
-
/* Deprecated, as it can't be called from the endpoint atm; use reloadData instead */
|
12
|
-
update: function(){
|
13
|
-
this.store.load();
|
14
|
-
},
|
15
|
-
|
16
|
-
/* Reloads data */
|
17
|
-
reloadData: function(){
|
18
|
-
this.store.load();
|
19
|
-
},
|
20
|
-
|
21
|
-
/* Loads passed */
|
22
|
-
loadStoreData: function(data){
|
23
|
-
var dataRecords = this.getStore().getProxy().getReader().read(data);
|
24
|
-
this.getStore().loadData(dataRecords.records);
|
25
|
-
Ext.each(['data', 'total', 'success'], function(property){delete data[property];}, this);
|
26
|
-
this.netzkeBulkExecute(data);
|
27
|
-
},
|
28
|
-
|
29
|
-
/** End of public methods **/
|
30
|
-
|
31
9
|
initComponent: function(){
|
32
10
|
// if we are being created by the locking feature - everything is configured already, nothing to do
|
33
11
|
if (this.isLocked) return this.callParent();
|
@@ -78,7 +56,7 @@
|
|
78
56
|
this.columns = colModelConfig;
|
79
57
|
|
80
58
|
// data store
|
81
|
-
this.store = this.
|
59
|
+
this.store = this.netzkeBuildStore();
|
82
60
|
|
83
61
|
// load inline data if available
|
84
62
|
if (this.inlineData) this.store.loadRawData(this.inlineData);
|
@@ -137,7 +115,7 @@
|
|
137
115
|
}, this);
|
138
116
|
|
139
117
|
// WIP: GridView
|
140
|
-
this.getView().getRowClass = this.
|
118
|
+
this.getView().getRowClass = this.netzkeDefaultGetRowClass;
|
141
119
|
|
142
120
|
// When starting editing as assocition column, pre-load the combobox store from the meta column, so that we don't see the real value of this cell (the id of the associated record), but rather the associated record by the configured method.
|
143
121
|
this.on('beforeedit', function(editor, e){
|
@@ -159,10 +137,10 @@
|
|
159
137
|
// Persistence-related events (afterrender to avoid blank event firing on render)
|
160
138
|
if (this.persistence) {
|
161
139
|
// Inform the server part about column operations
|
162
|
-
this.on('columnresize', this.
|
163
|
-
this.on('columnmove', this.
|
164
|
-
this.on('columnhide', this.
|
165
|
-
this.on('columnshow', this.
|
140
|
+
this.on('columnresize', this.netzkeSaveColumns, this);
|
141
|
+
this.on('columnmove', this.netzkeSaveColumns, this);
|
142
|
+
this.on('columnhide', this.netzkeSaveColumns, this);
|
143
|
+
this.on('columnshow', this.netzkeSaveColumns, this);
|
166
144
|
}
|
167
145
|
}, this);
|
168
146
|
|
@@ -180,10 +158,13 @@
|
|
180
158
|
this.onEditInForm();
|
181
159
|
}, this);
|
182
160
|
}
|
183
|
-
|
184
|
-
|
185
|
-
|
161
|
+
|
162
|
+
// Remember grid selection on reloads
|
163
|
+
if(this.netzkeRememberSelection && this.netzkeRestoreSelection){
|
164
|
+
this.getStore().on('beforeload', this.netzkeRememberSelection, this);
|
165
|
+
this.getView().on('refresh', this.netzkeRestoreSelection, this);
|
186
166
|
}
|
167
|
+
|
187
168
|
// In EXT JS 4.1 the filters object isn't initialized
|
188
169
|
if (this.enableColumnFilters)
|
189
170
|
{
|
@@ -213,12 +194,12 @@
|
|
213
194
|
// Run through columns and set up different configuration for each
|
214
195
|
Ext.each(this.columns, function(c, i){
|
215
196
|
|
216
|
-
this.
|
197
|
+
this.netzkeNormalizeRenderer(c);
|
217
198
|
|
218
199
|
// Build the field configuration for this column
|
219
200
|
var fieldConfig = {name: c.name, defaultValue: c.defaultValue, useNull: true}; // useNull is needed to not convert nils to 0 in associations!
|
220
201
|
|
221
|
-
if (c.name !== 'meta') fieldConfig.type = this.
|
202
|
+
if (c.name !== 'meta') fieldConfig.type = this.netzkeFieldTypeForAttrType(c.attrType); // field type (grid editors need this to function well)
|
222
203
|
|
223
204
|
if (c.attrType == 'datetime') {
|
224
205
|
fieldConfig.dateFormat = 'Y-m-d H:i:s'; // set the format in which we receive datetime from the server (so that the model can parse it)
|
@@ -251,7 +232,7 @@
|
|
251
232
|
if (c.editor) c.editor = Ext.apply({ name: c.name }, c.editor);
|
252
233
|
|
253
234
|
// Renderer for association column
|
254
|
-
this.
|
235
|
+
this.netzkeNormalizeAssociationRenderer(c);
|
255
236
|
}
|
256
237
|
|
257
238
|
if (c.editor) {
|
@@ -260,7 +241,7 @@
|
|
260
241
|
|
261
242
|
// Setting the default filter type
|
262
243
|
if (c.filterable != false && !c.filter) {
|
263
|
-
c.filter = {type: c.assoc ? 'string' : this.
|
244
|
+
c.filter = {type: c.assoc ? 'string' : this.netzkeFieldTypeForAttrType(c.attrType)};
|
264
245
|
}
|
265
246
|
|
266
247
|
// setting dataIndex
|
@@ -269,10 +250,10 @@
|
|
269
250
|
}, this);
|
270
251
|
},
|
271
252
|
|
272
|
-
|
253
|
+
netzkeBuildStore: function() {
|
273
254
|
var store = Ext.create('Ext.data.Store', Ext.apply({
|
274
255
|
model: this.id,
|
275
|
-
proxy: this.
|
256
|
+
proxy: this.netzkeBuildProxy(),
|
276
257
|
pruneModifiedRecords: true,
|
277
258
|
remoteSort: true,
|
278
259
|
pageSize: this.rowsPerPage,
|
@@ -288,18 +269,18 @@
|
|
288
269
|
return store;
|
289
270
|
},
|
290
271
|
|
291
|
-
|
272
|
+
netzkeBuildProxy: function() {
|
292
273
|
return Ext.create('Netzke.classes.Basepack.Grid.Proxy', {
|
293
|
-
reader: this.
|
274
|
+
reader: this.netzkeBuildReader(),
|
294
275
|
grid: this
|
295
276
|
});
|
296
277
|
},
|
297
278
|
|
298
|
-
|
279
|
+
netzkeBuildReader: function() {
|
299
280
|
return Ext.create('Netzke.classes.Basepack.Grid.ArrayReader');
|
300
281
|
},
|
301
282
|
|
302
|
-
|
283
|
+
netzkeFieldTypeForAttrType: function(attrType){
|
303
284
|
var map = {
|
304
285
|
integer : 'int',
|
305
286
|
decimal : 'float',
|
@@ -314,7 +295,7 @@
|
|
314
295
|
},
|
315
296
|
|
316
297
|
// Tries editing the first editable (i.e. not hidden, not read-only) sell
|
317
|
-
|
298
|
+
netzkeTryStartEditing: function(r){
|
318
299
|
var editableIndex = 0;
|
319
300
|
Ext.each(this.initialConfig.columns, function(c){
|
320
301
|
// skip columns that cannot be edited
|
@@ -327,79 +308,10 @@
|
|
327
308
|
if (editableIndex < this.initialConfig.columns.length) {this.getPlugin('celleditor').startEdit(r, this.columns[editableIndex]);}
|
328
309
|
},
|
329
310
|
|
330
|
-
|
331
|
-
updateNewRecords: function(records){
|
332
|
-
this.updateRecords(records);
|
333
|
-
},
|
334
|
-
|
335
|
-
// Called by the server side to update modified records
|
336
|
-
updateModRecords: function(records){
|
337
|
-
this.updateRecords(records, true);
|
338
|
-
},
|
339
|
-
|
340
|
-
// Updates modified or newly created records, by record ID
|
341
|
-
// Example of the records argument (updated columns):
|
342
|
-
// {1098 => [1, 'value1', 'value2'], 1099 => [2, 'value1', 'value2']}
|
343
|
-
// Example of the records argument (new columns, id autogenerated by Ext):
|
344
|
-
// {"ext-record-200" => [1, 'value1', 'value2']}
|
345
|
-
updateRecords: function(records, mod){
|
346
|
-
if (!mod) {mod = false;}
|
347
|
-
var modRecordsInGrid = [].concat(this.store.getUpdatedRecords()); // there must be a better way to clone an array...
|
348
|
-
// replace arrays of data in the args object with Ext.data.Record objects
|
349
|
-
for (var k in records){
|
350
|
-
records[k] = this.getStore().getProxy().getReader().read({data:[records[k]]}).records[0];
|
351
|
-
}
|
352
|
-
// for each new record write the data returned by the server, and commit the record
|
353
|
-
Ext.each(modRecordsInGrid, function(recordInGrid){
|
354
|
-
if (mod ^ recordInGrid.isNew) {
|
355
|
-
// if record is new, we access its id by "id", otherwise, the id is in the primary key column
|
356
|
-
var recordId = recordInGrid.getId();
|
357
|
-
// new data that the server sent us to update this record (identified by the id)
|
358
|
-
var newData = records[recordId];
|
359
|
-
|
360
|
-
if (newData){
|
361
|
-
for (var k in newData.data){
|
362
|
-
recordInGrid.set(k, newData.get(k));
|
363
|
-
}
|
364
|
-
|
365
|
-
recordInGrid.isNew = false;
|
366
|
-
recordInGrid.commit();
|
367
|
-
}
|
368
|
-
|
369
|
-
}
|
370
|
-
}, this);
|
371
|
-
|
372
|
-
// clear the selections
|
373
|
-
this.getSelectionModel().clearSelections();
|
374
|
-
|
375
|
-
// check if there are still records with errors
|
376
|
-
var modRecords = this.store.getUpdatedRecords();
|
377
|
-
if (modRecords.length == 0) {
|
378
|
-
// if all records are accepted, reload the grid (so that eventual order/filtering is correct)
|
379
|
-
this.store.load();
|
380
|
-
|
381
|
-
// ... and set default getRowClass function
|
382
|
-
this.getView().getRowClass = this.defaultGetRowClass;
|
383
|
-
} else {
|
384
|
-
this.getView().getRowClass = function(r){
|
385
|
-
return r.dirty ? "grid-dirty-record" : ""
|
386
|
-
}
|
387
|
-
}
|
388
|
-
|
389
|
-
this.getView().refresh();
|
390
|
-
this.getSelectionModel().fireEvent('selectionchange', this.getSelectionModel());
|
391
|
-
},
|
392
|
-
|
393
|
-
defaultGetRowClass: function(r){
|
311
|
+
netzkeDefaultGetRowClass: function(r){
|
394
312
|
return r.isNew ? "grid-dirty-record" : ""
|
395
313
|
},
|
396
314
|
|
397
|
-
selectFirstRow: function(){
|
398
|
-
this.getSelectionModel().suspendEvents();
|
399
|
-
this.getSelectionModel().selectRow(0);
|
400
|
-
this.getSelectionModel().resumeEvents();
|
401
|
-
},
|
402
|
-
|
403
315
|
// Normalizes the renderer for a column.
|
404
316
|
// Renderer may be:
|
405
317
|
// 1) a string that contains the name of the function to be used as renderer.
|
@@ -415,7 +327,7 @@
|
|
415
327
|
// * "myRenderer" (if this.myRenderer is a function)
|
416
328
|
// * ["Some.scope.Format.customRenderer", 10, 20, 30] (if Some.scope.Format.customRenderer is a function)
|
417
329
|
// * "function(v){ return 'Value: ' + v; }"
|
418
|
-
|
330
|
+
netzkeNormalizeRenderer: function(c) {
|
419
331
|
if (!c.renderer) return;
|
420
332
|
|
421
333
|
var name, args = [];
|
@@ -439,7 +351,7 @@
|
|
439
351
|
}
|
440
352
|
},
|
441
353
|
|
442
|
-
|
354
|
+
netzkeSaveColumns: function(){
|
443
355
|
var cols = [];
|
444
356
|
this.getView().getHeaderCt().items.each(function(c){
|
445
357
|
cols.push({name: c.name, width: c.width, hidden: c.hidden});
|
@@ -452,9 +364,9 @@
|
|
452
364
|
Set a renderer that displayes association values instead of association record ID.
|
453
365
|
The association values are passed in the meta-column under associationValues hash.
|
454
366
|
*/
|
455
|
-
|
367
|
+
netzkeNormalizeAssociationRenderer: function(c) {
|
456
368
|
c.scope = this;
|
457
|
-
var passedRenderer = c.renderer; // renderer we got from
|
369
|
+
var passedRenderer = c.renderer; // renderer we got from netzkeNormalizeRenderer
|
458
370
|
c.renderer = function(value, a, r, ri, ci, store, view){
|
459
371
|
var column = view.headerCt.items.getAt(ci + 1),
|
460
372
|
editor = column.getEditor && column.getEditor(),
|
@@ -1,12 +1,13 @@
|
|
1
1
|
{
|
2
|
-
|
2
|
+
netzkeRememberSelection: function(selModel, selectedRecords) {
|
3
3
|
if (!this.rendered || Ext.isEmpty(this.el)) {
|
4
4
|
return;
|
5
5
|
}
|
6
6
|
|
7
7
|
this.selectedRecords = this.getSelectionModel().getSelection();
|
8
8
|
},
|
9
|
-
|
9
|
+
|
10
|
+
netzkeRestoreSelection: function() {
|
10
11
|
if (!this.selectedRecords || 0 >= this.selectedRecords.length) {
|
11
12
|
return;
|
12
13
|
}
|
@@ -45,23 +45,27 @@ module Netzke
|
|
45
45
|
end
|
46
46
|
|
47
47
|
# Destroys records by ids
|
48
|
-
# Returns
|
48
|
+
# Returns hash with results per id, e.g.:
|
49
|
+
#
|
50
|
+
# {
|
51
|
+
# 1: "ok",
|
52
|
+
# 2: "error: "This record could not be destroyed"
|
53
|
+
# }
|
49
54
|
def destroy(ids)
|
50
|
-
|
51
|
-
|
55
|
+
out = {}
|
56
|
+
|
52
57
|
ids.each {|id|
|
53
58
|
record = data_adapter.find_record(id, scope: config[:scope])
|
54
59
|
next if record.nil?
|
55
60
|
|
56
61
|
if record.destroy
|
57
|
-
|
62
|
+
out[id] = "ok"
|
58
63
|
else
|
59
|
-
record.errors.to_a.
|
60
|
-
errors << msg
|
61
|
-
end
|
64
|
+
out[id] = {error: record.errors.to_a.first}
|
62
65
|
end
|
63
66
|
}
|
64
|
-
|
67
|
+
|
68
|
+
out
|
65
69
|
end
|
66
70
|
|
67
71
|
# Returns an array of records.
|
data/lib/netzke/basepack/grid.rb
CHANGED
@@ -237,19 +237,44 @@ module Netzke
|
|
237
237
|
#
|
238
238
|
# {name: "author__first_name", scope: ->(relation){relation.where(popular: true)}
|
239
239
|
#
|
240
|
-
# == Add/
|
240
|
+
# == Add/Edit/Search forms
|
241
|
+
#
|
242
|
+
# Add/Edit/Multi-edit/Search forms are each wrapped in a separate +Basepack::Window+-descending component (called
|
243
|
+
# +RecordFormWindow+ for the add/edit forms, and +SearchWindow+ for the search form), and can be overridden
|
244
|
+
# individually as any other child component.
|
245
|
+
#
|
246
|
+
# === Overriding windows
|
247
|
+
#
|
248
|
+
# Override the following direct child components to change the looks of the pop-up windows: +:add_window+,
|
249
|
+
# +:edit_window+, +:multi_edit_window+, and +:search_window+. For example, to override the title of the Add form,
|
250
|
+
# do:
|
251
|
+
#
|
252
|
+
# component :add_window do |c|
|
253
|
+
# super c
|
254
|
+
# c.title = "Adding new record"
|
255
|
+
# end
|
256
|
+
#
|
257
|
+
# === Modifying forms
|
241
258
|
#
|
242
259
|
# The forms will by default display the fields that correspond to the configured columns, taking over meaningful
|
243
260
|
# configuration options (e.g. +text+ will be converted into +fieldLabel+).
|
244
|
-
# You may override the default fields displayed in the forms by overriding the
|
245
|
-
# which should return an array understood by the +items+ config property of the
|
246
|
-
# class instead of +Form+, you need to override the
|
261
|
+
# You may override the default fields displayed in the all add/edit forms by overriding the
|
262
|
+
# +default_fields_for_forms+ method, which should return an array understood by the +items+ config property of the
|
263
|
+
# +Form+. If you need to use a custom +Basepack::Form+-descending class instead of +Form+, you need to override the
|
264
|
+
# +preconfigure_record_window+ method:
|
247
265
|
#
|
248
266
|
# def preconfigure_record_window(c)
|
249
267
|
# super
|
250
268
|
# c.form_config.klass = UserForm
|
251
269
|
# end
|
252
270
|
#
|
271
|
+
# To individually override forms, you should override the wrapping window components, as shown in the previous
|
272
|
+
# session. E.g., to modify the set of fields in the Add form:
|
273
|
+
#
|
274
|
+
# component :add_window do |c|
|
275
|
+
# super c
|
276
|
+
# c.form_config.items = [:title]
|
277
|
+
# end
|
253
278
|
#
|
254
279
|
# == Actions
|
255
280
|
# You can override Grid's actions to change their text, icons, and tooltips (see
|
@@ -521,6 +546,18 @@ module Netzke
|
|
521
546
|
raise ArgumentError, "Grid requires a model" if c.model.nil?
|
522
547
|
end
|
523
548
|
|
549
|
+
def preconfigure_record_window(c)
|
550
|
+
c.klass = RecordFormWindow
|
551
|
+
|
552
|
+
c.form_config = ActiveSupport::OrderedOptions.new.tap do |f|
|
553
|
+
f.model = config[:model]
|
554
|
+
f.persistent_config = config[:persistent_config]
|
555
|
+
f.strong_default_attrs = config[:strong_default_attrs]
|
556
|
+
f.mode = config[:mode]
|
557
|
+
f.items = default_fields_for_forms
|
558
|
+
end
|
559
|
+
end
|
560
|
+
|
524
561
|
private
|
525
562
|
|
526
563
|
def set_defaults(c)
|
@@ -534,18 +571,6 @@ module Netzke
|
|
534
571
|
c.tools = %w{ refresh } if c.tools.nil?
|
535
572
|
end
|
536
573
|
|
537
|
-
def preconfigure_record_window(c)
|
538
|
-
c.klass = RecordFormWindow
|
539
|
-
|
540
|
-
c.form_config = ActiveSupport::OrderedOptions.new.tap do |f|
|
541
|
-
f.model = config[:model]
|
542
|
-
f.persistent_config = config[:persistent_config]
|
543
|
-
f.strong_default_attrs = config[:strong_default_attrs]
|
544
|
-
f.mode = config[:mode]
|
545
|
-
f.items = default_fields_for_forms
|
546
|
-
end
|
547
|
-
end
|
548
|
-
|
549
574
|
def self.server_side_config_options
|
550
575
|
super + [:scope]
|
551
576
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netzke-basepack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.0
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Gorin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02
|
11
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: netzke-core
|
@@ -16,68 +16,68 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.10.0
|
19
|
+
version: 0.10.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.10.0
|
26
|
+
version: 0.10.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 4.0.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 4.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sqlite3
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: coffee-script
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
@@ -86,26 +86,26 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.10.0
|
89
|
+
version: 0.10.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.10.0
|
96
|
+
version: 0.10.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec-rails
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: A set of feature-rich extendible Netzke components (such as Form, Grid,
|
@@ -116,14 +116,22 @@ executables: []
|
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
|
+
- CHANGELOG.md
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- init.rb
|
119
125
|
- javascripts/basepack.js
|
120
126
|
- javascripts/netzkeremotecombo.js
|
121
127
|
- javascripts/xdatetime.js
|
128
|
+
- lib/netzke-basepack.rb
|
129
|
+
- lib/netzke/basepack.rb
|
122
130
|
- lib/netzke/basepack/accordion.rb
|
123
|
-
- lib/netzke/basepack/action_column/javascripts/action_column.js
|
124
131
|
- lib/netzke/basepack/action_column.rb
|
125
|
-
- lib/netzke/basepack/
|
132
|
+
- lib/netzke/basepack/action_column/javascripts/action_column.js
|
126
133
|
- lib/netzke/basepack/active_record.rb
|
134
|
+
- lib/netzke/basepack/active_record/relation_extensions.rb
|
127
135
|
- lib/netzke/basepack/attr_config.rb
|
128
136
|
- lib/netzke/basepack/column_config.rb
|
129
137
|
- lib/netzke/basepack/columns.rb
|
@@ -132,13 +140,14 @@ files:
|
|
132
140
|
- lib/netzke/basepack/data_adapters/active_record_adapter.rb
|
133
141
|
- lib/netzke/basepack/field_config.rb
|
134
142
|
- lib/netzke/basepack/fields.rb
|
143
|
+
- lib/netzke/basepack/form.rb
|
135
144
|
- lib/netzke/basepack/form/javascripts/comma_list_cbg.js
|
136
145
|
- lib/netzke/basepack/form/javascripts/form.js
|
137
146
|
- lib/netzke/basepack/form/javascripts/n_radio_group.js
|
138
147
|
- lib/netzke/basepack/form/javascripts/readonly_mode.js
|
139
148
|
- lib/netzke/basepack/form/services.rb
|
140
149
|
- lib/netzke/basepack/form/stylesheets/readonly_mode.css
|
141
|
-
- lib/netzke/basepack/
|
150
|
+
- lib/netzke/basepack/grid.rb
|
142
151
|
- lib/netzke/basepack/grid/endpoints.rb
|
143
152
|
- lib/netzke/basepack/grid/javascripts/advanced_search.js
|
144
153
|
- lib/netzke/basepack/grid/javascripts/edit_in_form.js
|
@@ -147,30 +156,27 @@ files:
|
|
147
156
|
- lib/netzke/basepack/grid/javascripts/grid.js
|
148
157
|
- lib/netzke/basepack/grid/javascripts/remember_selection.js
|
149
158
|
- lib/netzke/basepack/grid/services.rb
|
150
|
-
- lib/netzke/basepack/grid.rb
|
151
|
-
- lib/netzke/basepack/grid_live_search/javascripts/grid_live_search.js
|
152
159
|
- lib/netzke/basepack/grid_live_search.rb
|
153
|
-
- lib/netzke/basepack/
|
160
|
+
- lib/netzke/basepack/grid_live_search/javascripts/grid_live_search.js
|
154
161
|
- lib/netzke/basepack/item_persistence.rb
|
155
|
-
- lib/netzke/basepack/
|
162
|
+
- lib/netzke/basepack/item_persistence/events_plugin.rb
|
156
163
|
- lib/netzke/basepack/paging_form.rb
|
157
|
-
- lib/netzke/basepack/
|
164
|
+
- lib/netzke/basepack/paging_form/javascripts/paging_form.js
|
158
165
|
- lib/netzke/basepack/query_builder.rb
|
166
|
+
- lib/netzke/basepack/query_builder/javascripts/query_builder.js
|
159
167
|
- lib/netzke/basepack/record_form_window.rb
|
168
|
+
- lib/netzke/basepack/search_panel.rb
|
160
169
|
- lib/netzke/basepack/search_panel/javascripts/condition_field.js
|
161
170
|
- lib/netzke/basepack/search_panel/javascripts/search_panel.js
|
162
|
-
- lib/netzke/basepack/search_panel.rb
|
163
171
|
- lib/netzke/basepack/search_window.rb
|
164
172
|
- lib/netzke/basepack/simple_app/javascripts/statusbar_ext.js
|
165
|
-
- lib/netzke/basepack/tab_panel/javascripts/tab_panel.js
|
166
173
|
- lib/netzke/basepack/tab_panel.rb
|
174
|
+
- lib/netzke/basepack/tab_panel/javascripts/tab_panel.js
|
167
175
|
- lib/netzke/basepack/version.rb
|
168
176
|
- lib/netzke/basepack/viewport.rb
|
169
|
-
- lib/netzke/basepack/window/javascripts/window.js
|
170
177
|
- lib/netzke/basepack/window.rb
|
178
|
+
- lib/netzke/basepack/window/javascripts/window.js
|
171
179
|
- lib/netzke/basepack/wrap_lazy_loaded.rb
|
172
|
-
- lib/netzke/basepack.rb
|
173
|
-
- lib/netzke-basepack.rb
|
174
180
|
- lib/tasks/netzke_basepack_tasks.rake
|
175
181
|
- locales/de.yml
|
176
182
|
- locales/en.yml
|
@@ -179,12 +185,6 @@ files:
|
|
179
185
|
- locales/ru.yml
|
180
186
|
- stylesheets/basepack.css
|
181
187
|
- stylesheets/datetimefield.css
|
182
|
-
- CHANGELOG.md
|
183
|
-
- Gemfile
|
184
|
-
- LICENSE
|
185
|
-
- Rakefile
|
186
|
-
- README.md
|
187
|
-
- init.rb
|
188
188
|
homepage: http://netzke.org
|
189
189
|
licenses: []
|
190
190
|
metadata: {}
|
@@ -194,17 +194,17 @@ require_paths:
|
|
194
194
|
- lib
|
195
195
|
required_ruby_version: !ruby/object:Gem::Requirement
|
196
196
|
requirements:
|
197
|
-
- -
|
197
|
+
- - ">="
|
198
198
|
- !ruby/object:Gem::Version
|
199
199
|
version: '0'
|
200
200
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
201
|
requirements:
|
202
|
-
- -
|
202
|
+
- - ">="
|
203
203
|
- !ruby/object:Gem::Version
|
204
204
|
version: 1.3.4
|
205
205
|
requirements: []
|
206
206
|
rubyforge_project:
|
207
|
-
rubygems_version: 2.
|
207
|
+
rubygems_version: 2.2.0
|
208
208
|
signing_key:
|
209
209
|
specification_version: 4
|
210
210
|
summary: Pre-built Netzke components
|