|
4 | 4 | border: red 1px solid !important; |
5 | 5 | } |
6 | 6 | </style> |
| 7 | + |
| 8 | + <h3>Current flavors</h3> |
| 9 | + <ul> |
| 10 | + {% for flavor in flavors %} |
| 11 | + <li>{{ flavor.id }} - {{ flavor.name }} - {{ flavor.label }}</li> |
| 12 | + {% endfor %} |
| 13 | + </ul> |
7 | 14 |
|
8 | 15 | <div> |
9 | 16 | <h3>New Flavor (instance variable)</h3> |
@@ -31,85 +38,50 @@ <h3>New Flavor (class attribute)</h3> |
31 | 38 | <button unicorn:click="add_class_flavor">Add Flavor (class attribute)</button> |
32 | 39 | </div> |
33 | 40 |
|
34 | | - <!-- Can use unicorn:model or unicorn:db --> |
35 | | - <div unicorn:model="flavors" unicorn:db="flavor"> |
36 | | - <div unicorn:pk=""> |
37 | | - <h3>New flavor with blank PK</h3> |
| 41 | + <div> |
| 42 | + <h3>Using unicorn:db</h3> |
| 43 | + |
| 44 | + <div unicorn:db="flavor"> |
38 | 45 | <div> |
39 | 46 | <label>Name</label> |
40 | | - <input type="text" unicorn:field.defer="name"></input> |
41 | | - |
42 | | - <strong>Name</strong> {{ flavor.name }} |
| 47 | + <input type="text" unicorn:field.defer="name" u:dirty.class="dirty"></input> |
43 | 48 | </div> |
44 | 49 |
|
45 | 50 | <div> |
46 | 51 | <label>Label</label> |
47 | | - <input type="text" unicorn:field.defer="label"></input> |
48 | | - |
49 | | - <strong>Label</strong> {{ flavor.label }} |
| 52 | + <input type="text" unicorn:field.defer="label" u:dirty.class="dirty"></input> |
50 | 53 | </div> |
51 | 54 |
|
52 | | - {% comment %} |
53 | | - <label>Parent</label> |
54 | | - <select> |
55 | | - <option value="" selected>None</option> |
56 | | - {% for available_flavor in available_flavors %} |
57 | | - <option value="{{ available_flavor.pk }}" {% if instance_flavor.parent.pk == available_flavor.pk %}selected{% endif %}>{{ available_flavor.name }}</option> |
58 | | - {% endfor %} |
59 | | - </select> |
60 | | - {% endcomment %} |
61 | | - </div> |
62 | | - <br /> |
63 | | - |
64 | | - <h3>Last 2 added flavors</h3> |
65 | | - |
66 | | - {% for flavor in flavors %} |
67 | | - <div unicorn:pk="{{ flavor.pk }}"> |
68 | | - <h4>PK: {{ flavor.pk }}</h4> |
69 | | - <div> |
| 55 | + {% for flavor in flavors %} |
| 56 | + <div unicorn:pk="{{ flavor.pk }}"> |
| 57 | + <h4>{{ flavor.pk }}</h4> |
70 | 58 | <label>Name</label> |
71 | | - <input type="text" unicorn:field.lazy="name" u:dirty.class="dirty"></input> |
72 | | - |
73 | | - <strong>Name</strong> {{ flavor.name }} |
74 | | - </div> |
75 | | - |
76 | | - <div> |
| 59 | + <input type="text" unicorn:field.defer="name" u:dirty.class="dirty" value="{{ flavor.name }}"></input> |
| 60 | + {{ flavor.name }} |
| 61 | + <br /> |
| 62 | + |
77 | 63 | <label>Label</label> |
78 | | - <input type="text" unicorn:field.defer="label" u:dirty.class="dirty"></input> |
79 | | - |
80 | | - <strong>Label</strong> {{ flavor.label }} |
81 | | - </div> |
| 64 | + <input type="text" unicorn:field.defer="label" u:dirty.class="dirty" value="{{ flavor.label }}"></input> |
| 65 | + {{ flavor.label }} |
| 66 | + <br /> |
82 | 67 |
|
83 | | - <div> |
84 | | - <label>Float value</label> |
| 68 | + <label>Float</label> |
85 | 69 | <input type="text" unicorn:field.defer="float_value"></input> |
86 | | - |
87 | | - <strong>Float value</strong> {{ flavor.float_value }} |
88 | | - </div> |
| 70 | + {{ flavor.float_value }} |
| 71 | + <br /> |
89 | 72 |
|
90 | | - <div> |
91 | 73 | <label>Decimal value</label> |
92 | 74 | <input type="text" unicorn:field.defer="decimal_value"></input> |
93 | | - |
94 | | - <strong>Decimal value</strong> {{ flavor.decimal_value }} |
95 | | - </div> |
96 | | - |
97 | | - <button unicorn:click="delete($model)">delete($model)</button> |
98 | | - <br/> |
| 75 | + {{ flavor.decimal_value }} |
| 76 | + <br /> |
99 | 77 |
|
100 | | - <!-- todo: get updating parent working correctly --> |
101 | | - <label>Parent</label> |
102 | | - <select> |
103 | | - <option value="" selected>None</option> |
104 | | - {% for available_flavor in available_flavors %} |
105 | | - <option value="{{ available_flavor.pk }}" {% if flavor.parent.pk == available_flavor.pk %}selected{% endif %}>{{ available_flavor.name }}</option> |
106 | | - {% endfor %} |
107 | | - </select> |
| 78 | + <button unicorn:click="delete($model)">delete($model)</button> |
| 79 | + </div> |
| 80 | + {% endfor %} |
108 | 81 | </div> |
109 | | - {% endfor %} |
110 | 82 | </div> |
111 | | - <br /> |
112 | | - |
| 83 | + |
| 84 | + <br /><br /> |
113 | 85 | <button unicorn:click="$refresh">$refresh</button> |
114 | 86 | <button unicorn:click="$reset">$reset</button> |
115 | 87 | </div> |
0 commit comments