Commit a31b54cb authored by Evren Kutar's avatar Evren Kutar

versioning 0.6.0

parent 1e601f4a
...@@ -79,9 +79,7 @@ module.exports = function (grunt) { ...@@ -79,9 +79,7 @@ module.exports = function (grunt) {
{expand: true, cwd: 'app/styles/images/', src: '*', dest: 'dist/css/images/', flatten: true}, {expand: true, cwd: 'app/styles/images/', src: '*', dest: 'dist/css/images/', flatten: true},
{expand: true, cwd: 'app/bower_components/bootstrap/dist/fonts/', src: '*', dest: 'dist/fonts/', flatten: true, filter: 'isFile'}, {expand: true, cwd: 'app/bower_components/bootstrap/dist/fonts/', src: '*', dest: 'dist/fonts/', flatten: true, filter: 'isFile'},
{expand: true, cwd: 'app/bower_components/jquery/dist/', src: 'jquery.min.js', dest: 'dist/bower_components/', flatten: true, filter: 'isFile'}, {expand: true, cwd: 'app/bower_components/jquery/dist/', src: 'jquery.min.js', dest: 'dist/bower_components/', flatten: true, filter: 'isFile'},
{expand: true, cwd: 'app/bower_components/angular/', src: 'angular.min.js', dest: 'dist/bower_components/', flatten: true, filter: 'isFile'}, {expand: true, cwd: 'app/bower_components/angular/', src: 'angular.min.js', dest: 'dist/bower_components/', flatten: true, filter: 'isFile'}
//{expand: true, cwd: 'app/shared/scripts/', src: 'theme.js', dest: 'dist/bower_components/', flatten: true, filter: 'isFile'},
{expand: true, cwd: 'app/shared/scripts/', src: 'jquery-ui.min.js', dest: 'dist/bower_components/', flatten: true, filter: 'isFile'}
] ]
}, },
local_prod: { local_prod: {
...@@ -94,8 +92,7 @@ module.exports = function (grunt) { ...@@ -94,8 +92,7 @@ module.exports = function (grunt) {
{expand: true, cwd: 'app/styles/images/', src: '*', dest: 'dist/css/images/', flatten: true}, {expand: true, cwd: 'app/styles/images/', src: '*', dest: 'dist/css/images/', flatten: true},
{expand: true, cwd: 'app/bower_components/bootstrap/dist/fonts/', src: '*', dest: 'dist/fonts/', flatten: true, filter: 'isFile'}, {expand: true, cwd: 'app/bower_components/bootstrap/dist/fonts/', src: '*', dest: 'dist/fonts/', flatten: true, filter: 'isFile'},
{expand: true, cwd: 'app/bower_components/jquery/dist/', src: 'jquery.min.js', dest: 'dist/bower_components/', flatten: true, filter: 'isFile'}, {expand: true, cwd: 'app/bower_components/jquery/dist/', src: 'jquery.min.js', dest: 'dist/bower_components/', flatten: true, filter: 'isFile'},
{expand: true, cwd: 'app/bower_components/angular/', src: 'angular.js', dest: 'dist/bower_components/', flatten: true, filter: 'isFile'}, {expand: true, cwd: 'app/bower_components/angular/', src: 'angular.js', dest: 'dist/bower_components/', flatten: true, filter: 'isFile'}
{expand: true, cwd: 'app/shared/scripts/', src: 'jquery-ui.min.js', dest: 'dist/bower_components/', flatten: true, filter: 'isFile'}
] ]
} }
}, },
...@@ -127,8 +124,7 @@ module.exports = function (grunt) { ...@@ -127,8 +124,7 @@ module.exports = function (grunt) {
}, },
components: { components: {
src: [ src: [
//"app/bower_components/angular/angular.js", "app/bower_components/angular-i18n/angular-locale_tr.js",
//"app/bower_components/jquery/dist/jquery.js",
"app/bower_components/bootstrap/dist/js/bootstrap.js", "app/bower_components/bootstrap/dist/js/bootstrap.js",
"app/bower_components/angular-route/angular-route.js", "app/bower_components/angular-route/angular-route.js",
"app/bower_components/angular-cookies/angular-cookies.js", "app/bower_components/angular-cookies/angular-cookies.js",
...@@ -179,7 +175,7 @@ module.exports = function (grunt) { ...@@ -179,7 +175,7 @@ module.exports = function (grunt) {
}, },
components_branch: { components_branch: {
src: [ src: [
//"app/bower_components/jquery/dist/jquery.min.js", "app/bower_components/angular-i18n/angular-locale_tr.js",
"app/bower_components/angular-route/angular-route.min.js", "app/bower_components/angular-route/angular-route.min.js",
"app/bower_components/angular-cookies/angular-cookies.min.js", "app/bower_components/angular-cookies/angular-cookies.min.js",
"app/bower_components/angular-resource/angular-resource.min.js", "app/bower_components/angular-resource/angular-resource.min.js",
......
...@@ -51,6 +51,7 @@ app.config(['$routeProvider', function ($routeProvider, $route) { ...@@ -51,6 +51,7 @@ app.config(['$routeProvider', function ($routeProvider, $route) {
.run(function ($rootScope) { .run(function ($rootScope) {
$rootScope.loggedInUser = true; $rootScope.loggedInUser = true;
$rootScope.loginAttempt = 0;
$rootScope.$on("$routeChangeStart", function (event, next, current) { $rootScope.$on("$routeChangeStart", function (event, next, current) {
// will be used when needed // will be used when needed
}); });
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
'use strict'; 'use strict';
var auth = angular.module('ulakbus.auth', ['ngRoute', 'schemaForm', 'ngCookies']); var auth = angular.module('ulakbus.auth', ['ngRoute', 'schemaForm', 'ngCookies']);
auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, Generator, LoginService) { auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, $rootScope, $log, Generator, LoginService) {
$scope.url = 'login'; $scope.url = 'login';
$scope.form_params = {}; $scope.form_params = {};
$scope.form_params['clear_wf'] = 1; $scope.form_params['clear_wf'] = 1;
...@@ -23,13 +23,16 @@ auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, Gener ...@@ -23,13 +23,16 @@ auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, Gener
$scope.onSubmit = function (form) { $scope.onSubmit = function (form) {
$scope.$broadcast('schemaFormValidate'); $scope.$broadcast('schemaFormValidate');
if (form.$valid) { if (form.$valid) {
$rootScope.loginAttempt = 1;
LoginService.login($scope.url, $scope.model) LoginService.login($scope.url, $scope.model)
.error(function(data){ .error(function(data){
$scope.message = data.title; $scope.message = data.title;
}) })
} }
else { else {
console.log("not valid"); $log.debug("not valid");
}
} }
};
$log.debug('login attempt: ', $rootScope.loginAttempt);
}); });
\ No newline at end of file
...@@ -29,24 +29,29 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService']) ...@@ -29,24 +29,29 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService'])
* @returns {*} * @returns {*}
*/ */
generateParam: function (scope, routeParams, cmd) { generateParam: function (scope, routeParams, cmd) {
// define api request url path
scope.url = routeParams.wf; scope.url = routeParams.wf;
// why do this??
angular.forEach(routeParams, function (value, key) { angular.forEach(routeParams, function (value, key) {
if (key.indexOf('_id') > -1 && key !== 'param_id') { if (key.indexOf('_id') > -1 && key !== 'param_id') {
scope.param = key; scope.param = key;
scope.param_id = value; scope.param_id = value;
} }
}); });
scope.form_params = { scope.form_params = {
//cmd: cmd, //cmd: cmd,
model: routeParams.model, model: routeParams.model,
param: scope.param || routeParams.param, param: scope.param || routeParams.param,
id: scope.param_id || routeParams.param_id, id: scope.param_id || routeParams.param_id,
wf: routeParams.wf, wf: routeParams.wf,
object_id: routeParams.key object_id: routeParams.key,
filters: []
}; };
scope.form_params[scope.param] = scope.param_id;
if (scope.param_id) {
scope.form_params.filters.push({field: scope.param, values: [scope.param_id], type: 'check'});
}
scope.model = scope.form_params.model; scope.model = scope.form_params.model;
scope.wf = scope.form_params.wf; scope.wf = scope.form_params.wf;
scope.param = scope.form_params.param; scope.param = scope.form_params.param;
...@@ -150,16 +155,6 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService']) ...@@ -150,16 +155,6 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService'])
} }
}; };
$scope.filter = {};
$scope.addToFilter = function (field, filterValue) {
};
$scope.filterSubmit = function () {
};
$scope.do_action = function (key, cmd, mode) { $scope.do_action = function (key, cmd, mode) {
Generator.doItemAction($scope, key, cmd, mode || 'normal'); Generator.doItemAction($scope, key, cmd, mode || 'normal');
}; };
...@@ -168,22 +163,7 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService']) ...@@ -168,22 +163,7 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService'])
return new Array(num); return new Array(num);
}; };
$timeout(function () { ;
jQuery('.filterDate').datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd.mm.yy",
onSelect: function (date, inst) {
//scope.model[k] = date;
//if (scope.modalElements) {
// scope.validateModalDate(k);
//}
//else {
// scope.$broadcast('schemaForm.error.' + k, 'tv4-302', true);
//}
}
}).datepicker("setDate", new Date());
});
// //
$scope.showCmd = function () { $scope.showCmd = function () {
...@@ -299,6 +279,70 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService']) ...@@ -299,6 +279,70 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService'])
return { return {
templateUrl: 'components/crud/templates/filter.html', templateUrl: 'components/crud/templates/filter.html',
restrict: 'E', restrict: 'E',
replace: true replace: true,
link: function ($scope) {
$scope.filters = {};
angular.forEach($scope.listFilters, function (value, key) {
$scope.filters[value.field] = {field: value.field, values: [], type: value.type};
//if (value.type === 'date') {
// $scope.form_params.filters.push({field: value.field, values: [$scope.filterStartDate, $scope.filterEndDate], type: value.type});
//}
});
$scope.filterStartDate;
$scope.filterEndDate;
$scope.status = {startOpened: false, endOpened: false};
$scope.dateFilterOpen = function ($event, which) {
this.status[which] = true;
}; };
$scope.format = 'dd.MM.yyyy'
}
};
})
.directive('dateFilter', function () {
return {
templateUrl: 'components/crud/templates/dateFilter.html',
restrict: 'E',
replace: true,
link: function ($scope) {
$scope.filterStartDate;
$scope.filterEndDate;
$scope.status = {startOpened: false, endOpened: false};
$scope.dateFilterOpen = function ($event, which) {
this.status[which] = true;
};
$scope.format = 'dd.MM.yyyy'
}
}
})
.directive('checkboxFilter', function () {
return {
templateUrl: 'components/crud/templates/dateFilter.html',
restrict: 'E',
replace: true,
link: function ($scope) {
$scope.filterStartDate;
$scope.filterEndDate;
$scope.status = {startOpened: false, endOpened: false};
$scope.dateFilterOpen = function ($event, which) {
this.status[which] = true;
};
$scope.format = 'dd.MM.yyyy'
}
}
})
.directive('selectFilter', function () {
return {
templateUrl: 'components/crud/templates/dateFilter.html',
restrict: 'E',
replace: true,
link: function ($scope) {
$scope.filterStartDate;
$scope.filterEndDate;
$scope.status = {startOpened: false, endOpened: false};
$scope.dateFilterOpen = function ($event, which) {
this.status[which] = true;
};
$scope.format = 'dd.MM.yyyy'
}
}
}); });
\ No newline at end of file
<div> <div>
<h2>Filtrele</h2> <h2>Filtrele</h2>
<div ng-repeat="filter in list_filters"> <div ng-repeat="filter in list_filters">
<div> <div>
<div class=" clearfix"> <div class=" clearfix">
...@@ -8,28 +9,57 @@ ...@@ -8,28 +9,57 @@
<div ng-if="filter.type==='check' || !filter.type"> <div ng-if="filter.type==='check' || !filter.type">
<div class="checkbox" ng-repeat="filterItem in filter.values"> <div class="checkbox" ng-repeat="filterItem in filter.values">
<input type="checkbox" name="filter_group[]" value="{{filterItem.value}}"/>{{filterItem.name}}<br /> <label class="checkbox-inline">
<input type="checkbox" name="filter_group[]" value="{{filterItem.value}}"/>
{{filterItem.name}}
</label>
</div> </div>
</div> </div>
<div ng-if="filter.type==='select'"> <div ng-if="filter.type==='select'">
<div class="col-md-12"> <div class="col-md-12">
<select name="filterSelect" id="filterSelect" class="form-control"> <select name="filterSelect" id="filterSelect" class="form-control">
<option ng-repeat="filterItem in filter.values" value="{{filterItem.value}}">{{filterItem.name}}</option> <option ng-repeat="filterItem in filter.values" value="{{filterItem.value}}">
{{filterItem.name}}
</option>
</select> </select>
</div> </div>
</div> </div>
<div ng-if="filter.type==='date'"> <div ng-if="filter.type==='date'">
<div class="col-md-6"> <div class="col-md-12">
<br>
<label class="control-label" for="startDate">Başlangıç</label> <label class="control-label" for="startDate">Başlangıç</label>
<input type="text" name="startDate" class="form-control filterDate"/>
<p class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="dateFilterOpen($event, 'startOpened')">
<i class="fa fa-calendar"></i>
</button>
</span>
<input type="text" name="startDate" class="form-control" ng-model="filterStartDate"
uib-datepicker-popup="{{format}}"
is-open="status.startOpened"
close-text="Kapat"
current-text="Bugün"
clear-text="Temizle"
ng-click="dateFilterOpen($event, 'startOpened')"/></p>
</div> </div>
<div class="col-md-6"> <div class="col-md-12">
<br>
<label class="control-label" for="endDate">Bitiş</label> <label class="control-label" for="endDate">Bitiş</label>
<input type="text" name="endDate" class="form-control filterDate"/>
<p class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="dateFilterOpen($event, 'endOpened')">
<i class="fa fa-calendar"></i>
</button>
</span>
<input type="text" name="endDate" class="form-control" ng-model="filterEndDate"
uib-datepicker-popup="{{format}}"
is-open="status.endOpened"
close-text="Kapat"
current-text="Bugün"
clear-text="Temizle"
ng-click="dateFilterOpen($event, 'endOpened')"/></p>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<div class="dashboard-search-results"> <div class="dashboard-search-results">
<ul ng-if="students.length > 0"> <ul ng-if="students.length > 0">
<li ng-repeat="student in students"> <li ng-repeat="student in students">
<a href="javascript:void(0)" ng-click="select(student, 'ogrenci')">{{student}}</a> <a href="javascript:void(0)" ng-click="select(student, 'ogrenci')">{{student[0]}}</a>
</li> </li>
</ul> </ul>
</div> </div>
......
...@@ -5,4 +5,4 @@ angular.module('ulakbus.version', [ ...@@ -5,4 +5,4 @@ angular.module('ulakbus.version', [
'ulakbus.version.version-directive' 'ulakbus.version.version-directive'
]) ])
.value('version', '0.5.1'); .value('version', '0.6.0');
...@@ -5,7 +5,7 @@ describe('ulakbus.version module', function() { ...@@ -5,7 +5,7 @@ describe('ulakbus.version module', function() {
describe('version service', function() { describe('version service', function() {
it('should return current version', inject(function(version) { it('should return current version', inject(function(version) {
expect(version).toEqual('0.5.1'); expect(version).toEqual('0.6.0');
})); }));
}); });
}); });
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<script src="tmp/templates.js"></script> <script src="tmp/templates.js"></script>
<script src="app.js"></script> <script src="app.js"></script>
<script src="app_routes.js"></script> <script src="app_routes.js"></script>
<script src="shared/scripts/jquery-ui.min.js"></script> <!--<script src="shared/scripts/jquery-ui.min.js"></script>-->
<script src="shared/directives.js"></script> <script src="shared/directives.js"></script>
<script src="zetalib/interceptors.js"></script> <script src="zetalib/interceptors.js"></script>
<script src="zetalib/form_service.js"></script> <script src="zetalib/form_service.js"></script>
......
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
<script src="tmp/templates.js"></script> <script src="tmp/templates.js"></script>
<script src="app.js"></script> <script src="app.js"></script>
<script src="app_routes.js"></script> <script src="app_routes.js"></script>
<script src="shared/scripts/jquery-ui.min.js"></script> <!--<script src="shared/scripts/jquery-ui.min.js"></script>-->
<script src="shared/directives.js"></script> <script src="shared/directives.js"></script>
<script src="zetalib/interceptors.js"></script> <script src="zetalib/interceptors.js"></script>
<script src="zetalib/form_service.js"></script> <script src="zetalib/form_service.js"></script>
......
...@@ -331,8 +331,9 @@ app.directive('logout', function ($http, $location, RESTURL) { ...@@ -331,8 +331,9 @@ app.directive('logout', function ($http, $location, RESTURL) {
// changing menu items by listening for broadcast // changing menu items by listening for broadcast
$scope.$on("menuitems", function (event, data) { $scope.$on("menuitems", function (event, data) {
var menu = {other: $scope.allMenuItems.other}; var menu = {};
menu[data] = $scope.allMenuItems[data]; menu[data] = $scope.allMenuItems[data];
menu['other'] = $scope.allMenuItems.other;
$scope.menuItems = $scope.prepareMenu(menu); $scope.menuItems = $scope.prepareMenu(menu);
$timeout(function () { $timeout(function () {
sidebarmenu.metisMenu() sidebarmenu.metisMenu()
......
...@@ -184,12 +184,17 @@ angular.module('formService', ['ui.bootstrap']) ...@@ -184,12 +184,17 @@ angular.module('formService', ['ui.bootstrap'])
// check if type is date and if type date found change it to string // check if type is date and if type date found change it to string
if (v.type === 'date') { if (v.type === 'date') {
var modelDate = angular.copy(scope.model[k]); if (isNaN(new Date(scope.model[k]))) {
var modelDate;
}
else {
var modelDate = new Date(scope.model[k]);
}
scope.model[k] = generator.dateformatter(scope.model[k]); scope.model[k] = generator.dateformatter(scope.model[k]);
scope.form[scope.form.indexOf(k)] = { scope.form[scope.form.indexOf(k)] = {
key: k, name: k, title: v.title, key: k, name: k, title: v.title,
type: 'template', type: 'template',
modelDate: new Date(modelDate), modelDate: modelDate,
templateUrl: 'shared/templates/datefield.html', templateUrl: 'shared/templates/datefield.html',
validationMessage: { validationMessage: {
'dateNotValid': "Girdiğiniz tarih geçerli değildir. <i>orn: '01.01.2015'<i/>", 'dateNotValid': "Girdiğiniz tarih geçerli değildir. <i>orn: '01.01.2015'<i/>",
...@@ -200,6 +205,9 @@ angular.module('formService', ['ui.bootstrap']) ...@@ -200,6 +205,9 @@ angular.module('formService', ['ui.bootstrap'])
var deferred = $q.defer(); var deferred = $q.defer();
$timeout(function () { $timeout(function () {
scope.model[k] = angular.copy(generator.dateformatter(value)); scope.model[k] = angular.copy(generator.dateformatter(value));
if (scope.schema.required.indexOf(k) > -1) {
deferred.resolve();
}
if (value.constructor === Date) { if (value.constructor === Date) {
deferred.resolve(); deferred.resolve();
} }
......
...@@ -12,7 +12,7 @@ describe('form service module', function () { ...@@ -12,7 +12,7 @@ describe('form service module', function () {
beforeEach(module('ulakbus')); beforeEach(module('ulakbus'));
beforeEach(module('formService')); beforeEach(module('formService'));
var location; var location;
beforeEach(inject(function($location, $injector) { beforeEach(inject(function ($location, $injector) {
location = $location; location = $location;
// Set up the mock http service responses // Set up the mock http service responses
$httpBackend = $injector.get('$httpBackend'); $httpBackend = $injector.get('$httpBackend');
...@@ -81,16 +81,30 @@ describe('form service module', function () { ...@@ -81,16 +81,30 @@ describe('form service module', function () {
expect(Generator.prepareFormItems).not.toBe(null); expect(Generator.prepareFormItems).not.toBe(null);
var scope = { var scope = {
form: ['email', 'id', 'name'], form: ['email', 'id', 'name', 'save', 'select', 'date'],
schema: { schema: {
properties: { properties: {
email: {title: 'email', type: 'email'}, email: {title: 'email', type: 'email'},
id: {title: 'id', type: 'int'}, id: {title: 'id', type: 'int'},
name: {title: 'name', type: 'string'} name: {title: 'name', type: 'string'},
save: {title: 'save', type: 'submit'},
select: {title: 'select', type: 'select'},
date: {title: 'date', type: 'date'},
text_general: {title: 'text_general', type: 'text_general'},
model: {title: 'model', type: 'model'},
node: {title: 'Node', type: 'Node'},
listnode: {title: 'ListNode', type: 'ListNode'}
}, required: [], type: 'object', title: 'servicetest' }, required: [], type: 'object', title: 'servicetest'
}, },
model: { model: {
email: 'test@test.com', id: 2, name: 'travolta' email: 'test@test.com', id: 2, name: 'travolta',
save: {title: 'save', type: 'submit'},
select: 2,
date: '12.12.2012',
text_general: 'test',
model: '32gy1ukf3qiryv',
node: '',
listnode: ''
}, },
form_params: {} form_params: {}
}; };
...@@ -138,8 +152,7 @@ describe('form service module', function () { ...@@ -138,8 +152,7 @@ describe('form service module', function () {
}]) }])
); );
it('should get form', it('should get form', inject(function (Generator, $httpBackend, RESTURL) {
inject(function (Generator, $httpBackend, RESTURL) {
$httpBackend.expectPOST(RESTURL.url + 'add_student/', {cmd: 'add'}) $httpBackend.expectPOST(RESTURL.url + 'add_student/', {cmd: 'add'})
.respond(200, { .respond(200, {
...@@ -179,12 +192,16 @@ describe('form service module', function () { ...@@ -179,12 +192,16 @@ describe('form service module', function () {
it('should get list', it('should get list',
inject(function (Generator, $httpBackend, RESTURL) { inject(function (Generator, $httpBackend, RESTURL) {
$httpBackend.expectPOST(RESTURL.url + 'test/personel', {cmd: 'list', model: "personel", object_id: "5821bc25a90aa1"}) $httpBackend.expectPOST(RESTURL.url + 'test/personel', {
cmd: 'list',
model: "personel",
object_id: "5821bc25a90aa1"
})
.respond(200, { .respond(200, {
items: { items: {
"client_cmd": "list_objects", "client_cmd": "list_objects",
"is_login": true, "is_login": true,
"objects":[ "objects": [
["Ad\u0131", "Soyad\u0131", "TC No", "Durum"], ["Ad\u0131", "Soyad\u0131", "TC No", "Durum"],
["4MsKRH9435cdKOzKCITNPml5bhB", "firstname", "lastname", "dksoap", false] ["4MsKRH9435cdKOzKCITNPml5bhB", "firstname", "lastname", "dksoap", false]
], ],
...@@ -215,7 +232,7 @@ describe('form service module', function () { ...@@ -215,7 +232,7 @@ describe('form service module', function () {
url: 'student/add' url: 'student/add'
}; };
Generator.submit(scope) Generator.submit(scope)
.success(function(){ .success(function () {
}) })
.then(function (data) { .then(function (data) {
...@@ -226,7 +243,7 @@ describe('form service module', function () { ...@@ -226,7 +243,7 @@ describe('form service module', function () {
); );
it('should validate email', it('should validate email',
inject(function(Generator){ inject(function (Generator) {
var validEmails = [ var validEmails = [
'test@test.com', 'test@test.com',
'test@test.co.uk', 'test@test.co.uk',
...@@ -253,7 +270,7 @@ describe('form service module', function () { ...@@ -253,7 +270,7 @@ describe('form service module', function () {
); );
it('should validate tcNo', it('should validate tcNo',
inject(function(Generator){ inject(function (Generator) {
var validTCNos = [ var validTCNos = [
'12345678902', '12345678902',
'18307990654' '18307990654'
...@@ -277,6 +294,38 @@ describe('form service module', function () { ...@@ -277,6 +294,38 @@ describe('form service module', function () {
} }
}) })
); );
it('should validate date',
inject(function (Generator) {
var validDates = [
'12.12.2012',
'12/12/2012'
];
var invalidDates = [
'00000000000',
'dsad',
'0.0.0',
'12.15.2012',
''
];
for (var i in validDates) {
var valid = Generator.isValidDate(validDates[i]);
console.log(validDates[i]);
expect(valid).toBeTruthy();
}
for (var i in invalidDates) {
console.log(invalidDates[i]);
var valid = Generator.isValidDate(invalidDates[i]);
console.log(valid)
expect(valid).toBeFalsy();
}
})
);
it('should get wf and redirect according to client_cmd', it('should get wf and redirect according to client_cmd',
inject(function (Generator, $httpBackend, RESTURL) { inject(function (Generator, $httpBackend, RESTURL) {
...@@ -316,10 +365,11 @@ describe('form service module', function () { ...@@ -316,10 +365,11 @@ describe('form service module', function () {
//scope.url = 'test'; //scope.url = 'test';
scope.form_params = { scope.form_params = {
param: 'test', param: 'test',
id:'xyz123', id: 'xyz123',
model:'testModel', model: 'testModel',
object_id: 'xxx11', object_id: 'xxx11',
wf:'testModel'}; wf: 'testModel'
};
scope.url = 'test'; scope.url = 'test';
...@@ -331,7 +381,7 @@ describe('form service module', function () { ...@@ -331,7 +381,7 @@ describe('form service module', function () {
); );
it('should return diff object', it('should return diff object',
inject( function (Generator) { inject(function (Generator) {
expect(Generator.get_diff).not.toBe(null); expect(Generator.get_diff).not.toBe(null);
// test cases - testing for success // test cases - testing for success
...@@ -378,7 +428,7 @@ describe('form service module', function () { ...@@ -378,7 +428,7 @@ describe('form service module', function () {
describe('form service', function () { describe('form service', function () {
var location, rootScope, scope, ctrl; var location, rootScope, scope, ctrl;
beforeEach(inject(function($location, $rootScope) { beforeEach(inject(function ($location, $rootScope) {
location = $location; location = $location;
rootScope = $rootScope; rootScope = $rootScope;
scope = $rootScope.$new(); scope = $rootScope.$new();
...@@ -403,15 +453,15 @@ describe('form service module', function () { ...@@ -403,15 +453,15 @@ describe('form service module', function () {
// here begin the directive tests // here begin the directive tests
var compile, scope, directiveElem; var compile, scope, directiveElem;
beforeEach(function(){ beforeEach(function () {
inject(function($compile, $rootScope){ inject(function ($compile, $rootScope) {
compile = $compile; compile = $compile;
scope = $rootScope.$new(); scope = $rootScope.$new();
}); });
// directiveElem = getCompiledElement(); // directiveElem = getCompiledElement();
}); });
function getCompiledElement(){ function getCompiledElement() {
var element = angular.element('<div modal-for-nodes="Personel,ListNode,add"></div>'); var element = angular.element('<div modal-for-nodes="Personel,ListNode,add"></div>');
var compiledElement = compile(element)(scope); var compiledElement = compile(element)(scope);
scope.$digest(); scope.$digest();
......
...@@ -39,6 +39,7 @@ app.config(['$httpProvider', function ($httpProvider) { ...@@ -39,6 +39,7 @@ app.config(['$httpProvider', function ($httpProvider) {
} }
if (response.data.is_login === true) { if (response.data.is_login === true) {
$rootScope.loggedInUser = true; $rootScope.loggedInUser = true;
$rootScope.loginAttempt = 1; // this needs for popup errors
if ($location.path() === "/login") { if ($location.path() === "/login") {
$location.path("/dashboard"); $location.path("/dashboard");
} }
...@@ -52,6 +53,10 @@ app.config(['$httpProvider', function ($httpProvider) { ...@@ -52,6 +53,10 @@ app.config(['$httpProvider', function ($httpProvider) {
'responseError': function (rejection) { 'responseError': function (rejection) {
var errorModal = function () { var errorModal = function () {
if ($rootScope.loginAttempt === 0) {
console.log('not logged in, no alert message triggered');
return;
}
var codefield = ""; var codefield = "";
if (rejection.data.error) { if (rejection.data.error) {
codefield = '<p><pre>' + codefield = '<p><pre>' +
......
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