Commit c6f2bda3 authored by Evren Kutar's avatar Evren Kutar

Merge branch 'Feature/#143/Formsets'

parents 5804a4a9 92c1269e
...@@ -20,14 +20,14 @@ var app = angular.module( ...@@ -20,14 +20,14 @@ var app = angular.module(
'ulakbus.student', 'ulakbus.student',
'schemaForm', 'schemaForm',
'gettext', 'gettext',
'templates-prod' //'templates-prod'
]). ]).
/** /**
* RESTURL is the url of rest api to talk * RESTURL is the url of rest api to talk
* Based on the environment it changes from dev to prod * Based on the environment it changes from dev to prod
*/ */
constant("RESTURL", (function () { constant("RESTURL", (function () {
return {url: "http://"+ window.location.hostname + ":9001/"}; return {url: "http://" + window.location.hostname + ":9001/"};
})()). })()).
/** /**
* USER_ROLES and AUTH_EVENTS are constant for auth functions * USER_ROLES and AUTH_EVENTS are constant for auth functions
...@@ -77,11 +77,11 @@ var app = angular.module( ...@@ -77,11 +77,11 @@ var app = angular.module(
/** /**
* logout directive * logout directive
*/ */
directive('logout', function($http, $location){ directive('logout', function ($http, $location) {
return { return {
link: function($scope, $element, $rootScope){ link: function ($scope, $element, $rootScope) {
$element.on('click', function(){ $element.on('click', function () {
$http.post('http://'+window.location.hostname+':9001/logout', {}).then(function () { $http.post('http://' + window.location.hostname + ':9001/logout', {}).then(function () {
$rootScope.loggedInUser = false; $rootScope.loggedInUser = false;
console.log($rootScope.loggedInUser); console.log($rootScope.loggedInUser);
$location.path("/login"); $location.path("/login");
...@@ -92,6 +92,27 @@ var app = angular.module( ...@@ -92,6 +92,27 @@ var app = angular.module(
} }
}); });
/**
* listnode add directive
*/
//directive('addlistnode', function () {
// return {
// link: function ($scope, $modal, $element) {
// debugger;
//$element.on('click', function () {
// var nodename = $element[0].firstElementChild.innerHTML;
// var newitem = angular.copy($scope.listnodeform[nodename+'_1']);
// console.log($scope.form);
// $scope.form.splice(7, 0, newitem);
// console.log($scope.form);
// $scope.$broadcast('schemaFormRedraw');
// $scope.$apply();
//});
// }
// }
//});
// test the code with strict di mode to see if it works when minified // test the code with strict di mode to see if it works when minified
//angular.bootstrap(document, ['ulakbus'], { //angular.bootstrap(document, ['ulakbus'], {
// strictDi: true // strictDi: true
......
...@@ -10,22 +10,10 @@ ...@@ -10,22 +10,10 @@
var auth = angular.module('ulakbus.auth', ['ngRoute', 'schemaForm', 'ngCookies', 'general']); var auth = angular.module('ulakbus.auth', ['ngRoute', 'schemaForm', 'ngCookies', 'general']);
auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, Generator, LoginService) { auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, Generator, LoginService) {
$scope.url = 'simple_login'; $scope.url = 'simple_login';
var form_params = {}; $scope.form_params = {};
form_params['clear_wf'] = 1; $scope.form_params['clear_wf'] = 1;
// todo: change simple login when api ready // todo: change simple login when api ready
Generator.get_form($scope.url, form_params).then(function(data){ Generator.get_form($scope).then(function(data){
var d = data.data.forms;
for (var key in d)
$scope[key] = d[key];
// for email validation add asyncvalidator
//$scope.form[0].$asyncValidators = Generator.asyncValidators;
// add submit button to the form todo: move this to form service
//$scope.form.push(
// {
// type: "submit",
// title: "Save"
// }
//);
$scope.form = [ $scope.form = [
"*", "*",
{ key: "password", type: "password"}, { key: "password", type: "password"},
......
...@@ -16,33 +16,22 @@ var staff = angular.module('ulakbus.staff', ['ngRoute', 'schemaForm', 'formServi ...@@ -16,33 +16,22 @@ var staff = angular.module('ulakbus.staff', ['ngRoute', 'schemaForm', 'formServi
* which provide a form with form generator. * which provide a form with form generator.
*/ */
staff.controller('StaffAddEditCtrl', function ($scope, $rootScope, $location, $http, $log, Generator, $routeParams) { staff.controller('StaffAddEditCtrl', function ($scope, $rootScope, $location, $http, $log, $modal, Generator, $routeParams) {
$scope.url = 'personel_duzenle_basitlestirilmis'; $scope.url = 'personel_duzenle_basitlestirilmis';
var form_params = {}; $scope.form_params = {};
if ($routeParams.id) { if ($routeParams.id) {
form_params['object_id'] = $routeParams.id; $scope.form_params['object_id'] = $routeParams.id;
form_params['cmd'] = 'edit_object'; $scope.form_params['cmd'] = 'edit_object';
} }
else { else {
form_params['cmd'] = 'add_object'; $scope.form_params['cmd'] = 'add_object';
} }
// to start in certain part of the workflow use clear_wf=1 // to start in certain part of the workflow use clear_wf=1
form_params['clear_wf'] = 1; $scope.form_params['clear_wf'] = 1;
// get form with generator
Generator.get_form($scope);
Generator.get_form($scope.url, form_params).then(function (object) {
var d = object.data.forms;
// add form, schema and model to scope object
for (var key in d)
$scope[key] = d[key];
$scope.initialModel = angular.copy($scope.model);
$scope.form.push(
{
type: "submit",
title: "Save"
}
);
});
$scope.object_id = $routeParams.id;
$scope.onSubmit = function (form) { $scope.onSubmit = function (form) {
$scope.$broadcast('schemaFormValidate'); $scope.$broadcast('schemaFormValidate');
if (form.$valid) { if (form.$valid) {
...@@ -54,7 +43,7 @@ staff.controller('StaffAddEditCtrl', function ($scope, $rootScope, $location, $h ...@@ -54,7 +43,7 @@ staff.controller('StaffAddEditCtrl', function ($scope, $rootScope, $location, $h
$scope.message = data.title; $scope.message = data.title;
}); });
} }
} };
}); });
// todo: for single point of failure code a "get item" service and use it to // todo: for single point of failure code a "get item" service and use it to
...@@ -65,11 +54,12 @@ staff.controller('StaffAddEditCtrl', function ($scope, $rootScope, $location, $h ...@@ -65,11 +54,12 @@ staff.controller('StaffAddEditCtrl', function ($scope, $rootScope, $location, $h
*/ */
staff.controller('StaffListCtrl', function ($scope, $rootScope, Generator) { staff.controller('StaffListCtrl', function ($scope, $rootScope, Generator) {
var form_params = {"clear_wf": 1}; $scope.url = 'personel_duzenle_basitlestirilmis';
Generator.get_form('personel_duzenle_basitlestirilmis', form_params) $scope.form_params = {"clear_wf": 1};
// call generator's get_list func
Generator.get_list($scope)
.then(function (res) { .then(function (res) {
var data = res.data.employees; var data = res.data.employees;
//debugger;
for (var item in data){ for (var item in data){
delete data[item].data['deleted']; delete data[item].data['deleted'];
delete data[item].data['timestamp']; delete data[item].data['timestamp'];
...@@ -82,9 +72,10 @@ staff.controller('StaffListCtrl', function ($scope, $rootScope, Generator) { ...@@ -82,9 +72,10 @@ staff.controller('StaffListCtrl', function ($scope, $rootScope, Generator) {
* Staff Show Controller * Staff Show Controller
*/ */
staff.controller('StaffShowCtrl', function ($scope, $rootScope, Generator, $routeParams) { staff.controller('StaffShowCtrl', function ($scope, $rootScope, Generator, $routeParams) {
var form_params = {"object_id": $routeParams.id, "clear_wf": 1}; $scope.url = 'personel_duzenle_basitlestirilmis';
Generator.get_form('personel_duzenle_basitlestirilmis', form_params).then(function (res) { $scope.form_params = {"object_id": $routeParams.id, "clear_wf": 1};
// todo: get this line below more clear way // call generator's get_single_itemfunc
Generator.get_single_item($scope).then(function (res) {
$scope.staff = res.data.employees[0].data; $scope.staff = res.data.employees[0].data;
}) })
}); });
\ No newline at end of file
...@@ -87,18 +87,14 @@ ...@@ -87,18 +87,14 @@
<script src="bower_components/angular-bootstrap/ui-bootstrap.js"></script> <script src="bower_components/angular-bootstrap/ui-bootstrap.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script> <script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script type="text/javascript" <script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
src="bower_components/angular-sanitize/angular-sanitize.js"></script> <script src="bower_components/tv4/tv4.js"></script>
<script type="text/javascript" src="bower_components/tv4/tv4.js"></script> <script src="bower_components/objectpath/lib/ObjectPath.js"></script>
<script type="text/javascript" <script src="bower_components/angular-schema-form/dist/schema-form.js"></script>
src="bower_components/objectpath/lib/ObjectPath.js"></script> <script src="bower_components/angular-schema-form/dist/bootstrap-decorator.js"></script>
<script type="text/javascript"
src="bower_components/angular-schema-form/dist/schema-form.js"></script>
<script type="text/javascript"
src="bower_components/angular-schema-form/dist/bootstrap-decorator.js"></script>
<!--<script type="text/javascript"--> <!--<script type="text/javascript"-->
<!--src="bower_components/angular-schema-form-datepicker/"></script>--> <!--src="bower_components/angular-schema-form-datepicker/"></script>-->
<script type="text/javascript" src="bower_components/angular-schema-form-datepicker/bootstrap-datepicker.js"></script> <script src="bower_components/angular-schema-form-datepicker/bootstrap-datepicker.js"></script>
<script src="bower_components/angular-gettext/dist/angular-gettext.min.js"></script> <script src="bower_components/angular-gettext/dist/angular-gettext.min.js"></script>
<script src="shared/translations.js"></script> <script src="shared/translations.js"></script>
...@@ -115,7 +111,6 @@ ...@@ -115,7 +111,6 @@
<script src="components/dashboard/dashboard_controller.js"></script> <script src="components/dashboard/dashboard_controller.js"></script>
<script src="components/staff/staff_controller.js"></script> <script src="components/staff/staff_controller.js"></script>
<script src="components/student/student_controller.js"></script> <script src="components/student/student_controller.js"></script>
<script src="components/dashboard/dashboard.js"></script>
<!--<script src="bower_components/quantumui/dist/js/quantumui-nojq.js"></script>--> <!--<script src="bower_components/quantumui/dist/js/quantumui-nojq.js"></script>-->
</body> </body>
......
<div class="col-md-12">
<h1>{{ schema.title }}</h1>
<button type="button" ng-repeat="node in listnodes" ng-click="openmodal(node)">Add <span>{{node}}</span></button>
<form name="formgenerated" sf-schema="schema" sf-form="form" sf-model="model" ng-submit="onSubmit(formgenerated)"></form>
</div>
\ No newline at end of file
<fieldset ng-disabled="form.readonly" class="schema-form-fieldset {{form.htmlClass}}">
<legend ng-class="{'sr-only': !showTitle() }">
<span ng-click="isCollapsed = !isCollapsed">{{ form.title }}</span>
</legend>
<div collapse="isCollapsed" name="{{form.title}}">
<div class="help-block" ng-show="form.description" ng-bind-html="form.description"></div>
<sf-decorator class="col-md-4" ng-repeat="item in form.items" ng-if="item.name!='idx'" form="item"></sf-decorator>
</div>
</fieldset>
<div class="modal-body">
<form name="listnodeform" sf-schema="schema" sf-form="form" sf-model="model"></form>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary" ng-click="onSubmit(listnodeform)">OK</button>
<button type="button" class="btn btn-warning" ng-click="cancel()">Cancel</button>
</div>
\ No newline at end of file
...@@ -25,7 +25,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout, ...@@ -25,7 +25,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
); );
// if fieldset in form, make it collapsable with template // if fieldset in form, make it collapsable with template
scope.listnodeform = {}; scope.listnodeform = {};
if ((scope.listnode && scope.listnodes[0]) || (scope.listnode && scope.nodes[0])) { if ((scope.listnode && scope.listnodes[0]) || (scope.nodes && scope.nodes[0])) {
angular.forEach(scope.form, function (key, val) { angular.forEach(scope.form, function (key, val) {
if (typeof key == "object" && key.type == "fieldset") { if (typeof key == "object" && key.type == "fieldset") {
// change type to use shared template for form // change type to use shared template for form
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"angular-route": "1.3.x", "angular-route": "1.3.x",
"angular-resource": "1.3.x", "angular-resource": "1.3.x",
"angular-cookies": "1.3.x", "angular-cookies": "1.3.x",
"angular-bootstrap": "0.13.1",
"bootstrap": "3.3.4", "bootstrap": "3.3.4",
"angular-schema-form": "0.8.3", "angular-schema-form": "0.8.3",
"angular-schema-form-datepicker": "0.4.0", "angular-schema-form-datepicker": "0.4.0",
......
...@@ -118,7 +118,6 @@ ...@@ -118,7 +118,6 @@
<script src="components/dashboard/dashboard_controller.js"></script> <script src="components/dashboard/dashboard_controller.js"></script>
<script src="components/staff/staff_controller.js"></script> <script src="components/staff/staff_controller.js"></script>
<script src="components/student/student_controller.js"></script> <script src="components/student/student_controller.js"></script>
<script src="components/dashboard/dashboard.js"></script>
<!--<script src="bower_components/quantumui/dist/js/quantumui-nojq.js"></script>--> <!--<script src="bower_components/quantumui/dist/js/quantumui-nojq.js"></script>-->
<!-- @endif --> <!-- @endif -->
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
"scripts": { "scripts": {
"postinstall": "bower install", "postinstall": "bower install",
"prestart": "npm install", "prestart": "npm install",
"start": "http-server -a localhost -p 8000 -c-1", "start": "http-server app/ -a localhost -p 8000 -c-1",
"pretest": "npm install", "pretest": "npm install",
"test": "karma start karma.conf.js", "test": "karma start karma.conf.js",
"test-single-run": "karma start karma.conf.js --single-run", "test-single-run": "karma start karma.conf.js --single-run",
......
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