Skip to content

Commit

Permalink
prepare new release.
Browse files Browse the repository at this point in the history
change angular gii depend on yii2-angular ext.
  • Loading branch information
mdmunir committed Sep 5, 2015
1 parent 55600b9 commit 82b4711
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
],
"require": {
"yiisoft/yii2": ">=2.0.4",
"yiisoft/yii2": ">=2.0.6",
"yiisoft/yii2-gii": "~2.0"
},
"autoload": {
Expand Down
10 changes: 5 additions & 5 deletions generators/angular/default/views/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

<div class="<?= StringHelper::basename($generator->controllerID) ?>-form">
<form name="Form" >
<div ng-if="errors.status">
<h1>Error {{errors.status}}: {{errors.text}}</h1>
<div ng-if="errorStatus">
<h1>Error {{errorStatus}}: {{errorText}}</h1>
<ul>
<li ng-repeat="(field,msg) in errors.data">{{field}}: {{msg}}</li>
<li ng-repeat="(field,msg) in errors">{{field}}: {{msg}}</li>
</ul>
</div>

Expand All @@ -38,10 +38,10 @@
$attrLabel = $model->getAttributeLabel($attribute);
$attrId = Html::getInputId($model, $attribute);
echo <<<FIELD
<div class="{$containerCls}" ng-class="{error:errors.{$attribute}}">
<div class="{$containerCls}" ng-class="{error:!!errors.{$attribute}}">
<label for="{$attrId}" class="control-label">{$attrLabel}</label>
<input id="{$attrId}" name="{$attribute}" class="form-control" ng-model="model.{$attribute}">
<div class="help-block">{{errors.{$attribute}}}</div>
<div class="help-block" ng-bind"errors.{$attribute}"></div>
</div>
FIELD;
Expand Down
6 changes: 4 additions & 2 deletions generators/angular/default/views/js/create.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
}?>
$location.path('/<?= $prefixRoute; ?>' + id);
},function(r){
$scope.errors = {status: r.status, text: r.statusText, data: {}};
$scope.errors = {};
$scope.errorStatus = r.status;
$scope.errorText = r.statusTest;
if (r.status == 422) {
angular.forEach(r.data,function(err) {
$scope.errors.data[err.field] = err.message;
$scope.errors[err.field] = err.message;
});
}
});
Expand Down
12 changes: 6 additions & 6 deletions generators/angular/default/views/js/form.js.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
$scope.errors = {data:{}};
$scope.errors = {};

jQuery('form').on('keypress change',':input[ng-model]',function(){
var field = $(this).attr('name');
if($scope.errors.status){
delete $scope.errors.status;
delete $scope.errors.text;
if($scope.errorStatus){
delete $scope.errorStatus;
delete $scope.errorText;
}
if($scope.errors.data[field]){
delete $scope.errors.data[field];
if($scope.errors[field]){
delete $scope.errors[field];
}
});
3 changes: 2 additions & 1 deletion generators/angular/default/views/js/index.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
?>
var $location = $injector.get('$location');
var search = $location.search();
var $pageInfo = $injector.get('$pageInfo');

// data provider
$scope.provider = {
Expand All @@ -35,7 +36,7 @@
page: search.page,
sort: search.sort,
}, function (rows, headerCallback) {
yii.angular.getPageInfo($scope.provider, headerCallback);
$pageInfo(headerCallback, $scope.provider);
$scope.rows = rows;
});
}
Expand Down
6 changes: 4 additions & 2 deletions generators/angular/default/views/js/update.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
}?>
$location.path('/<?= $prefixRoute; ?>' + id);
},function(r){
$scope.errors = {status: r.status, text: r.statusText, data: {}};
$scope.errors = {};
$scope.errorStatus = r.status;
$scope.errorText = r.statusTest;
if (r.status == 422) {
angular.forEach(r.data,function(err) {
$scope.errors.data[err.field] = err.message;
$scope.errors[err.field] = err.message;
});
}
});
Expand Down
7 changes: 3 additions & 4 deletions generators/angular/default/views/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

use yii\helpers\StringHelper;
use yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $generator dee\gii\generators\angular\Generator */
Expand All @@ -22,7 +21,7 @@
?>
<?php echo "<?=\n" ?>
NgView::widget([
'requires' => ['ngResource','ui.bootstrap','dee.angular'],
'requires' => ['ngResource','ui.bootstrap','dee.ui'],
'routes' => [
'/<?= $prefixRoute; ?>' => [
'view' => 'index',
Expand All @@ -47,12 +46,12 @@
],
'resources' => [
'<?= $restName;?>' => [
'url' => '<?=Url::to([$resourceUrl])?>',
'url' => '<?= rtrim(Yii::$app->homeUrl,'/')."{$resourceUrl}/:id"?>',
'actions' =>[
'update' => [
'method' => 'PUT',
],
]
]
]
],
]);?>

0 comments on commit 82b4711

Please sign in to comment.