Commit 38722004 authored by Evren Kutar's avatar Evren Kutar

edit page model to form implementation

parent 1d1ea4c4
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
</a> </a>
</span> </span>
</h3> </h3>
<ng-include src="'shared/templates/nodeTable.html'" ng-if="node.lengthModels > 0"></ng-include> <ng-include src="'shared/templates/nodeTable.html'"></ng-include>
<hr> <hr>
</div> </div>
<div ng-repeat="node in ListNode"> <div ng-repeat="node in ListNode">
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</a> </a>
</span> </span>
</h3> </h3>
<ng-include src="'shared/templates/nodeTable.html'" ng-if="node.lengthModels > 0" ng-bind="node.lengthModels"></ng-include> <ng-include src="'shared/templates/nodeTable.html'"></ng-include>
<hr> <hr>
</div> </div>
......
...@@ -6,17 +6,17 @@ ...@@ -6,17 +6,17 @@
<ul class="nav in" id="side-menu"> <ul class="nav in" id="side-menu">
<!--<sidebar-search></sidebar-search>--> <!--<sidebar-search></sidebar-search>-->
<li ui-sref-active="active"> <li ui-sref-active="active">
<a href="#/dashboard"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a> <a href="#/dashboard"><i class="fa fa-dashboard fa-fw"></i> Panel</a>
</li> </li>
<li ng-repeat="(key, item) in menuItems" ng-class="{active: collapseVar == key}"> <li ng-repeat="(key, item) in menuItems" ng-class="{active: collapseVar == key}">
<a href="" ng-click="check(key)"><i class="fa fa-wrench fa-fw"></i> {{ item }}<span <a href="" ng-click="check(key)"><i class="fa fa-wrench fa-fw"></i> {{ item[0] }}<span
class="fa arrow"></span></a> class="fa arrow"></span></a>
<ul class="nav nav-second-level" collapse="collapseVar!={{key}}"> <ul class="nav nav-second-level" collapse="collapseVar!={{key}}">
<li ui-sref-active="active"> <li ui-sref-active="active">
<a href="#/{{item}}">List</a> <a href="#/{{item[1]}}">Listele</a>
</li> </li>
<li ui-sref-active="active"> <li ui-sref-active="active">
<a href="#/{{item}}/add">Add</a> <a href="#/{{item[1]}}/add">Ekle</a>
</li> </li>
</ul> </ul>
<!-- /.nav-second-level --> <!-- /.nav-second-level -->
......
...@@ -6,16 +6,16 @@ ...@@ -6,16 +6,16 @@
</label> </label>
<select ng-model="$$value$$" <select ng-model="$$value$$"
value="$$value$$"
ng-model-options="form.ngModelOptions" ng-model-options="form.ngModelOptions"
ng-disabled="form.readonly" ng-disabled="form.readonly"
sf-changed="form" sf-changed="form"
class="form-control {{form.fieldHtmlClass}}" class="form-control {{form.fieldHtmlClass}}"
schema-validate="form" schema-validate="form"
ng-options="item.value as item.name group by item.group for item in form.titleMap" ng-options="item.value as item.name for item in form.titleMap"
name="{{form.key.slice(-1)[0]}}"> name="{{form.key.slice(-1)[0]}}">
</select> </select>
<div class="help-block" sf-message="form.description"></div> <div class="help-block" sf-message="form.description"></div>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
......
<table class="table table-bordered" style="background-color:#fff;"> <table class="table table-bordered" style="background-color:#fff;">
<thead> <thead>
<tr> <tr>
<th colspan="2">#</th> <th colspan="2">
<th ng-repeat="(key,value) in node.fields">{{ value.title }}</th> <label>
<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">
Hepsini Seç
</label>
</th>
<th ng-repeat="(key,value) in node.form">{{ value }}</th>
<th>action</th> <th>action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody ng-class="{true: '', false: 'hidden'}[node.lengthModels > 0]">
<tr> <tr>
<td width="60"> <td width="60">
<label> <label>
...@@ -14,11 +19,11 @@ ...@@ -14,11 +19,11 @@
</label> </label>
</td> </td>
<th scope="row" style="text-align:center">1</th> <th scope="row" style="text-align:center">1</th>
<td ng-repeat="(key,value) in node.models">{{ value.value }}</td> <td ng-repeat="value in node.model">{{ value }}</td>
<td> <td>
<a ng-href="#/crud/{{model}}/edit/{{object.key}}">Edit</a><br> <button modal-for-nodes="{{node.title}},ListNode">Edit</button><br>
<a ng-href="#/crud/{{model}}/{{object.key}}">Show</a> <button>Show</button>
<a ng-href="#/crud/{{model}}/{{object.key}}">Delete</a> <button>Delete</button>
</td> </td>
</tr> </tr>
</tbody> </tbody>
......
...@@ -70,29 +70,35 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal ...@@ -70,29 +70,35 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
if (k.type == 'model') { if (k.type == 'model') {
var formitem = scope.form[scope.form.indexOf(v)]; var formitem = scope.form[scope.form.indexOf(v)];
var modelscope = {"url": scope.url, "form_params": {model: k.title}};
formitem = { formitem = {
"type": "template", "type": "template",
"templateUrl": "shared/templates/foreignKey.html", "templateUrl": "shared/templates/foreignKey.html",
"title": k.title "title": k.title,
"titleMap": generator.get_list(modelscope).then(function (res) {
};
var modelscope = {"url": scope.url, "form_params": {model: k.title}};
// get model objects from db and add to select list
generator.get_list(modelscope).then(function (res) {
formitem.titleMap = []; formitem.titleMap = [];
angular.forEach(res.data.objects, function (item) { angular.forEach(res.data.objects, function (item) {
formitem.titleMap.push({ formitem.titleMap.push({
"value": item.key, "value": item.key,
"name": item.data.name ? item.data.name : item.data.username "name": item.data.name ? item.data.name : item.data.username
}); });
}); });
}),
onChange: function(modelValue,form) {
scope.model[v] = modelValue;
}
};
// get model objects from db and add to select list
});
scope.form[scope.form.indexOf(v)] = formitem; scope.form[scope.form.indexOf(v)] = formitem;
scope.$broadcast('schemaFormRedraw');
// todo: make lines below work properly
//if (scope.model[v].indexOf("TMP_") > -1) {
// scope.model[v] = null;
//}
} }
if (k.type == 'ListNode' || k.type == 'Node') { if (k.type == 'ListNode' || k.type == 'Node') {
...@@ -103,13 +109,20 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal ...@@ -103,13 +109,20 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
title: k.title, title: k.title,
form: [], form: [],
schema: {properties: {}, required: [], title: k.title, type: "object", formType: k.type}, schema: {properties: {}, required: [], title: k.title, type: "object", formType: k.type},
model: {},
url: scope.url url: scope.url
}; };
debugger;
scope[k.type][k.title].model = scope.model[v] != null ? scope.model[v] : {};
angular.forEach(k.schema , function (item) { angular.forEach(k.schema , function (item) {
scope[k.type][k.title].schema.properties[item.name] = item; scope[k.type][k.title].schema.properties[item.name] = item;
scope[k.type][k.title].model[item.name] = item.value;
// if model is empty object then fill it with scope model item
//if (scope[k.type][k.title] == {}){
// scope[k.type][k.title].model[item.name] = item.value;
//}
// prepare required fields // prepare required fields
if (item.required == true && item.name != 'idx') { if (item.required == true && item.name != 'idx') {
......
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