merge improvements

This commit is contained in:
yuri
2018-01-11 12:24:12 +02:00
parent 76f17e3f95
commit a4d4e640a2
2 changed files with 53 additions and 10 deletions
+20 -5
View File
@@ -4,17 +4,32 @@
<thead>
<tr>
<th width="20%"></th>
{{#each models}}
{{#each dataList}}
<th width="5%">
<input type="radio" name="check-all" value="{{prop this 'id'}}" data-id="{{id}}" class="pull-right">
<input type="radio" name="check-all" value="{{id}}" data-id="{{id}}" class="pull-right">
</th>
<th width="{{../width}}%">
<a href="#{{../scope}}/view/{{prop this 'id'}}">{{get this 'name'}}</a>
<a href="#{{../scope}}/view/{{id}}" target="_BLANK">{{name}}</a>
</th>
{{/each}}
</tr>
</thead>
<tbody>
{{#if hasCreatedAt}}
<tr>
<td align="right">
{{translate 'createdAt' scope=../scope category='fields'}}
</td>
{{#each dataList}}
<td></td>
<td data-id="{{id}}">
<div class="field" data-name="createdAt">
{{{var createdAtViewName ../../this}}}
</div>
</td>
{{/each}}
</tr>
{{/if}}
{{#each rows}}
<tr>
<td align="right">
@@ -24,8 +39,8 @@
<td>
<input type="radio" name="{{../name}}" value="{{id}}" data-id="{{id}}" class="pull-right field-radio">
</td>
<td class="{{id}}">
<div class="field" data-name="{{name}}">
<td data-id="{{id}}">
<div class="field" data-name="{{../name}}">
{{{var fieldVariable ../../this}}}
</div>
</td>
+33 -5
View File
@@ -52,9 +52,11 @@ Espo.define('views/record/merge', 'view', function (Dep) {
}.bind(this));
return {
rows: rows,
models: this.models,
modelList: this.models,
scope: this.scope,
width: Math.round(((80 - this.models.length * 5) / this.models.length * 10)) / 10
hasCreatedAt: this.hasCreatedAt,
width: Math.round(((80 - this.models.length * 5) / this.models.length * 10)) / 10,
dataList: this.getDataList()
};
},
@@ -172,7 +174,7 @@ Espo.define('views/record/merge', 'view', function (Dep) {
this.createView(model.id + '-' + field, viewName, {
model: model,
el: '.merge .' + model.id + ' .field[data-name="' + field + '"]',
el: '.merge [data-id="'+model.id+'"] .field[data-name="' + field + '"]',
defs: {
name: field,
},
@@ -182,8 +184,34 @@ Espo.define('views/record/merge', 'view', function (Dep) {
}.bind(this));
}.bind(this));
this.hasCreatedAt = this.getMetadata().get(['entityDefs', this.scope, 'fields', 'createdAt']);
if (this.hasCreatedAt) {
this.models.forEach(function (model) {
this.createView(model.id + '-' + 'createdAt', 'views/fields/datetime', {
model: model,
el: '.merge [data-id="'+model.id+'"] .field[data-name="createdAt"]',
defs: {
name: 'createdAt',
},
mode: 'detail',
readOnly: true,
});
}, this);
}
},
getDataList: function () {
var dataList = [];
this.models.forEach(function (model, i) {
var o = {};
o.id = model.id;
o.name = Handlebars.Utils.escapeExpression(model.get('name'));
o.createdAtViewName = model.id + '-' + 'createdAt';
dataList.push(o);
}, this);
return dataList;
},
});
});