Commit d1c4af40 authored by Evren Kutar's avatar Evren Kutar

Merge branch 'Feature/issue44'

parents 06f9ed64 f48e927d
......@@ -330,7 +330,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-preprocess');
grunt.loadNpmTasks('grunt-env');
grunt.registerTask('dev', ['env:dev', 'preprocess:dev', 'html2js:dev', 'watch:dev']);
grunt.registerTask('dev', ['env:dev', 'preprocess:dev', 'html2js:dev', 'default', 'watch:dev']);
grunt.registerTask('test', ['bower', 'karma:continuous']);
grunt.registerTask('i18n', ['nggettext_extract', 'nggettext_compile']);
grunt.registerTask('local_prod', ['bower', 'env:prod', 'preprocess:prod', 'nggettext_compile', 'concat:js', 'concat:css', 'concat:components', 'copy:local_prod', 'html2js:prod', 'uglify:dist', 'connect:prod_server', 'watch:local_prod']);
......
......@@ -22,7 +22,6 @@ var app = angular.module(
'ulakbus.crud',
'ulakbus.debug',
'ulakbus.devSettings',
'ulakbus.wf',
'ulakbus.version',
//'schemaForm',
'gettext',
......
......@@ -22,45 +22,30 @@ app.config(['$routeProvider', function ($routeProvider, $route) {
// use crud without selected user
// important: regex urls must be defined later than static ones
.when('/:wf/', {
templateUrl: 'components/wf/templates/add.html',
templateUrl: 'components/crud/templates/crud.html',
controller: 'CRUDCtrl'
})
.when('/:wf/list', {
templateUrl: 'components/crud/templates/list.html',
controller: 'CRUDListCtrl'
.when('/:wf/do/:cmd', {
templateUrl: 'components/crud/templates/crud.html',
controller: 'CRUDListFormCtrl'
})
.when('/:wf/add', {
templateUrl: 'components/crud/templates/add.html',
controller: 'CRUDAddEditCtrl'
})
.when('/:wf/edit/:key', {
templateUrl: 'components/crud/templates/add.html',
controller: 'CRUDAddEditCtrl'
})
.when('/:wf/detail/:key', {
templateUrl: 'components/crud/templates/show.html',
controller: 'CRUDShowCtrl'
.when('/:wf/do/:cmd/:key', {
templateUrl: 'components/crud/templates/crud.html',
controller: 'CRUDListFormCtrl'
})
.when('/:wf/:model', {
templateUrl: 'components/wf/templates/add.html',
templateUrl: 'components/crud/templates/crud.html',
controller: 'CRUDCtrl'
})
.when('/:wf/:model/list', {
templateUrl: 'components/crud/templates/list.html',
controller: 'CRUDListCtrl'
})
.when('/:wf/:model/add', {
templateUrl: 'components/crud/templates/add.html',
controller: 'CRUDAddEditCtrl'
.when('/:wf/:model/do/:cmd', {
templateUrl: 'components/crud/templates/crud.html',
controller: 'CRUDListFormCtrl'
})
.when('/:wf/:model/edit/:key', {
templateUrl: 'components/crud/templates/add.html',
controller: 'CRUDAddEditCtrl'
})
.when('/:wf/:model/detail/:key', {
templateUrl: 'components/crud/templates/show.html',
controller: 'CRUDShowCtrl'
.when('/:wf/:model/do/:cmd/:key', {
templateUrl: 'components/crud/templates/crud.html',
controller: 'CRUDListFormCtrl'
})
.otherwise({redirectTo: '/dashboard'});
}])
.run(function ($rootScope) {
......
......@@ -17,6 +17,7 @@ crud.service('CrudUtility', function () {
generateParam: function (scope, routeParams, cmd) {
// define api request url path
scope.url = routeParams.wf;
// why do this??
angular.forEach(routeParams, function (value, key) {
if (key.indexOf('_id') > -1 && key !== 'param_id') {
scope.param = key;
......@@ -31,6 +32,10 @@ crud.service('CrudUtility', function () {
wf: routeParams.wf,
object_id: routeParams.key
};
scope.model = scope.form_params.model;
scope.wf = scope.form_params.wf;
scope.param = scope.form_params.param;
scope.param_id = scope.form_params.id;
return scope;
},
listPageItems: function (scope, pageData) {
......@@ -51,80 +56,110 @@ crud.controller('CRUDCtrl', function ($scope, $routeParams, Generator, CrudUtili
});
/**
* CRUDAddEditCtrl is a controller
* which provide a form with form generator.
*
*/
crud.controller('CRUDListFormCtrl', function ($scope, $rootScope, $location, $http, $log, $modal, $timeout, Generator, $routeParams, CrudUtility) {
if ($routeParams.cmd==='show') {
CrudUtility.generateParam($scope, $routeParams, $routeParams.cmd);
// todo: refactor createListObjects func
var createListObjects = function () {
angular.forEach($scope.object, function (value, key) {
if (typeof value == 'object') {
$scope.listobjects[key] = value;
delete $scope.object[key];
}
});
};
crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $http, $log, $modal, $timeout, Generator, $routeParams, CrudUtility) {
// get form with generator
if ($routeParams.pageData) {
CrudUtility.generateParam($scope, Generator.getPageData(), 'form');
Generator.generate($scope, Generator.getPageData());
} else {
CrudUtility.generateParam($scope, $routeParams, 'form');
Generator.get_form($scope);
}
$scope.listobjects = {};
$scope.onSubmit = function (form) {
$scope.$broadcast('schemaFormValidate');
if (form.$valid) {
Generator.submit($scope);
var pageData = Generator.getPageData();
if (pageData.pageData === true) {
$scope.object = pageData.object;
Generator.setPageData({pageData: false});
}
};
else {
// call generator's get_single_item func
Generator.get_single_item($scope).then(function (res) {
$scope.object = res.data.object;
$scope.model = $routeParams.model;
});
}
createListObjects();
}
});
if ($routeParams.cmd==='form' || $routeParams.cmd==='list') {
// function to set scope objects
var setpageobjects = function (data) {
CrudUtility.listPageItems($scope, data);
Generator.generate($scope, data);
Generator.setPageData({pageData: false});
};
/**
* CRUD List Controller
*/
// get pageData from service
var pageData = Generator.getPageData();
crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeParams, CrudUtility) {
CrudUtility.generateParam($scope, $routeParams, 'list');
// if pageData exists do not call get_wf function and manipulate page with pageData
if (pageData.pageData === true) {
$log.debug('pagedata', pageData.pageData);
CrudUtility.generateParam($scope, pageData, $routeParams.cmd);
setpageobjects(pageData, pageData);
}
// if pageData didn't defined or is {pageData: false} go get data from api with get_wf function
if (pageData.pageData === undefined || pageData.pageData === false) {
CrudUtility.generateParam($scope, $routeParams, $routeParams.cmd);
Generator.get_wf($scope);
}
if ($routeParams.pageData) {
var pageData = Generator.getPageData();
CrudUtility.listPageItems($scope, pageData);
}
else {
// call generator's get_list func
Generator.get_list($scope)
.then(function (res) {
CrudUtility.listPageItems($scope, res.Data);
});
}
// we use form generator for generic forms. this makes form's scope to confuse on the path to generate form
// object by its name. to manage to locate the form to controllers scope we use a directive called form locator
// a bit dirty way to find form working on but solves our problem
$scope.$on('formLocator', function(event) {
$scope.formgenerated = event.targetScope.formgenerated;
});
$scope.do_action = function (key, action) {
Generator.doItemAction($scope, key, action);
$scope.onSubmit = function (form) {
$scope.$broadcast('schemaFormValidate');
if (form.$valid) {
Generator.submit($scope);
}
};
$scope.do_action = function (key, action) {
Generator.doItemAction($scope, key, action);
};
}
});
/**
* CRUD Show Controller
*/
crud.controller('CRUDShowCtrl', function ($scope, $rootScope, $location, Generator, $routeParams, CrudUtility) {
CrudUtility.generateParam($scope, $routeParams, 'show');
// todo: refactor createListObjects func
var createListObjects = function () {
angular.forEach($scope.object, function (value, key) {
if (typeof value == 'object') {
$scope.listobjects[key] = value;
delete $scope.object[key];
}
});
crud.directive('crudListDirective', function () {
return {
templateUrl: 'components/crud/templates/list.html',
restrict: 'E',
replace: true
};
});
crud.directive('crudFormDirective', function () {
return {
templateUrl: 'components/crud/templates/form.html',
restrict: 'E',
replace: true
};
});
$scope.listobjects = {};
crud.directive('crudShowDirective', function () {
return {
templateUrl: 'components/crud/templates/show.html',
restrict: 'E',
replace: true
};
});
if ($routeParams.pageData) {
var pageData = Generator.getPageData();
$scope.object = pageData.object;
}
else {
// call generator's get_single_item func
Generator.get_single_item($scope).then(function (res) {
$scope.object = res.data.object;
$scope.model = $routeParams.model;
});
crud.directive('formLocator', function() {
return {
link: function(scope) {
scope.$emit('formLocator');
}
}
createListObjects();
});
\ No newline at end of file
......@@ -18,43 +18,10 @@ describe('crud controller module', function () {
$controller = _$controller_;
}));
describe('crud add controller', function() {
it('should get form', function() {
var $scope = {};
var controller = $controller('CRUDAddEditCtrl', { $scope: $scope });
expect($scope).not.toEqual(null);
});
});
// todo: chack if needed for these tests
// describe('crud list controller', function() {
// it('should get list', function() {
// var $scope = {};
// var controller = $controller('CRUDListCtrl', { $scope: $scope });
// expect($scope).not.toEqual(null);
// });
// });
// describe('crud show controller', function() {
// it('should get single item', function() {
// var $scope = {};
// var controller = $controller('CRUDShowCtrl', { $scope: $scope });
// expect($scope).not.toEqual(null);
// });
// });
describe('crud controller', function () {
it('should have CRUDAddEditCtrl', inject(function ($controller) {
expect($controller).toBeDefined();
}));
it('should have CRUDListCtrl', inject(function ($controller) {
expect($controller).toBeDefined();
}));
it('should have CRUDShowCtrl', inject(function ($controller) {
it('should have CRUDListFormCtrl', inject(function ($controller) {
expect($controller).toBeDefined();
}));
});
......
<crud-show-directive ng-if="object"></crud-show-directive>
<crud-form-directive ng-if="forms"></crud-form-directive>
<hr>
<crud-list-directive ng-if="objects"></crud-list-directive>
\ No newline at end of file
<div class="container" ng-app="ulakbus.crud">
<div class="col-md-6">
<h1>{{ schema.title }}</h1>
<form name="formgenerated" sf-schema="schema" sf-form="form" sf-model="model" ng-submit="onSubmit(formgenerated)"></form>
</div>
</div>
\ No newline at end of file
......@@ -2,7 +2,7 @@
<h1>{{ schema.title }}</h1>
<form id="formgenerated" name="formgenerated" sf-schema="schema" sf-form="form" sf-model="model"
ng-submit="onSubmit(formgenerated)"></form>
ng-submit="onSubmit(formgenerated)" form-locator></form>
<div ng-repeat="node in Node">
<h3>{{ node.title }}
......
<div class="starter-template container">
<h1>{{model}}
<a href="{{addLink}}">
<button type="button" class="btn btn-primary">Ekle</button>
</a>
</h1>
<!--<h1>{{model}}-->
<!--<a href="{{addLink}}">-->
<!--<button type="button" class="btn btn-primary">Ekle</button>-->
<!--</a>-->
<!--</h1>-->
<div class="row" ng-if="!objects[1]">
<div class="col-md-12">
<p class="no-content">Listelenecek içerik yok.</p>
......@@ -19,8 +19,8 @@
Hepsini Seç
</label>
</td>
<td ng-repeat="value in objects[0]" ng-if="objects[0]!='-1'">{{ value }}</td>
<td ng-if="objects[0]=='-1'">{{ model || wf }}</td>
<td ng-repeat="value in objects[0]" ng-if="objects[0]!='-1'">{{ objects }}</td>
<td ng-if="objects[0]=='-1'">{{ schema.title||model}}</td>
<td>action</td>
</tr>
</thead>
......@@ -34,11 +34,14 @@
<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="field in object.fields track by $index" ng-if="objects[0]=='-1'">
<a ng-href="{{object.detailLink}}">{{field}}</a>
<a ng-repeat="action in object.actions" ng-href="javascript:void(0)"
ng-if="action.show_as==='link'&&action.fields.indexOf($parent.$index)>-1" ng-click="do_action(object.key, action)">{{field}}</a>
</td>
<td ng-repeat="field in object.fields track by $index" ng-if="objects[0]!='-1'">
<a ng-href="{{object.detailLink}}" ng-if="$index==1">{{field}}</a>
<a ng-repeat="action in object.actions" ng-href="javascript:void(0)"
ng-if="action.show_as==='link'&&action.fields.indexOf($index)>-1"
ng-click="do_action(object.key, action)">{{field}}</a>
<span ng-if="$index!=1">{{field}}</span>
</td>
<td>
......@@ -46,8 +49,8 @@
ng-if="action.show_as==='button'" ng-click="do_action(object.key, action)">{{action
.name}}
</button>
<a ng-href="javascript:void(0)" ng-repeat="action in object.actions"
ng-if="action.show_as==='link'" ng-click="do_action(object.key, action)">{{action.name}}</a>
<!--<a ng-href="javascript:void(0)" ng-repeat="action in object.actions"-->
<!--ng-if="action.show_as==='link'" ng-click="do_action(object.key, action)">{{action.name}}</a>-->
<br>
</td>
</tr>
......
<div class="container">
<h1>{{ schema.title }}</h1>
<form id="formgenerated" name="formgenerated" sf-schema="schema" sf-form="form" sf-model="model"
ng-submit="onSubmit(formgenerated)"></form>
<div ng-repeat="node in Node">
<h3>{{ node.title }}
<span ng-if="node.lengthModels < 1">
<a href="javascript:void(0);" modal-for-nodes="{{node.schema.model_name}},Node">
<i class="fa fa-plus-circle fa-fw"></i>
</a>
</span>
</h3>
<div class="node-table">
<ng-include src="'shared/templates/nodeTable.html'"></ng-include>
</div>
<hr>
</div>
<div ng-repeat="node in ListNode">
<h3>{{ node.title }}
<span>
<a href="javascript:void(0);" modal-for-nodes="{{node.schema.model_name}},ListNode,add">
<i class="fa fa-plus-circle fa-fw"></i>
</a>
</span>
</h3>
<div class="list-node-table">
<ng-include src="'shared/templates/nodeTable.html'"></ng-include>
</div>
<hr>
</div>
</div>
\ No newline at end of file
<div class="container" ng-app="ulakbus.crud">
<div class="col-md-6">
<h1>{{ schema.title }}</h1>
<form name="formgenerated" sf-schema="schema" sf-form="form" sf-model="model" ng-submit="onSubmit(formgenerated)"></form>
</div>
</div>
\ No newline at end of file
<div class="starter-template container">
<h1>{{model}} <a href="#/crud/{{model}}/add"><button type="button" class="btn btn-primary">Ekle</button></a></h1>
<div class="row" ng-if="!nobjects[1]">
<div class="col-md-12">
<p class="no-content">Listelenecek içerik yok.</p>
</div>
</div>
<div class="tablescroll" ng-if="nobjects[1]">
<table class="table table-bordered" style="background-color:#fff;">
<thead>
<tr>
<th 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>
</tr>
</thead>
<tbody>
<tr ng-repeat="object in nobjects" ng-if="$index>0">
<td width="60">
<label>
<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">
</label>
</td>
<th scope="row" style="text-align:center">{{$index}}</th>
<td ng-repeat="k in object track by $index" ng-if="nobjects[0]=='-1' && $index>0">
<a ng-href="#/crud/{{model}}/{{object[0]}}">{{object[1]}}</a>
</td>
<td ng-repeat="(key,value) in object track by $index" ng-if="nobjects[0]!='-1' && $index>0">
<a ng-href="#/crud/{{model}}/{{object[0]}}" ng-if="$index==1">{{object[key]}}</a>
<span ng-if="$index!=1">{{object[key]}}</span>
</td>
<td>
<a ng-href="#/crud/{{model}}/edit/{{object[0]}}">Edit</a><br>
</td>
</tr>
</tbody>
</table>
</div>
<br/>
<hr/>
<div class="btn-group" ng-if="nobjects[1]">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
İşlemler <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="">İşlem 1</a></li>
<li><a href="">İşlem 2</a></li>
<li><a href="">İşlem 3</a></li>
<li role="separator" class="divider"></li>
<li><a href="">İşlem 4</a></li>
</ul>
</div>
<hr>
</div>
\ No newline at end of file
<div class="starter-template container">
<div class="personnel-info-container">
<div class="personnel-info-left">
<!--<div class="generic-profile-picture">-->
<!--<img src="../../img/sample-profile-pic.jpg" />-->
<!--</div>-->
<div class="info-block">
<div class="info-block-header">
<h1>{{model}}</h1>
</div>
<!-- end of info-block-header -->
<div class="info-block-body" ng-repeat="(key, value) in object">
<dl class="dl-horizontal">
<dt>{{ key }}</dt>
<dd>{{value}}</dd>
</dl>
</div>
<!-- end of info-block-body -->
</div>
<!--<ul>-->
<!--<li ng-repeat="(key, value) in object"><span class="col-md-3">{{ key }}:</span>{{value}}</li>-->
<!--<li>Pozisyon</li>-->
<!--<li><i class="fa fa-phone"></i> (+90) 123 456 7890</li>-->
<!--<li><i class="fa fa-envelope"></i> samplemail@mail.com</li>-->
<!--<li><i class="fa fa-map-marker"></i> Gülbahçe Mah. İzmir Teknoloji Geliştirme Bölgesi A9 Blok 215/A IYTE Campus, URLA/IZMIR</li></li>-->
<!--</ul>-->
</div>
<!-- end of personnel-info-left -->
<div class="personnel-info-right">
<div class="info-block" ng-repeat="(key, value) in listobjects">
<div class="info-block-header">
<h2>{{key}}</h2>
</div>
<!-- end of info-block-header -->
<div class="info-block-body" ng-repeat="(k, v) in value">
<dl class="dl-horizontal">
<dt>{{k}}</dt>
<dd>{{v}}</dd>
</dl>
</div>
<!-- end of info-block-body -->
</div>
<!-- end of info block -->
<!-- end of info block -->
</div>
<!-- personnel-info-left -->
</div>
<!-- end of personnel-info-container -->
</div>
\ No newline at end of file
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*/
'use strict';
var wf = angular.module('ulakbus.wf', ['ui.bootstrap', 'schemaForm', 'formService']);
/**
* CRUDAddEditCtrl is a controller
* which provide a form with form generator.
*/
wf.controller('WFAddEditCtrl', function ($scope, $rootScope, $location, $http, $log, $modal, $timeout, Generator, $routeParams) {
$scope.url = "";
$scope.form_params = {'model': $routeParams.model};
//if ($routeParams.id) {
// $scope.form_params['object_id'] = $routeParams.id;
// $scope.form_params['cmd'] = 'edit';
//}
//else {
// $scope.form_params['cmd'] = 'add';
//}
// get form with generator
if ($routeParams.model) {
Generator.get_form($scope);
}
$scope.onSubmit = function (form) {
$scope.$broadcast('schemaFormValidate');
if (form.$valid) {
Generator.submit($scope)
.success(function(data){
})
.error(function(data){
//$scope.message = data.title;
});
}
};
});
/**
* WorkFlow List Controller
*/
wf.controller('WFListCtrl', function ($scope, $rootScope, Generator, $routeParams) {
$scope.url = "";
$scope.form_params = $routeParams;
if ($routeParams.nobjects){
$scope.nobjects = $routeParams.nobjects;
$scope.model = $routeParams.model;
} else {
// call generator's get_list func
Generator.get_list($scope)
.then(function (res) {
$scope.nobjects = res.data.nobjects;
$scope.model = $routeParams.model;
});
}
});
/**
* WorkFlow Show Controller
*/
wf.controller('WFShowCtrl', function ($scope, $rootScope, Generator, $routeParams) {
$scope.url = "";
$scope.form_params = {"object_id": $routeParams.id, "cmd": "show", "model": $routeParams.model};
// call generator's get_single_itemfunc
Generator.get_single_item($scope).then(function (res) {
$scope.listobjects = {};
$scope.object = res.data.object;
angular.forEach($scope.object, function (value, key) {
if(typeof value == 'object'){
$scope.listobjects[key] = value;
delete $scope.object[key];
}
});
$scope.model = $routeParams.model;
})
});
\ No newline at end of file
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*/
'use strict';
describe('crud controller module', function () {
beforeEach(module('ulakbus'));
beforeEach(module('ulakbus.crud'));
var $controller;
beforeEach(inject(function (_$controller_) {
$controller = _$controller_;
}));
describe('crud add controller', function() {
it('should get form', function() {
var $scope = {};
var controller = $controller('CRUDAddEditCtrl', { $scope: $scope });
expect($scope).not.toEqual(null);
});
});
// todo: chack if needed for these tests
// describe('crud list controller', function() {
// it('should get list', function() {
// var $scope = {};
// var controller = $controller('CRUDListCtrl', { $scope: $scope });
// expect($scope).not.toEqual(null);
// });
// });
// describe('crud show controller', function() {
// it('should get single item', function() {
// var $scope = {};
// var controller = $controller('CRUDShowCtrl', { $scope: $scope });
// expect($scope).not.toEqual(null);
// });
// });
describe('crud controller', function () {
it('should have CRUDAddEditCtrl', inject(function ($controller) {
expect($controller).toBeDefined();
}));
it('should have CRUDListCtrl', inject(function ($controller) {
expect($controller).toBeDefined();
}));
it('should have CRUDShowCtrl', inject(function ($controller) {
expect($controller).toBeDefined();
}));
});
});
\ No newline at end of file
......@@ -22,7 +22,6 @@ var app = angular.module(
'ulakbus.crud',
'ulakbus.debug',
'ulakbus.devSettings',
'ulakbus.wf',
'ulakbus.version',
//'schemaForm',
'gettext',
......
This diff is collapsed.
......@@ -22,7 +22,7 @@ describe('form service module', function () {
function (Generator) {
expect(Generator.group).not.toBe(null);
var generated_url = Generator.makeUrl({url: 'test', form_params: {}});
expect(generated_url).toEqual("http://api.ulakbus.net/test/");
expect(generated_url).toEqual("//nightly.api.ulakbus.net/test/");
}])
);
......@@ -197,32 +197,6 @@ describe('form service module', function () {
})
);
it('should get single item',
inject(function (Generator, $httpBackend, RESTURL) {
$httpBackend.expectPOST(RESTURL.url + 'test/personel?personel_id=123')
.respond(200, {
items: {
"client_cmd": "show_object",
"object": {
"ad": "name",
"soyad": "lastname",
},
"token": "da73993f439549e7855fd82deafbbc99",
"is_login": true
}
});
var cred = {cmd: 'show', model: 'personel', param: 'personel_id', id: '123'};
Generator.get_single_item({url: 'test', form_params: cred})
.then(function (data) {
expect(data.data.items.token).toEqual("da73993f439549e7855fd82deafbbc99");
});
$httpBackend.flush();
})
);
it('should submit form',
inject(function (Generator, $httpBackend, RESTURL) {
......@@ -333,9 +307,8 @@ describe('form service module', function () {
"token": "da73993f439549e7855fd82deafbbc99",
"is_login": true
});
console.log(32131);
scope.url = 'test';
//scope.url = 'test';
scope.form_params = {
param: 'test',
id:'xyz123',
......@@ -361,35 +334,6 @@ describe('form service module', function () {
ctrl = $controller("CRUDCtrl", {$scope: scope});
}));
it('should generate itemlinks of objects in response data',
inject(function (Generator) {
var responseObject = {
"objects": [
"-1",
{
"fields": ["test object"],
"actions": [{"cmd": "delete", "name": "Sil"}, {"wf": "manage_permissions", "name": "Yetkilendir", "mode": "modal"}],
"do_list": true,
"key": "xx10"},
{
"fields": ["test object 2"],
"actions": [{"cmd": "delete", "name": "Sil"}, {"wf": "manage_permissions", "name": "Yetkilendir", "mode": "modal"}],
"do_list": true,
"key": "xx11"}
]
};
scope.url = 'test';
scope.form_params = {
param: 'test',
id:'xyz123',
model:'testModel',
object_id: 'xxx11',
wf:'testModel'};
Generator.itemLinksGenerator(scope, responseObject);
expect(responseObject.objects[1].detailLink).toEqual('#test/testModel/detail/xx10?test=xyz123');
})
);
});
var $controller;
......
......@@ -13,7 +13,6 @@ app.config(['$httpProvider', function ($httpProvider) {
$httpProvider.interceptors.push(function ($q, $rootScope, $location, $timeout) {
return {
'request': function (config) {
// todo: delete console logs
if (config.method === "POST") {
// to prevent OPTIONS preflight request
config.headers["Content-Type"] = "text/plain";
......@@ -100,7 +99,6 @@ app.config(['$httpProvider', function ($httpProvider) {
}
}
if (rejection.status === 403) {
console.log(403);
if (rejection.data.is_login === true) {
$rootScope.loggedInUser = true;
if ($location.path() === "/login") {
......@@ -112,15 +110,10 @@ app.config(['$httpProvider', function ($httpProvider) {
$rootScope.$broadcast('show_notifications', rejection.data);
if (rejection.status === 404) {
console.log(404);
errorModal();
//$location.path("/error/404");
}
// server 500 error returns with -1 on status.
//if (rejection.status === -1 && rejection.config.data.model) {
if (rejection.status === 500) {
errorModal();
//$location.path("/error/500");
}
return $q.reject(rejection);
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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