fix field names conflict with template variables
This commit is contained in:
@@ -611,6 +611,8 @@ var Bull = Bull || {};
|
||||
}, this);
|
||||
},
|
||||
|
||||
handleDataBeforeRender: function (data) {},
|
||||
|
||||
_getHtml: function (callback) {
|
||||
this._isBeingRendered = true;
|
||||
this.trigger("render", this);
|
||||
@@ -622,6 +624,7 @@ var Bull = Bull || {};
|
||||
if (this.model || null) {
|
||||
data.model = this.model;
|
||||
}
|
||||
this.handleDataBeforeRender(data);
|
||||
this._getTemplate(function (template) {
|
||||
var html = this._renderer.render(template, data);
|
||||
callback(html);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="cell" data-name="users">
|
||||
<label class="control-label" data-name="users">{{{translate 'User List' scope='Calendar'}}}</label>
|
||||
<div class="field" data-name="users">{{{users}}}</div>
|
||||
<div class="field" data-name="users">{{{usersField}}}</div>
|
||||
</div>
|
||||
@@ -7,7 +7,7 @@
|
||||
<% _.each(layout.rows, function (row, key) { %>
|
||||
<div class="expanded-row">
|
||||
<% _.each(row, function (defs, key) { %>
|
||||
<span class="cell" data-name="<%= defs.name %>"><%
|
||||
<span class="cell" data-name="<%= defs.field %>"><%
|
||||
var tag = 'tag' in defs ? defs.tag : false;
|
||||
if (tag) {
|
||||
print( '<' + tag);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
align = defs.options.defs.align || false;
|
||||
}
|
||||
%>
|
||||
<td class="cell" data-name="<%= defs.name %>" <% if (width) print(' width="'+width+'"'); if (align) print(' align="'+align+'"'); %>>
|
||||
<td class="cell" data-name="<%= defs.columnName %>" <% if (width) print(' width="'+width+'"'); if (align) print(' align="'+align+'"'); %>>
|
||||
<%
|
||||
var tag = 'tag' in defs ? defs.tag : false;
|
||||
if (tag) {
|
||||
|
||||
@@ -67,15 +67,15 @@
|
||||
spanClass = 'col-sm-12';
|
||||
}
|
||||
%>
|
||||
<div class="cell <%= spanClass %> form-group<% if (cell.name) { %>{{#if hiddenFields.<%= cell.name %>}} hidden-cell{{/if}}<% } %>" data-name="<%= cell.name %>">
|
||||
<% if (!cell.noLabel) { %><label class="control-label<% if (cell.name) { %>{{#if hiddenFields.<%= cell.name %>}} hidden{{/if}}<% } %>" data-name="<%= cell.name %>"><span class="label-text"><%
|
||||
<div class="cell <%= spanClass %> form-group<% if (cell.field) { %>{{#if hiddenFields.<%= cell.field %>}} hidden-cell{{/if}}<% } %>" data-name="<%= cell.field %>">
|
||||
<% if (!cell.noLabel) { %><label class="control-label<% if (cell.field) { %>{{#if hiddenFields.<%= cell.field %>}} hidden{{/if}}<% } %>" data-name="<%= cell.field %>"><span class="label-text"><%
|
||||
if ('customLabel' in cell) {
|
||||
print (cell.customLabel);
|
||||
} else {
|
||||
print ("{{translate \""+cell.name+"\" scope=\""+model.name+"\" category='fields'}}");
|
||||
print ("{{translate \""+cell.field+"\" scope=\""+model.name+"\" category='fields'}}");
|
||||
}
|
||||
%></span></label><% } %>
|
||||
<div class="field<% if (cell.name) { %>{{#if hiddenFields.<%= cell.name %>}} hidden{{/if}}<% } %>" data-name="<%= cell.name %>"><%
|
||||
<div class="field<% if (cell.field) { %>{{#if hiddenFields.<%= cell.field %>}} hidden{{/if}}<% } %>" data-name="<%= cell.field %>"><%
|
||||
if ('customCode' in cell) {
|
||||
print (cell.customCode);
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
{{translate 'beforeSaveCustomScript' category='fields' scope='EntityManager'}}
|
||||
</label>
|
||||
<div class="field" data-name="beforeSaveCustomScript">
|
||||
{{{beforeSaveCustomScript}}}
|
||||
{{{beforeSaveCustomScriptField}}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,6 +1,6 @@
|
||||
{{#each attributeList}}
|
||||
<div class="cell form-group" data-name="{{./this}}">
|
||||
<label class="control-label" data-name="{{./this}}">{{translate this category='fields' scope='LayoutManager'}}</label>
|
||||
<div class="field" data-name="{{./this}}">{{{var this ../this}}}</div>
|
||||
{{#each attributeDataList}}
|
||||
<div class="cell form-group" data-name="{{name}}">
|
||||
<label class="control-label" data-name="{{name}}">{{translate name category='fields' scope='LayoutManager'}}</label>
|
||||
<div class="field" data-name="{{name}}">{{{var viewKey ../this}}}</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
@@ -1,14 +1,14 @@
|
||||
<div class="cell form-group" data-name="format">
|
||||
<label class="control-label" data-name="format">{{translate 'format' category='fields' scope='Export'}}</label>
|
||||
<div class="field" data-name="format">{{{format}}}</div>
|
||||
<div class="field" data-name="format">{{{formatField}}}</div>
|
||||
</div>
|
||||
|
||||
<div class="cell form-group" data-name="exportAllFields">
|
||||
<label class="control-label" data-name="exportAllFields">{{translate 'exportAllFields' category='fields' scope='Export'}}</label>
|
||||
<div class="field" data-name="exportAllFields">{{{exportAllFields}}}</div>
|
||||
<div class="field" data-name="exportAllFields">{{{exportAllFieldsField}}}</div>
|
||||
</div>
|
||||
|
||||
<div class="cell form-group" data-name="fieldList">
|
||||
<label class="control-label" data-name="fieldList">{{translate 'fieldList' category='fields' scope='Export'}}</label>
|
||||
<div class="field" data-name="fieldList">{{{fieldList}}}</div>
|
||||
<div class="field" data-name="fieldList">{{{fieldListField}}}</div>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="cell form-group col-sm-6 col-md-12{{#if hidden}} hidden-cell{{/if}}" data-name="{{name}}">
|
||||
<label class="control-label{{#if hidden}} hidden{{/if}}" data-name="{{name}}"><span class="label-text">{{translate name scope=../model.name category='fields'}}</span></label>
|
||||
<div class="field{{#if hidden}} hidden{{/if}}" data-name="{{name}}">
|
||||
{{{var name ../this}}}
|
||||
{{{var viewKey ../this}}}
|
||||
</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
@@ -14,25 +14,25 @@
|
||||
<div class="cell form-group col-sm-6 col-md-12" data-name="complexCreated">
|
||||
<label class="control-label" data-name="complexCreated"><span class="label-text">{{translate 'Created'}}</span></label>
|
||||
<div class="field" data-name="complexCreated">
|
||||
<span data-name="createdAt" class="field">{{{createdAt}}}</span> <span class="text-muted">»</span> <span data-name="createdBy" class="field">{{{createdBy}}}</span>
|
||||
<span data-name="createdAt" class="field">{{{createdAtField}}}</span> <span class="text-muted">»</span> <span data-name="createdBy" class="field">{{{createdByField}}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell form-group col-sm-6 col-md-12" data-name="complexModified">
|
||||
<label class="control-label" data-name="complexModified"><span class="label-text">{{translate 'Modified'}}</span></label>
|
||||
<div class="field" data-name="complexModified">
|
||||
<span data-name="modifiedAt" class="field">{{{modifiedAt}}}</span> <span class="text-muted">»</span> <span data-name="modifiedBy" class="field">{{{modifiedBy}}}</span>
|
||||
<span data-name="modifiedAt" class="field">{{{modifiedAtField}}}</span> <span class="text-muted">»</span> <span data-name="modifiedBy" class="field">{{{modifiedByField}}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/unless}}
|
||||
|
||||
{{#if followers}}
|
||||
{{#if followersField}}
|
||||
<div class="row">
|
||||
<div class="cell form-group col-sm-6 col-md-12" data-name="followers">
|
||||
<label class="control-label" data-name="followers"><span class="label-text">{{translate 'Followers'}}</span></label>
|
||||
<div class="field" data-name="followers">
|
||||
{{{followers}}}
|
||||
{{{followersField}}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="cell form-group col-sm-6 col-md-12{{#if hidden}} hidden-cell{{/if}}" data-name="{{name}}">
|
||||
<label class="control-label{{#if hidden}} hidden{{/if}}" data-name="{{name}}"><span class="label-text">{{translate name scope=../model.name category='fields'}}</span></label>
|
||||
<div class="field{{#if hidden}} hidden{{/if}}" data-name="{{name}}">
|
||||
{{{var name ../this}}}
|
||||
{{{var viewKey ../this}}}
|
||||
</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="row">
|
||||
<div class="cell col-sm-12 form-group" data-name="post">
|
||||
<div class="field" data-name="post">{{{post}}}</div>
|
||||
<div class="field" data-name="post">{{{postField}}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row post-control{{#if interactiveMode}} hidden{{/if}}">
|
||||
@@ -10,23 +10,23 @@
|
||||
{{#if interactiveMode}}
|
||||
<button type="button" class="btn btn-primary post pull-left">{{translate 'Post'}}</button>
|
||||
{{/if}}
|
||||
<div class="field" style="display: inline-block;" data-name="attachments">{{{attachments}}}</div>
|
||||
<div class="field" style="display: inline-block;" data-name="attachments">{{{attachmentsField}}}</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<div class="cell" data-name="targetType">
|
||||
<div class="field" data-name="targetType">{{{targetType}}}</div>
|
||||
<div class="field" data-name="targetType">{{{targetTypeField}}}</div>
|
||||
</div>
|
||||
<div class="cell" data-name="users">
|
||||
<div class="field" data-name="users">{{{users}}}</div>
|
||||
<div class="field" data-name="users">{{{usersField}}}</div>
|
||||
</div>
|
||||
<div class="cell" data-name="teams">
|
||||
<div class="field" data-name="teams">{{{teams}}}</div>
|
||||
<div class="field" data-name="teams">{{{teamsField}}}</div>
|
||||
</div>
|
||||
<div class="cell" data-name="portals">
|
||||
<div class="field" data-name="portals">{{{portals}}}</div>
|
||||
<div class="field" data-name="portals">{{{portalsField}}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -33,11 +33,23 @@ Espo.define('views/admin/layouts/record/edit-attributes', 'views/record/base', f
|
||||
template: 'admin/layouts/record/edit-attributes',
|
||||
|
||||
data: function () {
|
||||
console.log(this.getAttributeDataList());
|
||||
return {
|
||||
attributeList: this.attributeList
|
||||
attributeDataList: this.getAttributeDataList()
|
||||
};
|
||||
},
|
||||
|
||||
getAttributeDataList: function () {
|
||||
var list = [];
|
||||
this.attributeList.forEach(function (item) {
|
||||
list.push({
|
||||
name: item,
|
||||
viewKey: item + 'Field'
|
||||
});
|
||||
}, this);
|
||||
return list;
|
||||
},
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
|
||||
|
||||
@@ -230,7 +230,13 @@ Espo.define('views/record/base', ['view', 'view-record-helper', 'dynamic-logic']
|
||||
},
|
||||
|
||||
getFieldView: function (name) {
|
||||
return this.getView(name) || null;
|
||||
var view = this.getView(name + 'Field') || null;
|
||||
|
||||
// TODO remove
|
||||
if (!view) {
|
||||
view = this.getView(name) || null;
|
||||
}
|
||||
return view;
|
||||
},
|
||||
|
||||
getField: function (name) {
|
||||
@@ -251,6 +257,14 @@ Espo.define('views/record/base', ['view', 'view-record-helper', 'dynamic-logic']
|
||||
};
|
||||
},
|
||||
|
||||
// TODO remove
|
||||
handleDataBeforeRender: function (data) {
|
||||
this.getFieldList().forEach(function (field) {
|
||||
var viewKey = field + 'Field';
|
||||
data[field] = data[viewKey];
|
||||
}, this);
|
||||
},
|
||||
|
||||
setup: function () {
|
||||
if (typeof this.model === 'undefined') {
|
||||
throw new Error('Model has not been injected into record view.');
|
||||
@@ -724,7 +738,9 @@ Espo.define('views/record/base', ['view', 'view-record-helper', 'dynamic-logic']
|
||||
o.customOptionList = this.recordHelper.getFieldOptionList(name);
|
||||
}
|
||||
|
||||
this.createView(name, view, o);
|
||||
var viewKey = name + 'Field';
|
||||
|
||||
this.createView(viewKey, view, o);
|
||||
|
||||
if (!~this.fieldList.indexOf(name)) {
|
||||
this.fieldList.push(name);
|
||||
@@ -736,4 +752,3 @@ Espo.define('views/record/base', ['view', 'view-record-helper', 'dynamic-logic']
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -135,7 +135,13 @@ Espo.define('views/record/detail-middle', 'view', function (Dep) {
|
||||
},
|
||||
|
||||
getFieldViews: function () {
|
||||
return Espo.Utils.clone(this.nestedViews);
|
||||
var nestedViews = this.nestedViews;
|
||||
var fieldViews = {};
|
||||
for (var viewKey in this.nestedViews) {
|
||||
var name = this.nestedViews[viewKey].name;
|
||||
fieldViews[name] = this.nestedViews[viewKey];
|
||||
}
|
||||
return fieldViews;
|
||||
},
|
||||
|
||||
getFieldView: function (name) {
|
||||
|
||||
@@ -560,6 +560,9 @@ Espo.define('views/record/detail', ['views/record/base', 'view-record-helper'],
|
||||
return view || null;
|
||||
},
|
||||
|
||||
// TODO remove
|
||||
handleDataBeforeRender: function (data) {},
|
||||
|
||||
data: function () {
|
||||
var navigateButtonsEnabled = !this.navigateButtonsDisabled && !!this.model.collection;
|
||||
|
||||
@@ -1154,8 +1157,9 @@ Espo.define('views/record/detail', ['views/record/base', 'view-record-helper'],
|
||||
}
|
||||
|
||||
var cell = {
|
||||
name: name,
|
||||
name: name + 'Field',
|
||||
view: viewName,
|
||||
field: name,
|
||||
el: el + ' .middle .field[data-name="' + name + '"]',
|
||||
fullWidth: fullWidth,
|
||||
options: o
|
||||
|
||||
@@ -86,7 +86,8 @@ Espo.define('views/record/list-expanded', 'views/record/list', function (Dep) {
|
||||
var type = e.type || model.getFieldType(e.name) || 'base';
|
||||
|
||||
var item = {
|
||||
name: e.name,
|
||||
name: e.name + 'Field',
|
||||
field: e.name,
|
||||
view: e.view || model.getFieldParam(e.name, 'view') || this.getFieldManager().getViewName(type),
|
||||
options: {
|
||||
defs: {
|
||||
@@ -106,8 +107,10 @@ Espo.define('views/record/list-expanded', 'views/record/list', function (Dep) {
|
||||
|
||||
if ('right' in listLayout) {
|
||||
if (listLayout.right != false) {
|
||||
var name = listLayout.right.name || 'right';
|
||||
layout.right = {
|
||||
name: listLayout.right.name || 'right',
|
||||
field: name,
|
||||
name: name,
|
||||
view: listLayout.right.view,
|
||||
options: {
|
||||
defs: {
|
||||
|
||||
@@ -910,7 +910,8 @@ Espo.define('views/record/list', 'view', function (Dep) {
|
||||
|
||||
if (this.checkboxes) {
|
||||
layout.push({
|
||||
name: 'r-checkbox',
|
||||
name: 'r-checkboxField',
|
||||
columnName: 'r-checkbox',
|
||||
template: 'record.list-checkbox'
|
||||
});
|
||||
}
|
||||
@@ -923,7 +924,8 @@ Espo.define('views/record/list', 'view', function (Dep) {
|
||||
}
|
||||
|
||||
var item = {
|
||||
name: col.name,
|
||||
columnName: col.name,
|
||||
name: col.name + 'Field',
|
||||
view: col.view || model.getFieldParam(col.name, 'view') || this.getFieldManager().getViewName(type),
|
||||
options: {
|
||||
defs: {
|
||||
@@ -1001,14 +1003,15 @@ Espo.define('views/record/list', 'view', function (Dep) {
|
||||
|
||||
getRowActionsDefs: function () {
|
||||
return {
|
||||
name: 'buttons',
|
||||
columnName: 'buttons',
|
||||
name: 'buttonsField',
|
||||
view: this.rowActionsView,
|
||||
options: {
|
||||
defs: {
|
||||
params: {
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
@@ -1065,7 +1068,7 @@ Espo.define('views/record/list', 'view', function (Dep) {
|
||||
},
|
||||
|
||||
getItemEl: function (model, item) {
|
||||
return this.options.el + ' tr[data-id="' + model.id + '"] td.cell[data-name="' + item.name + '"]';
|
||||
return this.options.el + ' tr[data-id="' + model.id + '"] td.cell[data-name="' + item.columnName + '"]';
|
||||
},
|
||||
|
||||
prepareInternalLayout: function (internalLayout, model) {
|
||||
|
||||
@@ -96,10 +96,12 @@ Espo.define('views/record/panels/bottom', 'view', function (Dep) {
|
||||
var item = d;
|
||||
if (typeof item !== 'object') {
|
||||
item = {
|
||||
name: item
|
||||
name: item,
|
||||
viewKey: item + 'Field'
|
||||
}
|
||||
}
|
||||
item = Espo.Utils.clone(item);
|
||||
item.viewKey = item.name + 'Field';
|
||||
|
||||
if (this.recordHelper.getFieldStateParam(item.name, 'hidden') !== null) {
|
||||
item.hidden = this.recordHelper.getFieldStateParam(item.name, 'hidden');
|
||||
@@ -133,8 +135,8 @@ Espo.define('views/record/panels/bottom', 'view', function (Dep) {
|
||||
var fields = {};
|
||||
|
||||
this.getFieldList().forEach(function (item) {
|
||||
if (this.hasView(item.name)) {
|
||||
fields[item.name] = this.getView(item.name);
|
||||
if (this.hasView(item.viewKey)) {
|
||||
fields[item.name] = this.getView(item.viewKey);
|
||||
}
|
||||
}, this);
|
||||
return fields;
|
||||
@@ -231,9 +233,9 @@ Espo.define('views/record/panels/bottom', 'view', function (Dep) {
|
||||
o.customOptionList = this.recordHelper.getFieldOptionList(field);
|
||||
}
|
||||
|
||||
this.createView(field, viewName, o);
|
||||
var viewKey = field + 'Field';
|
||||
this.createView(viewKey, viewName, o);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -82,4 +82,3 @@ Espo.define('views/record/panels/default-side', 'views/record/panels/side', func
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -96,10 +96,12 @@ Espo.define('views/record/panels/side', 'view', function (Dep) {
|
||||
var item = d;
|
||||
if (typeof item !== 'object') {
|
||||
item = {
|
||||
name: item
|
||||
name: item,
|
||||
viewKey: item + 'Field'
|
||||
}
|
||||
}
|
||||
item = Espo.Utils.clone(item);
|
||||
item.viewKey = item.name + 'Field';
|
||||
|
||||
if (this.recordHelper.getFieldStateParam(item.name, 'hidden') !== null) {
|
||||
item.hidden = this.recordHelper.getFieldStateParam(item.name, 'hidden');
|
||||
@@ -115,7 +117,6 @@ Espo.define('views/record/panels/side', 'view', function (Dep) {
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
|
||||
this.createFields();
|
||||
},
|
||||
|
||||
@@ -176,7 +177,9 @@ Espo.define('views/record/panels/side', 'view', function (Dep) {
|
||||
o.customOptionList = this.recordHelper.getFieldOptionList(field);
|
||||
}
|
||||
|
||||
this.createView(field, viewName, o);
|
||||
var viewKey = field + 'Field';
|
||||
|
||||
this.createView(viewKey, viewName, o);
|
||||
},
|
||||
|
||||
createFields: function () {
|
||||
@@ -209,10 +212,11 @@ Espo.define('views/record/panels/side', 'view', function (Dep) {
|
||||
var fields = {};
|
||||
|
||||
this.getFieldList().forEach(function (item) {
|
||||
if (this.hasView(item.name)) {
|
||||
fields[item.name] = this.getView(item.name);
|
||||
if (this.hasView(item.viewKey)) {
|
||||
fields[item.name] = this.getView(item.viewKey);
|
||||
}
|
||||
}, this);
|
||||
|
||||
return fields;
|
||||
},
|
||||
|
||||
@@ -241,4 +245,3 @@ Espo.define('views/record/panels/side', 'view', function (Dep) {
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user