Benjamin Renard commited on 2016-09-06 22:30:25
Showing 4 changed files, with 37 additions and 1 deletions.
... | ... |
@@ -133,6 +133,21 @@ on_close_copy_scase_modal=function () { |
133 | 133 |
$('#copy_scase_modal form')[0].reset(); |
134 | 134 |
} |
135 | 135 |
|
136 |
+/*********************** |
|
137 |
+ * Reset scase |
|
138 |
+ **********************/ |
|
139 |
+on_reset_scase_btn_click=function(event) { |
|
140 |
+ navbar_collapse_hide(); |
|
141 |
+ var scase=scases.byName($('#cats').data('scase')); |
|
142 |
+ if (scase) { |
|
143 |
+ myconfirm('Voulez-vous vraiment réinitialiser la valise '+$('#cats').data('scase')+' ?', |
|
144 |
+ function(data) { |
|
145 |
+ scases.resetSCase(scase.name); |
|
146 |
+ scases.save(); |
|
147 |
+ show_scase(scase); |
|
148 |
+ }); |
|
149 |
+ } |
|
150 |
+} |
|
136 | 151 |
/*********************** |
137 | 152 |
* Delete scase |
138 | 153 |
**********************/ |
... | ... |
@@ -603,6 +618,7 @@ $( document ).ready( function() { |
603 | 618 |
$("#copy_scase_modal").on('hidden.bs.modal',on_close_copy_scase_modal); |
604 | 619 |
$("#copy_scase_modal form").bind('submit',on_valid_copy_scase_modal); |
605 | 620 |
|
621 |
+ $('#reset_scase_btn').bind('click',on_reset_scase_btn_click); |
|
606 | 622 |
$('#delete_scase_btn').bind('click',on_delete_scase_btn_click); |
607 | 623 |
|
608 | 624 |
$('#add_cat_btn').bind('click',on_add_cat_btn_click); |
... | ... |
@@ -181,6 +181,14 @@ function SCaseList() { |
181 | 181 |
return false; |
182 | 182 |
} |
183 | 183 |
|
184 |
+ this.resetSCase=function(name) { |
|
185 |
+ for (el in this) { |
|
186 |
+ if (this.isSCase(this[el]) && this[el].name==name) { |
|
187 |
+ return this[el].reset(); |
|
188 |
+ } |
|
189 |
+ } |
|
190 |
+ return false; |
|
191 |
+ } |
|
184 | 192 |
} |
185 | 193 |
|
186 | 194 |
function SCase(name,data) { |
... | ... |
@@ -211,6 +219,17 @@ function SCase(name,data) { |
211 | 219 |
return this.cats.length; |
212 | 220 |
} |
213 | 221 |
|
222 |
+ this.reset=function() { |
|
223 |
+ this.cats.each(function(idx,cat) { |
|
224 |
+ for (idx in cat.things) { |
|
225 |
+ if (cat.things[idx].checked) { |
|
226 |
+ cat.things[idx].checked=false; |
|
227 |
+ } |
|
228 |
+ } |
|
229 |
+ }); |
|
230 |
+ return true; |
|
231 |
+ } |
|
232 |
+ |
|
214 | 233 |
/* |
215 | 234 |
* Contructor |
216 | 235 |
*/ |
... | ... |
@@ -62,6 +62,7 @@ div.panel-heading, li.list-group-item, a { |
62 | 62 |
<li class="divider"></li> |
63 | 63 |
<li><a href="#rename_scase" id="rename_scase_btn"><span class="glyphicon glyphicon-edit"></span> Renommer la valise</a></li> |
64 | 64 |
<li><a href="#copy_scase" id="copy_scase_btn"><span class="glyphicon glyphicon-duplicate"></span> Copier la valise</a></li> |
65 |
+ <li><a href="#reset_scase" id="reset_scase_btn"><span class="glyphicon glyphicon-cog"></span> RĂ©initialiser la valise</a></li> |
|
65 | 66 |
<li><a href="#delete_scase" id="delete_scase_btn"><span class="glyphicon glyphicon-trash"></span> Supprimer la valise</a></li> |
66 | 67 |
</ul> |
67 | 68 |
</li> |
68 | 69 |