Commit 72700504 authored by Evren Kutar's avatar Evren Kutar

Merge branch 'crudview_works'

parents 12e3097e 5e87049c
...@@ -38,12 +38,14 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt ...@@ -38,12 +38,14 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
if (form.$valid) { if (form.$valid) {
Generator.submit($scope) Generator.submit($scope)
.success(function (data) { .success(function (data) {
$location.path('/crud/' + $scope.form_params.model).search(data); $location.path('/crud/' + $scope.form_params.model + '/' + $scope.form_params.param + '/' + $scope.form_params.id).search(data);
}) })
.error(function (data) { .error(function (data) {
$scope.message = data.title; $scope.message = data.title;
}); });
} }
}; };
}); });
...@@ -83,10 +85,9 @@ crud.controller('CRUDShowCtrl', function ($scope, $rootScope, $location, Generat ...@@ -83,10 +85,9 @@ crud.controller('CRUDShowCtrl', function ($scope, $rootScope, $location, Generat
}; };
// 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) {
console.log(res.data.nobjects);
// if no data to show redirect to add/edit view // if no data to show redirect to add/edit view
//if (res.data.nobjects[0] === "-1") { //if (res.data.nobjects[0] === "-1") {
// $location.path('crud/' + $scope.form_params.model + '/' + $scope.form_params.param + '/' + $scope.form_params.object_id + '/edit'); // $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;
...@@ -96,7 +97,7 @@ crud.controller('CRUDShowCtrl', function ($scope, $rootScope, $location, Generat ...@@ -96,7 +97,7 @@ crud.controller('CRUDShowCtrl', function ($scope, $rootScope, $location, Generat
$scope.listobjects[key] = value; $scope.listobjects[key] = value;
delete $scope.object[key]; delete $scope.object[key];
} }
}); debugger; });
$scope.model = $routeParams.model; $scope.model = $routeParams.model;
......
...@@ -56,7 +56,7 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST ...@@ -56,7 +56,7 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST
// when clicked mark as read notification // when clicked mark as read notification
// it can be list of notifications // it can be list of notifications
$scope.markAsRead = function (items) { $scope.markAsRead = function (items) {
$http.post(RESTURL.url+"notify", {ignoreLoadingBar: true, read: items}) $http.post(RESTURL.url+"notify", {ignoreLoadingBar: true, read: [items]})
.success(function (data) { .success(function (data) {
console.log(data); console.log(data);
}); });
......
...@@ -52,11 +52,17 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form ...@@ -52,11 +52,17 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
* prepareforms checks input types and convert if necessary * prepareforms checks input types and convert if necessary
*/ */
angular.forEach(scope.schema.properties, function (v, k) { angular.forEach(scope.schema.properties, function (v, k) {
// check if type is date and if type date found change it to string
// generically change _id fields model value
if (k == scope.form_params.param) {
scope.model[k] = scope.form_params.id;
scope.form.splice(scope.form.indexOf(k), 1);
return;
}
if (v.type === 'submit' || v.type === 'button') { if (v.type === 'submit' || v.type === 'button') {
//k.type = 'button';
debugger;
scope.form[scope.form.indexOf(k)] = { scope.form[scope.form.indexOf(k)] = {
type: v.type, type: v.type,
title: v.title, title: v.title,
...@@ -64,6 +70,8 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form ...@@ -64,6 +70,8 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
}; };
} }
// check if type is date and if type date found change it to string
if (v.type === 'date') { if (v.type === 'date') {
v.type = 'string'; v.type = 'string';
scope.model[k] = generator.dateformatter(scope.model[k]); scope.model[k] = generator.dateformatter(scope.model[k]);
...@@ -98,7 +106,7 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form ...@@ -98,7 +106,7 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
if (v.type === 'model') { if (v.type === 'model') {
var formitem = scope.form[scope.form.indexOf(k)]; var formitem = scope.form[scope.form.indexOf(k)];
var modelscope = {"url": scope.url, "form_params": {model: v.model_name, param: scope.form_params.param, id: scope.form_params.id}}; var modelscope = {"url": scope.url, "form_params": {model: v.model_name}};
formitem = { formitem = {
type: "template", type: "template",
...@@ -183,16 +191,10 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form ...@@ -183,16 +191,10 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
} }
// generically change _id fields model value
if (k == scope.form_params.param) { debugger;
scope.model[k] = scope.form_params.id;
scope.form.splice(scope.form.indexOf(k), 1);
}
}); });
console.log(scope.form);
return scope; return scope;
}; };
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -261,7 +263,6 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form ...@@ -261,7 +263,6 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
}; };
// custom form submit for custom submit buttons // custom form submit for custom submit buttons
generator.genericSubmit = function ($scope, data) { generator.genericSubmit = function ($scope, data) {
debugger;
return $http.post(generator.makePostUrl($scope), data); return $http.post(generator.makePostUrl($scope), data);
}; };
generator.submit = function ($scope) { generator.submit = function ($scope) {
...@@ -393,7 +394,7 @@ form_generator.directive('modalForNodes', function ($modal) { ...@@ -393,7 +394,7 @@ form_generator.directive('modalForNodes', function ($modal) {
* @return: openmodal directive * @return: openmodal directive
*/ */
form_generator.directive('addModalForLinkedModel', function ($modal, Generator) { form_generator.directive('addModalForLinkedModel', function ($modal, $route, Generator) {
return { return {
link: function (scope, element) { link: function (scope, element) {
element.on('click', function () { element.on('click', function () {
...@@ -405,7 +406,7 @@ form_generator.directive('addModalForLinkedModel', function ($modal, Generator) ...@@ -405,7 +406,7 @@ form_generator.directive('addModalForLinkedModel', function ($modal, Generator)
resolve: { resolve: {
items: function () { items: function () {
return Generator.get_form({ return Generator.get_form({
url: 'crud', url: 'crud/',
form_params: {'model': scope.form.model_name, "cmd": "add"} form_params: {'model': scope.form.model_name, "cmd": "add"}
}); });
} }
...@@ -414,6 +415,7 @@ form_generator.directive('addModalForLinkedModel', function ($modal, Generator) ...@@ -414,6 +415,7 @@ form_generator.directive('addModalForLinkedModel', function ($modal, Generator)
modalInstance.result.then(function (childmodel, key) { modalInstance.result.then(function (childmodel, key) {
Generator.submit(childmodel); Generator.submit(childmodel);
$route.reload();
}); });
}); });
} }
...@@ -440,7 +442,7 @@ form_generator.directive('editModalForLinkedModel', function ($modal, Generator) ...@@ -440,7 +442,7 @@ form_generator.directive('editModalForLinkedModel', function ($modal, Generator)
resolve: { resolve: {
items: function () { items: function () {
return Generator.get_form({ return Generator.get_form({
url: 'crud', url: 'crud/',
form_params: {'model': scope.form.title, "cmd": "add"} form_params: {'model': scope.form.title, "cmd": "add"}
}); });
} }
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<title>ULAKBUS</title> <title>ULAKBUS</title>
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="/img/favicon.ico">
<link rel="stylesheet" href="css/app.css"> <link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="css/roboto/roboto.css"> <link rel="stylesheet" href="css/roboto/roboto.css">
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
<body> <body>
<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0" ng-if="$root.loggedInUser"> <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0" ng-if="$root.loggedInUser">
<collapse-menu></collapse-menu>
<ul class="header-menu"> <ul class="header-menu">
<li><a href="">Mesajlar</a></li> <li><a href="">Mesajlar</a></li>
<li><a href="">Görevler</a></li> <li><a href="">Görevler</a></li>
...@@ -59,7 +61,7 @@ ...@@ -59,7 +61,7 @@
<script src="bower_components/jquery.min.js"></script> <script src="bower_components/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.18/angular.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.20/angular.min.js"></script>
<script src="bower_components/components.js"></script> <script src="bower_components/components.js"></script>
<script src="shared/translations.js"></script> <script src="shared/translations.js"></script>
<script src="templates.js"></script> <script src="templates.js"></script>
......
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