Skip to content

Instantly share code, notes, and snippets.

@gregwiechec
Created September 18, 2015 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregwiechec/bf0fc8bccde4aa575309 to your computer and use it in GitHub Desktop.
Save gregwiechec/bf0fc8bccde4aa575309 to your computer and use it in GitHub Desktop.
Allow to disable preview options on specific ContentAreas
define([
"dojo/_base/declare",
"dojo/_base/lang",
"epi-cms/contentediting/command/BlockRemove",
"epi-cms/contentediting/command/BlockEdit",
"epi-cms/contentediting/command/MoveToPrevious",
"epi-cms/contentediting/command/MoveToNext",
"epi-cms/contentediting/command/MoveOutsideGroup",
"epi-cms/contentediting/command/Personalize",
"epi-cms/contentediting/command/SelectDisplayOption",
"epi-cms/contentediting/editors/ContentAreaEditor"
],
function(
declare,
lang,
RemoveCommand,
EditCommand,
MoveToPrevious,
MoveToNext,
MoveOutsideGroup,
Personalize,
SelectDisplayOption,
_ContentAreaEditor
) {
return declare("alloy.editors.contentAreaWithNoOptions", [_ContentAreaEditor], {
postMixInProperties: function () {
this._commands = [
new EditCommand(),
// new SelectDisplayOption(),
new Personalize({ category: null }),
new MoveOutsideGroup(),
new MoveToPrevious(),
new MoveToNext(),
new RemoveCommand()
];
this.inherited(arguments);
}
});
});
define( [
// General application modules
"dojo/_base/declare",
"dojo/_base/event",
"dojo/_base/lang",
"epi-cms/widget/overlay/Block",
"epi-cms/contentediting/command/ContentAreaCommands"
], function (
// General application modules
declare,
event,
lang,
Block,
ContentAreaCommands
) {
return declare([Block], {
postCreate: function () {
var contentAreaCommands = new ContentAreaCommands({ model: this.viewModel });
contentAreaCommands.commands.splice(1, 1); // remove Display options menu
this.commandProvider = contentAreaCommands;
this.inherited(arguments);
}
});
});
define( [
// Dojo
"dojo/_base/array",
"dojo/_base/declare",
"dojo/_base/lang",
"./contentAreaWithNoOptionsBlock",
"epi-cms/widget/overlay/ContentArea"
], function (
// Dojo
array,
declare,
lang,
CustomBlock,
ContentArea
) {
return declare([ContentArea], {
blockClass: CustomBlock
});
});
[EditorDescriptorRegistration(TargetType = typeof(ContentArea), UIHint = UIHint)]
public class NoPreviewContentAreaEditorDescriptor : EditorDescriptor
{
public const string UIHint = "NoPreviewContentArea";
public NoPreviewContentAreaEditorDescriptor()
{
this.ClientEditingClass = "alloy.editors.contentAreaWithNoOptions";
}
public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
base.ModifyMetadata(metadata, attributes);
metadata.OverlayConfiguration["customType"] = "alloy.editors.contentAreaWithNoOptionsOverlay";
}
}
public class ProductPage : StandardPage
{
[Display(
GroupName = SystemTabNames.Content,
Order = 330)]
[CultureSpecific]
[AllowedTypes(new[] { typeof(IContentData) }, new[] { typeof(JumbotronBlock) })]
[UIHint(NoPreviewContentAreaEditorDescriptor.UIHint)]
public virtual ContentArea RelatedContentArea { get; set; }
//
// other properties
//
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment