Commit 38722004 authored by Evren Kutar's avatar Evren Kutar

edit page model to form implementation

parent 1d1ea4c4
......@@ -8,7 +8,7 @@
</a>
</span>
</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>
</div>
<div ng-repeat="node in ListNode">
......@@ -19,7 +19,7 @@
</a>
</span>
</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>
</div>
......
......@@ -6,17 +6,17 @@
<ul class="nav in" id="side-menu">
<!--<sidebar-search></sidebar-search>-->
<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 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>
<ul class="nav nav-second-level" collapse="collapseVar!={{key}}">
<li ui-sref-active="active">
<a href="#/{{item}}">List</a>
<a href="#/{{item[1]}}">Listele</a>
</li>
<li ui-sref-active="active">
<a href="#/{{item}}/add">Add</a>
<a href="#/{{item[1]}}/add">Ekle</a>
</li>
</ul>
<!-- /.nav-second-level -->
......
......@@ -6,16 +6,16 @@
</label>
<select ng-model="$$value$$"
value="$$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"
ng-options="item.value as item.name 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">
......
<table class="table table-bordered" style="background-color:#fff;">
<thead>
<tr>
<th colspan="2">#</th>
<th ng-repeat="(key,value) in node.fields">{{ value.title }}</th>
<th colspan="2">
<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>
</tr>
</thead>
<tbody>
<tbody ng-class="{true: '', false: 'hidden'}[node.lengthModels > 0]">
<tr>
<td width="60">
<label>
......@@ -14,11 +19,11 @@
</label>
</td>
<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>
<a ng-href="#/crud/{{model}}/edit/{{object.key}}">Edit</a><br>
<a ng-href="#/crud/{{model}}/{{object.key}}">Show</a>
<a ng-href="#/crud/{{model}}/{{object.key}}">Delete</a>
<button modal-for-nodes="{{node.title}},ListNode">Edit</button><br>
<button>Show</button>
<button>Delete</button>
</td>
</tr>
</tbody>
......
......@@ -70,29 +70,35 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
if (k.type == 'model') {
var formitem = scope.form[scope.form.indexOf(v)];
var modelscope = {"url": scope.url, "form_params": {model: k.title}};
formitem = {
"type": "template",
"templateUrl": "shared/templates/foreignKey.html",
"title": k.title
"title": k.title,
"titleMap": 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
});
});
}),
onChange: function(modelValue,form) {
scope.model[v] = modelValue;
}
};
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 = [];
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;
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') {
......@@ -103,13 +109,20 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
title: k.title,
form: [],
schema: {properties: {}, required: [], title: k.title, type: "object", formType: k.type},
model: {},
url: scope.url
};
debugger;
scope[k.type][k.title].model = scope.model[v] != null ? scope.model[v] : {};
angular.forEach(k.schema , function (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
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