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

Adding fallback for forms component #2568

Merged
merged 8 commits into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* which allows selection of panel container items for editing, as well as other operations such as reordering of panels.
* @param {PanelSelectorConfig} config The Panel Selector configuration object
*/
var PanelSelector = ns.util.createClass({
window.CQ.CoreComponents.PanelSelector = ns.util.createClass({

/**
* The Panel Selector configuration Object
Expand Down Expand Up @@ -178,7 +178,7 @@
items.push({
id: child.path,
name: child.name,
title: getTitle(child, panelContainerItems[child.name], index + 1)
title: that.getTitle(child, panelContainerItems[child.name], index + 1)
});
});

Expand Down Expand Up @@ -379,6 +379,37 @@
that._unbindEvents();
that._elements.popover.parentNode.removeChild(that._elements.popover);
}
},

/**
* Retrieves a title from item data. If no item data exists, or it doesn't have a title
* instead lookup the editable display name of the corresponding [Editable]{@link Granite.author.Editable}.
* Prefixes each title with an index.
*
* @param {Granite.author.Editable} editable The [Editable]{@link Granite.author.Editable} representing the item
* @param {Object} item The item data
* @param {Number} index Index of the item
* @returns {String} The title
*/
getTitle: function(editable, item, index) {
var title = "<span class='foundation-layout-util-subtletext cmp-panelselector__indexMarker'>" + index + "</span>&nbsp;&nbsp;";
var subTitle = "";

title = title + " " + Granite.I18n.getVar(ns.editableHelper.getEditableDisplayableName(editable));

if (item) {
if (item[PN_PANEL_TITLE]) {
subTitle = item[PN_PANEL_TITLE];
} else if (item.title) {
subTitle = item.title;
}
}

if (subTitle) {
title = title + ": <span class='foundation-layout-util-subtletext'>" + subTitle + "</span>";
}

return title;
}
});

Expand All @@ -393,7 +424,7 @@
order: "before COPY",
execute: function(editable, param, target) {
if (!panelSelector || !panelSelector.isOpen()) {
panelSelector = new PanelSelector({
panelSelector = new window.CQ.CoreComponents.PanelSelector({
"editable": editable,
"target": target[0]
});
Expand Down Expand Up @@ -423,35 +454,4 @@
}
});

/**
* Retrieves a title from item data. If no item data exists, or it doesn't have a title
* instead lookup the editable display name of the corresponding [Editable]{@link Granite.author.Editable}.
* Prefixes each title with an index.
*
* @param {Granite.author.Editable} editable The [Editable]{@link Granite.author.Editable} representing the item
* @param {Object} item The item data
* @param {Number} index Index of the item
* @returns {String} The title
*/
function getTitle(editable, item, index) {
var title = "<span class='foundation-layout-util-subtletext cmp-panelselector__indexMarker'>" + index + "</span>&nbsp;&nbsp;";
var subTitle = "";

title = title + " " + Granite.I18n.getVar(ns.editableHelper.getEditableDisplayableName(editable));

if (item) {
if (item[PN_PANEL_TITLE]) {
subTitle = item[PN_PANEL_TITLE];
} else if (item.title) {
subTitle = item.title;
}
}

if (subTitle) {
title = title + ": <span class='foundation-layout-util-subtletext'>" + subTitle + "</span>";
}

return title;
}

}(jQuery, Granite.author, jQuery(document), this));
Loading