{{!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you 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.
}}

<div {{bindAttr class=":editable-list-container :well view.editMode"}}>
  <div class="items-box" {{action enableEditMode target="view"}}>
    <ul class="items-list">
      {{#each item in view.items}}
        <li {{bindAttr class=":item item.global:global:deletable"}}>
          <span>
            <a href>{{item.name}}</a>
            {{#unless item.global}}
              <button {{action removeFromItems item target="view"}} type="button" class="close">
                <span>&times;</span>
              </button>
            {{/unless}}
          </span>
        </li>
      {{/each}}
      {{#if view.editMode}}
        <li class="item add-item-input">
          {{view Ember.TextField valueBinding="view.input" placeholder="New" classBinding="input-area"}}
          {{#if view.typeahead}}
            <div class="typeahead-box">
              <ul>
                {{#each item in view.typeahead}}
                  <li {{action addItem item target="view"}} class="">{{item.name}}</li>
                {{/each}}
              </ul>
            </div>
          {{/if}}
        </li>
      {{else}}
        {{#if view.items}}
        {{else}}
           <li class="item add-item">Add</li>
        {{/if}}
      {{/if}}
    </ul>
  </div>

  {{#if view.editMode}}
    <div class="actions-panel">
      <button class="btn btn-default btn-xs" {{action onSecondary target="view"}}>
        <span class="icon-remove"></span>
      </button>
      <button class="btn btn-primary btn-xs" {{action onPrimary target="view"}}>
        <span class="icon-ok"></span>
      </button>
    </div>
  {{else}}
    <div class="pencil-box" {{action enableEditMode target="view"}}>
      <span class="icon-pencil"></span>
    </div>
  {{/if}}
</div>
