OOTB Granite Render Condition in AEM [closed] - aem

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have created a button called annotation and I have added hasannotation OOTB granite render condition. On selection of an image having annotation, the button doesn't get rendered.
Image Of the custom button with granite:rendercondition
Properties of the button
Properties of granite:rendercondition node

First you need to add granite:rel property to your button.
As said in the documentation:
This is used to indicate the semantic relationship of the component
similar to HTML rel attribute.
You can add the AEM existing granite:rel in your custom button as "aem-assets-admin-actions-annotate-activator" as shown /libs/dam/gui/content/assets/jcr:content/actions/selection/annotate
Or you can also add your custom value lets say "my-annotation-rel". In this case you need to tell AEM to consider your custom value. In order to do this, you need to overlay /libs/dam/gui/coral/components/admin/contentrenderer/base/assetBase.jsp
and add this line :
actionRels.add("my-annotation-rel");
Update: render condition is not working because the path is not correctly passed to redercondition component. {requestPathInfo.suffix} does not give the actual path of the asset rather it gives the folder path and hence it fails to check when you are in card/column/list view.
In order to implement this, follow these steps:
Overlay /libs/dam/gui/coral/components/admin/contentrenderer/base/base.jsp
Add this below code inside getActionRels(Node node, boolean hasReplicate,boolean hasRemoveNode, boolean hasModifyAccessControl, boolean isExpiredAsset, boolean isExpiredSubAsset, boolean isDAMAdmin, boolean isContentFragment) method
boolean hasAnnotation = false;
NodeIterator nodeItr= node.getNodes();
Node commentsNode;
while(nodeItr.hasNext()) {
Node childNode = nodeItr.nextNode();
NodeIterator childItr = childNode.getNodes();
while(childItr.hasNext()) {
Node secondLevelChild = childItr.nextNode();
if(secondLevelChild.getName().equals("comments")) {
NodeIterator thirdLevelNode = secondLevelChild.getNodes();
while(thirdLevelNode.hasNext()){
if(thirdLevelNode.nextNode().hasProperty("annotationData")){
hasAnnotation = true;
}
}
}
}
}
if(hasAnnotation){
actionRels.add("my-annotation-rel");
}
Add granite:rel (String) "my-annotation-rel" property to your custom button
It should work.
Another way without changing the OOTB jsp file behaviour, if you are customising metadataeditor then granite render condition should work . In this case you have to first overlay this and your custom button:
/libs/dam/gui/content/assets/metadataeditor/jcr:content/actions
and add granite:rendercondition node under your custom button and give path property as
${empty requestPathInfo.suffix ? param.item : requestPathInfo.suffix}

Related

Ag-Grid hide a mini-filter after 'Apply' button is pressed

I'm using the Enterprise Ag-Grid version in my Angular 6 application. I have a Set Filter in it. I added the 'Apply' button to the filter:
apply: Set to true to include an 'Apply' button with the filter and
not filter automatically as the selection changes.
The question is how can I hide the mini filter menu after button is pressed? I didn't find any documentation about this possibility in the official web site. But I find a comment in the internal library src file, specifying in the IComponent.ts:
/* A hook to perform any necessary operation just after the gui for this component has been renderer
in the screen.
If the filter popup is closed and reopened, this method is called each time the filter is shown.
This is useful for any
logic that requires attachment before executing, such as putting focus on a particular DOM
element. The params has one callback method 'hidePopup', which you can call at any later
point to hide the popup - good if you have an 'Apply' button and you want to hide the popup
after it is pressed. */
afterGuiAttached?(params?: IAfterGuiAttachedParams): void;
At the moment I can not understand how to set afterGuiAttached function to achieve the goal described above.
Could anyone help me?
Thanks in advance!
As you already checked afterGuiAttached is a part of Filter Component
So this function accessible inside custom filter like here.
So all that you should do is define afterGuiAttached inside:
export class PartialMatchFilter implements IFilterAngularComp {
afterGuiAttached(params){
params.hidePopup() <- executing will close the filter
}
}
afterGuiAttached - would be executed on init as described (but Apply button also would be custom and you should handle it by your self). You can bind hidePopup function to your custom filter parameter and use it when it would be necessary.
export class PartialMatchFilter implements IFilterAngularComp {
private hideFilter:Function;
afterGuiAttached(params){
this.hideFilter = params.hidePopup;
}
}
Executing this.hideFilter() will close your filter;
I've made a dummy sample based on the referenced demo

Disable a form if the other is updatable

I'm using page fragments to create a view and in the same page I have two forms to view / update specific information.
What I want know if it's possible to disable one form (or button, since it's the way I use to change from readable to updatable) based on if the other is in updatable mode.
Simplifying I have form A and B, both in the same page as readable. When I select A to update I want B to disable the option to edit until A is back to read mode, and the same to B form.
Can anyone help me?
---Update
Flows
A
B
In each fragment (view) I have a button that as an action to the fragment (edit)
What I need is to disable the button from B.view when A button is pressed and vice versa
If the forms are part of separate taskflows and these taskflows are used on the page as regions, then you will need to enable inter-region communication, so that an action in one region can affect the data and behavior of other region:
http://www.oracle.com/technetwork/developer-tools/adf/adfregioninteraction-155145.html
For your use case, contextual events can serve the purpose:
http://rohanwalia.blogspot.com/2013/07/contextual-events-basic-step-by-step.html
http://www.awasthiashish.com/2013/05/using-contextual-event-in-oracle-adf.html
https://blogs.oracle.com/raghuyadav/entry/refresh_bounded_taskflows_acro
To implement your case, follow the tutorials provided above with following changes:
Pass a boolean value in the customPayLoad of event
<event name="DisableButtonEvent" customPayLoad="${'true'}"/>
In the event handler method assign the payLoad value to a scope variable:
public void handleDisableButtonEvent(String payLoad) {
AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();
Map pageFlowScope = adfFacesContext.getPageFlowScope();
pageFlowScope.put("disableButton", payLoad);
}
Use the scope variable for disabled property of button on second region
<af:commandButton text="EditButoonB" id="cb1"
disabled="#{pageFlowScope.disableButton ne null? pageFlowScope.disableButton : false}"/>

Single select Tag in Touch UI

OOTB Tag has multi select functionality, Is it possible to create single select Tag in Touch UI? If yes, can you point me which js file I need to modify?
The cq:tags property is rendered by CUI.TagList widget that can be found within /etc/clientlibs/granite/coralui2/js/coral.js script.
Reading it you can learn that the widget raises itemadded event which might be helpful for you to handle the singular tag handling. An example function that can catch the event might be placed in any clientlibs that will be attached to the admin interface such as cq.authoring.dialog clientlib.
$('*[data-fieldname="./cq:tags"]').on('itemadded', function(ev, value) {
var el = $(ev.target),
div = el.siblings('div'),
input = div.find('input'),
button = div.find('button');
input.prop('disabled', true);
button.remove();
}
To have the fully functional flow you need to handle the itemremoved event as well and make the input field enabled again as well as add the button back to the widget.

How to get user's input from WicketStuff's TinyMCE

Pretty straight-forward question, but I can't find this anywhere. I'm using WicketStuff's TinyMCE to make a Rich Text Editor in my application, and can't find anywhere how to get the input from the text area. For brevity's sake, the following is a simplified version of the code I'm using.
private String input;
...
TinyMCESettings settings = new TinyMCESettings(TinyMCESettings.Theme.simple);
TextArea<String> textArea = new TextArea<String>("editor", new PropertyModel<String>(this, "input"));
textArea.add(new TinyMceBehavior(settings));
form.add(textArea);
Using this, I would expect the usual manner to simply use my String 'input' since it's set as the model. This always results in null as the model isn't being updated.
I tried using the auto-save plugin in case it was expecting the save button to be clicked (which doesn't update the model either), and neither worked. The only thing I've been able to do to get the user's input is to add a HiddenField, with a new model, and make a JavaScript call like
document.getElementById('hiddenField').value = tinyMCE.get('editor').getContent();
but this has led to other problems with trying to call the JS in the desired place and to get it to work properly. I feel this shouldn't be necessary anyways, as surely someone must have implemented a method to get the contents of the text area being used.
Any help would be greatly appreciated.
Thanks to a blog post at Nevermind Solutions, the way to get the model updated is to add the following JavaScript to the form's submitting button:
onclick="tinyMCE.triggerSave(true,true);"
My text area is inside a panel with the button outside of the panel, so it doesn't directly work for me. The trick was to add the JavaScript call to the button's onSubmit, move the logic into the onAfterSubmit, and to make the button MultiPart so that it could call the save trigger before doing the other logic associated to the model.
Hope this might help some others in the future.
You have to add a modifier to the submit button so that the model can update.
AjaxButton btnSubmit = new AjaxButton("btnSubmit", new Model()) {
#Override
public void onSubmit(AjaxRequestTarget target, Form<?> form) {
doSomething();
}
};
btnSubmit.add(new TinyMceAjaxSubmitModifier());
Have a look here for more info

Drupal 7 - Hide certain form fields of a content edit form depending on the content data

In Drupal 7, is there a way to change the standard edit form for a content type based on a certain content?
For example:
I have a content type with a checkbox...once it it checked and the form is saved, I do not want this checkbox to be visible anymore...therefore based on the checkboxes value in the Database I want to hide form fields when showing the form.
I am building a small specific project site, where a company wants to add projects, and their customers are supposed to follow certain steps (upload some content, provide information etc.), and also should be able to check off certain requirements, and once these are checked off, they should not be visible/editable to them.
Also the displayed form fields should depend on an user's role, and then FURTHER be limited depending on the content's database entries.
Is there a module, which could achieve this behaviour? "rules" and "field/permissions" come close to what I need, but are not sufficient. Or did I just miss the option to change a form field's accessibility based on conditions?
What I need is some place to define a logic like "IF (VALUEOF(CHECKBOX_1) == TRUE) THEN DO_NOT_SHOW(CHECKBOX_1)"
hook_form_alter is the way to do this, as explained by Mihaela, but what options do you have inside that function?
If you want just to disable field (it will be visible, but user can't change it) you can do it like this:
$form['field_myfield']['#disabled'] = TRUE;
And if you want it to be hidden, but to keep value it has before editing the way to do that is:
$form['field_myfield']['#access'] = FALSE;
I.e. hiding it (somewhere I saw someone suggesting that):
hide($form['field_myfield']);
really hides the field, but after that, when form is saved this field has empty value, validation fails, etc, so that's not a good way to do this. Hiding makes sense only if you want to print separately that field later, at some other place.
function your_module_form_alter(&$form, &$form_state, $form_id){
switch($form_id) {
case 'nameOfTheNode_node_form':
//your code here. check the value from from_state.
break;
}
}
In this case, I use module Conditional Fields https://www.drupal.org/project/conditional_fields
For example: If my Dependees field has a value, Dependent field can be visible/invisible, enabled/disabled, required/optional, checked/unchecked