AnsweredAssumed Answered

Faceted-search table view - row selection

Question asked by mario.fliegner on Jul 28, 2015
Latest reply on Sep 9, 2015 by ddraper
Hi folks,
again, I need some hands-on and insights for solving a request.
Please let me explain the use-case:
A legacy system calls a dynamic page in Alfresco. The webscript behind is already invoked with some URL parameter, i.e.: <blockquote>http://localhost:8080/share/page/dp/ws/addInformation?param1=value&param2=foo&param3=bar</blockquote>
The page in Alfresco is a customized copy of the faceted-search. It returns a table view and it was created based on this blog of Dave Draper: http://blogs.alfresco.com/wp/developer/2015/04/01/adding-views-to-filtered-search/
The user must be able to select one document (not multiple) of the search result. Based on the selection, a new aspect has to be added to the document and the URL parameter, that are provided by the legacy system should be stored in the properties of this aspect. After that, the window can be closed because it's not needed anymore.

I read that it is currently not (easily) possible to add a column with an option-box and to provide a menu entry that perform an action based on the selection. To solve it anyway I'm looking for an easier workaround.
I decided to display a button for each row in the search results. Now I'm struggling with the NodeRef for each column. On my side, I have currently 2 approaches:
<ul>
<li>Create a separate widget that only display the button for each row, collect all information and send it to a POST webscript</li>
<li>Use the existing "alfresco/buttons/AlfButton" widget with a dialog and create a separate service that handles the action to be performed</li>
</ul>

Related to the "Create separate button widget": - Please refer to attached image alfUC1.jpg
What I did - maybe this is already wrong or to much overhead or something else but: I've created a new widget that appears on top of the page and simply collect the URL parameter coming from the legacy system. Within this widget I've created a HTML <form> tag with some hiddden fields that also contains the parameter values. In addition, there is nodeRef field that is currently empty. The button, that appears in the first column of the search result is another widget. During creation I pass the current nodeRef of each row to it, so I have the nodeRef available (this.currentItem["nodeRef"] by using "alfresco/renderers/_JsNodeMixin" in the JS). I've created an "onClick" event for the button that just set the nodeRef to the hidden field in the widget on the top and submits this form. Issue now is: It seems to be, that this is not anymore in the Surf context? Because in the addAspect.post.js webscript which will be invoked by submitting the form, the "form.fields" are emtpy. There are no request parameter available at all!? This is the point where I'm struggling and do not have a clue anymore.

Related to the "Use existing AlfButton": - Please refer to attached image alfUC2.jpg
I've created the button for each row already in the GET webscript and also have created + registered a service for "formSubmissionTopic" (as explained in this tutorial: https://github.com/Alfresco/Aikau/blob/master/tutorial/chapters/Tutorial7.md):

{
  name: "alfresco/buttons/AlfButton",
  config: {
    label: "Add info 2",
    additionalCssClasses: "call-to-action",
    publishTopic: "ALF_CREATE_FORM_DIALOG_REQUEST",
    publishPayload: {
      dialogTitle: "Are you sure?",
      dialogConfirmationButtonTitle: "Yes. Do it!",
      dialogCancellationButtonTitle: "Cancel",
      formSubmissionTopic: "CON_ADD_ASPECT_WITH_PARAMETER",
      fixedWidth: true,
      widgets: [
{
   name: "alfresco/html/Label",
   config: {
      label: "Param1: " + this.param1
   }
},
{
   name: "alfresco/html/Label",
   config: {
      label: "<br/>Param2: " +this.param2
   }
},
{
   name: "alfresco/html/Label",
   config: {
      label: "<br/>Param3: " +this.param3
   }
},
{
   name: "alfresco/forms/controls/HiddenValue",
   config: {
      name: "hiddenNodeRef",
      value: "nodeRef"
   }
}
      ]
    }
  }
},

This dialog is not really necessary but would be ok, if this will be working. It just displays again the relevant data and can be used as a confirmation. The question here is: How can I pass the nodeRef to any of the "HiddenValue" fields? I tried already to extend the "alfresco/forms/controls/HiddenValue" and mix in the "_JsNodeMixin" to get the "currentItem" but it does not work. Any idea how I can solve it this way? Maybe there is a completely different approach besides my both above available to solve the use-case?

Can anyone help me on that? I really appreciate it.

Attachments

Outcomes