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
4f104469
Commit
4f104469
authored
Nov 06, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix routes
generic url creator
parent
ed7dbd75
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
23 deletions
+92
-23
app_routes.js
app/app_routes.js
+27
-7
crud_controller.js
app/components/crud/crud_controller.js
+26
-11
list.html
app/components/crud/templates/list.html
+5
-4
sidebar.html
app/shared/templates/directives/sidebar.html
+1
-1
form_service.js
app/zetalib/forms/form_service.js
+33
-0
No files found.
app/app_routes.js
View file @
4f104469
...
@@ -10,22 +10,42 @@ app.config(['$routeProvider', function ($routeProvider, $route) {
...
@@ -10,22 +10,42 @@ app.config(['$routeProvider', function ($routeProvider, $route) {
templateUrl
:
'components/dashboard/dashboard.html'
,
templateUrl
:
'components/dashboard/dashboard.html'
,
controller
:
'DashCtrl'
controller
:
'DashCtrl'
})
})
.
when
(
'/crud/add/:model/:param/:id'
,
{
//.when('/crud/:model/:param/:id/add', {
// templateUrl: 'components/crud/templates/add.html',
// controller: 'CRUDAddEditCtrl'
//})
//.when('/crud/:model/:param/:id/edit/:key', {
// templateUrl: 'components/crud/templates/add.html',
// controller: 'CRUDAddEditCtrl'
//})
//.when('/crud/:model/:param/:id/list', {
// templateUrl: 'components/crud/templates/list.html',
// controller: 'CRUDListCtrl'
//})
//.when('/crud/:model/:param/:id/detail/:key', {
// templateUrl: 'components/crud/templates/show.html',
// controller: 'CRUDShowCtrl'
//})
// use crud without selected user
.
when
(
'/crud/:model/list'
,
{
templateUrl
:
'components/crud/templates/list.html'
,
controller
:
'CRUDListCtrl'
})
.
when
(
'/crud/:model/add'
,
{
templateUrl
:
'components/crud/templates/add.html'
,
templateUrl
:
'components/crud/templates/add.html'
,
controller
:
'CRUDAddEditCtrl'
controller
:
'CRUDAddEditCtrl'
})
})
.
when
(
'/crud/
edit/:model/:param/:id
/:key'
,
{
.
when
(
'/crud/
:model/edit
/:key'
,
{
templateUrl
:
'components/crud/templates/add.html'
,
templateUrl
:
'components/crud/templates/add.html'
,
controller
:
'CRUDAddEditCtrl'
controller
:
'CRUDAddEditCtrl'
})
})
.
when
(
'/crud/:model/:param/:id'
,
{
.
when
(
'/crud/:model/detail/:key'
,
{
templateUrl
:
'components/crud/templates/list.html'
,
controller
:
'CRUDListCtrl'
})
.
when
(
'/crud/detail/:model/:param/:id/:key'
,
{
templateUrl
:
'components/crud/templates/show.html'
,
templateUrl
:
'components/crud/templates/show.html'
,
controller
:
'CRUDShowCtrl'
controller
:
'CRUDShowCtrl'
})
})
// wf links just need model
.
when
(
'/:model/'
,
{
.
when
(
'/:model/'
,
{
templateUrl
:
'components/wf/templates/add.html'
,
templateUrl
:
'components/wf/templates/add.html'
,
controller
:
'WFAddEditCtrl'
controller
:
'WFAddEditCtrl'
...
...
app/components/crud/crud_controller.js
View file @
4f104469
...
@@ -7,10 +7,8 @@
...
@@ -7,10 +7,8 @@
'use strict'
;
'use strict'
;
var
crud
=
angular
.
module
(
'ulakbus.crud'
,
[
'ui.bootstrap'
,
'schemaForm'
,
'formService'
]);
var
crud
=
angular
.
module
(
'ulakbus.crud'
,
[
'ui.bootstrap'
,
'schemaForm'
,
'formService'
]);
/**
/**
* CRUDAddEditCtrl is a controller
* CRUDAddEditCtrl is a controller
* which provide a form with form generator.
* which provide a form with form generator.
...
@@ -18,7 +16,14 @@ var crud = angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formSe
...
@@ -18,7 +16,14 @@ var crud = angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formSe
crud
.
controller
(
'CRUDAddEditCtrl'
,
function
(
$scope
,
$rootScope
,
$location
,
$http
,
$log
,
$modal
,
$timeout
,
Generator
,
$routeParams
)
{
crud
.
controller
(
'CRUDAddEditCtrl'
,
function
(
$scope
,
$rootScope
,
$location
,
$http
,
$log
,
$modal
,
$timeout
,
Generator
,
$routeParams
)
{
$scope
.
url
=
'crud/'
;
$scope
.
url
=
'crud/'
;
$scope
.
form_params
=
{
'model'
:
$routeParams
.
model
,
param
:
$routeParams
.
param
,
id
:
$routeParams
.
id
};
angular
.
forEach
(
$routeParams
,
function
(
value
,
key
)
{
if
(
key
.
indexOf
(
'_id'
)
>
-
1
)
{
$scope
.
param
=
key
;
$scope
.
param_id
=
value
;
}
});
$scope
.
form_params
=
{
'model'
:
$routeParams
.
model
,
param
:
$scope
.
param
,
id
:
$scope
.
param_id
};
if
(
$routeParams
.
key
)
{
if
(
$routeParams
.
key
)
{
$scope
.
form_params
[
'object_id'
]
=
$routeParams
.
key
;
$scope
.
form_params
[
'object_id'
]
=
$routeParams
.
key
;
$scope
.
form_params
[
'cmd'
]
=
'edit'
;
$scope
.
form_params
[
'cmd'
]
=
'edit'
;
...
@@ -56,7 +61,14 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
...
@@ -56,7 +61,14 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
crud
.
controller
(
'CRUDListCtrl'
,
function
(
$scope
,
$rootScope
,
Generator
,
$routeParams
)
{
crud
.
controller
(
'CRUDListCtrl'
,
function
(
$scope
,
$rootScope
,
Generator
,
$routeParams
)
{
$scope
.
url
=
'crud/'
;
$scope
.
url
=
'crud/'
;
$scope
.
form_params
=
$routeParams
;
angular
.
forEach
(
$routeParams
,
function
(
value
,
key
)
{
if
(
key
.
indexOf
(
'_id'
)
>
-
1
)
{
$scope
.
param
=
key
;
$scope
.
param_id
=
value
;
}
});
//$scope.form_params = $routeParams;
$scope
.
form_params
=
{
'model'
:
$routeParams
.
model
,
param
:
$scope
.
param
,
id
:
$scope
.
param_id
};
if
(
$routeParams
.
nobjects
)
{
if
(
$routeParams
.
nobjects
)
{
$scope
.
nobjects
=
$routeParams
.
nobjects
;
$scope
.
nobjects
=
$routeParams
.
nobjects
;
...
@@ -76,19 +88,23 @@ crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeP
...
@@ -76,19 +88,23 @@ crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeP
*/
*/
crud
.
controller
(
'CRUDShowCtrl'
,
function
(
$scope
,
$rootScope
,
$location
,
Generator
,
$routeParams
)
{
crud
.
controller
(
'CRUDShowCtrl'
,
function
(
$scope
,
$rootScope
,
$location
,
Generator
,
$routeParams
)
{
$scope
.
url
=
'crud/'
;
$scope
.
url
=
'crud/'
;
angular
.
forEach
(
$routeParams
,
function
(
value
,
key
)
{
if
(
key
.
indexOf
(
'_id'
)
>
-
1
)
{
$scope
.
param
=
key
;
$scope
.
param_id
=
value
;
}
});
$scope
.
form_params
=
{
$scope
.
form_params
=
{
"id"
:
$
routeParams
.
id
,
"id"
:
$
scope
.
param_
id
,
"object_id"
:
$routeParams
.
key
,
"object_id"
:
$routeParams
.
key
,
"cmd"
:
"show"
,
"cmd"
:
"show"
,
param
:
$
routeParams
.
param
,
param
:
$
scope
.
param
,
"model"
:
$routeParams
.
model
"model"
:
$routeParams
.
model
};
};
// call generator's get_single_item func
// call generator's get_single_item func
Generator
.
get_single_item
(
$scope
).
then
(
function
(
res
)
{
Generator
.
get_single_item
(
$scope
).
then
(
function
(
res
)
{
// if no data to show redirect to add/edit view
//if (res.data.nobjects[0] === "-1") {
// $location.path('crud/' + $scope.form_params.model + '/' + $scope.form_params.param + '/' + $scope.form_params.id + '/edit');
//}
$scope
.
listobjects
=
{};
$scope
.
listobjects
=
{};
$scope
.
object
=
res
.
data
.
object
;
$scope
.
object
=
res
.
data
.
object
;
...
@@ -99,7 +115,6 @@ crud.controller('CRUDShowCtrl', function ($scope, $rootScope, $location, Generat
...
@@ -99,7 +115,6 @@ crud.controller('CRUDShowCtrl', function ($scope, $rootScope, $location, Generat
}
}
});
});
$scope
.
model
=
$routeParams
.
model
;
$scope
.
model
=
$routeParams
.
model
;
});
});
});
});
\ No newline at end of file
app/components/crud/templates/list.html
View file @
4f104469
<div
class=
"starter-template"
>
<div
class=
"starter-template"
>
<h1>
{{model}}
<h1>
{{model}}
<a
href=
"
#/crud/add/{{model}}/{{form_params.param}}/{{form_params.id
}}"
>
<a
href=
"
{{nobjects.addLink
}}"
>
<button
type=
"button"
class=
"btn btn-primary"
>
Ekle
</button>
<button
type=
"button"
class=
"btn btn-primary"
>
Ekle
</button>
</a>
</a>
</h1>
</h1>
...
@@ -33,16 +33,17 @@
...
@@ -33,16 +33,17 @@
</td>
</td>
<th
scope=
"row"
style=
"text-align:center"
>
{{$index}}
</th>
<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"
>
<td
ng-repeat=
"k in object track by $index"
ng-if=
"nobjects[0]=='-1' && $index>0"
>
<a
ng-href=
"#/crud/detail/{{model}}/{{form_params.param}}/{{form_params.id}}/{{object[0]}}"
>
{{object[1]}}
</a>
<!--<a ng-href="#/crud/detail/{{model}}/{{form_params.param}}/{{form_params.id}}/{{object[0]}}">{{object[1]}}</a>-->
<a
ng-href=
"{{object[2].detailLink}}"
>
{{object[1]}}
</a>
</td>
</td>
<td
ng-repeat=
"(key,value) in object track by $index"
ng-if=
"nobjects[0]!='-1' && $index>0"
>
<td
ng-repeat=
"(key,value) in object track by $index"
ng-if=
"nobjects[0]!='-1' && $index>0"
>
<a
ng-href=
"
#/crud/detail/{{model}}/{{form_params.param}}/{{form_params.id}}/{{object[0]
}}"
<a
ng-href=
"
{{object[2].detailLink
}}"
ng-if=
"$index==1"
>
{{object[key]}}
</a>
ng-if=
"$index==1"
>
{{object[key]}}
</a>
<span
ng-if=
"$index!=1"
>
{{object[key]}}
</span>
<span
ng-if=
"$index!=1"
>
{{object[key]}}
</span>
</td>
</td>
<td>
<td>
<a
ng-href=
"
#/crud/edit/{{model}}/{{form_params.param}}/{{form_params.id}}/{{object[0]
}}"
>
Edit
</a>
<a
ng-href=
"
{{object[2].editLink
}}"
>
Edit
</a>
<br>
<br>
</td>
</td>
</tr>
</tr>
...
...
app/shared/templates/directives/sidebar.html
View file @
4f104469
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
<a
ng-if=
"key == 'other'"
ng-href=
"#{{v.url}}"
<a
ng-if=
"key == 'other'"
ng-href=
"#{{v.url}}"
ng-click=
"breadcrumb([key, v.text], $event)"
>
{{v.text}}
</a>
ng-click=
"breadcrumb([key, v.text], $event)"
>
{{v.text}}
</a>
<a
ng-if=
"key == 'ogrenci' || key == 'personel'"
<a
ng-if=
"key == 'ogrenci' || key == 'personel'"
ng-href=
"#{{v.url}}/
{{v.param}}/
{{$root.selectedUser.key}}"
ng-href=
"#{{v.url}}/
list?{{v.param}}=
{{$root.selectedUser.key}}"
ng-click=
"breadcrumb([key, v.text], $event)"
>
{{v.text}}
</a>
ng-click=
"breadcrumb([key, v.text], $event)"
>
{{v.text}}
</a>
</li>
</li>
</ul>
</ul>
...
...
app/zetalib/forms/form_service.js
View file @
4f104469
...
@@ -213,6 +213,38 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
...
@@ -213,6 +213,38 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
return
newdatearray
.
join
(
'.'
);
return
newdatearray
.
join
(
'.'
);
}
}
};
};
generator
.
itemLinksGenerator
=
function
(
scope
,
itemlist
)
{
angular
.
forEach
(
itemlist
.
data
.
nobjects
,
function
(
value
,
key
)
{
//var detailLink = "#/" + scope.url + "detail/" + scope.form_params.model;
//var addLink = "#/" + scope.url + "add/" + scope.form_params.model;
//var editLink = "#/" + scope.url + "edit/" + scope.form_params.model;
function
makelink
(
page
)
{
if
(
value
===
'-1'
)
{
return
;
}
var
link
=
"#"
+
scope
.
url
+
scope
.
form_params
.
model
;
if
(
page
===
'edit/'
||
page
===
'detail/'
)
{
link
+=
"/"
+
page
+
value
[
0
];
}
if
(
page
===
'add/'
)
{
link
+=
"/add"
;
}
if
(
scope
.
form_params
.
param
)
{
link
+=
"?"
+
scope
.
form_params
.
param
+
"="
+
scope
.
form_params
.
id
;
}
return
link
;
}
itemlist
.
data
.
nobjects
.
addLink
=
makelink
(
"add/"
);
value
[
2
]
=
{
detailLink
:
makelink
(
"detail/"
),
editLink
:
makelink
(
"edit/"
)};
});
};
generator
.
get_form
=
function
(
scope
)
{
generator
.
get_form
=
function
(
scope
)
{
return
$http
return
$http
.
post
(
generator
.
makeUrl
(
scope
),
scope
.
form_params
)
.
post
(
generator
.
makeUrl
(
scope
),
scope
.
form_params
)
...
@@ -225,6 +257,7 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
...
@@ -225,6 +257,7 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
.
get
(
generator
.
makeUrl
(
scope
))
.
get
(
generator
.
makeUrl
(
scope
))
.
then
(
function
(
res
)
{
.
then
(
function
(
res
)
{
//generator.dateformatter(res);
//generator.dateformatter(res);
generator
.
itemLinksGenerator
(
scope
,
res
);
return
res
;
return
res
;
});
});
};
};
...
...
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