Adding fields dynamically to Share form - alfresco

I want to add a text field for each file that is added to the attached package items in alfresco to write notes regarding each file, is it possible to do?

I have implemented something that could be reused for your use case.
You can define a property with multiple values that will contain the list of notes associated with each attachment.
There is a simple trick to post a property with multiple values: add "[]" to the name of the property. For example:
<input id="template_x002e_edit-metadata_x002e_edit-metadata_x0023_default_prop_someco_notes_0"
name="prop_someco_notes[]"
tabindex="0"
type="text"
value="Meeting minutes"
title="Notes"
noderef="workflow://...."
>
<input id="template_x002e_edit-metadata_x002e_edit-metadata_x0023_default_prop_someco_notes_1"
name="prop_someco_notes[]"
tabindex="1"
type="text"
value="Meeting minutes"
title="Notes"
noderef="workflow://...."
>
As you can see, the name of the input ends with []. Both input textfields have the same name.
The Alfresco Form Engine will consider these two inputs as the value for the property with multiple values: "someco:notes".
The bigger problem is that you need to generate this html with some smart javascript and free marker template.
You can write a custom free marker template to render the initial html: if a user opens a task on which documents have been already attached, you will need to generate the list of inputs using a custom control (you can of course start from textfield.ftl).
It won't be easy to generate the initial list because unfortunately Alfresco returns the list of values as a single comma separated value.
You can customise the webscript that injects the model in the free marker template "org.alfresco.web.scripts.forms.FormUIGet" to pass an array instead of a csv.
A quicker and dirtier solution is to split the csv value. In share-config-custom.xml, you can specify what textfield.ftl show use as a separator instead of the comma.
When a user adds/remove elements from the package, you can intercept the update and add/remove the correspondent note. Notice that I have added the filed "noderef" to each input so it is possible to know the relation between the notes and the nodes in the package.
UPDATE:
For the associations (used for example to define the package in a workflow task), Share uses a javascript library called "object finder" (or "object picker"). This library fires an event called "formValueChanged" that you can intercept:
YAHOO.Bubbling.fire("formValueChanged",
{
eventGroup: this,
addedItems: addedItems,
removedItems: removedItems,
selectedItems: selectedItems,
selectedItemsMetaData: Alfresco.util.deepCopy(this.selectedItems)
});

Related

How can I translate input use ngx-translate?

<input type="text" name="title" [(ngModel)]="dataAdd.titleEN">
<input type="text" name="title" [(ngModel)]="dataAdd.titleFR">
I need to show two title but different language
If I click of button en show text in English or fr show text in French
and save in variable string
Note: I need unique variable for unique data insert in Firestore
dataAdd = {
titleEN: '',
titleFR: '',
}
this.translateList = this.afs.collection('translates');
this.translateList.doc('en').set({
TITLE_FOR_RENT: this.dataAdd.titleEN,
});
this.translateList = this.afs.collection('translates');
this.translateList.doc('fr').set({
TITLE_FOR_RENT: this.dataAdd.titleFR,
});
In my opinion you have assumed wrongly the usage of ngx-translate, this package is used in order to support multiple pre defined languages , for example if you want to support en and fr , beforehand you must have a .json file for each desired language, with the following KvP structure => where the key is a universal key (some string that is the same in each json file), which is used to map values to the translations from the .json files. You can check out the official StackBlitz Demo for detailed example of the usage.
In order to achieve the result that you described, I would suggest to use something like Cloud Translation API provided by Google, which is able to translate live user inputs (or whatever you pass to the API), after that depending on your strategy you might display the response from the API directly to the client, or load it first in the ngx-translate and then display it to the client.
Note:
I would go for the first option, because I assume in your case filling the browser memory is unnecessary (because when loading the translation trough in ngx-translate you are just feeling one big js object behind the scenes)

mvcgrid.net unable to use toolbar

I'm working on a website with a feature that can sort users.
I'm using mvcgrid.net libs but I can't figure it out. the toolbar doesn't work.
I used most of the basic source codes from mvcgrid.net but when i press something in the search bar it doesn't work or the items per page selection.
If you have specific code to take a look at, please post. Otherwise, here are a few things you can check:
(1) Be sure you've applied the mvcgrid data attributes needed. For example, for a search field you might have these attributes:
<input
type="search"
data-mvcgrid-apply-additional="change"
data-mvcgrid-type="additionalQueryOption"
data-mvcgrid-option="search"
data-mvcgrid-name="ContactGrid">
(2) Be sure the value you chose for mvcgrid-option (in this example, "search") is then added when you configure the grid. For example:
MVCGridDefinitionTable.Add("ContactGrid", new MVCGridBuilder<ContactViewModel>(defaults)
.WithAdditionalQueryOptionNames("Search")
...
(3) You then need to read the attribute (again in the grid config) in your .WithRetrieveDataMethod()
string search = options.GetAdditionalQueryOptionString("search");
I've forgotten step 2 in the past -- that's generally what has tripped me up.

Error while build on Simple List form in AX7

I faced one issue while building Simple List form in AX7. I added all missing controls on form still its giving below error on build.
Pattern 'Simple List' requires a sub-pattern specified on control 'AXForm/Form name//Design/Controls/CustomFilterGroup'.
If you have an error informing you, that you have missing sub-pattern you should search for "unspecified" in the Form Designer. This search will show you all nodes where you have a missing sub-pattern.
For me this seems the easiest way to find all places where there is still work to be done in the Form. By work to be done, I mean to apply a fitting sub-pattern.
Here is an example:
After analyzing the new changes in AX7, I found that we also need to apply sub-patterns on Custom Filters in Simple List form pattern otherwise form will not build successfully. So to apply sub patterns on custom filter group , right click on group, select apply pattern and then click on Custom and Quick Filters. This will apply sub patterns to custom filters and you will be able to successful build the form.
you can use "form statistics". its show, how many object covered by patterns and there is left any unspecified object.
to do this: open form, right-click the form in the designer, and then select Addins > Form statistics.
its looks like: http://msdynamics.blob.core.windows.net/media/2015/09/formStatistics.png
source: https://ax.help.dynamics.com/en/wiki/form-styles-and-patterns/

Pass currency event in Dynamic Tag Management?

I am trying to use currency event in my site and want to capture same using DTM.
But in DTM, I could not locate any option to set currency event. Can someone please help me on this.
Here is my scenario:
Let's say, I have a Javascript on the page code as:
var digitalData = {
'Amount': 1000
}
Then in DTM data element, can this numeric value be passed, by writing this in the Path: 'digitalData.Amount' (after selecting 'Type' as JS Object in Data Elements)
Also, even if we capture this information in Data Element, how do I set this value in any currency success event (for eg event20) in the page load rule section in DTM ? Do I have to write any custom script for that ? If yes, please give me some example, how to do it.
Thanks in advance,
Adi
Yes, you can set a data element just how you said - assuming that digitalData is a globally scoped variable, available when DTM evaluates data elements. If it is not, then the data element won't be set.
That aside, DTM currently only lets you set s.events with a regular event. It does not let you do currency or numeric event syntax. In order to do this, you will need to open up the custom code section and set s.events yourself, and you can use _satellite.getVar('data_element_name') to reference the data element (replace data_element_name with the name of your data element).

How are keywords in metadata stored?

I'm researching options to synchronize external data to a Category and Keyword list.
I have a metadata field with a states field that uses a category called US States.
When I preview my component with a simple XSLT component template (<xsl:copy-of select="." />), I can see:
<tcm:Content>
...
</tcm:Content>
<tcm:Metadata><Metadata xmlns="http://createandbreak.net/schema/generic">
<states>California</states>
<states>New York</states>
</Metadata></tcm:Metadata>
When I update the keyword and preview, I can see updated values.
<tcm:Content>
...
</tcm:Content>
<tcm:Metadata><Metadata xmlns="http://createandbreak.net/schema/generic">
<states>Californias</states>
<states>New York</states>
</Metadata></tcm:Metadata>
Which is great. It looks like we do not need to synchronize components (open, edit, and save) to use updated keywords. Is that a safe assumption?
If I update a keyword, do I need to update components that use it in order to publish component presentations with the updated values?
Do I need to also be careful when moving components with content porter?
No, you don't need to do anything manually for those Keyword fields to be "Content Porter"-safe. Tridion stores the link from your Keyword field to the Keyword definition (in the category) as a so-called managed link (a TCM URI).
The reason you don't see this value in your XSLT has to do with the way Tridion traditionally exposes the Keywords in WebDAV: it hides the TCM URIs there and instead just exposes the value of the selected keyword. Since Keyword values must be unique within their category, this will always allow you to look up the correct TCM URI if needed.
But when exporting (and in general when you're using the API to access content) you should retrieve the Component XML with the TCM URIs in place. Check the API documentation for your programming language to see which Filter/ReadOption you need to specify for that.

Resources