Uploaded image for project: 'Alfresco'
  1. Alfresco
  2. ALF-19930

No easy / apparent way to remove Share widgets in customizations

    Details

    • Resolution Time Custom Field:
      50 weeks, 5 days, 19 hours, 56 minutes, 44 seconds

      Description

      It's not possible to easily remove a widget (i.e. a menu item) using a customization. The widgetUtils object allows us to find and modify a declared widget but there appears to be no way to fully remove that widget. ALF-19911 has added some configuration options to a specific widget (the Sites menu).

      I tried the following to modify the header.

      1) Provide a custom share-header.get.js
      2) Create an extension module that targets org.alfresco.share.header
      3) Implement the following in the custom share-header.get.js

      ===

      var widget = widgetUtils.findObject(model.jsonModel.widgets, "id", "HEADER_SHARED_FILES");
      if(widget !== undefined && widget !== null)

      { widget.name = null; // CreateWebScriptsWidgetsDirective checks name and only creates WidgetData if name is a string }

      ===

      This results in an empty header due to some Dojo DomOnReady error.

      The only way I could get a removal of widgets to work was with the following rather complex JavasScript in step #3:

      ====

      var widget, widgetsToRemove = [ "HEADER_SHARED_FILES", "HEADER_MY_FILES", "HEADER_PEOPLE", "HEADER_TASKS", "HEADER_REPOSITORY",
      "HEADER_SEARCH" ], idx, max;

      for (idx = 0, max = widgetsToRemove.length; idx < max; idx++)

      { findAndRemoveIn(model.jsonModel.widgets, null, null, widgetsToRemove[idx]); }

      function findAndRemoveIn(obj, arrContext, arrIdx, id)
      {
      var idx, max, key;
      if (obj !== undefined && obj !== null)
      {
      if (Object.prototype.toString().apply(obj) === "[object Object]")
      {
      if (obj.hasOwnProperty("id") && obj.id === id)
      {
      if (arrContext !== null && arrIdx !== null)

      { arrContext.splice(arrIdx, 1); }

      else

      { logger.debug("Unexpected match outside of array structure: " + jsonUtils.toJSONString(obj)); }

      }
      else
      {
      for (key in obj)
      {
      if (obj.hasOwnProperty(key))

      { findAndRemoveIn(obj[key], null, null, id); }

      }
      }
      }
      else if (Object.prototype.toString().apply(obj) === "[object Array]")
      {
      for (idx = 0, max = obj.length; idx < max; idx++)

      { findAndRemoveIn(obj[idx], obj, idx, id); }

      }
      }
      }

        Attachments

          Structure

            Activity

              People

              • Assignee:
                closedissues Closed Issues
                Reporter:
                afaust Axel Faust
              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Date of First Response:

                  Structure Helper Panel