hummingbird-me/hummingbird

View on GitHub
frontend/app/templates/apps/edit.hbs

Summary

Maintainability
Test Coverage
<div class="container">
  <div class="col-md-8 col-md-offset-2">
    <div class="panel panel-default">
      <div class="panel-heading">
        <h2 class="panel-title">
          {{#if creatingApp}}
            Create New App
          {{else}}
            {{!-- Unbound so it doesn't update as the user modifies the name --}}
            Editing {{unbound model.name}}
          {{/if}}
        </h2>
      </div>
      <div class="panel-body">
        <form class="form-horizontal">
          {{!-- TODO: add logo upload button and display logo
          <div class="form-group">
            <label for="app-logo" class="col-sm-4 control-label required-label">Logo</label>
            <div class="col-sm-8">
              <img src="{{model.logoUrl}}">
              {{view "file-upload" action="logoSelected" id="app-logo"}}
            </div>
          </div>
          --}}

          <div class="form-group {{if errors.model.name 'has-error'}}">
            <label for="app-name" class="col-sm-4 control-label required-label">Name</label>
            <div class="col-sm-8">
              {{input type="text" class="form-control" id="app-name"
                      value=model.name placeholder="Application Name"}}
            </div>
          </div>
          {{show-errors if=model.name fieldName="Name" clientErrors=errors.model.name
                        serverErrors=model.errors.name}}

          <div class="form-group {{if errors.model.description 'has-error'}}">
            <label for="app-desc" class="col-sm-4 control-label required-label">Description</label>
            <div class="col-sm-8">
              {{input type="text" class="form-control col-sm-8" id="app-desc"
                      value=model.description placeholder="Description"}}
            </div>
          </div>
          {{show-errors if=model.description fieldName="Description"
                        clientErrors=errors.model.description
                        serverErrors=model.errors.description}}

          <div class="form-group">
            <label for="app-homepage" class="col-sm-4 control-label">Homepage</label>
            <div class="col-sm-8">
              {{input type="url" class="form-control col-sm-8" id="app-homepage"
                      value=model.homepage placeholder="Homepage"}}
            </div>
          </div>

          {{!-- TODO: add database stuff for this
          <div class="form-group">
            <label class="col-sm-4 control-label required-label">Access</label>
            <div class="col-sm-8">
              <label class="radio-inline">
                {{radio-button value=false checked=model.writeAccess}}
                Read Only
              </label>
              <label class="radio-inline">
                {{radio-button value=true checked=model.writeAccess}}
                Read and Write
              </label>
              <span class="help-block">
                Read Only access gives you the ability to read data via APIv2.
                Read and Write access lets users log into your app and permit
                it to update data.
              </span>
            </div>
          </div>
          --}}

          {{!-- NOTE: enable this when we add usage tracking + dynamic /apps
          <div class="form-group">
            <label class="col-sm-4 control-label required-label">Visibility</label>
            <div class="col-sm-8">
              <label class="radio-inline">
                {{radio-button value=true checked=model.public}}
                Public
              </label>
              <label class="radio-inline">
                {{radio-button value=false checked=model.public}}
                Hidden
              </label>
            </div>
          </div>
          --}}

          {{!-- NOTE: enable this when OAuth2 happens
          {{#if model.writeAccess}}
          <div class="form-group {{if errors.model.redirectUri 'has-error'}}">
              <label for="redirect-uri" class="col-sm-4 control-label required-label">Redirect URI</label>
              <div class="col-sm-8">
                {{input type="url" class="form-control col-sm-8" id="redirect-uri"
                        value=model.redirectUri placeholder="Redirect URI"
                        aria-describedby="app-name-help"}}
                <span class="help-block" id="app-name-help">
                  Used by our <a href="#">OAuth2 provider</a> to know where to
                  redirect back to your app.
                </span>
              </div>
            </div>
            {{show-errors if=model.redirectUri fieldName="Redirect URI"
                          clientErrors=errors.model.redirectUri
                          serverErrors=model.errors.redirectUri}}
          {{/if}}
          --}}

          <div class="form-group">
            <button class="col-sm-3 col-sm-offset-3 btn btn-primary"
                    {{action 'saveApp'}} disabled={{isSaveDisabled}}>
              {{#if creatingApp}}
                Create
              {{else}}
                Save
              {{/if}}
            </button>
            {{#link-to 'apps.mine' class='col-sm-3 btn btn-default'}}
              Cancel
            {{/link-to}}
          </div>
        </form>
      </div>
    </div>
  </div>
</div>