AnsweredAssumed Answered

Aikau Document Picker Save Help

Question asked by sarah.jordison on Nov 17, 2015
Latest reply on Dec 2, 2015 by sarah.jordison
Hi Guys,

I am using one of the examples of the Aikau project. Now, I am new to this project and it looks like it's a huge time saver. However, I am being tripped up a little here.

I have the following json model and it displays the document picker and a save and cancel button. All I want to do it console.log() the list of selected document nodeRefs. However, I cannot seem to find the on save callback function, nor can I find the code to grab the list of user selected documents. Does someone have an example of this?

Thanks!

<strong>JSON Model</strong>
<javascript>
model.jsonModel = {
    services: [
        "alfresco/dialogs/AlfDialogService",
        "alfresco/services/DocumentService",
        "alfresco/services/SiteService",
        "alfresco/services/CrudService"
    ],
    widgets: [
        {
           id: "MY_DOCUMENT_FINDER",
           name: "alfresco/forms/Form",
           config: {
               okButtonLabel: "Ok",
               okButtonPublishTopic: "FORM_CONTENTS",
               widgets: [
                  {
                      id: "MY_WIDGET",
                      name: "example/widgets/MyWidget"
                  },
                  {
                      name: "alfresco/forms/controls/DocumentPicker",
                      itemKey: "nodeRef",
                      config: {
                          label: "Choose a document",
                          name: "document"
                      }
                  }
               ]
           }
        }
    ]
};
</javascript>

UPDATE:
I am still feeling totally lost in this Aikau code. I have now created a JavaScript widget successfully and altered my model, but cannot seem to get the subscribe to fire. Is there a specific way to do this? I have even changed my model and put the widget inside my own widget. I imagine this would put it into the scope of my widget, but then it doesn't load the document picker UI anymore.

<strong>MyWidget.js<strong>
<javascript>
define(["dojo/_base/declare",
        "dijit/_WidgetBase",
        "alfresco/core/Core"
    ],
    function(declare, _Widget, Core) {
        return declare([_Widget, Core], {
   
           /**
           *  Construct
           */
           constructor: function example_widgets_MyWidget__constructor(args) {
              console.log(args);
           
              this.alfSubscribe("ALF_ITEMS_SELECTED", lang.hitch(this, "getPickedItems"));

                        //this.alfSubscribe("ALF_ITEMS_SELECTED", lang.hitch(this, this.getPickedItems));
           },
           
           /**
            *  Get Picked Items from Picked Items Widget
            */
           getPickedItems: function example_widgets_MyWidget__getPickedItems() {
              var pickedItemsWidget = lang.getObject("verticalWidgets.pickedItemsWidget", false, this);
              
              alert(pickedItemsWidget.currentData.items);
           }
        });
});
</javascript>

Outcomes