Remove default value for a custom property in Advanced search - alfresco

I'm using Alfresco Share and I have a property with a default value
<property name="my:Property1">
<title>Property1</title>
<type>d:text</type>
<multiple>true</multiple>
<default>0</default>
</property>
I have customised the advanced search
<form id="search">
<field-visibility>
<show id="my:Property1"/>
</field-visibility>
<appearance>
<field id="my:Property1" label-id="Property1">
</appearance>
</form>
In Advanced search this property is initially filled with a default value, in my case with 0. Is there any way to remove that value from a search field?

I guess in this case it's best to create a custom Share Form controller like the textfield.ftl.
In the default controller there is a freemarker entry {field.value}. Just remove this entry throughout the template and there won't be any default value shown.

Related

Alfresco multi-select - Disable delete option based on a aspect

In Alfresco, how to disable actions in multiselect drop down. Assume I have delete couple of files. So i am selecting all those files. Now, if any of the selected files have a specific aspect then the delete option should not be enabled. How can I achieve this?
This is what I tried. But no luck.
<action type="action-link" id="onActionDelete" label="menu.selected-items.delete" notAspect="p:hasSecondaryParent" />
My expectation here is if any of the selected items have "p:hasSecondaryParent" aspect then I do not want the "Delete" action in "Selected Items" drop down. All other time it should display
You need to create action evaluator for that. There is out of box has aspect evaluator available which you need to utilize set your custom aspect in that evaluator. Now add that evaluator in config of delete action. Restart server And that's it.
Ex.
<bean id="evaluator.doclib.indicator.exifMetadata" class="org.alfresco.web.evaluator.HasAspectEvaluator">
<property name="aspects">
<list>
<value>exif:exif</value>
</list>
</property>
This is example from out of box context file you need to replace aspect name and id of evaluator. Then Add this evaluator in your action config.
<config evaluator="string-compare" condition="DocLibActions">
<actions>
<!-- Download document -->
<action id="custom-action" type="link" label="customaction">
<evaluator>evaluator.doclib.indicator.exifMetadata</evaluator>
</action>
</actions>

Alfresco: Finding out the type of a piece of content

When I log into http://localhost:8080/alfresco I can navigate to a folder and see four content items. So far so good. But there is no indication as to what the type is of each content type, except for a PDF icon.
Is there a way for me to specify an icon for my custom content types?
I would like the icon to be dependent on my custom type.
<types>
<type name="sc:doc">
<title>Someco Content</title>
<parent>cm:content</parent>
<icon>boring-icon.png</icon> <-- something like this
</type>
<type name="sc:marketingDoc">
<title>Marketing Document</title>
<parent>bnp:doc</parent>
<icon>fancy-marketing-icon.png</icon> <-- something like this
</type>
</types>
If it matters, I am using Alfresco 3.3 (Enterprise).
Take a look here http://docs.alfresco.com/3.4/tasks/kb-code-explorer-add.html
e.g. web-client-config-custom.xml (sc:marketingDocis the Alfresco content type):
<!-- Specify icon for the kb:document instances -->
<config evaluator="string-compare" condition="sc:marketingDoc icons">
<icons>
<icon name="sc_marketingDoc-icon" path="/images/icons/your_custom_icon.gif" />
</icons>
</config>
Are you informed, that Alfresco Explorer is deprecated & you should use Share instead?

Hide default properties and show aspect properties on Share

I'm stuck and I cannot figure out why can achieve this. I'm new to Alfresco, so maybe I'm doing it in a wrong way.
I'm trying to hide default properties on Alfresco Share and only show fields of one of my custom aspects. I mean I want to hide cm:title, cm:name etc.
I'm trying to carry out this by customizing share-config-custom.xml. If I only use <hide> with default properties (without adding custom fields) these are correctly hidden. If I use <show> with my custom properties, both, custom properties and default properties are shown. But the problem is that if I add <hide> and <show> fields, only default fields are shown, although they are seted as hidden.
Here is an example XML:
<config evaluator="node-type" condition="cm:content">
<forms>
<form>
<field-visibility>
<hide id="cm:title" />
<hide id="cm:description" />
<show id="custom:DocumentClass" />
<show id="custom:DocumentDate" />
</field-visibility>
</form>
</forms>
</config>
Thaks in advance.
You can try the following:
Use the hide fields on the cm:content type
Add an extra config and instead of the evaluator="node-type" make it evaluator="aspect"
Add your custom aspect in the new config you just created
If the above doesn't work, try adding replace=true flag to the cm:content config

Alfresco Share - Dynamic rendering of fields in a form

My question is more or less in the title, I added a new data type in my data model.
<type name="moi:montype">
<title>titre type</title>
<parent>cm:content</parent>
<mandatory-aspects>
<aspect>moi:monaspect</aspect>
</mandatory-aspects>
</type>
This one uses a new aspect in which I added a new field
<aspect name="moi:monaspect">
<title>titre aspect</title>
<properties>
<property name="moi:monchamp">
<type>d:text</type>
<mandatory>false</mandatory>
</property>
...
</properties>
</aspect>
I then displayed this new field in a Share form by editing the file share-config-custom.xml.
<config evaluator="node-type" condition="moi:montype">
<forms>
<form>
<field-visibility>
<show id="moi:monchamp"/>
...
</field-visibility>
<appearance>
<field id="moi:monchamp" label="Champ texte" />
...
</appearance>
</form>
</forms>
</config>
Till then, I could test my changes and the new field displays well.
But I would like to go further, and condition for example the display of the field depending on the logged in user's group.
If the logged in user is part of the "priviledged group", then the field is displayed, otherwise it will not, or only in read only mode.
Do you think we can do this ? And how ?
I looked at documentation, but can't find my happiness.
I don't ask for the full solution, but for tips to follow.
Thank you for your help.
Every field has a component renderer. These are implemented using FreeMarker. Most of the time, as in your case, you are relying on the default component renderer. In addition to the options mentioned by Matjaz, another option would be to point the field at a custom renderer. The renderer could inspect the user's group membership and the group required for this field (maybe passed in as an argument, for example), and then decide whether or not to show itself.
There are a few ways to do this.
The easiest way is to make a webscript which returns html for a form field based on if a current logged in user is in your target group. Then add a form control which is only javascript making an ajax call to the webscript and and appending results to your container div which is specified in your form control (ftl).
The second approach you could use is to extend "org.alfresco.repo.forms.processor.AbstractFilter" and implement the functionality in Java. You could probably implement after generate and remove the form field if current logged in user is not in a target group.
Hope this helps a bit... :)
There is no easy way to do this as alfresco does not allow you to set rights on node properties.
Every field has control template, you could define your own. in your template you would define how this property is rendered depending of user type.
<config evaluator="node-type" condition="cm:content">
<forms>
<form>
<appearance>
<field id="cm:title">
<control template="/org/alfresco/components/form/controls/yourOwnFtl.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
Another approach is to write your own share config form evaluator (like node-type ...)
This could check for node type and user permission role/group
let you write one config for each setup (per user group/role)
...
NB! this will one work for forms, so is purely a cosmetical setup, alfresco interface and CIFS etc. will not support this setup.

Is it possible to hide the Mime Type and Tags in Alfresco Share?

We don't want our users editing the Mime Type and Tags when they alter a document's properties. Is there a way to hide them from editing in Alfresco Share?
You can configure the visibility of metadata properties by having a share-config-custom.xml file with a proper field-visibility settings. Something like:
<config evaluator="node-type" condition="cm:content">
<forms>
<form>
<field-visibility>
<hide id="mimetype" for-mode="edit" />
<hide id="cm:taggable" for-mode="edit" />
</field-visibility>
</form>
</forms>
</config>

Resources