The thing is that the scene parameter does not seem to apply only to the component in which it is set. Instead the scene is applied globally to the whole site. Meaning that all my components inherit this scene and render the ‘editor’ and ‘always’ style sheets even if the user is not logged in. The ‘anon’ style sheets are completely ignored, so I can’t even override the styles set by the editor style sheet.
I don’t mind the forms pulling some extra stuff and honestly I like the approach that you’ve selected, but it feels a bit weird that making the forms pull that extra stuff changes the behavior of other completely unrelated modules.
I’ve tried to debug it a bit and I think the issue is in the load method of the apostrophe-widget class, which sets the scene to the whole request. Would it make more sense to store the scene as a widget specific option and process it in each widget individually instead of writing it to the whole request?
UPD:
I’ve gone a bit further and did the following for a test:
- from the widgets load() method I removed the part that sets the scene to the request
- I extended the push method of apostrophe-assets so it also adds the name of the module that pushes the asset
- in the filterAssets method of apostrophe-assets I added a check that makes sure that if the module that loaded the asset has scene defined and it matches that of the asset, that the asset is added to the bundle:
var assetLoadingModule = self.apos.modules[asset.module];
var relevant = (asset.when === ‘always’) || (when === ‘all’) || (asset.when === when) || (!!assetLoadingModule && assetLoadingModule.options && assetLoadingModule.options.scene === asset.when);
Now I do get the apostrophe-scheme user assets referenced on the page without affecting any other module, but apos.schemas is still undefined and calling the populate method results in an exception.
UPD2:
I extended the pushCreateSingleton method on apostrophe-schemas and now the apos.schema is properly initialized in the browser, however, calling the below code in user.js of apostrophe-schemas throws an undefined exception on $el.findSafe even though the array-modal.js is loaded;
self.findSafe = function($el, sel) {
return $el.findSafe(sel, '.apos-field');
};
Am I missing anything?