Alfresco Share constraint default empty value - select

i have a simple question.
Is there a simple config file or line that can be edited in order to achieve this:
I need that constraints from Alfresco content model have an empty field (like "unselected") in Advanced Search and Edit Metadata forms.
So a constraint of:
<constraint name="custom:customList" type="LIST">
<parameter name="allowedValues">
<list>
<value>first type</value>
<value>second type</value>
</list>
</parameter>
</constraint>
I need to view these in a "SELECT" form but with the first selection empty, like:
<select>
<value></value>
<value>first type</value>
<value>second type</value>
</select>
Hope I made that clear.
P.S. I don't want to insert a in the custom content model XML file. There should be another way to achieve this.
Thanks to all.

You need to override the presentation logic, i.e. customize or create a new form control template. The default one is implemented in selectone.ftl, you can customize it or start from it for a brand new control template which you can later assign to your metadata field in the forms configuration.

Related

Disable form fields in Sulu's admin frontend after the entity has been persisted

I'd like to connect the key of a category in the Sulu CMS with specific business logic. But therefore the key must not be changeable in the admin area. Is there a way to disable a form field once the entity is persisted?
It's possible to override any form configuration by creating a file with the same name and the same <key> in the config/forms/ directory of your project. In case of the category details form, create a config/forms/category_details.xml file with <key>category_details</key> containing only the properties you want to override, in your case the <property name="key">. You can omit the other properties, because all the form configurations with the same key will be merged together. Then you can use a disabledCondition to configure when this property should be disabled and when it should be possible to edit, in your case something like disaledCondition="!!id", because then the property is only editable, as long as it doesn't have an id, which is only the case when you create a new category. You probably also want to add the mandatory="true" attribute, if your application depends on the key of a category. So the whole file should look like this:
<?xml version="1.0" ?>
<form xmlns="http://schemas.sulu.io/template/template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/form-1.0.xsd"
>
<key>category_details</key>
<properties>
<property name="key" type="text_line" mandatory="true" disabledCondition="!!id">
<meta>
<title>sulu_admin.key</title>
</meta>
</property>
</properties>
</form>

field help text on form

Each share task form has fields. Some of them use icon to provide help text. For example, bpm:workflowPriority, get it. I need to remove this one.
I found, that сode below generates icons, but i cant understand, where the field.help process is runned. How i can hide icons for fields?
<#macro renderFieldHelp field>
<#if field.help?? && field.help?length > 0>
<span class="help-icon">
<img id="${fieldHtmlId}-help-icon" src="${url.context}/res/components/form/images/help.png" title="${msg("form.field.help")}" tabindex="0"/>
</span>
<div class="help-text" id="${fieldHtmlId}-help"><#if field.helpEncodeHtml>${field.help?html}<#else>${stringUtils.stripUnsafeHTML(field.help)}</#if></div>
</#if>
</#macro>
Help icon shows-up by-default when you have a constrain on your field. For example priority is defined as
<!-- Priority for the workflow as a whole -->
<property name="bpm:workflowPriority">
<type>d:int</type>
<default>2</default>
<constraints>
<constraint ref="bpm:allowedPriority" />
</constraints>
</property>
<constraint name="bpm:allowedPriority" type="LIST">
<parameter name="allowedValues">
<list>
<value>1</value>
<value>2</value>
<value>3</value>
</list>
</parameter>
</constraint>
I think help icon is a good idea if you have some constrain on your filed and want your user to select correct values.
You have following options:
If you don't need constraints , remove it from your model. You can override bpm:xxxxxx constraints by extending base model
You can look at BPMEngine code and change the template which generate help icon
Help icon is generated with class "help-icon" like :
span class="help-icon"
SO you can override form.css and hide this span. Something like this will work:
.form-container .help-icon {
visibility: hidden;
}
But this will remove all help icons from all the share forms, unless you change form divs and add some intelligence in your css selector.
Hope this helps.

OpenERP modeling / views: related object inline

I have installed the built in OpenERP 6.1 module crm.
As a result, I now have res.lead active and visible at "Sales->Opportunities".
I'd like to edit this object / view to show the partner's billing address.
Since I want to do this on the Opporunities form, there is already a partner_id.
Copying another module, I defined my new module like this:
class crm_lead(osv.osv):
_name = _inherit = 'crm.lead'
_columns = {
'billing_address_id': fields.many2one('res.partner.address', 'Partner Billing Address', domain="[('partner_id','=',partner_id),('type','in',['invoice', 'default'])]"),
}
And I changed my update_xml to:
<record model="ir.ui.view" id="crm_case_form_view_oppor">
<field name="name">Opportunity form (inherit)</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="arch" type="xml">
<data>
<separator string="Details" position="replace" />
<field name="description" position="replace">
<group colspan="2" col="4">
<separator colspan="4" string="Billing" />
<field widget="one2many_list" mode="form,tree" name="billing_address_id" colspan="4" nolabel="1" />
</group>
<group colspan="2" col="4">
<separator colspan="4" string="Details" />
<field name="description" nolabel="1" colspan="4" />
</group>
</field>
</data>
</field>
</record>
The problem is that the related object shows all the related fields (as I'd guess would be expected). In particular, it shows the partner_id and company fields, which I'd like to hide since they should default to / inherit from this opportunity (or the linked partner).
How can I hide these fields? I can't simply add a bunch of 'related' fields, as there is potentially more than one billing address.
Thanks for the help!
Edit: To be clearer, an opportunity should only have a single chosen billing address, chosen from the partner's invoice / default addresses. It should be displayed inline to allow easy editing.
There are a couple of ways to specify the view for related fields like this. You can use the context like this:
<field
name="order_line"
colspan="4"
nolabel="1"
context="{'form_view_ref': 'module.view_id', 'tree_view_ref': 'model.view_id'}"/>
You can also specify the whole view for the child record as a subview within the parent view like this:
<!-- <=== order_line is a one2many field -->
<field name="order_line" colspan="4" nolabel="1">
<form>
<field name="qty"/>
...
</form>
<tree>
<field name="qty"/>
...
</tree>
</field>
OK, I was a bit confused because you put a one2many widget on a many2one field.
If you want to control how a one2many field is displayed, use the subview or context methods I mentioned in my other answer.
If you want to control how a many2one field is displayed, you might be able to use related fields that pull fields from the record you selected, but I doubt it. Read-only might work, but I don't think it makes sense to edit multiple related fields and be able to change the selected record. You might be able to hack together some function fields with a store function that lets you write back to the related record, but it seems like it would really confuse your users.
On any OE Relation field you can define the Intenal View like :
<field name="" mode="tree,form">
<!--Internal tree view for your Relation field model-->
<tree>
</tree>
<!--Internal Form view for your Relation field model-->
<form>
</form>
</field>
Example Under Addons 1 Click to Example 2 Click to See Example
Hope this will help you,.
Now if yo uwan to shoe specific detail on your m2o file then we have some optional way also where you have to over the def name_get of your relational model, namge get look like :
name_get(cr, user, ids, context=None)
Returns the preferred display value (text representation) for the records with
the given ids. By default this will be the value of the name column, unless the
model implements a custom behavior. Can sometimes be seen as the inverse function
of name_search(), but it is not guaranteed to be.
Rtype : list(tuple)
Return : list of pairs (id,text_repr) for all records with the given ids.
So here in this method you can decide what string you want to show your relational field.
Example
This will fix your problem partially i guess.

How do I manually edit table mappings in ADO.NET in Visual Studio 2010?

I can't seem to find the answer to what I think is an easy question. I have a Entity model I just created and I want to set the name of the table and the columns by hand. I can see the "mapping details," but how do I edit them or add to them?
It appears the answer is, you can't without going into the XML. You can use the Entity Framework Power Pack to customize the templates for generation, but there's no direct GUI for editing the mappings.
I open the folder where edmx file in, look into all files in it, and find a possible solution.
I advice install the notepad++ first, then right click on the Edmx File in file explorer, and click Edit with Notepad++ then the xml file content will show, or you can directly open the Edmx file by notepad.exe
You'll see something like this on the top part of the file:
<EntityType Name="DataTableName">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="DataColumn1" Type="bigint" Nullable="false" />
<Property Name="DataColumn2" Type="datetime" Nullable="false" />
<Property Name="DataColumn3" Type="nvarchar" MaxLength="255" />
<Property Name="DataColumn4" Type="nvarchar" MaxLength="255" />
</EntityType>
What I want to do is remove DataColumn4, I first open the Edmx File in VS and directly click on the column name in the VS UI and press Delete on the keyboard, and you'll find that in the Mapping Detail Window, the right side of DataColumn4 property will be empty, but in the left side the DataColumn4 still exist.
Then, Open the edmx file using Step 1, remove the property in the Step 2 and save the file.
Remove--> <Property Name="DataColumn4" Type="nvarchar" MaxLength="255" />
Restart visual studio, and open the edmx again you'll find DataColumn4 disappear, and I try connect to DB and manipulate Data, works fine.
If you have your .edmx file open in Visual Studio, you should be able to simply right-click on a table or a column in the table and choose 'rename'. Once you change the name it will be reflected in the Mapping Details window.
You can edit the names easily... just click on the name (when the item is already selected) in the 'class diagram' or the table representation in the edmx file and type the new name. If the text does not become selected and editable when you click on it, you can press F2, the standard Windows key to raname an object. Note: you cannot edit the name in the mapping window.
After editing the names, you can right click on the entity and select 'Generate Database from Model...' option to update the names in the database.
Also, see this post for more information.
Here a solution that works on VS 2010. If you Rename an entry, afterwards run "Generate Database from Model..." two times. IN the first run, the mapping is adjusted but you still get a (let me say "compiler") error. In the second run, everything is fine.
I just tested it two times. Worked perfectly.

Jasper report using same template to render in CSV and PDF formats

We are using one template to render the report in CSV and PDF format. But the problem is we need to have report split into pages in PDF but not in CSV. Is it possible to alter the rendering options based on the format in one template. So that we have CSV without pagination information and PDF divided into page. In such a case 2 separate templates one for CSV and one for PDF should be used? or this can be achieved using one template?
Finally found the answer. In the template following properties need to be set
<property name="net.sf.jasperreports.export.csv.exclude.origin.keep.first.band.columnHeader" value="columnHeader" />
<property name="net.sf.jasperreports.export.csv.exclude.origin.band.columnFooter" value="columnFooter" />
<property name="net.sf.jasperreports.export.csv.exclude.origin.band.pageFooter" value="pageFooter" />
<property name="net.sf.jasperreports.export.csv.exclude.origin.band.lastPageFooter" value="lastPageFooter" />
<property name="net.sf.jasperreports.export.csv.exclude.origin.band.summary" value="summary" />
Using JRCsvMetadataExporter solved similar problem. This class extracts the data from the template ignoring the rendering part. Check out the sample here