navigate in quick view 2

This commit is contained in:
yuri
2015-12-22 15:16:39 +02:00
parent e959bcb369
commit 75f26e3ecc
24 changed files with 114 additions and 145 deletions
@@ -25,7 +25,7 @@
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('Crm:Views.Fields.Ico', 'Views.Fields.Base', function (Dep) {
Espo.define('crm:views/fields/ico', 'views/fields/base', function (Dep) {
return Dep.extend({
@@ -36,7 +36,7 @@ Espo.define('Crm:Views.Fields.Ico', 'Views.Fields.Base', function (Dep) {
if (this.params.notRelationship) {
icoTpl = '<span class="glyphicon glyphicon-{icoName} text-muted action" style="cursor: pointer" title="'+this.translate('View')+'" data-action="quickView" data-id="'+this.model.id+'" data-scope="'+this.model.name+'"></span>';
} else {
icoTpl = '<span class="glyphicon glyphicon-{icoName} text-muted action" style="cursor: pointer" title="'+this.translate('View')+'" data-action="viewRelated" data-id="'+this.model.id+'"></span>';
icoTpl = '<span class="glyphicon glyphicon-{icoName} text-muted action" style="cursor: pointer" title="'+this.translate('View')+'" data-action="quickView" data-id="'+this.model.id+'"></span>';
}
switch (this.model.name) {
@@ -32,7 +32,7 @@ Espo.define('crm:views/record/row-actions/activities', 'views/record/row-actions
getActionList: function () {
var list = [{
action: 'viewRelated',
action: 'quickView',
label: 'View',
data: {
id: this.model.id
@@ -40,7 +40,7 @@ Espo.define('crm:views/record/row-actions/activities', 'views/record/row-actions
}];
if (this.options.acl.edit) {
list.push({
action: 'editRelated',
action: 'quickEdit',
label: 'Edit',
data: {
id: this.model.id
@@ -26,13 +26,13 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('Crm:Views.Record.RowActions.History', 'Views.Record.RowActions.Relationship', function (Dep) {
Espo.define('crm:views/record/row-actions/history', 'views/record/row-actions/relationship', function (Dep) {
return Dep.extend({
getActionList: function () {
var list = [{
action: 'viewRelated',
action: 'quickView',
label: 'View',
data: {
id: this.model.id
@@ -50,7 +50,7 @@ Espo.define('Crm:Views.Record.RowActions.History', 'Views.Record.RowActions.Rela
if (this.options.acl.edit) {
list = list.concat([
{
action: 'editRelated',
action: 'quickEdit',
label: 'Edit',
data: {
id: this.model.id
@@ -32,7 +32,7 @@ Espo.define('crm:views/record/row-actions/tasks', 'views/record/row-actions/rela
getActionList: function () {
var list = [{
action: 'viewRelated',
action: 'quickView',
label: 'View',
data: {
id: this.model.id
@@ -40,7 +40,7 @@ Espo.define('crm:views/record/row-actions/tasks', 'views/record/row-actions/rela
}];
if (this.options.acl.edit) {
list.push({
action: 'editRelated',
action: 'quickEdit',
label: 'Edit',
data: {
id: this.model.id
@@ -4,7 +4,7 @@
{{{avatar}}}
</div>
<div class="stream-head-text-container">
<span class="text-muted"><span class="glyphicon glyphicon-envelope action" style="cursor: pointer;" title="{{translate 'View'}}" data-action="viewRecord" data-id="{{emailId}}" data-scope="Email"></span>
<span class="text-muted"><span class="glyphicon glyphicon-envelope action" style="cursor: pointer;" title="{{translate 'View'}}" data-action="quickView" data-id="{{emailId}}" data-scope="Email"></span>
{{{message}}}
</span>
</div>
@@ -13,7 +13,7 @@
{{{avatar}}}
</div>
<div class="stream-head-text-container">
<span class="text-muted"><span class="glyphicon glyphicon-envelope action" style="cursor: pointer;" title="{{translate 'View'}}" data-action="viewRecord" data-id="{{emailId}}" data-scope="Email"></span>
<span class="text-muted"><span class="glyphicon glyphicon-envelope action" style="cursor: pointer;" title="{{translate 'View'}}" data-action="quickView" data-id="{{emailId}}" data-scope="Email"></span>
{{{message}}}
</span>
</div>
@@ -13,7 +13,7 @@
{{{avatar}}}
</div>
<div class="stream-head-text-container">
<span class="text-muted"><span class="glyphicon glyphicon-envelope action" style="cursor: pointer;" title="{{translate 'View'}}" data-action="viewRecord" data-id="{{emailId}}" data-scope="Email"></span>
<span class="text-muted"><span class="glyphicon glyphicon-envelope action" style="cursor: pointer;" title="{{translate 'View'}}" data-action="quickView" data-id="{{emailId}}" data-scope="Email"></span>
{{{message}}}
</span>
</div>
+1
View File
@@ -156,6 +156,7 @@ Espo.define('views/modal', 'view', function (Dep) {
},
actionCancel: function () {
this.trigger('cancel');
this.dialog.close();
},
+40 -41
View File
@@ -72,7 +72,7 @@ Espo.define('views/modals/detail', 'views/modal', function (Dep) {
label: 'Close'
});
if (this.model.collection && !this.navigateButtonsDisabled) {
if (this.model && this.model.collection && !this.navigateButtonsDisabled) {
this.buttonList.push({
name: 'previous',
html: '<span class="glyphicon glyphicon-chevron-left"></span>',
@@ -87,6 +87,9 @@ Espo.define('views/modals/detail', 'views/modal', function (Dep) {
pullLeft: true,
disabled: true
});
this.indexOfRecord = this.model.collection.indexOf(this.model);
} else {
this.navigateButtonsDisabled = true;
}
this.scope = this.scope || this.options.scope;
@@ -96,34 +99,27 @@ Espo.define('views/modals/detail', 'views/modal', function (Dep) {
this.sourceModel = this.model;
if (this.model) {
if (this.model.collection) {
this.indexOfRecord = this.model.collection.indexOf(this.model);
}
}
this.getModelFactory().create(this.scope, function (model) {
if (!this.sourceModel) {
this.model = model;
model.id = this.id;
model.once('sync', function () {
this.createRecord(model);
}, this);
model.fetch();
} else {
var collection = this.model.collection;
this.model.id = this.id;
model = this.model = this.model.clone();
model.collection = collection;
this.listenToOnce(this.model, 'sync', function () {
this.createRecordView();
}, this);
this.model.fetch();
} else {
this.model = this.sourceModel.clone();
this.model.collection = this.sourceModel.collection;
this.listenTo(this.model, 'change', function () {
this.sourceModel.set(this.model.getClonedAttributes());
}, this);
this.once('after:render', function () {
model.fetch();
});
this.createRecord(model);
this.listenTo(model, 'change', function () {
this.sourceModel.set(model.getClonedAttributes());
this.model.fetch();
}, this);
this.createRecordView();
}
}, this);
},
@@ -156,7 +152,8 @@ Espo.define('views/modals/detail', 'views/modal', function (Dep) {
}
},
createRecord: function (model, callback) {
createRecordView: function (callback) {
var model = this.model;
this.header = this.getLanguage().translate(this.scope, 'scopeNames');
if (model.get('name')) {
@@ -193,7 +190,7 @@ Espo.define('views/modals/detail', 'views/modal', function (Dep) {
this.$el.children(0).scrollTop(0);
}.bind(this), 50);
if (!this.navigateButtonsEnabled) {
if (!this.navigateButtonsDisabled) {
this.controlNavigationButtons();
}
},
@@ -241,32 +238,30 @@ Espo.define('views/modals/detail', 'views/modal', function (Dep) {
switchToModelByIndex: function (indexOfRecord) {
if (!this.model.collection) return;
var model = this.model.collection.at(indexOfRecord);
if (!model) {
this.sourceModel = this.model.collection.at(indexOfRecord);
if (!this.sourceModel) {
throw new Error("Model is not found in collection by index.");
}
this.indexOfRecord = indexOfRecord;
this.id = model.id;
this.scope = model.name;
this.id = this.sourceModel.id;
this.scope = this.sourceModel.name;
this.model = this.sourceModel = model;
var collection = this.model.collection;
this.model = this.model.clone();
this.model.collection = collection;
this.once('after:render', function () {
this.model.fetch();
}, this);
this.model = this.sourceModel.clone();
this.model.collection = this.sourceModel.collection;
this.listenTo(this.model, 'change', function () {
this.sourceModel.set(this.model.getClonedAttributes());
}, this);
this.once('after:render', function () {
this.model.fetch();
}, this);
this.createRecord(this.model, function () {
this.createRecordView(function () {
this.reRender();
}.bind(this));
@@ -322,12 +317,16 @@ Espo.define('views/modals/detail', 'views/modal', function (Dep) {
this.close();
}, this);
this.listenToOnce(view, 'after:save', function () {
this.trigger('after:save');
this.listenToOnce(view, 'after:save', function (model) {
this.trigger('after:save', model);
}, this);
this.listenToOnce(view, 'cancel', function () {
this.trigger('after:edit-cancel');
}, this);
view.render();
}.bind(this));
}, this);
},
actionFullForm: function () {
@@ -26,28 +26,10 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('Views.Notifications.List', 'Views.Record.ListExpanded', function (Dep) {
Espo.define('views/notifications/list', 'views/record/list-expanded', function (Dep) {
return Dep.extend({
actionViewRecord: function (data) {
var id = data.id;
var scope = data.scope;
var viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.detail') || 'Modals.Detail';
this.notify('Loading...');
this.createView('quickDetail', viewName, {
scope: scope,
id: id
}, function (view) {
view.once('after:render', function () {
Espo.Ui.notify(false);
});
view.render();
}.bind(this));
}
});
});
+36 -15
View File
@@ -904,28 +904,41 @@ Espo.define('views/record/list', 'view', function (Dep) {
var id = data.id;
if (!id) return;
var scope = data.scope || this.scope;
var model = null;
if (this.collection) {
model = this.collection.get(id);
}
if (!data.scope && !model) {
return;
}
var viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.detail') || 'Modals.Detail';
var scope = data.scope || model.name || this.scope;
var viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.detail') || 'views/modals/detail';
if (!this.quickDetailDisabled) {
this.notify('Loading...');
this.createView('modal', viewName, {
scope: scope,
model: this.collection.get(id),
model: model,
id: id
}, function (view) {
view.once('after:render', function () {
this.listenToOnce(view, 'after:render', function () {
Espo.Ui.notify(false);
});
view.render();
view.once('after:save', function () {
var model = this.collection.get(id);
this.listenToOnce(view, 'after:save', function (m) {
var model = this.collection.get(m.id);
if (model) {
model.fetch();
model.set(m.getClonedAttributes());
this.actionQuickView({id: m.id, scope: model.name});
}
}, this);
}.bind(this));
this.listenToOnce(view, 'after:edit-cancel', function () {
this.actionQuickView({id: view.model.id, scope: view.model.name});
}, this);
}, this);
} else {
this.getRouter().navigate('#' + scope + '/view/' + id, {trigger: true});
}
@@ -936,16 +949,24 @@ Espo.define('views/record/list', 'view', function (Dep) {
var id = data.id;
if (!id) return;
var scope = data.scope || this.scope;
var model = null;
if (this.collection) {
model = this.collection.get(id);
}
if (!data.scope && !model) {
return;
}
var viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.edit') || 'Modals.Edit';
var scope = data.scope || model.name || this.scope;
var viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.edit') || 'views/modals/edit';
if (!this.quickEditDisabled) {
this.notify('Loading...');
this.createView('modal', viewName, {
scope: scope,
id: id,
model: this.collection.get(id),
model: model,
fullFormDisabled: data.noFullForm,
returnUrl: '#' + scope,
returnDispatchParams: {
@@ -962,14 +983,14 @@ Espo.define('views/record/list', 'view', function (Dep) {
view.render();
this.listenToOnce(view, 'after:save', function () {
var model = this.collection.get(id);
this.listenToOnce(view, 'after:save', function (m) {
var model = this.collection.get(m.id);
if (model) {
model.fetch();
model.set(m.getClonedAttributes());
}
}, this);
}.bind(this));
}, this);
} else {
this.getRouter().dispatch(scope, 'edit', {
id: id,
@@ -127,25 +127,6 @@ Espo.define('views/record/panels/bottom', 'view', function (Dep) {
return this.actionList || [];
},
actionViewRecord: function (data) {
var id = data.id;
var scope = data.scope;
var viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.detail') || 'Modals.Detail';
this.notify('Loading...');
this.createView('quickDetail', viewName, {
scope: scope,
id: id,
model: this.collection.get(id),
}, function (view) {
view.once('after:render', function () {
Espo.Ui.notify(false);
});
view.render();
}.bind(this));
},
getFieldViews: function () {
var fields = {};
@@ -228,7 +228,7 @@ Espo.define('views/record/panels/relationship', ['views/record/panels/bottom', '
var id = data.id;
var scope = this.collection.get(id).name;
var viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.detail') || 'Modals.Detail';
var viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.detail') || 'views/modals/detail';
this.notify('Loading...');
this.createView('quickDetail', viewName, {
@@ -250,7 +250,7 @@ Espo.define('views/record/panels/relationship', ['views/record/panels/bottom', '
var id = data.id;
var scope = this.collection.get(id).name;
var viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.edit') || 'Modals.Edit';
var viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.edit') || 'views/modals/edit';
this.notify('Loading...');
this.createView('quickEdit', viewName, {
@@ -34,7 +34,7 @@ Espo.define('views/record/row-actions/relationship-edit-and-remove', 'views/reco
if (this.options.acl.edit) {
return [
{
action: 'editRelated',
action: 'quickEdit',
label: 'Edit',
data: {
id: this.model.id
@@ -32,7 +32,7 @@ Espo.define('views/record/row-actions/relationship-no-remove', 'views/record/row
getActionList: function () {
var list = [{
action: 'viewRelated',
action: 'quickView',
label: 'View',
data: {
id: this.model.id
@@ -41,7 +41,7 @@ Espo.define('views/record/row-actions/relationship-no-remove', 'views/record/row
if (this.options.acl.edit) {
list = list.concat([
{
action: 'editRelated',
action: 'quickEdit',
label: 'Edit',
data: {
id: this.model.id
@@ -26,13 +26,13 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('Views.Record.RowActions.RelationshipNoUnlink', 'Views.Record.RowActions.Relationship', function (Dep) {
Espo.define('views/record/row-actions/relationship-no-unlink', 'views/record/row-actions/relationship', function (Dep) {
return Dep.extend({
getActionList: function () {
var list = [{
action: 'viewRelated',
action: 'quickView',
label: 'View',
data: {
id: this.model.id
@@ -41,7 +41,7 @@ Espo.define('Views.Record.RowActions.RelationshipNoUnlink', 'Views.Record.RowAct
if (this.options.acl.edit) {
list = list.concat([
{
action: 'editRelated',
action: 'quickEdit',
label: 'Edit',
data: {
id: this.model.id
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('Views.Record.RowActions.RelationshipRemoveOnly', 'Views.Record.RowActions.Relationship', function (Dep) {
Espo.define('views/record/row-actions/relationship-remove-only', 'views/record/row-actions/relationship', function (Dep) {
return Dep.extend({
@@ -42,7 +42,7 @@ Espo.define('Views.Record.RowActions.RelationshipRemoveOnly', 'Views.Record.RowA
}
];
}
},
}
});
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('Views.Record.RowActions.RelationshipUnlinkOnly', 'Views.Record.RowActions.Relationship', function (Dep) {
Espo.define('views/record/row-actions/relationship-unlink-only', 'views/record/row-actions/relationship', function (Dep) {
return Dep.extend({
@@ -26,13 +26,13 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('Views.Record.RowActions.RelationshipViewAndEdit', 'Views.Record.RowActions.Relationship', function (Dep) {
Espo.define('views/record/row-actions/relationship-view-and-edit', 'views/record/row-actions/relationship', function (Dep) {
return Dep.extend({
getActionList: function () {
var list = [{
action: 'viewRelated',
action: 'quickView',
label: 'View',
data: {
id: this.model.id
@@ -40,7 +40,7 @@ Espo.define('Views.Record.RowActions.RelationshipViewAndEdit', 'Views.Record.Row
}];
if (this.options.acl.edit) {
list.push({
action: 'editRelated',
action: 'quickEdit',
label: 'Edit',
data: {
id: this.model.id
@@ -32,7 +32,7 @@ Espo.define('views/record/row-actions/relationship-view-and-unlink', 'views/reco
getActionList: function () {
var list = [{
action: 'viewRelated',
action: 'quickView',
label: 'View',
data: {
id: this.model.id
@@ -26,13 +26,13 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('Views.Record.RowActions.Relationship', 'Views.Record.RowActions.Default', function (Dep) {
Espo.define('views/record/row-actions/relationship', 'views/record/row-actions/default', function (Dep) {
return Dep.extend({
getActionList: function () {
var list = [{
action: 'viewRelated',
action: 'quickView',
label: 'View',
data: {
id: this.model.id
@@ -41,7 +41,7 @@ Espo.define('Views.Record.RowActions.Relationship', 'Views.Record.RowActions.Def
if (this.options.acl.edit) {
list = list.concat([
{
action: 'editRelated',
action: 'quickEdit',
label: 'Edit',
data: {
id: this.model.id
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('Views.Record.RowActions.ViewAndEdit', 'Views.Record.RowActions.Default', function (Dep) {
Espo.define('views/record/row-actions/view-and-edit', 'views/record/row-actions/default', function (Dep) {
return Dep.extend({
@@ -115,26 +115,6 @@ Espo.define('views/stream/record/list', 'views/record/list-expanded', function (
collection.fetchNew({
success: success,
});
},
actionViewRecord: function (data, e) {
e.stopPropagation();
var id = data.id;
var scope = data.scope;
var viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.detail') || 'Modals.Detail';
this.notify('Loading...');
this.createView('modal', viewName, {
scope: scope,
id: id
}, function (view) {
view.once('after:render', function () {
Espo.Ui.notify(false);
});
view.render();
}.bind(this));
}
});
+5
View File
@@ -39,6 +39,11 @@ blockquote {
padding: @panel-padding @panel-padding @panel-padding;
}
.modal-footer .btn.pull-left {
margin-left: 0;
margin-right: 0;
}
.table thead > tr > th {
border-bottom: 1px solid @table-border-color;
font-weight: normal;