+ `
@@ -935,7 +940,7 @@ define([
this.elements.content.appendChild(this.$content[0]);
// Render Search Filter
- userFilter(userCollection).setCustomSearchBox($('#txtGridSearch'));
+ userCollection.nonFilter = userFilter(userCollection).setCustomSearchBox($('#txtGridSearch')).shadowCollection;
userCollection.fetch();
this.$content.find('a.close-error').on('click',() => {
@@ -945,47 +950,33 @@ define([
this.$content.find('button.add').first().on('click',(e) => {
e.preventDefault();
- var canAddRow = true;
-
- if (canAddRow) {
- // There should be only one empty row.
-
- var isEmpty = false,
- unsavedModel = null;
-
- userCollection.each(function(model) {
- if (!isEmpty) {
- isEmpty = model.isNew();
- unsavedModel = model;
- }
- });
- var idx;
-
- if (isEmpty) {
- idx = userCollection.indexOf(unsavedModel);
- var row = view.body.rows[idx].$el;
-
+ // There should be only one empty row.
+ for(const [idx, model] of userCollection.models.entries()) {
+ if(model.isNew()) {
+ let row = view.body.rows[idx].$el;
row.addClass('new');
- $(row).pgMakeVisible('backform-tab');
+ $(row).pgMakeVisible('backgrid');
+ $(row).find('.email').trigger('click');
return false;
}
+ }
- $(view.body.$el.find($('tr.new'))).removeClass('new');
- var m = new(UserModel)(null, {
- handler: userCollection,
- top: userCollection,
- collection: userCollection,
- });
- userCollection.add(m);
-
- idx = userCollection.indexOf(m);
- var newRow = view.body.rows[idx].$el;
+ $(view.body.$el.find($('tr.new'))).removeClass('new');
+ var m = new(UserModel)(null, {
+ handler: userCollection,
+ top: userCollection,
+ collection: userCollection,
+ });
+ userCollection.add(m);
- newRow.addClass('new');
- $(newRow).pgMakeVisible('backform-tab');
- return false;
- }
+ var newRow = view.body.rows[userCollection.indexOf(m)].$el;
+ newRow.addClass('new');
+ $(newRow).pgMakeVisible('backgrid');
+ $(newRow).find('.email').trigger('click');
+ return false;
});
+
+ commonUtils.findAndSetFocus(this.$content);
},
callback: function(e) {
if (e.button.element.name == 'dialog_help') {