Skip to content
This repository has been archived by the owner on Nov 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #78 from treolabs/t-75543
Browse files Browse the repository at this point in the history
75543
  • Loading branch information
rratsun authored Jun 7, 2019
2 parents d257e2a + 4c1a6f9 commit 2057cb3
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
"Manage Folders": "Ordner verwalten",
"New notifications": "Neue Benachrichtigungen",
"Return to Application": "Zurück zur Anwendung",
"you": "sie"
"you": "sie",
"No Group": "Keine Gruppe",
"Defined Attributes": "Definierte Attribute"
},
"dashlets": {
"GeneralStatistics": "Allgemeine Statistiken",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@
},
"labels": {
"Add Field": "Add Filter",
"removeExplain": "Select this to unlink attribute from other Entities before removing"
"removeExplain": "Select this to unlink attribute from other Entities before removing",
"No Group": "No Group",
"Defined Attributes": "Defined Attributes"
},
"dashlets": {
"GeneralStatistics": "General Statistics",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
"disabledMassActions": [
"merge"
],
"modalViews": {
"detail": "pim:views/product-attribute-value/modals/detail",
"edit": "pim:views/product-attribute-value/modals/edit"
},
"recordViews": {
"detail": "pim:views/product-attribute-value/record/detail",
"edit": "pim:views/product-attribute-value/record/edit",
"detailSmall": "pim:views/product-attribute-value/record/detail-small",
"editSmall": "pim:views/product-attribute-value/record/edit-small",
"list": "pim:views/record/list"
"list": "pim:views/product-attribute-value/record/list"
},
"dynamicLogic": {
"fields": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Pim
* Free Extension
* Copyright (c) TreoLabs 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/product-attribute-value/modals/detail', 'views/modals/detail',
Dep => Dep.extend({

fullFormDisabled: true

})
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Pim
* Free Extension
* Copyright (c) TreoLabs 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/product-attribute-value/modals/edit', 'views/modals/edit',
Dep => Dep.extend({

fullFormDisabled: true

})
);
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ Espo.define('pim:views/product-attribute-value/record/detail', 'views/record/det
},

updateModelDefs() {
this.model.defs.fields.scope.readOnly = this.model.defs.fields.attribute.readOnly =
this.model.defs.fields.channels.readOnly = !this.model.get('isCustom');
['attribute', 'channels', 'product', 'scope'].forEach(field => this.model.defs.fields[field].readOnly = !this.model.get('isCustom'));
if (this.model.get('attributeId')) {
let type = this.model.get('attributeType');
let typeValue = this.model.get('typeValue');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Pim
* Free Extension
* Copyright (c) TreoLabs 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/product-attribute-value/record/list', 'views/record/list',
Dep => Dep.extend({

massActionsDisabled: true,

rowActionsView: 'views/record/row-actions/empty'

})
);

110 changes: 1 addition & 109 deletions client/modules/pim/src/views/product/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,115 +32,7 @@ Espo.define('pim:views/product/detail', 'pim:views/detail',
return this.model.id;
},
},
},

actionSelectAttribute(data) {
let link = data.link;
let scope = data.scope || this.model.defs['links'][link].entity;
let afterSelectCallback = data.afterSelectCallback;
let boolFilterListCallback = data.boolFilterListCallback;
let boolFilterDataCallback = data.boolFilterDataCallback;
let panelView = this.getPanelView(link);

if (!this.model.defs['links'][link]) {
throw new Error('Link ' + link + ' does not exist.');
}
let foreign = this.model.defs['links'][link].foreign;

let massRelateEnabled = false;
if (foreign) {
let foreignType = this.getMetadata().get('entityDefs.' + scope + '.links.' + foreign + '.type');
if (foreignType == 'hasMany') {
massRelateEnabled = true;
}
}

let filters = Espo.Utils.cloneDeep(this.selectRelatedFilters[link]) || {};
for (let filterName in filters) {
if (typeof filters[filterName] == 'function') {
let filtersData = filters[filterName].call(this);
if (filtersData) {
filters[filterName] = filtersData;
} else {
delete filters[filterName];
}
}
}

let primaryFilterName = data.primaryFilterName || this.selectPrimaryFilterNames[link] || null;
if (typeof primaryFilterName == 'function') {
primaryFilterName = primaryFilterName.call(this);
}

let boolFilterList = data.boolFilterList || Espo.Utils.cloneDeep(this.selectBoolFilterLists[link] || []);
if (typeof boolFilterList == 'function') {
boolFilterList = boolFilterList.call(this);
}

if (boolFilterListCallback && panelView && typeof panelView[boolFilterListCallback] === 'function') {
boolFilterList = panelView[boolFilterListCallback]();
}

let boolfilterData = [];
if (boolFilterDataCallback && panelView && typeof panelView[boolFilterDataCallback] === 'function') {
boolfilterData = panelView[boolFilterDataCallback](boolFilterList);
}

let viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.select') || 'views/modals/select-records';

this.notify('Loading...');
this.createView('dialog', viewName, {
scope: scope,
multiple: true,
createButton: false,
listLayout: data.listLayout,
filters: filters,
massRelateEnabled: massRelateEnabled,
primaryFilterName: primaryFilterName,
boolFilterList: boolFilterList,
boolFilterData: boolfilterData
}, dialog => {
dialog.render();
this.notify(false);
dialog.once('select', selectObj => {
if (afterSelectCallback && panelView && typeof panelView[afterSelectCallback] === 'function') {
panelView[afterSelectCallback](selectObj);
} else {
let data = {};
if (Object.prototype.toString.call(selectObj) === '[object Array]') {
let ids = [];
selectObj.forEach(function (model) {
ids.push(model.id);
});
data.ids = ids;
} else {
if (selectObj.massRelate) {
data.massRelate = true;
data.where = selectObj.where;
} else {
data.id = selectObj.id;
}
}
$.ajax({
url: this.scope + '/' + this.model.id + '/' + link,
type: 'POST',
data: JSON.stringify(data),
success: function () {
this.notify('Linked', 'success');
this.updateRelationshipPanel(link);
this.model.trigger('after:relate', link);
this.afterSelectAttributeCallback(data);
}.bind(this),
error: function () {
this.notify('Error occurred', 'error');
}.bind(this)
});
}
});
});
},

afterSelectAttributeCallback(data) {}
}

})
);
Expand Down
Loading

0 comments on commit 2057cb3

Please sign in to comment.