[Layout] Add notion of representers

Add representers as a category of extension; these are extra
steps to perform when representing a domain object. This
will be used to support automatic mutation/persistence of
domain objects from a watch, while avoiding bloat within
the mct-representation directive itself. This, in turn,
simplifies the persistence strategy to be employed by
Layout views when editing concludes. WTD-535.
This commit is contained in:
Victor Woeltjen
2014-12-05 09:43:22 -08:00
parent b50f40f399
commit 67b9af54b3
3 changed files with 62 additions and 14 deletions

View File

@@ -0,0 +1,37 @@
/*global define*/
define(
[],
function () {
"use strict";
function GestureRepresenter(gestureService, scope, element) {
var gestureHandle;
function destroy() {
if (gestureHandle) {
gestureHandle.destroy();
}
}
function represent(representation, domainObject) {
// Clear out any existing gestures
destroy();
// Attach gestures - by way of the service.
gestureHandle = gestureService.attachGestures(
element,
domainObject,
(representation || {}).gestures || []
);
}
return {
represent: represent,
destroy: destroy
};
}
return GestureRepresenter;
}
);