cancel
Showing results for 
Search instead for 
Did you mean: 

How to use customproperty with aikau InlineEditProperty

janaka1984
Star Contributor
Star Contributor

Hi,

i need to use customProperty ('customProperties.stcpSmiley TonguerojectID.value') with this.originalRenderedValue = this.getFormWidget().getValue()[this.postParam]; in InlineEditProperty aikau widget

this.postParam = 'customProperties.stcpSmiley TonguerojectID.value';

this.originalRenderedValue = this.getFormWidget().getValue()[this.postParam];

Problem is i can not use this dot notation to fetch data , it return output  'undefined '

Please help me to handle this..

Regards

Janakaa

1 ACCEPTED ANSWER

Hi Dave draper,

i could manage issue with custom site property (dot notation) by using standard Inlineeditproperty widget as follow

{

                                                              id: "MY_PROJECT_ID",

                                                              name: "alfresco/renderers/InlineEditProperty",

                                                              config: {

                                                                 propertyToRender: "customProperties.stcpSmiley TonguerojectID.value",

                                                                 permissionProperty: null,

                                                                 refreshCurrentItem: true,

                                                                 requirementConfig: {

                                                                    initialValue: true

                                                                 },

                                                                 postParam:"prop_stcp_ProjectID",

                                                                 publishTopic: "ALF_CRUD_UPDATE",

                                                                 publishPayloadType: "PROCESS",

                                                                 publishPayloadModifiers: ["processCurrentItemTokens"],

                                                                 publishPayloadItemMixin: false,

                                                                 publishPayload: {

                                                                   

                                                                    url:"ivory/vdr-project-update-repo/{shortName}",

                                                                    isUpdate: "project-id",                                                                

                                                                    noRefresh: true,

                                                                    successMessage: I18nUtils.msg("","update.successMessage")

                                                                 }

                                                              }

                                                           }

Best  Regards

Janaka

View answer in original post

9 REPLIES 9

ddraper
World-Class Innovator
World-Class Innovator

Could you provide a bit more context as to how you're trying to use the InlineEditProperty widget?

It's purpose is to both display and support the editing of an attribute on Node. As such you provide it with a "propertyToRender" (the display value) and then a "postParam" the property that will be sent in the POST request to update the value. By default (see the "setDefaultPublicationData") it will use the standard forms processing API to try and update the property represented.

So for example if you look at a sample configuration in the AlfSimpleView, it looks like this:

{

   id: "SIMPLE_VIEW_NAME",

   name: "alfresco/renderers/InlineEditPropertyLink",

   config: {

      propertyToRender: "node.properties.cm:name",

      permissionProperty: "node.permissions.user.Write",

      postParam: "prop_cm_name",

      renderSize: "large"

   }

},

So it's posting the updated value on the forms processing API using "prop_cm_name", but will have rendered the "node.properties.cm:name" attribute.

It is possible to reconfigure the publishTopic and publishPayload used to update the value through configuration (see the unit test application page source for examples of this) - this gives you complete flexibility on how the edits are persisted. There is also the configuration option "refreshCurrentItem" that will update the item in context (an extension point function is provided if you need to update more than just the value (the _ItemLinkMixin provides a good example of this).

But it's important to remember that this is a self contained widget for rendering and editing a single property... your example suggests that you're trying to access the data programmatically (maybe from a custom widget) which might not be the best approach to take - so providing some context on what you're doing would definitely be useful to assist you.

You may want to review the tutorial chapter on how to use this widget.

Hi Dave Draper,

i defined custom property on content model

<import uri="http://www.alfresco.org/model/sitecustomproperty/1.0" prefix="stcp"/>

<property name="stcpSmiley TonguerojectName">

                <title>Project Name</title>

                <type>d:text</type>

                <!-- <default>Enter Project Name</default> -->

</property>

When create new site , it is possible to create above property with existing site property.

"customProperties":,

"{http:\/\/www.alfresco.org\/model\/sitecustomproperty\/1.0}ProjectName":

{

"name": "{http:\/\/www.alfresco.org\/model\/sitecustomproperty\/1.0}ProjectName",

"value": "HAI",

"type": "{http:\/\/www.alfresco.org\/model\/dictionary\/1.0}text",

"title": "Project Name"

}

i have used custom widget which extends "alfresco/renderers/InlineEditProperty"

name: "myWidget/CustomInlineEditProperty",

          config: { 

                   propertyToRender:  "customProperties.stcpSmiley TonguerojectID.value",

                   refreshCurrentItem: true,

                   requirementConfig: {

                              initialValue: true

                    },

                    postParam: "prop_stcp_ProjectID",

                    publishTopic: "ALF_UPDATE_PROJECT_DETAILS_CELL",

                    publishPayloadType: "PROCESS",

                    publishPayloadModifiers: ["processCurrentItemTokens"],

                    publishPayloadItemMixin: true,

this dotnotation can render stored data. but when i try to update data, dot notation can not be handled with this.postParam. (this.getFormWidget().getValue()[this.postParam]Smiley Wink of onSaveSuccess().

although new value  is stored , it does not render at that time (cell is empty)

thanks

regards

janaka

ddraper
World-Class Innovator
World-Class Innovator

So a few questions...

  1. Do you actually have something subscribing to the "ALF_UPDATE_PROJECT_DETAILS_CELL" topic that is being published?
  2. Why are you prefixing your topic with "ALF_" it's short for "ALFRESCO" - it's probably better to namespace your topics with something relevant to your own company/project
  3. Why have you extended the InlinePropertyEdit widget and what functions have your overridden or extended in it?

1) - I update new value by subscribing  'ALF_UPDATE_PROJECT_DETAILS_CELL' which contains URL to call custom update service

2) - i have made mistake by using ALF_ instead need to use custom prefix.

3) - i couldn't manage "customProperties.stcpSmiley TonguerojectID.value" by applying into this.postParam in onSaveSuccess().

therefore. i override following function and set default value to this.postParam

postMixInProperties: function alfresco_renderers_InlineEditProperty__postMixInProperties() {

         this.postParam = "currentVal";

         this.inherited(arguments);

}also override following function to make access

updateSaveData: function alfresco_renderers_InlineEditProperty__getSaveData(payload) {

          this.inherited(arguments);

           var param = {customProperties:{

                       "stcpSmiley TonguerojectID":{

                               value:"NewID"

                   }}}

            lang.mixin(payload, param);

}

ddraper
World-Class Innovator
World-Class Innovator

OK... so just to clarify - the update is persisted, it's just that the new value isn't rendered again?

If this is the case it's likely to be because you're changing the value of the configured postParam to "currentVal" ??  If you add a break point in the "onSaveSuccess" function, what values are actually being returned from a call to this.getFormWidget().getValue()  ?

Maybe you need to consider overriding the "updateCurrentItem" function as well to ensure that the currentItem object has the new value?  It would probably also be a good idea to set a break point on both the "onSaveSuccess" and "reRenderProperty" functions to see what is happening when the new value is trying to be rendered.

Without having complete access to your environment, making debugging suggestions like this is the best I can do.

if i use default value "currentVal" for this.postParam,   new value is rendered.

this.getFormWidget().getValue()  returns  currentVal :"New Value"

but this can not be used to save new value.  To do that, i override  following function

updateSaveData: function alfresco_renderers_InlineEditProperty__getSaveData(payload) {

          this.inherited(arguments);

           var param = {customProperties:{

                       "stcpSmiley TonguerojectID":{

                               value: this.getFormWidget().getValue().currentVal

                   }}}

            lang.mixin(payload, param);

}

i need to know whether i use correct way to do that now?

ddraper
World-Class Innovator
World-Class Innovator

postParam should be the attribute that you assign to the request body that you send to be updated - it shouldn't be the actual value - it is the name of the parameter to be posted, not the value to be posted.

Is it possible that your custom service isn't interpreting the data being published correctly... you really shouldn't need to be changing postParam - it should be fixed for the API that is ultimately being called. The reason that propertyToRender and postParam are set to different properties is because they frequently differ - the rendered property is almost always different to the property PUT or POST on the API.

I really don't think that you need to be extending the InlineEditProperty widget, I would suspect all the work can be achieved in your custom service. Have you reviewed the Aikau unit test application and the many examples where this is used? Maybe you can post your custom service code for me to take a look at?

custom service-

registerSubscriptions: function alfresco_services_CustomSiteService__registerSubscriptions() {

       

         this.alfSubscribe("CUST_GET_SITES", lang.hitch(this, this.getVdrSites));

         this.alfSubscribe("CUST_UPDATE_PROJECT_DETAILS_DROPDOWN", lang.hitch(this, this.updateProjectDropdown));

         this.alfSubscribe("CUST_UPDATE_PROJECT_DETAILS_CELL", lang.hitch(this, this.updateProjectCell));

}, 

getVdrSites: function alfresco_services_customSiteService__getVdrSites(payload) {

         // skipCount is the number of entries to skip, not pages so needs some maths:

         var skipCount = (payload.page - 1) * payload.pageSize;

         this.serviceXhr({         

            url: AlfConstants.PROXY_URI +"org/my-project-repo?skipCount=" + skipCount + "&maxItems="+ payload.pageSize,

            method: "GET",

            alfTopic: payload.responseTopic

         });

      },

updateProjectDropdown: function alfresco_services_customSiteServiceVdr__updateProjectDropdown(payload) {

         var shortName = lang.getObject("shortName", false, payload);

         if (shortName)

         {

            var url = AlfConstants.PROXY_URI + "org/my-project-update-repo/" + shortName;

            this.serviceXhr({

               url: url,

               method: "PUT",

               data: payload,

               alfTopic: payload.responseTopic

            });

         }

         else

         {

            this.alfLog("warn", "A request was made to update a site but no 'shortName' attribute was provided", payload, this);

         }

      },

updateProjectCell: function alfresco_services_SiteServiceVdr__updateProjectCell(payload) {

         var shortName = lang.getObject("shortName", false, payload);

         //payload.responseTopic = this.generateUuid();

         //payload.alfPublishScope = "MANAGE_SITES_SITE_SERVICE_";

         if (shortName)

         {

            var url = AlfConstants.PROXY_URI + "org/my-project-update-repo/" + shortName;

            this.serviceXhr({

               url: url,

               method: "PUT",

               data: this.clonePayload(payload),

               alfTopic: payload.alfResponseTopic,

               successMessage: this.message(payload.successMessage || "crudservice.generic.success.message"),

                successCallback: this.refreshRequest,

                failureMessage: this.message(payload.failureMessage || "crudservice.generic.failure.message"),

                failureCallback: this.failureCallback,

                callbackScope: this

            });

         }

         else

         {

            this.alfLog("warn", "A request was made to update a site but no 'shortName' attribute was provided", payload, this);

         }

      },

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

following are defined as alfresco repo project

1)

i have used my-project-repo.json.ftl to read existing site details and its custom property

{

    "list" : {

                <#assign length = sites?size>

                <#assign skipCount = pagination.skipCount>

                <#assign maxItems = pagination.maxItems>

               

                "pagination" : {

                        "count" : "${length}",

                        "hasMoreItems" : "false",

                        "totalItems" : "${length}",

                        "skipCount" :"${skipCount}",

                        "maxItems" : "${maxItems}"

                    },

                "entries" :[

                    <#list sites?sort_by("shortName") as site>

                        {

                        "entry" :{

                       

                            "url": "${url.serviceContext + "/api/sites/" + site.shortName}",

                            "sitePreset": "${site.sitePreset}",

                            "shortName": "${site.shortName}",

                            "title": "${site.title}",

                            "description": "${site.description}",

                            "isPublic": ${site.isPublic?string("true", "false")},

                            "visibility": "${site.visibility}"

                            <#if site.customProperties?size != 0>,

                            "customProperties":{

                                <#list site.customProperties?keys as prop>

                                <#assign propDetails = site.customProperties[prop]>

                                <#assign s = prop>

                                "${s?replace('{http://www.alfresco.org/model/sitecustomproperty/1.0}', 'stcp:')}":

                                {

                                    "name": "${prop}",

                                    "value":

                                    <#if propDetails.value?is_enumerable>

                                    [

                                    <#list propDetails.value as v>

                                    "${v?string}"<#if v_has_next>,</#if>

                                    </#list>

                                    ]

                                    <#else>

                                    "${propDetails.value?string}"

                                    </#if>,

                                    "type": <#if propDetails.type??>"${propDetails.type}"<#else>null</#if>,

                                    "title": <#if propDetails.title??>"${propDetails.title}"<#else>null</#if>

                                }

                                <#if prop_has_next>,</#if>

                                </#list>

                            }

                            </#if>                           

                        }

                        }

                        <#if site_has_next>,</#if>

                       

                    </#list>

                ]

        }

    }

------------------------------------------

2).

my-project-update-repo.get.js

function main()

{

    // Get the site

    var shortName = url.extension;

    var site = siteService.getSite(shortName);

    var siteNode = site.node;

   

    if (site != null)

    {   

        // Update the Project Name        

        if (json.get("isUpdate") == "project-name")

        {          

           siteNode.properties["stcpSmiley TonguerojectName"] = json.get("customProperties").get("stcpSmiley TonguerojectName").get("value");

        }

        // Update the Project ID       

        if (json.get("isUpdate") == "project-id")

        {          

           siteNode.properties["stcpSmiley TonguerojectID"] = json.get("customProperties").get("stcpSmiley TonguerojectID").get("value");

        }

        // Update the Project Owner

        if (json.get("isUpdate") == "project-owner")

        {          

           siteNode.properties["stcpSmiley TonguerojectOwner"] = json.get("customProperties").get("stcpSmiley TonguerojectOwner").get("value");

        }

        // Update the Project Status       

        if (json.get("isUpdate") == "project-status")

        {                  

           siteNode.properties["stcpSmiley Tonguehase"] = json.get("ProjectStatus");

        }

       

        siteNode.save();

        

        //site.node.save();

        // Save the site

        site.save();

       

        // Pass the model to the template

        //model.site = site;

    }

    else

    {

        // Return 404

        status.setCode(status.STATUS_NOT_FOUND, "Site " + shortName + " does not exist");

        return;

    }

}

main();

Hi Dave draper,

i could manage issue with custom site property (dot notation) by using standard Inlineeditproperty widget as follow

{

                                                              id: "MY_PROJECT_ID",

                                                              name: "alfresco/renderers/InlineEditProperty",

                                                              config: {

                                                                 propertyToRender: "customProperties.stcpSmiley TonguerojectID.value",

                                                                 permissionProperty: null,

                                                                 refreshCurrentItem: true,

                                                                 requirementConfig: {

                                                                    initialValue: true

                                                                 },

                                                                 postParam:"prop_stcp_ProjectID",

                                                                 publishTopic: "ALF_CRUD_UPDATE",

                                                                 publishPayloadType: "PROCESS",

                                                                 publishPayloadModifiers: ["processCurrentItemTokens"],

                                                                 publishPayloadItemMixin: false,

                                                                 publishPayload: {

                                                                   

                                                                    url:"ivory/vdr-project-update-repo/{shortName}",

                                                                    isUpdate: "project-id",                                                                

                                                                    noRefresh: true,

                                                                    successMessage: I18nUtils.msg("","update.successMessage")

                                                                 }

                                                              }

                                                           }

Best  Regards

Janaka