cancel
Showing results for 
Search instead for 
Did you mean: 

Need a Aikau form control Site Picker, but filtered for the "site preset" property

4535992
Star Collaborator
Star Collaborator

Hi all, I need help customizing the default SitePicker.js of the Aikau library to show only the choice only to sites with a specific "site preset".

The process is i select a site type from the standard "Create Site" dialog:
image

When select the "Custom Preset" i show my custom form dialog:

image

Now i click on the button "Parent Site" a classical "SitePicker" form control of Aikau, but i need to show only site with a specific "site preset".

I based my example on the "site-hierarchy addon" :

https://github.com/Acosix/alfresco-site-hierarchy/blob/master/share/src/main/site-webscripts/de/acos... 

And i need to make a customized version of the :

https://github.com/Alfresco/Aikau/blob/develop/aikau/src/main/resources/alfresco/forms/controls/Site... 

For filter by "site preset".

Can anyone help with this or link me to some similar example ?

5 REPLIES 5

afaust
Legendary Innovator
Legendary Innovator

That's really not trivial. You would have to

  • Create a customisation of the alfresco/services/SiteService which provides a pubSub topic via which sites can be queried / loaded using the site preset - by default, it only supports all sites, favorite or recent sites
  • Create a customisation of alfresco/pickers/SitePicker which includes a section to load sites like the "allSites" option but with a publish payload to specify the preset to the customised SiteService
  • Create a customisation of alfresco/forms/controls/SitePicker which uses your customised, non-form SitePicker instead of the default
  • Use your customised form SitePicker in the Create Site dialog

Note: I am the original author of the site hierarchy addon

4535992
Star Collaborator
Star Collaborator

Hi afaust, It must be me who don't know aikau well yet, but I still can't get what I want.

Here main resource file structure:

image

Here the attachment of the files:  https://drive.google.com/drive/folders/1WEm73VpeZBq98kcAbDc83LAEPN1vIJnX?usp=sharing

I'm lost on the 3rd point of the list:

"Create a customisation of alfresco/forms/controls/SitePicker which uses your customised, non-form SitePicker instead of the default"

i don't get how can i connect the code i made on the " alfresco/forms/controls/SitePresetPicker":

{
                     name: "alfresco/menus/AlfMenuBarItem",
                     config: {
                        label: "picker.allSites.label",
                        publishTopic: "ALF_ADD_PICKER",
                        publishPayload: {
                           currentPickerDepth: 0,
                           pickerLabel: "SitesPreset",
                           picker: [
                              {
                                 name: "alfresco/lists/AlfSortablePaginatedList",
                                 config: {
                                    noDataMessage: "sitePicker.list.noSitesFound",
                                    dataFailureMessage: "sitePicker.list.errorLoadingSites",
                                    itemsProperty: "",
                                    loadDataPublishTopic: "ALF_GET_SITES_BY_SITE_PRESET",
                                    waitForPageWidgets: false,
                                    widgets: [sitesView]
                                 }
                              }
                           ]
                        }
                     }
                  }

with method i made on "alfresco/services/SitePresetService"

      getSitesBySitePreset: function alfresco_services_SitePresetService__getSites(payload) {
         // TODO: Clean this up. Choose on or other as the Aikau standard.
         var alfResponseTopic = payload.alfResponseTopic || payload.responseTopic;
         var config = {
            url: AlfConstants.PROXY_URI + "api/sites", // I'll do something here eventually
            method: "GET",
            alfTopic: alfResponseTopic
         };
         this.serviceXhr(config);
      },

for clarification here the code of my share custom configuration.

                <config evaluator="string-compare" condition="WebFramework" replace="false">
                    <web-framework>
                        <dojo-pages>
                            <packages>
                                <package name="sitepresetservice" location="resources/service-site-hierarchy/aikau/alfresco/services/SitePresetService.js"/>
                                <package name="sitepresetpicker" location="resources/service-site-hierarchy/aikau/alfresco/pickers/SitePresetPicker.js"/>
                                <package name="sitepresetformcontrolpicker" location="resources/service-site-hierarchy/aikau/alfresco/forms/controls/SitePresetPicker.js"/>
                            </packages>
                        </dojo-pages>
                    </web-framework>
                </config>

Sorry for the inconvenience, but it is something that I have to solve at all costs. I'm willing ot pay a small bounty for this.

afaust
Legendary Innovator
Legendary Innovator

In your site service you must have mapped the new "getSitesBySitePreset" function to a pubsub topic, similar to how all the default functions are mapped/registered. That topic is the connection - a widget publishes to that topic to trigger the request, and the site service actually publishes to a similar response topic (original topic with an added suffix) to send back the results (handled transparently by "serviceXhr" in your case)

.

4535992
Star Collaborator
Star Collaborator

Ty again, i have already do that on the service file:

https://drive.google.com/drive/u/1/folders/1MVl6w-et7C9GLxoNE90qrkAIVjH0lWrP

this.alfSubscribe("ALF_GET_SITES_BY_SITE_PRESET", lang.hitch(this, this.getSitesBySitePreset));

it's must be something else i'm not seeing or some dojo config i screwed up.

Like i said i'm willing to pay for a use case example on github, because I admit I'm completely lost.

If it helps you in your answers I am trying to add the following customizations to your "site-hierarchy" addon used as a starting point:

A site selector limited to sites of a specific type.

Show or hide elements of the site creation or display form depending on which value has been selected in the "type site" dropdown.

Ty for your help.

4535992
Star Collaborator
Star Collaborator

Ok maybe i find the problem i need to make a override of the site service:

var siteService = widgetUtils.findObject(model.jsonModel, "id", "SITE_SERVICE");

so on the file "share-header.get.js" i add this code:

//Change SiteService to Customized Module
widgetUtils.findObject(model.jsonModel, "id", "SITE_SERVICE").name = "alfresco/services/SitePresetService”;
make sense ?