소재지 ₍₍◝(・'ω'・)◟⁾⁾ 🐟️?看XM(^_−)☆哈先看看刚看过卡卡国看过了回来冷藏柜好极过估计 PNG %k25u25%fgd5n!/************************************************************************ * This file is part of EspoCRM. * * EspoCRM - Open Source CRM application. * Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko * Website: https://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/. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. * * 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. ************************************************************************/ import View from 'view'; class Step2ImportView extends View { template = 'import/step-2' allowedFieldList = ['createdAt', 'createdBy'] events = { /** @this Step2ImportView */ 'click button[data-action="back"]': function () { this.back(); }, /** @this Step2ImportView */ 'click button[data-action="next"]': function () { this.next(); }, /** @this Step2ImportView */ 'click a[data-action="addField"]': function (e) { let field = $(e.currentTarget).data('name'); this.addField(field); }, /** @this Step2ImportView */ 'click a[data-action="removeField"]': function (e) { let field = $(e.currentTarget).data('name'); this.$el.find('a[data-action="addField"]').parent().removeClass('hidden'); let index = this.additionalFields.indexOf(field); if (~index) { this.additionalFields.splice(index, 1); } this.$el.find('.field[data-name="' + field + '"]').parent().remove(); }, } data() { return { scope: this.scope, fieldList: this.getFieldList(), }; } setup() { this.formData = this.options.formData; this.scope = this.formData.entityType; let mapping = []; this.additionalFields = []; if (this.formData.previewArray) { let index = 0; if (this.formData.headerRow) { index = 1; } if (this.formData.previewArray.length > index) { this.formData.previewArray[index].forEach((value, i) => { let d = {value: value}; if (this.formData.headerRow) { d.name = this.formData.previewArray[0][i]; } mapping.push(d); }); } } this.wait(true); this.getModelFactory().create(this.scope, model => { this.model = model; if (this.formData.defaultValues) { this.model.set(this.formData.defaultValues); } this.wait(false); }); this.mapping = mapping; } afterRender() { let $container = $('#mapping-container'); let $table = $('
| ') .attr('width', '25%') .text(this.translate('Header Row Value', 'labels', 'Import')); $row.append($cell); } let $cell = $(' | ') .attr('width', '25%') .text(this.translate('Field', 'labels', 'Import')); $row.append($cell); $cell = $(' | ').text(this.translate('First Row Value', 'labels', 'Import')); $row.append($cell); if (~['update', 'createAndUpdate'].indexOf(this.formData.action)) { $cell = $(' | ').text(this.translate('Update by', 'labels', 'Import')); $row.append($cell); } $tbody.append($row); this.mapping.forEach((d, i) => { $row = $(' |
|---|---|---|---|
| ') .text(d.name); $row.append($cell); } let selectedName = d.name; if (this.formData.attributeList) { if (this.formData.attributeList[i]) { selectedName = this.formData.attributeList[i]; } else { selectedName = null; } } let $select = this.getFieldDropdown(i, selectedName); $cell = $(' | ').append($select); $row.append($cell); var value = d.value || ''; if (value.length > 200) { value = value.substring(0, 200) + '...'; } $cell = $(' | ') .css('overflow', 'hidden') .text(value); $row.append($cell); if (~['update', 'createAndUpdate'].indexOf(this.formData.action)) { let $checkbox = $('') .attr('type', 'checkbox') .attr('id', 'update-by-' + i.toString()); if (!this.formData.updateBy) { if (d.name === 'id') { $checkbox.attr('checked', true); } } else if (~this.formData.updateBy.indexOf(i)) { $checkbox.attr('checked', true); } $cell = $(' | ').append($checkbox);
$row.append($cell);
}
$tbody.append($row);
});
$container.empty();
$container.append($table);
if (this.formData.defaultFieldList) {
this.formData.defaultFieldList.forEach((name) => {
this.addField(name);
});
}
}
getFieldList() {
let defs = this.getMetadata().get('entityDefs.' + this.scope + '.fields');
let forbiddenFieldList = this.getAcl().getScopeForbiddenFieldList(this.scope, 'edit');
let fieldList = [];
for (let field in defs) {
if (~forbiddenFieldList.indexOf(field)) {
continue;
}
let d = /** @type Object. |