Content Management and Capture

Content Management and Capture

Come for answers. Stay for best practices. All we’re missing is you.

 View Only
Expand all | Collapse all

EditPage Closure for Edited EntryTemplate

  • 1.  EditPage Closure for Edited EntryTemplate

    Posted Mon September 21, 2020 05:29 PM

    we are facing problem in Edited EntryTemplate(That we Edited using 'EditLayout') while saving. The documents that are added using Non-Edited EntryTemplate is staying on the edit page while saving whereas the documents which we are tried to edit(Right Click document-->Properties) does not stay on the page and closes on click of 'Save' button.

    Tried to use the below code:

    Main JS:

    ItemPropertiesPane.addExtension(CustomItemPropertiesPaneExtension);

    CustomItemPropertiesPaneExtension.js:

    define( ["dojo/_base/declare",

    "ecm/widget/ItemPropertiesPaneExtension",

    "ecm/widget/CommonPropertiesPane",

    "dojo/aspect",

    "ecm/model/Request",

    "dojo/_base/array",

    "dijit/registry",

    "dojo/query",

    "dojo/NodeList-dom",

    "dojo/dom-construct"],

    function(declare, ItemPropertiesPaneExtension, CommonPropertiesPane, aspect, Request, array, registry, query, nodeList, domConstruct) {

    return declare("entryTemplateInterceptorDojo.CustomItemPropertiesPaneExtension", [ ItemPropertiesPaneExtension ], {

    postCreate: function() {

    console.log("ItemPropertiesPaneExtension postCreate!");

    aspect.after(CommonPropertiesPane.prototype, "validate", function(response,args){

    var dt = this.getPropertyValue("DocumentTitle");

    if (dt == "stop") {

    console.log("Preventing from closing");

    return [];

    } else {

    console.log("NOT preventing from closing");

    }

    });

    },

    isEnabledFor: function(item) {

    return true;

    }

    });

    });

    For the above code , For Non-EDITED EntryTemplate when the DocumentTitle PropertyValue is 'stop' and click on save the page stays whereas this is not the case for EDITED EntryTemplate.



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 2.  RE: EditPage Closure for Edited EntryTemplate

    Posted Tue September 22, 2020 02:18 AM

    How about use ecm/widget/LayoutPropertiesPane.js ?

    aspect.after(LayoutPropertiesPane.prototype, "validateAll", ...



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 3.  RE: EditPage Closure for Edited EntryTemplate

    Posted Tue September 22, 2020 07:15 AM

    Hi Jian, Thanks it worked for me. I had tried aspect.after(LayoutPropertiesPane.prototype, "validate", ... but it didn't worked for me that time on click of 'save' button. For the code- aspect.after(LayoutPropertiesPane.prototype, "validateAll", ... it is applicable for opening property page, changing the properties apart from click on 'save' button. Is there anything which is applicable only for 'save' button.? else this is also fine :)



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 4.  RE: EditPage Closure for Edited EntryTemplate

    Posted Tue September 22, 2020 05:18 PM

    Hi Jian, Actually this does not fulfill our requirement. We want to readProperty Value at Edit-->Pass to the service-->Service will do some calculation and return the targetValues.These targetValues we should set against the respective property and it should hold the Edit page for that and if all the propertyValue matches then onClicking of save button it should save the page and close.

    The code works fine for Non-Edited ET, but Edited ET it is causing the issue because the postCreate function is being called multiple times

    Below is code snippet:

    MainJS:

    require(["dojo/_base/declare",

    "dojo/_base/lang",

    ..

    "ecm/widget/dialog/CheckInDialog"

    ],

    function(declare, lang,.., CustomItemPropertiesPaneExtension,.. ) { ItemPropertiesPane.addExtension(CustomItemPropertiesPaneExtension);

    });

    CustomItemPropertiesPaneExtension.js

    postCreate: function() {

    console.log("ItemPropertiesPaneExtension postCreate!");// This is called multiple times so that once the targetPropValue is set in second/third time since the value is already setted so no invalidFields therefore no return and the page gets closed

    aspect.after(LayoutPropertiesPane.prototype, "validateAll", function(response,args){

    console.log("*Inside the LayoutPropertiesPane Validate*");

    var propJSON = new Array();

    var propdt1 = new Object();

    propdt1["name"] = 'DocumentTitle';

    propdt1["value"] = this.getPropertyValue("DocumentTitle");

    propJSON.push(propdt1);

    var propdt2 = new Object();

    propdt2["name"] = 'strsA';

    propdt2["value"] = this.getPropertyValue("strsA");

    propJSON.push(propdt2);

    var propdt3 = new Object();

    propdt3["name"] = 'strsFlag';

    propdt3["value"] = this.getPropertyValue("strsFlag");

    propJSON.push(propdt3);

    console.log("propJson: "+JSON.stringify(propJSON));

    var serviceParams = {

    "properties": JSON.stringify(propJSON)

    };

    var response = Request.invokeSynchronousPluginService("ETInterceptor", "ValidatePropertiesService", serviceParams);

    var invalidFields = new Array();

    array.forEach(response.props, function(item, i){

    var name = item.name;

    var value = item.value;

    if("invalidValue" in item){

    //set to new value.

    invalidFields.push(item);

    }

    });

    if(invalidFields.length > 0){

    return invalidFields;

    }

    });

    }



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 5.  RE: EditPage Closure for Edited EntryTemplate

    Posted Wed September 23, 2020 03:07 AM

    Does a request filter meet your requirement? Validate the values in the request filter and throw an error if some values are invalid?



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 6.  RE: EditPage Closure for Edited EntryTemplate

    Posted Wed September 23, 2020 04:35 AM

    Not exactly. As if after the calculation we are getting the target Property. Then we have to set the propertyValue(Yes that can be done using EditAttributeFilter),Show the customMessage besides that property(so that user gets to know that this property is updated) and it should stay on the same page. And if there is not targetProp then it should save and close the page.



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 7.  RE: EditPage Closure for Edited EntryTemplate

    Posted Wed September 23, 2020 04:46 AM

    Tried the below code in the starting :


    But this works perfectly for Non-Edited ET and because the postCreate fn is called more than 1 it is not able to hold the page(as there is no invalidField value when executed for 2/3 time).


    CustomJS:

    define( ["dojo/_base/declare",

    "ecm/widget/ItemPropertiesPaneExtension", 

    "ecm/widget/CommonPropertiesPane",

    "dojo/aspect",

    "ecm/model/Request",

    "dojo/_base/array", 

    "dijit/registry",

    "dojo/query",

    "dojo/NodeList-dom",

    "dojo/dom-construct"],

    function(declare, ItemPropertiesPaneExtension, CommonPropertiesPane, aspect, Request, array, registry, query, nodeList, domConstruct) {


    /**

    *

    * , used in the property editor, to add a custom section.

    *

    */

    return declare("entryTemplateInterceptorDojo.CustomItemPropertiesPaneExtension", [ ItemPropertiesPaneExtension ], {

    postCreate: function() {

    console.log("ItemPropertiesPaneExtension postCreate!");

    this.inherited(arguments);

    //hide the tab that is created to provide custom attributes ... We don't want it

    // There are no special attribute for this solutions, just hide it!

    query(this.domNode).style("visibility", "hidden");

    ///this is for the EditPropertiesDialog-Right Click Document-->Properties

    var epdWidget;

    array.forEach(registry.toArray(), function(widget,i){

    //console.log(widget.dojoAttachPoint);

    if(widget.dojoAttachPoint.indexOf("_itemEditPane") != -1){

    console.log(widget.id);

    console.log(widget);

    epdWidget = widget;

    }

    });


    if(epdWidget){

    aspect.after(epdWidget, "onCompleteRendering", function(){

    console.log(epdWidget._itemPropertiesPane);

    var ipp = epdWidget._itemPropertiesPane;

    //POC3 ContentListEditPane - start


    //POC3 ContentListEditPane - finish

    //POC5 EditPropertiesDialog - start

    aspect.after(ipp, "validate", function(response,args){

    var invalidFields = new Array();

    if(args[2]){

    var commProps = ipp._commonProperties;


    //we have to this differently than the other because empty properties are not shown

    var propJSON = new Array();

    //For Non-EDITED ET

    if(commProps._propertyEditors){

    var fields = commProps._propertyEditors._fields;

    var i;

    for(i=0; i<fields.length; i++){

    var prop = new Object();

    prop["name"] = fields[i].name;

    prop["value"] = fields[i].value;

    propJSON.push(prop);

    }}

    //For EDITED ET

    else{

    var fields = commProps._view.properties;

    var i;

    for(i=0; i<fields.length; i++){

    var prop = new Object();

    prop["name"] = fields[i].controller.id;

    if(fields[i].controller.get("value")==null){

    prop["value"] ="";}

    else{

    prop["value"] =fields[i].controller.get("value");

    }

    propJSON.push(prop);

    }

    }


    var serviceParams = {

    "properties": JSON.stringify(propJSON)

    };


    var response = Request.invokeSynchronousPluginService("EntryTemplateInterceptor", "ValidatePropertiesService", serviceParams);

    console.log("responsePropsEdit2: "+JSON.stringify(response.props));

    array.forEach(response.props, function(item, i){

    var name = item.name;

    var value = item.value;


    if("invalidValue" in item){

    var invalidValue = item.invalidValue;

    commProps.setPropertyValue(name, value);

    //commProps.setFieldError(name, "Invalid field value", invalidValue);

    invalidFields.push(item);

    }

    //For Non-Edited EntryTemplate.

    if(commProps._propertyEditors){

    console.log("====Inside If===");

    var defaultNode = "<td class='validationSpan'><span style='color:blue'>Property Updated</span></td>"

    var props = commProps._propertyEditors._fields;

    array.forEach(props, function(prop, i){

    var propName = prop.name;

    if(propName === name){

    var node = prop.domNode;

    var propNode = dojo.query(node);

    var parentNode = dojo.query(propNode.parent()[0]);

    var grandParentNode = dojo.query(parentNode.parent()[0]);

    var nlCustom = dojo.query(".validationSpan", grandParentNode[0]);

    if(nlCustom.length == 0){

    domConstruct.place(defaultNode, parentNode[0], "after");

    }

    }

    });

    }

    //For EDITED ET

    else{

    console.log("====Inside Else===");

    var props = commProps._view.properties;

    var defaultNode = "<div class='defaultSpan'><span style='color:blue'>Property Updated</span></div>"

    array.forEach(props, function(prop, i){

    var propName = prop.controller.id;

    if(propName === name){

    console.log("EditITEMS1st=="+propName);

    var node = prop.domNode;

    domConstruct.place(defaultNode,node, "after");

    }

    });

    }

    });


    if(invalidFields.length > 0){

    return invalidFields;

    }

    }


    });

    //POC5 EditPropertiesDialog - finish


    });

    }

    },

    isEnabledFor: function(item) {

    return true;

    }

    });

    });



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 8.  RE: EditPage Closure for Edited EntryTemplate

    Posted Thu September 24, 2020 06:27 AM

    There are 3 parameters in method

    validateAll: function(onEditStatus, onSaveStatus, focus){...}

    onSaveStatus will be 'true' if its a saving event. So I think maybe you can add this check logic in your code to resolve the multipal calling issue?



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 9.  RE: EditPage Closure for Edited EntryTemplate

    Posted Wed September 30, 2020 05:17 AM

    Hi sun, Yes I will try that and see.



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration