Try our conversational search powered by Generative AI!

Blocks/media folders missing on new pages in edit mode [episerver.ui v11.5.2.0]

Vote:
 

Hey here,

Just wondering if anyone knows what the line of dojo code does for Episerver backend editor UI - "this.onChildrenChange(this.root, roots);"? please see more details about the code in below. 

/*
    This code makes a few changes to the editor experience
*/
define([
	"dojo/_base/declare",
	"dojo/when",
	"epi-cms/widget/ContextualContentForestStoreModel",
	"epi-cms/component/viewmodels/TasksViewModel",
	"epi-cms/widget/FolderTree"
], function (
	declare,
	when,
	ContextualContentForestStoreModel,
	TasksViewModel,
	FolderTree
) {
		return declare([], {
			initialize: function () {
				
...
				// 3. Change the order of the items, i.e. move 'for this page' to the top of the list
				var originalGetRoots = ContextualContentForestStoreModel.prototype.refreshRoots;

				function ensureRoots() {
					when(this.getRoots()).then(function (roots) {
						roots.unshift(roots.pop());
                                                //debugger;
						this.onChildrenChange(this.root, roots);
					}.bind(this));
				}

				ContextualContentForestStoreModel.prototype.refreshRoots = function () {
					originalGetRoots.apply(this, arguments);
					ensureRoots.apply(this);
				};

				var originalGetChildren = ContextualContentForestStoreModel.prototype.getChildren;

				ContextualContentForestStoreModel.prototype.getChildren = function () {
					originalGetChildren.apply(this, arguments);
					ensureRoots.apply(this);
				};
			}
		});
	});



This code does change the order of asset folders, and move "for this page" to the top of the list. However, it causes that the "Blocks/Media" tree doesn't get loaded on new pages. I run the js in debug mode, and found out the dojo.js throws an exception in this line ("this.onChildrenChange(this.root, roots);") on loading media/blocks on a new page node. Please see more details in below. However, if I commented out this line of code, the media/blocks are loaded fine on new pages. Not sure what else will be blocked/crashed if I will remove this line of code.

The Exception message:

"Cannot read property 'trim' of undefined"

"TypeError: Cannot read property 'trim' of undefined

    at Object.lang.trim (https://doc/docui/Shell/11.5.2/ClientResources/dojo/dojo.js:15:31982)

    at Object._setValueAttr (https://doc/docui/Shell/11.5.2/ClientResources/epi/shell/widgets.js:2:804065)

    at Object.set (https://doc/docui/Shell/11.5.2/ClientResources/epi/shell/widgets.js:2:19049)

    at Object._applyAttributes (https://doc/docui/Shell/11.5.2/ClientResources/epi/shell/widgets.js:2:16357)

    at Object.create (https://doc/docui/Shell/11.5.2/ClientResources/epi/shell/widgets.js:2:15531)

    at Object.postscript (https://doc/docui/Shell/11.5.2/ClientResources/epi/shell/widgets.js:2:14925)

    at new (https://doc/docui/Shell/11.5.2/ClientResources/dojo/dojo.js:15:41540)

    at Object.buildRendering (https://doc/docui/CMS/11.5.2/ClientResources/epi-cms/widgets.js:2:621540)

    at Object.create (https://doc/docui/Shell/11.5.2/ClientResources/epi/shell/widgets.js:2:15484)

    at Object.postscript (https://doc/docui/Shell/11.5.2/ClientResources/epi/shell/widgets.js:2:14925)"

[Pasting files is not allowed]

#197504
Edited, Oct 05, 2018 0:23
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.