cancel
Showing results for 
Search instead for 
Did you mean: 

How to work permissionProperty in InlineEditProperty Widget

janaka1984
Star Contributor
Star Contributor

Hi,

i have used following widget. but i have no idea how to fill "node.permissions.user.Write". currently  i used my own json file to read site data

please give me hint how to do that?

{

                                                              id: "MY_PROJECT_ID",

                                                              name: "alfresco/renderers/InlineEditProperty",

                                                              config: {

                                                                 propertyToRender: "customProperties.stcpSmiley TonguerojectID.value",

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

                                                                 refreshCurrentItem: true,

                                                                 requirementConfig: {

                                                                    initialValue: true

                                                                 },

                                                               

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

mytest.get.json.ftl

{

    "list" : {

                <#assign length = sites?size>

                <#assign skipCount = pagination.skipCount>

                <#assign maxItems = pagination.maxItems>

                <#assign userid=person.properties.userName>

               

                "pagination" : {

                        "count" : "${length}",

                        "hasMoreItems" : "false",

                        "totalItems" : "${length}",

                        "skipCount" :"${skipCount}",

                        "maxItems" : "${maxItems}"

                    },

                "entries" :[

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

                        {

                        "entry" :{

                       

                            "user":"${userid}",

                            "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")},

                            <#if site.node?exists>

                            "node": "${url.serviceContext + "/api/node/" + site.node.storeType + "/" + site.node.storeId + "/" + site.node.id}",

                            "tagScope": "${url.serviceContext + "/api/tagscopes/" + site.node.storeType + "/" + site.node.storeId + "/" + site.node.id}",

                            </#if>

                           

                            "siteRole": "${site.getMembersRole(userid)!""}",

                           

                           

                            "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>

                ]

        }

       

    }

regards

janaka

1 ACCEPTED ANSWER

ddraper
World-Class Innovator
World-Class Innovator

OK... so the currentItem object for each widget in your instance will have access to the following properties:

  • url
  • sitePreset
  • shortName
  • title
  • description
  • isPublic
  • node
  • tagScope
  • siteRole
  • isPublic
  • visibility

The attribute that is closest to what you want is going to be siteRole - but it is not a boolean value and looking at the InlineEditProperty widget source it is using a "truthy" evaluation so any value will be treated as true.

If you have your own service you can add a new attribute to each item to indicate whether or not the user has permission to make a change. I'm assuming that you want to allow the user to edit the site title - only a SiteManager has permission to do this, therefore you could add a new attribute "isSiteManager" which evaluates to "siteRole === "SiteManager".

You could use this new "isSiteManager" attribute as the "permissionProperty"

View answer in original post

7 REPLIES 7

ddraper
World-Class Innovator
World-Class Innovator

The permissionProperty is an optional configuration attribute. If provided the InlineEditProperty widget will attempt to look up the specified property in the currentItem object assigned to it. The the property cannot be found or is false then the current user will not be given access to toggle edit mode. The "node.permissions.user.Write" is an attribute that you would expect to find in the XHR response from a Document Library REST API. It indicates if the user has write permission on that node.

The permissionProperty can be any value, but obviously it makes sense to have a relevant value.

There is an example of this in the unit test application - see the controller here.

although i use permissionProperty: "node.permissions.user.Write" with widget,  i can not see it in "this.currentItem".

do i need to explicitly defined  "node.permissions.user.Write" attribute in any where like unit test application?

ddraper
World-Class Innovator
World-Class Innovator

The currentItem object represent the current context item. The reason it exists is so that when using a widget that iterates over it's widgets model with an array of data (the classing example being the alfresco/lists/views/AlfListView widget) each instance has a different currentItem. So the standard list pattern is that an alfresco/lists/AlfList widget will load an array of data (typically Nodes from the repository) and then pass those to an AlfListView to be rendered. The widgets model in the view is re-rendered for each node in the array, and each model instance will have a currentItem containing the data for the node that it represents.

So when the alfresco/documentlibrary/AlfDocumentList (which extends AlfList) requests data from the DocumentService a Document Library REST API will be called that will retrieve an array of nodes (documents) to display. Each node will have permissions metadata and if you had an InlineEditProperty widget in the view then only the nodes that the current user have write permission to would be editable.

Ultimately you can configure a currentItem yourself - but if you know that the user shouldn't be editing the property, then you shouldn't be using the InlineEditProperty widget. It makes more sense when used within the context of a view.

All of this is described in detail in the Aikau tutorial - and this chapter in particular.

In my case , i use "alfresco/documentlibrary/AlfSitesList", becuase i need to render existing sites and allow admin to edit site details and not allow to normal user to edit .    i couldn't see  "node.permissions.user.Write" attribute on this.currentItem yet.

To configure currentItem, do i need to change mytest.get.json.js file as i pasted at top ?

ddraper
World-Class Innovator
World-Class Innovator

You can configure a currentItem for any widget, however if you're using a list (like the AlfSitesList) then the currentItem will be overridden for each item in the list. The reason that you're not seeing that property is because it almost certainly isn't in the response body of the REST API that you're calling. What URL are you calling to get the data to populate the AlfSitesList?  And what does the data look like for each item in the array of sites?

i used my own service  - url: AlfConstants.PROXY_URI +"xyz/my-project-repo?skipCount=" + skipCount + "&maxItems="+ payload.pageSize,

return following result when call above array

{

"list" : {

"pagination" : {

"count" : "9",

"hasMoreItems" : "false",

"totalItems" : "9",

"skipCount" :"0",

"maxItems" : "25"

},

"entries" :[

{

"entry" :{

"url": "/alfresco/s/api/sites/a1",

"sitePreset": "site-dashboard",

"shortName": "a1",

"title": "A10",

"description": "",

"isPublic": true,

"node": "/alfresco/s/api/node/workspace/SpacesStore/84bb5e8b-7a24-4d05-bfbc-c232b784b88d",

"tagScope": "/alfresco/s/api/tagscopes/workspace/SpacesStore/84bb5e8b-7a24-4d05-bfbc-c232b784b88d",

"siteRole": "SiteManager"

"isPublic": true,

"visibility": "PUBLIC"

}

}

}

ddraper
World-Class Innovator
World-Class Innovator

OK... so the currentItem object for each widget in your instance will have access to the following properties:

  • url
  • sitePreset
  • shortName
  • title
  • description
  • isPublic
  • node
  • tagScope
  • siteRole
  • isPublic
  • visibility

The attribute that is closest to what you want is going to be siteRole - but it is not a boolean value and looking at the InlineEditProperty widget source it is using a "truthy" evaluation so any value will be treated as true.

If you have your own service you can add a new attribute to each item to indicate whether or not the user has permission to make a change. I'm assuming that you want to allow the user to edit the site title - only a SiteManager has permission to do this, therefore you could add a new attribute "isSiteManager" which evaluates to "siteRole === "SiteManager".

You could use this new "isSiteManager" attribute as the "permissionProperty"

Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.