edit_event.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. {% extends "dbadmin_base.html" %}
  2. {%block styles %}
  3. {{super()}}
  4. <style>
  5. #selected {
  6. margin: 5px;
  7. padding: 5px;
  8. border: 2px dashed #999;
  9. }
  10. </style>
  11. {%endblock styles%}
  12. {%block scripts %}
  13. {{super()}}
  14. </script>
  15. <script type="text/javascript">
  16. var my_id = {{alarm.eid}};
  17. $(function() {
  18. $('.avail').draggable({
  19. connectToSortable: '#selected',
  20. helper: 'clone',
  21. }).droppable({
  22. drop: function(evt, ui) {
  23. $(ui.draggable).remove();
  24. },
  25. });
  26. $('#selected').sortable({
  27. })
  28. $('ul, li').disableSelection();
  29. $('button').button().click(function(evt) {
  30. var ids = $('#selected li').map(function(i, li) {
  31. return $(li).data('id');
  32. });
  33. jQuery.post(
  34. '{{routeprefix}}/db/api/alarm/' + my_id + '/actions',
  35. {"actions[]": ids.toArray()},
  36. function onSuccess(data, textStatus, xhr) {
  37. window.location.href = "{{routeprefix}}/db/list";
  38. }
  39. );
  40. });
  41. });
  42. </script>
  43. {%endblock scripts %}
  44. {% block title %}Larigira - edit event {%endblock%}
  45. {% block content %}
  46. <div class="container-fluid">
  47. {% if alarm: %}
  48. You are currently editing: <code>{{alarm|tojson}}</code>
  49. {% endif %}
  50. <h2>Change actions</h2>
  51. <div>
  52. Available actions:
  53. <ul>
  54. {% for a in all_actions %}
  55. <li title="{{a.kind}}"
  56. data-nick="{{a.nick}}"
  57. data-id="{{a.eid}}"
  58. class="avail ui-state-highlight">{% if a.nick %} {{a.nick}} {% else %} {{a.eid}} {%endif%}</li>
  59. {% endfor %}
  60. </ul>
  61. </div>
  62. <div>
  63. Actions currently added:
  64. <ul id="selected">
  65. {% for a in actions %}
  66. <li title="{{a.kind}}"
  67. data-nick="{{a.nick}}"
  68. data-id="{{a.eid}}"
  69. class="ui-state-default">{% if a.nick %} {{a.nick}} {% else %} {{a.eid}} {%endif%}</li>
  70. {% endfor %}
  71. </ul>
  72. </div>
  73. <div>
  74. <button>Save</button>
  75. </div>
  76. </div>
  77. {% endblock content %}
  78. {# vim: set ts=2 sw=2 noet: #}