-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d426258
commit 33d2b7c
Showing
11 changed files
with
234 additions
and
5,012 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
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 |
---|---|---|
|
@@ -5,13 +5,18 @@ | |
* @copyright 2010 SkeekS (СкикС) | ||
* @date 10.09.2015 | ||
*/ | ||
|
||
namespace skeeks\cms\measure\components; | ||
|
||
use skeeks\cms\base\Component; | ||
use skeeks\yii2\form\fields\SelectField; | ||
use skeeks\yii2\measureClassifier\Measure; | ||
use yii\helpers\ArrayHelper; | ||
|
||
/** | ||
* Class MeasureComponent | ||
* @package skeeks\cms\measure\components | ||
* @property Measure[] $measures; | ||
* | ||
* @author Semenov Alexander <[email protected]> | ||
*/ | ||
class MeasureComponent extends Component | ||
{ | ||
|
@@ -22,7 +27,92 @@ class MeasureComponent extends Component | |
static public function descriptorConfig() | ||
{ | ||
return array_merge(parent::descriptorConfig(), [ | ||
'name' => \Yii::t('skeeks/measure', 'Units of measurement'), | ||
'name' => \Yii::t('skeeks/measure', 'Units of measurement'), | ||
]); | ||
} | ||
|
||
public $default_measure_code = "796"; //шт. | ||
|
||
|
||
public $active_measure_codes = [ | ||
"796", | ||
|
||
"112", | ||
"163", | ||
"166", | ||
|
||
"003", | ||
"006", | ||
]; | ||
|
||
/*public function behaviors() | ||
{ | ||
return ArrayHelper::merge(parent::behaviors(), [ | ||
]); | ||
}*/ | ||
|
||
|
||
|
||
public function getConfigFormFields() | ||
{ | ||
return [ | ||
'default_measure_code' => [ | ||
'class' => SelectField::class, | ||
'multiple' => false, | ||
'items' => function() { | ||
return \Yii::$app->measureClassifier->getDataForSelect(); | ||
} | ||
], | ||
'active_measure_codes' => [ | ||
'class' => SelectField::class, | ||
'multiple' => true, | ||
'items' => function() { | ||
return \Yii::$app->measureClassifier->getDataForSelect(); | ||
} | ||
], | ||
]; | ||
} | ||
|
||
|
||
public function rules() | ||
{ | ||
return ArrayHelper::merge(parent::rules(), [ | ||
[['default_measure_code'], 'string'], | ||
[['active_measure_codes'], 'safe'], | ||
]); | ||
} | ||
|
||
public function attributeLabels() | ||
{ | ||
return ArrayHelper::merge(parent::attributeLabels(), [ | ||
'default_measure_code' => 'Валюта по умолчанию', | ||
'active_measure_codes' => 'Включенные для выбора валюты', | ||
]); | ||
} | ||
|
||
public function attributeHints() | ||
{ | ||
return ArrayHelper::merge(parent::attributeHints(), [ | ||
]); | ||
} | ||
|
||
|
||
/** | ||
* @return Measure[] | ||
*/ | ||
public function getActiveMeasures() | ||
{ | ||
$result = []; | ||
|
||
foreach ((array) $this->active_measure_codes as $key => $code) | ||
{ | ||
if ($model = \Yii::$app->measureClassifier->getMeasureByCode($code)) { | ||
$result[$code] = $model; | ||
} | ||
} | ||
|
||
|
||
return $result; | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.