/**
 * @license
 * Copyright 2016 Google Inc. All Rights Reserved.
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

foam.CLASS({
  package: 'foam.comics',
  name: 'DAOCreateController',

  imports: [
    'stack'
  ],

  exports: [
    'data'
  ],

  properties: [
    {
      name: 'dao',
      hidden: true,
      required: true
    },
    {
      name: 'data',
      label: '',
      view: function(args, X) {
        var e = foam.u2.DetailView.create({ showActions: true, of: X.data.dao.of }, X).copyFrom(args);
        e.data$ = X.data$.dot(this.name);
        return e;
      },
      factory: function() {
        return this.dao.of.create(null, this);
      }
    }
  ],

  actions: [
    {
      name: 'save',
      code: function() {
        var stack = this.stack;

        this.dao.put(this.data.clone()).then(function() {
          if ( stack ) stack.back();
        }, function(e) {
          console.error(e);
        });
      }
    },
    {
      name: 'cancel',
      code: function() {
        this.stack && this.stack.back();
      }
    }
  ]
});

@@ -1220,16 +1220,20 @@
 ll, this
+.dao
 );%0A     
@@ -1381,16 +1381,24 @@
 a.clone(
+this.dao
 )).then(

Use this.dao as the context for data.