Commit b3b8e2bc authored by Evren Kutar's avatar Evren Kutar

msgbox directive

parent 0e38699b
......@@ -13,15 +13,15 @@
<table class="table table-bordered" style="background-color:#fff;">
<thead>
<tr>
<th colspan="2">
<td colspan="2">
<label>
<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">
Hepsini Seç
</label>
</th>
<th ng-repeat="value in nobjects[0]" ng-if="nobjects[0]!='-1'">{{ value }}</th>
<th ng-if="nobjects[0]=='-1'">{{ model }}</th>
<th>action</th>
</td>
<td ng-repeat="value in nobjects[0]" ng-if="nobjects[0]!='-1' && !$last">{{ value }}</td>
<td ng-if="nobjects[0]=='-1'">{{ model }}</td>
<td>action</td>
</tr>
</thead>
<tbody>
......@@ -31,18 +31,18 @@
<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">
</label>
</td>
<th scope="row" style="text-align:center">{{$index}}</th>
<td scope="row" style="text-align:center">{{$index}}</td>
<!-- below 2 of object will not be listed there for ng repeat loops 2 less -->
<td ng-repeat="k in object track by $index" ng-if="nobjects[0]=='-1' && $index>1">
<a ng-href="{{object[2].detailLink}}">{{object[1]}}</a>
<td ng-repeat="k in object track by $index" ng-if="nobjects[0]=='-1' && $index>0 && !$last">
<a ng-href="{{object[object.length-1].detailLink}}">{{object[1]}}</a>
</td>
<td ng-repeat="(key,value) in object track by $index" ng-if="nobjects[0]!='-1' && $index>1">
<a ng-href="{{object[2].detailLink}}" ng-if="$index==1">{{object[key]}}</a>
<td ng-repeat="(key,value) in object track by $index" ng-if="nobjects[0]!='-1' && $index>0 && !$last">
<a ng-href="{{object[object.length-1].detailLink}}" ng-if="$index==1">{{object[key]}}</a>
<span ng-if="$index!=1">{{object[key]}}</span>
</td>
<td>
<a ng-href="{{object[2].editLink}}">Edit</a>
<a ng-href="{{object[object.length-1].editLink}}">Edit</a>
<br>
</td>
</tr>
......
......@@ -324,6 +324,18 @@ app.directive('notifications', function () {
};
});
/**
* msgbox directive
*/
app.directive('msgbox', function () {
return {
templateUrl: 'shared/templates/directives/msgbox.html',
restrict: 'E',
replace: true
};
});
/**
* search directive in sidebar
*/
......
<div class="">
<div class="panel panel-info">
<div class="panel-heading">
{{msgbox.title}}
</div>
<div class="panel-body">
<p>{{msgbox.msg}}</p>
</div>
<!--<div class="panel-footer">-->
<!--</div>-->
</div>
</div>
\ No newline at end of file
<div class="navbar-default sidebar" role="navigation" ng-mouseenter="openSidebar()" ng-mouseleave="closeSidebar()">
<div class="brand">
<a href="" class="logo"><img src="/img/brand-logo.png" /></a>
<a href="#/dashboard" class="logo"><img src="/img/brand-logo.png" /></a>
</div>
<div class="sidebar-nav navbar-collapse">
......
......@@ -7,7 +7,7 @@
var form_generator = angular.module('formService', ['general']);
form_generator.factory('Generator', function ($http, $q, $timeout, $location, RESTURL, FormDiff, $rootScope) {
form_generator.factory('Generator', function ($http, $q, $timeout, $location, $compile, RESTURL, FormDiff, $rootScope) {
var generator = {};
generator.makeUrl = function (scope) {
var getparams = scope.form_params.param ? "?" + scope.form_params.param + "=" + scope.form_params.id : "";
......@@ -61,15 +61,18 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, RE
}
});
debugger;
angular.forEach(scope.schema.properties, function (v, k) {
// generically change _id fields model value
if (k == scope.form_params.param) {
scope.model[k] = scope.form_params.id;
scope.form.splice(scope.form.indexOf(k), 1);
return;
if ('form_params' in scope) {
if (k == scope.form_params.param) {
scope.model[k] = scope.form_params.id;
scope.form.splice(scope.form.indexOf(k), 1);
return;
}
}
if (v.type === 'select') {
......@@ -261,8 +264,9 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, RE
}
if (value !== '-1') {
value[2] = {detailLink: makelink("detail/"), editLink: makelink("edit/")};
value.push({detailLink: makelink("detail/"), editLink: makelink("edit/")});
}
console.log(value);
});
};
generator.get_form = function (scope) {
......@@ -346,22 +350,33 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, RE
//data.form = get_diff;
}
//debugger;
return $http.post(generator.makeUrl($scope), data)
.success(function (data) {
// if return data consists forms key then trogger redraw the form with updated data
// if return data consists forms key then trigger redraw the form with updated data
if (data.forms) {
delete $scope.form, $scope.model, $scope.schema, $scope.form_params.cmd;
generator.generate($scope, data);
$scope.$broadcast('schemaFormRedraw')
}
// if submit returns nobjects after save
if (data.nobjects) {
generator.itemLinksGenerator($scope, data);
data[$scope.form_params.param] = $scope.form_params.id;
$location.path('/crud/' + $scope.form_params.model + '/list').search(angular.fromJson(data));
}
// if submit returns msgbox after save
if (data.msgbox) {
$scope.msgbox = data.msgbox;
var newElement = $compile( "<msgbox ></msgbox>" )( $scope );
//debugger;
angular.element(document.querySelector('.main.ng-scope')).children().remove();
angular.element(document.querySelector('.main.ng-scope')).append( newElement );
}
});
};
return generator;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment