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
7eede52e
Commit
7eede52e
authored
Aug 17, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make listnodemodal generic
parent
acb89377
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
174 additions
and
25 deletions
+174
-25
app.js
app/app.js
+26
-5
staff_controller.js
app/components/staff/staff_controller.js
+2
-2
index.html
app/index.html
+6
-6
add.html
app/shared/templates/add.html
+3
-3
fieldset.html
app/shared/templates/fieldset.html
+9
-0
listnodeModalContent.html
app/shared/templates/listnodeModalContent.html
+7
-0
modalContent.html
app/shared/templates/modalContent.html
+0
-0
form_service.js
app/zetalib/forms/form_service.js
+121
-9
No files found.
app/app.js
View file @
7eede52e
...
@@ -27,7 +27,7 @@ var app = angular.module(
...
@@ -27,7 +27,7 @@ var app = angular.module(
* 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
...
...
app/components/staff/staff_controller.js
View file @
7eede52e
...
@@ -16,7 +16,7 @@ var staff = angular.module('ulakbus.staff', ['ngRoute', 'schemaForm', 'formServi
...
@@ -16,7 +16,7 @@ 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'
;
$scope
.
form_params
=
{};
$scope
.
form_params
=
{};
if
(
$routeParams
.
id
)
{
if
(
$routeParams
.
id
)
{
...
@@ -43,7 +43,7 @@ staff.controller('StaffAddEditCtrl', function ($scope, $rootScope, $location, $h
...
@@ -43,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
...
...
app/index.html
View file @
7eede52e
...
@@ -87,14 +87,14 @@
...
@@ -87,14 +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"
src=
"bower_components/angular-sanitize/angular-sanitize.js"
></script>
<script
src=
"bower_components/angular-sanitize/angular-sanitize.js"
></script>
<script
type=
"text/javascript"
src=
"bower_components/tv4/tv4.js"
></script>
<script
src=
"bower_components/tv4/tv4.js"
></script>
<script
type=
"text/javascript"
src=
"bower_components/objectpath/lib/ObjectPath.js"
></script>
<script
src=
"bower_components/objectpath/lib/ObjectPath.js"
></script>
<script
type=
"text/javascript"
src=
"bower_components/angular-schema-form/dist/schema-form.js"
></script>
<script
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
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>
...
...
app/shared/templates/add.html
View file @
7eede52e
<div
class=
"col-md-
6
"
>
<div
class=
"col-md-
12
"
>
<h1>
{{ schema.title }}
</h1>
<h1>
{{ schema.title }}
</h1>
<
form
name=
"formgenerated"
sf-schema=
"schema"
sf-form=
"form"
<
button
type=
"button"
ng-repeat=
"node in listnodes"
ng-click=
"openmodal(node)"
>
Add
<span>
{{node}}
</span></button>
sf-model=
"model"
ng-submit=
"onSubmit(formgenerated)"
></form>
<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
app/shared/templates/fieldset.html
0 → 100644
View file @
7eede52e
<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>
app/shared/templates/listnodeModalContent.html
0 → 100644
View file @
7eede52e
<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
app/shared/templates/modalContent.html
0 → 100644
View file @
7eede52e
app/zetalib/forms/form_service.js
View file @
7eede52e
...
@@ -5,9 +5,9 @@
...
@@ -5,9 +5,9 @@
* (GPLv3). See LICENSE.txt for details.
* (GPLv3). See LICENSE.txt for details.
*/
*/
var
form_generator
=
angular
.
module
(
'formService'
,
[
'general'
]);
var
form_generator
=
angular
.
module
(
'formService'
,
[
'general'
,
'ui.bootstrap'
]);
form_generator
.
factory
(
'Generator'
,
function
(
$http
,
$q
,
$log
,
$timeout
,
RESTURL
,
FormDiff
)
{
form_generator
.
factory
(
'Generator'
,
function
(
$http
,
$q
,
$log
,
$
modal
,
$
timeout
,
RESTURL
,
FormDiff
)
{
var
generator
=
{};
var
generator
=
{};
generator
.
makeUrl
=
function
(
url
)
{
generator
.
makeUrl
=
function
(
url
)
{
return
RESTURL
.
url
+
url
;
return
RESTURL
.
url
+
url
;
...
@@ -16,14 +16,82 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
...
@@ -16,14 +16,82 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
for
(
var
key
in
forms
)
for
(
var
key
in
forms
)
scope
[
key
]
=
forms
[
key
];
scope
[
key
]
=
forms
[
key
];
scope
.
initialModel
=
angular
.
copy
(
scope
.
model
);
scope
.
initialModel
=
angular
.
copy
(
scope
.
model
);
//debugger;
scope
.
form
.
push
(
scope
.
form
.
push
(
{
{
type
:
"submit"
,
type
:
"submit"
,
title
:
"Save"
title
:
"Save"
}
}
);
);
scope
.
isCollapsed
=
false
;
// if fieldset in form, make it collapsable with template
scope
.
listnodeform
=
{};
if
(
scope
.
listnodes
[
0
]
||
scope
.
nodes
[
0
])
{
angular
.
forEach
(
scope
.
form
,
function
(
key
,
val
)
{
if
(
typeof
key
==
"object"
&&
key
.
type
==
"fieldset"
)
{
// change type to use shared template for form
key
.
type
=
"template"
;
key
.
templateUrl
=
"shared/templates/fieldset.html"
;
// check if fieldset in listnodes
if
(
scope
.
listnodes
.
indexOf
(
key
.
title
)
>=
0
)
{
scope
.
listnodeform
[
key
.
title
]
=
{};
scope
.
listnodeform
[
key
.
title
][
"schema"
]
=
{
"title"
:
angular
.
copy
(
key
.
title
),
"type"
:
"object"
,
"properties"
:
{},
"required"
:
[]
};
angular
.
forEach
(
scope
.
schema
.
properties
,
function
(
k
,
v
){
angular
.
forEach
(
key
.
items
,
function
(
item
){
if
(
item
.
key
==
v
){
scope
.
listnodeform
[
key
.
title
][
"schema"
][
"properties"
][
v
]
=
angular
.
copy
(
k
);
}
});
});
key
.
setType
=
"ListNode"
;
scope
.
listnodeform
[
key
.
title
][
"form"
]
=
[
angular
.
copy
(
key
)];
scope
.
listnodeform
[
key
.
title
][
"model"
]
=
{};
key
.
type
=
"list"
;
debugger
;
delete
key
.
templateUrl
;
delete
key
.
items
;
}
}
});
}
scope
.
isCollapsed
=
true
;
scope
.
object_id
=
scope
.
form_params
[
'object_id'
];
scope
.
object_id
=
scope
.
form_params
[
'object_id'
];
// open modal with given items and controller
scope
.
openmodal
=
function
(
listnode
,
nodeID
){
var
modalInstance
=
$modal
.
open
({
animation
:
false
,
templateUrl
:
'shared/templates/listnodeModalContent.html'
,
controller
:
'ListNodeModalCtrl'
,
size
:
'lg'
,
resolve
:
{
items
:
function
()
{
if
(
nodeID
){
scope
.
listnodeform
[
listnode
].
model
=
1
;
}
return
scope
.
listnodeform
[
listnode
];
}
}
});
modalInstance
.
result
.
then
(
function
(
childmodel
,
key
)
{
angular
.
forEach
(
childmodel
,
function
(
v
,
k
){
debugger
;
if
(
scope
.
model
[
k
]){
scope
.
model
[
k
][
v
.
idx
]
=
v
;
}
else
{
scope
.
model
[
k
]
=
{};
scope
.
model
[
k
][
v
.
idx
]
=
v
;
}
scope
.
$broadcast
(
'schemaFormRedraw'
);
});
debugger
;
});
};
return
generator
.
group
(
scope
);
return
generator
.
group
(
scope
);
};
};
generator
.
group
=
function
(
formObject
)
{
generator
.
group
=
function
(
formObject
)
{
...
@@ -84,11 +152,55 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
...
@@ -84,11 +152,55 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
}
}
return
$http
return
$http
.
post
(
generator
.
makeUrl
(
$scope
.
url
),
data
)
.
post
(
generator
.
makeUrl
(
$scope
.
url
),
data
)
//.then(function (res) {
//.then(function (res) {
// // todo: for now fake rest api returns 'ok' no data to
// // todo: for now fake rest api returns 'ok' no data to
// // manipulate on ui. therefor used just a log
// // manipulate on ui. therefor used just a log
// $log.info(res);
// $log.info(res);
//});
//});
};
};
return
generator
;
return
generator
;
});
});
\ No newline at end of file
/**
* ListNodeModalCtrl
* controller to use with openmodal function of Generator
* @params: $scope, $modalInstance, items
* @returns: return value used in openmodal's result function
*/
form_generator
.
controller
(
'ListNodeModalCtrl'
,
function
(
$scope
,
$modalInstance
,
items
)
{
for
(
var
key
in
items
)
$scope
[
key
]
=
items
[
key
];
$scope
.
onSubmit
=
function
(
form
){
// send form to modalinstance result function
$modalInstance
.
close
(
$scope
.
model
,
$scope
.
form
.
title
);
};
$scope
.
cancel
=
function
()
{
$modalInstance
.
dismiss
(
'cancel'
);
};
});
// todo: generic modal directive for all forms
//form_generator.directive('openmodal', ['Generator', function (Generator, $modal) {
// return {
// link: function ($modal) {
// var modalInstance = $modal.open({
// animation: false,
// templateUrl: 'shared/templates/modalContent.html',
// controller: 'ModalInstanceCtrl',
// size: 'lg',
// resolve: {
// items: function () {
// return "";
// }
// }
// });
//
// modalInstance.result.then(function (selectedItem) {
// $scope.selected = selectedItem;
// }, function () {
// $log.info('Modal dismissed at: ' + new Date());
// });
// }
// }
//}]);
\ No newline at end of file
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