Skip to content

Commit

Permalink
move new user form outside of user list
Browse files Browse the repository at this point in the history
+ fix confirm delete route bug
  • Loading branch information
vincent-peugnet committed Oct 16, 2024
1 parent 91d6f82 commit 315964b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 41 deletions.
78 changes: 38 additions & 40 deletions app/view/templates/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,19 @@
<main class="user">

<section>

<div class="block">

<h1>Admin panel</h1>

<h2>Users</h2>
<div class="scroll">

<table>
<tr>
<th>id</th><th>password</th><th>hash</th><th>level</th><th>set expiration date</th><th>action</th><th>expire</th><th>connect</th>
</tr>

<tr>
<form action="<?= $this->url('useradd') ?>" method="post">
<td>
<input type="text" name="id" maxlength="<?= Wcms\Model::MAX_ID_LENGTH ?>" required>
</td>
<td>
<input type="password" name="password" id="password" minlength="<?= Wcms\Model::PASSWORD_MIN_LENGTH ?>" maxlength="<?= Wcms\Model::PASSWORD_MAX_LENGTH ?>" required>
</td>

<td>
<input type="hidden" name="passwordhashed" value="0">
<input type="checkbox" name="passwordhashed" value="1" checked>
</td>

<td>
<select name="level" id="level">
<option value="1">reader</option>
<option value="2">invite</option>
<option value="3">editor</option>
<option value="4">super editor</option>
<option value="10">admin</option>
</select>
</td>
<td>
<input type="date" name="expiredate" id="expiredate" min="<?= $now->format('Y-m-d'); ?>">
</td>
<td>
<input type="submit" value="add">
</td>
<td>

</td>
<td>

</td>

</form>
</tr>


<?php
foreach ($userlist as $user ) {
Expand Down Expand Up @@ -134,6 +96,42 @@

</section>

<section class="new-user">

<div class="block">

<h2>Add new user</h2>

<div class="scroll">


<form action="<?= $this->url('useradd') ?>" method="post">

<label for="id">username</label>
<input type="text" name="id" id="id" maxlength="<?= Wcms\Model::MAX_ID_LENGTH ?>" required>
<label for="password">password</label>
<input type="password" name="password" id="password" minlength="<?= Wcms\Model::PASSWORD_MIN_LENGTH ?>" maxlength="<?= Wcms\Model::PASSWORD_MAX_LENGTH ?>" required>
<div>
<input type="hidden" name="passwordhashed" value="0">
<input type="checkbox" name="passwordhashed" id="passwordhashed" value="1" checked>
<label for="passwordhashed">hash password</label>
</div>
<label for="level">level</label>
<select name="level" id="level">
<option value="1">reader</option>
<option value="2">invite</option>
<option value="3">editor</option>
<option value="4">super editor</option>
<option value="10">admin</option>
</select>
<label for="expiredate">expiration date</label>
<input type="date" name="expiredate" id="expiredate" min="<?= $now->format('Y-m-d'); ?>">
<input type="submit" value="add">
</form>

</div>
</div>
</section>

</main>

Expand Down
2 changes: 1 addition & 1 deletion app/view/templates/userconfirmdelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@



<form action="<?= $this->url('userupdate') ?>" method="post">
<form action="<?= $this->url('useredit') ?>" method="post">

<input type="hidden" name="id" value="<?= $userdelete->id() ?>">

Expand Down
5 changes: 5 additions & 0 deletions assets/css/user.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ main.user table form {
main.user td {
white-space: nowrap;
}


.new-user form > * {
display: block;
}

0 comments on commit 315964b

Please sign in to comment.