Skip to content

Commit d69e316

Browse files
author
Igor Chepurnoy
committed
add x-editable as bower dependency to the composer.json, change bootstrap asset bundle
1 parent ea8ad8f commit d69e316

14 files changed

+90
-7485
lines changed

Editable.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function init()
5656
if ($this->url === null) {
5757
throw new InvalidConfigException("You must setup the 'Url' property.");
5858
}
59+
5960
if (!isset($this->options['id'])) {
6061
$this->options['id'] = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->getId();
6162
}
@@ -111,6 +112,7 @@ protected function registerClientScript()
111112

112113
/**
113114
* Return plugin options in json format
115+
*
114116
* @return string
115117
*/
116118
public function getPluginOptions()
@@ -130,6 +132,7 @@ public function getPluginOptions()
130132

131133
/**
132134
* Register client events
135+
*
133136
* @param $id
134137
*/
135138
public function registerClientEvents($id)
@@ -144,6 +147,7 @@ public function registerClientEvents($id)
144147

145148
/**
146149
* Return link text
150+
*
147151
* @return mixed|string
148152
*/
149153
protected function getLinkText()
@@ -169,6 +173,7 @@ protected function getLinkText()
169173

170174
/**
171175
* To ensure that `getPrimaryKey()` and `getIsNewRecord()` methods are implemented in model.
176+
*
172177
* @return bool
173178
*/
174179
protected function hasActiveRecord()

EditableAction.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,23 @@ class EditableAction extends Action
1717
* @var string the class name to handle
1818
*/
1919
public $modelClass;
20+
2021
/**
2122
* @var string the scenario to be used (optional)
2223
*/
2324
public $scenario;
25+
2426
/**
2527
* @var \Closure a function to be called previous saving model. The anonymous function is preferable to have the
2628
* model passed by reference. This is useful when we need to set model with extra data previous update.
2729
*/
2830
public $preProcess;
31+
2932
/**
3033
* @var bool whether to create a model if a primary key parameter was not found.
3134
*/
3235
public $forceCreate = true;
36+
3337
/**
3438
* @var string default pk column name
3539
*/
@@ -48,6 +52,7 @@ public function init()
4852

4953
/**
5054
* Runs the action
55+
*
5156
* @return bool
5257
* @throws BadRequestHttpException
5358
*/
@@ -62,12 +67,15 @@ public function run()
6267
$attribute = array_pop($attributeParts);
6368
}
6469
$value = Yii::$app->request->post('value');
70+
6571
if ($attribute === null) {
6672
throw new BadRequestHttpException("Attribute cannot be empty.");
6773
}
74+
6875
if ($value === null) {
6976
throw new BadRequestHttpException("Value cannot be empty.");
7077
}
78+
7179
/** @var \Yii\db\ActiveRecord $model */
7280
$model = $class::findOne(is_array($pk) ? $pk : [$this->pkColumn => $pk]);
7381
if (!$model) {
@@ -77,13 +85,16 @@ public function run()
7785
throw new BadRequestHttpException('Entity not found by primary key ' . $pk);
7886
}
7987
}
88+
8089
// do we have a preProcess function
8190
if ($this->preProcess && is_callable($this->preProcess, true)) {
8291
call_user_func($this->preProcess, $model);
8392
}
93+
8494
if ($this->scenario !== null) {
8595
$model->setScenario($this->scenario);
8696
}
97+
8798
$model->$attribute = $value;
8899

89100
if ($model->validate([$attribute])) {
@@ -93,5 +104,4 @@ public function run()
93104
throw new BadRequestHttpException($model->getFirstError($attribute));
94105
}
95106
}
96-
97-
}
107+
}

EditableColumn.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ class EditableColumn extends DataColumn
2222
* Editable options
2323
*/
2424
public $editableOptions = [];
25+
2526
/**
2627
* @var string suffix substituted to a name class of the tag <a>
2728
*/
2829
public $classSuffix;
30+
2931
/**
3032
* @var string the url to post
3133
*/
3234
public $url;
35+
3336
/**
3437
* @var string the type of editor
3538
*/
@@ -59,6 +62,7 @@ public function init()
5962

6063
/**
6164
* Renders the data cell content.
65+
*
6266
* @param mixed $model the data model
6367
* @param mixed $key the key associated with the data model
6468
* @param integer $index the zero-based index of the data model among the models array returned by [[GridView::dataProvider]].

0 commit comments

Comments
 (0)