improve action events

This commit is contained in:
yuri
2015-03-04 11:15:34 +02:00
parent 529d8c1100
commit 274c043f44
3 changed files with 36 additions and 32 deletions
@@ -17,56 +17,55 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
************************************************************************/
Espo.define('Crm:Views.Call.List', 'Views.List', function (Dep) {
return Dep.extend({
actionSetHeld: function (data) {
var id = data.id;
if (!id) {
return;
}
}
var model = this.collection.get(id);
if (!model) {
return;
}
model.set('status', 'Held');
this.listenToOnce(model, 'sync', function () {
this.notify(false);
this.collection.fetch();
}, this);
this.notify('Saving...');
model.save();
model.save();
},
actionSetNotHeld: function (data) {
var id = data.id;
if (!id) {
return;
}
}
var model = this.collection.get(id);
if (!model) {
return;
}
model.set('status', 'Not Held');
this.listenToOnce(model, 'sync', function () {
this.notify(false);
this.collection.fetch();
}, this);
this.notify('Saving...');
model.save();
model.save();
},
});
});
+18 -14
View File
@@ -132,18 +132,15 @@ Espo.define('Views.Record.List', 'View', function (Dep) {
this.$el.find('.list > table tbody tr').removeClass('active');
}
},
'click [data-action="quickEdit"]': function (e) {
var $target = $(e.currentTarget);
var id = $target.data('id');
var data = $target.data();
this.quickEdit(id, data);
},
'click [data-action="quickRemove"]': function (e) {
var $target = $(e.currentTarget);
var id = $target.data('id');
var data = $target.data();
this.quickRemove(id, data);
'click .action': function (e) {
$el = $(e.currentTarget);
var action = $el.data('action');
var method = 'action' + Espo.Utils.upperCaseFirst(action);
if (typeof this[method] == 'function') {
var data = $el.data();
this[method](data);
e.stopPropagation();
}
},
'click .checkbox-dropdown [data-action="selectAllResult"]': function (e) {
this.selectAllResult();
@@ -785,8 +782,11 @@ Espo.define('Views.Record.List', 'View', function (Dep) {
});
},
quickEdit: function (id, d) {
actionQuickEdit: function (d) {
d = d || {}
var id = d.id;
if (!id) return;
if (this.allowQuickEdit) {
this.notify('Loading...');
this.createView('quickEdit', 'Modals.Edit', {
@@ -811,7 +811,11 @@ Espo.define('Views.Record.List', 'View', function (Dep) {
return 'tr[data-id="' + id + '"]';
},
quickRemove: function (id) {
actionQuickRemove: function (data) {
data = data || {}
var id = data.id;
if (!id) return;
var model = this.collection.get(id);
if (!this.getAcl().checkModel(model, 'delete')) {
this.notify('Access denied', 'error');
@@ -35,6 +35,7 @@ Espo.define('Views.Record.Panels.Bottom', 'View', function (Dep) {
if (typeof this[method] == 'function') {
var data = $el.data();
this[method](data);
e.stopPropagation();
}
}
},