/* global  OverView */

var AnimatedFolderOverView = Namespace.declare("com.twitter.Bootstrap.AnimatedFolder",
  class AnimatedFolderOverView extends OverView {
    constructor() {
      super();
    }
    init(object) {
      super.init(object);
      return this;
    }

    /*
    loadWeBean() {
      if (Thinglish.lookupInObject(DefaultFolder, "type.ucpComponentDescriptor.webBeanUnits")) {
        return DefaultFolder.type.ucpComponentDescriptor.webBeanUnits.find(u => u.model.name.startsWith(this.constructor.name)).weBean;
      }
      return null;
    }

    get description() {
      let description = this.properties.description;
      if (!description) {
        description = Thinglish.lookupInObject(this, "ucpComponent.type.ucpComponentDescriptor.properties.description");
      }
      if (!description) {
        description = "";
      }
      if (Thinglish.lookupInObject(this, "model.type.name")) {
        description = this.model.type.name + ": " + description;
      }

      if (this.ucpModel instanceof StructrObject) {
        description = "StructrObject: " + this.model.structrType;
      }

      return description;
    }

    get typeName() {
      return Thinglish.getTypeName(this.model);
    }

    select() {
      console.info("select", this.ucpModel._private.model);
    }

    handleSelection(event, item) {
      console.log(this.constructor.name, "selected", item);
      Action.do(Workflow.ACTION_SELECT, item, DetailsView.ACTION_SHOW, [What.ACTION_PUSH, What.ACTION_POP]);
      Action.do(OverView.ACTION_SHOW, item);
    }

    async updateView(view) {
      if (!this.breadcrumb) {
        this.breadcrumb = Breadcrumb.getInstance().init();
        this.breadcrumb.model = this.model;
      }
      this.breadcrumb.defaultView.prepend(this.documentElement);

      let list = this.model.folders.concat(this.model.files);
      list = await Promise.all(list.map(file => (file.load && !file.isLoaded) ? file.load() : file));
      list = list.sort((a, b) =>
        (String((a.model.type.startsWith("File")) ? "0" : "") + a.model.name).localeCompare(((b.model.type.startsWith("File")) ? "0" : "") + b.model.name)
      );
      this.slipList.properties.items = list;

      this.slipList.eventSupport.addEventListener("selected", this.ucpComponent, this.ucpComponent.handleSelection.bind(this.ucpComponent));
      this.slipList.eventSupport.addEventListener("selected", this, this.handleSelection.bind(this));

    }


    append(element) {
      super.append(element);
    }

    replace(element) {
      super.replace(element);
    }

    get slipList() {
      return this.documentElement.children[2].ucpView.ucpComponent;
    }
*/

  }
);