Alfresco / Aikau

Aikau UI framework
GNU Lesser General Public License v3.0
81 stars 61 forks source link

implementing Bulk Edit Properties in faceted search screen #1368

Open KiranPM opened 7 years ago

KiranPM commented 7 years ago

Hi,

I am trying to implement Bulk Edit Properties in faceted search screen. We are using Alfresco 5.2+Aikau-100.0.1+Form Runtime support jar(100.0.1); Please note that formId is coming from share-config-custom.xml; Edit Properties form is coming but cm:taggable and cm:categories fields are there in share-config-custom.xml,those are not populating correctly.Is there any example out there to show tags and categories in the dialog box.

onSelectedDocumentsAction will call the form dialog and onEditPropertiesAction will submit the form with values.

Is it correct way to pass multiple nodeRef's while submitting the form?

I have modified the code based on below link. https://community.alfresco.com/community/ecm/blog/2016/10/20/inline-advanced-search

var selectedItemsActionsGroup = widgetUtils.findObject(model.jsonModel.widgets,"id", "SELECTED_ITEMS_ACTIONS_GROUP");

if (selectedItemsActionsGroup !== null) {

selectedItemsActionsGroup.config.widgets.push(
                {
                    id : "EditProperties",
                    name : "faceted-search/CustomBulkSelectItems/CustomBulkSelectItems",
                    config : {
                        label : "Edit Properties",
                        iconImage : url.context
                                + "/res/components/documentlibrary/actions/document-edit-metadata-16.png",
                        type : "action-link",
                        permission : "",
                        asset : "",
                        href : "",
                        hasAspect : "",
                        notAspect : "",
                        publishTopic : "BULK_OPS",
                        publishPayload : {
                            action : "onActionEditProperties"
                        }
                    }
                });

CustomBulkSelectItems.js


postCreate: function alfresco_documentlibrary_CustomBulkSelectItems__postCreate() {

     this.alfSubscribe("BULK_OPS", lang.hitch(this, this.onSelectedDocumentsAction));
     this.alfSubscribe("ALF_EDIT_PROP", lang.hitch(this, this.onEditPropertiesAction));
     this.inherited(arguments);
  } ,

onSelectedDocumentsAction: function alfresco_documentlibrary_CustomBulkSelectItems__onSelectedDocumentsAction(payload) { payload.documents = this.selectedItems;

for (var i = 0; i < payload.documents.length; i++) { nodeRefs.push(payload.documents[i].nodeRef); }

if(nodeRefs.length == 1 ) form="simple-metadata";

     else
         form="bulk-metadata-form";

      this.alfPublish("ALF_CREATE_DIALOG_REQUEST", {
         dialogId: "ALF_EDIT_PROP_DIALOG",
         dialogTitle: "Edit Properties",
         dialogConfirmationButtonTitle: "Save",
         dialogCancellationButtonTitle: "Cancel",
         formSubmissionTopic: "EDIT_PROPERTIES",
         contentWidth: "1000px",
         hideTopic: "ALF_EDIT_PROP",
         fixedWidth : true,
         widgetsContent: [
             {
                name: "alfresco/forms/Form",
                config: {
                   autoSavePublishTopic: "ALF_FORM_REQUEST",
                   autoSavePublishGlobal: true,
                   autoSavePublishPayload: {
                      itemKind: "bulkedit",
                      itemId: nodeRefs,
                      submitType:"json",
                      mode: "edit",
                      formId: form,
                      alfSuccessTopic: "EDIT_FORM_RETRIEVED",
                      formConfig: {
                         okButtonLabel: "Save",
                         okButtonPublishTopic: "ALF_EDIT_PROP"
                      }
                   }
              }
             },
             {
                name: "alfresco/layout/DynamicWidgets",
                config: {
                   subscribeGlobal: true,
                   subscriptionTopic: "EDIT_FORM_RETRIEVED"
                }
             }
          ],
          publishOnShow: [
             {
                publishTopic: "ALF_FORM_REQUEST",
                publishPayload: {
                   itemId: nodeRefs,
                   itemKind: "bulkedit",
                   mode: "edit",
                   submitType:"json",
                   formId: form,
                   alfSuccessTopic: "EDIT_FORM_RETRIEVED",
                   formConfig: {
                      okButtonLabel: "Save",
                      okButtonPublishTopic: "ALF_EDIT_PROP"
                   }
                },
                publishGlobal: true
             }
          ]
      });
      },

     onEditPropertiesAction: function alfresco_CustomBulkSelectItems__onEditPropertiesAction(payload) {

      payload.documents = this.selectedItems;

      var nodeRefs = [];
      var url ="";
      for (var i = 0; i < payload.documents.length; i++) {
         nodeRefs.push(payload.documents[i].nodeRef);
      }

      var templateUrl =Alfresco.constants.PROXY_URI + "xxxx/formprocessor";

      this.serviceXhr({
            url: templateUrl,
            method: "POST",
            data: {
                "itemKind":"bulk","formId":"bulk-metadata-form","itemId":nodeRefs
            },
             successCallback: this.EditPropertiesRequestComplete,
              failureCallback: this.EditPropertiesRequestFailed,
              callbackScope: this
        });
  } 
SanjayBandhniya commented 2 years ago

@KiranPM Is this working for you? I need same kind of functionality. I have tried your code but I am not getting idea where I need to place CustomBulkSelectItems.js