task and call complete actions

This commit is contained in:
Yuri Kuznetsov
2014-10-15 16:57:51 +03:00
parent 9ced6d7427
commit b839c76a1e
15 changed files with 370 additions and 30 deletions
@@ -29,9 +29,7 @@
"Create Meeting": "Create Meeting",
"Set Held": "Set Held",
"Set Not Held": "Set Not Held",
"Send Invitations": "Send Invitations",
"Saved as Held": "Saved as Held",
"Saved as Not Held": "Saved as Not Held"
"Send Invitations": "Send Invitations"
},
"presetFilters": {
"planned": "Planned",
@@ -26,7 +26,8 @@
}
},
"labels": {
"Create Task": "Create Task"
"Create Task": "Create Task",
"Complete": "Complete"
},
"presetFilters": {
"actual": "Actual",
@@ -1,7 +1,11 @@
{
"controller": "Controllers.Record",
"views":{
"detail":"Crm:Call.Detail"
"detail":"Crm:Call.Detail",
"list": "Crm:Call.List"
},
"recordViews":{
"list":"Crm:Call.Record.List"
},
"menu": {
"detail": {
@@ -1,5 +1,12 @@
{
"controller": "Controllers.Record",
"recordViews":{
"list":"Crm:Task.Record.List"
},
"views": {
"list": "Crm:Task.List",
"detail": "Crm:Task.Detail"
},
"presetFilters": [
{
"name":"actual",
@@ -10,8 +10,7 @@
"default": "Planned",
"view": "Fields.EnumStyled",
"style": {
"Held": "success",
"Not Held": "danger"
"Held": "success"
}
},
"dateStart": {
@@ -10,8 +10,7 @@
"default": "Planned",
"view": "Fields.EnumStyled",
"style": {
"Held": "success",
"Not Held": "danger"
"Held": "success"
}
},
"dateStart": {
@@ -49,7 +49,7 @@
actionSendInvitations: function () {
if (confirm(this.translate('confirmation', 'messages'))) {
this.$el.find('button[data-action="sendInvitations"]').addClass('disabled');
this.$el.find('[data-action="sendInvitations"]').addClass('disabled');
this.notify('Sending...');
$.ajax({
url: 'Call/action/sendInvitations',
@@ -59,10 +59,10 @@
}),
success: function () {
this.notify('Sent', 'success');
this.$el.find('button[data-action="sendInvitations"]').removeClass('disabled');
this.$el.find('[data-action="sendInvitations"]').removeClass('disabled');
}.bind(this),
error: function () {
this.$el.find('button[data-action="sendInvitations"]').removeClass('disabled');
this.$el.find('[data-action="sendInvitations"]').removeClass('disabled');
}.bind(this),
});
}
@@ -74,10 +74,10 @@
}, {
patch: true,
success: function () {
this.notify('Saved as Held', 'success');
this.$el.find('button[data-action="sendInvitations"]').remove();
this.$el.find('a[data-action="setHeld"]').remove();
this.$el.find('a[data-action="setNotHeld"]').remove();
this.notify('Saved', 'success');
this.$el.find('[data-action="sendInvitations"]').remove();
this.$el.find('[data-action="setHeld"]').remove();
this.$el.find('[data-action="setNotHeld"]').remove();
}.bind(this),
});
},
@@ -88,10 +88,10 @@
}, {
patch: true,
success: function () {
this.notify('Saved as Not Held', 'success');
this.$el.find('button[data-action="sendInvitations"]').remove();
this.$el.find('a[data-action="setHeld"]').remove();
this.$el.find('a[data-action="setNotHeld"]').remove();
this.notify('Saved', 'success');
this.$el.find('[data-action="sendInvitations"]').remove();
this.$el.find('[data-action="setHeld"]').remove();
this.$el.find('[data-action="setNotHeld"]').remove();
}.bind(this),
});
},
@@ -0,0 +1,72 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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();
},
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();
},
});
});
@@ -0,0 +1,30 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.Record.List', 'Views.Record.List', function (Dep) {
return Dep.extend({
rowActionsView: 'Crm:Call.Record.RowActions.Default',
});
});
@@ -0,0 +1,50 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.Record.RowActions.Default', 'Views.Record.RowActions.Default', function (Dep) {
return Dep.extend({
getActions: function () {
var actions = Dep.prototype.getActions.call(this);
if (this.options.acl.edit && !~['Held', 'Not Held'].indexOf(this.model.get('status'))) {
actions.push({
action: 'setHeld',
label: 'Set Held',
data: {
id: this.model.id
}
});
actions.push({
action: 'setNotHeld',
label: 'Set Not Held',
data: {
id: this.model.id
}
});
}
return actions;
},
});
});
@@ -59,10 +59,10 @@ Espo.define('Crm:Views.Meeting.Detail', 'Views.Detail', function (Dep) {
}),
success: function () {
this.notify('Sent', 'success');
this.$el.find('button[data-action="sendInvitations"]').removeClass('disabled');
this.$el.find('[data-action="sendInvitations"]').removeClass('disabled');
}.bind(this),
error: function () {
this.$el.find('button[data-action="sendInvitations"]').removeClass('disabled');
this.$el.find('[data-action="sendInvitations"]').removeClass('disabled');
}.bind(this),
});
}
@@ -74,10 +74,10 @@ Espo.define('Crm:Views.Meeting.Detail', 'Views.Detail', function (Dep) {
}, {
patch: true,
success: function () {
Espo.Ui.success(this.translate('Saved as Held', 'labels', 'Meeting'));
this.$el.find('button[data-action="sendInvitations"]').remove();
this.$el.find('a[data-action="setHeld"]').remove();
this.$el.find('a[data-action="setNotHeld"]').remove();
Espo.Ui.success(this.translate('Saved', 'labels', 'Meeting'));
this.$el.find('[data-action="sendInvitations"]').remove();
this.$el.find('[data-action="setHeld"]').remove();
this.$el.find('[data-action="setNotHeld"]').remove();
}.bind(this),
});
},
@@ -88,10 +88,10 @@ Espo.define('Crm:Views.Meeting.Detail', 'Views.Detail', function (Dep) {
}, {
patch: true,
success: function () {
Espo.Ui.success(this.translate('Saved as Not Held', 'labels', 'Meeting'));
this.$el.find('button[data-action="sendInvitations"]').remove();
this.$el.find('a[data-action="setHeld"]').remove();
this.$el.find('a[data-action="setNotHeld"]').remove();
Espo.Ui.success(this.translate('Saved', 'labels', 'Meeting'));
this.$el.find('[data-action="sendInvitations"]').remove();
this.$el.find('[data-action="setHeld"]').remove();
this.$el.find('[data-action="setNotHeld"]').remove();
}.bind(this),
});
},
@@ -0,0 +1,57 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.Task.Detail', 'Views.Detail', function (Dep) {
return Dep.extend({
setup: function () {
Dep.prototype.setup.call(this);
if (!~['Completed', 'Canceled'].indexOf(this.model.get('status'))) {
if (this.getAcl().checkModel(this.model, 'edit')) {
this.menu.buttons.push({
'label': 'Complete',
'action': 'setCompleted',
icon: 'glyphicon glyphicon-ok',
'acl': 'edit',
});
}
}
},
actionSetCompleted: function (data) {
var id = data.id;
this.model.save({
status: 'Completed'
}, {
patch: true,
success: function () {
Espo.Ui.success(this.translate('Saved'));
this.$el.find('[data-action="setCompleted"]').remove();
}.bind(this),
});
},
});
});
@@ -0,0 +1,50 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.Task.List', 'Views.List', function (Dep) {
return Dep.extend({
actionSetCompleted: function (data) {
var id = data.id;
if (!id) {
return;
}
var model = this.collection.get(id);
if (!model) {
return;
}
model.set('status', 'Completed');
this.listenToOnce(model, 'sync', function () {
this.notify(false);
this.collection.fetch();
}, this);
this.notify('Saving...');
model.save();
},
});
});
@@ -0,0 +1,30 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.Task.Record.List', 'Views.Record.List', function (Dep) {
return Dep.extend({
rowActionsView: 'Crm:Task.Record.RowActions.Default',
});
});
@@ -0,0 +1,43 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.Task.Record.RowActions.Default', 'Views.Record.RowActions.Default', function (Dep) {
return Dep.extend({
getActions: function () {
var actions = Dep.prototype.getActions.call(this);
if (this.options.acl.edit && !~['Completed', 'Canceled'].indexOf(this.model.get('status'))) {
actions.push({
action: 'setCompleted',
label: 'Complete',
data: {
id: this.model.id
}
});
}
return actions;
},
});
});