files.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\gii\CodeFile;
  4. /**
  5. * @var \yii\web\View $this
  6. * @var \yii\gii\Generator $generator
  7. * @var CodeFile[] $files
  8. * @var array $answers
  9. * @var string $id panel ID
  10. */
  11. ?>
  12. <div class="default-view-files">
  13. <div id="action-toggle" class="btn-group btn-group-xs pull-right">
  14. <label class="btn btn-success active" title="Filter files that are created">
  15. <input type="checkbox" value="<?= CodeFile::OP_CREATE ?>" checked> Create
  16. </label>
  17. <label class="btn btn-default active" title="Filter files that are unchanged.">
  18. <input type="checkbox" value="<?= CodeFile::OP_SKIP ?>" checked> Unchanged
  19. </label>
  20. <label class="btn btn-warning active" title="Filter files that are overwritten">
  21. <input type="checkbox" value="<?= CodeFile::OP_OVERWRITE ?>" checked> Overwrite
  22. </label>
  23. </div>
  24. <p>Click on the above <code>Generate</code> button to generate the files selected below:</p>
  25. <table class="table table-bordered table-striped table-condensed">
  26. <thead>
  27. <tr>
  28. <th class="file">Code File</th>
  29. <th class="action">Action</th>
  30. <?php
  31. $fileChangeExists = false;
  32. foreach ($files as $file) {
  33. if ($file->operation !== CodeFile::OP_SKIP) {
  34. $fileChangeExists = true;
  35. echo '<th><input type="checkbox" id="check-all"></th>';
  36. break;
  37. }
  38. }
  39. ?>
  40. </tr>
  41. </thead>
  42. <tbody>
  43. <?php foreach ($files as $file): ?>
  44. <?php
  45. if ($file->operation === CodeFile::OP_OVERWRITE) {
  46. $trClass = 'warning';
  47. } elseif ($file->operation === CodeFile::OP_SKIP) {
  48. $trClass = 'active';
  49. } elseif ($file->operation === CodeFile::OP_CREATE) {
  50. $trClass = 'success';
  51. } else {
  52. $trClass = '';
  53. }
  54. ?>
  55. <tr class="<?= "$file->operation $trClass" ?>">
  56. <td class="file">
  57. <?= Html::a(Html::encode($file->getRelativePath()), ['preview', 'id' => $id, 'file' => $file->id], ['class' => 'preview-code', 'data-title' => $file->getRelativePath()]) ?>
  58. <?php if ($file->operation === CodeFile::OP_OVERWRITE): ?>
  59. <?= Html::a('diff', ['diff', 'id' => $id, 'file' => $file->id], ['class' => 'diff-code label label-warning', 'data-title' => $file->getRelativePath()]) ?>
  60. <?php endif; ?>
  61. </td>
  62. <td class="action">
  63. <?php
  64. if ($file->operation === CodeFile::OP_SKIP) {
  65. echo 'unchanged';
  66. } else {
  67. echo $file->operation;
  68. }
  69. ?>
  70. </td>
  71. <?php if ($fileChangeExists): ?>
  72. <td class="check">
  73. <?php
  74. if ($file->operation === CodeFile::OP_SKIP) {
  75. echo '&nbsp;';
  76. } else {
  77. echo Html::checkBox("answers[{$file->id}]", isset($answers) ? isset($answers[$file->id]) : ($file->operation === CodeFile::OP_CREATE));
  78. }
  79. ?>
  80. </td>
  81. <?php endif; ?>
  82. </tr>
  83. <?php endforeach; ?>
  84. </tbody>
  85. </table>
  86. <div class="modal fade" id="preview-modal" tabindex="-1" role="dialog">
  87. <div class="modal-dialog">
  88. <div class="modal-content">
  89. <div class="modal-header">
  90. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  91. <div class="btn-group pull-left">
  92. <a class="modal-previous btn btn-xs btn-default" href="#" title="Previous File (Left Arrow)"><span class="glyphicon glyphicon-arrow-left"></span></a>
  93. <a class="modal-next btn btn-xs btn-default" href="#" title="Next File (Right Arrow)"><span class="glyphicon glyphicon-arrow-right"></span></a>
  94. <a class="modal-refresh btn btn-xs btn-default" href="#" title="Refresh File (R)"><span class="glyphicon glyphicon-refresh"></span></a>
  95. &nbsp;
  96. </div>
  97. <strong class="modal-title pull-left">Modal title</strong>
  98. <div class="clearfix"></div>
  99. </div>
  100. <div class="modal-body">
  101. <p>Please wait ...</p>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. </div>