Allow to use the script component with modules' custom scripts.
This commit is contained in:
parent
ff945c6e34
commit
f3913aef24
@ -15,6 +15,9 @@ class Script extends Component
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
public $scriptFile;
|
public $scriptFile;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
public $version;
|
||||||
|
|
||||||
public $items;
|
public $items;
|
||||||
|
|
||||||
public $currencies;
|
public $currencies;
|
||||||
@ -26,10 +29,11 @@ class Script extends Component
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(string $type = '', string $scriptFile = '', $items = [], $currencies = [], $taxes = [])
|
public function __construct(string $type = '', string $scriptFile = '', string $version = '', $items = [], $currencies = [], $taxes = [])
|
||||||
{
|
{
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
$this->scriptFile = ($scriptFile) ? $scriptFile : 'public/js/common/documents.js';
|
$this->scriptFile = ($scriptFile) ? $scriptFile : 'public/js/common/documents.js';
|
||||||
|
$this->version = $this->getVersion($version);
|
||||||
$this->items = $items;
|
$this->items = $items;
|
||||||
$this->currencies = $this->getCurrencies($currencies);
|
$this->currencies = $this->getCurrencies($currencies);
|
||||||
$this->taxes = $this->getTaxes($taxes);
|
$this->taxes = $this->getTaxes($taxes);
|
||||||
@ -45,6 +49,19 @@ class Script extends Component
|
|||||||
return view('components.documents.script');
|
return view('components.documents.script');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getVersion($version)
|
||||||
|
{
|
||||||
|
if (!empty($version)) {
|
||||||
|
return $version;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($alias = config('type.' . $this->type . '.alias')) {
|
||||||
|
return module_version($alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
return version('short');
|
||||||
|
}
|
||||||
|
|
||||||
protected function getCurrencies($currencies)
|
protected function getCurrencies($currencies)
|
||||||
{
|
{
|
||||||
if (!empty($currencies)) {
|
if (!empty($currencies)) {
|
||||||
|
@ -15,4 +15,4 @@
|
|||||||
var document_taxes = {!! $taxes !!};
|
var document_taxes = {!! $taxes !!};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="{{ asset( $scriptFile . '?v=' . version('short')) }}"></script>
|
<script src="{{ asset( $scriptFile . '?v=' . $version) }}"></script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user