tutorial consistency . (#1079)

* [API] use new-style objects consistently

* rewrite todo tutorial in test-api.html

* [API] Add API doc, update object API

* [Tutorials] Rename tutorials, remove old

* Fix Links

* updates

* initial

* hope this works

* Object Utils always return new objects instead of mutating existing objects

* keep domain object model in-sync when listening

Keep the domain object model in sync with the latest version when
listening for mutation events.

* Remove old-style plugins

* Update views to use new API

* Tidy Code

* Update API Docs

* Add Plugin API and Example
This commit is contained in:
Pete Richards
2016-07-21 14:39:02 -07:00
committed by GitHub
parent 18843cee48
commit 7890fcae69
17 changed files with 599 additions and 154 deletions

View File

@ -6,7 +6,8 @@ define([
'text!./adapter/templates/edit-object-replacement.html',
'./ui/Dialog',
'./Selection',
'./api/objects/bundle'
'./api/objects/bundle',
'./api/objects/object-utils'
], function (
EventEmitter,
legacyRegistry,
@ -14,7 +15,9 @@ define([
api,
editObjectTemplate,
Dialog,
Selection
Selection,
objectAPIBundle,
objectUtils
) {
function MCT() {
EventEmitter.call(this);
@ -67,9 +70,11 @@ define([
this.legacyExtension('policies', {
category: "view",
implementation: function Policy() {
this.allow = function (v, domainObject) {
if (v.key === adaptedViewKey) {
return definition.canView(domainObject);
this.allow = function (view, domainObject) {
if (view.key === adaptedViewKey) {
var model = domainObject.getModel();
var newDO = objectUtils.toNewFormat(model);
return definition.canView(newDO);
}
return true;
};
@ -81,6 +86,13 @@ define([
region: region,
key: viewKey
});
this.legacyExtension('services', {
key: 'PublicAPI',
implementation: function () {
return this;
}.bind(this)
});
};
MCT.prototype.type = function (key, type) {
@ -114,6 +126,16 @@ define([
this.emit('start');
};
/**
* Install a plugin in MCT.
*
* @param `Function` plugin -- a plugin install function which will be
* invoked with the mct instance.
*/
MCT.prototype.install = function (plugin) {
plugin(this);
};
MCT.prototype.regions = {
main: "MAIN",
toolbar: "TOOLBAR"