Skip to content

Commit

Permalink
Move personalization to own bundle (pimcore#14102)
Browse files Browse the repository at this point in the history
* Moved js files and controller to the personalization bundle

* Moved translations,tests,lib files,configurations etc to own bundle

* Update Doc

* Add updated namespace in yaml config

* Minor fixes

* Moved some more files and fixed some errors

* Remove TargetingOverrideHandlersPass from core

* Error fixes and added event for document settings tab

* More fixes

* Update Documentation

* Update doc and add migration to remove user permissions

* Moved model files, fixed error with clearing editables, moved the dataobject configuration of target group to bundle

* Minor fixes

* More refactoring

* More fixes

* Fix Php stan

* Fix PHP stan

* Removed the dependency injection and implementd it using event listener in DocumentRenderer.php

* Typo fixes

* Added pre render event listener and removed the leftover targeting section from standard document page in the core

* Add condition getUseTargetGroup() method in snipper

* Added alias to model used by portal engine

* Add if condition for target group value

* Change namespace in ecommerce framework and update translations

* DocumentTargetingConfigurator usages refactoring

* Move DebugStopwatchPass to the bundle

* Refactor geoip pimcore setting

* Add class aliases for the data types

* Delete listeners.yaml

* Fix EventListener

* Refactor Newsletter Address DefaultAdapter to extract target groups

* Fix Snippet & IncludeRenderer

* Further refactoring

* futher refactoring

* Revert configs

* Refactor ecommerce target group condition

* Refactor ecommerce target group condition

* Refactor TargetGroup data types to use legacy namespaces for BC reasons

* Action files cleanup

* further refactorings

* further refactorings & cleanup

* Further Refactoring - Move Renderlet configure targeting to event listener

* Use generic event for Document Page settings

* Further Refactorings

* Fix codeception test

* Fix PHP stan

* Remove user permission (targeting) from core bundle and add warning on bundle uninstall

* Fix IncludeRenderer pre render even dispatch

* Fix Renderlet pre render event arguments

* Add ignore paths for passing phpstan

* Revert DocumentTargetGroupListener return typehint

* Fix PimcoreTargetingDataCollector return typehints

* Add migration to mark bundle as installed

* Further refactoring & fixes

* Add requirement to EcommerceBundle

* Modified migration to mark the bundle as installed

* Add missing targetGroup.js

* Remove comment in console

* Re-add geoip2/geoip2 temporarily

* Add TargetingSnippetController

* Optimize uninstall warning

* catch targeting configured check

* Docs changes

---------

Co-authored-by: Divesh Pahuja <[email protected]>
  • Loading branch information
aryaantony92 and dvesh3 authored Feb 17, 2023
1 parent c4d6cf4 commit d505e46
Show file tree
Hide file tree
Showing 261 changed files with 4,526 additions and 1,576 deletions.
26 changes: 0 additions & 26 deletions bundles/AdminBundle/public/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -869,32 +869,6 @@ span.warning {
background: url(/bundles/pimcoreadmin/img/flat-color-icons/high_priority.svg) 2px 2px/16px no-repeat #ffdbdb;
}

.pimcore_targeting_bracket {
position: absolute;
top: 64px;
cursor: pointer;

color: #CCCCCC;
font-family: sans-serif;
font-size: 50px;
}

.pimcore_targeting_bracket:hover {
color: #B4B4B4;
}

.pimcore_targeting_bracket_active {
color: #000 !important;
}

.pimcore_targeting_bracket_left {
left: 5px;
}

.pimcore_targeting_bracket_right {
right: 5px;
}

#pimcore_tree_preview {
position:fixed;
top:0;
Expand Down
28 changes: 0 additions & 28 deletions bundles/AdminBundle/public/css/icons.css
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,6 @@
background: url(/bundles/pimcoreadmin/img/flat-white-icons/targetgroup.svg) center center no-repeat !important;
}

.pimcore_nav_icon_targeting {
background: url(/bundles/pimcoreadmin/img/flat-white-icons/person.svg) center center no-repeat !important;
}

.pimcore_nav_icon_target_groups {
background: url(/bundles/pimcoreadmin/img/flat-white-icons/targetgroup.svg) center center no-repeat !important;
}

.pimcore_nav_icon_targeting_toolbar {
background: url(/bundles/pimcoreadmin/img/flat-white-icons/ok.svg) center center no-repeat !important;
}

.pimcore_nav_icon_marketing_settings {
background: url(/bundles/pimcoreadmin/img/flat-white-icons/settings.svg) center center no-repeat !important;
}
Expand Down Expand Up @@ -794,10 +782,6 @@
background: url(/bundles/pimcoreadmin/img/flat-color-icons/settings.svg) center center no-repeat !important;
}

.pimcore_icon_targeting {
background: url(/bundles/pimcoreadmin/img/flat-color-icons/person.svg) center center no-repeat !important;
}

.pimcore_icon_versions {
background: url(/bundles/pimcoreadmin/img/flat-color-icons/org_unit.svg) center center no-repeat !important;
}
Expand Down Expand Up @@ -978,18 +962,6 @@
background: url(/bundles/pimcoreadmin/img/flat-color-icons/stop-circle.svg) center center no-repeat !important;
}

.pimcore_icon_targeting_toolbar_enable {
background: url(/bundles/pimcoreadmin/img/flat-color-icons/ok.svg) center center no-repeat !important;
}

.pimcore_icon_targeting_toolbar_disable {
background: url(/bundles/pimcoreadmin/img/flat-color-icons/stop-circle.svg) center center no-repeat !important;
}

.pimcore_icon_targeting_toolbar {
background: url(/bundles/pimcoreadmin/img/flat-color-icons/list.svg) center center no-repeat !important;
}

.pimcore_icon_info {
background: url(/bundles/pimcoreadmin/img/flat-color-icons/info.svg) center center no-repeat !important;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pimcore.document.document_language_overview = Class.create({
parameters.id = id;

Ext.Ajax.request({
url: '/admin/' + type + '/save?task=' + task,
url: Routing.generate('pimcore_admin_document_' + type + '_save', {task: task}),
method: "PUT",
params: parameters,
success: function (task, response) {
Expand Down
97 changes: 7 additions & 90 deletions bundles/AdminBundle/public/js/pimcore/document/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ pimcore.document.edit = Class.create({
link += "&unminified_js";
}

if(this.targetGroup && this.targetGroup.getValue()) {
link += "&_ptg=" + this.targetGroup.getValue();
if (pimcore.bundle.personalization) {
if (this.areaToolBar && this.areaToolBar.targetGroup && this.areaToolBar.targetGroup.getValue()) {
link += "&_ptg=" + this.areaToolBar.targetGroup.getValue();
}
}

return link;
Expand All @@ -53,7 +55,6 @@ pimcore.document.edit = Class.create({
url: Routing.generate('pimcore_admin_document_page_cleareditabledata'),
method: "PUT",
params: {
targetGroup: this["targetGroup"] ? this.targetGroup.getValue() : "",
id: this.document.id
},
success: function () {
Expand Down Expand Up @@ -100,7 +101,9 @@ pimcore.document.edit = Class.create({
handler: cleanupFunction.bind(this)
}];

this.addTargetingPanel(lbar, cleanupFunction);
if (pimcore.bundle.personalization) {
this.areaToolBar = new pimcore.bundle.personalization.document.areatoolbar(this.document, lbar);
}

// edit panel configuration
var config = {
Expand Down Expand Up @@ -189,91 +192,6 @@ pimcore.document.edit = Class.create({
this.highlightTagButton.toggle(this.tagHighlightingActive);
},

addTargetingPanel: function(lbar, cleanupFunction) {
if (!Ext.Array.contains(['page', 'snippet'], this.document.getType())) {
return;
}

if (pimcore.globalmanager.get("target_group_store").getCount() === 0) {
return;
}

this.targetGroupText = Ext.create('Ext.toolbar.TextItem', {
scale: "medium",
style: "-webkit-transform: rotate(270deg); -moz-transform: rotate(270deg); -o-transform: rotate(270deg); writing-mode: lr-tb;"
});

this.targetGroupStore = Ext.create('Ext.data.JsonStore', {
proxy: {
type: 'ajax',
url: Routing.generate('pimcore_admin_targeting_targetgrouplist', {'add-default': true})
},
fields: ["id", "text"],
listeners: {
load: function() {
this.updateTargetGroupText(this.targetGroup.getValue());
}.bind(this)
}
});

// add target group selection to toolbar
this.targetGroup = new Ext.form.ComboBox({
displayField:'text',
valueField: "id",
store: this.targetGroupStore,
editable: false,
triggerAction: 'all',
width: 240,
listeners: {
select: function (el) {
if(this.document.isDirty()) {
Ext.Msg.confirm(t('warning'), t('you_have_unsaved_changes')
+ "<br />" + t("continue") + "?",
function(btn){
if (btn === 'yes'){
this.reload(true);
this.updateTargetGroupText(this.targetGroup.getValue());
}
}.bind(this)
);
} else {
this.reload(true);
this.updateTargetGroupText(this.targetGroup.getValue());
}
}.bind(this)
}
});

this.targetGroupStore.load();

lbar.push("->",
this.targetGroupText,
{
tooltip: t("edit_content_for_target_group"),
iconCls: "pimcore_icon_target_groups",
arrowVisible: false,
menuAlign: "tl",
menu: [this.targetGroup]
},
{
tooltip: t("clear_content_of_selected_target_group"),
iconCls: "pimcore_icon_cleanup",
handler: cleanupFunction.bind(this)
}
);
},

updateTargetGroupText: function(targetgroup) {
var record = this.targetGroupStore.getById(targetgroup);

if(record) {
this.targetGroupText.update('&nbsp;&nbsp;<img src="/bundles/pimcoreadmin/img/flat-color-icons/manager.svg" style="height: 16px;" align="absbottom" />&nbsp;&nbsp;'
+ record.data.text);
} else {
this.targetGroupText.update('');
}
},

setLayoutFrameDimensions: function (el, width, height, rWidth, rHeight) {
Ext.get(this.iframeName).setStyle({
height: (height-7) + "px"
Expand Down Expand Up @@ -305,7 +223,6 @@ pimcore.document.edit = Class.create({
},

reload: function (disableSaveToSession) {

this.areaToolbarTrigger.toggle(false);

if (this.reloadInProgress) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pimcore.document.newsletters.addressSourceAdapters.default = Class.create({
},{
fieldLabel: t('assign_target_group'),
xtype: "multiselect",
hidden: pimcore.globalmanager.get("target_group_store").getCount() < 1,
hidden: !pimcore.globalmanager.get("target_group_store"),
store: pimcore.globalmanager.get("target_group_store"),
displayField: "text",
valueField: "id",
Expand Down
42 changes: 15 additions & 27 deletions bundles/AdminBundle/public/js/pimcore/document/pages/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ pimcore.document.pages.settings = Class.create(pimcore.document.settings_abstrac
var serpAbsoluteUrl = this.document.data.url;

// create layout

this.layout = new Ext.FormPanel({
title: t('SEO') + ' &amp; ' + t('settings'),
border: false,
Expand Down Expand Up @@ -245,39 +244,28 @@ pimcore.document.pages.settings = Class.create(pimcore.document.settings_abstrac
}
}
]
}, {
xtype:'fieldset',
title: t('assign_target_groups'),
collapsible: true,
autoHeight:true,
defaults: {
labelWidth: 300
},
defaultType: 'textfield',
items :[
Ext.create('Ext.ux.form.MultiSelect', {
fieldLabel: t('visitors_of_this_page_will_be_automatically_associated_with_the_selected_target_groups'),
store: pimcore.globalmanager.get("target_group_store"),
displayField: "text",
valueField: "id",
name: 'targetGroupIds',
width: 700,
//listWidth: 200,
value: this.document.data["targetGroupIds"].split(',').map(Number).filter(item => item),
minHeight: 100
})
]
},
this.getControllerViewFields(true),
this.getStaticGeneratorFields(true),
this.getPathAndKeyFields(true),
this.getContentMasterFields(true)
]
});

// To add additional block to settings
const additionalSettings = new CustomEvent(pimcore.events.prepareDocumentPageSettingsLayout, {
detail: {
layout: this.layout,
document: this.document
}
});
document.dispatchEvent(additionalSettings);

this.layout.add(this.getControllerViewFields(true));
this.layout.add(this.getStaticGeneratorFields(true));
this.layout.add(this.getPathAndKeyFields(true));
this.layout.add(this.getContentMasterFields(true));
}

return this.layout;
}



});
2 changes: 1 addition & 1 deletion bundles/AdminBundle/public/js/pimcore/document/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ pimcore.document.tree = Class.create({
parameters.id = id;

Ext.Ajax.request({
url: '/admin/' + type + '/save?task=' + task,
url: Routing.generate('pimcore_admin_document_' + type + '_save', {task: task}),
method: "PUT",
params: parameters,
success: function (task, response) {
Expand Down
6 changes: 6 additions & 0 deletions bundles/AdminBundle/public/js/pimcore/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,9 @@
*/
pimcore.events.preMenuBuild = "pimcore.menu.preBuild";

/**
* after settings tab of page is opened
* layout and document are passed as parameter
*/
pimcore.events.prepareDocumentPageSettingsLayout = "pimcore.documentPageSettingsLayout.prepare";

Loading

0 comments on commit d505e46

Please sign in to comment.