Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Simplify status selector
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbedard committed Apr 25, 2017
1 parent c2f061f commit 9c04e7f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 30 deletions.
1 change: 0 additions & 1 deletion build/webpack.base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module.exports = {
options_inventories: resolve('formwidgets/optionsinventories/components'),
products: resolve('controllers/products'),
relationships: resolve('formwidgets/relationships/components'),
status_selector: resolve('formwidgets/statusselector'),
},
output: {
filename: '[name].min.js',
Expand Down
16 changes: 0 additions & 16 deletions formwidgets/StatusSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ class StatusSelector extends FormWidgetBase
*/
protected $defaultAlias = 'bedard_shop_status_selector';

/**
* {@inheritdoc}
*/
public function init()
{
}

/**
* {@inheritdoc}
*/
Expand All @@ -42,15 +35,6 @@ public function prepareVars()
$this->vars['statuses'] = Status::all();
}

/**
* {@inheritdoc}
*/
public function loadAssets()
{
$this->addJs('/plugins/bedard/shop/assets/dist/vendor.min.js', 'Bedard.Shop');
$this->addJs('/plugins/bedard/shop/assets/dist/status_selector.min.js', 'Bedard.Shop');
}

/**
* {@inheritdoc}
*/
Expand Down
23 changes: 10 additions & 13 deletions formwidgets/statusselector/partials/_statusselector.htm
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<div
data-component="status-selector"
data-name="<?= $name ?>"
data-statuses="<?= e($statuses->toJson()) ?>"
data-value="<?= $value ?>">
</div>

<script>
// since this component is usually loaded in a modal, we
// will manually mount our comonent through the window
// to avoid any timing bugs with october's spinner.
window.mountBedardShopStatusSelector();
</script>
<select
name="<?= $name ?>"
class="form-control custom-select">
<option value=""><?= e(trans('bedard.shop::lang.drivers.form.status_selector_placeholder')) ?></option>
<?php foreach ($statuses as $status): ?>
<option value="<?= $status->id ?>" <?= $value == $status->id ? 'selected' : '' ?>>
<?= $status->name ?>
</option>
<?php endforeach; ?>
</select>
3 changes: 3 additions & 0 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
// drivers
//
'drivers' => [
'form' => [
'status_selector_placeholder' => 'Select a status',
],
'nopayment' => [
'event_complete' => 'Checkout complete',
'event_complete_descrition' => 'This event fires when a user completes the checkout process.',
Expand Down

0 comments on commit 9c04e7f

Please sign in to comment.