|
1 | | -pimcore.registerNS("pimcore.plugin.datadefinitions.export.context_menu"); |
2 | | - |
3 | | -pimcore.plugin.datadefinitions.export.context_menu = Class.create(pimcore.plugin.admin, { |
4 | | - getClassName: function () { |
5 | | - return "pimcore.plugin.datadefinitions.export.context_menu"; |
6 | | - }, |
7 | | - |
8 | | - initialize: function () { |
9 | | - pimcore.plugin.broker.registerPlugin(this); |
10 | | - }, |
| 1 | +document.addEventListener(pimcore.events.prepareObjectTreeContextMenu, function (event) { |
| 2 | + if (!Ext.ClassManager.get('Executable')) { |
| 3 | + Ext.define('Executable', { |
| 4 | + extend: 'Ext.data.Model', |
| 5 | + fields: [ |
| 6 | + {name: 'name', type: 'string'}, |
| 7 | + ] |
| 8 | + }); |
| 9 | + } |
11 | 10 |
|
12 | | - prepareObjectTreeContextMenu: function (tree, treeClass, menuItem) { |
13 | | - if (!Ext.ClassManager.get('Executable')) { |
14 | | - Ext.define('Executable', { |
15 | | - extend: 'Ext.data.Model', |
16 | | - fields: [ |
17 | | - {name: 'name', type: 'string'}, |
18 | | - ] |
19 | | - }); |
20 | | - } |
| 11 | + const tree = event.detail.menu; |
21 | 12 |
|
22 | | - var $this = this; |
23 | | - Ext.create('Ext.data.Store', { |
24 | | - model: 'Executable', |
25 | | - proxy: { |
26 | | - type: 'ajax', |
27 | | - url: '/admin/process_manager/executables/list-by-type', |
28 | | - extraParams: { |
29 | | - type: 'exportdefinition' |
30 | | - }, |
31 | | - reader: { |
32 | | - type: 'json', |
33 | | - rootProperty: 'data' |
34 | | - } |
| 13 | + Ext.create('Ext.data.Store', { |
| 14 | + model: 'Executable', |
| 15 | + proxy: { |
| 16 | + type: 'ajax', |
| 17 | + url: '/admin/process_manager/executables/list-by-type', |
| 18 | + extraParams: { |
| 19 | + type: 'exportdefinition' |
35 | 20 | }, |
36 | | - sorters: [{ |
37 | | - property: 'name', |
38 | | - direction: 'ASC' |
39 | | - }], |
40 | | - sortRoot: 'data', |
41 | | - autoLoad: true, |
42 | | - listeners: { |
43 | | - refresh: function (store) { |
44 | | - var exportMenu = []; |
45 | | - store.each(function (executable) { |
46 | | - exportMenu.push({ |
47 | | - text: executable.get('name'), |
48 | | - iconCls: "pimcore_icon_object pimcore_icon_overlay_add", |
49 | | - handler: $this.exportObjects.bind($this, executable, menuItem) |
50 | | - }); |
51 | | - }); |
52 | | - |
53 | | - if (exportMenu) { |
54 | | - tree.add([ |
55 | | - {xtype: 'menuseparator'}, |
56 | | - { |
57 | | - text: t("data_definitions_processmanager_export_from_here"), |
58 | | - iconCls: "pimcore_icon_object pimcore_icon_overlay_download", |
59 | | - menu: exportMenu |
60 | | - } |
61 | | - ]); |
62 | | - } |
63 | | - } |
| 21 | + reader: { |
| 22 | + type: 'json', |
| 23 | + rootProperty: 'data' |
64 | 24 | } |
65 | | - }); |
66 | | - }, |
| 25 | + }, |
| 26 | + sorters: [{ |
| 27 | + property: 'name', |
| 28 | + direction: 'ASC' |
| 29 | + }], |
| 30 | + sortRoot: 'data', |
| 31 | + autoLoad: true, |
| 32 | + listeners: { |
| 33 | + refresh: function (store) { |
| 34 | + var exportMenu = []; |
| 35 | + store.each(function (executable) { |
| 36 | + exportMenu.push({ |
| 37 | + text: executable.get('name'), |
| 38 | + iconCls: "pimcore_icon_object pimcore_icon_overlay_add", |
| 39 | + handler: function (menuItem) { |
| 40 | + Ext.Ajax.request({ |
| 41 | + url: '/admin/process_manager/executables/run', |
| 42 | + params: { |
| 43 | + id: executable.id, |
| 44 | + startupConfig: Ext.encode({ |
| 45 | + root: menuItem.$iid, |
| 46 | + }), |
| 47 | + csrfToken: pimcore.settings['csrfToken'] |
| 48 | + }, |
| 49 | + method: 'POST', |
| 50 | + success: function (result) { |
| 51 | + result = Ext.decode(result.responseText); |
67 | 52 |
|
68 | | - exportObjects: function (executable, menuItem) { |
69 | | - Ext.Ajax.request({ |
70 | | - url: '/admin/process_manager/executables/run', |
71 | | - params: { |
72 | | - id: executable.id, |
73 | | - startupConfig: Ext.encode({ |
74 | | - root: menuItem.get('id'), |
75 | | - }), |
76 | | - csrfToken: pimcore.settings['csrfToken'] |
77 | | - }, |
78 | | - method: 'POST', |
79 | | - success: function (result) { |
80 | | - result = Ext.decode(result.responseText); |
| 53 | + if (result.success) { |
| 54 | + Ext.Msg.alert(t('success'), t('processmanager_executable_started')); |
| 55 | + } else { |
| 56 | + Ext.Msg.alert(t('error'), result.message); |
| 57 | + } |
| 58 | + }.bind(this) |
| 59 | + }); |
| 60 | + } |
| 61 | + }); |
| 62 | + }); |
81 | 63 |
|
82 | | - if (result.success) { |
83 | | - Ext.Msg.alert(t('success'), t('processmanager_executable_started')); |
84 | | - } else { |
85 | | - Ext.Msg.alert(t('error'), result.message); |
| 64 | + if (exportMenu) { |
| 65 | + tree.add([ |
| 66 | + {xtype: 'menuseparator'}, |
| 67 | + { |
| 68 | + text: t("data_definitions_processmanager_export_from_here"), |
| 69 | + iconCls: "pimcore_icon_object pimcore_icon_overlay_download", |
| 70 | + menu: exportMenu |
| 71 | + } |
| 72 | + ]); |
86 | 73 | } |
87 | | - }.bind(this) |
88 | | - }); |
89 | | - } |
| 74 | + } |
| 75 | + } |
| 76 | + }); |
90 | 77 | }); |
91 | | - |
92 | | -new pimcore.plugin.datadefinitions.export.context_menu(); |
0 commit comments