files.php 3.05 KB
Newer Older
Qiang Xue committed
1 2 3 4 5 6
<?php

use yii\helpers\Html;
use yii\gii\CodeFile;

/**
slavcodev committed
7 8
 * @var \yii\web\View $this
 * @var \yii\gii\Generator $generator
Qiang Xue committed
9 10 11 12 13 14 15 16 17 18 19 20
 * @var CodeFile[] $files
 * @var array $answers
 */
?>
<div class="default-view-files">
	<p>Click on the above <code>Generate</code> button to generate the files selected below:</p>

	<table class="table table-bordered table-striped table-condensed">
		<thead>
			<tr>
				<th class="file">Code File</th>
				<th class="action">Action</th>
21
				<?php
Nikola Trifunovic committed
22
				$fileChangeExists = false;
23 24
				foreach ($files as $file) {
					if ($file->operation !== CodeFile::OP_SKIP) {
Nikola Trifunovic committed
25
						$fileChangeExists = true;
26 27
						echo '<th><input type="checkbox" id="check-all"></th>';
						break;
Qiang Xue committed
28
					}
29 30 31
				}
				?>
				
Qiang Xue committed
32 33 34 35
			</tr>
		</thead>
		<tbody>
			<?php foreach ($files as $file): ?>
36 37 38 39 40 41 42 43 44 45 46 47
			<?php
			if ($file->operation === CodeFile::OP_OVERWRITE) {
				$trClass = 'warning';
			} elseif ($file->operation === CodeFile::OP_SKIP) {
				$trClass = 'active';
			} elseif ($file->operation === CodeFile::OP_CREATE) {
				$trClass = 'success';
			} else {
				$trClass = '';
			}
			?>
			<tr class="<?= "$file->operation $trClass" ?>">
Qiang Xue committed
48
				<td class="file">
Alexander Makarov committed
49
					<?= Html::a(Html::encode($file->getRelativePath()), ['preview', 'file' => $file->id], ['class' => 'preview-code', 'data-title' => $file->getRelativePath()]) ?>
Qiang Xue committed
50
					<?php if ($file->operation === CodeFile::OP_OVERWRITE): ?>
Alexander Makarov committed
51
						<?= Html::a('diff', ['diff', 'file' => $file->id], ['class' => 'diff-code label label-warning', 'data-title' => $file->getRelativePath()]) ?>
Qiang Xue committed
52 53 54 55 56 57 58 59 60 61 62
					<?php endif; ?>
				</td>
				<td class="action">
					<?php
					if ($file->operation === CodeFile::OP_SKIP) {
						echo 'unchanged';
					} else {
						echo $file->operation;
					}
					?>
				</td>
63
				<?php if ($fileChangeExists): ?>
Qiang Xue committed
64 65 66 67 68
				<td class="check">
					<?php
					if ($file->operation === CodeFile::OP_SKIP) {
						echo '&nbsp;';
					} else {
69
						echo Html::checkBox("answers[{$file->id}]", isset($answers) ? isset($answers[$file->id]) : ($file->operation === CodeFile::OP_CREATE));
Qiang Xue committed
70 71 72
					}
					?>
				</td>
73
				<?php endif; ?>
Qiang Xue committed
74 75 76 77 78
			</tr>
			<?php endforeach; ?>
		</tbody>
	</table>

79
	<div class="modal fade" id="preview-modal" tabindex="-1" role="dialog">
Qiang Xue committed
80 81 82 83
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
84
					<div class="btn-group pull-left">
Thiago Talma committed
85 86 87
						<a class="modal-previous btn btn-xs btn-default" href="#" title="Previous File (Left Arrow)"><span class="glyphicon glyphicon-arrow-left"></span></a>
						<a class="modal-next btn btn-xs btn-default" href="#" title="Next File (Right Arrow)"><span class="glyphicon glyphicon-arrow-right"></span></a>
						<a class="modal-refresh btn btn-xs btn-default" href="#" title="Refresh File (R)"><span class="glyphicon glyphicon-refresh"></span></a>
88 89 90 91
						&nbsp;
					</div>
					<strong class="modal-title pull-left">Modal title</strong>
					<div class="clearfix"></div>
Qiang Xue committed
92 93 94 95 96 97 98 99
				</div>
				<div class="modal-body">
					<p>Please wait ...</p>
				</div>
			</div>
		</div>
	</div>
</div>