PHP Classes

File: client/modules/pim/src/views/record/panels/refresh-after-update-related.js

Recommend this page to a friend!
  Classes of alex nov   KennerPIM   client/modules/pim/src/views/record/panels/refresh-after-update-related.js   Download  
File: client/modules/pim/src/views/record/panels/refresh-after-update-related.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: KennerPIM
Product information management application
Author: By
Last change:
Date: 1 year ago
Size: 6,911 bytes
 

Contents

Class file image Download
/* * Pim * Free Extension * Copyright (c) TreoLabs GmbH * Copyright (c) Kenner Soft Service GmbH * * This program 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. * * This program 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 this program. If not, see <https://www.gnu.org/licenses/>. */ Espo.define('pim:views/record/panels/refresh-after-update-related', ['views/record/panels/relationship', 'views/record/panels/bottom', 'search-manager'], (Dep, BottomPanel, SearchManager) => Dep.extend({ setup() { let bottomPanel = new BottomPanel(); bottomPanel.setup.call(this); this.link = this.link || this.defs.link || this.panelName; if (!this.scope && !(this.link in this.model.defs.links)) { throw new Error('Link \'' + this.link + '\' is not defined in model \'' + this.model.name + '\''); } this.title = this.title || this.translate(this.link, 'links', this.model.name); this.scope = this.scope || this.model.defs.links[this.link].entity; if (!this.getConfig().get('scopeColorsDisabled')) { var iconHtml = this.getHelper().getScopeColorIconHtml(this.scope); if (iconHtml) { if (this.defs.label) { this.titleHtml = iconHtml + this.translate(this.defs.label, 'labels', this.scope); } else { this.titleHtml = iconHtml + this.title; } } } var url = this.url || this.model.name + '/' + this.model.id + '/' + this.link; if (!this.readOnly && !this.defs.readOnly) { if (!('create' in this.defs)) { this.defs.create = true; } if (!('select' in this.defs)) { this.defs.select = true; } } this.filterList = this.defs.filterList || this.filterList || null; if (this.filterList && this.filterList.length) { this.filter = this.getStoredFilter(); } if (this.defs.create) { if (this.getAcl().check(this.scope, 'create') && !~['User', 'Team'].indexOf()) { this.buttonList.push({ title: 'Create', action: this.defs.createAction || 'createRelated', link: this.link, acl: 'create', aclScope: this.scope, html: '<span class="fas fa-plus"></span>', data: { link: this.link, } }); } } if (this.defs.select) { var data = {link: this.link}; if (this.defs.selectPrimaryFilterName) { data.primaryFilterName = this.defs.selectPrimaryFilterName; } if (this.defs.selectBoolFilterList) { data.boolFilterList = this.defs.selectBoolFilterList; } this.actionList.unshift({ label: 'Select', action: this.defs.selectAction || 'selectRelated', data: data }); } var layoutName = 'listSmall'; var listLayout = null; var layout = this.defs.layout || null; if (layout) { if (typeof layout == 'string') { layoutName = layout; } else { layoutName = 'listRelationshipCustom'; listLayout = layout; } } var sortBy = this.defs.sortBy || null; var asc = this.defs.asc || null; this.wait(true); this.getCollectionFactory().create(this.scope, function (collection) { collection.maxSize = this.getConfig().get('recordsPerPageSmall') || 5; if (this.defs.filters) { var searchManager = new SearchManager(collection, 'listRelationship', false, this.getDateTime()); searchManager.setAdvanced(this.defs.filters); collection.where = searchManager.getWhere(); } collection.url = collection.urlRoot = url; if (sortBy) { collection.sortBy = sortBy; } if (asc) { collection.asc = asc; } this.collection = collection; this.setFilter(this.filter); if (this.fetchOnModelAfterRelate) { this.listenTo(this.model, 'after:relate', function () { collection.fetch(); }, this); } var viewName = this.defs.recordListView || this.getMetadata().get('clientDefs.' + this.scope + '.recordViews.list') || 'Record.List'; this.once('after:render', function () { this.createView('list', viewName, { collection: collection, layoutName: layoutName, listLayout: listLayout, checkboxes: false, rowActionsView: this.defs.readOnly ? false : (this.defs.rowActionsView || this.rowActionsView), buttonsDisabled: true, el: this.options.el + ' .list-container', skipBuildRows: true }, function (view) { view.getSelectAttributeList(function (selectAttributeList) { if (selectAttributeList) { collection.data.select = selectAttributeList.join(','); } collection.fetch(); }.bind(this)); this.listenTo(view, 'after:save', function (model) { view.reRender(); this.model.trigger('after:updateRelated'); }, this); }); }, this); this.wait(false); }, this); this.setupFilterActions(); }, }) );