Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
ulakbus-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ulakbus
ulakbus-ui
Commits
23f35a14
Commit
23f35a14
authored
Sep 03, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'Feature/#143/Formsets'
parents
7fabbe24
37ab09cd
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
350 additions
and
238 deletions
+350
-238
app.js
app/app.js
+0
-65
app_routes.js
app/app_routes.js
+8
-8
crud_controller.js
app/components/crud/crud_controller.js
+9
-8
list.html
app/components/crud/templates/list.html
+27
-19
show.html
app/components/crud/templates/show.html
+5
-1
index.html
app/index.html
+43
-45
directives.js
app/shared/directives.js
+49
-30
header-notification.html
app/shared/templates/directives/header-notification.html
+1
-1
sidebar.html
app/shared/templates/directives/sidebar.html
+1
-1
foreignKey.html
app/shared/templates/foreignKey.html
+26
-0
linkedModelModalContent.html
app/shared/templates/linkedModelModalContent.html
+3
-0
form_service.js
app/zetalib/forms/form_service.js
+129
-11
interceptors.js
app/zetalib/interceptors.js
+1
-1
bower.json
bower.json
+0
-1
index.html
index.html
+48
-47
No files found.
app/app.js
View file @
23f35a14
...
...
@@ -50,74 +50,9 @@ var app = angular.module(
sessionTimeout
:
'auth-session-timeout'
,
notAuthenticated
:
'auth-not-authenticated'
,
notAuthorized
:
'auth-not-authorized'
}).
/**
* Directive to highlight current menu item
*/
// todo: not working properly, get it done!
directive
(
'activeLink'
,
[
'$location'
,
function
(
$location
)
{
return
{
restrict
:
'A'
,
link
:
function
(
$scope
,
$element
,
$attrs
)
{
var
clazz
=
$attrs
.
activeLink
;
var
path
=
$location
.
path
();
path
=
path
//hack because path does not
// return including hashbang
$scope
.
location
=
$location
;
$scope
.
$watch
(
'location.path()'
,
function
(
newPath
)
{
if
(
path
===
newPath
)
{
$element
.
addClass
(
clazz
);
}
else
{
$element
.
removeClass
(
clazz
);
}
});
}
};
}]).
/**
* logout directive
*/
directive
(
'logout'
,
function
(
$http
,
$location
)
{
return
{
link
:
function
(
$scope
,
$element
,
$rootScope
)
{
$element
.
on
(
'click'
,
function
()
{
$http
.
post
(
'http://'
+
window
.
location
.
hostname
+
':9001/logout'
,
{}).
then
(
function
()
{
$rootScope
.
loggedInUser
=
false
;
console
.
log
(
$rootScope
.
loggedInUser
);
$location
.
path
(
"/login"
);
$scope
.
$apply
();
});
});
}
}
});
// buildbot mailnotifier change on master mail test comment (will be deleted)
/**
* 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
//angular.bootstrap(document, ['ulakbus'], {
...
...
app/app_routes.js
View file @
23f35a14
...
...
@@ -52,14 +52,14 @@ app.config(['$routeProvider', function ($routeProvider) {
$rootScope
.
loggedInUser
?
$rootScope
.
loggedInUser
:
false
;
$rootScope
.
$on
(
"$routeChangeStart"
,
function
(
event
,
next
,
current
)
{
if
(
$rootScope
.
loggedInUser
==
null
)
{
// no logged user, redirect to /login
if
(
next
.
templateUrl
===
"login/login.html"
)
{
}
else
{
$location
.
path
(
"/login"
);
}
}
//
if ($rootScope.loggedInUser == null) {
//
// no logged user, redirect to /login
//
if (next.templateUrl === "login/login.html") {
//
//
} else {
//
$location.path("/login");
//
}
//
}
});
}).
config
([
'$httpProvider'
,
function
(
$httpProvider
)
{
// to send cookies CORS
...
...
app/components/crud/crud_controller.js
View file @
23f35a14
...
...
@@ -16,7 +16,7 @@ var crud = angular.module('ulakbus.crud', ['ngRoute', 'schemaForm', 'formService
* which provide a form with form generator.
*/
crud
.
controller
(
'CRUDAddEditCtrl'
,
function
(
$scope
,
$rootScope
,
$location
,
$http
,
$log
,
$modal
,
Generator
,
$routeParams
)
{
crud
.
controller
(
'CRUDAddEditCtrl'
,
function
(
$scope
,
$rootScope
,
$location
,
$http
,
$log
,
$modal
,
$timeout
,
Generator
,
$routeParams
)
{
$scope
.
url
=
'crud'
;
$scope
.
form_params
=
{
'model'
:
$routeParams
.
model
};
if
(
$routeParams
.
id
)
{
...
...
@@ -26,12 +26,16 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
else
{
$scope
.
form_params
[
'cmd'
]
=
'add'
;
}
// to start in certain part of the workflow use clear_wf=1
//$scope.form_params['clear_wf'] = 1;
// get form with generator
Generator
.
get_form
(
$scope
);
$scope
.
loaddata
=
function
()
{
console
.
log
(
'loading data'
);
Generator
.
get_form
(
$scope
);
};
// todo remove timeout to load controller efficiently
//$timeout($scope.loaddata, 1000);
$scope
.
loaddata
();
$scope
.
onSubmit
=
function
(
form
)
{
$scope
.
$broadcast
(
'schemaFormValidate'
);
if
(
form
.
$valid
)
{
...
...
@@ -46,9 +50,6 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
};
});
// todo: for single point of failure code a "get item" service and use it to
// retrieve list and single item
/**
* CRUD List Controller
*/
...
...
@@ -59,7 +60,6 @@ crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeP
// call generator's get_list func
Generator
.
get_list
(
$scope
)
.
then
(
function
(
res
)
{
debugger
;
var
data
=
res
.
data
.
objects
;
for
(
var
item
in
data
){
delete
data
[
item
].
data
[
'deleted'
];
...
...
@@ -79,5 +79,6 @@ crud.controller('CRUDShowCtrl', function ($scope, $rootScope, Generator, $routeP
// call generator's get_single_itemfunc
Generator
.
get_single_item
(
$scope
).
then
(
function
(
res
)
{
$scope
.
object
=
res
.
data
.
object
;
$scope
.
model
=
$routeParams
.
model
;
})
});
\ No newline at end of file
app/components/crud/templates/list.html
View file @
23f35a14
<table
class=
"table table-bordered table-responsive"
>
<thead>
<tr>
<!--<th>{{ objects[0].key }}</th>-->
<th
ng-repeat=
"(key,value) in objects[0].data"
>
{{ key }}
</th>
<th>
action
</th>
</tr>
</thead>
<tbody>
<tr
ng-repeat=
"object in objects"
>
<!--<td><a ng-href="#/object/{{object.id}}">{{object.name}}</a></td>-->
<td
ng-repeat=
"(key,value) in object.data"
>
{{value}}
</td>
<td>
<a
ng-href=
"#/crud/{{model}}/edit/{{object.key}}"
>
Edit
</a><br>
<a
ng-href=
"#/crud/{{model}}/{{object.key}}"
>
Show
</a>
</td>
</tr>
</tbody>
</table>
\ No newline at end of file
<div
class=
"starter-template"
>
<h1>
{{model}}
</h1>
<table
class=
"table table-bordered"
style=
"background-color:#fff;"
>
<thead>
<tr>
<th
colspan=
"2"
>
#
</th>
<th
ng-repeat=
"(key,value) in objects[0].data"
>
{{ key }}
</th>
<th>
action
</th>
</tr>
</thead>
<tbody>
<tr
ng-repeat=
"object in objects"
>
<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"
>
1
</th>
<td
ng-repeat=
"(key,value) in object.data"
>
{{value}}
</td>
<td>
<a
ng-href=
"#/crud/{{model}}/edit/{{object.key}}"
>
Edit
</a><br>
<a
ng-href=
"#/crud/{{model}}/{{object.key}}"
>
Show
</a>
</td>
</tr>
</tbody>
</table>
</div>
\ No newline at end of file
app/components/crud/templates/show.html
View file @
23f35a14
<p
ng-repeat=
"(key, value) in object"
><span
class=
"col-md-3"
>
{{ key }}:
</span>
{{value}}
</p>
\ No newline at end of file
<div
class=
"starter-template"
>
<h1>
{{model}}
</h1>
<p
ng-repeat=
"(key, value) in object"
><span
class=
"col-md-3"
>
{{ key }}:
</span>
{{value}}
</p>
</div>
\ No newline at end of file
app/index.html
View file @
23f35a14
...
...
@@ -28,23 +28,23 @@
<nav
class=
"navbar navbar-default navbar-static-top"
role=
"navigation"
style=
"margin-bottom: 0"
>
<div
class=
"navbar-header"
>
<button
type=
"button"
class=
"navbar-toggle"
data-toggle=
"collapse"
data-target=
".navbar-collapse"
>
<span
class=
"sr-only"
>
Toggle navigation
</span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
</button>
<a
class=
"navbar-brand"
href=
"index.html"
><img
src=
"img/ulakbus-logo.png"
/></a>
<a
class=
"navbar-brand"
href=
"index.html"
><img
src=
"img/ulakbus-logo.png"
/></a>
</div>
<!-- /.navbar-header -->
<header-notification></header-notification>
<sidebar></sidebar>
</nav>
<div
id=
"page-wrapper"
>
<div
class=
"col-md-12"
>
<div
class=
"col-md-12"
>
<div
class=
"row"
>
<div
class=
"main"
ng-view
>
</div>
...
...
@@ -53,54 +53,52 @@
</div>
</div>
<script
src=
"bower_components/angular/angular.min.js"
></script>
<script
src=
"bower_components/jquery/dist/jquery.min.js"
></script>
<script
src=
"bower_components/angular/angular.min.js"
></script>
<script
src=
"bower_components/jquery/dist/jquery.min.js"
></script>
<script
src=
"bower_components/bootstrap/dist/js/bootstrap.min.js"
></script>
<script
src=
"bower_components/jquery/dist/jquery.min.js"
></script>
<script
src=
"bower_components/angular-route/angular-route.min.js"
></script>
<script
src=
"bower_components/angular-cookies/angular-cookies.min.js"
></script>
<script
src=
"bower_components/angular-resource/angular-resource.min.js"
></script>
<script
src=
"bower_components/angular-bootstrap/ui-bootstrap.min.js"
></script>
<script
src=
"bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"
></script>
<script
src=
"bower_components/angular-route/angular-route.min.js"
></script>
<script
src=
"bower_components/angular-cookies/angular-cookies.min.js"
></script>
<script
src=
"bower_components/angular-resource/angular-resource.min.js"
></script>
<script
src=
"bower_components/angular-bootstrap/ui-bootstrap.min.js"
></script>
<script
src=
"bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"
></script>
<script
src=
"bower_components/angular-sanitize/angular-sanitize.min.js"
></script>
<script
src=
"bower_components/tv4/tv4.js"
></script>
<script
src=
"bower_components/objectpath/lib/ObjectPath.js"
></script>
<script
src=
"bower_components/angular-schema-form/dist/schema-form.min.js"
></script>
<script
src=
"bower_components/angular-schema-form/dist/bootstrap-decorator.min.js"
></script>
<script
src=
"bower_components/angular-schema-form-datepicker/bootstrap-datepicker.min.js"
></script>
<script
src=
"bower_components/angular-gettext/dist/angular-gettext.min.js"
></script>
<script
src=
"bower_components/angular-sanitize/angular-sanitize.min.js"
></script>
<script
src=
"bower_components/tv4/tv4.js"
></script>
<script
src=
"bower_components/objectpath/lib/ObjectPath.js"
></script>
<script
src=
"bower_components/objectpath/lib/ObjectPath.js"
></script>
<script
src=
"bower_components/angular-schema-form/dist/schema-form.min.js"
></script>
<script
src=
"bower_components/angular-schema-form/dist/bootstrap-decorator.min.js"
></script>
<!--<script src="bower_components/angular-schema-form-datepicker/bootstrap-datepicker.min.js"></script>-->
<script
src=
"bower_components/angular-gettext/dist/angular-gettext.min.js"
></script>
<!-- TODO: check all js and remove unused -->
<script
src=
"bower_components/json3/lib/json3.min.js"
></script>
<script
src=
"bower_components/angular-loading-bar/build/loading-bar.min.js"
></script>
<script
src=
"bower_components/metisMenu/dist/metisMenu.min.js"
></script>
<script
src=
"bower_components/Chart.js/Chart.min.js"
></script>
<!-- TODO: check all js and remove unused -->
<script
src=
"bower_components/json3/lib/json3.min.js"
></script>
<script
src=
"bower_components/angular-loading-bar/build/loading-bar.min.js"
></script>
<script
src=
"bower_components/metisMenu/dist/metisMenu.min.js"
></script>
<script
src=
"bower_components/Chart.js/Chart.min.js"
></script>
<script
src=
"shared/translations.js"
></script>
<script
src=
"tmp/templates.js"
></script>
<script
src=
"shared/translations.js"
></script>
<script
src=
"tmp/templates.js"
></script>
<script
src=
"app.js"
></script>
<script
src=
"app_routes.js"
></script>
<script
src=
"shared/scripts/theme.js"
></script>
<script
src=
"shared/directives.js"
></script>
<script
src=
"zetalib/interceptors.js"
></script>
<script
src=
"zetalib/general.js"
></script>
<script
src=
"zetalib/forms/form_service.js"
></script>
<script
src=
"app.js"
></script>
<script
src=
"app_routes.js"
></script>
<script
src=
"shared/scripts/theme.js"
></script>
<script
src=
"shared/directives.js"
></script>
<script
src=
"zetalib/interceptors.js"
></script>
<script
src=
"zetalib/general.js"
></script>
<script
src=
"zetalib/forms/form_service.js"
></script>
<!-- components -->
<!-- components -->
<script
src=
"components/auth/auth_controller.js"
></script>
<script
src=
"components/auth/auth_service.js"
></script>
<script
src=
"components/dashboard/dashboard_controller.js"
></script>
<script
src=
"components/crud/crud_controller.js"
></script>
<script
src=
"components/staff/staff_controller.js"
></script>
<script
src=
"components/student/student_controller.js"
></script>
<script
src=
"components/version/version.js"
></script>
<!--<script src="bower_components/quantumui/dist/js/quantumui-nojq.js"></script>-->
<script
src=
"components/auth/auth_controller.js"
></script>
<script
src=
"components/auth/auth_service.js"
></script>
<script
src=
"components/dashboard/dashboard_controller.js"
></script>
<script
src=
"components/crud/crud_controller.js"
></script>
<script
src=
"components/staff/staff_controller.js"
></script>
<script
src=
"components/student/student_controller.js"
></script>
<script
src=
"components/version/version.js"
></script>
<!--<script src="bower_components/quantumui/dist/js/quantumui-nojq.js"></script>-->
</body>
</html>
app/shared/directives.js
View file @
23f35a14
...
...
@@ -5,23 +5,43 @@
* (GPLv3). See LICENSE.txt for details.
*/
app
.
directive
(
'headerNotification'
,
function
(){
/**
* logout directive
*/
app
.
directive
(
'logout'
,
function
(
$http
,
$location
)
{
return
{
link
:
function
(
$scope
,
$element
,
$rootScope
)
{
$element
.
on
(
'click'
,
function
()
{
$http
.
post
(
'http://'
+
window
.
location
.
hostname
+
':9001/logout'
,
{}).
then
(
function
()
{
$rootScope
.
loggedInUser
=
false
;
console
.
log
(
$rootScope
.
loggedInUser
);
$location
.
path
(
"/login"
);
$scope
.
$apply
();
});
});
}
}
});
/**
* headerNotification directive for header
*/
app
.
directive
(
'headerNotification'
,
function
()
{
return
{
templateUrl
:
'shared/templates/directives/header-notification.html'
,
templateUrl
:
'shared/templates/directives/header-notification.html'
,
restrict
:
'E'
,
replace
:
true
,
}
});
app
.
directive
(
'sidebar'
,
[
'$location'
,
function
()
{
app
.
directive
(
'sidebar'
,
[
'$location'
,
function
()
{
return
{
templateUrl
:
'shared/templates/directives/sidebar.html'
,
templateUrl
:
'shared/templates/directives/sidebar.html'
,
restrict
:
'E'
,
replace
:
true
,
scope
:
{
},
controller
:
function
(
$scope
,
$http
,
RESTURL
){
$http
.
post
(
RESTURL
.
url
+
'crud/'
).
success
(
function
(
data
){
scope
:
{},
controller
:
function
(
$scope
,
$http
,
RESTURL
)
{
$http
.
post
(
RESTURL
.
url
+
'crud/'
).
success
(
function
(
data
)
{
//debugger;
$scope
.
menuItems
=
data
.
models
;
});
...
...
@@ -32,17 +52,17 @@ app.directive('sidebar',['$location',function() {
$scope
.
collapseVar
=
0
;
$scope
.
multiCollapseVar
=
0
;
$scope
.
check
=
function
(
x
)
{
$scope
.
check
=
function
(
x
)
{
if
(
x
==
$scope
.
collapseVar
)
if
(
x
==
$scope
.
collapseVar
)
$scope
.
collapseVar
=
0
;
else
$scope
.
collapseVar
=
x
;
};
$scope
.
multiCheck
=
function
(
y
)
{
$scope
.
multiCheck
=
function
(
y
)
{
if
(
y
==
$scope
.
multiCollapseVar
)
if
(
y
==
$scope
.
multiCollapseVar
)
$scope
.
multiCollapseVar
=
0
;
else
$scope
.
multiCollapseVar
=
y
;
...
...
@@ -51,57 +71,56 @@ app.directive('sidebar',['$location',function() {
}
}]);
app
.
directive
(
'stats'
,
function
()
{
app
.
directive
(
'stats'
,
function
()
{
return
{
templateUrl
:
'shared/templates/directives/stats.html'
,
restrict
:
'E'
,
replace
:
true
,
templateUrl
:
'shared/templates/directives/stats.html'
,
restrict
:
'E'
,
replace
:
true
,
scope
:
{
'model'
:
'='
,
'comments'
:
'@'
,
'number'
:
'@'
,
'name'
:
'@'
,
'colour'
:
'@'
,
'details'
:
'@'
,
'type'
:
'@'
,
'goto'
:
'@'
'details'
:
'@'
,
'type'
:
'@'
,
'goto'
:
'@'
}
}
});
app
.
directive
(
'notifications'
,
function
()
{
app
.
directive
(
'notifications'
,
function
()
{
return
{
templateUrl
:
'shared/templates/directives/notifications.html'
,
templateUrl
:
'shared/templates/directives/notifications.html'
,
restrict
:
'E'
,
replace
:
true
,
}
});
app
.
directive
(
'sidebarSearch'
,
function
()
{
app
.
directive
(
'sidebarSearch'
,
function
()
{
return
{
templateUrl
:
'shared/templates/directives/sidebar-search.html'
,
templateUrl
:
'shared/templates/directives/sidebar-search.html'
,
restrict
:
'E'
,
replace
:
true
,
scope
:
{
},
controller
:
function
(
$scope
){
scope
:
{},
controller
:
function
(
$scope
)
{
$scope
.
selectedMenu
=
'home'
;
}
}
});
app
.
directive
(
'timeline'
,
function
()
{
app
.
directive
(
'timeline'
,
function
()
{
return
{
templateUrl
:
'shared/templates/directives/timeline.html'
,
templateUrl
:
'shared/templates/directives/timeline.html'
,
restrict
:
'E'
,
replace
:
true
,
}
});
app
.
directive
(
'chat'
,
function
()
{
app
.
directive
(
'chat'
,
function
()
{
return
{
templateUrl
:
'shared/templates/directives/chat.html'
,
templateUrl
:
'shared/templates/directives/chat.html'
,
restrict
:
'E'
,
replace
:
true
,
}
...
...
app/shared/templates/directives/header-notification.html
View file @
23f35a14
...
...
@@ -200,7 +200,7 @@
</li>
<li><a
href=
"http://www.strapui.com/"
><i
class=
"fa fa-eye fa-fw"
></i>
Premium Angular Themes
</a></li>
<li
class=
"divider"
></li>
<li><a
ui-sref=
"login"
><i
class=
"fa fa-sign-out fa-fw"
></i>
Logout
</a>
<li><a
ui-sref=
"login"
href=
"javascript:void(0);"
logout
><i
class=
"fa fa-sign-out fa-fw"
></i>
Logout
</a>
</li>
</ul>
<!-- /.dropdown-user -->
...
...
app/shared/templates/directives/sidebar.html
View file @
23f35a14
...
...
@@ -3,7 +3,7 @@
<ul
class=
"nav in"
id=
"side-menu"
>
<sidebar-search></sidebar-search>
<li
ui-sref-active=
"active"
>
<a
ui-sref=
"dashboard.home
"
><i
class=
"fa fa-dashboard fa-fw"
></i>
Dashboard
</a>
<a
href=
"#/dashboard
"
><i
class=
"fa fa-dashboard fa-fw"
></i>
Dashboard
</a>
</li>
<!--<li ui-sref-active="active"><a href="#/staffs" translate>Staffs</a></li>-->
<!--<li ui-sref-active="active"><a href="#/staff/add" translate>New Staff</a></li>-->
...
...
app/shared/templates/foreignKey.html
0 → 100644
View file @
23f35a14
<div
class=
"form-group {{form.htmlClass}} schema-form-select col-md-12"
ng-class=
"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess(), 'has-feedback': form.feedback !== false}"
>
<div
class=
"col-md-8"
>
<label
class=
"control-label {{form.labelHtmlClass}}"
ng-show=
"showTitle()"
>
{{form.title}}
</label>
<select
ng-model=
"$$value$$"
ng-model-options=
"form.ngModelOptions"
ng-disabled=
"form.readonly"
sf-changed=
"form"
class=
"form-control {{form.fieldHtmlClass}}"
schema-validate=
"form"
ng-options=
"item.value as item.name group by item.group for item in form.titleMap"
name=
"{{form.key.slice(-1)[0]}}"
>
</select>
<div
class=
"help-block"
sf-message=
"form.description"
></div>
</div>
<div
class=
"col-md-4"
>
<a
href=
"javascript:void(0);"
add-modal
>
<i
class=
"fa fa-plus-circle fa-fw"
></i>
</a>
</div>
</div>
\ No newline at end of file
app/shared/templates/linkedModelModalContent.html
0 → 100644
View file @
23f35a14
<div
class=
"modal-body"
>
<form
name=
"linkedModelForm"
sf-schema=
"schema"
sf-form=
"form"
sf-model=
"model"
ng-submit=
"onSubmit(linkedModelForm)"
></form>
</div>
\ No newline at end of file
app/zetalib/forms/form_service.js
View file @
23f35a14
...
...
@@ -25,11 +25,59 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
);
// if fieldset in form, make it collapsable with template
scope
.
listnodeform
=
{};
angular
.
forEach
(
scope
.
schema
.
properties
,
function
(
k
,
v
){
// check if type date and if type date found change it to string
// check if type
is
date and if type date found change it to string
// and give it 'format':'date' property
if
(
k
.
type
==
'date'
)
{
k
.
type
=
'string'
;
k
.
format
=
'date'
}
// todo: make datepicker work below
if
(
k
.
type
==
'date'
)
{
k
.
type
=
"template"
;
k
.
templateUrl
=
"shared/templates/datefield.html"
;
//scope.form[scope.form.indexOf(v)] = {
// "key": k.name,
// "minDate": "1995-09-01",
// "maxDate": new Date(),
// "format": "yyyy-mm-dd"
//}
scope
.
model
[
v
]
=
null
;
}
debugger
;
if
(
k
.
type
==
'int'
)
{
k
.
type
=
'number'
}
// if type is model use foreignKey.html template to show them
if
(
k
.
type
==
'model'
)
{
var
formitem
=
scope
.
form
[
scope
.
form
.
indexOf
(
v
)];
formitem
=
{
"type"
:
"template"
,
"templateUrl"
:
"shared/templates/foreignKey.html"
,
"title"
:
k
.
model_name
,
};
k
.
title
=
k
.
model_name
;
var
modelscope
=
{
"url"
:
scope
.
url
,
"form_params"
:
{
model
:
k
.
model_name
}};
// get model objects from db and add to select list
generator
.
get_list
(
modelscope
).
then
(
function
(
res
){
formitem
.
titleMap
=
[];
angular
.
forEach
(
res
.
data
.
objects
,
function
(
item
){
formitem
.
titleMap
.
push
({
"value"
:
item
.
key
,
"name"
:
item
.
data
.
name
?
item
.
data
.
name
:
item
.
data
.
username
});
});
});
scope
.
form
[
scope
.
form
.
indexOf
(
v
)]
=
formitem
;
}
});
// catch node and listnode and edit their schema and form props
if
((
scope
.
listnode
&&
scope
.
listnodes
[
0
])
||
(
scope
.
nodes
&&
scope
.
nodes
[
0
]))
{
angular
.
forEach
(
scope
.
form
,
function
(
key
,
val
)
{
if
(
typeof
key
==
"object"
&&
key
.
type
==
"fieldset"
)
{
...
...
@@ -99,6 +147,14 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
generator
.
group
=
function
(
formObject
)
{
return
formObject
;
};
generator
.
dateformatter
=
function
(
formObject
){
//angular.forEach(formObject.objects, function(k, v) {
// check if date string and convert to date object
// todo: catch date object and convert
//debugger;
//});
return
formObject
;
};
generator
.
get_form
=
function
(
scope
)
{
return
$http
.
post
(
generator
.
makeUrl
(
scope
.
url
),
scope
.
form_params
)
...
...
@@ -111,6 +167,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
return
$http
.
post
(
generator
.
makeUrl
(
scope
.
url
),
scope
.
form_params
)
.
then
(
function
(
res
)
{
generator
.
dateformatter
(
res
);
return
res
;
// todo: cover all other exceptions (4xx, 5xx)
});
...
...
@@ -119,6 +176,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
return
$http
.
post
(
generator
.
makeUrl
(
scope
.
url
),
scope
.
form_params
)
.
then
(
function
(
res
)
{
generator
.
dateformatter
(
res
);
return
res
;
// todo: cover all other exceptions (4xx, 5xx)
});
...
...
@@ -141,7 +199,14 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
}
};
generator
.
submit
=
function
(
$scope
)
{
data
=
{
"form"
:
$scope
.
model
,
"cmd"
:
$scope
.
form_params
.
cmd
,
"subcmd"
:
"do_list"
,
"model"
:
$scope
.
form_params
.
model
};
debugger
;
data
=
{
"form"
:
$scope
.
model
,
"cmd"
:
$scope
.
form_params
.
cmd
,
"subcmd"
:
"do_list"
,
"model"
:
$scope
.
form_params
.
model
,
"token"
:
$scope
.
token
};
if
(
$scope
.
object_id
)
{
var
get_diff
=
FormDiff
.
get_diff
(
$scope
.
model
,
$scope
.
initialModel
);
var
data
=
{
...
...
@@ -149,13 +214,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
"form"
:
get_diff
};
}
return
$http
.
post
(
generator
.
makeUrl
(
$scope
.
url
),
data
);
//.then(function (res) {
// // todo: for now fake rest api returns 'ok' no data to
// // manipulate on ui. therefor used just a log
// $log.info(res);
//});
return
$http
.
post
(
generator
.
makeUrl
(
$scope
.
url
),
data
);
};
return
generator
;
});
...
...
@@ -179,6 +238,21 @@ form_generator.controller('ListNodeModalCtrl', function ($scope, $modalInstance,
};
});
form_generator
.
controller
(
'LinkedModelModalCtrl'
,
function
(
$scope
,
$modalInstance
,
$route
,
items
)
{
angular
.
forEach
([
"model"
,
"schema"
,
"form"
],
function
(
key
){
$scope
[
key
]
=
items
[
key
];
});
$scope
.
onSubmit
=
function
(){
// send form to modalinstance result function
$modalInstance
.
close
(
$scope
);
$route
.
reload
();
};
$scope
.
cancel
=
function
()
{
$modalInstance
.
dismiss
(
'cancel'
);
$route
.
reload
();
};
});
// todo: generic modal directive for all forms
//form_generator.directive('openmodal', ['Generator', function (Generator, $modal) {
// return {
...
...
@@ -202,4 +276,48 @@ form_generator.controller('ListNodeModalCtrl', function ($scope, $modalInstance,
// });
// }
// }
//}]);
\ No newline at end of file
//}]);
/**
* modal directive for linked models
*/
form_generator
.
directive
(
'addModal'
,
function
(
$modal
,
Generator
)
{
return
{
link
:
function
(
scope
,
element
)
{
element
.
on
(
'click'
,
function
()
{
debugger
;
var
modalInstance
=
$modal
.
open
({
animation
:
false
,
templateUrl
:
'shared/templates/linkedModelModalContent.html'
,
controller
:
'LinkedModelModalCtrl'
,
size
:
'lg'
,
resolve
:
{
items
:
function
()
{
debugger
;
scope
.
url
=
'crud'
;
scope
.
form_params
=
{
'model'
:
scope
.
form
.
title
,
"cmd"
:
"add"
};
return
Generator
.
get_form
(
scope
);
}
}
});
modalInstance
.
result
.
then
(
function
(
childmodel
,
key
)
{
Generator
.
submit
(
scope
);
//angular.forEach(childmodel, function(v, k){
// if ($scope.model[k]){
// $scope.model[k][v.idx] = v;
// } else {
// $scope.model[k] = {};
// $scope.model[k][v.idx] = v;
// }
//scope.$broadcast('schemaFormRedraw');
//scope.apply();
//});
});
//$scope.$broadcast('schemaFormRedraw');
//$scope.$apply();
});
}
}
});
\ No newline at end of file
app/zetalib/interceptors.js
View file @
23f35a14
...
...
@@ -26,7 +26,7 @@ app.config(['$httpProvider', function ($httpProvider) {
//Will only be called for HTTP up to 300
if
(
response
.
data
.
is_login
===
true
){
$rootScope
.
loggedInUser
=
response
.
data
.
is_login
;
$location
.
replace
();
//
$location.replace();
if
(
$location
.
path
()
===
"/login"
){
$location
.
path
(
"/dashboard"
);
}
...
...
bower.json
View file @
23f35a14
...
...
@@ -16,7 +16,6 @@
"angular-bootstrap"
:
"0.13.1"
,
"font-awesome"
:
"4.3.0"
,
"angular-schema-form"
:
"0.8.3"
,
"angular-schema-form-datepicker"
:
"0.4.0"
,
"angular-loading-bar"
:
"~0.7.0"
,
"angular-ui-router"
:
"~0.2.15"
,
"angular-toggle-switch"
:
"~1.2.1"
,
...
...
index.html
View file @
23f35a14
...
...
@@ -40,7 +40,7 @@
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
</button>
<a
class=
"navbar-brand"
href=
"index.html"
><img
src=
"
app/
img/ulakbus-logo.png"
/></a>
<a
class=
"navbar-brand"
href=
"index.html"
><img
src=
"img/ulakbus-logo.png"
/></a>
</div>
<!-- /.navbar-header -->
<header-notification></header-notification>
...
...
@@ -58,61 +58,62 @@
</div>
</div>
<!-- @if NODE_ENV == 'DEVELOPMENT' -->
<script
src=
"bower_components/angular/angular.min.js"
></script>
<script
src=
"bower_components/jquery/dist/jquery.min.js"
></script>
<!-- @if NODE_ENV == 'DEVELOPMENT' -->
<script
src=
"bower_components/angular/angular.min.js"
></script>
<script
src=
"bower_components/jquery/dist/jquery.min.js"
></script>
<script
src=
"bower_components/angular-route/angular-route.min.js"
></script>
<script
src=
"bower_components/angular-cookies/angular-cookies.min.js"
></script>
<script
src=
"bower_components/angular-resource/angular-resource.min.js"
></script>
<script
src=
"bower_components/angular-bootstrap/ui-bootstrap.min.js"
></script>
<script
src=
"bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"
></script>
<script
src=
"bower_components/angular-route/angular-route.min.js"
></script>
<script
src=
"bower_components/angular-cookies/angular-cookies.min.js"
></script>
<script
src=
"bower_components/angular-resource/angular-resource.min.js"
></script>
<script
src=
"bower_components/angular-bootstrap/ui-bootstrap.min.js"
></script>
<script
src=
"bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"
></script>
<script
src=
"bower_components/angular-sanitize/angular-sanitize.min.js"
></script>
<script
src=
"bower_components/tv4/tv4.js"
></script>
<script
src=
"bower_components/objectpath/lib/ObjectPath.js"
></script>
<script
src=
"bower_components/angular-schema-form/dist/schema-form.min.js"
></script>
<script
src=
"bower_components/angular-schema-form/dist/bootstrap-decorator.min.js"
></script>
<script
src=
"bower_components/angular-schema-form-datepicker/bootstrap-datepicker.min.js"
></script>
<script
src=
"bower_components/angular-gettext/dist/angular-gettext.min.js"
></script>
<script
src=
"bower_components/angular-sanitize/angular-sanitize.min.js"
></script>
<script
src=
"bower_components/tv4/tv4.js"
></script>
<script
src=
"bower_components/objectpath/lib/ObjectPath.js"
></script>
<script
src=
"bower_components/objectpath/lib/ObjectPath.js"
></script>
<script
src=
"bower_components/angular-schema-form/dist/schema-form.min.js"
></script>
<script
src=
"bower_components/angular-schema-form/dist/bootstrap-decorator.min.js"
></script>
<!--<script src="bower_components/angular-schema-form-datepicker/bootstrap-datepicker.min.js"></script>-->
<script
src=
"bower_components/angular-gettext/dist/angular-gettext.min.js"
></script>
<!-- TODO: check all js and remove unused -->
<script
src=
"bower_components/json3/lib/json3.min.js"
></script>
<script
src=
"bower_components/angular-loading-bar/build/loading-bar.min.js"
></script>
<script
src=
"bower_components/metisMenu/dist/metisMenu.min.js"
></script>
<script
src=
"bower_components/Chart.js/Chart.min.js"
></script>
<!-- TODO: check all js and remove unused -->
<script
src=
"bower_components/json3/lib/json3.min.js"
></script>
<script
src=
"bower_components/angular-loading-bar/build/loading-bar.min.js"
></script>
<script
src=
"bower_components/metisMenu/dist/metisMenu.min.js"
></script>
<script
src=
"bower_components/Chart.js/Chart.min.js"
></script>
<script
src=
"shared/translations.js"
></script>
<script
src=
"tmp/templates.js"
></script>
<script
src=
"shared/translations.js"
></script>
<script
src=
"tmp/templates.js"
></script>
<script
src=
"app.js"
></script>
<script
src=
"app_routes.js"
></script>
<script
src=
"shared/scripts/theme.js"
></script>
<script
src=
"shared/directives.js"
></script>
<script
src=
"zetalib/interceptors.js"
></script>
<script
src=
"zetalib/general.js"
></script>
<script
src=
"zetalib/forms/form_service.js"
></script>
<script
src=
"app.js"
></script>
<script
src=
"app_routes.js"
></script>
<script
src=
"shared/scripts/theme.js"
></script>
<script
src=
"shared/directives.js"
></script>
<script
src=
"zetalib/interceptors.js"
></script>
<script
src=
"zetalib/general.js"
></script>
<script
src=
"zetalib/forms/form_service.js"
></script>
<!-- components -->
<!-- components -->
<script
src=
"components/auth/auth_controller.js"
></script>
<script
src=
"components/auth/auth_service.js"
></script>
<script
src=
"components/dashboard/dashboard_controller.js"
></script>
<script
src=
"components/crud/crud_controller.js"
></script>
<script
src=
"components/staff/staff_controller.js"
></script>
<script
src=
"components/student/student_controller.js"
></script>
<script
src=
"components/version/version.js"
></script>
<!--<script src="bower_components/quantumui/dist/js/quantumui-nojq.js"></script>-->
<!-- @endif -->
<script
src=
"components/auth/auth_controller.js"
></script>
<script
src=
"components/auth/auth_service.js"
></script>
<script
src=
"components/dashboard/dashboard_controller.js"
></script>
<script
src=
"components/crud/crud_controller.js"
></script>
<script
src=
"components/staff/staff_controller.js"
></script>
<script
src=
"components/student/student_controller.js"
></script>
<script
src=
"components/version/version.js"
></script>
<!--<script src="bower_components/quantumui/dist/js/quantumui-nojq.js"></script>-->
<!-- @endif -->
<!-- @if NODE_ENV == 'PRODUCTION' -->
<script
src=
"bower_components/jquery.min.js"
></script>
<script
src=
"http://ajax.googleapis.com/ajax/libs/angularjs/1.3.17/angular.min.js"
></script>
<script
src=
"bower_components/components.js"
></script>
<script
src=
"shared/translations.js"
></script>
<script
src=
"templates.js"
></script>
<script
src=
"app.js"
></script>
<!-- @if NODE_ENV == 'PRODUCTION' -->
<script
src=
"bower_components/jquery.min.js"
></script>
<script
src=
"http://ajax.googleapis.com/ajax/libs/angularjs/1.3.17/angular.min.js"
></script>
<script
src=
"bower_components/components.js"
></script>
<script
src=
"shared/translations.js"
></script>
<script
src=
"templates.js"
></script>
<script
src=
"app.js"
></script>
<!-- @endif -->
</body>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment