AnsweredAssumed Answered

Creating Dashlet Which Uses Forms Service

Question asked by nixon_d on Nov 22, 2013
Hi All,

Was hoping someone may be able to help. I'm trying to create a new site dashlet which contains a simple link - when clicked, the link should open up a SimpleDialog and be populated using the response from a call to the forms service.

I'm having some difficulty in actually getting the SimpleDialog to appear! I've included the file containing the class declaration in my head.ftl and have compared my code to how this is done elsewhere but can't find anything that would prevent this from displaying.

I've provided some source code below.Is there anything that I'm missing? Would greatly appreciate any help.

File name - mytest.get.html.ftl

<#assign el=args.htmlid?html>
<script type="text/javascript">//<![CDATA[
   new Alfresco.MyTest("${args.htmlid?js_string}");
<div class="dashlet">
   <div class="title">Test Title</div>
<div class="toolbar flat-button">
      <span class="align-right yui-button-align"> <span
         class="first-child"> <a id="email-anchor" href="#" class="theme-color-1">
               <img src="${url.context}/res/components/images/email-16.png"
               style="vertical-align: text-bottom" width="16" />
               Test Link

File name - mytest.get.head.ftl

<#include "/org/alfresco/components/">
<#include "/org/alfresco/components/form/form.get.head.ftl">
<@script type="text/javascript" src="${page.url.context}/res/components/dashlet/mytest.js"></@script>
<@script type="text/javascript" src="${page.url.context}/res/modules/simple-dialog.js"></@script>

File name - mytest.js

   var Dom = YAHOO.util.Dom,
   Event = YAHOO.util.Event;
   Alfresco.MyTest = function(htmlId){
   , htmlId);
    = "Alfresco.MyTest";
    = htmlId;
      return this;
   YAHOO.lang.extend(Alfresco.MyTest, Alfresco.component.ShareFormManager,{
      options   :   {},
      onReady   :   function MyTest_onReady()
         var testAnchor = Dom.get("email-anchor");
            Event.addListener(testAnchor, "click", this.onAnchorClick, this, true);
      onAnchorClick   :   function onAnchorClick(e)
            var templateUrl = YAHOO.lang.substitute(Alfresco.constants.URL_SERVICECONTEXT
                    + "components/form?itemKind={itemKind}&itemId={itemId}&mode={mode}&submissionUrl={submissionUrl}&submitType={submitType}",
               itemKind : "type",
               itemId : "mkt:test",
               mode : "create",
               submissionUrl     :      "/slingshot/test/send",
               submitType   :   "json"

            var testDialog = new Alfresco.module.SimpleDialog( + "-myTestDialog").setOptions(
               width      :   "30em",
               templateUrl   :   templateUrl,
               onSuccess   :   
                     fn   :   function MyTest_onSuccess_callback(response)
                              alert("onSuccess callback");
                     scope   :   this