Add product tab to wish

This commit is contained in:
grandeljay 2022-06-13 09:20:45 +02:00
parent 3456456ea4
commit 8307e7092e
3 changed files with 112 additions and 85 deletions

View file

@ -1,5 +1,10 @@
$(function () {
/**
* Tabs
*/
$('.menu.wish-add .item').tab();
/**
* Priority
*/
@ -8,6 +13,13 @@ $(function () {
/**
* Properties
*/
$('.checkbox').checkbox();
$('.checkbox').checkbox({
onChecked : function() {
$('.menu.wish-add .item[data-tab="product"]').removeClass('disabled');
},
onUnchecked : function() {
$('.menu.wish-add .item[data-tab="product"]').addClass('disabled');
},
});
});

View file

@ -10,88 +10,107 @@ $scriptPart = '/src/assets/js/parts/wish-add.js';
?>
<script defer src="<?= $scriptPart ?>?m=<?= filemtime(ROOT . $scriptPart) ?>"></script>
<div class="stackable row">
<div class="column">
<div class="ui secondary menu wish-add">
<a class="item active" data-tab="general"><?= __('General') ?></a>
<a class="item disabled" data-tab="product"><?= __('Product') ?></a>
</div>
<div class="field">
<label><?= __('Title') ?></label>
<div class="ui tab" data-tab="general">
<div class="ui two column grid">
<div class="stackable row">
<div class="column">
<div class="ui input">
<input type="text"
name="wish_title"
placeholder="<?= $wish->title ?? '' ?>"
value="<?= $wish->title ?? '' ?>"
maxlength="128"
/>
</div>
</div>
<div class="field">
<label><?= __('Title') ?></label>
<div class="field">
<label><?= __('Description') ?></label>
<textarea name="wish_description"
placeholder="<?= $wish->description ?? '' ?>"
><?= $wish->description ?? '' ?></textarea>
</div>
</div>
<div class="column">
<div class="field">
<label><?= __('URL') ?></label>
<input type="url"
name="wish_url"
placeholder="<?= $wish->url ?? '' ?>"
value="<?= $wish->url ?? '' ?>"
maxlength="255"
/>
</div>
<div class="field">
<label><?= __('Priority') ?></label>
<select class="ui selection clearable dropdown priority"
name="wish_priority"
>
<option value=""><?= __('Select priority') ?></option>
<?php foreach (Wish::$priorities as $priority => $item) { ?>
<?php if (isset($wish->priority) && $wish->priority === $priority) { ?>
<option value="<?= $priority ?>" selected><?= $item['name'] ?></option>
<?php } else { ?>
<option value="<?= $priority ?>"><?= $item['name'] ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="field disabled">
<label><?= __('Price') ?></label>
<input type="text"
name="wish_price"
placeholder="<?= $wish->price ?? '' ?>"
value="<?= $wish->price ?? '' ?>"
maxlength="9"
/>
</div>
<div class="grouped fields">
<label><?= __('Properties') ?></label>
<div class="field">
<div class="ui checkbox">
<input type="checkbox"
name="wish_is_purchasable"
<?= isset($wish->is_purchasable) && $wish->is_purchasable ? 'checked' : '' ?>
/>
<label><?= __('Is purchasable') ?></label>
<div class="ui input">
<input type="text"
name="wish_title"
placeholder="<?= $wish->title ?? '' ?>"
value="<?= $wish->title ?? '' ?>"
maxlength="128"
/>
</div>
</div>
<div class="field">
<label><?= __('Description') ?></label>
<textarea name="wish_description"
placeholder="<?= $wish->description ?? '' ?>"
><?= $wish->description ?? '' ?></textarea>
</div>
</div>
<div class="column">
<div class="field">
<label><?= __('URL') ?></label>
<input type="url"
name="wish_url"
placeholder="<?= $wish->url ?? '' ?>"
value="<?= $wish->url ?? '' ?>"
maxlength="255"
/>
</div>
<div class="field">
<label><?= __('Priority') ?></label>
<select class="ui selection clearable dropdown priority"
name="wish_priority"
>
<option value=""><?= __('Select priority') ?></option>
<?php foreach (Wish::$priorities as $priority => $item) { ?>
<?php if (isset($wish->priority) && $wish->priority === $priority) { ?>
<option value="<?= $priority ?>" selected><?= $item['name'] ?></option>
<?php } else { ?>
<option value="<?= $priority ?>"><?= $item['name'] ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="grouped fields">
<label><?= __('Properties') ?></label>
<div class="field">
<div class="ui checkbox">
<input type="checkbox"
name="wish_is_purchasable"
<?= isset($wish->is_purchasable) && $wish->is_purchasable ? 'checked' : '' ?>
/>
<label><?= __('Is purchasable') ?></label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="ui tab" data-tab="product">
<div class="ui two column grid">
<div class="stackable row">
<div class="column">
<div class="field">
<label><?= __('Price') ?></label>
<input type="text"
name="wish_price"
placeholder="<?= $wish->price ?? '' ?>"
value="<?= $wish->price ?? '' ?>"
maxlength="9"
/>
</div>
</div>
</div>
</div>
</div>

View file

@ -167,14 +167,12 @@ $page->navigation();
</div>
<div class="content">
<div class="description">
<p><?= __('Fill out any or all of the below fields to add your new wish. If you just fill out the URL, wishthis will attempt to auto fill all other fields.') ?></p>
<p><?= __('Fill the title and/or description to add your new wish. If you just fill out the URL, wishthis will attempt to auto fill all other fields.') ?></p>
<form class="ui form wishlist-wish-add" method="POST">
<input type="hidden" name="wishlist_id" />
<div class="ui two column grid">
<?php include 'parts/wish-add.php' ?>
</div>
<?php include 'parts/wish-add.php' ?>
<div class="ui error message"></div>
</form>
@ -201,9 +199,7 @@ $page->navigation();
<input type="hidden" name="wishlist_id" />
<input type="hidden" name="wish_id" />
<div class="ui two column grid">
<?php include 'parts/wish-add.php' ?>
</div>
<?php include 'parts/wish-add.php' ?>
<div class="ui error message"></div>
</form>