edit_widget.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. global $myUser;
  3. User::check_access('statistic','edit');
  4. require_once(__DIR__.SLASH.'Widget.class.php');
  5. require_once(__DIR__.SLASH.'View.class.php');
  6. $widget = Widget::provide();
  7. if($myUser->login != $widget->creator && !$myUser->can('statistic','edit',$widget->id) ) throw new Exception("Edition non permise");
  8. $view = $widget->view;
  9. $widgetLabel = $widget->label == '' ? 'Widget' : $widget->label;
  10. ?>
  11. <div class="row stats-widget-board" id="widget" data-id="<?php echo $widget->id; ?>">
  12. <!-- panel elements -->
  13. <div class="stats-element-panel">
  14. <div class="widget-tree">
  15. <h5>
  16. <span id="widgetPropertiesTitle"><?php echo ($widget->label == '' ? '' : 'Widget : '); ?></span>
  17. <a id="widgetProperties" onclick="stats_select_properties_tab();"><?php echo $widgetLabel; ?></a>
  18. </h5>
  19. <table class="table table-dark stats-widget-element" id="elements">
  20. <thead>
  21. <tr>
  22. <th>
  23. <div class="form-row">
  24. <div class="form-group col-md-12">
  25. <label for="label">Libellé</label>
  26. <input class="form-control-sm" id="label" name="label" type="text">
  27. </div>
  28. </div>
  29. </th>
  30. <th>
  31. <div class="form-row">
  32. <div class="form-group col-md-6">
  33. <label for="type">Type</label>
  34. <select class="form-control-sm" id="type" name="type">
  35. <?php foreach(glob(__DIR__.SLASH.'element'.SLASH.'*.class.php') as $file):
  36. require_once($file);
  37. $className = str_replace('.class.php','',basename($file));
  38. $instance = new $className();
  39. ?>
  40. <option value="<?php echo $className; ?>"><?php echo $instance->typeLabel; ?></option>
  41. <?php endforeach; ?>
  42. </select>
  43. </div>
  44. </div>
  45. </th>
  46. <th>
  47. <div class="widget-btn widget-btn-sm" onclick="stats_save_widget_element();">
  48. <i class="fas fa-check no-margin"></i>
  49. </div>
  50. </th>
  51. </tr>
  52. </thead>
  53. <tbody>
  54. <tr data-id="{{id}}" data-type="{{type}}" class="hidden" onclick="stats_edit_widget_element(this)">
  55. <td><i class="{{icon}}" title="{{typeLabel}}"></i>{{label}}<br><code>id: {{slug}}</code></td>
  56. <td colspan="2">
  57. <div class="right">
  58. <div class="widget-btn widget-btn-sm d-inline-block btn-element-sort" title="Déplacer">
  59. <i class="fas fa-arrows-alt-v"></i>
  60. </div>
  61. <div class="widget-btn widget-btn-sm d-inline-block" title="Modifier" onclick="stats_rename_widget_element(this,event);"><i class="fas fa-pencil-alt no-margin"></i></i></div>
  62. <div class="widget-btn widget-btn-sm d-inline-block" title="Supprimer" onclick="stats_delete_widget_element(this,event);"><i class="fas fa-times no-margin"></i>
  63. </div>
  64. </div>
  65. </td>
  66. </tr>
  67. </tbody>
  68. </table>
  69. <br>
  70. <div class="view-block">
  71. <h5 class="text-muted text-bold">AFFICHAGE</h5>
  72. <ul id="view" class="stats-widget-element">
  73. <?php foreach (View::views() as $item) { ?>
  74. <li onclick="stats_select_widget_view(this);" title="<?php echo $item::$LABEL.' : '.$item::$DESCRIPTION; ?>" class="<?php echo $view==$item ? 'selected':'' ?>" data-uid="<?php echo $item; ?>">
  75. <i class="fa <?php echo $item::$ICON; ?>"></i>
  76. </li>
  77. <?php } ?>
  78. </ul>
  79. <div class="clear"></div>
  80. </div>
  81. </div>
  82. </div>
  83. <!-- editeur -->
  84. <div class="stats-workspace-panel" id="workspace">
  85. <ul class="nav nav-tabs" id="widgetTab" role="tablist">
  86. <li class="nav-item">
  87. <a class="nav-link active" id="edit-tab" data-toggle="tab" href="#edit-panel" role="tab" aria-controls="edit-panel" aria-selected="true">Editeur</a>
  88. </li>
  89. <li class="nav-item">
  90. <a class="nav-link" id="output-tab" data-toggle="tab" href="#output-panel" role="tab" aria-controls="output-panel" aria-selected="false">Données</a>
  91. </li>
  92. <li class="nav-item">
  93. <a class="nav-link" id="preview-tab" data-toggle="tab" href="#preview-panel" role="tab" aria-controls="preview-panel" aria-selected="false">Rendu</a>
  94. </li>
  95. <li class="nav-item" id="widgetPropertiesTab" onclick="stats_properties_load();">
  96. <a class="nav-link" id="properties-tab" data-toggle="tab" href="#properties-panel" role="tab" aria-controls="properties-panel" aria-selected="false">Propriétés</a>
  97. </li>
  98. </ul>
  99. <button id="widgetCloseBtn" type="button" onclick="stats_refresh_widget_content();" class="close widget-btn" data-dismiss="modal" aria-label="Close">
  100. <span>&times;</span>
  101. </button>
  102. <div class="tab-content" id="widgetTabContent">
  103. <div class="tab-pane fade show active" id="edit-panel" role="tabpanel" aria-labelledby="edit-tab"></div>
  104. <div class="tab-pane fade" id="output-panel" role="tabpanel" aria-labelledby="output-tab"></div>
  105. <div class="tab-pane fade" id="preview-panel" role="tabpanel" aria-labelledby="preview-tab"></div>
  106. <div class="tab-pane fade" id="properties-panel" role="tabpanel" aria-labelledby="properties-tab">
  107. <div class="form-row">
  108. <div class="form-group col-md-12 properties-block"></div>
  109. </div>
  110. <div class="element-properties"></div>
  111. </div>
  112. </div>
  113. </div>
  114. <!--<div id="scripts"></div>-->
  115. </div>