-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update export_contextmenu.js for Pimcore 11
- Loading branch information
Showing
1 changed file
with
69 additions
and
84 deletions.
There are no files selected for viewing
153 changes: 69 additions & 84 deletions
153
src/DataDefinitionsBundle/Resources/public/pimcore/js/process_manager/export_contextmenu.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,77 @@ | ||
pimcore.registerNS("pimcore.plugin.datadefinitions.export.context_menu"); | ||
|
||
pimcore.plugin.datadefinitions.export.context_menu = Class.create(pimcore.plugin.admin, { | ||
getClassName: function () { | ||
return "pimcore.plugin.datadefinitions.export.context_menu"; | ||
}, | ||
|
||
initialize: function () { | ||
pimcore.plugin.broker.registerPlugin(this); | ||
}, | ||
document.addEventListener(pimcore.events.prepareObjectTreeContextMenu, function (event) { | ||
if (!Ext.ClassManager.get('Executable')) { | ||
Ext.define('Executable', { | ||
extend: 'Ext.data.Model', | ||
fields: [ | ||
{name: 'name', type: 'string'}, | ||
] | ||
}); | ||
} | ||
|
||
prepareObjectTreeContextMenu: function (tree, treeClass, menuItem) { | ||
if (!Ext.ClassManager.get('Executable')) { | ||
Ext.define('Executable', { | ||
extend: 'Ext.data.Model', | ||
fields: [ | ||
{name: 'name', type: 'string'}, | ||
] | ||
}); | ||
} | ||
const tree = event.detail.menu; | ||
|
||
var $this = this; | ||
Ext.create('Ext.data.Store', { | ||
model: 'Executable', | ||
proxy: { | ||
type: 'ajax', | ||
url: '/admin/process_manager/executables/list-by-type', | ||
extraParams: { | ||
type: 'exportdefinition' | ||
}, | ||
reader: { | ||
type: 'json', | ||
rootProperty: 'data' | ||
} | ||
Ext.create('Ext.data.Store', { | ||
model: 'Executable', | ||
proxy: { | ||
type: 'ajax', | ||
url: '/admin/process_manager/executables/list-by-type', | ||
extraParams: { | ||
type: 'exportdefinition' | ||
}, | ||
sorters: [{ | ||
property: 'name', | ||
direction: 'ASC' | ||
}], | ||
sortRoot: 'data', | ||
autoLoad: true, | ||
listeners: { | ||
refresh: function (store) { | ||
var exportMenu = []; | ||
store.each(function (executable) { | ||
exportMenu.push({ | ||
text: executable.get('name'), | ||
iconCls: "pimcore_icon_object pimcore_icon_overlay_add", | ||
handler: $this.exportObjects.bind($this, executable, menuItem) | ||
}); | ||
}); | ||
|
||
if (exportMenu) { | ||
tree.add([ | ||
{xtype: 'menuseparator'}, | ||
{ | ||
text: t("data_definitions_processmanager_export_from_here"), | ||
iconCls: "pimcore_icon_object pimcore_icon_overlay_download", | ||
menu: exportMenu | ||
} | ||
]); | ||
} | ||
} | ||
reader: { | ||
type: 'json', | ||
rootProperty: 'data' | ||
} | ||
}); | ||
}, | ||
}, | ||
sorters: [{ | ||
property: 'name', | ||
direction: 'ASC' | ||
}], | ||
sortRoot: 'data', | ||
autoLoad: true, | ||
listeners: { | ||
refresh: function (store) { | ||
var exportMenu = []; | ||
store.each(function (executable) { | ||
exportMenu.push({ | ||
text: executable.get('name'), | ||
iconCls: "pimcore_icon_object pimcore_icon_overlay_add", | ||
handler: function (menuItem) { | ||
Ext.Ajax.request({ | ||
url: '/admin/process_manager/executables/run', | ||
params: { | ||
id: executable.id, | ||
startupConfig: Ext.encode({ | ||
root: menuItem.$iid, | ||
}), | ||
csrfToken: pimcore.settings['csrfToken'] | ||
}, | ||
method: 'POST', | ||
success: function (result) { | ||
result = Ext.decode(result.responseText); | ||
|
||
exportObjects: function (executable, menuItem) { | ||
Ext.Ajax.request({ | ||
url: '/admin/process_manager/executables/run', | ||
params: { | ||
id: executable.id, | ||
startupConfig: Ext.encode({ | ||
root: menuItem.get('id'), | ||
}), | ||
csrfToken: pimcore.settings['csrfToken'] | ||
}, | ||
method: 'POST', | ||
success: function (result) { | ||
result = Ext.decode(result.responseText); | ||
if (result.success) { | ||
Ext.Msg.alert(t('success'), t('processmanager_executable_started')); | ||
} else { | ||
Ext.Msg.alert(t('error'), result.message); | ||
} | ||
}.bind(this) | ||
}); | ||
} | ||
}); | ||
}); | ||
|
||
if (result.success) { | ||
Ext.Msg.alert(t('success'), t('processmanager_executable_started')); | ||
} else { | ||
Ext.Msg.alert(t('error'), result.message); | ||
if (exportMenu) { | ||
tree.add([ | ||
{xtype: 'menuseparator'}, | ||
{ | ||
text: t("data_definitions_processmanager_export_from_here"), | ||
iconCls: "pimcore_icon_object pimcore_icon_overlay_download", | ||
menu: exportMenu | ||
} | ||
]); | ||
} | ||
}.bind(this) | ||
}); | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
new pimcore.plugin.datadefinitions.export.context_menu(); |