playlist editor draft

This commit is contained in:
bkfox
2022-12-10 03:27:27 +01:00
parent 80cd5baa18
commit cfc0e45439
35 changed files with 13605 additions and 56 deletions

View File

@ -35,7 +35,7 @@ export default class Model {
* Instanciate model with provided data and options.
* By default `url` is taken from `data.url_`.
*/
constructor(data, {url=null, ...options}={}) {
constructor(data={}, {url=null, ...options}={}) {
this.url = url || data.url_;
this.options = options;
this.commit(data);
@ -133,6 +133,8 @@ export default class Model {
}
/**
* List of models
*/
@ -231,6 +233,25 @@ export class Set {
this.items.splice(index,1);
save && this.save();
}
/**
* Clear items, assign new ones
*/
reset(items=[]) {
// TODO: check reactivity
this.items = []
for(var item of items)
this.push(item)
}
move(from, to) {
if(from >= this.length || to > this.length)
throw "source or target index is not in range"
const value = this.items[from]
this.items.splice(from, 1)
this.items.splice(to, 0, value)
}
}
Set[Symbol.iterator] = function () {