-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask-list.html
More file actions
49 lines (42 loc) · 1.16 KB
/
task-list.html
File metadata and controls
49 lines (42 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<link rel="import" href="components/polymer/polymer.html">
<link rel="import" href="components/core-ajax/core-ajax.html">
<link rel="import" href="task-box.html">
<polymer-element name="task-list">
<template>
<core-ajax id="ajax"
auto
url="all/"
on-core-response="{{tasksLoaded}}"
handleAs="json">
</core-ajax>
<div layout vertical center>
<template repeat="{{task in tasks}}">
<task-box done="{{task.done}}" dataid="{{task.id}}" assigned="{{task.assigned}}">{{task.description}}</task-box>
</template>
</div>
</template>
<script>
Polymer({
tasks: [],
tasksLoaded: function () {
this.tasks = this.$.ajax.response.slice(0)
},
addTask: function (task) {
// overrides properties from from in into
function extend(into, from) {
for (var prop in from)
into[prop] = from[prop]
}
var std = {
id: -1,
done: false,
description: '',
assigned: null
}
extend(std, task)
this.tasks.push(task)
return task
}
})
</script>
</polymer-element>