1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Products sample and Publish/Draft buttons

Products sample and Publish/Draft buttons

7 posts, 0 answered
  1. Denis
    Denis avatar
    105 posts
    Registered:
    27 Feb 2009
    15 Dec 2011
    Link to this post
    Hello,

    I'am little confused about tool bar in Products sample (Details view). It has "Publish" and "Save as Draft" buttons. But is I check ProductsDefinitions.cs -> CreateBackendFormToolbar function it says following:
    // Create
    toolbarSectionElement.Items.Add(new CommandWidgetElement(toolbarSectionElement.Items)
    {
        Name = "SaveChangesWidgetElement",
        ButtonType = CommandButtonType.Save,
        CommandName = DefinitionsHelper.SaveCommandName,
        Text = (isCreateMode) ? String.Concat("Create", itemName) : "SaveChanges",
        ResourceClassId = resourceClassId,
        WrapperTagKey = HtmlTextWriterTag.Span,
        WidgetType = typeof(CommandWidget)
    });

    so button should say Create or SaveChanges but it is not. Why?

    I'm trying to implement Public/Draft functionality for my custom module.
    So far I implemented LifecycleDecoratorWrapper for my service
    Item implements ILifecycleDataItemGeneric
    ItemsManager implements ILifecycleManager

    Let me know what I'm missing here...
    Thanks,
    Denis.
  2. Denis
    Denis avatar
    105 posts
    Registered:
    27 Feb 2009
    18 Dec 2011
    Link to this post
    Any ideas on this?

    Also I found that my data item has following property overridden:
    public override bool SupportsContentLifecycle
    {
        get
        {
            return false;
        }
    }

    If I remove this overriding, I can't edit my module items in the backed. All changes are ignored when clicking save button.
  3. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    20 Dec 2011
    Link to this post
    Hi Denis,

    The Products sample in our SDK is a full blown content based module which supports almost all features of the built-in modules. One of them is workflow. The confusion comes, because in the user interface, all buttons that you see are actually related to the workflow.

    Although you have definitions for "Save as Draft", those definitions are not applied if workflow is supported. Instead, the buttons which should be displayed are shown as the result of a service call that you can see if you inspect the network traffic in Firebug. That said, if you want to modify those buttons, you would have to switch workflow off. 

    The SupportContentLifecycle property is not overriden anywhere in Products. Maybe you've followed another of our tutorials where we don't use workflow?

    Greetings,
    Slavo
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  4. Denis
    Denis avatar
    105 posts
    Registered:
    27 Feb 2009
    21 Dec 2011
    Link to this post
    Hi Slavo,

    Thank you for the reply.
    I created my custom module based on the following tutorial:
    http://www.sitefinity.com/blogs/joshmorales/posts/11-07-07/creating_sitefinity_4_content_modules_part_1_project_preparation_and_hello_world.aspx

    It doesn't show how to add Publish/Draft functionality. I'm trying to figure out what I should add to support "Publish/Draft" functionality.

    I tried to review Products sample, but it contains a way more features and it is hard to extract only what I need. I want to extend my module gradually.
    So far I implemented LifecycleDecoratorWrapper for my service
    Item implements ILifecycleDataItemGeneric
    ItemsManager implements ILifecycleManager
    Could you please let me know what new interfaces/functions need to be supported in order to have "Publish/Draft" functionality?

    I don't sure if I need workflow functionality for right now. But if it is tied to "Publish/Draft" functionality, I'm fine to support workflow feature as well.

    Thanks!
    Denis.
  5. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    27 Dec 2011
    Link to this post
    Hi Denis,

    If you want your module data items to behave like the default modules, you have to implement both content lifecycle and workflow. To implement lifecycle, what you've already done is enough. Of course you should remove the SupportContentLifecycle property, or return true from its getter.

    To support workflow, there are a number of steps you need to take.

    Before I describe the steps, I want to mention that the easiest way to achieve this scenario in Sitefinity 4.4 is using the Module Builder. With that feature, you can do all this work though the UI and items support publish/draft versions by default. For more information, please go to http://www.sitefinity.com/asp-net-cms-for-developers/module-builder.aspx 

    If you still decide to implement workflow yourself, here are the steps:

    1. Copy the ProductsWorkflow.xamlx file from the Products module to your module's assembly. Make the file an embedded resource.
    2. In your data item, implement the IApprovalWorkflowItem interface. This is essentially including two properties, like ProductItem class - ApprovalWorkflowState and ApprovalTrackingRecordMap.
    3. In your module class, add a property for the workflow URL, called WorkflowRelativeURL. See the ProductsModule.cs.
    4. In the same module class, copy the InstallCustomWorkflow() method. Substitute the ProductItem class in the code with your data model. Do the same with ProductResources class.
    5. Call the InstallCustomWorkflow() method from the Install() method.

    After all this you need to reinstall your module for the changes to take effect. For all the steps above you can take a look at the implementation in the ProductsModule for details. If you have questions for the details of this implementation, contact us again.

    Kind regards,
    Slavo
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Denis
    Denis avatar
    105 posts
    Registered:
    27 Feb 2009
    08 Jan 2012
    Link to this post
    Hi Slavo,

    I've done all steps you suggested in the previous message.
    Additionally, I added following line in the FluentMapping->MapItem method:
    itemMapping.HasAssociation<Telerik.Sitefinity.Workflow.Model.Tracking.ApprovalTrackingRecordMap>(p => p.ApprovalTrackingRecordMap);

    I still don't see publish/draft buttons.
    Now, when I create new item and click "Create" button, I get “Sequence contains no elements” error (attached). After I cancel creation I can see that item was actually created and exists in the list. Update operation causes the same error.

    If I turn SupportsContentLifecycle property off - no errors occur.

    So far the following interfaces were implemented:
    - LifecycleDecoratorWrapper
    - ILifecycleDataItemGeneric
    - ILifecycleManager
    - IApprovalWorkflowItem
    - added Workflow.xamlx file
    - Added installation steps for workflow

    To avoid conflicts I was installed and tested module on the clean web-site.

    Wait for more ideas about enabling workflow.
    Thanks,
    Denis.


    /******* added later *******************************************/
    I just figured out.
    If I try to update item (it fails with with message I mentioned above) and query after that all items using API I can see two copies of item with Status temp and Master. It makes me think that workflow/lifecycle functionality halfly enabled.
  7. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    13 Jan 2012
    Link to this post
    Hello,

    It looks like the content lifecycle is working, but workflow is not.

    From what I see the problem is related to the service which is invoked. Either the service fails or it cannot find the workflow file. The problem is related to step 1 or 3 from my previous post. When you open the edit screen, a call is made to the workflow service. You can take a look at the request in your browser's web development tools (as shown in the attached image), and see if this call returns ok.

    Please send back the result from the call. If it is not OK, the log file may contain info about what exactly failed.

    Regards,
    Slavo
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
7 posts, 0 answered