/
gdprPanel.js
159 lines (122 loc) · 4.34 KB
/
gdprPanel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/
pimcore.registerNS("pimcore.settings.gdpr.gdprPanel");
pimcore.settings.gdpr.gdprPanel = Class.create({
initialize: function () {
this.getPanel();
},
getPanel: function () {
var tabPanel = Ext.getCmp("pimcore_panel_tabs");
if(!this.panel) {
this.panel = new Ext.Panel({
title: t("gdpr_data_extractor"),
layout: "border",
iconCls: "pimcore_icon_gdpr",
closable: true,
items: [
this.getSearchPanel(),
this.getTabPanel()
]
});
tabPanel.add(this.panel);
}
tabPanel.setActiveTab(this.panel);
return this.panel;
},
getSearchPanel: function() {
this.formPanel = Ext.create('Ext.form.Panel', {
region: "north",
bodyStyle: "padding: 10px;",
items: [
{
xtype: 'textfield',
name: 'id',
fieldLabel: t("gdpr_data_extractor_label_id"),
width: 650
},
{
xtype: 'textfield',
name: 'firstname',
fieldLabel: t("gdpr_data_extractor_label_firstname"),
width: 650
},
{
xtype: 'textfield',
name: 'lastname',
fieldLabel: t("gdpr_data_extractor_label_lastname"),
width: 650
},
{
xtype: 'fieldcontainer',
layout: 'hbox',
items: [
{
xtype: 'textfield',
name: 'email',
fieldLabel: t("gdpr_data_extractor_label_email"),
width: 650,
validator: function (value) {
if(value !== value.replace(/[^a-zA-Z0-9_\-@.]/g,'')){
this.setValue(value.replace(/[^a-zA-Z0-9_\-@.]/g,''));
}
return true;
}
},
{
xtype: "button",
text: t("search"),
iconCls: "pimcore_icon_search",
style: "margin-left: 20px;",
handler: this.search.bind(this)
}
]
}
]
});
return this.formPanel;
},
search: function() {
var searchParams = this.formPanel.getForm().getFieldValues();
Ext.Ajax.request({
url: Routing.generate('pimcore_admin_gdpr_admin_getdataproviders'),
success: function (response) {
this.tabPanel.removeAll();
var res = Ext.decode(response.responseText);
for(var i = 0; i < res.length; i++) {
var definition = res[i];
var constructor = this.stringToFunction(definition.jsClass);
var panel = new constructor(searchParams);
this.tabPanel.add(panel.getPanel());
}
this.tabPanel.setActiveTab(0);
}.bind(this)
});
},
stringToFunction: function(str) {
var arr = str.split(".");
var fn = (window || this);
for (var i = 0, len = arr.length; i < len; i++) {
fn = fn[arr[i]];
}
if (typeof fn !== "function") {
throw new Error("function not found");
}
return fn;
},
getTabPanel: function() {
this.tabPanel = Ext.create('Ext.tab.Panel', {
region: 'center'
});
return this.tabPanel;
}
});