/**
 * @license
 * Copyright 2019 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

foam.CLASS({
  package: 'foam.nanos.auth',
  name: 'ChangePasswordView',
  extends: 'foam.u2.Controller',

  documentation: 'renders a password change model',

  imports: [
    'stack',
    'theme',
    'user'
  ],

  css: `
    ^ {
      background: #ffffff;
      height: 100vh;
    }
    ^top-bar {
      background: /*%LOGOBACKGROUNDCOLOUR%*/ #202341;
      width: 100%;
      height: 8vh;
      border-bottom: solid 1px #e2e2e3;
    }
    ^top-bar img {
      height: 4vh;
      padding-top: 2vh;
      display: block;
      margin: 0 auto;
    }
    ^content {
      max-width: 30vw;
      padding-top: 4vh;
      margin: 0 auto;
    }
    ^section {
    }
    /* title  */
    ^ ^section h2 {
      margin-top: 0;
      margin-bottom: 4vh;
      font-size: 2.5rem;
    }
    /* subtitle */
    ^ ^section .subtitle {
      color: /*%GREY2%*/ #8e9090;
      font-size: 1rem;
      margin-top: 0;
      margin-bottom: 3vh;
      line-height: 1.5;
      text-align: center;
    }
    ^link {
      color: /*%PRIMARY3%*/ #604aff;
      cursor: pointer;
      text-align: center;
      padding-top: 1.5vh;
    }
  `,

  properties: [
    {
      class: 'Boolean',
      name: 'showHeader',
      documentation: `This property toggles the view from having a top bar displayed.`,
      value: true,
      hidden: true
    },
    {
      class: 'String',
      name: 'modelOf',
      documentation: `Password model used for this view.
                      Pass this property along when you create this view.
                      e.g., stack.push({
                        class: 'foam.nanos.auth.ChangePasswordView',
                        modelOf: 'foam.nanos.auth.RetrievePassword'
                      })
                     `,
    },
    {
      class: 'FObjectProperty',
      of: this.modelOf,
      name: 'model',
      documentation: 'instance of password model used for this view',
      expression: function(modelOf) {
        return foam.lookup(modelOf).create({}, this);
      }
    }
  ],

  methods: [
    function initE() {
      const self = this;
      const logo = this.theme.largeLogo || this.theme.logo;

      this.addClass(this.myClass())
        // header
        .callIf(this.showHeader, function() {
          this.start().addClass(self.myClass('top-bar'))
            .start('img').attr('src', logo).end()
          .end();
        })
        // body
        .start().addClass(this.myClass('content'))
          // section
          .start().addClass(this.myClass('section'))
            .start(foam.u2.detail.SectionView, {
              data: this.model,
              sectionName: this.model.cls_.model_.sections[0].name,
              isCentered: true
            }).end()
          .end()
          // link
          .callIf(this.model.hasBackLink, function() {
            this.start().addClass(self.myClass('link'))
              .add(self.model.REDIRECTION_TO)
              .on('click', function() {
                self.stack.push({ class: 'foam.u2.view.LoginView', mode_: 'SignIn' }, self);
              })
            .end();
          })
        .end();
    }
  ]
});

@@ -1850,17 +1850,16 @@
        %60
-,
 %0A    %7D,%0A

remove trailing commas