Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy Reference + Tooltip for Elements Menu #14942

Open
MrJimWest opened this issue Jan 1, 2020 · 2 comments
Open

Copy Reference + Tooltip for Elements Menu #14942

MrJimWest opened this issue Jan 1, 2020 · 2 comments
Labels
feature Request about implementing a brand new function or possibility. type-frontend Issues related to UI/UX issues, mostly about styles and frontend implementations on JavaScript.

Comments

@MrJimWest
Copy link

Feature request

Summary

Add "copy reference" functionality to right-click menu of left toolbar. In addition, adding hint/tooltip on hover to those items, similar to how TVs are treated whilst editing a page.

Why is it needed?

This will make it easier to keep the references straight, and allow for easy copying/pasting of element references.

Suggested solution(s)

Tooltip Example:
23fdbbebed2b02ae2ff9828dad4152603b2381d0

Right-Click Example:
5b3cdac46440b903bdec68c102ab1795a1d95c4a

As talked about here: https://community.modx.com/t/title-attribute-to-element-categories/2073

@JoshuaLuckers JoshuaLuckers added type-frontend Issues related to UI/UX issues, mostly about styles and frontend implementations on JavaScript. feature Request about implementing a brand new function or possibility. labels Jan 1, 2020
@Jako
Copy link
Collaborator

Jako commented Jan 2, 2020

I like the context menu enhancement, but the tooltip is a bit superfluous.

Did you know that you could drag&drop a snippet/chunk to a textarea i.e. introtext? That way the snippet properties could be prefilled in a popup on base of the default property set.

@JoshuaLuckers
Copy link
Contributor

For anyone interested how the drag and drop functionality works:

,notifyDrop: function(ddSource, e, data) {
if (!data.node || !data.node.attributes || !data.node.attributes.type) return false;
if (data.node.attributes.type != 'MODX\\Revolution\\modResource' && data.node.attributes.leaf != true) return false;
var v = '';
var win = false;
switch (data.node.attributes.type) {
case 'MODX\\Revolution\\modResource': v = '[[~'+data.node.attributes.pk+']]'; break;
case 'snippet': win = true; break;
case 'chunk': win = true; break;
case 'tv': win = true; break;
case 'file': v = data.node.attributes.url; break;
default:
var dh = Ext.getCmp(data.node.attributes.type+'-drop-handler');
if (dh) {
return dh.handle(data,{
ddTargetEl: ddTargetEl
,cfg: cfg
,iframe: cfg.iframe
,iframeEl: cfg.iframeEl
,onInsert: cfg.onInsert
,panel: cfg.panel
});
}
return false;
break;
}
if (win) {
MODx.loadInsertElement({
pk: data.node.attributes.pk
,classKey: data.node.attributes.classKey
,name: data.node.attributes.name
,output: v
,ddTargetEl: ddTargetEl
,cfg: cfg
,iframe: cfg.iframe
,iframeEl: cfg.iframeEl
,onInsert: cfg.onInsert
,panel: cfg.panel
});
} else {
if (cfg.iframe) {
MODx.insertForRTE(v,cfg);
} else {
var el = Ext.get(ddTargetEl);
if (el.dom.id == 'modx-static-content') {
v = v.substring(1);
Ext.getCmp(el.dom.id).setValue('');
}
if (el.dom.id == 'modx-symlink-content' || el.dom.id == 'modx-weblink-content') {
Ext.getCmp(el.dom.id).setValue('');
if(typeof data.node.attributes.pk !== undefined && data.node.attributes.pk !== undefined){
MODx.insertAtCursor(ddTargetEl,data.node.attributes.pk,cfg.onInsert);
}else{
MODx.insertAtCursor(ddTargetEl,v,cfg.onInsert);
}
} else if (el.dom.id == 'modx-resource-parent') {
v = data.node.attributes.pk;
var pf = Ext.getCmp('modx-resource-parent');
if (v == pf.currentid) {
MODx.msg.alert('',_('resource_err_own_parent'));
return false;
}
pf.setValue(v);
Ext.getCmp(pf.parentcmp).setValue(v);
var p = Ext.getCmp(pf.formpanel);
if (p) { p.markDirty(); }
} else {
MODx.insertAtCursor(ddTargetEl,v,cfg.onInsert);
}
if (cfg.panel) {
var p = Ext.getCmp(cfg.panel);
if (p) { p.markDirty(); }
}
}
}
return true;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Request about implementing a brand new function or possibility. type-frontend Issues related to UI/UX issues, mostly about styles and frontend implementations on JavaScript.
Projects
None yet
Development

No branches or pull requests

3 participants