Skip to content

Commit

Permalink
feat(admin): added possibility to reset category image, closes #1673
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Mar 22, 2020
1 parent e06c2e2 commit d8e9e84
Showing 1 changed file with 36 additions and 16 deletions.
52 changes: 36 additions & 16 deletions phpmyfaq/admin/category.edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
<input type="hidden" id="catlang" name="catlang" value="<?= $categoryData->getLang() ?>">
<input type="hidden" name="parent_id" value="<?= $categoryData->getParentId() ?>">
<input type="hidden" name="csrf" value="<?= $user->getCsrfTokenFromSession() ?>">
<input type="hidden" name="existing_image" value="<?= $categoryData->getImage() ?>">
<input type="hidden" name="existing_image" value="<?= $categoryData->getImage() ?>"
id="pmf-category-existing-image">

<div class="form-group row">
<label class="col-lg-2 col-form-label">
Expand Down Expand Up @@ -115,24 +116,33 @@ class="form-control"><?= $categoryData->getDescription() ?></textarea>

<div class="form-group row">
<label class="col-lg-2 col-form-label" for="pmf-category-image-upload">
<?= $PMF_LANG['ad_category_image'] ?>:
<?= $PMF_LANG['ad_category_image'] ?>
</label>
<div class="col-lg-4">
<div class="custom-file">
<input type="file" class="custom-file-input" name="image" id="pmf-category-image-upload"
value="<?= $categoryData->getImage() ?>">
<label class="custom-file-label" for="pmf-category-image-upload"><?= $categoryData->getImage() ?></label>
<div class="form-group">
<div class="custom-file">
<input type="file" class="custom-file-input" name="image" id="pmf-category-image-upload"
value="<?= $categoryData->getImage() ?>">
<label class="custom-file-label" for="pmf-category-image-upload" id="pmf-category-image-label">
<?= $categoryData->getImage() ?>
</label>
</div>
</div>
<div class="form-group">
<button type="button" class="btn btn-info" id="button-reset-category-image">
Reset category image
</button>
</div>
</div>
</div>


<div class="form-group row">
<label class="col-lg-2 col-form-label">
<?= $PMF_LANG['ad_categ_owner'] ?>:
<label class="col-lg-2 col-form-label" for="user_id">
<?= $PMF_LANG['ad_categ_owner'] ?>
</label>
<div class="col-lg-4">
<select name="user_id" class="form-control">
<select id="user_id" name="user_id" class="form-control">
<?= $user->getAllUserOptions($categoryData->getUserId()) ?>
</select>
</div>
Expand All @@ -155,12 +165,12 @@ class="form-control"><?= $categoryData->getDescription() ?></textarea>
</div>

<div class="form-group row">
<label class="col-lg-2 col-form-label">
<label class="col-lg-2 col-form-label" for="grouppermission">
<?= $PMF_LANG['ad_entry_grouppermission'] ?>
</label>
<div class="col-lg-4">
<div class="radio">
<input type="radio" name="grouppermission" value="all"
<input type="radio" id="grouppermission" name="grouppermission" value="all"
<?php echo($allGroups ? 'checked' : '') ?>>
<?= $PMF_LANG['ad_entry_all_groups'] ?>
</div>
Expand Down Expand Up @@ -189,16 +199,16 @@ class="form-control"><?= $categoryData->getDescription() ?></textarea>
<?= $PMF_LANG['ad_entry_userpermission'] ?>
</label>
<div class="col-lg-4">
<label class="radio">
<div class="radio">
<input type="radio" name="userpermission" value="all"
<?= ($allUsers ? 'checked' : '') ?>>
<?= $PMF_LANG['ad_entry_all_users'] ?>
</label>
<label class="radio">
</div>
<div class="radio">
<input type="radio" name="userpermission" value="restricted"
<?= ($restrictedUsers ? 'checked' : '') ?>>
<?= $PMF_LANG['ad_entry_restricted_users'] ?>
</label>
</div>
<select name="restricted_users" class="form-control">
<?= $user->getAllUserOptions($userPermission[0]) ?>
</select>
Expand All @@ -217,7 +227,17 @@ class="form-control"><?= $categoryData->getDescription() ?></textarea>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
bsCustomFileInput.init()
bsCustomFileInput.init();

const resetButton = document.getElementById('button-reset-category-image');
const categoryExistingImage = document.getElementById('pmf-category-existing-image');
const categoryImageInput = document.getElementById('pmf-category-image-upload');
const categoryImageLabel = document.getElementById('pmf-category-image-label');
resetButton.addEventListener('click', () => {
categoryImageInput.value = '';
categoryExistingImage.value = '';
categoryImageLabel.innerHTML = '';
});
});
</script>
<?php
Expand Down

0 comments on commit d8e9e84

Please sign in to comment.