[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:
37
platform/representation/src/gestures/GestureRepresenter.js
Normal file
37
platform/representation/src/gestures/GestureRepresenter.js
Normal 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;
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user