Change root element in association picker control in Alfresco Share - alfresco

I'm using Alfresco Share 4.2c and I have to change a root node of an association picker. When I change some property of my document I want that picker directly points to the folder where my document is placed (parent of my document).
My problem is how to access nodeRef of document from association.ftl. I think that one solution is to use page.url.args.nodeRef, find his parent and add pass it to parameter rootNode. I'm not satisfied with that because it works only if I'm on Edit metadata page and my clients also what to use popup window to manage properties which appears on click Edit Properties link.
In that case I don't have nodeRef of document in url.
Do you have any idea how to solve this?

The best way is to a NodeLocator fur such purposes: http://docs.alfresco.com/4.1/concepts/node-locator-intro.html
the ancestor NodeLocator should be sufficient for your needs. Try the following setting in your form configuration:
<field id="my:association">
<control>
<control-param name="startLocation">{ancestor}</control-param>
</control>
</field>

Related

How to edit Teaser's Tab options order on AEM?

I'm (trying) customizing the Teaser component on .content.xml to reach out to my requirements but I don't understand how I can set up an order to tabs options. The best solution would be to write some logic to hide/unhide the Teaser's fields based on the parent component, but I don't know how to do it yet. Meanwhile, I'm editing the XML file.
Options:
Image
Metadata
Text
Link & Actions
The first thing stranger is that I've written the code to show only three options but on AEM Editor keeping showing all options, with "Link & Actions" not declared on .XML. As you can see in the print below.
Path file: ui.apps/.../components/teaser/_cq_dialog/.content.xml
The second thing is that I want to put "Link & Actions" options as the last option on the tab bar. So, how make it?
The following print is my current behavior.
The behaviour you notice is due to Sling's Resource Merger feature. The same feature can be leveraged to achieve everything that you want to do.
To answer your question in parts
You see Links & Actions tab even though you've not defined it in your dialog because your component extends the OOB teaser component and the Sling Resource Merger would merge the options in the parent and the child dialogs to create the final dialog that is presented to the author.
This allows easily extending the features of the parent and only defining the custom properties within your dialog. For e.g. If you only need to add a new tab called Metadata in your teaser component it is enough to just create configurations for that new tab in your custom component and the rest of the configs will flow through from your parent component.
<tabs
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/tabs">
<items jcr:primaryType="nt:unstructured">
<metadata ...>
</items>
</tabs>
You can then use the following properties provided by Sling to further customise the ordering of the properties / tabs or remove / hide some properties.
sling:hideProperties - Specifies the property, or list of properties, to hide. The wildcard * hides all.
sling:hideResource - Indicates whether the resources should be completely hidden, including its children.
sling:hideChildren - Contains the child node, or list of child nodes, to hide. The properties of the node will be maintained. The wildcard * hides all.
sling:orderBefore - Contains the name of the sibling node that the current node should be positioned in front of.
Now to answer your second part, if you want to hide the Links & Actions tab completely in your component, then create a node called actions (same name as parent) and then set the property sling:hideResource to true
<tabs
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/tabs">
<items jcr:primaryType="nt:unstructured">
<metadata ...>
<actions
jcr:primaryType="nt:unstructured"
sling:hideResource="{Boolean}true"/>
</items>
</tabs>
Alternatively, if you don't want it removed but just moved to the end, just create a node called actions and place it after all the other nodes or use the sling:orderBefore property to specify the order of the tabs. An example of order before shown below where metadata tab appears second, followed by text and then links and actions.
<tabs
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/tabs">
<items jcr:primaryType="nt:unstructured">
<metadata
jcr:primaryType="nt:unstructured"
sling:orderBefore="text"
...>
<text
jcr:primaryType="nt:unstructured"
sling:orderBefore="actions"/>
</items>
</tabs>
EDIT: How do you know what tab names to use?:
Sling Resource Merger works when you overlay a component (think of it like inheritance in Java where you are extending another class).
You can overlay an existing component using the property sling:resourceSuperType on the component node. For e.g., this is the screenshot of my teaser component which is overlaying the OOB teaser component core/wcm/components/teaser/v1/teaser.
Since it is not an absolute path, the order of preference for seaching the component in the repository is /libs/ followed by /apps/
So, searching under /libs/ I was able to find the component at /libs/core/wcm/components/teaser/v1/teaser and expanding the dialog showed the following tabs. The same names need to be used in our component to override the position or visibility or any other sling merger features.
I would recommend understanding the inheritance concepts of Sling in general to make it easier working with AEM.

Alfresco custom model with sys:base as parent is having property cm:name

I have created a custom model with parent as sys:base and modified the share-config-custom.xml so that I can create the content from the share. After creating the content from share am unable to see the content in share or explore. Instead am getting the below error when checking from document details page.
The item cannot be found. Either you do not have permissions to view the item, it has been removed or it never existed.
In Node browser I can see cm:name in the property field. But as per the alfresco svn, sys:base is not having the property cm:name.
<type name="sys:base">
<title>Base</title>
<mandatory-aspects>
<aspect>sys:referenceable</aspect>
<aspect>sys:localized</aspect>
</mandatory-aspects>
</type>
Can someone please tell how the custom model get the cm:name property?
Also I want to delete the content. Is there any way to delete that content from share or explore?
Thanks in advance!
To delete your content, call the webscript
/slingshot/doclib/action/aspects/node/{store_type}/{store_id}/{id}
and send the sys:temporary as an argument.

Is it possible to inherit cm:folder properties to its content in alfresco?

I have the following in my model.xml
<type name="abc:Policy">
<title>abc Policy</title>
<parent>cm:folder</parent>
<archive>true</archive>
<mandatory-aspects>
<aspect>abc:policyProperties</aspect>
</mandatory-aspects>
</type>
abc:policyProperties has the following.
<aspect name="abc:policytProperties">
<title>abc Policy Properties</title>
<properties>
<property name="abc:dated">
<title>Dated</title>
<type>d:date</type>
</property>
</properties>
</aspect>
A user can upload a document to the abc:Policy folder. But there is no reference to that document currently in the model. How to make it possible for any document within this folder to inherit abc:dated and display it within its properties in Alfresco-share?
It sounds like what you want to do is have a document inherit a property value from the same-named property on the document's parent folder.
One way to do this would be to write a folder rule in JavaScript that reads the property and sets it on a document. You can configure the rule to do that when the document is created or when it is updated.
Here's a quick example that does this with the out-of-the-box cm:title property:
var title = document.parent.properties['cm:title'];
if (title != undefined) {
document.properties['cm:title'] = title;
document.save();
}
You can put that script in a file called "inherit-title.js" under Data Dictionary/Scripts, then configure your rule to execute the script. Any time a new object is created in that folder it will get the current title.
You can modify this to work with your content model.
Note that unless you configure the rule to work on updates, the value on the child will never be updated. So if the title changes in the folder it will not change in its children. And if a child is changed it will not pull the latest value from the parent. You could get that to happen through some rule config and script tweaks, but be mindful of the performance cost.
If you wanted to make this happen more universally, i.e., without setting this up as rules on individual folders, you could write a behavior to do it (tutorial).
If you refer to alfresco content model definitions contentModel.xml
you will find that, cm:folder has default child association cm:contains for the type sys:base. So you are able to add node of type that extends sys:base.
Each document added to your folder abc:Policy goes as a child. And the aspect is applied to parent i.e. abc:Policy. So abc:dated is a property of abc:Policy and not of the document.
One thing you can do is, define one more type that extends cm:content and add is as a child association to your abc:Policy also apply the aspect to it, then you can get the abc:dated as a property of your document

Maximo Anywhere 7.6 - Adding additional field to a list item - Error: Cannot add an item to layout

We are trying to add a field in the SR List screen of Service Request app. We are able to see the additional field's data in the response and see the value in the detail screen. But the same is not visible in the list screen even after we made changes in the WorkListItem.xml. When we looked at the developer logs, we saw an error as below.
Cannot add an item to layout [generated_application_ui_layout_small_WorkListItem_0]. Position [item7] does not exist.
We executed build.xml and also artifact-processor.xml. But if is of no use as we are still getting the error.
Below are code snippets added in the app.xml & WorkListItem.xml.
app.xml
<listItemTemplate id="ServiceRequest.MyReportedSR_serviceRequest_listItemTemplate_WorkListItem" layout="WorkListItem">
.
.
<listtext id="ServiceRequest.MyReportedSR_serviceRequest_WorkListItem_internalpriority" layoutInsertAt="item7" resourceAttribute="internalpriority"/>
</listItemTemplate>
WorkListItem.xml
<layout>
.
.
<row id="row_3">
<column colspan="10" columnid="item7" id="item7_column"/>
</row>
</layout>
Please let us know if we are missing any steps.
Regards,
Karthik
The layoutInsertAt field should point to the id within the layout which is id="item7_column", not "item7".
It looks like the standard Service Requests app has issue when it is referring the Worklistitem layout xml. I have found that there is field mapped to item2 in app.xml but item2 is not present in the layout xml.
I have created a custom layout file copied from the WorkListItem and provided a different name. It worked after referring the new layout xml which included item2(For existing field) and item7 (New Field which we wanted to display) added in the layout xml.

ReactJS: how to access all child components in parent component?

Suppose I've got comments list component with comments components. I wanna implement method that will return all comments components. I assigned to each comment component same ref:
<comments>
<comment ref="myComments" text="abc" />
<comment ref="myComments" text="efg" />
</comments>
I thought I can access all my components by this.refs.myComments but it doesn't work - it returns only last comment component.
What's the correct way to access all comment components?
There is no correct way to do that.
Your view is a representation of your data, so if you want the text for all comments, look at the data.
If you want to update the comments, update the data.
Pulling data out of the view, or manually manipulating the view defeats the purpose of react.

Resources