## 2017-06-12 #ShowProgress

- fixed test template and [added tests](../../test/templates/)
- removed terminal and bin files #StudenProject
- removed turtle canvas #StudentProject
 

## Show Progress

```
    var progress = await lively.showProgress("update");
    var all = this.db.files.where("name").notEqual("");
    var total = await all.count();
    var i=0
    await all.modify((ea) => {
       this.extractTitleAndTags(ea)
       progress.value = i++ / total
       console.log("i "+ (i / total))
    });
    progress.remove()
```

Why should this not be enough?

```
lively.showProgress("update", () => {
    this.db.files.where("name").notEqual("").modify((ea) => {
       this.extractTitleAndTags(ea)
    });
})
```

Ok, I implemented a #ContextJS layer that creates and updates a progress bar on modify.


```

cop.layer(window, "ShowDexieProgress").refineClass(FileCache.current().db.Collection, {
  async modify(func) {
    var i = 0
    var total = await this.count()
    var progress = await lively.showProgress("update");
    if (ShowDexieProgress.currentLabel) {
      progress.textContent = ShowDexieProgress.currentLabel
    }
    var innerFunc = function(ea)  {
      progress.value = i++ / total
      func(ea)
    }
    // #TODO 'cop.proceed' does not work in the async setting...
    var result = await cop.withoutLayers([ShowDexieProgress], async () => {
      return this.modify(innerFunc)
    })
    progress.remove()
    return result
  }
})
```

```
cop.withLayers([ShowDexieProgress], () => {
  FileCache.current().db.files.where("title").equals("").modify(ea => {
    ea.title = ""
  })
})
```

hiding the layer-based implementation:

```
FileCache.current().showProgress("update title", () => {
  FileCache.current().db.files.where("title").equals("").modify(ea => {
    ea.title = ""
  })
})
```

Resulting in a clean "update" method:
```
  async update() {
    this.showProgress("update title", () => {
      this.db.files.where("name").notEqual("").modify((ea) => {
         this.extractTitleAndTags(ea)
      });
    })
  }
```

