forked from BantenITSolutions/oc-shop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First commit. Adding backend products and categories
- Loading branch information
Showing
29 changed files
with
744 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php namespace DShoreman\Shop; | ||
|
||
use Backend; | ||
use System\Classes\PluginBase; | ||
|
||
/** | ||
* Shop Plugin Information File | ||
*/ | ||
class Plugin extends PluginBase | ||
{ | ||
|
||
/** | ||
* Returns information about this plugin. | ||
* | ||
* @return array | ||
*/ | ||
public function pluginDetails() | ||
{ | ||
return [ | ||
'name' => 'Shop', | ||
'description' => 'No description provided yet...', | ||
'author' => 'Dave Shoreman', | ||
'icon' => 'icon-shopping-cart' | ||
]; | ||
} | ||
|
||
public function registerNavigation() | ||
{ | ||
return [ | ||
'shop' => [ | ||
'label' => 'Shop', | ||
'url' => Backend::url('dshoreman/shop/products'), | ||
'icon' => 'icon-shopping-cart', | ||
'permissions' => ['dshoreman.shop.*'], | ||
'order' => 300, | ||
|
||
'sideMenu' => [ | ||
'products' => [ | ||
'label' => 'Products', | ||
'url' => Backend::url('dshoreman/shop/products'), | ||
'icon' => 'icon-gift', | ||
'permissions' => ['dshoreman.shop.access_products'] | ||
], | ||
'categories' => [ | ||
'label' => 'Categories', | ||
'url' => Backend::url('dshoreman/shop/categories'), | ||
'icon' => 'icon-list-ul', | ||
'permissions' => ['dshoreman.shop.access_categories'], | ||
], | ||
], | ||
], | ||
]; | ||
} | ||
|
||
public function registerPermissions() | ||
{ | ||
return [ | ||
'dshoreman.shop.access_products' => ['label' => "Manage the shop's products"], | ||
'dshoreman.shop.access_categories' => ['label' => "Manage the shop categories"], | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php namespace DShoreman\Shop\Controllers; | ||
|
||
use BackendMenu; | ||
use Backend\Classes\Controller; | ||
|
||
/** | ||
* Categories Back-end Controller | ||
*/ | ||
class Categories extends Controller | ||
{ | ||
public $implement = [ | ||
'Backend.Behaviors.FormController', | ||
'Backend.Behaviors.ListController' | ||
]; | ||
|
||
public $formConfig = 'config_form.yaml'; | ||
public $listConfig = 'config_list.yaml'; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
BackendMenu::setContext('DShoreman.Shop', 'shop', 'categories'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php namespace DShoreman\Shop\Controllers; | ||
|
||
use BackendMenu; | ||
use Backend\Classes\Controller; | ||
|
||
/** | ||
* Products Back-end Controller | ||
*/ | ||
class Products extends Controller | ||
{ | ||
public $implement = [ | ||
'Backend.Behaviors.FormController', | ||
'Backend.Behaviors.ListController' | ||
]; | ||
|
||
public $formConfig = 'config_form.yaml'; | ||
public $listConfig = 'config_list.yaml'; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
BackendMenu::setContext('DShoreman.Shop', 'shop', 'products'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div data-control="toolbar"> | ||
<a href="<?= Backend::url('dshoreman/shop/categories/create') ?>" class="btn btn-primary oc-icon-plus">New Category</a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# =================================== | ||
# Form Behavior Config | ||
# =================================== | ||
|
||
# Record name | ||
name: Category | ||
|
||
# Model Form Field configuration | ||
form: $/dshoreman/shop/models/category/fields.yaml | ||
|
||
# Model Class name | ||
modelClass: DShoreman\Shop\Models\Category | ||
|
||
# Default redirect location | ||
defaultRedirect: dshoreman/shop/categories | ||
|
||
# Create page | ||
create: | ||
title: Create Category | ||
redirect: dshoreman/shop/categories/update/:id | ||
redirectClose: dshoreman/shop/categories | ||
|
||
# Update page | ||
update: | ||
title: Edit Category | ||
redirect: dshoreman/shop/categories | ||
redirectClose: dshoreman/shop/categories | ||
|
||
# Preview page | ||
preview: | ||
title: Preview Category |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# =================================== | ||
# List Behavior Config | ||
# =================================== | ||
|
||
# Model List Column configuration | ||
list: $/dshoreman/shop/models/category/columns.yaml | ||
|
||
# Model Class name | ||
modelClass: DShoreman\Shop\Models\Category | ||
|
||
# List Title | ||
title: Manage Categories | ||
|
||
# Link URL for each record | ||
recordUrl: dshoreman/shop/categories/update/:id | ||
|
||
# Message to display if the list is empty | ||
noRecordsMessage: backend::lang.list.no_records | ||
|
||
# Records to display per page | ||
recordsPerPage: 25 | ||
|
||
# Displays the list column set up button | ||
showSetup: true | ||
|
||
# Displays the sorting link on each column | ||
showSorting: true | ||
|
||
# Default sorting column | ||
defaultSort: | ||
column: sort_order | ||
direction: asc | ||
|
||
# Display checkboxes next to each record | ||
showCheckboxes: true | ||
|
||
# Toolbar widget configuration | ||
toolbar: | ||
# Partial for toolbar buttons | ||
buttons: list_toolbar | ||
|
||
# Search widget configuration | ||
search: | ||
prompt: backend::lang.list.search_prompt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php Block::put('breadcrumb') ?> | ||
<ul> | ||
<li><a href="<?= Backend::url('dshoreman/shop/categories') ?>">Categories</a></li> | ||
<li><?= e($this->pageTitle) ?></li> | ||
</ul> | ||
<?php Block::endPut() ?> | ||
|
||
<?php if (!$this->fatalError): ?> | ||
|
||
<?= Form::open(['class'=>'layout-item stretch layout-column']) ?> | ||
|
||
<?= $this->formRender() ?> | ||
|
||
<div class="form-buttons layout-item fix"> | ||
<div class="loading-indicator-container"> | ||
<button | ||
type="submit" | ||
data-request="onSave" | ||
data-hotkey="ctrl+s, cmd+s" | ||
data-load-indicator="Creating Category..." | ||
class="btn btn-primary"> | ||
Create | ||
</button> | ||
<button | ||
type="button" | ||
data-request="onSave" | ||
data-request-data="close:1" | ||
data-hotkey="ctrl+enter, cmd+enter" | ||
data-load-indicator="Creating Category..." | ||
class="btn btn-default"> | ||
Create and Close | ||
</button> | ||
<span class="btn-text"> | ||
or <a href="<?= Backend::url('dshoreman/shop/categories') ?>">Cancel</a> | ||
</span> | ||
</div> | ||
</div> | ||
|
||
<?= Form::close() ?> | ||
|
||
<?php else: ?> | ||
|
||
<p class="flash-message static error"><?= e($this->fatalError) ?></p> | ||
<p><a href="<?= Backend::url('dshoreman/shop/categories') ?>" class="btn btn-default">Return to categories list</a></p> | ||
|
||
<?php endif ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
<?= $this->listRender() ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php Block::put('breadcrumb') ?> | ||
<ul> | ||
<li><a href="<?= Backend::url('dshoreman/shop/categories') ?>">Categories</a></li> | ||
<li><?= e($this->pageTitle) ?></li> | ||
</ul> | ||
<?php Block::endPut() ?> | ||
|
||
<?php if (!$this->fatalError): ?> | ||
|
||
<div class="layout-item stretch layout-column form-preview"> | ||
<?= $this->formRenderPreview() ?> | ||
</div> | ||
|
||
<?php else: ?> | ||
|
||
<p class="flash-message static error"><?= e($this->fatalError) ?></p> | ||
<p><a href="<?= Backend::url('dshoreman/shop/categories') ?>" class="btn btn-default">Return to categories list</a></p> | ||
|
||
<?php endif ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php Block::put('breadcrumb') ?> | ||
<ul> | ||
<li><a href="<?= Backend::url('dshoreman/shop/categories') ?>">Categories</a></li> | ||
<li><?= e($this->pageTitle) ?></li> | ||
</ul> | ||
<?php Block::endPut() ?> | ||
|
||
<?php if (!$this->fatalError): ?> | ||
|
||
<?= Form::open(['class'=>'layout-item stretch layout-column']) ?> | ||
|
||
<?= $this->formRender() ?> | ||
|
||
<div class="form-buttons layout-item fix"> | ||
<div class="loading-indicator-container"> | ||
<button | ||
type="submit" | ||
data-request="onSave" | ||
data-request-data="redirect:0" | ||
data-hotkey="ctrl+s, cmd+s" | ||
data-load-indicator="Saving Category..." | ||
class="btn btn-primary"> | ||
<u>S</u>ave | ||
</button> | ||
<button | ||
type="button" | ||
data-request="onSave" | ||
data-request-data="close:1" | ||
data-hotkey="ctrl+enter, cmd+enter" | ||
data-load-indicator="Saving Category..." | ||
class="btn btn-default"> | ||
Save and Close | ||
</button> | ||
<button | ||
type="button" | ||
class="oc-icon-trash-o btn-icon danger pull-right" | ||
data-request="onDelete" | ||
data-load-indicator="Deleting Category..." | ||
data-request-confirm="Do you really want to delete this category?"> | ||
</button> | ||
<span class="btn-text"> | ||
or <a href="<?= Backend::url('dshoreman/shop/categories') ?>">Cancel</a> | ||
</span> | ||
</div> | ||
</div> | ||
|
||
<?= Form::close() ?> | ||
|
||
<?php else: ?> | ||
|
||
<p class="flash-message static error"><?= e($this->fatalError) ?></p> | ||
<p><a href="<?= Backend::url('dshoreman/shop/categories') ?>" class="btn btn-default">Return to categories list</a></p> | ||
|
||
<?php endif ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div data-control="toolbar"> | ||
<a href="<?= Backend::url('dshoreman/shop/products/create') ?>" class="btn btn-primary oc-icon-plus">New Product</a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# =================================== | ||
# Form Behavior Config | ||
# =================================== | ||
|
||
# Record name | ||
name: Product | ||
|
||
# Model Form Field configuration | ||
form: $/dshoreman/shop/models/product/fields.yaml | ||
|
||
# Model Class name | ||
modelClass: DShoreman\Shop\Models\Product | ||
|
||
# Default redirect location | ||
defaultRedirect: dshoreman/shop/products | ||
|
||
# Create page | ||
create: | ||
title: Create Product | ||
redirect: dshoreman/shop/products/update/:id | ||
redirectClose: dshoreman/shop/products | ||
|
||
# Update page | ||
update: | ||
title: Edit Product | ||
redirect: dshoreman/shop/products | ||
redirectClose: dshoreman/shop/products | ||
|
||
# Preview page | ||
preview: | ||
title: Preview Product |
Oops, something went wrong.