Commit 764d8593 authored by Evren Kutar's avatar Evren Kutar

add listnode item to table and edit correct item

parent 2072228e
<div class="tablescroll"> <div class="tablescroll">
<table class="table table-bordered" style="background-color:#fff;"> <table class="table table-bordered" style="background-color:#fff;">
<thead> <thead>
<tr> <tr ng-if="node.schema.formType=='Node'">
<!--<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.model">{{ key }}</th>
<th>İşlem</th>
</tr>
<tr ng-if="node.schema.formType=='ListNode'">
<th colspan="2"> <th colspan="2">
<label> <label>
<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;"> <input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">
Hepsini Seç Hepsini Seç
</label> </label>
</th> </th>
<th ng-repeat="(key,value) in node.model">{{ key }}</th> <th ng-repeat="(key,value) in node.model[0]">{{ key }}</th>
<th>action</th> <th>İşlem</th>
</tr> </tr>
</thead> </thead>
<tbody ng-class="{hidden: node.lengthModels < 1}"> <tbody ng-class="{hidden: node.lengthModels < 1}">
<tr ng-if="node.schema.formType=='Node'"> <tr ng-if="node.schema.formType=='Node'">
<td width="60"> <!--<td width="60">-->
<label> <!--<label>-->
<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;"> <!--<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">-->
</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="value in node.model">{{ value }}</td> <td ng-repeat="value in node.model">{{ value }}</td>
<td> <td>
<button modal-for-nodes="{{node.schema.model_name}},{{node.schema.formType}},edit">Edit</button><br> <button modal-for-nodes="{{node.schema.model_name}},{{node.schema.formType}},edit">Düzenle</button><br>
<button>Show</button> <button>Sil</button>
<button>Delete</button>
</td> </td>
</tr> </tr>
...@@ -35,12 +44,11 @@ ...@@ -35,12 +44,11 @@
<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;"> <input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">
</label> </label>
</td> </td>
<th scope="row" style="text-align:center">1</th> <th scope="row" style="text-align:center">{{$index+1}}</th>
<td ng-repeat="value in listnodemodel">{{ value }}</td> <td ng-repeat="(k, v) in listnodemodel">{{ v }}</td>
<td> <td>
<button modal-for-nodes="{{node.schema.model_name}},{{node.schema.formType}},edit">Edit</button><br> <button modal-for-nodes="{{node.schema.model_name}},{{node.schema.formType}},edit,{{$index}}">Düzenle</button><br>
<button>Show</button> <button>Sil</button>
<button>Delete</button>
</td> </td>
</tr> </tr>
......
...@@ -126,7 +126,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal ...@@ -126,7 +126,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
}; };
if (scope.model[v] == null) { if (scope.model[v] == null) {
scope[k.type][v].model = k.type == 'Node' ? [] : {}; scope[k.type][v].model = k.type == 'Node' ? {} : [];
} else { } else {
scope[k.type][v].model = scope.model[v]; scope[k.type][v].model = scope.model[v];
} }
...@@ -286,34 +286,38 @@ form_generator.directive('modalForNodes', function ($modal) { ...@@ -286,34 +286,38 @@ form_generator.directive('modalForNodes', function ($modal) {
resolve: { resolve: {
items: function () { items: function () {
var attribs = attributes['modalForNodes'].split(','); var attribs = attributes['modalForNodes'].split(',');
debugger;
// get node from parent scope catch with attribute // get node from parent scope catch with attribute
var node = angular.copy(scope.$parent[attribs[1]][attribs[0]]); var node = angular.copy(scope.$parent[attribs[1]][attribs[0]]);
if(attribs[2] == 'add'){ if(attribs[2] == 'add'){
node.model = {}; node.model = {};
} }
if(attribs[3]){
// if listnode catch edit object with index
node.model=node.model[attribs[3]];
}
// tell result.then function which item to edit
node.edit = attribs[3];
return node; return node;
} }
} }
}); });
modalInstance.result.then(function (childmodel, key) { modalInstance.result.then(function (childmodel, key) {
// subfix will be removed
//var subfix = scope.schema.title.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
if (childmodel.schema.formType == 'Node') { if (childmodel.schema.formType == 'Node') {
//scope.$parent.model[childmodel.schema.model_name] = childmodel.model;
scope.$parent[childmodel.schema.formType][childmodel.schema.model_name].model = childmodel.model; scope.$parent[childmodel.schema.formType][childmodel.schema.model_name].model = childmodel.model;
} }
if (childmodel.schema.formType == 'ListNode') { if (childmodel.schema.formType == 'ListNode') {
if(childmodel.edit){
if (scope.$parent.model[childmodel.schema.model_name] == null) { scope.$parent[childmodel.schema.formType][childmodel.schema.model_name].model[childmodel.edit] = childmodel.model;
scope.$parent.model[childmodel.schema.model_name] = []; } else {
scope.$parent[childmodel.schema.formType][childmodel.schema.model_name].model.push(childmodel.model);
} }
//scope.$parent.model[childmodel.schema.model_name].push(childmodel.model);
scope.$parent[childmodel.schema.formType][childmodel.schema.model_name].model.push(childmodel.model);
} }
scope.$parent[childmodel.schema.formType][childmodel.schema.model_name].lengthModels += 1; scope.$parent[childmodel.schema.formType][childmodel.schema.model_name].lengthModels += 1;
......
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