forked from fanruan/fineui-start
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.6 KiB
56 lines
1.6 KiB
!(function () { |
|
|
|
var ToDoListModel = BI.inherit(Fix.Model, { |
|
|
|
state: function () { |
|
return { |
|
list: [] |
|
}; |
|
}, |
|
watch: {}, |
|
|
|
computed: { |
|
todoList: function () { |
|
var items = BI.filter(this.model.list, function (index, item) { |
|
return !item.done; |
|
}); |
|
return BI.map(items, function (index, item) { |
|
return BI.extend({ |
|
type: "bi.multi_select_item" |
|
}, item); |
|
}); |
|
}, |
|
doneList: function () { |
|
var items = BI.filter(this.model.list, function (index, item) { |
|
return item.done; |
|
}); |
|
return BI.map(items, function (index, item) { |
|
return BI.extend({ |
|
type: "bi.multi_select_item", |
|
selected: true, |
|
disabled: true |
|
}, item); |
|
}); |
|
} |
|
}, |
|
|
|
actions: { |
|
addToDo: function (v) { |
|
this.model.list.push({ |
|
value: BI.UUID(), |
|
text: v, |
|
done: false |
|
}); |
|
}, |
|
|
|
finish: function (v) { |
|
BI.some(this.model.list, function (index, item) { |
|
if (item.value === v) { |
|
item.done = true; |
|
} |
|
}); |
|
} |
|
} |
|
}); |
|
BI.model("my.model.todolist", ToDoListModel); |
|
})();
|
|
|