Beispiel #1
0
        public override bool UpdateItem(ContentItem parentItem, Control editor)
        {
            ItemEditor itemEditor   = editor as ItemEditor;
            ItemEditor parentEditor = ItemUtility.FindInParents <ItemEditor>(editor.Parent);

            return(itemEditor.UpdateObject(parentEditor.BinderContext.CreateNestedContext(itemEditor, itemEditor.CurrentItem, itemEditor.GetDefinition())));
        }
Beispiel #2
0
        public void NewChild_IsSaved()
        {
            var item       = new DecoratedItem();
            var definition = new DefinitionMap().GetOrCreateDefinition(item);
            var editable   = (EditableItemAttribute)definition.Properties["TheItem"].Editable;

            var page            = new Page();
            var enclosingEditor = new ItemEditor();
            var editor          = AddEditorAndInit(item, editable, page, enclosingEditor);

            editable.UpdateEditor(item, editor);

            var ctx = new N2.Edit.Workflow.CommandContext(definition, item, Interfaces.Editing, engine.RequestContext.User);

            enclosingEditor.UpdateObject(ctx);

            ctx.GetItemsToSave().ShouldContain(item.TheItem);
        }
Beispiel #3
0
        public void ItemEditor_AddsNewChild()
        {
            var item       = new DecoratedItem();
            var definition = new DefinitionMap().GetOrCreateDefinition(item);
            var editable   = (EditableItemAttribute)definition.Properties["TheItem"].Editable;

            var page            = new Page();
            var enclosingEditor = new ItemEditor();
            var editor          = AddEditorAndInit(item, editable, page, enclosingEditor);

            editable.UpdateEditor(item, editor);

            ItemUtility.FindInChildren <N2.Web.UI.WebControls.NameEditor>(editor).Single().Text = "Hello child";

            enclosingEditor.UpdateObject(new N2.Edit.Workflow.CommandContext(definition, item, Interfaces.Editing, engine.RequestContext.User));

            item.Children.Single().ShouldBe(item.TheItem);
        }
Beispiel #4
0
		public void ItemEditor_AddsNewChild()
		{
			var item = new DecoratedItem();
			var definition = new DefinitionMap().GetOrCreateDefinition(item);
			var editable = (EditableItemAttribute)definition.Properties["TheItem"].Editable;

			var page = new Page();
			var enclosingEditor = new ItemEditor();
			var editor = AddEditorAndInit(item, editable, page, enclosingEditor);

			editable.UpdateEditor(item, editor);
			
			ItemUtility.FindInChildren<N2.Web.UI.WebControls.NameEditor>(editor).Single().Text = "Hello child";

			enclosingEditor.UpdateObject(new N2.Edit.Workflow.CommandContext(definition, item, Interfaces.Editing, engine.RequestContext.User));

			item.Children.Single().ShouldBe(item.TheItem);
		}
        public override bool UpdateItem(ContentItem parentItem, Control editor)
        {
            ItemEditor childEditor  = editor as ItemEditor;
            ItemEditor parentEditor = ItemUtility.FindInParents <ItemEditor>(editor.Parent);

            var childItem = childEditor.CurrentItem;

            if (childItem.ID != 0 && parentItem.ID == 0)
            {
                // we may have initialized the editor with the published version but we want to use the draft here
                childItem = parentItem.FindPartVersion(childItem);
            }

            if (childEditor.UpdateObject(parentEditor.BinderContext.CreateNestedContext(childEditor, childItem, childEditor.GetDefinition())))
            {
                parentItem[Name] = childItem;
                return(true);
            }

            return(false);
        }
Beispiel #6
0
		public void NewChild_IsSaved()
		{
			var item = new DecoratedItem();
			var definition = new DefinitionMap().GetOrCreateDefinition(item);
			var editable = (EditableItemAttribute)definition.Properties["TheItem"].Editable;

			var page = new Page();
			var enclosingEditor = new ItemEditor();
			var editor = AddEditorAndInit(item, editable, page, enclosingEditor);

			editable.UpdateEditor(item, editor);

			var ctx = new N2.Edit.Workflow.CommandContext(definition, item, Interfaces.Editing, engine.RequestContext.User);
			enclosingEditor.UpdateObject(ctx);

			ctx.GetItemsToSave().ShouldContain(item.TheItem);
		}