cancel
Showing results for 
Search instead for 
Did you mean: 

Make Tags a mandatory field in a pop up module

gmurphy
Champ on-the-rise
Champ on-the-rise
Folks,

I have being tring to make Tags (Or Keywords as I have changed it to in parts) as a mandatory field within a pop up module and need some advise. I have been able to make the other fields madatory in the normal way using forms valadation Name, Title etc.Is there anywhere in the Alfresco code where tags is mandatory and also you can see below the javascript file for the module can you offer any advise.



/**
* Document Library "Details" module for Document Library.
*
* @namespace Alfresco.module
* @class Alfresco.module.DoclibDetails
*/
(function()
{
    /**
     * YUI Library aliases
     */
    var Dom = YAHOO.util.Dom, Selector = YAHOO.util.Selector, KeyListener = YAHOO.util.KeyListener;
   
    /**
     * Alfresco Slingshot aliases
     */
    var $html = Alfresco.util.encodeHTML;
   
    /**
     * Internal date formats
     */
    var DATE_LONG = "dddd, d mmmm yyyy", DATE_SHORT = "yyyy/mm/dd";
   
    /**
     * Alfresco Slingshot aliases
     */
    var $html = Alfresco.util.encodeHTML, $combine = Alfresco.util.combinePaths;
   
    Alfresco.module.ManualDoclibDetails = function(htmlId)
    {
        return Alfresco.module.ManualDoclibDetails.superclass.constructor.call(this, "Alfresco.module.ManualDoclibDetails", htmlId, ["button", "calendar", "container", "connection", "json"]);
    };
   
    YAHOO.extend(Alfresco.module.ManualDoclibDetails, Alfresco.module.DoclibDetails);
   
    YAHOO.lang.augmentObject(Alfresco.module.ManualDoclibDetails.prototype,
    {
   
        newDocument: false,
       
        /**
         * Main entry point
         * @method showDialog
         */
        showDialog: function MLD_showDialog()
        {
            // DocLib Actions module
            if (!this.modules.actions)
            {
                this.modules.actions = new Alfresco.module.DoclibActions();
            }
           
            if (!this.modules.docList)
            {
                this.modules.docList = Alfresco.util.ComponentManager.findFirst("Alfresco.DocumentList");
            }
           
            if (!this.containerDiv)
            {
                // Load the UI template from the server
                Alfresco.util.Ajax.request(
                {
                    url: Alfresco.constants.URL_SERVICECONTEXT + "modules/taxdutymanuallibrary/details",
                    dataObj:
                    {
                        htmlid: this.id
                    },
                    successCallback:
                    {
                        fn: this.onTemplateLoaded,
                        scope: this
                    },
                    failureMessage: "Could not load Document Library Details template",
                    execScripts: true
                });
            }
            else
            {
                // Show the dialog
                this._showDialog();
            }
        },
       
        /**
         * Event callback when dialog template has been loaded
         *
         * @method onTemplateLoaded
         * @param response {object} Server response from load template XHR request
         */
        onTemplateLoaded: function MLD_onTemplateLoaded(response)
        {
            var me = this;
           
            // Inject the template from the XHR request into a new DIV element
            this.containerDiv = document.createElement("div");
            this.containerDiv.setAttribute("style", "display:none");
            this.containerDiv.innerHTML = response.serverResponse.responseText;
           
            // The panel is created from the HTML returned in the XHR request, not the container
            var dialogDiv = Dom.getFirstChild(this.containerDiv);
            while (dialogDiv && dialogDiv.tagName.toLowerCase() != "div")
            {
                dialogDiv = Dom.getNextSibling(dialogDiv);
            }
           
            // Create and render the YUI dialog
            this.widgets.dialog = Alfresco.util.createYUIPanel(dialogDiv,
            {
                width: this.options.width
            });
           
            // Template combobox
            YAHOO.util.Event.addListener(this.id + "-template", "change", this.onTemplateChanged, this, true);
           
            //Link Checkboxes
            YAHOO.util.Event.addListener(this.id + "-oi-checkbox", "click", this.onOIChanged, this, true);
            YAHOO.util.Event.addListener(this.id + "-eb-checkbox", "click", this.onEBriefChanged, this, true);
           
            //Link Text boxes
            YAHOO.util.Event.addListener(this.id + "-oi", "keyup", this.onOITextChanged, this, true);
            YAHOO.util.Event.addListener(this.id + "-eb", "keyup", this.onEBriefTextChanged, this, true);
           
            //Delete link to Manual
         // Hook remove person action click events
            var fnRemoveHandler = function DLW_fnRemoveHandler(layer, args)
            {
               Dom.get("remove-link").value = true;
               Dom.get("link-modified").value = true;
               
               Dom.get("lk").value = "";
              Dom.get("lk").focus();
              return true;
            };
            YAHOO.Bubbling.addDefaultAction("remove-manual", fnRemoveHandler);
        
            // Edit metadata link button
            this.widgets.editMetadata = Alfresco.util.createYUIButton(this, "editMetadata", null,
            {
                type: "link"
            });
           
            // Edit metadata link button
            this.widgets.linkManual = Alfresco.util.createYUIButton(this, "linkManual", this.onLink,
            {
                type: "push"
            });
           
            // Publishing due date calendar button
            this.widgets.publishDateButton = new YAHOO.widget.Button(
            {
                type: "push",
                id: "calendarpicker",
                container: this.id + "-publishdate"
            });
            this.widgets.publishDateButton.on("click", this.onDateSelectButton, this);
           
            // OK button
            this.widgets.okButton = Alfresco.util.createYUIButton(this, "ok", null,
            {
                type: "submit",
                htmlName: "-"
            });
           
            // Cancel button
            this.widgets.cancelButton = Alfresco.util.createYUIButton(this, "cancel", this.onCancel);
           
            // Form definition
            this.modules.form = new Alfresco.forms.Form(this.id + "-form");
           
            // Tag Library
            this.modules.tagLibrary = new Alfresco.module.KeywordLibrary(this.id);
            this.modules.tagLibrary.setOptions(
            {
                siteId: this.options.siteId
            });
            this.modules.tagLibrary.initialize(this.modules.form);
           
            // Validation
            this.modules.form.addValidation(this.id + "-name", Alfresco.forms.validation.mandatory, null, "blur");
            this.modules.form.addValidation(this.id + "-name", Alfresco.forms.validation.nodeName, null, "keyup");
            this.modules.form.addValidation(this.id + "-name", Alfresco.forms.validation.length,
            {
                max: 256,
                crop: true
            }, "keyup");
            this.modules.form.addValidation(this.id + "-fileTitle", Alfresco.forms.validation.mandatory, null, "blur");
            this.modules.form.addValidation(this.id + "-fileTitle", Alfresco.forms.validation.length,
          
            {
                max: 256,
                crop: true
            }, "keyup");
            this.modules.form.addValidation(this.id + "-description", Alfresco.forms.validation.mandatory, null, "blur");
            this.modules.form.addValidation(this.id + "-description", Alfresco.forms.validation.length,
            {
                max: 512,
                crop: true
            }, "keyup");
          
           
           
            this.modules.form.addValidation(this.id + "-template", function D_oMT_validManualTemplate(field, args, event, form, silent)
            {
                return (Dom.get(args.obj.id + "-template").selectedIndex > 0);
            }, { "obj": this}, "blur");
           
            this.modules.form.addValidation("pd", this._onPublishDateValidation, { "obj": this}, "blur");
            this.modules.form.addValidation("pd", this._onPublishDateValidation, { "obj": this}, "focus");
           
            this.modules.form.setShowSubmitStateDynamically(true, false);
            // Add doc file extension to name
            /*         this.modules.form.addValidation(this.id + "-name", this._onAppendFileExtension,
             {
             obj: this
             }, "keyup");
             */
            // OK button submits the form
            this.modules.form.setSubmitElements(this.widgets.okButton);
           
            // Hide dialog and disable ok button after submit and display a waiting message
            this.modules.form.doBeforeFormSubmit =
            {
                fn: function()
                {
                   this.widgets.linkManual.set("disabled", true);
                    this.widgets.editMetadata.set("disabled", true);
                    this.widgets.okButton.set("disabled", true);
                    this.widgets.cancelButton.set("disabled", true);
                    this.widgets.publishDateButton.set("disabled", true);
                    this.modules.tagLibrary.updateForm(this.id + "-form", "tags");
                    this.widgets.dialog.hide();
//                    this.widgets.feedbackMessage = Alfresco.util.PopupManager.displayMessage(
//                    {
//                        text: Alfresco.util.message("message.saving", this.name),
//                        spanClass: "wait",
//                        displayTime: 0
//                    });
                },
                obj: null,
                scope: this
            };
           
            // JSON submit type
            this.modules.form.setAJAXSubmit(true,
            {
                successCallback:
                {
                    fn: this.onSuccess,
                    scope: this
                },
                failureCallback:
                {
                    fn: this.onFailure,
                    scope: this
                }
            });
            this.modules.form.setSubmitAsJSON(true);
           
            // Show the dialog
            this._showDialog();
        },
       
        _onPublishDateValidation: function MLD_onPublishDateValidation(field, args, event, form, silent)
        {
            return (Dom.get("pd").value != "");
        },
       
        /**
         * Details form submit success handler
         *
         * @method onSuccess
         * @param response {object} Server response object
         */
        onSuccess: function MLD_onSuccess(response)
        {
           
            if (this.newDocument)
            {
                this._hideDialog();
               
                var file = response.json.results[0];
                var path = file.path;
                var displayName = file.displayName;
                var fileName = file.name;
                var nodeRef = file.nodeRef;
               
                var multipleFiles = [];
               
                if(file.oiNodeRef != ""){
                   multipleFiles.push(file.oiNodeRef);
                }
               
                if(file.eBriefNodeRef != ""){
                   multipleFiles.push(file.eBriefNodeRef);
                }
              
                multipleFiles.push(nodeRef);
               
                var me = this;
               
                this.modules.actions.genericAction(
                {
                    success:
                    {
                        event:
                        {
                            name: "metadataRefresh"
                        },
                        callback:
                        {
                            fn: function MLD_oND_success(data)
                            {
                                var fnAfterUpdate = function MLD_onND_success_afterUpdate(obj)
                                {
                                    var nodeRef = data.json.results[0].nodeRef;
                                    if (YAHOO.env.ua.ie > 6)
                                    {
                                        // MSIE7 blocks the download and gets the wrong URL in the "manual download bar"
                                        Alfresco.util.PopupManager.displayPrompt(
                                        {
                                            //title: this.msg("message.new-document.success", displayName),
                                            //text: this.msg("message.new-document.success.ie7"),
                                            title: "New manual created!",
                                            text: "New manual created succcessfully",
                                            buttons: [
                                            {
                                                text: this.msg("button.close"),
                                                handler: function DLTB_oAEO_success_close()
                                                {
                                                    this.destroy();
                                                }
                                            }]
                                        });
                                    }
                                    else
                                    {
                                        Alfresco.util.PopupManager.displayMessage(
                                        {
                                            //text: this.msg("message.new-document.success", displayName)
                                            text: "New manual created"
                                        });
                                    }
                                   
                                    var file = this.getSelectedFile(nodeRef);
                                   
                                    Alfresco.logger.debug("afterupdate: newFile is ", file);
                                   
                                    YAHOO.Bubbling.fire("fileSelected",
                                    {
                                        fileNodeRef: nodeRef
                                    });
                                   
                                };
                                this.modules.docList.afterDocListUpdate.push(fnAfterUpdate);
                               
                            },
                            scope: this
                        }
                    },
                    failure:
                    {
                        callback:
                        {
                            fn: function DL_oAEO_failure()
                            {
                                //me.state.actionEditOfflineActive = false;
                            }
                        },
                        //message: this.msg("message.new-document.failure", displayName)
                        message: "Could not create new manual"
                    },
                    webscript:
                    {
                        method: Alfresco.util.Ajax.POST,
                        name: $combine("checkout-files/site", this.options.siteId, this.options.containerId, path, fileName)
                    },
                    config:
                    {
                       requestContentType: Alfresco.util.Ajax.JSON,
                       dataObj:
                       {
                          nodeRefs:  multipleFiles
                       }
                    }
                });
            }
            else
            {
               
                // Reload the node's metadata
                Alfresco.util.Ajax.request(
                {
                    url: Alfresco.constants.PROXY_URI + "slingshot/manual-doclib/doclist/node/" + this.options.file.nodeRef.replace(":/", "") + "?filter=node",
                    successCallback:
                    {
                        fn: this.onMetadataSuccess,
                        scope: this
                    },
                    failureCallback:
                    {
                        fn: this.onMetadataFailed,
                        scope: this
                    }
                });
               
                YAHOO.Bubbling.fire("metadataRefresh");
            }
        },
       
        onDateSelectButton: function MLD__onDateSelectButton(e)
        {
            var oCalendarMenu = new YAHOO.widget.Overlay("calendarmenu");
            oCalendarMenu.setBody(" ");
            oCalendarMenu.body.id = "calendarcontainer";
           
            var container = this.get("container");
            // Render the Overlay instance into the Button's parent element
            oCalendarMenu.render(container);
           
            // Align the Overlay to the Button instance
            oCalendarMenu.align();
           
            var today = new Date();
           
            var oCalendar = new YAHOO.widget.Calendar("buttoncalendar", oCalendarMenu.body.id,
            {
                mindate: today
            });
            oCalendar.render();
           
            oCalendar.changePageEvent.subscribe(function()
            {
                window.setTimeout(function()
                {
                    oCalendarMenu.show();
                }, 0);
            });
           
            oCalendar.selectEvent.subscribe(function(type, args)
            {
                var date;
               
                if (args)
                {
                    date = args[0][0];
                    var selectedDate = new Date(date[0], (date[1] - 1), date[2]);
                   
                    var elem = Dom.get("pd");
                    elem.value = Alfresco.util.formatDate(selectedDate, DATE_LONG);
               elem.focus();
                   
                    var hiddenEl = Dom.get("details-publish");
                    hiddenEl.value = Alfresco.util.formatDate(selectedDate, DATE_SHORT);
                }
               
                oCalendarMenu.hide();
            }, this);
           
        },
       
        _onAppendFileExtension: function MLD__onAppendFileExtension(field, args, event, form, silent)
        {
            var name = Dom.get(args.obj.id + "-name").value;
           
            if (name.length > 0)
            {
                var index = name.lastIndexOf(".doc");
                if (index < 0)
                {
                    name = name + ".doc";
                    Dom.get(args.obj.id + "-name").value = name;
                }
            }
           
            return true;
        },
       
        /**
         * Templates select value change event handler
         *
         * @method onTemplateChanged
         * @param e {object} DomEvent
         * @param p_obj {object} Object passed back from addListener method
         */
        onTemplateChanged: function DLW_onTemplateChanged(e, p_obj)
        {
           var elTarget = YAHOO.util.Event.getTarget(e);
           var template = elTarget.children[elTarget.selectedIndex].text;
           
           if(template === "ManualTemplate.doc")
           {
              Dom.get(this.id + "-oi-checkbox").disabled = false;
              Dom.get(this.id + "-oi").disabled = false;
              
              Dom.get(this.id + "-eb-checkbox").disabled = false;
              Dom.get(this.id + "-eb").disabled = false;
              
              this.widgets.linkManual.set("disabled", true);
              Dom.get("lk").value="";
              Dom.get("details-link").value = "";
           }
           else
           {
              Dom.get(this.id + "-oi-checkbox").disabled = true;
              Dom.get(this.id + "-oi-checkbox").checked = false;
              Dom.get(this.id + "-oi").disabled = true;
              Dom.get(this.id + "-oi").value = "";
              Dom.get("details-oi").value = "";
              
              Dom.get(this.id + "-eb-checkbox").disabled = true;
              Dom.get(this.id + "-eb-checkbox").checked = false;
              Dom.get(this.id + "-eb").disabled = true;
              Dom.get(this.id + "-eb").value = "";
              Dom.get("details-eb").value = "";
              
              this.widgets.linkManual.set("disabled", false);
              
           }
        },
       
        onOIChanged: function DLW_onOIChanged(e, p_obj)
        {
          Dom.get("oi-modified").value = true;
           if(!Dom.get(this.id + "-oi-checkbox").checked)
           {
              Dom.get(this.id + "-oi").value = "";
              Dom.get("details-oi").value = "";
           }
        },
       
        onEBriefChanged: function DLW_onEBriefChanged(e, p_obj)
        {
           Dom.get("eb-modified").value = true;
           if(!Dom.get(this.id + "-eb-checkbox").checked)
           {
              Dom.get(this.id + "-eb").value = "";
              Dom.get("details-eb").value = "";
           }
        },
       
        onOITextChanged: function DLW_onOITextChanged(e, p_obj)
        {
              Dom.get("oi-modified").value = true;
              if(Dom.get(this.id + "-oi").value != "")
              {
                 Dom.get(this.id + "-oi-checkbox").checked = true;
              }
        },
       
        onEBriefTextChanged: function DLW_onEBriefTextChanged(e, p_obj)
        {
           Dom.get("eb-modified").value = true;
           if(Dom.get(this.id + "-eb").value != "")
          {
              Dom.get(this.id + "-eb-checkbox").checked = true;
          }
        },
       
        /**
         * Templates select value change event handler
         *
         * @method onTemplateChanged
         * @param e {object} DomEvent
         * @param p_obj {object} Object passed back from addListener method
         */
        onLink: function DLW_onLink(e, p_obj)
        {   
           if (!this.modules.linkTo)
            {
               this.modules.linkTo = new Alfresco.module.ManualDoclibLinkTo(this, this.id + "-linkTo");
            }
           
            this.modules.linkTo.setOptions(
            {
               mode: "link",
               siteId: this.options.siteId,
               containerId: this.options.containerId,
               path: this.options.currentPath,
               files: this.options.file
            }).showDialog();
        },
       
        printLinkedDocument: function MLD__printLinkedDocument(p_obj_data)
        {
           Dom.get("link-modified").value = true;
           Dom.get("remove-link").value = false;
           
           this.linkedDocument = p_obj_data;
           
           var paths = this.linkedDocument.data.path.split("/");
           
           if(paths.length > 0)
           {
              Dom.get("lk").value = this.linkedDocument.data.path;
              Dom.get("details-link").value =this.linkedDocument.data.nodeRef;
              Dom.get("lk").focus();
           }
           
        },
       
        /**
         * PRIVATE FUNCTIONS
         */
       
        /**
         * Internal show dialog function
         * @method _showDialog
         */
        _showDialog: function MLD__showDialog()
        {
            var file = this.options.file;
           
            if ((typeof file !== "undefined") && (file.length !== 0))
            {
                this.newDocument = false;
            }
            else
            {
                this.newDocument = true;
            }
           
            // Grab the form element
            var formElement = Dom.get(this.id + "-form");
           
            // Set-up the form action
            if (this.newDocument)
            {
                var actionUrl = YAHOO.lang.substitute(Alfresco.constants.PROXY_URI + "slingshot/doclib/action/file/site/{site}/{container}/{path}",
                {
                    site: this.options.siteId,
                    container: this.options.containerId,
                    path: this.options.currentPath
                });
            }
            else
            {
                var actionUrl = YAHOO.lang.substitute(Alfresco.constants.PROXY_URI + "api/manual-metadata/node/{nodeRef}",
                {
                    nodeRef: file.nodeRef.replace(":/", "")
                });
            }
           
            formElement.attributes.action.nodeValue = actionUrl;
           
            // Dialog title
            var titleDiv = Dom.get(this.id + "-title");
            var fileSpan = this.newDocument ? '<span class="light">' + this.msg("title.new-content") + '</span>' : '<span class="light">' + $html(file.displayName) + '</span>';
            titleDiv.innerHTML = this.msg("title", fileSpan);
           
            // Item details
            if (this.newDocument)
            {
               Dom.setStyle(Dom.get(this.id + "-editMetadata"), "display", "none");
                this.widgets.editMetadata.set("disabled", true);
                Dom.get(this.id + "-name").value = "";
                Dom.get(this.id + "-fileTitle").value = "";
                Dom.get(this.id + "-description").value = "";
                Dom.get("details-publish").value = "";
                Dom.get("pd").value = "";
              Dom.get(this.id + "-template").value = "";
               
                Dom.get(this.id + "-oi-checkbox").disabled = true;
              Dom.get(this.id + "-oi-checkbox").checked = false;
              Dom.get(this.id + "-oi").disabled = true;
              Dom.get(this.id + "-oi").value = "";
              Dom.get("details-oi").value = "";
              Dom.get(this.id + "-eb-checkbox").disabled = true;
              Dom.get(this.id + "-eb-checkbox").checked = false;
              Dom.get(this.id + "-eb").disabled = true;
              Dom.get(this.id + "-eb").value = "";
              Dom.get("details-eb").value = "";
               
                this.modules.tagLibrary.setTags([]);   
               
                Dom.get("versionNotes").value = "";
               
                // Enable buttons
                this.widgets.linkManual.set("disabled", true);
                Dom.get("lk").value = "";
                Dom.get("details-link").value = "";
                Dom.get(this.id + "-linkManual-text").disabled = true;
            }
            else
            {
                Dom.get(this.id + "-name").value = file.fileName ? file.fileName : "";
                Dom.get(this.id + "-fileTitle").value = file.title ? file.title : "";
                Dom.get(this.id + "-description").value = file.description ? file.description : "";
                Dom.get("details-publish").value = file.publishingDueDate ? Alfresco.util.formatDate(file.publishingDueDate, DATE_SHORT) : "";
                Dom.get("pd").value = file.publishingDueDate ? Alfresco.util.formatDate(file.publishingDueDate, DATE_LONG) : "";
                Dom.get("oi-modified").value = false;
                Dom.get("eb-modified").value = false;
                Dom.get("link-modified").value = false;
                Dom.get(this.id + "-linkManual-text").disabled = true;
               
                if(file.nodeType == "itc:manual")
                {
                   this.widgets.linkManual.set("disabled", true);
                   Dom.get("lk").value = "";
                    Dom.get("details-link").value = "";
                   
                    Dom.setStyle(Dom.get(this.id + "-linkDiv"), "display", "none");
                    Dom.setStyle(Dom.get(this.id + "-oiDiv"), "display", "block");
                    Dom.setStyle(Dom.get(this.id + "-ebDiv"), "display", "block");
                   
                    if(file.custom.isWorkingCopy != undefined && file.custom.isWorkingCopy == true)
                    {
                       Dom.get(this.id + "-oi-checkbox").disabled = true;
                       Dom.get(this.id + "-oi").disabled = true;
                       Dom.get("details-oi").value = "";
   
                      Dom.get(this.id + "-eb-checkbox").disabled = true;
                     Dom.get(this.id + "-eb").disabled = true;
                     Dom.get("details-oi-ref").value = "";
                    }
                    else
                    {
                       Dom.get(this.id + "-oi-checkbox").disabled = false;
                       Dom.get(this.id + "-oi").disabled = false;
   
                      Dom.get(this.id + "-eb-checkbox").disabled = false;
                     Dom.get(this.id + "-eb").disabled = false;
                    }
                   
                    if(file.custom.associatedOI != null && file.custom.associatedOI != undefined && file.custom.associatedOI != "")
                    {
                      Dom.get(this.id + "-oi-checkbox").checked = true;
                      Dom.get(this.id + "-oi").value = file.custom.associatedOIName;
                      Dom.get("details-oi").value = file.custom.associatedOIName;
                      Dom.get("details-oi-ref").value = file.custom.associatedOI;
                    }
                    else
                    {
                      Dom.get(this.id + "-oi-checkbox").checked = false;
                      Dom.get(this.id + "-oi").value = "";
                      Dom.get("details-oi").value = "";
                      Dom.get("details-oi-ref").value = "";
                    }
                   
                    if(file.custom.associatedeBrief != null && file.custom.associatedeBrief != undefined && file.custom.associatedeBrief != "")
                    {
                      Dom.get(this.id + "-eb-checkbox").checked = true;
                      Dom.get(this.id + "-eb").value = file.custom.associatedeBriefName;
                      Dom.get("details-eb").value = file.custom.associatedeBriefName;
                      Dom.get("details-eb-ref").value = file.custom.associatedeBrief;
                    }
                    else
                    {
                       Dom.get(this.id + "-eb-checkbox").checked = false;
                      Dom.get(this.id + "-eb").value = "";
                      Dom.get("details-eb").value = "";
                      Dom.get("details-eb-ref").value = "";
                    }
                }
                else if(file.nodeType == "itc:oi" || file.nodeType == "itc:ebrief")
                {
                   Dom.setStyle(Dom.get(this.id + "-ebDiv"), "display", "none");
                   Dom.setStyle(Dom.get(this.id + "-oiDiv"), "display", "none");
                   Dom.setStyle(Dom.get(this.id + "-linkDiv"), "display", "block");
                   
                   Dom.get(this.id + "-oi-checkbox").disabled = true;
                  Dom.get(this.id + "-oi-checkbox").checked = false;
                  Dom.get(this.id + "-oi").disabled = true;
                  Dom.get(this.id + "-oi").value = "";
                  Dom.get("details-oi").value = "";
                  Dom.get("details-oi-ref").value = "";
                  
                  Dom.get(this.id + "-eb-checkbox").disabled = true;
                  Dom.get(this.id + "-eb-checkbox").checked = false;
                  Dom.get(this.id + "-eb").disabled = true;
                  Dom.get(this.id + "-eb").value = "";
                  Dom.get("details-eb").value = "";
                  Dom.get("details-eb-ref").value = "";
                  
                  if(file.custom.isWorkingCopy != undefined && file.custom.isWorkingCopy == true)
                  {
                     this.widgets.linkManual.set("disabled", true);
                     Dom.get("lk").disabled = true;
                  }
                  else
                  {
                     this.widgets.linkManual.set("disabled", false);
                     Dom.get("lk").disabled=false;
                  }
                  
                  if(file.custom.linkedManual != null && file.custom.linkedManual != undefined && file.custom.linkedManual != "")
                  {
                     this.widgets.linkManual.set("disabled", false);
                       Dom.get("lk").value = file.custom.linkedManualName;
                        Dom.get("details-link").value = file.custom.linkedManual;
                  }
                }
               
                this.modules.tagLibrary.setTags(file.tags);
                Dom.get("versionNotes").value = file.versionNotes ? file.versionNotes : "";
               
                // Edit Metadata link
                this.widgets.editMetadata.set("href", "edit-metadata?nodeRef=" + file.nodeRef);
               
                // Enable buttons
                this.widgets.editMetadata.set("disabled", false);
            }
           
            this.widgets.okButton.set("disabled", false);
            this.widgets.cancelButton.set("disabled", false);
           
            // Initialise the form
            this.modules.form.init();
           
            // Show the dialog
            this.widgets.dialog.show();
           
            // Fix Firefox caret issue
            Alfresco.util.caretFix(this.id + "-form");
           
            // We're in a popup, so need the tabbing fix
            this.modules.form.applyTabFix();
           
            // Register the ESC key to close the dialog
            var escapeListener = new KeyListener(document,
            {
                keys: KeyListener.KEY.ESCAPE
            },
            {
                fn: function(id, keyEvent)
                {
                    this._hideDialog();
                },
                scope: this,
                correctScope: true
            });
            escapeListener.enable();
           
            if (this.newDocument)
         {
            Dom.get(this.id + "-name").focus();
         }
         else
         {
            Dom.get(this.id + "-template").disabled = true;
            Dom.setStyle(Dom.get(this.id + "-templateDiv"), "display", "none");
            
            if (file !== null && file.custom.isWorkingCopy)
            {
               // Disable name field if asset is a working copy
               Dom.get(this.id + "-name").disabled = true;
               Dom.get(this.id + "-fileTitle").focus();
            }
            else
            {
               Dom.get(this.id + "-name").focus();
            }
            
         }
        }
       
    }, true);
   
    /* Dummy instance to load optional YUI components early */
    var dummyInstance = new Alfresco.module.ManualDoclibDetails("null");
})();
1 REPLY 1

senanufc
Champ in-the-making
Champ in-the-making

Also have the same request